chore(ckeditor5/plugins): integrate internal link

This commit is contained in:
Elian Doran
2025-05-03 16:51:17 +03:00
parent daa1df5a24
commit a54d8ed811
3 changed files with 8 additions and 8 deletions

View File

@@ -0,0 +1,30 @@
import { ButtonView, Plugin } from 'ckeditor5';
import internalLinkIcon from '../icons/trilium.svg?raw';
export default class InternalLinkPlugin extends Plugin {
init() {
const editor = this.editor;
editor.ui.componentFactory.add('internalLink', locale => {
const view = new ButtonView( locale );
view.set( {
label: 'Internal Trilium link (CTRL-L)',
icon: internalLinkIcon,
tooltip: true
} );
// enable internal link only if the editor is not read only
view.bind('isEnabled').to(editor, 'isReadOnly', isReadOnly => !isReadOnly);
view.on('execute', () => {
const editorEl = editor.editing.view.getDomRoot();
const component = glob.getComponentByEl(editorEl);
component.triggerCommand('addLinkToText');
} );
return view;
});
}
}