atlassian/prosemirror-utils is a open-source project on GitHub, written primarily in TypeScript. It has 523 stars. ⚒ Utils library for ProseMirror
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
findParentNode(predicate: fn(node: ProseMirrorNode) → boolean) → fn(selection: Selection) → ?{pos: number, start: number, depth: number, node: ProseMirrorNode}
Iterates over parent nodes, returning the closest node and its start position predicate returns truthy for. start points to the start position of the node, pos points directly before the node.
findParentNodeClosestToPos($pos: ResolvedPos, predicate: fn(node: ProseMirrorNode) → boolean) → ?{pos: number, start: number, depth: number, node: ProseMirrorNode}
Iterates over parent nodes starting from the given $pos, returning the closest node and its start position predicate returns truthy for. start points to the start position of the node, pos points directly before the node.
hasParentNode(predicate: fn(node: ProseMirrorNode) → boolean) → fn(selection: Selection) → boolean
Checks if there's a parent node predicate returns truthy for.
if (hasParentNode(node => node.type === schema.nodes.table)(selection)) {
// ....
}
findParentNodeOfType(nodeType: NodeType | [NodeType]) → fn(selection: Selection) → ?{pos: number, start: number, depth: number, node: ProseMirrorNode}
Iterates over parent nodes, returning closest node of a given nodeType. start points to the start position of the node, pos points directly before the node.
findParentNodeOfTypeClosestToPos($pos: ResolvedPos, nodeType: NodeType | [NodeType]) → ?{pos: number, start: number, depth: number, node: ProseMirrorNode}
Iterates over parent nodes starting from the given $pos, returning closest node of a given nodeType. start points to the start position of the node, pos points directly before the node.
hasParentNodeOfType(nodeType: NodeType | [NodeType]) → fn(selection: Selection) → boolean
Checks if there's a parent node of a given nodeType.
if (hasParentNodeOfType(schema.nodes.table)(selection)) {
// ....
}
findParentDomRefOfType(nodeType: NodeType | [NodeType], domAtPos: fn(pos: number) → {node: dom.Node, offset: number}) → fn(selection: Selection) → ?dom.Node
Iterates over parent nodes, returning DOM reference of the closest node of a given nodeType.
findSelectedNodeOfType(nodeType: NodeType | [NodeType]) → fn(selection: Selection) → ?{pos: number, start: number, depth: number, node: ProseMirrorNode}
Returns a node of a given nodeType if it is selected. start points to the start position of the node, pos points directly before the node.
findDomRefAtPos(position: number, domAtPos: fn(pos: number) → {node: dom.Node, offset: number}) → dom.Node
Returns DOM reference of a node at a given position. If the node type is of type TEXT_NODE it will return the reference of the parent node.
flatten(node: ProseMirrorNode, descend: ?boolean = true) → [{node: ProseMirrorNode, pos: number}]
Flattens descendants of a given node. It doesn't descend into a node when descend argument is false (defaults to true).
const children = flatten(node);
findChildren(node: ProseMirrorNode, predicate: fn(node: ProseMirrorNode) → boolean, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
Iterates over descendants of a given node, returning child nodes predicate returns truthy for. It doesn't descend into a node when descend argument is false (defaults to true).
findTextNodes(node: ProseMirrorNode, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
Returns text nodes of a given node. It doesn't descend into a node when descend argument is false (defaults to true).
const textNodes = findTextNodes(node);
findInlineNodes(node: ProseMirrorNode, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
Returns inline nodes of a given node. It doesn't descend into a node when descend argument is false (defaults to true).
const inlineNodes = findInlineNodes(node);
findBlockNodes(node: ProseMirrorNode, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
Returns block descendants of a given node. It doesn't descend into a node when descend argument is false (defaults to true).
const blockNodes = findBlockNodes(node);
findChildrenByAttr(node: ProseMirrorNode, predicate: fn(attrs: ?Object) → boolean, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
Iterates over descendants of a given node, returning child nodes predicate returns truthy for. It doesn't descend into a node when descend argument is false (defaults to true).
findChildrenByType(node: ProseMirrorNode, nodeType: NodeType, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
Iterates over descendants of a given node, returning child nodes of a given nodeType. It doesn't descend into a node when descend argument is false (defaults to true).
findChildrenByMark(node: ProseMirrorNode, markType: markType, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
Iterates over descendants of a given node, returning child nodes that have a mark of a given markType. It doesn't descend into a node when descend argument is false (defaults to true).
contains(node: ProseMirrorNode, nodeType: NodeType) → boolean
Returns true if a given node contains nodes of a given nodeType
if (contains(panel, schema.nodes.listItem)) {
// ...
}
Utils for document transformation
removeParentNodeOfType(nodeType: NodeType | [NodeType]) → fn(tr: Transaction) → Transaction
Returns a new transaction that removes a node of a given nodeType. It will return an original transaction if parent node hasn't been found.
replaceParentNodeOfType(nodeType: NodeType | [NodeType], content: ProseMirrorNode | Fragment) → fn(tr: Transaction) → Transaction
Returns a new transaction that replaces parent node of a given nodeType with the given content. It will return an original transaction if either parent node hasn't been found or replacing is not possible.
removeSelectedNode(tr: Transaction) → Transaction
Returns a new transaction that removes selected node. It will return an original transaction if current selection is not a NodeSelection.
dispatch(
removeSelectedNode(tr)
);
replaceSelectedNode(content: ProseMirrorNode | ProseMirrorFragment) → fn(tr: Transaction) → Transaction
Returns a new transaction that replaces selected node with a given node, keeping NodeSelection on the new node.
It will return the original transaction if either current selection is not a NodeSelection or replacing is not possible.
safeInsert(content: ProseMirrorNode | Fragment, position: ?number, tryToReplace: ?boolean) → fn(tr: Transaction) → Transaction
Returns a new transaction that inserts a given content at the current cursor position, or at a given position, if it is allowed by schema. If schema restricts such nesting, it will try to find an appropriate place for a given node in the document, looping through parent nodes up until the root document node.
If tryToReplace is true and current selection is a NodeSelection, it will replace selected node with inserted content if its allowed by schema.
If cursor is inside of an empty paragraph, it will try to replace that paragraph with the given content. If insertion is successful and inserted node has content, it will set cursor inside of that content.
It will return an original transaction if the place for insertion hasn't been found.
setParentNodeMarkup(nodeType: NodeType | [NodeType], type: ?NodeType | null, attrs: ?Object | null, marks: ?[Mark]) → fn(tr: Transaction) → Transaction
Returns a transaction that changes the type, attributes, and/or marks of the parent node of a given nodeType.
selectParentNodeOfType(nodeType: NodeType | [NodeType]) → fn(tr: Transaction) → Transaction
Returns a new transaction that sets a NodeSelection on a parent node of a given nodeType.
removeNodeBefore(tr: Transaction) → Transaction
Returns a new transaction that deletes previous node.
dispatch(
removeNodeBefore(state.tr)
);
setTextSelection(position: number, dir: ?number = 1) → fn(tr: Transaction) → Transaction
Returns a new transaction that tries to find a valid cursor selection starting at the given position
and searching back if dir is negative, and forward if positive.
If a valid cursor position hasn't been found, it will return the original transaction.
Does atlassian/prosemirror-utils have a project website?
No homepage URL was recorded for atlassian/prosemirror-utils in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
How active is development on atlassian/prosemirror-utils?
The most recent commit recorded on atlassian/prosemirror-utils was 2.5 years ago, based on the GitHub push timestamp. The repository has 61 forks — one of the better signals of community interest.
Is atlassian/prosemirror-utils open source?
TopGit's metadata for atlassian/prosemirror-utils does not record a license. Most public repositories on GitHub ARE open source, but the exact terms vary — verify by opening the LICENSE file directly.
What topics is atlassian/prosemirror-utils associated with?
GitHub's repository topics for atlassian/prosemirror-utils: "helpers", "prosemirror", "prosemirror-utils", "utils". TopGit's editorial category is open-source.
Where do I read more about atlassian/prosemirror-utils?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/atlassian/prosemirror-utils is the definitive source.
Read full README in the tab above.
Is prosemirror-utils worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of prosemirror-utils.