EditorView.theme from facet value

What is a good way to provide a Theme derived from the value of a Facet?

Say there’s a facet full of custom colors that a theme wants to use.

I’ve attempted Facet.compute, StateField, ViewPlugin and more but I can’t seem to get anything that will allow me to get the current facet’s value to then use to build a separate theme extension.

Is there another API I should be using? What would you recommend?

A theme is a composite extension, not just a single facet value, so you can’t use something like Facet.compute for it. You’d have to use a compartment and apply an actual reconfiguration effect (possibly in a transaction extender) to do something like this.

2 Likes