FEAT: Enhanced Shadow DOM Support
Question
What are you trying to add to GrapesJS? Better Shadow DOM support, allowing developers to render GrapesJS inside a Shadow element without having to specifically pass in elements rather than selectors in the configuration.
Describe your feature request detailed When currently using element selectors, GrapesJS simply uses the document query selector. This does not work when rendering inside a Shadow DOM, as the document isn't the shadow root. I would like to be able to define a shadow root so that anything GrapesJS does/needs is contained within the shadow root.
Example of using GrapesJS inside a ShadowDOM: https://jsfiddle.net/theandybob/s9bnhw30/
Is there an alternative at the latest version?
- Yes (describe the alternative)
- No
Is this related to an issue?
- Yes (Give a link to the issue)
- No
Answers (3)
Hi @AStoker I don't understand what is the real issue with your example (aside not loading GrapesJS styles inside your shadow dom). If you're attaching shadow dom, obviously, you can't do this container: '#gjs', but you're still able to pass HTMLElements as you're already doing in your example, so what is the issue?
The issue is that I must pass HTML elements everywhere and cannot use selectors. This can become cumbersome to write as I must now use the shadow Dom's query selector for every panel, every element, anything that we hook into GrapesJS. Additionally, if there were the concept of a container, it would significantly help isolate GrapesJS from accidentally interfering with other parts of an application. As more applications make use of components and custom elements, proper isolation between components is important. The fact that GrapesJS automatically pulls in font-awesome (from a CDN too) into the root of the page isn't ideal, as there could very easily be conflicting styles. If you are using Shadow DOM, you could pass the container to GrapesJS and it would put font-awesome within the Shadow DOM, appropriately isolating styles from other parts of the application.
I updated the JSFiddle so you can see what we need to do to get styles within Shadow DOM. But unfortunately the CSS that's automatically added by GrapesJS exists on the body and is both polluting the global stylesheets and pointless due to GrapesJS being inside the Shadow DOM.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3608
FEAT: Disable Dragging
What are you trying to add to GrapesJS? I have implemented an alternative text editing component (not based on RTE). I want people to be ab...
Issue #3207
Form is not submitting
I am trying to create as custom block. But the form is not submitting when i use components inside content. I am able to get all the form d...
Issue #2494
When adding components to the canvas, duplicates are created in the DOM (but not the model)
When I drag a component - say a Map - onto the canvas, it now creates three copies of that element in the DOM. However, the model is correc...
Issue #3193
FEAT: Change of current internal object store to allow for relation mappings instead of current indexable container implementation
What are you trying to add to GrapesJS? Currently newly instantiated editor instances are added to a indexable collection where the user mu...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.