Try to understand the StateField.provide function


I don’t understand how the ‘provide’ function works. I understand its purpose, but when I read the source code, I don’t understand where it is used. My goal is to understand what happens with the extension we return with this function.

Thank you in advance for your assistance.

As far as I understand it, provide allows for adding a StateField to a facet. For example to EditorView.decorations. provide runs on creation of the EditorState (if the StateField was added to the extension list) and one can wrap the StateField in a facet (or other extension) like some form of label.