diff --git a/src/demo.js b/src/demo.js index 5c895e623..c0510c37b 100644 --- a/src/demo.js +++ b/src/demo.js @@ -6,6 +6,7 @@ require(['config/require-config'], function() { { + noticeOnUnload: 0, container : '#gjs', height: '100%', fromElement: true, diff --git a/src/grapesjs/config/config.js b/src/grapesjs/config/config.js index 716f709d4..3f404fb09 100644 --- a/src/grapesjs/config/config.js +++ b/src/grapesjs/config/config.js @@ -22,6 +22,9 @@ define(function () { // Enable/Disable undo manager undoManager: true, + // Show an alert before unload the page + noticeOnUnload: true, + // Storage Manager storage: {}, diff --git a/src/grapesjs/main.js b/src/grapesjs/main.js index 130baf652..5d79ab4a0 100644 --- a/src/grapesjs/main.js +++ b/src/grapesjs/main.js @@ -45,6 +45,11 @@ define(function (require) { if(!els) throw new Error("'container' is required"); + if(c.noticeOnUnload) + window.onbeforeunload = function(e) { + return 1; + }; + c.el = document.querySelector(els); var editor = new Editor(c).init();