From 4dcbd36b2de94d37f1e9ef32dd366695cf762350 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 18 Apr 2026 10:22:58 +0300 Subject: [PATCH] feat(text): add a slash command for bookmarks --- packages/ckeditor5/src/extra_slash_commands.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/ckeditor5/src/extra_slash_commands.ts b/packages/ckeditor5/src/extra_slash_commands.ts index ee6068dc3d..fb86e18efa 100644 --- a/packages/ckeditor5/src/extra_slash_commands.ts +++ b/packages/ckeditor5/src/extra_slash_commands.ts @@ -17,6 +17,8 @@ import internalLinkIcon from './icons/trilium.svg?raw'; import noteIcon from './icons/note.svg?raw'; import importMarkdownIcon from './icons/markdown-mark.svg?raw'; import { icons as mathIcons, MathUI } from '@triliumnext/ckeditor5-math'; +import { BookmarkUI } from "ckeditor5"; +import bxBookmark from "boxicons/svg/regular/bx-bookmark.svg?raw"; type SlashCommandDefinition = SlashCommandEditorConfig["extraCommands"][number]; @@ -74,6 +76,19 @@ export default function buildExtraCommands(): SlashCommandDefinition[] { description: "Import a markdown file into this note", icon: importMarkdownIcon, commandName: MARKDOWN_IMPORT_COMMAND + }, + { + id: "bookmark", + title: "Bookmark", + description: "Insert a bookmark anchor for internal linking", + aliases: [ "anchor" ], + icon: bxBookmark, + execute: (editor: Editor) => { + // Defer to the next event loop tick so the slash command fully finishes + // its DOM/selection cleanup; _showFormView needs the view and mapper to + // be in a settled state for balloon positioning. + setTimeout(() => (editor.plugins.get(BookmarkUI) as any)._showFormView(), 0); + } } ]; }