Ignore/avoid changeCount
Question
Due to https://github.com/artf/grapesjs/issues/436, I cannot rely on StorageManager's Remote Load method to load a template from a REST endpoint, so I'm falling back to alternatives as editor.setComponents() and editor.setStyle() (being used within a command, so grapesjs and editor are available).
Unfortunately, those methods make changesCount to increase and triggers onbeforeunload event when our users try to leave the webpage.
Also, including sentences like editor.editor.set('changesCount', 0); in the command are useless, since changesCount gets incremented as soon as the command finishes (even after completing run() and stop() execution).
Is there any workaround this issue? Or any way to override changesCount right after .setComponents()/.setStyles() are used?
Thanks. PS: As for https://github.com/artf/grapesjs/issues/436, I'll be working on a refactor proposal for fetch library to make it REST-compliant. Hope to push it at some point next week
Answers (3)
Hi @santiph well, if the problem is onbeforeunload you can disable it with noticeOnUnload
grapesjs.init({
...
noticeOnUnload: false
})
Hi @artf I need to warn the user know of any unsaved changes consistently. And skip it when there's nothing new to be saved: When a new empty template is created, right after saving or right after loading a template, no confirmation message should be displayed.
Saving scenario through StorageManager works as expected. Loading doesn't, unfortunately. At least not when components, styles, html and so on is being loaded through the editor's API, not the StorageManager .load().
I could test it with remote storage fully:
onbeforeunload is disabled, as expected, on closing right after saving.
Unfortunately, it's still being displayed on closing right after loading a new template.
After a little debugging, loading a new template seems to increase changesCount to 1.
(Load changesCount = 1. Load changesCount = 2. Load changesCount = 3.)
How could this counter be reseted if the reason of template change was Loading a new one?
Related Questions and Answers
Continue research with similar issue discussions.
Issue #768
IE browser issue
Hi @artf , Created this issue due to https://github.com/artf/grapesjs/issues/214 has been closed ... I cloned the latest repo and run it on...
Issue #1908
[question] Cannot read property 'indexOf' of undefined
I found a previous result here: https://github.com/artf/grapesjs/issues/1772 however I can still not get it to work, using the most basic s...
Issue #901
Can we have local and remote storage at the same time.
WARNING READ and FOLLOW next 5 steps, then REMOVE them before posting the issueFollow CONTRIBUTING Guidelines https://github.com/artf/grape...
Issue #1757
Remote storagemanager not working
Hello, For 2 days I am fighting with the storageManager. I couldn't load template from remote file. Finaly I discovered that it is working...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.