(editor: Editor, src: string)
| 70 | } |
| 71 | |
| 72 | function removeImageBySrc(editor: Editor, src: string): void { |
| 73 | const { state } = editor; |
| 74 | const { tr } = state; |
| 75 | let found = false; |
| 76 | |
| 77 | state.doc.descendants((node, pos) => { |
| 78 | if (found) return false; |
| 79 | if (node.type.name === 'image' && node.attrs.src === src) { |
| 80 | tr.delete(pos, pos + node.nodeSize); |
| 81 | found = true; |
| 82 | return false; |
| 83 | } |
| 84 | }); |
| 85 | |
| 86 | if (found) { |
| 87 | editor.view.dispatch(tr); |
| 88 | } |
| 89 | } |
no test coverage detected