mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-11-03 06:31:30 +08:00
Fix MathJax 2 preview rendering
This commit is contained in:
parent
2984df0a9a
commit
6e6a7ec10a
@ -76,7 +76,8 @@ export default class MainFormView extends View {
|
|||||||
'ck',
|
'ck',
|
||||||
'ck-math-form',
|
'ck-math-form',
|
||||||
],
|
],
|
||||||
tabindex: '-1'
|
tabindex: '-1',
|
||||||
|
spellcheck: 'false'
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
|||||||
33
src/utils.js
33
src/utils.js
@ -27,10 +27,19 @@ export function renderEquation( equation, element, engine = 'katex', display = f
|
|||||||
} );
|
} );
|
||||||
} else {
|
} else {
|
||||||
selectRenderMode( element, preview, el => {
|
selectRenderMode( element, preview, el => {
|
||||||
renderMathJax2( equation, el, display );
|
// Fixme: MathJax typesetting cause occasionally math processing error without asynchronous call
|
||||||
if ( preview ) {
|
// eslint-disable-next-line
|
||||||
moveAndScaleElement( element, el );
|
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' ) {
|
} else if ( engine === 'katex' && typeof katex !== 'undefined' ) {
|
||||||
@ -86,16 +95,12 @@ function renderMathJax3( equation, element, display, after ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderMathJax2( equation, element, display ) {
|
function renderMathJax2( equation, element, display ) {
|
||||||
// Fixme: MathJax typesetting cause occasionally math processing error without asynchronous call
|
if ( display ) {
|
||||||
// eslint-disable-next-line
|
element.innerHTML = '\\[' + equation + '\\]';
|
||||||
setTimeout( () => {
|
} else {
|
||||||
if ( display ) {
|
element.innerHTML = '\\(' + equation + '\\)';
|
||||||
element.innerHTML = '\\[' + equation + '\\]';
|
}
|
||||||
} else {
|
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, element ] ); // eslint-disable-line
|
||||||
element.innerHTML = '\\(' + equation + '\\)';
|
|
||||||
}
|
|
||||||
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, element ] ); // eslint-disable-line
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPreviewElement( element, render ) {
|
function createPreviewElement( element, render ) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user