Editor.getSelected().toHTML() is not consistent
Inside your html-block component create a new property (eg. custom-code) for user's code and retrieve it with editor.getSelected().get('custom-code')
Read full answer below βQuestion
Hi everyone, I created a new component type, 'html-block', which is a component in which you can add your html code. I added an 'Edit' button to the toolbar, to enable the user editing the added html code. In order to show the html code of the component in the modal, I am using the function 'editor.getSelected().toHTML()'; The problem is that, sometimes the code returned is per example: <div><h1>h1</h1></div> (which is what I need, since I need the exact code that the user added at first), and sometimes it returns something like that: <div id='135'><h1>h1</h1></div> (with an id added automati...
Answers (3)
Inside your html-block component create a new property (eg. custom-code) for user's code and retrieve it with editor.getSelected().get('custom-code')
This solved the problem for me. Thank you.
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 #563
Table <thead> and <tbody> tag gets Omitted
Hello, There is new issue with GrapesJS (maybe). I've created new component using bm.add() in which I've used a table element with <thead>...
Issue #1661
I've created html table and cannot drag new elements to table cells
Hello. if I create html table with next block of code, everything works, I'm able to drop a Quote, for example, to any cell: But next code...
Issue #1466
Editing Saved html editor.setComponents slider load issue
I am working on a project where i integrated grapesJs for users to build there templates, save them in database and edit these saved templa...
Issue #384
Create and Edit Template into Database
This is my code to Create a new template and insert the inline html with style into the database : I am able to insert the template-data in...
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.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.