prosemirror-state
v1.4.4 MIT ArchivedProseMirror editor state
prosemirror-state Download Trends
About prosemirror-state
ProseMirror-state is the core state management module for the ProseMirror rich text editor framework. It provides the fundamental data structures and logic for managing the editor's content, selection, and history, abstracting away the complexities of rich text manipulation.
This package is built around a functional programming paradigm, emphasizing immutability and pure functions to ensure predictable state updates. Its primary goal is to offer a robust and extensible foundation for building custom text editing experiences, appealing to developers who require fine-grained control over editor behavior and data.
The key API revolves around the `EditorState` class, which holds the current document, selection, and other editor-specific information. State changes are managed through `Transaction` objects, allowing for atomic updates and undo/redo functionality via the `history` plugin. Developers interact with these through methods like `apply` and `dispatch`.
ProseMirror-state is designed to be framework-agnostic, making it a versatile choice for integration into various frontend environments. It can be easily paired with UI rendering libraries like React, Vue, or plain JavaScript to construct interactive editing interfaces. The `EditorView` component is responsible for rendering the state and handling user input.
With weekly downloads of 5.8M, ProseMirror-state demonstrates significant adoption within its niche. Its bundle size is relatively modest at 19.6 kB (gzipped), striking a balance between features and performance. The project is mature and well-maintained, as indicated by its 0 open issues and last updated date of 2025-10-23.
While powerful, developers should be aware that ProseMirror-state requires a significant upfront investment in understanding its architecture. It is not a drop-in replacement for simple text inputs and involves a learning curve to leverage its full capabilities effectively. Customization often means diving deep into ProseMirror's schema and plugin system.
When to use
- When building a custom rich text editor with complex formatting requirements.
- When needing to manage editor state immutably, enabling robust undo/redo functionality via `Transaction` objects.
- When integrating an editor into a frontend application and requiring a declarative way to represent content using ProseMirror's `Schema` and `Node` structures.
- When developing plugins that extend editor functionality by interacting with the `EditorState` and `EditorView`.
- When targeting applications where precise control over text selection and document structure is paramount.
- When opting for a framework-agnostic state management solution for rich text content.
When NOT to use
- If you only require basic text input fields — a simple HTML `<input type="text">` or `<textarea>` is more appropriate.
- If you need a UI-agnostic plain JavaScript key-value store — browser `localStorage` or simpler state management libraries suffice.
- If you are building a markdown editor that primarily targets plain text conversion — a markdown parser and renderer might be more direct.
- If your application's rich text needs are very basic and do not involve complex document structures or custom formatting.
- If you prefer a WYSIWYG editor that relies on direct DOM manipulation without an explicit state management layer.