editor: add support for ignoring edits

This commit is contained in:
Abdullah Atta
2024-01-29 17:58:40 +05:00
committed by Abdullah Atta
parent 270e6778d1
commit 081201aa42
2 changed files with 5 additions and 2 deletions

View File

@@ -44,6 +44,7 @@ declare module "@tiptap/core" {
attachment: Partial<Attachment>,
options: {
preventUpdate?: boolean;
ignoreEdit?: boolean;
query: (attachment: Attachment) => boolean;
}
) => ReturnType;
@@ -169,6 +170,7 @@ export const AttachmentNode = Node.create<AttachmentOptions>({
});
}
tr.setMeta("preventUpdate", options.preventUpdate || false);
tr.setMeta("ignoreEdit", options.ignoreEdit || false);
tr.setMeta("addToHistory", false);
if (dispatch) dispatch(tr);
return true;

View File

@@ -296,13 +296,14 @@ export function ImageComponent(
...fixedDimensions,
aspectRatio: naturalAspectRatio
},
{ query: makeImageQuery(src, hash) }
{ query: makeImageQuery(src, hash), ignoreEdit: true }
)
);
} else if (height !== fixedDimensions.height) {
await editor.threadsafe((editor) =>
editor.commands.updateAttachment(fixedDimensions, {
query: makeImageQuery(src, hash)
query: makeImageQuery(src, hash),
ignoreEdit: true
})
);
}