Skip to content

Commit

Permalink
🏷️ Add module DEFAULTS types
Browse files Browse the repository at this point in the history
  • Loading branch information
alecgibson authored and luin committed Jun 5, 2023
1 parent d490704 commit 27d9a6e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions modules/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ interface ClipboardOptions {
}

class Clipboard extends Module<ClipboardOptions> {
static DEFAULTS: ClipboardOptions;

matchers: [Selector, Matcher][];

constructor(quill: Quill, options: Partial<ClipboardOptions>) {
Expand Down
2 changes: 2 additions & 0 deletions modules/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ interface HistoryOptions {
}

class History extends Module<HistoryOptions> {
static DEFAULTS: HistoryOptions;

lastRecorded: number;
ignoreChange: boolean;
stack: {
Expand Down
2 changes: 2 additions & 0 deletions modules/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ interface KeyboardOptions {
}

class Keyboard extends Module<KeyboardOptions> {
static DEFAULTS: KeyboardOptions;

static match(evt: KeyboardEvent, binding) {
if (
['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(key => {
Expand Down
2 changes: 2 additions & 0 deletions modules/syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ interface SyntaxOptions {
}

class Syntax extends Module<SyntaxOptions> {
static DEFAULTS: SyntaxOptions & { hljs: any };

static register() {
Quill.register(CodeToken, true);
// @ts-expect-error
Expand Down
7 changes: 4 additions & 3 deletions modules/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ const debug = logger('quill:toolbar');
type Handler = (value: any) => void;

interface ToolbarProps {
container: HTMLElement;
container?: HTMLElement;
handlers?: Record<string, Handler>;
}

class Toolbar extends Module<ToolbarProps> {
static DEFAULTS: ToolbarProps;

container: HTMLElement;
controls: [string, HTMLElement][];
handlers: Record<string, Handler>;
Expand All @@ -36,9 +39,7 @@ class Toolbar extends Module<ToolbarProps> {
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(
Expand Down
4 changes: 3 additions & 1 deletion modules/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ interface UploaderOptions {
}

class Uploader extends Module<UploaderOptions> {
static DEFAULTS: UploaderOptions;

constructor(quill: Quill, options: Partial<UploaderOptions>) {
super(quill, options);
quill.root.addEventListener('drop', e => {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 27d9a6e

Please sign in to comment.