mirror of
https://github.com/zadam/trilium.git
synced 2026-05-06 19:06:35 +02:00
feat(text): add a slash command for bookmarks
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user