diff --git a/src/exports/extensions/attachment.ts b/src/exports/extensions/attachment.ts index 247fc668..8372469b 100644 --- a/src/exports/extensions/attachment.ts +++ b/src/exports/extensions/attachment.ts @@ -712,7 +712,7 @@ export const Attachment = Node.create({ } }; - const removeFigure = () => { + function removeFigure (this: HTMLElement) { if (typeof getPos === "function") { const { view } = editor; @@ -722,6 +722,12 @@ export const Attachment = Node.create({ tr.delete(pos, pos + 1); view.dispatch(tr); } + + // For some reason it doesnt always delete the attachment, so this is some extra insurance. + const closestAttachment = this.closest(".attachment") + if (closestAttachment) { + closestAttachment.remove() + } }; const template = html`