{"id":11594,"library":"prosemirror-trailing-node","title":"ProseMirror Trailing Node Plugin","description":"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.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/remirror/remirror","tags":["javascript","typescript"],"install":[{"cmd":"npm install prosemirror-trailing-node","lang":"bash","label":"npm"},{"cmd":"yarn add prosemirror-trailing-node","lang":"bash","label":"yarn"},{"cmd":"pnpm add prosemirror-trailing-node","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for ProseMirror's document model.","package":"prosemirror-model","optional":false},{"reason":"Required peer dependency for managing editor state, including plugins.","package":"prosemirror-state","optional":false},{"reason":"Required peer dependency for rendering the editor and handling interactions.","package":"prosemirror-view","optional":false}],"imports":[{"note":"The package primarily uses named exports. CommonJS require is not supported in v3 due to ESM migration.","wrong":"const { trailingNode } = require('prosemirror-trailing-node');","symbol":"trailingNode","correct":"import { trailingNode } from 'prosemirror-trailing-node';"},{"note":"Importing types requires the `type` keyword and is crucial for TypeScript projects.","symbol":"TrailingNodeOptions","correct":"import type { TrailingNodeOptions } from 'prosemirror-trailing-node';"},{"note":"EditorState is a named export from prosemirror-state, not a default export.","wrong":"import EditorState from 'prosemirror-state';","symbol":"EditorState","correct":"import { EditorState } from 'prosemirror-state';"}],"quickstart":{"code":"import { schema } from 'prosemirror-schema-basic';\nimport { EditorState } from 'prosemirror-state';\nimport { EditorView } from 'prosemirror-view';\nimport { trailingNode } from 'prosemirror-trailing-node';\n\nconst editorSchema = schema;\n\n// Initialize the editor state with the trailingNode plugin.\nconst state = EditorState.create({\n  schema: editorSchema,\n  plugins: [\n    trailingNode({\n      ignoredNodes: ['code_block'], // Example: don't add trailing node after code blocks\n      nodeName: 'paragraph' // The node type to append\n    })\n  ]\n});\n\n// Create the editor view and mount it to the DOM.\nconst view = new EditorView(document.body, { \n  state,\n  dispatchTransaction(transaction) {\n    const newState = view.state.apply(transaction);\n    view.updateState(newState);\n  }\n});\n\nconsole.log('ProseMirror editor with trailing node plugin initialized.');","lang":"typescript","description":"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."},"warnings":[{"fix":"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.","message":"Version 3.0.0 introduces breaking changes, primarily aligning with Remirror v3's move towards ESM-only imports and updated ProseMirror peer dependencies. Ensure your project is configured for ESM and that you update your core ProseMirror packages to compatible versions.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"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.","message":"This package requires specific peer dependencies of `prosemirror-model`, `prosemirror-state`, and `prosemirror-view`. Failure to install these or using incompatible versions can lead to runtime errors or unexpected behavior within your ProseMirror editor.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Verify that the `nodeName` configured in `trailingNode({ nodeName: 'your_node' })` matches an existing node type within your `prosemirror-schema-basic` or custom schema.","message":"The `nodeName` option in `trailingNode` must correspond to a valid node name defined in your ProseMirror schema. If the specified `nodeName` does not exist in the schema, the plugin may not function correctly or could throw errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"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`).","cause":"Attempting to use CommonJS `require()` syntax with an ESM-only package or incorrect named import.","error":"TypeError: trailingNode is not a function"},{"fix":"Run `npm install prosemirror-trailing-node prosemirror-model prosemirror-state prosemirror-view` (or `yarn add`/`pnpm add`) to ensure all necessary packages are present.","cause":"The package or its peer dependencies are not installed correctly or not accessible in the current environment.","error":"Error: Cannot find module 'prosemirror-trailing-node'"},{"fix":"When initializing the plugin, provide either `nodeName` (a string matching a schema node) or a `createNode` function: `trailingNode({ nodeName: 'paragraph' })`.","cause":"The `nodeName` or `createNode` option was not provided to the `trailingNode` plugin configuration.","error":"Error: (plugin prosemirror-trailing-node): 'nodeName' (or 'createNode') is required"}],"ecosystem":"npm"}