feat: Show icon on external links (#3100)

* feat: External links get treatment

* cache decorations
This commit is contained in:
Tom Moor
2022-02-16 18:05:02 -08:00
committed by GitHub
parent 3760a03c44
commit d7ee801fe4
11 changed files with 162 additions and 73 deletions

View File

@@ -0,0 +1,19 @@
import { Node } from "prosemirror-model";
import { findTextNodes, NodeWithPos } from "prosemirror-utils";
export default function findLinkNodes(doc: Node): NodeWithPos[] {
const textNodes = findTextNodes(doc);
const nodes: NodeWithPos[] = [];
for (const nodeWithPos of textNodes) {
const hasLinkMark = nodeWithPos.node.marks.find(
(mark) => mark.type.name === "link"
);
if (hasLinkMark) {
nodes.push(nodeWithPos);
}
}
return nodes;
}