Skip to content

Commit

Permalink
fix removeFigure function
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed Apr 23, 2024
1 parent 45e055e commit 6229136
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/exports/extensions/attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ export const Attachment = Node.create<AttachmentOptions>({
}
};

const removeFigure = () => {
function removeFigure (this: HTMLElement) {
if (typeof getPos === "function") {
const { view } = editor;

Expand All @@ -722,6 +722,12 @@ export const Attachment = Node.create<AttachmentOptions>({
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`
Expand Down

0 comments on commit 6229136

Please sign in to comment.