mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 13:26:01 +01:00
Add display toggle
This commit is contained in:
@@ -2,7 +2,7 @@ import Command from '@ckeditor/ckeditor5-core/src/command';
|
||||
import { getSelectedMathModelWidget } from './utils';
|
||||
|
||||
export default class MathCommand extends Command {
|
||||
execute( equation ) {
|
||||
execute( equation, display ) {
|
||||
const model = this.editor.model;
|
||||
const selection = model.document.selection;
|
||||
const selectedElement = selection.getSelectedElement();
|
||||
@@ -12,11 +12,10 @@ export default class MathCommand extends Command {
|
||||
if ( selectedElement && selectedElement.is( 'mathtex' ) ) {
|
||||
// Update selected element
|
||||
const mode = selectedElement.getAttribute( 'mode' );
|
||||
const display = selectedElement.getAttribute( 'display' );
|
||||
mathtex = writer.createElement( 'mathtex', { equation, mode, display } );
|
||||
} else {
|
||||
// Create new model element
|
||||
mathtex = writer.createElement( 'mathtex', { equation, mode: 'script', display: true } );
|
||||
mathtex = writer.createElement( 'mathtex', { equation, mode: 'script', display } );
|
||||
}
|
||||
model.insertContent( mathtex );
|
||||
writer.setSelection( mathtex, 'on' );
|
||||
@@ -31,6 +30,8 @@ export default class MathCommand extends Command {
|
||||
this.isEnabled = isAllowed;
|
||||
|
||||
const selectedEquation = getSelectedMathModelWidget( selection );
|
||||
console.log(selectedEquation);
|
||||
this.value = selectedEquation ? selectedEquation.getAttribute( 'equation' ) : null;
|
||||
this.display = selectedEquation ? selectedEquation.getAttribute( 'display' ) : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user