From ec7b064315c41e79bf02a2cf7203820be367de2a Mon Sep 17 00:00:00 2001 From: Loren Riesenfeld Date: Mon, 8 Jan 2024 14:48:31 -0500 Subject: [PATCH] don't spread `props.insertImages` into the dom element --- src/controls/MenuButtonImageUpload.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/controls/MenuButtonImageUpload.tsx b/src/controls/MenuButtonImageUpload.tsx index 932ee54..75f5b33 100644 --- a/src/controls/MenuButtonImageUpload.tsx +++ b/src/controls/MenuButtonImageUpload.tsx @@ -2,7 +2,10 @@ import type { Editor } from "@tiptap/core"; import { useRef, type ComponentPropsWithoutRef } from "react"; import type { SetOptional } from "type-fest"; import { useRichTextEditorContext } from "../context"; -import { insertImages, type ImageNodeAttributes } from "../utils"; +import { + insertImages as fallbackInsertImages, + type ImageNodeAttributes, +} from "../utils"; import MenuButtonAddImage, { type MenuButtonAddImageProps, } from "./MenuButtonAddImage"; @@ -52,6 +55,7 @@ export interface MenuButtonImageUploadProps export default function MenuButtonImageUpload({ onUploadFiles, inputProps, + insertImages, ...props }: MenuButtonImageUploadProps) { const editor = useRichTextEditorContext(); @@ -64,9 +68,9 @@ export default function MenuButtonImageUpload({ } const attributesForImages = await onUploadFiles(Array.from(files)); if (typeof props.insertImages === "function") { - props.insertImages({ editor, images: attributesForImages }); + insertImages({ editor, images: attributesForImages }); } else { - insertImages({ + fallbackInsertImages({ editor, images: attributesForImages, });