(blockId: string, note: Note)
| 66 | blockId: string |
| 67 | ): BlockReference | null => { |
| 68 | for (const note of Object.values(notes)) { |
| 69 | const blockRef = getBlockReferenceFromNote(blockId, note); |
| 70 | if (blockRef) { |
| 71 | return blockRef; |
| 72 | } |
| 73 | } |
| 74 | return null; |
| 75 | }; |
| 76 | |
| 77 | const getBlockReferenceFromNote = (blockId: string, note: Note) => { |
| 78 | const editor = createEditor(); |
| 79 | editor.children = note.content; |
| 80 | |
| 81 | // Find element that matches the block id |
| 82 | const matchingElements = Editor.nodes<Element>(editor, { |
| 83 | at: [], |
| 84 | match: (n) => |
| 85 | Element.isElement(n) && |
| 86 | Editor.isBlock(editor, n) && |
| 87 | isReferenceableBlockElement(n) && |
| 88 | n.id === blockId, |
| 89 | }); |
| 90 |
no test coverage detected