Skip to content

Commit

Permalink
Allows configuration of debounce time of the Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDeadJoe committed Mar 20, 2023
1 parent 4304a2c commit 54ca718
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/components/__module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ export default class Module<T extends ModuleNodes = Record<string, HTMLElement>>
this.eventsDispatcher = eventsDispatcher;
}

/**
* Returns config
*/
public getConfig(): EditorConfig {
return this.config;
}

/**
* Editor modules setter
*
Expand Down
6 changes: 5 additions & 1 deletion src/components/block/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export default class Block extends EventsDispatcher<BlockEvents> {
*
* @type {number}
*/
private readonly modificationDebounceTimer = 450;
private modificationDebounceTimer = 450; // eslint-disable-line @typescript-eslint/no-magic-numbers

/**
* Is fired when DOM mutation has been happened
Expand Down Expand Up @@ -278,6 +278,10 @@ export default class Block extends EventsDispatcher<BlockEvents> {
this.composeTunes(tunesData);

this.holder = this.compose();

if (this.api.getConfig()?.saverDebounce) {
this.modificationDebounceTimer = this.api.getConfig().saverDebounce;
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions types/configs/editor-config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ export interface EditorConfig {
*/
i18n?: I18nConfig;

/**
* Debounce time for Editor's MutationObserver
*/
saverDebounce?: number;

/**
* Fires when Editor is ready to work
*/
Expand Down

0 comments on commit 54ca718

Please sign in to comment.