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
No known key found for this signature in database
3 changed files with 8 additions and 8 deletions

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -4,12 +4,14 @@ import CutToNotePlugin from "./plugins/cuttonote.js";
import UploadimagePlugin from "./plugins/uploadimage.js";
import ItalicAsEmPlugin from "./plugins/italic_as_em.js";
import StrikethroughAsDel from "./plugins/strikethrough_as_del.js";
import InternalLinkPlugin from "./plugins/internallink.js";
const TRILIUM_PLUGINS: typeof Plugin[] = [
CutToNotePlugin,
ItalicAsEmPlugin,
StrikethroughAsDel,
UploadimagePlugin
UploadimagePlugin,
InternalLinkPlugin
];
export const COMMON_PLUGINS: typeof Plugin[] = [
@ -66,7 +68,6 @@ export const COMMON_PLUGINS: typeof Plugin[] = [
// SpecialCharactersEmoji,
FindAndReplace,
Mention,
// InternalLinkPlugin,
// MarkdownImportPlugin,
// MentionCustomization,
// IncludeNote,

View File

@ -1,12 +1,11 @@
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import internalLinkIcon from './icons/trilium.svg';
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
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 => {
editor.ui.componentFactory.add('internalLink', locale => {
const view = new ButtonView( locale );
view.set( {
@ -18,7 +17,7 @@ export default class InternalLinkPlugin extends Plugin {
// enable internal link only if the editor is not read only
view.bind('isEnabled').to(editor, 'isReadOnly', isReadOnly => !isReadOnly);
view.on( 'execute', () => {
view.on('execute', () => {
const editorEl = editor.editing.view.getDomRoot();
const component = glob.getComponentByEl(editorEl);
@ -26,6 +25,6 @@ export default class InternalLinkPlugin extends Plugin {
} );
return view;
} );
});
}
}