diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d065aff55..e7b79aaae2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ # [Unreleased] +# 2.0.0-rc.5 + - **Clipboard** Add support for Quill v1 list attributes - 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 2a6f5216ed..b753828b66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "quill-monorepo", - "version": "2.0.0-rc.4", + "version": "2.0.0-rc.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "quill-monorepo", - "version": "2.0.0-rc.4", + "version": "2.0.0-rc.5", "license": "BSD-3-Clause", "workspaces": [ "packages/*" @@ -12346,9 +12346,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", @@ -16223,13 +16223,13 @@ }, "packages/quill": { "name": "@reedsy/quill", - "version": "2.0.0-reedsy-5.0.4", + "version": "2.0.0-reedsy-5.0.5", "license": "BSD-3-Clause", "dependencies": { "@reedsy/quill-delta": "^5.1.0-reedsy.3.0.0", "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": { @@ -16530,7 +16530,7 @@ "dev": true }, "packages/website": { - "version": "2.0.0-rc.4", + "version": "2.0.0-rc.5", "license": "BSD-3-Clause", "dependencies": { "@codesandbox/sandpack-react": "^2.11.3", diff --git a/package.json b/package.json index 6f8a64bc55..4d988c3646 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "quill-monorepo", - "version": "2.0.0-rc.4", + "version": "2.0.0-rc.5", "description": "Quill development environment", "private": true, "author": "Jason Chen ", diff --git a/packages/quill/package.json b/packages/quill/package.json index 491d0a0f34..74fa17234e 100644 --- a/packages/quill/package.json +++ b/packages/quill/package.json @@ -1,6 +1,6 @@ { "name": "@reedsy/quill", - "version": "2.0.0-reedsy-5.0.4", + "version": "2.0.0-reedsy-5.0.5", "description": "Your powerful, rich text editor", "author": "Jason Chen ", "homepage": "https://quilljs.com", @@ -10,7 +10,7 @@ "@reedsy/quill-delta": "^5.1.0-reedsy.3.0.0", "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 72c36f8b3c..51790e50ef 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 0ce5ff5e57..1c834eecd8 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.ts b/packages/quill/src/core.ts index e171e1f55f..5dded9bffe 100644 --- a/packages/quill/src/core.ts +++ b/packages/quill/src/core.ts @@ -1,5 +1,6 @@ import Quill, { Parchment, Range } from './core/quill.js'; import type { + Bounds, DebugLevel, EmitterSource, ExpandedQuillOptions, @@ -26,7 +27,13 @@ import Selection from './core/selection.js'; import UINode from './modules/uiNode.js'; export { Delta, Op, OpIterator, AttributeMap, Parchment, Range }; -export type { DebugLevel, EmitterSource, ExpandedQuillOptions, QuillOptions }; +export type { + Bounds, + DebugLevel, + EmitterSource, + ExpandedQuillOptions, + QuillOptions, +}; Quill.register({ 'blots/block': Block, diff --git a/packages/quill/src/core/quill.ts b/packages/quill/src/core/quill.ts index 5e2cbb6229..aad2b091b0 100644 --- a/packages/quill/src/core/quill.ts +++ b/packages/quill/src/core/quill.ts @@ -403,7 +403,7 @@ class Quill { } formatText( - range: { index: number; length: number }, + range: Range, name: string, value: unknown, source?: EmitterSource, @@ -422,7 +422,7 @@ class Quill { source?: EmitterSource, ): Delta; formatText( - index: number | { index: number; length: number }, + index: number | Range, length: number | string, name: string | unknown, value?: unknown | EmitterSource, @@ -474,11 +474,11 @@ class Quill { } getFormat(index?: number, length?: number): { [format: string]: unknown }; - getFormat(range?: { index: number; length: number }): { + getFormat(range?: Range): { [format: string]: unknown; }; getFormat( - index: { index: number; length: number } | number = this.getSelection(true), + index: Range | number = this.getSelection(true), length = 0, ): { [format: string]: unknown } { if (typeof index === 'number') { @@ -503,10 +503,10 @@ class Quill { return this.scroll.line(index); } - getLines(range: { index: number; length: number }): (Block | BlockEmbed)[]; + getLines(range: Range): (Block | BlockEmbed)[]; getLines(index?: number, length?: number): (Block | BlockEmbed)[]; getLines( - index: { index: number; length: number } | number = 0, + index: Range | number = 0, length = Number.MAX_VALUE, ): (Block | BlockEmbed)[] { if (typeof index !== 'number') { @@ -527,12 +527,9 @@ class Quill { return this.selection.getRange()[0]; } - getSemanticHTML(range: { index: number; length: number }): string; + getSemanticHTML(range: Range): string; getSemanticHTML(index?: number, length?: number): string; - getSemanticHTML( - index: { index: number; length: number } | number = 0, - length?: number, - ) { + getSemanticHTML(index: Range | number = 0, length?: number) { if (typeof index === 'number') { length = length ?? this.getLength() - index; } @@ -541,12 +538,9 @@ class Quill { return this.editor.getHTML(index, length); } - getText(range?: { index: number; length: number }): string; + getText(range?: Range): string; getText(index?: number, length?: number): string; - getText( - index: { index: number; length: number } | number = 0, - length?: number, - ): string { + getText(index: Range | number = 0, length?: number): string { if (typeof index === 'number') { length = length ?? this.getLength() - index; } @@ -1034,7 +1028,7 @@ function shiftRange( return new Range(start, end - start); } -export type { DebugLevel, EmitterSource }; +export type { Bounds, DebugLevel, EmitterSource }; export { Parchment, Range }; export { globalRegistry, expandConfig, overload, Quill as default }; diff --git a/packages/quill/src/core/selection.ts b/packages/quill/src/core/selection.ts index e4a51f4105..dedd84cb47 100644 --- a/packages/quill/src/core/selection.ts +++ b/packages/quill/src/core/selection.ts @@ -32,7 +32,7 @@ export interface Bounds { width: number; } -class Range { +export class Range { constructor( public index: number, public length = 0, @@ -172,7 +172,6 @@ class Selection extends Module { // 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 @@ -494,4 +493,4 @@ function contains(parent: Node, descendant: Node) { return parent.contains(descendant); } -export { Range, Selection as default }; +export default Selection; diff --git a/packages/quill/src/quill.ts b/packages/quill/src/quill.ts index bc2535b1b8..0c3626fd8a 100644 --- a/packages/quill/src/quill.ts +++ b/packages/quill/src/quill.ts @@ -1,5 +1,6 @@ import Quill, { Parchment, Range } from './core.js'; import type { + Bounds, DebugLevel, EmitterSource, ExpandedQuillOptions, @@ -114,7 +115,13 @@ Quill.register( true, ); -export type { DebugLevel, EmitterSource, ExpandedQuillOptions, QuillOptions }; +export type { + Bounds, + DebugLevel, + EmitterSource, + ExpandedQuillOptions, + QuillOptions, +}; export { Parchment, Range }; export default Quill; diff --git a/packages/quill/test/types/quill.test-d.ts b/packages/quill/test/types/quill.test-d.ts index d7ae524188..1d65de3823 100644 --- a/packages/quill/test/types/quill.test-d.ts +++ b/packages/quill/test/types/quill.test-d.ts @@ -179,6 +179,9 @@ const quill = new Quill('#editor'); { quill.scrollRectIntoView({ left: 0, right: 0, top: 0, bottom: 0 }); + quill.scrollRectIntoView( + document.createElement('div').getBoundingClientRect(), + ); } { diff --git a/packages/website/package.json b/packages/website/package.json index c1aec73cfc..bffcea2f8e 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "website", - "version": "2.0.0-rc.4", + "version": "2.0.0-rc.5", "description": "Quill official website", "private": true, "homepage": "https://quilljs.com",