Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prosemirror-utils

Package Overview
Dependencies
Maintainers
5
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-utils

Utils library for ProseMirror

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
117K
increased by5.96%
Maintainers
5
Weekly downloads
 
Created

What is prosemirror-utils?

The prosemirror-utils package provides a set of utility functions to simplify common tasks when working with ProseMirror, a toolkit for building rich-text editors. These utilities help with node manipulation, selection handling, and other editor-related operations.

What are prosemirror-utils's main functionalities?

findParentNode

This utility function helps to find the closest parent node of a given type from the current selection. In this example, it finds the closest parent node of type 'paragraph'.

const { findParentNode } = require('prosemirror-utils');

const parentNode = findParentNode(node => node.type === schema.nodes.paragraph)(state.selection);
console.log(parentNode);

removeNodeAtPos

This function removes a node at a specific position in the document. In this example, it removes the node at position 5.

const { removeNodeAtPos } = require('prosemirror-utils');

const tr = removeNodeAtPos(5)(state.tr);
console.log(tr);

replaceText

This utility replaces text within a specified range. In this example, it replaces the text between positions 5 and 10 with 'new text'.

const { replaceText } = require('prosemirror-utils');

const tr = replaceText(5, 10, schema.text('new text'))(state.tr);
console.log(tr);

findSelectedNodeOfType

This function finds the selected node of a specific type. In this example, it finds the selected node of type 'paragraph'.

const { findSelectedNodeOfType } = require('prosemirror-utils');

const selectedNode = findSelectedNodeOfType(schema.nodes.paragraph)(state.selection);
console.log(selectedNode);

Other packages similar to prosemirror-utils

Keywords

FAQs

Package last updated on 13 May 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc