mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 21:36:05 +01:00
Add output options
This commit is contained in:
@@ -2,7 +2,8 @@ import Command from '@ckeditor/ckeditor5-core/src/command';
|
||||
import { getSelectedMathModelWidget } from './utils';
|
||||
|
||||
export default class MathCommand extends Command {
|
||||
execute( equation, display ) {
|
||||
execute( equation, display, outputType, forceOutputType ) {
|
||||
console.log( 'execute', display, outputType, forceOutputType );
|
||||
const model = this.editor.model;
|
||||
const selection = model.document.selection;
|
||||
const selectedElement = selection.getSelectedElement();
|
||||
@@ -11,11 +12,15 @@ export default class MathCommand extends Command {
|
||||
let mathtex;
|
||||
if ( selectedElement && selectedElement.is( 'mathtex' ) ) {
|
||||
// Update selected element
|
||||
const mode = selectedElement.getAttribute( 'mode' );
|
||||
mathtex = writer.createElement( 'mathtex', { equation, mode, display } );
|
||||
const typeAttr = selectedElement.getAttribute( 'type' );
|
||||
|
||||
// Use already set type if found and is not forced
|
||||
const type = forceOutputType ? outputType : typeAttr || outputType;
|
||||
|
||||
mathtex = writer.createElement( 'mathtex', { equation, type, display } );
|
||||
} else {
|
||||
// Create new model element
|
||||
mathtex = writer.createElement( 'mathtex', { equation, mode: 'script', display } );
|
||||
mathtex = writer.createElement( 'mathtex', { equation, type: outputType, display } );
|
||||
}
|
||||
model.insertContent( mathtex );
|
||||
writer.setSelection( mathtex, 'on' );
|
||||
|
||||
Reference in New Issue
Block a user