Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@tiptap/pm
Advanced tools
@tiptap/pm is a package that provides a set of tools and utilities for building rich text editors. It is part of the Tiptap ecosystem, which is built on top of ProseMirror, a toolkit for building rich text editors. @tiptap/pm offers a range of functionalities including schema creation, commands, input rules, and more.
Schema Creation
This feature allows you to define the structure of your document. The schema defines the nodes and marks that can be used in the editor.
const { Schema } = require('@tiptap/pm');
const mySchema = new Schema({
nodes: {
doc: { content: 'block+' },
paragraph: { content: 'text*', toDOM: () => ['p', 0], parseDOM: [{ tag: 'p' }] },
text: { inline: true }
},
marks: {}
});
Commands
Commands are functions that perform actions on the editor state. This example shows how to create a command to toggle a bold mark.
const { toggleMark } = require('@tiptap/pm');
const boldCommand = toggleMark(mySchema.marks.bold);
// Usage in an editor instance
editor.commands.bold = () => boldCommand(editor.state, editor.dispatch);
Input Rules
Input rules are used to automatically transform text as the user types. This example shows how to create an input rule that transforms text starting with '>' into a blockquote.
const { inputRules, wrappingInputRule } = require('@tiptap/pm');
const blockquoteRule = wrappingInputRule(/^
*>
$/, mySchema.nodes.blockquote);
const myInputRules = inputRules({ rules: [blockquoteRule] });
ProseMirror is a toolkit for building rich text editors. It provides a lot of the underlying functionality that @tiptap/pm builds upon. While ProseMirror is more low-level and requires more setup, @tiptap/pm offers a more user-friendly API and additional utilities.
Slate is another framework for building rich text editors. It offers a different approach compared to ProseMirror and @tiptap/pm, focusing on a more React-friendly API. Slate is highly customizable but can be more complex to set up.
Draft.js is a rich text editor framework developed by Facebook. It provides a set of React components and utilities for building rich text editors. While it is powerful, it is not as flexible as ProseMirror and @tiptap/pm.
Tiptap is a headless wrapper around ProseMirror – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as New York Times, The Guardian or Atlassian.
pm
package?The pm
package is a wrapper package for ProseMirror. This includes all ProseMirror packages that are required to run Tiptap.
Documentation can be found on the Tiptap website.
Tiptap is open sourced software licensed under the MIT license.
FAQs
prosemirror wrapper package for tiptap
The npm package @tiptap/pm receives a total of 11,030 weekly downloads. As such, @tiptap/pm popularity was classified as popular.
We found that @tiptap/pm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.