emmetio / codemirror6-plugin

WIP Plugin for CodeMirror 6
39 stars 7 forks source link

Mount Preview to ShadowDOM root #22

Closed shshaw closed 3 days ago

shshaw commented 6 months ago

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:

  1. Use the parent EditorView's root property when creating the preview EditorView, though it doesn't seem like createPreview gets the parent EditorView which could be referenced.
  2. Give an API to retrieve the preview EditorView to allow setting the root manually with setRoot
sergeche commented 6 months ago

Ok, I’ll try to explore how to attach styles for preview in ShadowDOM mode, seems to be a valid use case

sergeche commented 1 month ago

Added root option for preview config in v0.3.2.

shshaw commented 3 days ago

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!