mirror of
https://github.com/ruilisi/fortune-sheet.git
synced 2025-01-07 03:16:50 +08:00
fix: Right-click menu insert image option doesn't work
This commit is contained in:
parent
b5b5a530c7
commit
6fa630c22f
@ -31,6 +31,7 @@ import {
|
||||
fixRowStyleOverflowInFreeze,
|
||||
fixColumnStyleOverflowInFreeze,
|
||||
handleKeydownForZoom,
|
||||
insertImage,
|
||||
} from "@fortune-sheet/core";
|
||||
import _ from "lodash";
|
||||
import WorkbookContext, { SetContextOptions } from "../../context";
|
||||
@ -428,6 +429,31 @@ const SheetOverlay: React.FC = () => {
|
||||
<RowHeader />
|
||||
<ScrollBar axis="x" />
|
||||
<ScrollBar axis="y" />
|
||||
<input
|
||||
id="fortune-img-upload"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
style={{ display: "none" }}
|
||||
onChange={(e) => {
|
||||
const file = e.currentTarget.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
const render = new FileReader();
|
||||
render.readAsDataURL(file);
|
||||
render.onload = (event) => {
|
||||
if (event.target == null) return;
|
||||
const src = event.target?.result;
|
||||
const image = new Image();
|
||||
image.onload = () => {
|
||||
setContext((draftCtx) => {
|
||||
insertImage(draftCtx, image);
|
||||
});
|
||||
};
|
||||
image.src = src as string;
|
||||
};
|
||||
e.currentTarget.value = "";
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
ref={refs.cellArea}
|
||||
className="fortune-cell-area"
|
||||
|
@ -24,7 +24,6 @@ import {
|
||||
handleBorder,
|
||||
toolbarItemSelectedFunc,
|
||||
handleFreeze,
|
||||
insertImage,
|
||||
showImgChooser,
|
||||
updateFormat,
|
||||
handleSort,
|
||||
@ -846,33 +845,7 @@ const Toolbar: React.FC<{
|
||||
if (context.allowEdit === false) return;
|
||||
showImgChooser();
|
||||
}}
|
||||
>
|
||||
<input
|
||||
id="fortune-img-upload"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
style={{ display: "none" }}
|
||||
onChange={(e) => {
|
||||
const file = e.currentTarget.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
const render = new FileReader();
|
||||
render.readAsDataURL(file);
|
||||
render.onload = (event) => {
|
||||
if (event.target == null) return;
|
||||
const src = event.target?.result;
|
||||
const image = new Image();
|
||||
image.onload = () => {
|
||||
setContext((draftCtx) => {
|
||||
insertImage(draftCtx, image);
|
||||
});
|
||||
};
|
||||
image.src = src as string;
|
||||
};
|
||||
e.currentTarget.value = "";
|
||||
}}
|
||||
/>
|
||||
</Button>
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (name === "comment") {
|
||||
|
Loading…
Reference in New Issue
Block a user