Possible upgrade path issue where 'textnode' is now called 'wrapper' from 0.18 -> latest
Thanks @mitcht but as I already mentioned the main component could never been textnode in the first place so it doesn't make sense to handle such a case in the core or have this issue open. Anyway, if the logic works for you just use it in your editor.
Read full answer below ↓Question
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
Chrome Version 122.0.6261.95 (Official Build) (64-bit)
Reproducible demo link
https://jsfiddle.net/n4x6L1v0/2/
Describe the bug
How to reproduce the bug?
- Save component data from an earlier version of grapejs (0.18)
- Attempt to import into latest version of grapesjs as project data
What is the expected behavior? Grapes could simply replace watch for older 'textnode' entries and update them to be 'wrapper' entried.
What is the current behavior? Throws an offset error in the console
This code is not necessary to reproduce the bug, but it is currently allowing me to circumvent the problem.
// fixup broken wrapper
var data = JSON.parse(self.model().components())
if (data.pages[0].frames[0].component.type !== 'wrapper') {
data.pages[0].frames[0].component.type = 'wrapper'
self.model().components(JSON.stringify(data))
}
self.editor.loadProjectData(JSON.parse(self.model().components()));
Attached here is the output from my existing grapesjs when i drag over a text box only
{ "assets": [], "styles": [{ "selectors": ["row"], "style": { "display": "table", "padding-top": "10px", "padding-right": "10px", "padding-bottom": "10px", "padding-left": "10px", "width": "100%" } }], "pages": [{ "frames": [{ "component": { "tagName": "", "type": "textnode", "stylable": ["background", "background-color", "background-image", "background-repeat", "background-attachment", "background-position", "background-size"], "content": "Broken Text", "components": [{ "name": "Row", "droppable": ".cell", "classes": ["row"], "attributes": { "id": "i3kf" } }] }, "id": "fs6syHItKWdVv79U" }], "id": "1" }] }
It is almost perfect, except for type 'textnode' being at the base. I've read into the changes to the wrapper, changes and adjustments to the inline styles, etc. I'm pretty confident I understand what is wrong. I am just sharing that it might not be difficult to support this for migration ease.
Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (2)
Thanks @mitcht but as I already mentioned the main component could never been textnode in the first place so it doesn't make sense to handle such a case in the core or have this issue open.
Anyway, if the logic works for you just use it in your editor.
Thanks for reporting this, @mitcht.
Great suggestion about Possible upgrade path issue where 'textnode' is now called 'wrapper' from 0.18 -> latest! While this specific feature isn't yet in the core API, there are several ways to achieve similar behavior.
Using the event system:
editor.on('component:update', (component) => {
// your logic here
});
Alternative approaches:
- Listen to
selector:addfor CSS selector changes - Use
selector:customfor custom rules - Tap into the
change:*events for fine-grained tracking - Build a plugin that extends the editor with this capability
Making it official: If this feature would benefit many users, consider opening a formal Feature Request on the GrapesJS repo with:
- A detailed use case
- Code example showing the desired behavior
- Why this matters for your workflow
The core team is receptive to well-motivated feature requests backed by real use cases.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #4904
getHtml() producing invalid structure when there is js inside it
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? chrome latestReproducible demo link https://...
Issue #4752
Component with pointer-events: 'all' (except wrapper) or editable component are draggable & droppable to itself.
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome 107.0.5304.121 (Official Build) (arm6...
Issue #4754
Closing `</script>` tag not escaped for script properties
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Version 107.0.5304.122 (64-bit) Rep...
Issue #5229
textnode with content "null" is rendered as "null" not whitespace
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome Version 114.0.5735.199 (Official Buil...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Tutorial
Find the Right GrapesJS Plugin in Seconds: Smarter Discovery Is Live
We're shipping a set of discovery upgrades. New label filters, a proper compatibility switch for GrapesJS vs Studio, one-click and a smarter sort bar.
Tutorial
GJS Market 2.0 - Donations, Tracking, Labels and Better Product Discovery
We’ve rolled out a new set of GrapesJS marketplace updates across GJS Market, focused on improving how creators distribute products
Tutorial
Preset DevFuture 2.0 — New Update Released
Preset continues evolving as a clean, production-ready starting point for building visual editors powered by GrapesJS
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.