Repository navigation
Description
classes referenced are vs/editor/browser/view/viewImpl and vs/editor/browser/widget/codeEditorWidget.
any idea why:
https://github.com/Microsoft/vscode/blob/master/src/vs/editor/browser/widget/codeEditorWidget.ts#L487 -> https://github.com/Microsoft/vscode/blob/master/src/vs/editor/browser/view/viewImpl.ts#L115
doesn't pass in the domElement from:
https://github.com/Microsoft/vscode/blob/master/src/vs/editor/browser/widget/codeEditorWidget.ts#L65?
i think calls like this.linesContent = document.createElement('div'); are a bit problematic to deal with in the realm of WebComponents. for some reason i can't get the textarea to display properly if the #container is not placed in the body.
that aside, could the contract be listed a bit more explicitly.
setting breakpoints on the dom tree, e.g., break on -> subtree modifcations or attributes modifcations shows the code touching other elements outside of the #container.
out of interest; do you test with shadow/shady dom enabled?
working:
here is a working version that is not ideal: http://bana.io/monaco-editor-polymer/.
<body>
<monaco-editor-polymer-code-editor></monaco-editor-polymer-code-editor>
<div class="code-editor-app">
<div class="code-editor" id="container"></div>
</div>
</body>not working:
in this version the textarea seems to get a
<dom-module id="monaco-editor-polymer-code-editor">
<template>
...
<div class="code-editor" id="container"></div>
...
</template>
<script>
var require = {
baseUrl: '/monaco-editor-polymer/',
paths: {
'vs': 'node_modules/monaco-editor/min/vs'
}
};
</script>
<script src="node_modules/monaco-editor/min/vs/loader.js"></script>
<script src="node_modules/monaco-editor/min/vs/editor/editor.main.nls.js"></script>
<script src="node_modules/monaco-editor/min/vs/editor/editor.main.js"></script>
<script src="elements/monaco-editor-polymer-code-editor.js"></script>
</dom-module>
...
<body>
<monaco-editor-polymer-code-editor></monaco-editor-polymer-code-editor>
</body>
...
Activity
bana-io commentedon Jan 3, 2017
still failing but i see an uncoloured textbuffer now with the change below.
ok i just saw something:
https://github.com/Microsoft/vscode/blob/a2e26c85ab8e82fbe037718bf65f1a1f048bac2c/src/vs/base/browser/dom.ts#L49
i need to do something like the below in WebComponents.
override the
isInDOMmethod to return shadow root's parent.if anyone has any ideas, fire away.
bana-io commentedon Jan 3, 2017
ok i've got it to load now. http://bana.io/monaco-editor-polymer/.
summary:
seems like there is a dependency on the
#containerhavingbodyas theparentNode.effectively, i render
#containerinto the light dom tree of the element and then proceed to construct Monaco. seems to work this way without hacks. e.g., the below snippet.if,
#containeris in the<monaco-editor-polymer>element - my ideal approach - it fails as there are places, not sure where, that doesn't play well with shadow dom.alexandrudima, hi, would you please confirm if this an OK approach?
alexdima commentedon Jan 13, 2017
@mbana This is awesome! I have never tried loading the editor in a shadow dom / with polymer. Are the patches you needed to apply to
vs/base/browser/dom.isInDOMsomething you could contribute via a PR in such a way that we use only dom API (i.e. noPolymerusage) and in such a way that it doesn't break the editor usage in the rest of the cases?Would you also consider contributing a PR to https://github.com/Microsoft/monaco-editor-samples with a working example?
paresy commentedon Mar 6, 2017
I did not fix the issue in the ts file yet. Just for reference on how you can patch the editor.main.js:
If we are in a shodow dom we want to walk the shadow dom boundaries aswell.
This is just one of a lot of issues regarding shadow dom. The editor is injecting scripts and sytles using document.* functions, which disregards the shadow dom boundaries and pollutes the document DOM.
paresy commentedon Mar 6, 2017
Another thing that is totally broken is detection of CONTENT_TEXT. Therefore getting focus works only for CONTENT_EMPTY which is outside of the text area.
"MouseTargetFactory._doHitTest" fails because we need to do hit tests against the shadow root instead of document. Unfortunately all current browsers do not implement caretRangeFromPoint or caretPositionFromPoint for shadow doms. See related ticket for TinyMCE which discusses the problem further: tinymce/tinymce#561
paulvarache commentedon Jul 23, 2017
I'm jumping in this issue, because I did a while ago a custom element with shadow DOM for the
monaco-editor. I encountered the same issues as described here, but found work arounds.Here's a demo: https://paulvarache.github.io/monaco-editor-element
I had to hotfix the
isInDOMmethod as mentioned and I did a polyfill forcaretRangeFromPointin a shadow root. I also had to move some of the style tags inside the shadow root.I use
monaco-editoras a node dependency and at build time copy the files in adistfolder and with some dirty use ofsedI replace the bits of code that needs to be changed before uglifying all that.samccone commentedon May 26, 2019
I encountered similar problems with shadow dom and monaco. I was able to work around the problem by slotting the target DOM node into my application from the body level down.
hediet commentedon Feb 16, 2023
Closing due to inactivity.
Please create new issues for the remaining problems around monaco-editor and shadow dom.
Also, please share monaco editor playground samples that make use of the shadow dom to demonstrate what does not work.