feat: editor attachment paste handling (#1975)

* reupload attachments if uploaded to a different page
* use image dimensions on paste/DnD

* tooltips withinPortal:false

* isolating attribute
This commit is contained in:
Philip Okugbe
2026-02-28 01:24:19 +00:00
committed by GitHub
parent df64de5306
commit fc0997fd90
15 changed files with 260 additions and 33 deletions
@@ -53,6 +53,7 @@ export const Callout = Node.create<CalloutOptions>({
content: "block+",
group: "block",
defining: true,
isolating: true,
addAttributes() {
return {
@@ -40,6 +40,8 @@ const handleImageUpload =
);
const placeholderId = generateNodeId();
const width = imageDimensions?.width ?? undefined;
const height = imageDimensions?.height ?? undefined;
const aspectRatio = imageDimensions
? imageDimensions.width / imageDimensions.height
: undefined;
@@ -57,6 +59,8 @@ const handleImageUpload =
id: placeholderId,
name: file.name,
},
width,
height,
aspectRatio,
});
@@ -88,6 +92,8 @@ const handleImageUpload =
src: `/api/files/${attachment.id}/${attachment.fileName}`,
attachmentId: attachment.id,
size: attachment.fileSize,
width,
height,
aspectRatio,
});
@@ -24,6 +24,7 @@ export const MathBlock = Node.create({
name: "mathBlock",
group: "block",
atom: true,
isolating: true,
addOptions() {
return {
@@ -29,6 +29,7 @@ export const Subpages = Node.create<SubpagesOptions>({
group: "block",
atom: true,
draggable: true,
isolating: true,
parseHTML() {
return [
@@ -61,7 +61,9 @@ const handleVideoUpload =
const objectUrl = URL.createObjectURL(file);
const videoDimensions = await getVideoDimensions(objectUrl);
const placeholderId = generateNodeId();
const aspectRatio = videoDimensions.aspectRatio;
const width = videoDimensions?.width ?? undefined;
const height = videoDimensions?.height ?? undefined;
const aspectRatio = videoDimensions?.aspectRatio;
let placeholderInserted = false;
@@ -76,6 +78,8 @@ const handleVideoUpload =
id: placeholderId,
name: file.name,
},
width,
height,
aspectRatio,
});
@@ -108,6 +112,8 @@ const handleVideoUpload =
attachmentId: attachment.id,
title: attachment.fileName,
size: attachment.fileSize,
width,
height,
aspectRatio,
});