josdejong / josdejong/jsoneditor

Code mode (Ace editor) not working inside shadow DOM

Open
#742 3 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
JavaScript
Stars
12.3k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

Hi,
I want to make a JSON editor custom element. But I meet some problems.
Here is my code:
```html




var template = document.getElementById('custom-template')
class CustomJsonEditor extends HTMLElement {
constructor() {
super();
this._shadowRoot = this.attachShadow({mode: 'open'})
this._shadowRoot.appendChild(template.content.cloneNode(true))
var options = {
mode: 'code',
modes: ["code", "tree"],
};

this.container = this._shadowRoot.querySelector('div');
this.editor = new JSONEditor(this.container, options);
}
}
customElements.define('json-editor', CustomJsonEditor);

```
And the Json editor will become this:
![image](https://user-images.githubusercontent.com/12412109/61261869-cfe01880-a7b5-11e9-809c-fceb931eb715.png)
It seems that I need to load the ace theme somewhere, right? I am a beginner on JavaScript. Could you give me some helps? Thank you.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.