Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: add support for ignoring edits

Abdullah Atta081201aa4237
diff --git a/packages/editor/src/extensions/attachment/attachment.ts b/packages/editor/src/extensions/attachment/attachment.ts
index 11b4e49dc..e83cfd3bc 100644
--- a/packages/editor/src/extensions/attachment/attachment.ts
+++ b/packages/editor/src/extensions/attachment/attachment.ts
@@ -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;
diff --git a/packages/editor/src/extensions/image/component.tsx b/packages/editor/src/extensions/image/component.tsx
index def457cdc..06840dc82 100644
--- a/packages/editor/src/extensions/image/component.tsx
+++ b/packages/editor/src/extensions/image/component.tsx
@@ -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
})
);
}