StateFieldSpec<Value>
A specification for a state field.
Import:
import type { StateFieldSpec } from 'obsidian-dev-utils/codemirror/state-field-spec';Signature:
export interface StateFieldSpec<Value>Methods
| Method | Returns | Description |
|---|---|---|
| compare(a, b) | boolean | Compare two values of the field, returning true when they are the same. This is used to avoid recomputing facets that depend on the field when its value did not change. Defaults to using ===. |
| create(state) | Value | Creates the initial value for the field when a state is created. |
| fromJSON(json, state) | Value | A function that deserializes the JSON representation of this field's content. |
| provide(field) | Extension | Provide extensions based on this field. The given function will be called once with the initialized field. It will usually want to call some facet's from method to create facet inputs from this field, but can also return other extensions that should be enabled when the field is present in a configuration. |
| toJSON(value, state) | unknown | A function used to serialize this field's content to JSON. Only necessary when this field is included in the argument to EditorState.toJSON. |
| update(value, transaction) | Value | Compute a new value from the field's previous value and a transaction. |