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.
prosemirror-utils
Advanced tools
Install prosemirror-utils
package from npm:
npm install prosemirror-utils
Getting the parent node based on the current cursor position:
findParentNode
(predicate: fn(node: ProseMirrorNode) → boolean) → fn(selection: Selection) → ?{pos: number, node: ProseMirrorNode}
predicate
returns truthy for.findParentDomRef
(predicate: fn(node: ProseMirrorNode) → boolean, domAtPos: fn(pos: number) → {node: HTMLElement, offset: number}) → fn(selection: Selection) → ?HTMLElement
predicate
returns truthy for.hasParentNode
(predicate: fn(node: ProseMirrorNode) → boolean) → fn(selection: Selection) → boolean
predicate
returns truthy for.findParentNodeOfType
(nodeType: NodeType) → fn(selection: Selection) → ?{node: ProseMirrorNode, pos: number}
nodeType
.hasParentNodeOfType
(nodeType: NodeType) → fn(selection: Selection) → boolean
nodeType
.findParentDomRefOfType
(nodeType: NodeType, domAtPos: fn(pos: number) → {node: HTMLElement, offset: number}) → fn(selection: Selection) → ?HTMLElement
nodeType
.Getting descendants of a given node:
flatten
(node: ProseMirrorNode, descend: ?boolean = true) → [{node: ProseMirrorNode, pos: number}]
node
. Doesn't descend into a node
when descend
argument is false
. Defaults to true
.findChildren
(node: ProseMirrorNode, predicate: fn(node: ProseMirrorNode) → boolean, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
node
, returning child nodes predicate
returns truthy for. Doesn't descend into a node
when descend
argument is false
.findTextNodes
(node: ProseMirrorNode, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
node
. Doesn't descend into a node
when descend
argument is false
.findInlineNodes
(node: ProseMirrorNode, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
node
. Doesn't descend into a node
when descend
argument is false
.findBlockNodes
(node: ProseMirrorNode, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
node
. Doesn't descend into a node
when descend
argument is false
.findChildrenByAttr
(node: ProseMirrorNode, predicate: fn(attrs: ?Object) → boolean, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
node
, returning child nodes predicate
returns truthy for. Doesn't descend into a node
when descend
argument is false
.findChildrenByType
(node: ProseMirrorNode, nodeType: NodeType, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
node
, returning child nodes of a given nodeType
. Doesn't descend into a node
when descend
argument is false
.findChildrenByMark
(node: ProseMirrorNode, markType: markType, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
node
, returning child nodes that have a mark of a given markType
. Doesn't descend into a node
when descend
argument is false
.
exapmle: findChildrenByMark(paragraph, schema.marks.strong)
contains
(node: ProseMirrorNode, nodeType: NodeType) → boolean
true
if a given node
contains nodes of a given nodeType
Tables helpers:
findTable
(selection: Selection) → ?{pos: number, node: ProseMirrorNode}
isCellSelection
(selection: Selection) → boolean
isColumnSelected
(columnIndex: number) → fn(selection: Selection) → boolean
columnIndex
is selectedisRowSelected
(rowIndex: number) → fn(selection: Selection) → boolean
rowIndex
is selectedisTableSelected
(selection: Selection) → boolean
getCellsInColumn
(columnIndex: number) → fn(selection: Selection) → [{pos: number, node: ProseMirrorNode}]
columnIndex
.getCellsInRow
(rowIndex: number) → fn(selection: Selection) → [{pos: number, node: ProseMirrorNode}]
rowIndex
.getCellsInTable
(selection: Selection) → [{pos: number, node: ProseMirrorNode}]
Transforms:
removeParentNodeOfType
(nodeType: NodeType) → fn(tr: Transaction) → ?Transaction
replace
transaction that replaces a node of a given nodeType
with the given node
.replaceParentNodeOfType
(nodeType: NodeType, node: ProseMirrorNode) → fn(tr: Transaction) → ?Transaction
replace
transaction that replaces parent node of a given nodeType
with the given node
.removeSelectedNode
(tr: Transaction) → ?Transaction
delete
transaction that removes selected node.safeInsert
(node: ProseMirrorNode) → fn(tr: Transaction) → ?Transaction
insert
transaction that inserts a given node
at the current cursor position if it is allowed by schema. If schema restricts such nesting, it will try to find the appropriate place for the given node
in the document, looping through parent nodes up until the root document node.FAQs
Utils library for ProseMirror
The npm package prosemirror-utils receives a total of 73,880 weekly downloads. As such, prosemirror-utils popularity was classified as popular.
We found that prosemirror-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 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.