Skip to content

Commit

Permalink
Merge pull request #3595 from microsoft/hediet/blonde-puma
Browse files Browse the repository at this point in the history
Fixes #3588
  • Loading branch information
hediet authored Feb 24, 2023
2 parents f2d1d1d + 268f388 commit bdc690a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>`,
});
}
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Web Component",
"sortingKey": 10000
}

0 comments on commit bdc690a

Please sign in to comment.