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
Fix MathJax 2 preview rendering
Sauli Anto6e6a7ec10ac3
diff --git a/src/ui/mainformview.js b/src/ui/mainformview.jsindex c75886de2b..5100675672 100644--- a/src/ui/mainformview.js+++ b/src/ui/mainformview.js@@ -76,7 +76,8 @@ export default class MainFormView extends View {'ck','ck-math-form',],- tabindex: '-1'+ tabindex: '-1',+ spellcheck: 'false'},children: [{diff --git a/src/utils.js b/src/utils.jsindex a750c1c1ed..511ba82266 100644--- a/src/utils.js+++ b/src/utils.js@@ -27,10 +27,19 @@ export function renderEquation( equation, element, engine = 'katex', display = f} );} else {selectRenderMode( element, preview, el => {- renderMathJax2( equation, el, display );- if ( preview ) {- moveAndScaleElement( element, el );- }+ // Fixme: MathJax typesetting cause occasionally math processing error without asynchronous call+ // eslint-disable-next-line+ setTimeout( () => {+ renderMathJax2( equation, el, display );++ // Move and scale after rendering+ if ( preview ) {+ // eslint-disable-next-line+ MathJax.Hub.Queue( () => {+ moveAndScaleElement( element, el );+ } );+ }+ } );} );}} else if ( engine === 'katex' && typeof katex !== 'undefined' ) {@@ -86,16 +95,12 @@ function renderMathJax3( equation, element, display, after ) {}function renderMathJax2( equation, element, display ) {- // Fixme: MathJax typesetting cause occasionally math processing error without asynchronous call- // eslint-disable-next-line- setTimeout( () => {- if ( display ) {- element.innerHTML = '\\[' + equation + '\\]';- } else {- element.innerHTML = '\\(' + equation + '\\)';- }- MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, element ] ); // eslint-disable-line- } );+ if ( display ) {+ element.innerHTML = '\\[' + equation + '\\]';+ } else {+ element.innerHTML = '\\(' + equation + '\\)';+ }+ MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, element ] ); // eslint-disable-line}function createPreviewElement( element, render ) {