From db682f1c2eee9bc1aeeb3cd0868d1233cd24da77 Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Fri, 3 Feb 2023 15:41:47 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20Add=20module=20`DEFAULT?= =?UTF-8?q?S`=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/clipboard.ts | 2 ++ modules/history.ts | 2 ++ modules/keyboard.ts | 2 ++ modules/syntax.ts | 2 ++ modules/toolbar.ts | 7 ++++--- modules/uploader.ts | 4 +++- 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/clipboard.ts b/modules/clipboard.ts index af9a022732..39030920d9 100644 --- a/modules/clipboard.ts +++ b/modules/clipboard.ts @@ -71,6 +71,8 @@ interface ClipboardOptions { } class Clipboard extends Module { + static DEFAULTS: ClipboardOptions; + matchers: [Selector, Matcher][]; constructor(quill: Quill, options: Partial) { diff --git a/modules/history.ts b/modules/history.ts index 9f5aa320ee..a021a5dfc7 100644 --- a/modules/history.ts +++ b/modules/history.ts @@ -10,6 +10,8 @@ interface HistoryOptions { } class History extends Module { + static DEFAULTS: HistoryOptions; + lastRecorded: number; ignoreChange: boolean; stack: { diff --git a/modules/keyboard.ts b/modules/keyboard.ts index 9f6ea6f67e..31c02d57c9 100644 --- a/modules/keyboard.ts +++ b/modules/keyboard.ts @@ -58,6 +58,8 @@ interface KeyboardOptions { } class Keyboard extends Module { + static DEFAULTS: KeyboardOptions; + static match(evt: KeyboardEvent, binding) { if ( ['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(key => { diff --git a/modules/syntax.ts b/modules/syntax.ts index b7c994c5dc..e824fea518 100644 --- a/modules/syntax.ts +++ b/modules/syntax.ts @@ -193,6 +193,8 @@ interface SyntaxOptions { } class Syntax extends Module { + static DEFAULTS: SyntaxOptions & { hljs: any }; + static register() { Quill.register(CodeToken, true); // @ts-expect-error diff --git a/modules/toolbar.ts b/modules/toolbar.ts index 263eb9170e..9d4967339b 100644 --- a/modules/toolbar.ts +++ b/modules/toolbar.ts @@ -9,10 +9,13 @@ const debug = logger('quill:toolbar'); type Handler = (value: any) => void; interface ToolbarProps { - container: HTMLElement; + container?: HTMLElement; + handlers?: Record; } class Toolbar extends Module { + static DEFAULTS: ToolbarProps; + container: HTMLElement; controls: [string, HTMLElement][]; handlers: Record; @@ -36,9 +39,7 @@ class Toolbar extends Module { this.container.classList.add('ql-toolbar'); this.controls = []; this.handlers = {}; - // @ts-expect-error Object.keys(this.options.handlers).forEach(format => { - // @ts-expect-error this.addHandler(format, this.options.handlers[format]); }); Array.from(this.container.querySelectorAll('button, select')).forEach( diff --git a/modules/uploader.ts b/modules/uploader.ts index 5fff8f4aba..84dbe27bf8 100644 --- a/modules/uploader.ts +++ b/modules/uploader.ts @@ -10,6 +10,8 @@ interface UploaderOptions { } class Uploader extends Module { + static DEFAULTS: UploaderOptions; + constructor(quill: Quill, options: Partial) { super(quill, options); quill.root.addEventListener('drop', e => { @@ -61,7 +63,7 @@ Uploader.DEFAULTS = { Promise.all(promises).then(images => { const update = images.reduce((delta: Delta, image) => { return delta.insert({ image }); - }, new Delta().retain(range.index).delete(range.length)); + }, new Delta().retain(range.index).delete(range.length)) as Delta; this.quill.updateContents(update, Emitter.sources.USER); this.quill.setSelection( range.index + images.length,