Socket
Socket
Sign inDemoInstall

prosemirror-model

Package Overview
Dependencies
1
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    prosemirror-model

ProseMirror's document model


Version published
Weekly downloads
1.3M
decreased by-1.48%
Maintainers
1
Install size
515 kB
Created
Weekly downloads
 

Package description

What is prosemirror-model?

The prosemirror-model package is a part of the ProseMirror toolkit, which provides a powerful, flexible, and customizable framework for building rich text editors. The prosemirror-model package specifically deals with the document model, which includes defining schemas, creating and manipulating documents, and working with nodes and marks.

What are prosemirror-model's main functionalities?

Defining a Schema

This feature allows you to define a schema for your document. A schema specifies the types of nodes and marks that can appear in the document, as well as their attributes and how they should be serialized to and from DOM.

const { Schema } = require('prosemirror-model');

const mySchema = new Schema({
  nodes: {
    doc: { content: 'block+' },
    paragraph: { content: 'text*', toDOM: () => ['p', 0] },
    text: { inline: true }
  },
  marks: {
    strong: { toDOM: () => ['strong', 0] }
  }
});

Creating a Document

This feature allows you to create a document using the schema you defined. The document is created from a JSON representation that matches the schema.

const { Node } = require('prosemirror-model');

const doc = Node.fromJSON(mySchema, {
  type: 'doc',
  content: [
    { type: 'paragraph', content: [{ type: 'text', text: 'Hello, world!' }] }
  ]
});

Manipulating Nodes

This feature allows you to manipulate nodes within the document. You can create new nodes, copy existing nodes, and create fragments of nodes.

const { Fragment } = require('prosemirror-model');

const paragraph = mySchema.nodes.paragraph.createAndFill();
const textNode = mySchema.text('New text');
const newParagraph = paragraph.copy(Fragment.from(textNode));

Other packages similar to prosemirror-model

Changelog

Source

1.21.1 (2024-06-03)

Bug fixes

Improve performance and accuracy of DOMParser style matching by using the DOM's own style object.

Readme

Source

prosemirror-model

[ WEBSITE | ISSUES | FORUM | CHANGELOG ]

This is a core module of ProseMirror. ProseMirror is a well-behaved rich semantic content editor based on contentEditable, with support for collaborative editing and custom document schemas.

This module implements ProseMirror's document model, along with the mechanisms needed to support schemas.

The project page has more information, a number of examples and the documentation.

This code is released under an MIT license. There's a forum for general discussion and support requests, and the Github bug tracker is the place to report issues.

We aim to be an inclusive, welcoming community. To make that explicit, we have a code of conduct that applies to communication around the project.

FAQs

Last updated on 03 Jun 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc