Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(doc): failed to process image upload (#4120)
Gpound.liu2547183f5653
diff --git a/packages/docs-ui/src/services/clipboard/clipboard.service.ts b/packages/docs-ui/src/services/clipboard/clipboard.service.tsindex db82b1103e..33ef0ac2aa 100644--- a/packages/docs-ui/src/services/clipboard/clipboard.service.ts+++ b/packages/docs-ui/src/services/clipboard/clipboard.service.ts@@ -49,7 +49,7 @@ export interface IDocClipboardHook {onCopyProperty?(start: number, end: number): IClipboardPropertyItem;onCopyContent?(start: number, end: number): string;onBeforePaste?: (body: IDocumentBody) => IDocumentBody;- onBeforePasteImage?: (file: File) => Promise<{ source: string; imageSourceType: ImageSourceType }>;+ onBeforePasteImage?: (file: File) => Promise<{ source: string; imageSourceType: ImageSourceType } | null>;}export interface IDocClipboardService {@@ -527,6 +527,9 @@ export class DocClipboardService extends Disposable implements IDocClipboardServawait Promise.all(files.map(async (file, index) => {const image = await onBeforePasteImage(file);+ if (!image) {+ return Promise.resolve();+ }const { width = 100, height = 100 } = await getImageSize(file);const itemId = `paste_image_id_${index}`;const body = doc.body!;