Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(ckeditor5-mermaid): fix references: Element -> ModelElement
Elian Doran70eece142980
diff --git a/packages/ckeditor5-mermaid/src/commands/mermaidPreviewCommand.ts b/packages/ckeditor5-mermaid/src/commands/mermaidPreviewCommand.tsindex 420ab111ba..b4de57f8b3 100644--- a/packages/ckeditor5-mermaid/src/commands/mermaidPreviewCommand.ts+++ b/packages/ckeditor5-mermaid/src/commands/mermaidPreviewCommand.ts@@ -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 => {diff --git a/packages/ckeditor5-mermaid/src/commands/mermaidSourceViewCommand.ts b/packages/ckeditor5-mermaid/src/commands/mermaidSourceViewCommand.tsindex 67e5e19548..fd623a6b2e 100644--- a/packages/ckeditor5-mermaid/src/commands/mermaidSourceViewCommand.ts+++ b/packages/ckeditor5-mermaid/src/commands/mermaidSourceViewCommand.ts@@ -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' ) {diff --git a/packages/ckeditor5-mermaid/src/commands/mermaidSplitViewCommand.ts b/packages/ckeditor5-mermaid/src/commands/mermaidSplitViewCommand.tsindex 692e707cb6..d78c4c0605 100644--- a/packages/ckeditor5-mermaid/src/commands/mermaidSplitViewCommand.ts+++ b/packages/ckeditor5-mermaid/src/commands/mermaidSplitViewCommand.ts@@ -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' ) {diff --git a/packages/ckeditor5-mermaid/src/mermaidediting.ts b/packages/ckeditor5-mermaid/src/mermaidediting.tsindex 1e2fc2e88a..9ee150fb18 100644--- a/packages/ckeditor5-mermaid/src/mermaidediting.ts+++ b/packages/ckeditor5-mermaid/src/mermaidediting.ts@@ -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;}diff --git a/packages/ckeditor5-mermaid/src/mermaidui.ts b/packages/ckeditor5-mermaid/src/mermaidui.tsindex e7109c0c0b..d5fc6519eb 100644--- a/packages/ckeditor5-mermaid/src/mermaidui.ts+++ b/packages/ckeditor5-mermaid/src/mermaidui.ts@@ -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();