Skip to content

Commit

Permalink
Allows configuration of debounce time of Editor's MutationObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDeadJoe committed Nov 10, 2020
1 parent 4499e05 commit 3f4893b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/editor.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/components/modules/modificationsObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class ModificationsObserver extends Module {
*
* @type {number}
*/
public static readonly DebounceTimer = 450;
public DebounceTimer = 450;

/**
* MutationObserver instance
Expand All @@ -41,7 +41,7 @@ export default class ModificationsObserver extends Module {
if (_.isFunction(this.config.onChange)) {
this.config.onChange(this.Editor.API.methods);
}
}, ModificationsObserver.DebounceTimer);
}, this.DebounceTimer);

/**
* Array of native inputs in Blocks.
Expand Down Expand Up @@ -176,6 +176,9 @@ export default class ModificationsObserver extends Module {
* Sets observer and enables it
*/
private enableModule(): void {
if (this?.config?.saverDebounce) {
this.DebounceTimer = this.config.saverDebounce;
}
/**
* wait till Browser render Editor's Blocks
*/
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 @@ -80,6 +80,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 3f4893b

Please sign in to comment.