diff --git a/apps/client/src/widgets/type_widgets/ckeditor/config.ts b/apps/client/src/widgets/type_widgets/ckeditor/config.ts index d259427a8..4eb15e913 100644 --- a/apps/client/src/widgets/type_widgets/ckeditor/config.ts +++ b/apps/client/src/widgets/type_widgets/ckeditor/config.ts @@ -1,6 +1,6 @@ import { ALLOWED_PROTOCOLS } from "../../../services/link.js"; import { MIME_TYPE_AUTO } from "@triliumnext/commons"; -import { type EditorConfig, PREMIUM_PLUGINS } from "@triliumnext/ckeditor5"; +import { buildExtraCommands, type EditorConfig, PREMIUM_PLUGINS } from "@triliumnext/ckeditor5"; import { getHighlightJsNameForMime } from "../../../services/mime_types.js"; import options from "../../../services/options.js"; import { ensureMimeTypesForHighlighting, isSyntaxHighlightEnabled } from "../../../services/syntax_highlight.js"; @@ -154,7 +154,7 @@ export async function buildConfig(opts: BuildEditorOptions): Promise editor.plugins.get(MathUI)._showUI() + }, + { + id: "include-note", + title: "Include note", + description: "Display the content of another note in this note", + icon: noteIcon, + commandName: INCLUDE_NOTE_COMMAND + }, + { + id: "page-break", + title: "Page break", + description: "Insert a page break (for printing)", + icon: IconPageBreak, + commandName: "pageBreak" + }, + { + id: "markdown-import", + title: "Markdown import", + description: "Import a markdown file into this note", + icon: importMarkdownIcon, + commandName: MARKDOWN_IMPORT_COMMAND + } + ]; +} + +function buildAlignmentExtraCommands(): SlashCommandDefinition[] { + return [ + { + id: "align-left", + title: "Align Left", + description: "Align text to the left", + icon: IconAlignLeft, + execute: (editor: Editor) => editor.execute("alignment", { value: "left" }), + }, + { + id: "align-center", + title: "Align Center", + description: "Align text to the center", + icon: IconAlignCenter, + execute: (editor: Editor) => editor.execute("alignment", { value: "center" }), + }, + { + id: "align-right", + title: "Align Right", + description: "Align text to the right", + icon: IconAlignRight, + execute: (editor: Editor) => editor.execute("alignment", { value: "right" }), + }, + { + id: "align-justify", + title: "Justify", + description: "Justify text alignment", + icon: IconAlignJustify, + execute: (editor: Editor) => editor.execute("alignment", { value: "justify" }), + } + ]; +} + +function buildAdmonitionExtraCommands(): SlashCommandDefinition[] { + const commands: SlashCommandDefinition[] = []; + const admonitionIcons: Record = { + note: bxInfoCircle, + tip: bxBulb, + important: bxCommentError, + caution: bxErrorCircle, + warning: bxError, + }; + + for (const [ keyword, definition ] of Object.entries(ADMONITION_TYPES)) { + commands.push({ + id: keyword, + title: definition.title, + description: "Inserts a new admonition", + icon: admonitionIcons[keyword as AdmonitionType], + execute: (editor: Editor) => editor.execute("admonition", { forceValue: keyword as AdmonitionType }), + aliases: [ "box" ] + }); + } + return commands; +} + diff --git a/packages/ckeditor5/src/index.ts b/packages/ckeditor5/src/index.ts index 0b97076b6..0bdc4c493 100644 --- a/packages/ckeditor5/src/index.ts +++ b/packages/ckeditor5/src/index.ts @@ -6,8 +6,8 @@ import "./translation_overrides.js"; export { EditorWatchdog } from "ckeditor5"; export { PREMIUM_PLUGINS } from "./plugins.js"; export type { EditorConfig, MentionFeed, MentionFeedObjectItem, ModelNode, ModelPosition, ModelElement, WatchdogConfig } from "ckeditor5"; -// export type { TemplateDefinition } from "ckeditor5-premium-features"; -// export { default as buildExtraCommands } from "./extra_slash_commands.js"; +export type { TemplateDefinition } from "ckeditor5-premium-features"; +export { default as buildExtraCommands } from "./extra_slash_commands.js"; // Import with sideffects to ensure that type augmentations are present. import "@triliumnext/ckeditor5-math"; diff --git a/packages/ckeditor5/src/plugins.ts b/packages/ckeditor5/src/plugins.ts index 833a0fa1c..bbd613a9e 100644 --- a/packages/ckeditor5/src/plugins.ts +++ b/packages/ckeditor5/src/plugins.ts @@ -1,5 +1,5 @@ import { Autoformat, AutoLink, BlockQuote, BlockToolbar, Bold, CKFinderUploadAdapter, Clipboard, Code, CodeBlock, Enter, FindAndReplace, Font, FontBackgroundColor, FontColor, GeneralHtmlSupport, Heading, HeadingButtonsUI, HorizontalLine, Image, ImageCaption, ImageInline, ImageResize, ImageStyle, ImageToolbar, ImageUpload, Alignment, Indent, IndentBlock, Italic, Link, List, ListProperties, Mention, PageBreak, Paragraph, ParagraphButtonUI, PasteFromOffice, PictureEditing, RemoveFormat, SelectAll, ShiftEnter, SpecialCharacters, SpecialCharactersEssentials, Strikethrough, Style, Subscript, Superscript, Table, TableCaption, TableCellProperties, TableColumnResize, TableProperties, TableSelection, TableToolbar, TextPartLanguage, TextTransformation, TodoList, Typing, Underline, Undo, Bookmark, Emoji, Notification, EmojiMention, EmojiPicker } from "ckeditor5"; -// import { SlashCommand, Template } from "ckeditor5-premium-features"; +import { SlashCommand, Template } from "ckeditor5-premium-features"; import type { Plugin } from "ckeditor5"; import CutToNotePlugin from "./plugins/cuttonote.js"; import UploadimagePlugin from "./plugins/uploadimage.js"; @@ -82,8 +82,8 @@ export const CORE_PLUGINS: typeof Plugin[] = [ * Plugins that require a premium CKEditor license key to work. */ export const PREMIUM_PLUGINS: typeof Plugin[] = [ - // SlashCommand, - // Template + SlashCommand, + Template ]; /**