editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

❓Editor.js inside web component

Open lukaszkaleta opened this issue 3 years ago • 3 comments

Question

How do I embed editor js inside web component ?

Context

Our application is developed around web component (Lit) and we would like to give a try to editorjs. But when we use it something wierd happens with styles.

image

` import {css, html, LitElement} from 'lit' import EditorJS from '@editorjs/editorjs';

export class TestingEditor extends LitElement {

firstUpdated(_changedProperties) {
    const editor = new EditorJS(this.renderRoot.querySelector('#editorjs'));
}

render() {
    return html`<div id="editorjs"></div>`
}

}

customElements.define('testing-editor', TestingEditor)

`

Any tips appreciated.

lukaszkaleta avatar Apr 26 '22 13:04 lukaszkaleta

does disabling shadowRoot for the LitElement fix it? If so you need to attach the editorjs styles to the shadowRoot

blahah avatar May 24 '22 22:05 blahah

@blahah I'm not saying this is the best code ever written but here:

 editor.isReady.then(() => {
   const styles = document.querySelector("#editor-js-styles").cloneNode(true);
   this.shadowRoot.appendChild(styles)
 })

It would probably be nice to have an option to render the styles directly within the holder container.

MadeByMike avatar Jul 29 '22 22:07 MadeByMike

FYI I found many other issues with this working inside a shadow DOM. Had to revert to no shadow DOM.

MadeByMike avatar Jul 29 '22 22:07 MadeByMike