Issue #3810πŸ’¬ AnsweredOpened Sep 23, 2021by mihir-khandekar0 reactions

92.0.4515.131 (Official Build) (64-bit)Reproducible demo link

Quick answerby artf

the getHtml has nothing to do with the DOM of the canvas... Read carefully the documentation https://grapesjs.com/docs/modules/Components.html and try to understand the difference between the model and the view of the component.

Read full answer below ↓

Question

GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? 92.0.4515.131 (Official Build) (64-bit)Reproducible demo link N/ADescribe the bug How to reproduce the bug?Insert HTML into canvas using the editor.Canvas.getBody().ownerDocument.execCommand('insertHTML', false, HTMLString) command.the inserted HTML does show up on the editor canvas.Use the editor's editor.getHtml() function.The returned HTML string by editor.getHtml() does not contain the HTML that was inserted using the execCommand command. What is the expected behavior? The final HTML should retu...

Answers (4)

artfβ€’ Sep 23, 2021

the getHtml has nothing to do with the DOM of the canvas... Read carefully the documentation https://grapesjs.com/docs/modules/Components.html and try to understand the difference between the model and the view of the component.

mihir-khandekarβ€’ Sep 23, 2021

@artf thanks for the prompt response, what is the right way of doing this then?

My requirement is: I want to add a component at the current cursor position. How can I then get it to be part of the editor.getHtml() method?

ionutmiftodeβ€’ Feb 21, 2023

@mihir-khandekar did you manage to fix this?

GJSBlockβ€’ May 17, 2026

Thanks for reporting this, @mihir-khandekar. Great question about *. The recommended approach with ProseMirror is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Most operations can be achieved by listening t...

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 β†’

Related tutorials

In-depth guides on the same topic.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.