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

🏷️ Add module DEFAULTS types #3733

Merged
merged 1 commit into from
Jun 5, 2023
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
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