From 6aa3b8dbd7fb6dd6cb4d22f40360dda840137a8b Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 12 Jul 2025 19:38:36 +0300 Subject: [PATCH] chore(ckeditor5-admonition): fix references --- .../src/admonitioncommand.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/ckeditor5-admonition/src/admonitioncommand.ts b/packages/ckeditor5-admonition/src/admonitioncommand.ts index 000224519..35456efbc 100644 --- a/packages/ckeditor5-admonition/src/admonitioncommand.ts +++ b/packages/ckeditor5-admonition/src/admonitioncommand.ts @@ -8,7 +8,7 @@ */ import { Command, first } from 'ckeditor5'; -import type { ViewDocumentFragment, Element, Position, Range, Schema, Writer } from 'ckeditor5'; +import type { ModelElement, ModelPosition, ModelRange, ModelSchema, ModelWriter, ModelDocumentFragment } from 'ckeditor5'; /** * The block quote command plugin. @@ -154,18 +154,18 @@ export default class AdmonitionCommand extends Command { * start it or end it, then the quote will be split (if needed) and the blocks * will be moved out of it, so other quoted blocks remained quoted. */ - private _removeQuote( writer: Writer, blocks: Array ): void { + private _removeQuote( writer: ModelWriter, blocks: Array ): void { // Unquote all groups of block. Iterate in the reverse order to not break following ranges. getRangesOfBlockGroups( writer, blocks ).reverse().forEach( groupRange => { if ( groupRange.start.isAtStart && groupRange.end.isAtEnd ) { - writer.unwrap( groupRange.start.parent as Element ); + writer.unwrap( groupRange.start.parent as ModelElement ); return; } // The group of blocks are at the beginning of an so let's move them left (out of the ). if ( groupRange.start.isAtStart ) { - const positionBefore = writer.createPositionBefore( groupRange.start.parent as Element ); + const positionBefore = writer.createPositionBefore( groupRange.start.parent as ModelElement ); writer.move( groupRange, positionBefore ); @@ -180,7 +180,7 @@ export default class AdmonitionCommand extends Command { // Now we are sure that groupRange.end.isAtEnd is true, so let's move the blocks right. - const positionAfter = writer.createPositionAfter( groupRange.end.parent as Element ); + const positionAfter = writer.createPositionAfter( groupRange.end.parent as ModelElement ); writer.move( groupRange, positionAfter ); } ); @@ -189,9 +189,9 @@ export default class AdmonitionCommand extends Command { /** * Applies the quote to given blocks. */ - private _applyQuote( writer: Writer, blocks: Array, type?: AdmonitionType): void { + private _applyQuote( writer: ModelWriter, blocks: Array, type?: AdmonitionType): void { this._lastType = type; - const quotesToMerge: Array = []; + const quotesToMerge: Array = []; // Quote all groups of block. Iterate in the reverse order to not break following ranges. getRangesOfBlockGroups( writer, blocks ).reverse().forEach( groupRange => { @@ -205,7 +205,7 @@ export default class AdmonitionCommand extends Command { writer.wrap( groupRange, quote ); } else if (quote.is("element")) { this.editor.model.change((writer) => { - writer.setAttribute(ADMONITION_TYPE_ATTRIBUTE, type, quote as Element); + writer.setAttribute(ADMONITION_TYPE_ATTRIBUTE, type, quote as ModelElement); }); } @@ -228,7 +228,7 @@ export default class AdmonitionCommand extends Command { } } -function findQuote( elementOrPosition: Element | Position ): Element | ViewDocumentFragment | null { +function findQuote( elementOrPosition: ModelElement | ModelPosition ): ModelElement | ModelDocumentFragment | null { return elementOrPosition.parent!.name == 'aside' ? elementOrPosition.parent : null; } @@ -239,7 +239,7 @@ function findQuote( elementOrPosition: Element | Position ): Element | ViewDocum * blocks: [ a, b, d, f, g, h ] * output ranges: [ab]c[d]e[fgh] */ -function getRangesOfBlockGroups( writer: Writer, blocks: Array ): Array { +function getRangesOfBlockGroups( writer: ModelWriter, blocks: Array ): Array { let startPosition; let i = 0; const ranges = []; @@ -266,9 +266,9 @@ function getRangesOfBlockGroups( writer: Writer, blocks: Array ): Array /** * Checks whether can wrap the block. */ -function checkCanBeQuoted( schema: Schema, block: Element ): boolean { +function checkCanBeQuoted( schema: ModelSchema, block: ModelElement ): boolean { // TMP will be replaced with schema.checkWrap(). - const isBQAllowed = schema.checkChild( block.parent as Element, 'aside' ); + const isBQAllowed = schema.checkChild( block.parent as ModelElement, 'aside' ); const isBlockAllowedInBQ = schema.checkChild( [ '$root', 'aside' ], block ); return isBQAllowed && isBlockAllowedInBQ;