Registry / productivity / prosemirror-schema-basic

prosemirror-schema-basic

JSON →
library1.2.4jsnpmunverified

Provides the default rich-text schema for ProseMirror, including nodes (doc, paragraph, blockquote, heading, code_block, image, hard_break, horizontal_rule, text) and marks (link, em, strong, code). Current version 1.2.4 is stable and mature with infrequent updates. Key differentiator: designed to be extended or subsetted in custom schemas via `schema.spec.nodes` and `schema.spec.marks`. ES module only; no CommonJS or UMD bundle. Ships TypeScript definitions.

npm install prosemirror-schema-basic
INSTALL
IMPORT
SIG · PROSEMIRROR-SCHEMA
P
prosemirror-schema-basic
productivityjavascriptv1.2.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

schema
import { schema } from 'prosemirror-schema-basic'
import schema from 'prosemirror-schema-basic'
Named export, not default. ESM-only since v1.0.
nodes
import { nodes } from 'prosemirror-schema-basic'
const nodes = require('prosemirror-schema-basic').nodes
CommonJS require will cause 'undefined' if the package is transpiled incorrectly; use ESM imports.
marks
import { marks } from 'prosemirror-schema-basic'
import { marks } from 'prosemirror-schema-basic/marks'
marks is a top-level export, not a sub-path. Do not append '/marks'.
Schema
import { Schema } from 'prosemirror-model'
import { Schema } from 'prosemirror-schema-basic'
Schema is provided by prosemirror-model, not this package. Common mistake is to import from here.

Shows how to import the basic schema and extend it with a custom node using the prosemirror-model Schema class.

import { schema } from 'prosemirror-schema-basic'; import { Schema } from 'prosemirror-model'; // Build your own schema extending the basic one const extendedSchema = new Schema({ nodes: schema.spec.nodes.append({ myNode: { inline: true, group: 'inline', toDOM: () => ['span', 0] } }), marks: schema.spec.marks }); console.log(extendedSchema.nodes.doc); console.log(extendedSchema.marks.em);
Debug
Known issues
gotchaThe `schema` export is the default ProseMirror schema; do not mutate it directly. Always create a new Schema for customizations.
fix
Use schema.spec.nodes and schema.spec.marks to build new schemas.
affects: >=1.0.0
breakingThis package is ESM-only since v1.0.0. CommonJS require() will not work.
fix
Use ES module imports (import ... from ...). If using Node, set "type": "module" in package.json or use .mjs extension.
affects: >=1.0.0
deprecatedThe `schema` object's `nodes` and `marks` are NodeSpec and MarkSpec, not Schema nodes. Directly calling `schema.nodes.doc.create()` works but is discouraged.
fix
Create a new Schema and use its node types.
affects: >=0.0.0
gotchaTypeScript types are included but may require `prosemirror-model` types to be installed separately.
fix
Install `prosemirror-model` as a dependency and ensure `@types/prosemirror-model` is not needed (types ship in prosemirror-model itself).
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Named export 'schema' not found. The requested module 'prosemirror-schema-basic' is a CommonJS module; it may be treated as an ES module.
Using ES import syntax in a Node.js environment that expects CommonJS, or bundler misconfiguration.
fix
Ensure your bundler supports ES modules from prosemirror packages. If using Node directly, set "type": "module" in package.json or use `.mjs` file extension.
TypeError: Cannot read properties of undefined (reading 'nodes')
Importing 'schema' incorrectly, e.g., `import schema from 'prosemirror-schema-basic'` (default import instead of named import).
fix
Use named import: `import { schema } from 'prosemirror-schema-basic'`.
Module not found: Error: Can't resolve 'prosemirror-schema-basic'
Missing prosemirror-schema-basic in dependencies.
fix
Run `npm install prosemirror-schema-basic`.
Cannot use import statement outside a module
Using `import` in a CommonJS file without enabling ESM.
fix
Either convert to ESM (add `"type": "module"` in package.json) or use dynamic import: `const { schema } = await import('prosemirror-schema-basic')`.
Upgrade
Version history
1.2.4latest on npm
Audit
Dependencies
prosemirror-modelrequiredUses `Schema` class and node types from prosemirror-model
Agent activity
32 hits · last 30 days
node
28
OpenAI (training)
2
Amazon
1
Resources
prosemirror-schema-basic — npm install prosemirror-schema-basic · libregistry