Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
style(markdown): size the slash command list as the text editor's
Elian Doran7312f5053c60
diff --git a/apps/client/src/widgets/react/NoteAutocomplete.css b/apps/client/src/widgets/react/NoteAutocomplete.cssindex c12e93ad6f..3ec32db584 100644--- a/apps/client/src/widgets/react/NoteAutocomplete.css+++ b/apps/client/src/widgets/react/NoteAutocomplete.css@@ -282,3 +282,17 @@background: var(--cmd-button-keyboard-shortcut-background, transparent);color: var(--cmd-button-keyboard-shortcut-color, inherit) !important;}++/*+ * The `/` list of the text and Markdown editors, at a width that fits all but the longest+ * descriptions, and given more height than a list usually is: it is long, and the query only+ * narrows it.+ */+.note-autocomplete-menu.slash-command-menu {+ width: 350px;+ max-width: calc(100vw - 10px);++ > .tn-menu-scroll {+ max-height: var(--ck-mention-list-max-height);+ }+}diff --git a/apps/client/src/widgets/type_widgets/markdown/completions.spec.ts b/apps/client/src/widgets/type_widgets/markdown/completions.spec.tsindex 9129aef4bc..4b22d2f660 100644--- a/apps/client/src/widgets/type_widgets/markdown/completions.spec.ts+++ b/apps/client/src/widgets/type_widgets/markdown/completions.spec.ts@@ -295,6 +295,8 @@ describe("useSlashCommands", () => {// Found by its title, without the slash.await vi.waitFor(() => expect(rows().map((row) => row.textContent)).toEqual([ expect.stringContaining("titles.tip") ]));expect(rows()[0]?.querySelector("b")?.textContent).toBe("tip");+ // Sized as the text editor's `/` list is.+ expect(document.querySelector(".note-autocomplete-menu.slash-command-menu")).not.toBeNull();// Opened on the best match, so Enter runs it.editor.contentDOM.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }));diff --git a/apps/client/src/widgets/type_widgets/markdown/completions.tsx b/apps/client/src/widgets/type_widgets/markdown/completions.tsxindex feb725d633..08cda7f1e0 100644--- a/apps/client/src/widgets/type_widgets/markdown/completions.tsx+++ b/apps/client/src/widgets/type_widgets/markdown/completions.tsx@@ -354,6 +354,7 @@ function createSlashCommandList(commands: () => SlashCommand[]) {{...list}query={state.match.query}source={async (query) => filterCommandEntries(commands(), query)}+ className="slash-command-menu"onPick={(entry) => state.commit(entry.apply)}/>));diff --git a/apps/client/src/widgets/type_widgets/text/mention_list_view.css b/apps/client/src/widgets/type_widgets/text/mention_list_view.cssdeleted file mode 100644index a06c76643f..0000000000--- a/apps/client/src/widgets/type_widgets/text/mention_list_view.css+++ /dev/null@@ -1,12 +0,0 @@-/*- * The `/` palette, at a width that fits all but the longest descriptions, and given more height than- * a list usually is: it is long, and the query only narrows it.- */-.slash-command-menu {- width: 350px;- max-width: calc(100vw - 10px);-}--.slash-command-menu > .tn-menu-scroll {- max-height: var(--ck-mention-list-max-height);-}diff --git a/apps/client/src/widgets/type_widgets/text/mention_list_view.tsx b/apps/client/src/widgets/type_widgets/text/mention_list_view.tsxindex 3ee7228bc9..86a5c9a07a 100644--- a/apps/client/src/widgets/type_widgets/text/mention_list_view.tsx+++ b/apps/client/src/widgets/type_widgets/text/mention_list_view.tsx@@ -1,5 +1,3 @@-import "./mention_list_view.css";-import type { EmojiSuggestion, MentionFeedObjectItem, MentionHostedList, MentionHostedListState, SlashCommandConfig, SlashCommandDefinition, SlashCommandItem, TriliumEmojiMention, TriliumSlashCommands } from "@triliumnext/ckeditor5";import clsx from "clsx";import type { ComponentChildren } from "preact";