mirror of
https://github.com/zadam/trilium.git
synced 2025-11-09 06:45:49 +01:00
feat(slash): markdown import
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { ButtonView, Plugin } from 'ckeditor5';
|
||||
import { ButtonView, Command, Plugin } from 'ckeditor5';
|
||||
import markdownIcon from '../icons/markdown-mark.svg?raw';
|
||||
|
||||
export const COMMAND_NAME = 'importMarkdownInline';
|
||||
|
||||
export default class MarkdownImportPlugin extends Plugin {
|
||||
init() {
|
||||
const editor = this.editor;
|
||||
|
||||
editor.commands.add(COMMAND_NAME, new ImportMarkdownInline(editor));
|
||||
|
||||
editor.ui.componentFactory.add( 'markdownImport', locale => {
|
||||
const view = new ButtonView( locale );
|
||||
|
||||
@@ -15,11 +19,19 @@ export default class MarkdownImportPlugin extends Plugin {
|
||||
} );
|
||||
|
||||
// Callback executed once the image is clicked.
|
||||
view.on( 'execute', () => {
|
||||
glob.importMarkdownInline();
|
||||
} );
|
||||
const command = editor.commands.get(COMMAND_NAME)!;
|
||||
view.bind('isEnabled').to(command, 'isEnabled');
|
||||
view.on('execute', () => editor.execute(COMMAND_NAME));
|
||||
|
||||
return view;
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
class ImportMarkdownInline extends Command {
|
||||
|
||||
execute() {
|
||||
glob.importMarkdownInline();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user