Skip to content

Commit

Permalink
fix: image deletion on submit fixed in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Palanikannan1437 committed Oct 4, 2024
1 parent f1a0a8d commit 0f7efb3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/editor/src/core/hooks/use-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const useEditor = (props: CustomEditorProps) => {
forwardedRef,
() => ({
clearEditor: (emitUpdate = false) => {
editorRef.current?.commands.clearContent(emitUpdate);
editorRef.current?.chain().setMeta("skipImageDeletion", true).clearContent(emitUpdate).run();
},
setEditorValue: (content: string) => {
editorRef.current?.commands.setContent(content, false, { preserveWhitespace: "full" });
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/core/plugins/image/delete-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const TrackImageDeletionPlugin = (editor: Editor, deleteImage: DeleteImag
});

transactions.forEach((transaction) => {
if (transaction.getMeta("skipImageDeletion")) return;
// transaction could be a selection
if (!transaction.docChanged) return;

Expand Down

0 comments on commit 0f7efb3

Please sign in to comment.