From 70eece14298006cddf3a17f05c04bea2dd83ae08 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 12 Jul 2025 19:24:39 +0300 Subject: [PATCH] chore(ckeditor5-mermaid): fix references: Element -> ModelElement --- .../src/commands/mermaidPreviewCommand.ts | 4 ++-- .../src/commands/mermaidSourceViewCommand.ts | 4 ++-- .../src/commands/mermaidSplitViewCommand.ts | 4 ++-- packages/ckeditor5-mermaid/src/mermaidediting.ts | 8 ++++---- packages/ckeditor5-mermaid/src/mermaidui.ts | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/ckeditor5-mermaid/src/commands/mermaidPreviewCommand.ts b/packages/ckeditor5-mermaid/src/commands/mermaidPreviewCommand.ts index 420ab111b..b4de57f8b 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.ts index 67e5e1954..fd623a6b2 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.ts index 692e707cb..d78c4c060 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.ts index 1e2fc2e88..9ee150fb1 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.ts index e7109c0c0..d5fc6519e 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();