mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-11-02 05:51: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-math-form',
|
||||
],
|
||||
tabindex: '-1'
|
||||
tabindex: '-1',
|
||||
spellcheck: 'false'
|
||||
},
|
||||
children: [
|
||||
{
|
||||
|
||||
33
src/utils.js
33
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 ) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user