Skip to content

Commit

Permalink
fix: active editor issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Quorafind committed May 24, 2024
1 parent 4066184 commit 357e7ae
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/component/DailyNote.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import type DailyNoteViewPlugin from "../dailyNoteViewIndex";
import { TAbstractFile, TFile, WorkspaceLeaf } from "obsidian";
import { DailyNoteEditor, spawnLeafView } from "../leafView";
import { spawnLeafView } from "../leafView";
import { inview } from "svelte-inview";
import { genId } from "../utils/utils";
Expand All @@ -16,7 +16,7 @@
let id: string;
let createdLeaf: WorkspaceLeaf;
let dnEditor: DailyNoteEditor;
// let dnEditor: DailyNoteEditor;
$: if (editorEl) {
showEditor();
Expand All @@ -30,7 +30,7 @@
title = file.basename;
[createdLeaf, dnEditor] = spawnLeafView(plugin, editorEl, leaf);
[createdLeaf] = spawnLeafView(plugin, editorEl, leaf);
createdLeaf.setPinned(true);
createdLeaf.openFile(file, {
Expand All @@ -48,14 +48,14 @@
} else plugin.app.workspace.getLeaf(false).openFile(file);
}
function hideHandler(event: any) {
console.log(event);
const {scrollDirection} = event.detail;
if (scrollDirection.vertical === "up") {
rendered = false;
dnEditor.hide();
}
}
// function hideHandler(event: any) {
// console.log(event);
// const {scrollDirection} = event.detail;
// if (scrollDirection.vertical === "up") {
// rendered = false;
// dnEditor.hide();
// }
// }
function showHandler(event: any) {
const {scrollDirection} = event.detail;
Expand Down
10 changes: 8 additions & 2 deletions src/dailyNoteViewIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
TFile,
Workspace,
WorkspaceContainer, WorkspaceItem,
WorkspaceLeaf, TAbstractFile, Scope, Notice, View, Constructor
WorkspaceLeaf, TAbstractFile, Scope, Notice
} from 'obsidian';
import DailyNoteEditorView from "./component/DailyNoteEditorView.svelte";
import { around } from "monkey-around";
Expand Down Expand Up @@ -156,7 +156,13 @@ export default class DailyNoteViewPlugin extends Plugin {
function (e: WorkspaceLeaf, t?: any) {
if ((e as any).parentLeaf) {
(e as any).parentLeaf.activeTime = 1700000000000;
return next.call(this, (e as any).parentLeaf, t);


next.call(this, (e as any).parentLeaf, t);
if (e.view.editMode) {
this.activeEditor = e.view;
}
return;
}
next.call(this, e, t);
},
Expand Down
107 changes: 106 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
@@ -1 +1,106 @@
.daily-note.svelte-18gimyz.svelte-18gimyz{margin-bottom:var(--size-4-5);padding-bottom:var(--size-4-5)}.daily-note.svelte-18gimyz:has(.is-readable-line-width) .daily-note-title.svelte-18gimyz{max-width:var(--file-line-width);margin-left:auto;margin-right:auto}.daily-note-title.svelte-18gimyz.svelte-18gimyz{display:flex;justify-content:space-between;margin-top:var(--size-4-12)}.daily-node-icon.svelte-18gimyz.svelte-18gimyz{width:var(--size-4-8);height:var(--size-4-8);cursor:pointer}.daily-node-icon.svelte-18gimyz.svelte-18gimyz:hover{background-color:var(--background-modifier-hover)}.dn-stock.svelte-101lm3m{height:1000px;width:100%}.no-more-text.svelte-101lm3m{margin-left:auto;margin-right:auto;text-align:center}.dn-blank-day.svelte-101lm3m{display:flex;margin-left:auto;margin-right:auto;max-width:var(--file-line-width);color:var(--color-base-40);padding-top:20px;padding-bottom:20px;transition:all .3s}.dn-blank-day.svelte-101lm3m:hover{padding-top:40px;padding-bottom:40px;transition:padding .3s}.dn-blank-day-text.svelte-101lm3m{margin-left:auto;margin-right:auto;text-align:center}.dn-editor .cm-scroller{padding:unset}.dn-editor .workspace-leaf{all:unset}.dn-editor .dn-content{display:none}.dn-editor .workspace-leaf,.dn-editor .workspace-split{height:100%;width:100%}.dn-editor .markdown-source-view.mod-cm6 .cm-editor{min-height:auto}.dn-editor .cm-content{padding-bottom:0!important;padding-top:0!important}.dn-editor .view-content{background:none!important}.dn-editor .cm-scroller{padding:0!important;overflow-y:clip}.daily-note-view .daily-note-container:before{content:"";display:block;height:1px;width:var(--file-line-width);margin-bottom:30px;margin-left:auto;margin-right:auto;background-color:var(--color-base-25)}.daily-note-view .daily-note-container:first-child:before{height:0px}.is-popout-window .dn-editor .dn-content{margin:0;border-radius:var(--he-popover-border-radius);overflow:hidden;height:auto}.is-popout-window .dn-editor .workspace-leaf,.is-popout-window .dn-editor .workspace-split{height:auto;width:100%}.is-popout-window .dn-editor .cm-scroller,.is-popout-window .dn-editor .markdown-source-view.mod-cm6,.is-popout-window .dn-editor .view-content,.is-popout-window .dn-editor .workspace-leaf-content{height:auto}.daily-note-view .embedded-backlinks{min-height:unset!important}.daily-note-view{display:flex;flex-direction:column;gap:var(--size-4-4)}body.daily-notes-hide-frontmatter .daily-note-view .markdown-source-view.is-live-preview.show-properties .metadata-container,body.daily-notes-hide-backlinks .daily-note-view .embedded-backlinks{display:none}
.daily-note.svelte-18gimyz.svelte-18gimyz{margin-bottom:var(--size-4-5);padding-bottom:var(--size-4-5)}.daily-note.svelte-18gimyz:has(.is-readable-line-width) .daily-note-title.svelte-18gimyz{max-width:var(--file-line-width);margin-left:auto;margin-right:auto}.daily-note-title.svelte-18gimyz.svelte-18gimyz{display:flex;justify-content:space-between;margin-top:var(--size-4-12)}.daily-node-icon.svelte-18gimyz.svelte-18gimyz{width:var(--size-4-8);height:var(--size-4-8);cursor:pointer}.daily-node-icon.svelte-18gimyz.svelte-18gimyz:hover{background-color:var(--background-modifier-hover)}.dn-stock.svelte-101lm3m{height:1000px;width:100%}.no-more-text.svelte-101lm3m{margin-left:auto;margin-right:auto;text-align:center}.dn-blank-day.svelte-101lm3m{display:flex;margin-left:auto;margin-right:auto;max-width:var(--file-line-width);color:var(--color-base-40);padding-top:20px;padding-bottom:20px;transition:all 300ms}.dn-blank-day.svelte-101lm3m:hover{padding-top:40px;padding-bottom:40px;transition:padding 300ms}.dn-blank-day-text.svelte-101lm3m{margin-left:auto;margin-right:auto;text-align:center}.dn-editor {
/*overflow-y: hidden;*/
}

.dn-editor .cm-scroller {
/*overflow-y: hidden;*/
padding: unset;
}

.dn-editor .workspace-leaf {
all: unset;
}

.dn-editor .dn-content {
display: none;
/*margin: 0;*/
/*border-radius: var(--he-popover-border-radius);*/
/*overflow: hidden;*/
/*height: 100%;*/
}

.dn-editor .workspace-leaf,
.dn-editor .workspace-split {
height: 100%;
width: 100%;
}

.dn-editor .markdown-source-view.mod-cm6 .cm-editor {
min-height: auto;
}

.dn-editor .cm-content {
padding-bottom: 0 !important;
padding-top: 0 !important;
}

.dn-editor .view-content {
background: none !important;
}

.dn-editor .cm-scroller {
padding: 0 !important;
overflow-y: clip;
}

.daily-note-view .daily-note-container::before {
content: "";
display: block;
height: 1px;
width: var(--file-line-width);
margin-bottom: 30px;
margin-left: auto;
margin-right: auto;
background-color: var(--color-base-25);
}

.daily-note-view .daily-note-container:first-child::before {
height: 0px;
}

.is-popout-window .dn-editor .dn-content {
margin: 0;
border-radius: var(--he-popover-border-radius);
overflow: hidden;
height: auto;
}

.is-popout-window .dn-editor .workspace-leaf,
.is-popout-window .dn-editor .workspace-split {
height: auto;
width: 100%;
}

.is-popout-window .dn-editor .cm-scroller {
height: auto;
}

.is-popout-window .dn-editor .markdown-source-view.mod-cm6 {
height: auto;
}

.is-popout-window .dn-editor .view-content {
height: auto;
}

.is-popout-window .dn-editor .workspace-leaf-content {
height: auto;
}

.daily-note-view .embedded-backlinks {
min-height: unset !important;
}

.daily-note-view {
display: flex;
flex-direction: column;
gap: var(--size-4-4);
}

body.daily-notes-hide-frontmatter .daily-note-view .markdown-source-view.is-live-preview.show-properties .metadata-container {
display: none;
}

body.daily-notes-hide-backlinks .daily-note-view .embedded-backlinks {
display: none;
}

0 comments on commit 357e7ae

Please sign in to comment.