Skip to content

Commit

Permalink
fix: dynamic render empty-text
Browse files Browse the repository at this point in the history
  • Loading branch information
Jambo2018 committed Sep 16, 2023
1 parent d159a7c commit 7b0c503
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
21 changes: 20 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export default class TypingAsstPlugin extends Plugin {
});

this.registerDomEvent(document, "keydown", (evt: KeyboardEvent) => {
renderEmptyText()
if (this.commands.isVisible()) {
const { key } = evt;
if (
Expand Down Expand Up @@ -249,12 +250,14 @@ export default class TypingAsstPlugin extends Plugin {
};
this.registerEvent(
this.app.workspace.on("active-leaf-change", () => {

if (this.scrollArea) {
this.scrollArea.removeEventListener("scroll", scrollEvent);
}
const view =
this.app.workspace.getActiveViewOfType(MarkdownView);
if (!view) return;

this.scrollArea =
view.containerEl.querySelector(".cm-scroller") ?? undefined;
const appHeader = document.querySelector(".titlebar");
Expand Down Expand Up @@ -303,11 +306,27 @@ export default class TypingAsstPlugin extends Plugin {
}
});

const renderEmptyText = () => {
const view =
this.app.workspace.getActiveViewOfType(MarkdownView);
if (!view) return;
setTimeout(() => {
const activeEle = view.containerEl.querySelector('.cm-active')
activeEle?.setAttribute('promote-text', "💡Please input ‘ / ’ for more commands...");
}, 50);
}
this.registerDomEvent(document, "pointermove", () => {
renderEmptyText()
});
this.registerDomEvent(document, "click", () => {
renderEmptyText()
});

this.registerMarkdownCodeBlockProcessor(CODE_LAN, (source, el, ctx) => {
const bookmark = generateBookMark(source);
el?.appendChild(bookmark);
});
}

onunload() {}
onunload() { }
}
8 changes: 4 additions & 4 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,18 @@
bottom: 0;
left: 3px;
color: var(--empty-prompt);
content: "💡Please input ‘ / ’ for more commands...";
content: attr(promote-text);
}

.link-input input {
width: 100%;
}

.scroll-disable {
overflow: hidden;
margin-right: 12px;
overflow: hidden;
}

.display-none{
.display-none {
display: none;
}
}

0 comments on commit 7b0c503

Please sign in to comment.