(
view: { state: { doc: { nodeAt(pos: number): { type: { name: string }; textContent: string } | null } } },
getPos: (() => number | undefined) | undefined,
)
| 23 | * view ProseMirror has since discarded answers null instead of stale text. |
| 24 | */ |
| 25 | export function codeBlockModelText( |
| 26 | view: { state: { doc: { nodeAt(pos: number): { type: { name: string }; textContent: string } | null } } }, |
| 27 | getPos: (() => number | undefined) | undefined, |
| 28 | ): string | null { |
| 29 | const pos = typeof getPos === 'function' ? getPos() : undefined; |
| 30 | if (typeof pos !== 'number') return null; |
| 31 | const node = view.state.doc.nodeAt(pos); |
| 32 | if (!node || node.type.name !== 'codeBlock') return null; |
| 33 | return node.textContent; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * A hover-to-reveal "Copy" button. `getText` is called on each click; null |
no outgoing calls
no test coverage detected