Skip to content

Commit f86f400

Browse files
committed
fix(file-viewer): don't upload pasted/dropped images into a read-only editor
handlePaste/handleDrop ran the workspace image upload without checking editability, so a read-only doc (canEdit=false or a round-trip-unsafe file) could still trigger an upload. Guard both on view.editable.
1 parent 55860f6 commit f86f400

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/rich-markdown-editor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,15 @@ function LoadedRichMarkdownEditor({
239239
return true
240240
},
241241
handlePaste: (view, event) => {
242+
if (!view.editable) return false
242243
const images = extractImageFiles(event.clipboardData)
243244
if (images.length === 0) return false
244245
event.preventDefault()
245246
void insertImagesRef.current(images, view.state.selection.from)
246247
return true
247248
},
248249
handleDrop: (view, event) => {
250+
if (!view.editable) return false
249251
const images = extractImageFiles(event.dataTransfer)
250252
if (images.length === 0) return false
251253
event.preventDefault()

0 commit comments

Comments
 (0)