Skip to content

Commit

Permalink
don't spread props.insertImages into the dom element
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenries authored Jan 8, 2024
1 parent 021af5f commit ec7b064
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/controls/MenuButtonImageUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -52,6 +55,7 @@ export interface MenuButtonImageUploadProps
export default function MenuButtonImageUpload({
onUploadFiles,
inputProps,
insertImages,
...props
}: MenuButtonImageUploadProps) {
const editor = useRichTextEditorContext();
Expand All @@ -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,
});
Expand Down

0 comments on commit ec7b064

Please sign in to comment.