Skip to content

Build your personal knowledge base with Trilium Notes

Update config

Sauli Antofe3c7ba393d5
diff --git a/src/mathediting.js b/src/mathediting.js
index 62e766db99..0938f64813 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 572abed8bd..b73464e225 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 974c8a6db0..391cad49fb 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