atlassian/prosemirror-utils hiện có 521 sao trên GitHub, viết chủ yếu bằng TypeScript. ⚒ Utils library for ProseMirror
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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.
GitHub topics của atlassian/prosemirror-utils: "helpers", "prosemirror", "prosemirror-utils", "utils". TopGit xếp repo vào nhóm mã nguồn mở.
atlassian/prosemirror-utils có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho atlassian/prosemirror-utils. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
atlassian/prosemirror-utils có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho atlassian/prosemirror-utils. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
atlassian/prosemirror-utils còn đang phát triển không?
Commit gần nhất trên atlassian/prosemirror-utils là 2.3 năm trước (theo timestamp GitHub). Repo có 61 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
Đọc thêm về atlassian/prosemirror-utils ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/atlassian/prosemirror-utils là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
prosemirror-utils có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về prosemirror-utils.