mirror of
https://github.com/zadam/trilium.git
synced 2025-11-14 01:05:49 +01:00
chore(ckeditor5-math): integrate source code
This commit is contained in:
@@ -1,39 +1,14 @@
|
||||
import { Plugin, ButtonView } from 'ckeditor5';
|
||||
|
||||
import ckeditor5Icon from '../theme/icons/ckeditor.svg';
|
||||
import { Plugin, Widget } from 'ckeditor5';
|
||||
import MathEditing from './mathediting.js';
|
||||
import MathUI from './mathui.js';
|
||||
import AutoMath from './automath.js';
|
||||
|
||||
export default class Math extends Plugin {
|
||||
public static get requires() {
|
||||
return [ MathEditing, MathUI, AutoMath, Widget ] as const;
|
||||
}
|
||||
|
||||
public static get pluginName() {
|
||||
return 'Math' as const;
|
||||
}
|
||||
|
||||
public init(): void {
|
||||
const editor = this.editor;
|
||||
const t = editor.t;
|
||||
const model = editor.model;
|
||||
|
||||
// Register the "math" button, so it can be displayed in the toolbar.
|
||||
editor.ui.componentFactory.add( 'math', locale => {
|
||||
const view = new ButtonView( locale );
|
||||
|
||||
view.set( {
|
||||
label: t( 'Math' ),
|
||||
icon: ckeditor5Icon,
|
||||
tooltip: true
|
||||
} );
|
||||
|
||||
// Insert a text into the editor after clicking the button.
|
||||
this.listenTo( view, 'execute', () => {
|
||||
model.change( writer => {
|
||||
const textNode = writer.createText( 'Hello CKEditor 5!' );
|
||||
|
||||
model.insertContent( textNode );
|
||||
} );
|
||||
|
||||
editor.editing.view.focus();
|
||||
} );
|
||||
|
||||
return view;
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user