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

Upgrade Quill Dependency to 2.0.0-rc.4 #967

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@
"LICENSE"
],
"dependencies": {
"@types/quill": "^1.3.10",
"lodash": "^4.17.4",
"quill": "^1.3.7"
"lodash": "^4.17.21",
"quill": "^2.0.0-rc.4"
},
"peerDependencies": {
"react": "^16 || ^17 || ^18",
Expand All @@ -70,6 +69,7 @@
"jsdom-global": "^3.0.2",
"mocha": "^6.2.2",
"mocha-text-cov": "^0.1.1",
"quill-delta": "^5.1.0",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-test-renderer": "^16.11.0",
Expand Down
36 changes: 17 additions & 19 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ import React from 'react';
import ReactDOM from 'react-dom';
import isEqual from 'lodash/isEqual';

import Quill, {
QuillOptionsStatic,
DeltaStatic,
RangeStatic,
BoundsStatic,
StringMap,
Sources,
} from 'quill';
import Quill, { QuillOptions as QuillOptionsStatic } from 'quill';
import type { EmitterSource as Sources } from 'quill/core/emitter';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: EmitterSource can be imported directly from quill:

import type { EmitterSource } from 'quill';

The same applies to Range:

import type { Range } from 'quill';

import type { Range as RangeStatic } from 'quill/core/selection';
import type DeltaStatic from 'quill-delta';

// Merged namespace hack to export types along with default object
// See: https://github.com/Microsoft/TypeScript/issues/2719
Expand All @@ -23,6 +19,8 @@ namespace ReactQuill {
export type Range = RangeStatic | null;

export interface QuillOptions extends QuillOptionsStatic {
scrollingContainer?: HTMLElement | string | undefined,
strict?: boolean | undefined,
tabIndex?: number,
}

Expand All @@ -33,7 +31,7 @@ namespace ReactQuill {
defaultValue?: Value,
formats?: string[],
id?: string,
modules?: StringMap,
modules?: QuillOptions['modules'],
onChange?(
value: string,
delta: DeltaStatic,
Expand Down Expand Up @@ -69,12 +67,12 @@ namespace ReactQuill {
}

export interface UnprivilegedEditor {
getLength(): number;
getText(index?: number, length?: number): string;
getHTML(): string;
getBounds(index: number, length?: number): BoundsStatic;
getSelection(focus?: boolean): RangeStatic;
getContents(index?: number, length?: number): DeltaStatic;
getLength: Quill['getLength'];
getText: Quill['getText'];
getHTML: Quill['getSemanticHTML'];
getBounds: Quill['getBounds'];
getSelection: Quill['getSelection'];
getContents: Quill['getContents'];
}
}

Expand Down Expand Up @@ -328,7 +326,7 @@ class ReactQuill extends React.Component<ReactQuillProps, ReactQuillState> {
Creates an editor on the given element. The editor will be passed the
configuration, have its events bound,
*/
createEditor(element: Element, config: QuillOptions) {
createEditor(element: HTMLElement, config: QuillOptions) {
const editor = new Quill(element, config);
if (config.tabIndex != null) {
this.setEditorTabIndex(editor, config.tabIndex);
Expand Down Expand Up @@ -384,7 +382,7 @@ class ReactQuill extends React.Component<ReactQuillProps, ReactQuillState> {
this.value = value;
const sel = this.getEditorSelection();
if (typeof value === 'string') {
editor.setContents(editor.clipboard.convert(value));
editor.setContents(editor.clipboard.convert({html: value}));
} else {
editor.setContents(value);
}
Expand Down Expand Up @@ -432,7 +430,7 @@ class ReactQuill extends React.Component<ReactQuillProps, ReactQuillState> {
};
}

getEditingArea(): Element {
getEditingArea(): HTMLElement {
if (!this.editingArea) {
throw new Error('Instantiating on missing editing area');
}
Expand All @@ -443,7 +441,7 @@ class ReactQuill extends React.Component<ReactQuillProps, ReactQuillState> {
if (element.nodeType === 3) {
throw new Error('Editing area cannot be a text node');
}
return element as Element;
return element as HTMLElement;
}

/*
Expand Down