mirror of
https://github.com/makeplane/plane.git
synced 2026-07-12 21:40:18 +02:00
fix: fixed multi time file opener
This commit is contained in:
@@ -72,8 +72,12 @@ export const CustomImageNode = (props: CustomImageNodeViewProps) => {
|
||||
if (uploadEntity.event === "drop" && "file" in uploadEntity) {
|
||||
uploadFile(uploadEntity.file);
|
||||
} else if (uploadEntity.event === "insert" && fileInputRef.current && !hasTriggeredFilePickerRef.current) {
|
||||
const entity = editorStorage?.fileMap.get(id);
|
||||
if (entity && entity.hasOpenedFileInputOnce) return;
|
||||
fileInputRef.current.click();
|
||||
hasTriggeredFilePickerRef.current = true;
|
||||
if (!entity) return;
|
||||
editorStorage?.fileMap.set(id, { ...entity, hasOpenedFileInputOnce: true });
|
||||
}
|
||||
}
|
||||
}, [getUploadEntity, uploadFile]);
|
||||
|
||||
@@ -22,7 +22,7 @@ export interface UploadImageExtensionStorage {
|
||||
fileMap: Map<string, UploadEntity>;
|
||||
}
|
||||
|
||||
export type UploadEntity = { event: "insert" } | { event: "drop"; file: File };
|
||||
export type UploadEntity = ({ event: "insert" } | { event: "drop"; file: File }) & { hasOpenedFileInputOnce: boolean };
|
||||
|
||||
export const CustomImageExtension = (props: TFileHandler) => {
|
||||
const { upload } = props;
|
||||
@@ -46,12 +46,6 @@ export const CustomImageExtension = (props: TFileHandler) => {
|
||||
height: {
|
||||
default: "auto",
|
||||
},
|
||||
["data-type"]: {
|
||||
default: this.name,
|
||||
},
|
||||
["data-file"]: {
|
||||
default: null,
|
||||
},
|
||||
["id"]: {
|
||||
default: null,
|
||||
},
|
||||
@@ -63,6 +57,9 @@ export const CustomImageExtension = (props: TFileHandler) => {
|
||||
{
|
||||
tag: "image-component",
|
||||
},
|
||||
{
|
||||
tag: "img",
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
@@ -101,9 +98,7 @@ export const CustomImageExtension = (props: TFileHandler) => {
|
||||
}
|
||||
|
||||
const attributes = {
|
||||
"data-type": this.name,
|
||||
id: fileId,
|
||||
"data-file": props.file ? `data-file="${props.file}"` : "",
|
||||
};
|
||||
|
||||
if (props.pos) {
|
||||
|
||||
@@ -24,12 +24,6 @@ export const CustomReadOnlyImageExtension = () =>
|
||||
height: {
|
||||
default: "auto",
|
||||
},
|
||||
["data-type"]: {
|
||||
default: this.name,
|
||||
},
|
||||
["data-file"]: {
|
||||
default: null,
|
||||
},
|
||||
["id"]: {
|
||||
default: null,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user