Skip to content

Build your personal knowledge base with Trilium Notes

feat(slash): include note

Elian Doran60695187490f
diff --git a/packages/ckeditor5/src/extra_slash_commands.ts b/packages/ckeditor5/src/extra_slash_commands.ts
index f9caf3d0da..a44e85af5d 100644
--- a/packages/ckeditor5/src/extra_slash_commands.ts
+++ b/packages/ckeditor5/src/extra_slash_commands.ts
@@ -2,11 +2,13 @@ import type { Editor } from 'ckeditor5';
import type { SlashCommandEditorConfig } from 'ckeditor5-premium-features';
import { icons as admonitionIcons } from '@triliumnext/ckeditor5-admonition';
import { icons as footnoteIcons } from '@triliumnext/ckeditor5-footnotes';
-import { COMMAND_NAME as INSERT_DATE_TIME_COMMAND } from './plugins/insert_date_time';
-import { COMMAND_NAME as INTERNAL_LINK_COMMAND } from './plugins/internallink';
+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';
import { ADMONITION_TYPES, type AdmonitionType } from '@triliumnext/ckeditor5-admonition';
import dateTimeIcon from './icons/date-time.svg?raw';
import internalLinkIcon from './icons/trilium.svg?raw';
+import noteIcon from './icons/note.svg?raw';
import { icons as mathIcons, MathUI } from '@triliumnext/ckeditor5-math';
type SlashCommandDefinition = SlashCommandEditorConfig["extraCommands"][number];
@@ -41,6 +43,13 @@ export default function buildExtraCommands(): SlashCommandDefinition[] {
description: "Insert a math equation",
icon: mathIcons.ckeditor,
execute: (editor: Editor) => 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
}
];
}
diff --git a/packages/ckeditor5/src/plugins/includenote.ts b/packages/ckeditor5/src/plugins/includenote.ts
index 0c71490785..1ce633f357 100644
--- a/packages/ckeditor5/src/plugins/includenote.ts
+++ b/packages/ckeditor5/src/plugins/includenote.ts
@@ -1,6 +1,8 @@
import { ButtonView, Command, Plugin, toWidget, Widget, type Editor, type Observable } from 'ckeditor5';
import noteIcon from '../icons/note.svg?raw';
+export const COMMAND_NAME = 'insertIncludeNote';
+
export default class IncludeNote extends Plugin {
static get requires() {
return [ IncludeNoteEditing, IncludeNoteUI ];
@@ -16,7 +18,7 @@ class IncludeNoteUI extends Plugin {
// to be displayed in the toolbar.
editor.ui.componentFactory.add( 'includeNote', locale => {
// The state of the button will be bound to the widget command.
- const command = editor.commands.get( 'insertIncludeNote' );
+ const command = editor.commands.get( COMMAND_NAME );
// The button will be an instance of ButtonView.
const buttonView = new ButtonView( locale );
@@ -35,7 +37,7 @@ class IncludeNoteUI extends Plugin {
}
// Execute the command when the button is clicked (executed).
- this.listenTo( buttonView, 'execute', () => editor.execute( 'insertIncludeNote' ) );
+ this.listenTo( buttonView, 'execute', () => editor.execute( COMMAND_NAME ) );
return buttonView;
} );
@@ -51,7 +53,7 @@ class IncludeNoteEditing extends Plugin {
this._defineSchema();
this._defineConverters();
- this.editor.commands.add( 'insertIncludeNote', new InsertIncludeNoteCommand( this.editor ) );
+ this.editor.commands.add( COMMAND_NAME, new InsertIncludeNoteCommand( this.editor ) );
}
_defineSchema() {