diff --git a/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.css b/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.css new file mode 100644 index 00000000..e69de29b diff --git a/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.html b/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.html new file mode 100644 index 00000000..6a145630 --- /dev/null +++ b/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.html @@ -0,0 +1,8 @@ + + + diff --git a/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.js b/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.js new file mode 100644 index 00000000..07dc477f --- /dev/null +++ b/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.js @@ -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: `
Hello World
`, + }); + } + } +); diff --git a/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.json b/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.json new file mode 100644 index 00000000..1bff9606 --- /dev/null +++ b/website/src/website/data/playground-samples/creating-the-editor/web-component/sample.json @@ -0,0 +1,4 @@ +{ + "title": "Web Component", + "sortingKey": 10000 +}