pull/3595/head
Henning Dieterichs 2023-02-24 11:17:10 +01:00
parent 8c0dd6c726
commit 268f388cfb
No known key found for this signature in database
GPG Key ID: 771381EFFDB9EC06
4 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<template id="editor-template">
<div
id="container"
style="overflow: hidden; width: 100%; height: 100%; position: absolute"
></div>
</template>
<code-view-monaco></code-view-monaco>

View File

@ -0,0 +1,33 @@
customElements.define(
"code-view-monaco",
class CodeViewMonaco extends HTMLElement {
_monacoEditor;
/** @type HTMLElement */
_editor;
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: "open" });
// Copy over editor styles
const style = document.querySelector(
"link[rel='stylesheet'][data-name='vs/editor/editor.main']"
);
shadowRoot.appendChild(style.cloneNode(true));
const template = /** @type HTMLTemplateElement */ (
document.getElementById("editor-template")
);
shadowRoot.appendChild(template.content.cloneNode(true));
this._editor = shadowRoot.querySelector("#container");
this._monacoEditor = monaco.editor.create(this._editor, {
automaticLayout: true,
language: "html",
value: `<div>Hello World</div>`,
});
}
}
);

View File

@ -0,0 +1,4 @@
{
"title": "Web Component",
"sortingKey": 10000
}