Skip to content
Snippets Groups Projects
Commit 5dd66655 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

WIP: Begin MathJax plugin

parent ea3c4773
Branches
Tags
No related merge requests found
import {
Plugin
} from 'ckeditor/src/core';
import {
ButtonView
} from 'ckeditor/src/ui';
export default class MathJaxCodeDelimiters extends Plugin {
static get pluginName() {
return 'MathJaxCodeDelimiters';
}
init() {
// This is well-defined since this class inherits from `Plugin`
const editor = this.editor;
const model = editor.model;
// Stay compatible to possible future translations
const t = editor.t;
// Add the inline-math button
editor.ui.componentFactory.add( 'inlineMathButton', locale => {
const view = new ButtonView( locale );
view.set( {
label: t( 'Insert inline math delimiters' ),
icon: '$',
tooltip: true,
isToggleable: true
} );
// Insert the inline delimiters ("`$$`") into the text at the
// position of the cursor.
this.listenTo( view, 'execute', () => {
model.change( writer => {
const textNode = writer.createText( '`$$`' );
model.insertContent( textNode );
} );
editor.editing.view.focus();
} );
} );
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment