![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
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
findParentNode
(predicate: fn(node: ProseMirrorNode) → boolean) → fn(selection: Selection) → ?{pos: number, node: ProseMirrorNode}
Iterates over parent nodes, returning the first node and its position predicate
returns truthy for.
findParentDomRef
(predicate: fn(node: ProseMirrorNode) → boolean, domAtPos: fn(pos: number) → {node: dom.Node, offset: number}) → fn(selection: Selection) → ?dom.Node
Iterates over parent nodes, returning DOM reference of the first node predicate
returns truthy for.
hasParentNode
(predicate: fn(node: ProseMirrorNode) → boolean) → fn(selection: Selection) → boolean
Checks if there's a parent node predicate
returns truthy for.
findParentNodeOfType
(nodeType: NodeType | [NodeType]) → fn(selection: Selection) → ?{node: ProseMirrorNode, pos: number}
Iterates over parent nodes, returning first node of the given nodeType
.
hasParentNodeOfType
(nodeType: NodeType | [NodeType]) → fn(selection: Selection) → boolean
Checks if there's a parent node of the given nodeType
.
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 first node of the given nodeType
.
findSelectedNodeOfType
(nodeType: NodeType | [NodeType]) → fn(selection: Selection) → ?{node: ProseMirrorNode, pos: number}
Returns a node of a given nodeType
if its selected.
isNodeSelection
(selection: Selection) → boolean
Checks if current selection is a NodeSelection
flatten
(node: ProseMirrorNode, descend: ?boolean = true) → [{node: ProseMirrorNode, pos: number}]
Flattens descendants of a given 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}]
Iterates over descendants of a given 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}]
Returns text nodes of a given node
. Doesn't descend into a node
when descend
argument is false
.
findInlineNodes
(node: ProseMirrorNode, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
Returns inline nodes of a given node
. Doesn't descend into a node
when descend
argument is false
.
findBlockNodes
(node: ProseMirrorNode, descend: ?boolean) → [{node: ProseMirrorNode, pos: number}]
Returns block descendants of a given 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}]
Iterates over descendants of a given 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}]
Iterates over descendants of a given 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}]
Iterates over descendants of a given 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
Returns true
if a given node
contains nodes of a given nodeType
findTable
(selection: Selection) → ?{pos: number, node: ProseMirrorNode}
Iterates over parent nodes, returning the first found table node.
isCellSelection
(selection: Selection) → boolean
Checks if current selection is a CellSelection
isColumnSelected
(columnIndex: number) → fn(selection: Selection) → boolean
Checks if entire column at index columnIndex
is selected
isRowSelected
(rowIndex: number) → fn(selection: Selection) → boolean
Checks if entire row at index rowIndex
is selected
isTableSelected
(selection: Selection) → boolean
Checks if entire table is selected
getCellsInColumn
(columnIndex: number) → fn(selection: Selection) → ?[{pos: number, node: ProseMirrorNode}]
Returns an array of cells in a column at index columnIndex
.
getCellsInRow
(rowIndex: number) → fn(selection: Selection) → ?[{pos: number, node: ProseMirrorNode}]
Returns an array of cells in a row at index rowIndex
.
getCellsInTable
(selection: Selection) → ?[{pos: number, node: ProseMirrorNode}]
Returns an array of all cells in a table.
selectColumn
(columnIndex: number) → fn(tr: Transaction) → Transaction
Creates a CellSelection on a column at columnIndex
.
selectRow
(rowIndex: number) → fn(tr: Transaction) → Transaction
Creates a CellSelection on a row at rowIndex
.
selectTable
(selection: Selection) → fn(tr: Transaction) → Transaction
Creates a CellSelection on the entire table.
emptySelectedCells
(schema: Schema) → fn(tr: Transaction) → Transaction
Clears the content of selected cells.
addColumnAt
(columnIndex: number) → fn(tr: Transaction) → Transaction
Returns a new transaction that adds a new column at columnIndex
.
addRowAt
(rowIndex: number) → fn(tr: Transaction) → Transaction
Returns a new transaction that adds a new row at rowIndex
.
removeColumnAt
(columnIndex: number) → fn(tr: Transaction) → Transaction
Returns a new transaction that removes a column at columnIndex
.
removeRowAt
(rowIndex: number) → fn(tr: Transaction) → Transaction
Returns a new transaction that removes a row at rowIndex
.
removeTable
(tr: Transaction) → Transaction
Returns a new transaction that removes a table if the cursor is inside
removeSelectedColumns
(tr: Transaction) → Transaction
Returns a new transaction that removes selected columns
removeSelectedRows
(tr: Transaction) → Transaction
Returns a new transaction that removes selected rows
removeParentNodeOfType
(nodeType: NodeType | [NodeType]) → fn(tr: Transaction) → Transaction
Returns a new transaction that removes a node of a given nodeType
.
It will return the original transaction if parent node hasn't been found.
replaceParentNodeOfType
(nodeType: NodeType | [NodeType], node: ProseMirrorNode) → fn(tr: Transaction) → Transaction
Returns a new transaction that replaces parent node of a given nodeType
with the given node
.
It will return the original transaction if 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 the original transaction if current selection is not a NodeSelection
replaceSelectedNode
(node: ProseMirrorNode) → fn(tr: Transaction) → Transaction
Returns a new transaction that replaces selected node with a given node
.
It will return the original transaction if current selection is not a NodeSelection, or replacing is not possible.
safeInsert
(node: ProseMirrorNode) → fn(tr: Transaction) → Transaction
Returns a new 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 an appropriate place for a given node
in the document, looping through parent nodes up until the root document node.
It will return the 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 transaction that sets a NodeSelection on a parent node of a given nodeType
.
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.