Issue #5718Opened March 4, 2024by mitcht0 reactions

BUG: Possible upgrade path issue where 'textnode' is now called 'wrapper' from 0.18 -> latest

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?

  1. Save component data from an earlier version of grapejs (0.18)
  2. 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 (1)

artfMarch 7, 20240 reactions

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.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.