prosemirror-trailing-node is a plugin for the ProseMirror rich text editor that ensures there's always an editable node at the end of the document. This is particularly useful for preventing users from getting stuck within non-editable or complex nodes, allowing for continuous input. It automatically appends a configurable default node, such as a paragraph, when the last node in the document is not empty. The current stable version is 3.0.0, aligning with the major version 3 of the Remirror ecosystem, of which it is a part. Remirror, and by extension its associated plugins like this one, maintains an active release cadence with frequent patch updates to address issues and align with ProseMirror core updates, as seen in recent changelogs. Its key differentiator is its simple, focused solution for a common ProseMirror UX problem, integrated within a broader, actively developed framework.
npm install prosemirror-trailing-nodeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a basic ProseMirror editor with the `prosemirror-trailing-node` plugin, configuring it to append a paragraph node and ignore specific node types. It sets up the editor state and view, making it runnable in a browser environment.
Migrate your project to use ESM `import` syntax. Update `prosemirror-model`, `prosemirror-state`, and `prosemirror-view` to the `^1.x.x` ranges specified in the peer dependencies for optimal compatibility.
Always install the peer dependencies alongside `prosemirror-trailing-node` using your package manager (e.g., `npm install prosemirror-trailing-node prosemirror-view prosemirror-state prosemirror-keymap`) and ensure their versions fall within the specified ranges.
Verify that the `nodeName` configured in `trailingNode({ nodeName: 'your_node' })` matches an existing node type within your `prosemirror-schema-basic` or custom schema.Ensure you are using `import { trailingNode } from 'prosemirror-trailing-node';` in an ESM context. If using TypeScript, ensure your `tsconfig.json` targets `es2015` or higher and `moduleResolution` is set appropriately (e.g., `bundler`).Run `npm install prosemirror-trailing-node prosemirror-model prosemirror-state prosemirror-view` (or `yarn add`/`pnpm add`) to ensure all necessary packages are present.
When initializing the plugin, provide either `nodeName` (a string matching a schema node) or a `createNode` function: `trailingNode({ nodeName: 'paragraph' })`.