Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Add engine option
Sauli Antodbaaa96ae9b6
diff --git a/src/mathcommand.js b/src/mathcommand.jsindex 72004bc146..745bb7d45a 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.jsindex bcab44d548..62e766db99 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 -> Modelconversion.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.jsindex bfce006f31..572abed8bd 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.jsindex 573c8bfa6b..01791b2630 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.jsindex b7f874be68..974c8a6db0 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.cssindex 1569c19480..66268773fd 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