mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
chore(ckeditor5-mermaid): fix references: Element -> ModelElement
This commit is contained in:
parent
b4f2be332b
commit
70eece1429
@ -1,5 +1,5 @@
|
||||
import { checkIsOn } from '../utils.js';
|
||||
import { Command, Element } from 'ckeditor5';
|
||||
import { Command, ModelElement } from 'ckeditor5';
|
||||
|
||||
/**
|
||||
* The mermaid preview command.
|
||||
@ -27,7 +27,7 @@ export default class MermaidPreviewCommand extends Command {
|
||||
const editor = this.editor;
|
||||
const model = editor.model;
|
||||
const documentSelection = this.editor.model.document.selection;
|
||||
const mermaidItem = (documentSelection.getSelectedElement() || documentSelection.getLastPosition()?.parent) as Element;
|
||||
const mermaidItem = (documentSelection.getSelectedElement() || documentSelection.getLastPosition()?.parent) as ModelElement;
|
||||
|
||||
if (mermaidItem) {
|
||||
model.change( writer => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { checkIsOn } from '../utils.js';
|
||||
import { Command, Element } from 'ckeditor5';
|
||||
import { Command, ModelElement } from 'ckeditor5';
|
||||
|
||||
/**
|
||||
* The mermaid source view command.
|
||||
@ -29,7 +29,7 @@ export default class MermaidSourceViewCommand extends Command {
|
||||
const editor = this.editor;
|
||||
const model = editor.model;
|
||||
const documentSelection = this.editor.model.document.selection;
|
||||
const mermaidItem = (documentSelection.getSelectedElement() || documentSelection.getLastPosition()?.parent) as Element;
|
||||
const mermaidItem = (documentSelection.getSelectedElement() || documentSelection.getLastPosition()?.parent) as ModelElement;
|
||||
|
||||
model.change( writer => {
|
||||
if ( mermaidItem.getAttribute( 'displayMode' ) !== 'source' ) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import { checkIsOn } from '../utils.js';
|
||||
import { Command, Element } from 'ckeditor5';
|
||||
import { Command, ModelElement } from 'ckeditor5';
|
||||
|
||||
/**
|
||||
* The mermaid split view command.
|
||||
@ -31,7 +31,7 @@ export default class MermaidSplitViewCommand extends Command {
|
||||
const editor = this.editor;
|
||||
const model = editor.model;
|
||||
const documentSelection = this.editor.model.document.selection;
|
||||
const mermaidItem = (documentSelection.getSelectedElement() || documentSelection.getLastPosition()?.parent) as Element;
|
||||
const mermaidItem = (documentSelection.getSelectedElement() || documentSelection.getLastPosition()?.parent) as ModelElement;
|
||||
|
||||
model.change( writer => {
|
||||
if ( mermaidItem.getAttribute( 'displayMode' ) !== 'split' ) {
|
||||
|
@ -8,7 +8,7 @@ import MermaidPreviewCommand from './commands/mermaidPreviewCommand.js';
|
||||
import MermaidSourceViewCommand from './commands/mermaidSourceViewCommand.js';
|
||||
import MermaidSplitViewCommand from './commands/mermaidSplitViewCommand.js';
|
||||
import InsertMermaidCommand from './commands/insertMermaidCommand.js';
|
||||
import { DowncastAttributeEvent, DowncastConversionApi, EditorConfig, Element, EventInfo, Item, Node, Plugin, toWidget, UpcastConversionApi, UpcastConversionData, ViewElement, ViewText, ViewUIElement } from 'ckeditor5';
|
||||
import { DowncastAttributeEvent, DowncastConversionApi, EditorConfig, ModelElement, EventInfo, Item, Node, Plugin, toWidget, UpcastConversionApi, UpcastConversionData, ViewElement, ViewText, ViewUIElement } from 'ckeditor5';
|
||||
|
||||
// Time in milliseconds.
|
||||
const DEBOUNCE_TIME = 300;
|
||||
@ -109,7 +109,7 @@ export default class MermaidEditing extends Plugin {
|
||||
writer.insert( model.createPositionAt( code, 'end' ) as any, sourceTextNode );
|
||||
writer.insert( model.createPositionAt( pre, 'end' ) as any, code );
|
||||
writer.insert( targetViewPosition, pre );
|
||||
mapper.bindElements( data.item as Element, code as ViewElement );
|
||||
mapper.bindElements( data.item as ModelElement, code as ViewElement );
|
||||
}
|
||||
|
||||
_mermaidDowncast( evt: EventInfo, data: DowncastConversionData, conversionApi: DowncastConversionApi ) {
|
||||
@ -144,7 +144,7 @@ export default class MermaidEditing extends Plugin {
|
||||
|
||||
writer.insert( targetViewPosition, wrapper );
|
||||
|
||||
mapper.bindElements( data.item as Element, wrapper );
|
||||
mapper.bindElements( data.item as ModelElement, wrapper );
|
||||
|
||||
return toWidget( wrapper, writer, {
|
||||
label: t( 'Mermaid widget' ),
|
||||
@ -200,7 +200,7 @@ export default class MermaidEditing extends Plugin {
|
||||
const domConverter = this.editor.editing.view.domConverter;
|
||||
|
||||
if ( newSource ) {
|
||||
const mermaidView = conversionApi.mapper.toViewElement( data.item as Element );
|
||||
const mermaidView = conversionApi.mapper.toViewElement( data.item as ModelElement );
|
||||
if (!mermaidView) {
|
||||
return;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import previewModeIcon from '../theme/icons/preview-mode.svg';
|
||||
import splitModeIcon from '../theme/icons/split-mode.svg';
|
||||
import sourceModeIcon from '../theme/icons/source-mode.svg';
|
||||
import infoIcon from '../theme/icons/info.svg';
|
||||
import { ButtonView, Editor, Element, Locale, Observable, Plugin } from 'ckeditor5';
|
||||
import { ButtonView, Editor, ModelElement, Locale, Observable, Plugin } from 'ckeditor5';
|
||||
import InsertMermaidCommand from './commands/insertMermaidCommand.js';
|
||||
|
||||
/* global window, document */
|
||||
@ -69,7 +69,7 @@ export default class MermaidUI extends Plugin {
|
||||
|
||||
// Execute the command when the button is clicked.
|
||||
command.listenTo( buttonView, 'execute', () => {
|
||||
const mermaidItem = editor.execute( 'insertMermaidCommand' ) as Element;
|
||||
const mermaidItem = editor.execute( 'insertMermaidCommand' ) as ModelElement;
|
||||
const mermaidItemViewElement = editor.editing.mapper.toViewElement( mermaidItem );
|
||||
|
||||
view.scrollToTheSelection();
|
||||
|
Loading…
x
Reference in New Issue
Block a user