MCPcopy
hub / github.com/GrapesJS/grapesjs / updateChanges

Method updateChanges

packages/core/src/editor/model/Editor.ts:432–448  ·  view source on GitHub ↗

* Set the alert before unload in case it's requested * and there are unsaved changes * @private

(m: any, v: any, opts: ObjectAny)

Source from the content-addressed store, hash-verified

430 * @private
431 */
432 updateChanges(m: any, v: any, opts: ObjectAny) {
433 const stm = this.Storage;
434 const changes = this.getDirtyCount();
435
436 if (!opts.isClear) {
437 this.updateItr && clearTimeout(this.updateItr);
438 this.updateItr = setTimeout(() => this.trigger(EditorEvents.update));
439 }
440
441 if (this.config.noticeOnUnload) {
442 window.onbeforeunload = changes ? () => true : null;
443 }
444
445 if (stm.isAutosave() && changes >= stm.getStepsBeforeSave()) {
446 this.store().catch((err) => this.logError(err));
447 }
448 }
449
450 /**
451 * Load generic module

Callers

nothing calls this directly

Calls 6

getDirtyCountMethod · 0.95
triggerMethod · 0.95
storeMethod · 0.95
logErrorMethod · 0.95
isAutosaveMethod · 0.80
getStepsBeforeSaveMethod · 0.80

Tested by

no test coverage detected