diff --git a/src/mathcommand.js b/src/mathcommand.js index 72004bc14..745bb7d45 100644 --- a/src/mathcommand.js +++ b/src/mathcommand.js @@ -30,7 +30,6 @@ export default class MathCommand extends Command { this.isEnabled = isAllowed; const selectedEquation = getSelectedMathModelWidget( selection ); - console.log(selectedEquation); this.value = selectedEquation ? selectedEquation.getAttribute( 'equation' ) : null; this.display = selectedEquation ? selectedEquation.getAttribute( 'display' ) : null; } diff --git a/src/mathediting.js b/src/mathediting.js index bcab44d54..62e766db9 100644 --- a/src/mathediting.js +++ b/src/mathediting.js @@ -37,7 +37,9 @@ export default class MathEditing extends Plugin { _defineConverters() { const conversion = this.editor.conversion; - + const mathConfig = this.editor.config.get( 'math' ); + // Todo: better checks + const engine = typeof mathConfig !== 'undefined' && typeof mathConfig.engine !== 'undefined' ? mathConfig.engine : 'mathjax'; // View -> Model conversion.for( 'upcast' ) @@ -120,7 +122,7 @@ export default class MathEditing extends Plugin { const uiElement = viewWriter.createUIElement( 'div', null, function( domDocument ) { const domElement = this.toDomElement( domDocument ); - renderEquation( equation, domElement, 'mathjax', display ); + renderEquation( equation, domElement, engine, display ); return domElement; } ); diff --git a/src/mathui.js b/src/mathui.js index bfce006f3..572abed8b 100644 --- a/src/mathui.js +++ b/src/mathui.js @@ -57,7 +57,10 @@ export default class MathUI extends Plugin { _createFormView() { const editor = this.editor; const mathCommand = editor.commands.get( 'math' ); - const engine = 'mathjax'; + + const mathConfig = editor.config.get( 'math' ); + // Todo: better checks + const engine = typeof mathConfig !== 'undefined' && typeof mathConfig.engine !== 'undefined' ? mathConfig.engine : 'mathjax'; const formView = new MainFormView( editor.locale, engine ); diff --git a/src/ui/mathview.js b/src/ui/mathview.js index 573c8bfa6..01791b263 100644 --- a/src/ui/mathview.js +++ b/src/ui/mathview.js @@ -6,7 +6,7 @@ export default class MathView extends View { super( locale ); this.engine = engine; - + this.set( 'value', '' ); this.set( 'display', false); diff --git a/src/utils.js b/src/utils.js index b7f874be6..974c8a6db 100644 --- a/src/utils.js +++ b/src/utils.js @@ -8,17 +8,18 @@ export function renderEquation( equation, element, engine = 'katex', display = f /* eslint-disable */ MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, element ] ); /* eslint-enable */ - } - else if ( engine === 'katex' && typeof katex !== 'undefined' ) { + } else if ( engine === 'katex' && typeof katex !== 'undefined' ) { /* eslint-disable */ katex.render( equation, element, { throwOnError: false, displayMode: display } ); /* eslint-enable */ + } else if ( typeof engine === 'function' ) { + engine(equation, element, display); } else { element.innerHTML = equation; - console.warn( 'math-tex-typesetting-missing: Missing the mathematical typesetting engine for tex.' ); + console.warn( `math-tex-typesetting-missing: Missing the mathematical typesetting engine (${engine}) for tex.` ); } } diff --git a/theme/mathform.css b/theme/mathform.css index 1569c1948..66268773f 100644 --- a/theme/mathform.css +++ b/theme/mathform.css @@ -6,6 +6,16 @@ flex-direction: row; flex-wrap: nowrap; + & .ck.ck-math-preview { + user-select: none; + } + + /* FIXME: mathjax isn't working with .ck.ck-reset_all * without this fix*/ + & .ck.ck-math-preview * { + vertical-align: initial; + text-align: center; + } + @mixin ck-media-phone { flex-wrap: wrap; @@ -25,11 +35,4 @@ flex-basis: 50%; } } - -} - -/* FIXME: mathjax isn't working with .ck.ck-reset_all * without this fix*/ -.ck.ck-math-preview * { - vertical-align: initial; - text-align: center; } \ No newline at end of file