mirror of
https://github.com/zadam/trilium.git
synced 2025-11-12 00:05:50 +01:00
feat(slash): admonition types
This commit is contained in:
25
packages/ckeditor5/src/extra_slash_commands.ts
Normal file
25
packages/ckeditor5/src/extra_slash_commands.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { Editor } from 'ckeditor5';
|
||||
import type { SlashCommandEditorConfig } from 'ckeditor5-premium-features';
|
||||
import { icons as admonitionIcons } from '@triliumnext/ckeditor5-admonition';
|
||||
import { ADMONITION_TYPES, type AdmonitionType } from '@triliumnext/ckeditor5-admonition';
|
||||
|
||||
type SlashCommandDefinition = SlashCommandEditorConfig["extraCommands"][number];
|
||||
|
||||
export default function buildExtraCommands(): SlashCommandDefinition[] {
|
||||
return [
|
||||
...buildAdmonitionExtraCommands()
|
||||
];
|
||||
}
|
||||
|
||||
function buildAdmonitionExtraCommands(): SlashCommandDefinition[] {
|
||||
const commands: SlashCommandDefinition[] = [];
|
||||
for (const [ keyword, definition ] of Object.entries(ADMONITION_TYPES)) {
|
||||
commands.push({
|
||||
id: keyword,
|
||||
title: `Admonition: ${definition.title}`,
|
||||
icon: admonitionIcons.admonitionIcon,
|
||||
execute: (editor: Editor) => editor.execute("admonition", { forceValue: keyword as AdmonitionType })
|
||||
});
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { COMMON_PLUGINS, CORE_PLUGINS, POPUP_EDITOR_PLUGINS } from "./plugins";
|
||||
import { BalloonEditor, DecoupledEditor, FindAndReplaceEditing, FindCommand } from "ckeditor5";
|
||||
export { EditorWatchdog } from "ckeditor5";
|
||||
export type { EditorConfig, MentionFeed, MentionFeedObjectItem, Node, Position, Element, WatchdogConfig } from "ckeditor5";
|
||||
export { default as buildExtraCommands } from "./extra_slash_commands.js";
|
||||
|
||||
// Import with sideffects to ensure that type augmentations are present.
|
||||
import "@triliumnext/ckeditor5-math";
|
||||
@@ -25,6 +26,7 @@ export type FindCommandResult = ReturnType<FindCommand["execute"]>;
|
||||
* The text editor that can be used for editing attributes and relations.
|
||||
*/
|
||||
export class AttributeEditor extends BalloonEditor {
|
||||
|
||||
static override get builtinPlugins() {
|
||||
return CORE_PLUGINS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user