Closed andrewebdev closed 2 years ago
Hi @andrewebdev I don't see tools imported. Are they imported somewhere else?
yeah I just snipped that part out of the paste. All imports are working. The exact same config works in our iFrame version of the code, but as I mentioned we would like to transition away from the iframe requirement.
Could you provide Editor.js version also
It seems something wrong with internal modules import
@gohabereg aha, you just made me think to look at something. Not all my modules are packaged for web, so some have relative imports which might then break the internal imports for other modules. I'll run everything through rollup and revert back with results.
In the meantime, if still interested, here is the versions:
"dependencies": {
"@editorjs/checklist": "^1.1.0",
"@editorjs/code": "^2.4.1",
"@editorjs/delimiter": "^1.1.0",
"@editorjs/editorjs": "^2.16.1",
"@editorjs/embed": "^2.2.1",
"@editorjs/header": "^2.3.2",
"@editorjs/inline-code": "^1.3.1",
"@editorjs/list": "^1.4.0",
"@editorjs/marker": "^1.2.2",
"@editorjs/quote": "^2.3.0",
"@editorjs/table": "^1.2.1",
"@editorjs/warning": "^1.1.1",
"@editorjs/paragraph": "^2.6.1",
"lit-element": "^2.0.0-rc.3",
"lit-html": "^1.0.0-rc.2"
},
"devDependencies": {
"rollup": "^1.1.0",
"rollup-plugin-node-resolve": "^4.0.0"
}
@gohabereg ok so it seems id didn't just have anything to do with the tools. I attempted to use it without specifying any tools in my config, just to test. And the editor still doesn't load.
Ah @gohabereg I see the problem. It seems like, importing the editor will add the CSS to the main document, which of course wont leak through into the shadow dom of our custom element. Are the CSS exported in the main module, then I can maybe import it and insert it into the custom element.
I'm having the same issue. I made a CodePen to reproduce this.
I've tried to render styles into shadowRoot by patching loadStyles
in ui.ts
, but it seems that it isn't enough;(
It would be nice to support that render the editor into the shadowRoot.
I want to separate the scope of css from other css frameworks.
@katsew I also discovered that every plugin also injects their own CSS into the main document as well. So every one of the plugins would also need to allow for usage inside the shadowroot, which is quite annoying.
I am facing the same issues. Any solution folks? Any suggested direction? Is there a manner in which the css can be appended to the webcomponent? Thanks
Any update on this?
Btw, it's specially annoying that plugins doesn't use any encapsulation nor namespacing for class names, so it's very easy to mess up. Now that Shadow Dom is widely supported across all major browsers, it would be awesome to embrace it for editor.js internals as well!
Any update?
Yep, came here while trying to build a web component with editor.js, but with CSS in the wrong DOM it's not feasible. Another problem is that CSS is not distributed in the packages (except in the js bundle file), so can't incorporate it in the build process either.
I found an easy workaround to be able to use editorJS inside a web component. When designing your web component with your favorite framework (e.g. stencilJS, LitElement, Fast Element, etc.), create a
Here is some pseudo code for your reference: // Web component definition @customElement('my-element') class MyComponent extends LitElement { render() { return html''; // Embed slot inside your HTML } }
In your index.html, make editorjs DIV a child element of my-element, and add the following script: var editor = new EditorJS({holder: 'editorjs',....});
I hope this is helpful to you!
We wanted to use EditorJS with customElements (we use
lit-html
internally). Our reasons behind this is because we wanted to isolate the editor styles away from the main dom so that our CMS styles don't make the editor content look strange. This way we can also customize the CSS nicely so that the end user looks at the formatting and text with about the same styles as they would on the frontend.We previously used a Iframe for this (which still works), but we would like to avoid that if possible.
With the editor in the customElement, we get errors like these:![editorjs_shadowdom](https://user-images.githubusercontent.com/84479/72177431-9260ee80-33d8-11ea-906f-279249606cde.png)
Here is the code that creates the customElement:
And this is how we are using the element:
Edit: Oh and here is the config that is used.