Skip to content

Commit

Permalink
Remove unneeded ScrollConstructor
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Jan 16, 2024
1 parent c765212 commit f42cceb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
6 changes: 3 additions & 3 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 packages/quill/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"eventemitter3": "^5.0.1",
"lodash-es": "^4.17.21",
"parchment": "github:quilljs/parchment#c4cd8723382972dc3c5b5911b4dfabc0047bb26e",
"parchment": "github:quilljs/parchment#9d148df41cc3d62ab07c25ebcead46a3d513d2c6",
"quill-delta": "^5.1.0"
},
"devDependencies": {
Expand Down
8 changes: 0 additions & 8 deletions packages/quill/src/blots/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,4 @@ function insertInlineContents(
}, index);
}

export interface ScrollConstructor {
new (
registry: Registry,
domNode: HTMLDivElement,
options: { emitter: Emitter },
): Scroll;
}

export default Scroll;
14 changes: 8 additions & 6 deletions packages/quill/src/core/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Delta from 'quill-delta';
import type { BlockEmbed } from '../blots/block';
import type Block from '../blots/block';
import type Scroll from '../blots/scroll';
import type { ScrollConstructor } from '../blots/scroll';
import type Clipboard from '../modules/clipboard';
import type History from '../modules/history';
import type Keyboard from '../modules/keyboard';
Expand Down Expand Up @@ -169,13 +168,16 @@ class Quill {
this.root = this.addContainer('ql-editor');
this.root.classList.add('ql-blank');
this.emitter = new Emitter();
// @ts-expect-error TODO: fix BlotConstructor
const ScrollBlot = this.options.registry.query(
Parchment.ScrollBlot.blotName,
) as ScrollConstructor;
const scrollBlotName = Parchment.ScrollBlot.blotName;
const ScrollBlot = this.options.registry.query(scrollBlotName);
if (!ScrollBlot || !('blotName' in ScrollBlot)) {
throw new Error(
`Cannot initialize Quill without "${scrollBlotName}" blot`,
);
}
this.scroll = new ScrollBlot(this.options.registry, this.root, {
emitter: this.emitter,
});
}) as Scroll;
this.editor = new Editor(this.scroll);
this.selection = new Selection(this.scroll, this.emitter);
this.composition = new Composition(this.scroll, this.emitter);
Expand Down
3 changes: 2 additions & 1 deletion packages/quill/test/unit/__helpers__/factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Registry } from 'parchment';
import type { Attributor } from 'parchment';

import Block from '../../../src/blots/block';
import Break from '../../../src/blots/break';
Expand All @@ -14,7 +15,7 @@ export const createRegistry = (formats: unknown[] = []) => {
const registry = new Registry();

formats.forEach((format) => {
registry.register(format);
registry.register(format as Attributor);
});
registry.register(Block);
registry.register(Break);
Expand Down

0 comments on commit f42cceb

Please sign in to comment.