codemirror6-plugin
codemirror6-plugin copied to clipboard
Mount Preview to ShadowDOM root
For reasons we have to mount CodeMirror 6 in ShadowDOM (which CodeMirror 6 supports via the root
property of EditorView
.
Emmet overall works fine, but theme styles don't work in Emmet in the ShadowDOM since the Emmet Preview's EditorView
is using the parent document instead of the ShadowDOM root.
A couple of ideas on how to solve the problem:
- Use the parent
EditorView
'sroot
property when creating the previewEditorView
, though it doesn't seem likecreatePreview
gets the parentEditorView
which could be referenced. - Give an API to retrieve the preview
EditorView
to allow setting theroot
manually withsetRoot
Ok, I’ll try to explore how to attach styles for preview in ShadowDOM mode, seems to be a valid use case
Added root
option for preview config in v0.3.2.
Haven't been able to get this integrated yet, but that does seem like what I need. Would be great if it could automatically be inherited from the parent, but doesn't seem like CodeMirror even has that available. Closing out for now, if I can get it working or run into trouble, I'll update. Thanks!