Missing step in Developer Docs for CodeMirror: StateField to DecorationSet

I am so utterly confused by the Obsidian developer docs for CodeMirror state fields. Editor extensions tells you to make a StateField with a number data type. Then the next part, Decorations tells you that the only way to actually change the appearance is by creating a StateField with the DecorationSet data type. How do I create a StateField with my own data type that then provides decorations?

Can these docs be improved to explain this step???

The docs have a GitHub repo (linked at the bottom of the homepage) where you can file an issue about this.

2 Likes

The developer documentation recommends reading CodeMirror’s system guide:

https://codemirror.net/docs/guide/

Long but super useful.

Here’s an example of creating a StateField with a custom data type, and then using this StateField to define another extension that provides decoration.