mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-11 19:22:31 +08:00
Fix linting errors
This commit is contained in:
parent
53c4c72c10
commit
566c9a40cb
@ -62,7 +62,7 @@ export default class MathUI extends Plugin {
|
|||||||
const mathConfig = {
|
const mathConfig = {
|
||||||
...defaultConfig,
|
...defaultConfig,
|
||||||
...this.editor.config.get( 'math' )
|
...this.editor.config.get( 'math' )
|
||||||
}
|
};
|
||||||
|
|
||||||
const formView = new MainFormView( editor.locale, mathConfig.engine );
|
const formView = new MainFormView( editor.locale, mathConfig.engine );
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import View from '@ckeditor/ckeditor5-ui/src/view';
|
|||||||
import ViewCollection from '@ckeditor/ckeditor5-ui/src/viewcollection';
|
import ViewCollection from '@ckeditor/ckeditor5-ui/src/viewcollection';
|
||||||
|
|
||||||
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
||||||
import SwitchButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
|
||||||
import LabeledInputView from '@ckeditor/ckeditor5-ui/src/labeledinput/labeledinputview';
|
import LabeledInputView from '@ckeditor/ckeditor5-ui/src/labeledinput/labeledinputview';
|
||||||
import InputTextView from '@ckeditor/ckeditor5-ui/src/inputtext/inputtextview';
|
import InputTextView from '@ckeditor/ckeditor5-ui/src/inputtext/inputtextview';
|
||||||
import LabelView from '@ckeditor/ckeditor5-ui/src/label/labelview';
|
import LabelView from '@ckeditor/ckeditor5-ui/src/label/labelview';
|
||||||
@ -60,14 +59,14 @@ export default class MainFormView extends View {
|
|||||||
this.displayButtonView,
|
this.displayButtonView,
|
||||||
this.previewLabel,
|
this.previewLabel,
|
||||||
this.mathView
|
this.mathView
|
||||||
]
|
];
|
||||||
} else {
|
} else {
|
||||||
this.previewLabel.text = t( `Equation preview isn't available` );
|
this.previewLabel.text = t( 'Equation preview isn\'t available' );
|
||||||
children = [
|
children = [
|
||||||
this.mathInputView,
|
this.mathInputView,
|
||||||
this.displayButtonView,
|
this.displayButtonView,
|
||||||
this.previewLabel
|
this.previewLabel
|
||||||
]
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add UI elements to template
|
// Add UI elements to template
|
||||||
@ -193,7 +192,7 @@ export default class MainFormView extends View {
|
|||||||
_createDisplayButton() {
|
_createDisplayButton() {
|
||||||
const t = this.locale.t;
|
const t = this.locale.t;
|
||||||
|
|
||||||
const switchButton = new SwitchButtonView( this.locale );
|
const switchButton = new ButtonView( this.locale );
|
||||||
|
|
||||||
switchButton.set( {
|
switchButton.set( {
|
||||||
label: t( 'Display mode' ),
|
label: t( 'Display mode' ),
|
||||||
|
35
src/utils.js
35
src/utils.js
@ -1,26 +1,45 @@
|
|||||||
export function renderEquation( equation, element, engine = 'katex', display = false ) {
|
export function renderEquation( equation, element, engine = 'katex', display = false ) {
|
||||||
|
/* eslint-disable */
|
||||||
if ( engine === 'mathjax' && typeof MathJax !== 'undefined' ) {
|
if ( engine === 'mathjax' && typeof MathJax !== 'undefined' ) {
|
||||||
|
const version = MathJax.version;
|
||||||
|
// If major version is 3
|
||||||
|
if ( isMathJaxVersion3( version ) ) {
|
||||||
|
const options = MathJax.getMetricsFor( element );
|
||||||
|
|
||||||
|
MathJax.texReset();
|
||||||
|
MathJax.tex2chtmlPromise( equation, options ).then( node => {
|
||||||
|
if ( element.firstChild ) {
|
||||||
|
element.firstChild.replaceWith( node );
|
||||||
|
} {
|
||||||
|
element.appendChild( node );
|
||||||
|
}
|
||||||
|
MathJax.startup.document.clear();
|
||||||
|
MathJax.startup.document.updateDocument();
|
||||||
|
} );
|
||||||
|
} else {
|
||||||
if ( display ) {
|
if ( display ) {
|
||||||
element.innerHTML = '\\[' + equation + '\\]';
|
element.innerHTML = '\\[' + equation + '\\]';
|
||||||
} else {
|
} else {
|
||||||
element.innerHTML = '\\(' + equation + '\\)';
|
element.innerHTML = '\\(' + equation + '\\)';
|
||||||
}
|
}
|
||||||
/* eslint-disable */
|
|
||||||
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, element ] );
|
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, {
|
katex.render( equation, element, {
|
||||||
throwOnError: false,
|
throwOnError: false,
|
||||||
displayMode: display
|
displayMode: display
|
||||||
} );
|
} );
|
||||||
/* eslint-enable */
|
|
||||||
} else if ( typeof engine === 'function' ) {
|
} else if ( typeof engine === 'function' ) {
|
||||||
engine( equation, element, display );
|
engine( equation, element, display );
|
||||||
} else {
|
} else {
|
||||||
element.innerHTML = equation;
|
element.innerHTML = equation;
|
||||||
console.warn( `math-tex-typesetting-missing: Missing the mathematical typesetting engine (${engine}) for tex.` );
|
console.warn( `math-tex-typesetting-missing: Missing the mathematical typesetting engine (${engine}) for tex.` );
|
||||||
}
|
}
|
||||||
|
/* eslint-enable */
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isMathJaxVersion3( version ) {
|
||||||
|
return version && typeof version === 'string' && version.split( '.' ).length === 3 && version.split( '.' )[0] === '3';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSelectedMathModelWidget( selection ) {
|
export function getSelectedMathModelWidget( selection ) {
|
||||||
@ -33,14 +52,8 @@ export function getSelectedMathModelWidget( selection ) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const defaultConfig = {
|
export const defaultConfig = {
|
||||||
/*
|
|
||||||
engine: (equation, element, display) => {
|
|
||||||
console.log(equation, element, display);
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
engine: 'mathjax',
|
engine: 'mathjax',
|
||||||
outputType: 'script',
|
outputType: 'script',
|
||||||
forceOutputType: false
|
forceOutputType: false
|
||||||
}
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user