From 20f02f55e30ca87c0c539632b36c6c52ca4670eb Mon Sep 17 00:00:00 2001 From: Zihua Li Date: Thu, 4 Apr 2024 21:03:08 +0800 Subject: [PATCH] Allow ref for insertBefore to be null --- CHANGELOG.md | 1 + package-lock.json | 8 ++++---- packages/quill/package.json | 2 +- packages/quill/src/blots/block.ts | 4 ---- packages/quill/src/blots/embed.ts | 1 - packages/quill/src/blots/scroll.ts | 2 +- packages/quill/src/core/selection.ts | 1 - 7 files changed, 7 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0306aa787c..eb2a6117a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fix overload declarations for `quill.formatText()` and other methods - Expose Bounds type for getBounds() - Expose Range type +- Allow ref for insertBefore to be null # 2.0.0-rc.4 diff --git a/package-lock.json b/package-lock.json index cbf28ef92b..977b87602f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14782,9 +14782,9 @@ } }, "node_modules/parchment": { - "version": "3.0.0-rc.0", - "resolved": "https://registry.npmjs.org/parchment/-/parchment-3.0.0-rc.0.tgz", - "integrity": "sha512-JyVx3qaAkFPOCrJpENNYnQkxBYRbo9oPEU2LMJX4g1czXmwtzLDWztFRe90BXrw/LBRLDfZpHcL8TvIGkS1vIA==" + "version": "3.0.0-rc.1", + "resolved": "https://registry.npmjs.org/parchment/-/parchment-3.0.0-rc.1.tgz", + "integrity": "sha512-UiXun/99vbUgfPgAIuyZzqRN1YARfMz3ktAoTOxDWnrK/OMQlshPh0TKrNhePxxDWCGz/xVsexMtsaEQy+fmXQ==" }, "node_modules/parent-module": { "version": "1.0.1", @@ -19016,7 +19016,7 @@ "dependencies": { "eventemitter3": "^5.0.1", "lodash-es": "^4.17.21", - "parchment": "3.0.0-rc.0", + "parchment": "3.0.0-rc.1", "quill-delta": "^5.1.0" }, "devDependencies": { diff --git a/packages/quill/package.json b/packages/quill/package.json index bca4b6f8c5..3fa562e67d 100644 --- a/packages/quill/package.json +++ b/packages/quill/package.json @@ -9,7 +9,7 @@ "dependencies": { "eventemitter3": "^5.0.1", "lodash-es": "^4.17.21", - "parchment": "3.0.0-rc.0", + "parchment": "3.0.0-rc.1", "quill-delta": "^5.1.0" }, "devDependencies": { diff --git a/packages/quill/src/blots/block.ts b/packages/quill/src/blots/block.ts index e1f1607e61..e4c4f98747 100644 --- a/packages/quill/src/blots/block.ts +++ b/packages/quill/src/blots/block.ts @@ -90,7 +90,6 @@ class Block extends BlockBlot { } moveChildren(target: Parent, ref?: Blot | null) { - // @ts-expect-error Parchment types are wrong super.moveChildren(target, ref); this.cache = {}; } @@ -116,7 +115,6 @@ class Block extends BlockBlot { this.parent.insertBefore(clone, this); return this; } - // @ts-expect-error Fix me later this.parent.insertBefore(clone, this.next); return clone; } @@ -172,11 +170,9 @@ class BlockEmbed extends EmbedBlot { }); const ref = this.split(index); blocks.forEach((block) => { - // @ts-expect-error Fix me later this.parent.insertBefore(block, ref); }); if (text) { - // @ts-expect-error Fix me later this.parent.insertBefore(this.scroll.create('text', text), ref); } } diff --git a/packages/quill/src/blots/embed.ts b/packages/quill/src/blots/embed.ts index 2e019f7613..2668b89893 100644 --- a/packages/quill/src/blots/embed.ts +++ b/packages/quill/src/blots/embed.ts @@ -65,7 +65,6 @@ class Embed extends EmbedBlot { }; } else { textNode = document.createTextNode(text); - // @ts-expect-error Fix me later this.parent.insertBefore(this.scroll.create(textNode), this.next); range = { startNode: textNode, diff --git a/packages/quill/src/blots/scroll.ts b/packages/quill/src/blots/scroll.ts index 07fc2458db..9975e12831 100644 --- a/packages/quill/src/blots/scroll.ts +++ b/packages/quill/src/blots/scroll.ts @@ -124,7 +124,7 @@ class Scroll extends ScrollBlot { this.optimize(); } - insertBefore(blot: Blot, ref?: Blot) { + insertBefore(blot: Blot, ref?: Blot | null) { if (blot.statics.scope === Scope.INLINE_BLOT) { const wrapper = this.scroll.create( this.statics.defaultChild.blotName, diff --git a/packages/quill/src/core/selection.ts b/packages/quill/src/core/selection.ts index 79ed119fe5..33f7f2a576 100644 --- a/packages/quill/src/core/selection.ts +++ b/packages/quill/src/core/selection.ts @@ -162,7 +162,6 @@ class Selection { // TODO Give blot ability to not split if (blot instanceof LeafBlot) { const after = blot.split(nativeRange.start.offset); - // @ts-expect-error Fix me later blot.parent.insertBefore(this.cursor, after); } else { // @ts-expect-error TODO: nativeRange.start.node doesn't seem to match function signature