mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-11 02:42:27 +08:00
Add engine option
This commit is contained in:
parent
a89cadeac5
commit
dbaaa96ae9
@ -30,7 +30,6 @@ export default class MathCommand extends Command {
|
|||||||
this.isEnabled = isAllowed;
|
this.isEnabled = isAllowed;
|
||||||
|
|
||||||
const selectedEquation = getSelectedMathModelWidget( selection );
|
const selectedEquation = getSelectedMathModelWidget( selection );
|
||||||
console.log(selectedEquation);
|
|
||||||
this.value = selectedEquation ? selectedEquation.getAttribute( 'equation' ) : null;
|
this.value = selectedEquation ? selectedEquation.getAttribute( 'equation' ) : null;
|
||||||
this.display = selectedEquation ? selectedEquation.getAttribute( 'display' ) : null;
|
this.display = selectedEquation ? selectedEquation.getAttribute( 'display' ) : null;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,9 @@ export default class MathEditing extends Plugin {
|
|||||||
|
|
||||||
_defineConverters() {
|
_defineConverters() {
|
||||||
const conversion = this.editor.conversion;
|
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 -> Model
|
// View -> Model
|
||||||
conversion.for( 'upcast' )
|
conversion.for( 'upcast' )
|
||||||
@ -120,7 +122,7 @@ export default class MathEditing extends Plugin {
|
|||||||
const uiElement = viewWriter.createUIElement( 'div', null, function( domDocument ) {
|
const uiElement = viewWriter.createUIElement( 'div', null, function( domDocument ) {
|
||||||
const domElement = this.toDomElement( domDocument );
|
const domElement = this.toDomElement( domDocument );
|
||||||
|
|
||||||
renderEquation( equation, domElement, 'mathjax', display );
|
renderEquation( equation, domElement, engine, display );
|
||||||
|
|
||||||
return domElement;
|
return domElement;
|
||||||
} );
|
} );
|
||||||
|
@ -57,7 +57,10 @@ export default class MathUI extends Plugin {
|
|||||||
_createFormView() {
|
_createFormView() {
|
||||||
const editor = this.editor;
|
const editor = this.editor;
|
||||||
const mathCommand = editor.commands.get( 'math' );
|
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 );
|
const formView = new MainFormView( editor.locale, engine );
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ export default class MathView extends View {
|
|||||||
super( locale );
|
super( locale );
|
||||||
|
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
|
|
||||||
this.set( 'value', '' );
|
this.set( 'value', '' );
|
||||||
this.set( 'display', false);
|
this.set( 'display', false);
|
||||||
|
|
||||||
|
@ -8,17 +8,18 @@ export function renderEquation( equation, element, engine = 'katex', display = f
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, element ] );
|
MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, element ] );
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
}
|
} else if ( engine === 'katex' && typeof katex !== 'undefined' ) {
|
||||||
else if ( engine === 'katex' && typeof katex !== 'undefined' ) {
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
katex.render( equation, element, {
|
katex.render( equation, element, {
|
||||||
throwOnError: false,
|
throwOnError: false,
|
||||||
displayMode: display
|
displayMode: display
|
||||||
} );
|
} );
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
|
} else if ( typeof engine === 'function' ) {
|
||||||
|
engine(equation, element, display);
|
||||||
} else {
|
} else {
|
||||||
element.innerHTML = equation;
|
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.` );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,16 @@
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: nowrap;
|
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 {
|
@mixin ck-media-phone {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
||||||
@ -25,11 +35,4 @@
|
|||||||
flex-basis: 50%;
|
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;
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user