Skip to content

Commit 631a4b0

Browse files
Copilottommoor
andauthored
Default PDF attachments to non-embedded on upload (outline#11745)
* Initial plan * Default PDF preview to false when uploading via drag and drop Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com> * Preserve PDF preview for block menu option and attachment replacement Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>
1 parent 52077e4 commit 631a4b0

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

app/editor/menus/block.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export default function blockMenuItems(
126126
accept: "application/pdf",
127127
width: 300,
128128
height: 424,
129+
preview: true,
129130
},
130131
},
131132
{

shared/editor/commands/insertFiles.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export type Options = {
3939
alt?: string | null;
4040
/** Layout class for alignment when inserting image */
4141
layoutClass?: string | null;
42+
/** Whether to show a PDF preview embed for attachment nodes */
43+
preview?: boolean;
4244
};
4345
};
4446

@@ -82,7 +84,6 @@ const insertFiles = async function (
8284
FileHelper.isVideo(file.type) &&
8385
!options.isAttachment &&
8486
!!schema.nodes.video;
85-
const isPdf = FileHelper.isPdf(file.type) && !options.isAttachment;
8687
const getDimensions = isImage
8788
? FileHelper.getImageDimensions
8889
: isVideo
@@ -95,7 +96,6 @@ const insertFiles = async function (
9596
source: await FileHelper.getImageSourceAttr(file),
9697
isImage,
9798
isVideo,
98-
isPdf,
9999
file,
100100
};
101101
})
@@ -204,7 +204,7 @@ const insertFiles = async function (
204204
title: upload.file.name ?? dictionary.untitled,
205205
size: upload.file.size,
206206
contentType: upload.file.type,
207-
preview: upload.isPdf,
207+
preview: false,
208208
...options.attrs,
209209
})
210210
)

shared/editor/nodes/Attachment.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ export default class Attachment extends Node {
209209
onFileUploadProgress,
210210
dictionary: this.options.dictionary,
211211
replaceExisting: true,
212+
attrs: {
213+
preview: node.attrs.preview,
214+
},
212215
});
213216
};
214217
inputElement.click();

0 commit comments

Comments
 (0)