Add topic extension

This commit is contained in:
Jon Staab
2024-08-22 17:25:53 -07:00
parent dc4dcb1ea2
commit d6fa0a85bc
9 changed files with 281 additions and 192 deletions
+22
View File
@@ -0,0 +1,22 @@
import type {JSONContent, PasteRuleMatch} from '@tiptap/core'
export const createPasteRuleMatch = <T extends Record<string, unknown>>(
match: RegExpMatchArray,
data: T,
): PasteRuleMatch => ({ index: match.index!, replaceWith: match[2], text: match[0], match, data })
export const findNodes = (json: JSONContent, type: string) => {
const results: JSONContent[] = []
for (const node of json.content || []) {
if (node.type === type) {
results.push(node)
}
for (const result of findNodes(node, type)) {
results.push(result)
}
}
return results
}