Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch up to upstream #60

Merged
merged 6 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down
4 changes: 2 additions & 2 deletions packages/quill/package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"homepage": "https://quilljs.com",
Expand All @@ -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": {
Expand Down
4 changes: 0 additions & 4 deletions packages/quill/src/blots/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/quill/src/blots/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/quill/src/blots/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion packages/quill/src/core.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Quill, { Parchment, Range } from './core/quill.js';
import type {
Bounds,
DebugLevel,
EmitterSource,
ExpandedQuillOptions,
Expand All @@ -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,
Expand Down
28 changes: 11 additions & 17 deletions packages/quill/src/core/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class Quill {
}

formatText(
range: { index: number; length: number },
range: Range,
name: string,
value: unknown,
source?: EmitterSource,
Expand All @@ -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,
Expand Down Expand Up @@ -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') {
Expand All @@ -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') {
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 };
5 changes: 2 additions & 3 deletions packages/quill/src/core/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface Bounds {
width: number;
}

class Range {
export class Range {
constructor(
public index: number,
public length = 0,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -494,4 +493,4 @@ function contains(parent: Node, descendant: Node) {
return parent.contains(descendant);
}

export { Range, Selection as default };
export default Selection;
9 changes: 8 additions & 1 deletion packages/quill/src/quill.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Quill, { Parchment, Range } from './core.js';
import type {
Bounds,
DebugLevel,
EmitterSource,
ExpandedQuillOptions,
Expand Down Expand Up @@ -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;
3 changes: 3 additions & 0 deletions packages/quill/test/types/quill.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
}

{
Expand Down
2 changes: 1 addition & 1 deletion packages/website/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down