From 1a64b3ce8edad0907f2fd5912fb77ca5d9cf001a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 16 Jun 2025 21:21:42 +0300 Subject: [PATCH] feat(slash): alignment --- .../ckeditor5/src/extra_slash_commands.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/packages/ckeditor5/src/extra_slash_commands.ts b/packages/ckeditor5/src/extra_slash_commands.ts index 0ead233aa..ead3a0e45 100644 --- a/packages/ckeditor5/src/extra_slash_commands.ts +++ b/packages/ckeditor5/src/extra_slash_commands.ts @@ -3,6 +3,10 @@ import type { SlashCommandEditorConfig } from 'ckeditor5-premium-features'; import { icons as admonitionIcons } from '@triliumnext/ckeditor5-admonition'; import { icons as footnoteIcons } from '@triliumnext/ckeditor5-footnotes'; import IconPageBreak from "@ckeditor/ckeditor5-icons/theme/icons/page-break.svg?raw"; +import IconAlignLeft from "@ckeditor/ckeditor5-icons/theme/icons/align-left.svg?raw"; +import IconAlignCenter from "@ckeditor/ckeditor5-icons/theme/icons/align-center.svg?raw"; +import IconAlignRight from "@ckeditor/ckeditor5-icons/theme/icons/align-right.svg?raw"; +import IconAlignJustify from "@ckeditor/ckeditor5-icons/theme/icons/align-justify.svg?raw"; import { COMMAND_NAME as INSERT_DATE_TIME_COMMAND } from './plugins/insert_date_time.js'; import { COMMAND_NAME as INTERNAL_LINK_COMMAND } from './plugins/internallink.js'; import { COMMAND_NAME as INCLUDE_NOTE_COMMAND } from './plugins/includenote.js'; @@ -18,6 +22,7 @@ type SlashCommandDefinition = SlashCommandEditorConfig["extraCommands"][number]; export default function buildExtraCommands(): SlashCommandDefinition[] { return [ + ...buildAlignmentExtraCommands(), ...buildAdmonitionExtraCommands(), { id: 'footnote', @@ -71,6 +76,39 @@ export default function buildExtraCommands(): SlashCommandDefinition[] { ]; } +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[] = []; for (const [ keyword, definition ] of Object.entries(ADMONITION_TYPES)) {