[Bug] Issue with editor.destroy() and reinitialization
Question
With GrapesJS 0.14.33 editor.destroy() was introduced (https://github.com/artf/grapesjs/commit/52f8bdf2e894de536d44c1699c1e18bbaf52488f), so that it is possible to initialize, destroy and reinitialize an editor.
Problem
After initializing, destroying, re-initializing, I am however experiencing exceptions when editing text-blocks with the default RTE. Today's destroy() eventually forgets to tear down s.th., so that it is possible to provoke the following:
Uncaught TypeError: Cannot read property 'body' of null
at Object.getBody (grapes.js:24607)
at Object.getWrapperEl (grapes.js:24616)
at child.getCanvasWrapper (grapes.js:26883)
at child.initialize (grapes.js:26842)
at child.Backbone.View (grapes.js:5596)
at child [as constructor] (grapes.js:6256)
at new child (grapes.js:6256)
at Object.get (grapes.js:26519)
at Object.method (grapes.js:38111)
at dispatch (grapes.js:19528)
or:
Uncaught TypeError: Cannot read property 'hasFocus' of null
Demo
Please find this fiddle for 0.14.33 including reproduction steps: https://jsfiddle.net/srkm18yu/
Related PRs and Issues
In my opinion PR #920 has already fixed part of this problem, but was not sufficient.
Other people have experienced the same issue in the past, especially when they are building SPAs, e.g. with Angular, since an SPA will reinitialize GrapesJS everytime the user navigates to page using a GrapesJS editor e.g. #1288.
Answers (2)
Hey @artf , are you planning to fix this in future releases? I belive this is relevant to many other issues people encounter, especially when using JS/SPA frameworks.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1051
[BUG] CommandAbstract's callRun and callStop should return result for backward compatibility
Hi @artf, after the latest upgrade (0.14.9) some of my commands that rely on the results of other commands fail. This happens because of th...
Issue #980
[BUG] Related with task https://github.com/artf/grapesjs/issues/873
Hello, After restoring editor from db still have some part of bug present. It seems inside of script: function () traits will have old valu...
Issue #581
Reading component related events
The Editor API wiki lists a set of component-related events that can be listened to (e.g. component:add, component:update). There is howeve...
Issue #1109
[QUESTION] Column blocks not droppable in canvas
Morning @artf :) I'm experiencing an similar problem to this issue. I can't drop any block (text, image, etc.) inside the column block from...
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.