prosemirror-state downloads · last 12 months
prosemirror-state provides the state-management layer for a ProseMirror editor. It represents the document and editor selection, and coordinates changes made through transactions so an editor can update predictably rather than mutating its content directly.
Its design centers on explicit state transitions: an editor state is updated by applying a transaction, producing a new state that reflects the change. This makes the package suited to developers building ProseMirror-based editors who need document changes, selection, and editor behavior to follow a consistent model.
The main APIs include EditorState, Transaction, Selection, and Plugin. Create an EditorState with a document and configuration, dispatch transactions to apply edits, and use plugins to add stateful behavior; plugins can define their own state fields and respond to transactions. This architecture gives editor features a shared way to track and interpret changes.
prosemirror-state is intended to work as part of the ProseMirror editor ecosystem, alongside the components that provide document schemas, editing commands, and a view in the browser. It is not a complete rich-text editor interface on its own: developers integrate its state model with the rest of their editing setup and decide how editor behavior is presented to users.
The package is version 1.4.4, is MIT-licensed, and has a reported gzip bundle size of 19.6 kB. Its 10.1M weekly downloads and 231 GitHub stars indicate substantial usage, while the reported 0 open issues and update date of 2026-04-01 are point-in-time project details rather than guarantees about future maintenance.
A key caveat is that prosemirror-state supplies editor state mechanisms, not a ready-made interface or every capability needed by a complete editor. Teams must understand transactions, selections, plugins, and the surrounding ProseMirror components; applications seeking ordinary application state management rather than structured document editing should choose a more general state approach.
- When building a ProseMirror editor that needs a defined document, selection, and configuration, initialize and manage them with EditorState.
- When edits must be applied as explicit state transitions, create or handle Transaction instances and apply them to the current EditorState.
- When editor features need to react to document or selection changes, use Plugin hooks and plugin state fields to keep that behavior within the editor state model.
- When implementing selection-aware editing behavior, use Selection as the editor's representation of the current selected content or cursor position.
- When composing multiple editor behaviors, register them through the ProseMirror plugin mechanism rather than keeping unrelated editor state outside the state lifecycle.
- When integrating a custom ProseMirror editing interface, use prosemirror-state for the state layer and connect it to the surrounding document and view components.
- If the application only needs ordinary UI state and does not model structured editor documents, use a general-purpose state approach instead of EditorState and Transaction.
- If you need a complete rich-text editor interface out of the box, choose an editor product or framework that supplies the interface; prosemirror-state provides state mechanisms, not a finished editor UI.
- If your feature does not need document-aware selections or transaction-based edits, avoid adding the ProseMirror state model and use a simpler representation for that data.
- If you are not using the surrounding ProseMirror editing components, first choose an editor architecture that includes the document and view integration; prosemirror-state is one layer, not a standalone editing system.
- If your team cannot accommodate the concepts of transactions, selections, and plugin state, use an editor approach with a higher-level abstraction or implement the limited behavior with simpler application state.
- If the target is a non-editing content display, render the content without introducing editor state, transactions, or plugin lifecycle management.
CORRECTIONS
Spot wrong data here?Spot wrong data on this page?
A short note helps us fix it.A short note helps us fix it. We read every one; confirmed fixes ship in the next nightly build.
Anonymous · No account · No email back