3268e6a008 | ||
---|---|---|
.. | ||
README.md | ||
change.ts | ||
config.ts | ||
extension.ts | ||
facet.ts | ||
index.ts | ||
selection.ts | ||
state.ts | ||
transaction.ts |
README.md
In its most basic form, the editor state is made up of a current document and a selection. Because there are a lot of extra pieces that an editor might need to keep in its state (such as an undo history or syntax tree), it is possible for extensions to add additional fields to the state object.
@EditorStateConfig
@EditorState
@SelectionRange
@EditorSelection
@Text
Changes and Transactions
CodeMirror treats changes to the document as objects, which are usually part of a transaction.
This is how you'd make a change to a document (replacing “world” with “editor”) and create a new state with the updated document:
let state = EditorState.create({doc: "hello world"})
let transaction = state.t().replace(6, 11, "editor")
console.log(transaction.doc.toString()) // "hello editor"
let newState = transaction.apply()
@ChangeDesc
@Change
@ChangeSet
@Transaction
@Annotation
@StateEffect
@StateEffectSpec
@StateEffectType
@MapMode
@Mapping
@ChangedRange
Extending Editor State
The following are some types and mechanisms used when writing extensions for the editor state.
@StateCommand
@Extension
@StateFieldSpec
@StateField
@FacetConfig
@Facet
@Precedence
@ExtensionGroup
@Syntax
@IndentContext
@languageData
Utilities
@fillConfig
@combineConfig