chore(ckeditor5-math): initialize empty plugin

This commit is contained in:
Elian Doran
2025-05-04 19:53:24 +03:00
parent 2d27a4b50d
commit 6626aca12a
28 changed files with 22067 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
import type { Math } from './index.js';
declare module '@ckeditor/ckeditor5-core' {
interface PluginsMap {
[ Math.pluginName ]: Math;
}
}

View File

@@ -0,0 +1,8 @@
import ckeditor from './../theme/icons/ckeditor.svg';
import './augmentation.js';
export { default as Math } from './math.js';
export const icons = {
ckeditor
};

View File

@@ -0,0 +1,39 @@
import { Plugin, ButtonView } from 'ckeditor5';
import ckeditor5Icon from '../theme/icons/ckeditor.svg';
export default class Math extends Plugin {
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;
} );
}
}