Issue #2691✓ SolvedOpened March 31, 2020by sathyanarayananaCES8 reactions

Losing the component information on saving the code from Code Editor

Quick answerby pouyamiralayi3

@jenter #1331 comment and #2644 comment are good examples. Also checkout #2664 comment which is a pitfall to avoid! Cheers!

Read full answer below ↓

Question

I have integrated the code edit option in the Web builder.Using editor.getHtml() to get the current HTML content and populate in the code editorWhile saving the code from the code editor, I am using editor.setComponents() to set the edited content to the builder canvas. IssuesOn Saving the html from the code editor, it loses all the old component related information and acts as a new component with default values in the traits. data-gjs-type becomes default and it is not recognizing the custom components. Anaysis & Thoughts On checking it seems like,when we use editor.getHtml() it gives the f...

Answers (3)

👍 Most helpfulpouyamiralayiApril 1, 2020

@jenter #1331 comment and #2644 comment are good examples. Also checkout #2664 comment which is a pitfall to avoid! Cheers!

noogenApril 5, 2020

@sathyanarayananaCES First, to echo others that it is best to use get/setComponents and get/setStyle to save the content of the editor. If I understand your usage correctly, that you want HTML for htmlCodeEditor and be able to import back into the editor after user edit. Take a look at the demo of...

pouyamiralayiMarch 31, 2020

Hi @sathyanarayananaCES you must call editor.getComponents and editor.getStyle in order to retrieve the components details; then you can return to the stored state by calling editor.setComponents and editor.setStyle with the result of above mentioned function calls. Cheers!

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.