From fe3c7ba393d5e748a0ae8d714508df69bf0d7610 Mon Sep 17 00:00:00 2001 From: Sauli Anto Date: Tue, 17 Sep 2019 16:31:39 +0300 Subject: [PATCH] Update config --- src/mathediting.js | 11 ++++++----- src/mathui.js | 10 ++++++---- src/utils.js | 7 +++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/mathediting.js b/src/mathediting.js index 62e766db9..0938f6481 100644 --- a/src/mathediting.js +++ b/src/mathediting.js @@ -5,7 +5,7 @@ import Widget from '@ckeditor/ckeditor5-widget/src/widget'; import MathCommand from './mathcommand'; -import { renderEquation } from './utils'; +import { renderEquation, defaultConfig } from './utils'; export default class MathEditing extends Plugin { static get requires() { @@ -37,9 +37,10 @@ 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'; + const mathConfig = { + ...defaultConfig, + ...this.editor.config.get( 'math' ) + } // View -> Model conversion.for( 'upcast' ) @@ -122,7 +123,7 @@ export default class MathEditing extends Plugin { const uiElement = viewWriter.createUIElement( 'div', null, function( domDocument ) { const domElement = this.toDomElement( domDocument ); - renderEquation( equation, domElement, engine, display ); + renderEquation( equation, domElement, mathConfig.engine, display ); return domElement; } ); diff --git a/src/mathui.js b/src/mathui.js index 572abed8b..b73464e22 100644 --- a/src/mathui.js +++ b/src/mathui.js @@ -8,6 +8,7 @@ import MainFormView from './ui/mainformview'; // Need math commands from there import MathEditing from './mathediting'; +import { defaultConfig } from './utils'; import pluginIcon from '../theme/icons/icon.svg'; @@ -58,11 +59,12 @@ export default class MathUI extends Plugin { const editor = this.editor; const mathCommand = editor.commands.get( 'math' ); - const mathConfig = editor.config.get( 'math' ); - // Todo: better checks - const engine = typeof mathConfig !== 'undefined' && typeof mathConfig.engine !== 'undefined' ? mathConfig.engine : 'mathjax'; + const mathConfig = { + ...defaultConfig, + ...this.editor.config.get( 'math' ) + } - const formView = new MainFormView( editor.locale, engine ); + const formView = new MainFormView( editor.locale, mathConfig.engine ); formView.mathInputView.bind( 'value' ).to( mathCommand, 'value' ); formView.displayButtonView.bind( 'displayIsOn' ).to( mathCommand, 'display'); diff --git a/src/utils.js b/src/utils.js index 974c8a6db..391cad49f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -32,3 +32,10 @@ export function getSelectedMathModelWidget( selection ) { return null; } + + +export const defaultConfig = { + engine: 'mathjax', + outputMode: 'script', + forceOutputMode: false +} \ No newline at end of file