Skip to content

Commit

Permalink
resolve pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
reactoholic committed Jan 6, 2025
1 parent 004871a commit ce38df9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/core/ui/forms/MarkdownInput/FormikMarkdownField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ export const FormikMarkdownField = ({
const clipboardData = event.clipboardData;
const items = clipboardData.items;

if (!items) {
return;
}
if (!items) return;

const storageBucketId = storageConfig?.storageBucketId;

if (storageBucketId) {
let hasImage = false;

for (const item of items) {
if (item.type.startsWith('image/')) {
const file = item.getAsFile();
Expand All @@ -165,11 +165,15 @@ export const FormikMarkdownField = ({
});
};

reader.readAsDataURL(file);
event.preventDefault();
reader.readAsDataURL(file); // Read to trigger onLoad.
hasImage = true;
}
}
}

if (hasImage) {
event.preventDefault(); // Prevent default only if there's an image.
}
}
},
[storageConfig?.storageBucketId, uploadFile]
Expand Down

0 comments on commit ce38df9

Please sign in to comment.