Skip to content

Commit 0441643

Browse files
MacMac
Mac
authored and
Mac
committed
image uploading issue resolved
1 parent e095e78 commit 0441643

File tree

4 files changed

+199
-30
lines changed

4 files changed

+199
-30
lines changed

‎lowcoder-comp-excalidraw/package-lock.json

+165-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lowcoder-comp-excalidraw/package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "meenam-lowcoder-comp-excalidraw-1",
3-
"version": "0.0.8",
2+
"name": "lowcoder-comp-excalidraw",
3+
"version": "0.0.1",
44
"type": "module",
55
"license": "MIT",
66
"dependencies": {
@@ -9,6 +9,7 @@
99
"@types/react": "18",
1010
"@types/react-dom": "18",
1111
"d3-array": "^3.2.4",
12+
"lodash": "^4.17.21",
1213
"lowcoder-cli": "^0.0.30",
1314
"lowcoder-sdk": "^2.4.3",
1415
"prop-types": "^15.8.1",
@@ -36,5 +37,8 @@
3637
"start": "vite",
3738
"build": "lowcoder-cli build",
3839
"build_publish": "lowcoder-cli build --publish"
40+
},
41+
"devDependencies": {
42+
"@types/lodash": "^4.17.7"
3943
}
4044
}

‎lowcoder-comp-excalidraw/src/ExcalidrawComp.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import {Excalidraw} from '@excalidraw/excalidraw';
1111
import {useState, useRef, useEffect} from 'react';
1212
import {trans} from './i18n/comps';
13+
import isEqual from 'lodash/isEqual';
1314

1415
import {useResizeDetector} from 'react-resize-detector';
1516
const defaultData = {
@@ -83,11 +84,14 @@ let ExcalidrawCompBase = (function () {
8384
});
8485
},
8586
});
87+
8688
useEffect(() => {
87-
if (excalidrawAPI) {
89+
if (excalidrawAPI && isEqual(previousDrawRef.current, props.data.value)) {
8890
excalidrawAPI.updateScene(props.data.value);
91+
previousDrawRef.current = props.data.value;
8992
}
90-
}, [JSON.stringify(props.data)]);
93+
}, [props.data.value, excalidrawAPI]);
94+
9195
return (
9296
<div
9397
ref={conRef}
@@ -100,7 +104,11 @@ let ExcalidrawCompBase = (function () {
100104
<Excalidraw
101105
isCollaborating={false}
102106
initialData={props.data.value}
103-
excalidrawAPI={(api) => setExcalidrawAPI(api)}
107+
excalidrawAPI={(api) => {
108+
if (!excalidrawAPI) {
109+
setExcalidrawAPI(api);
110+
}
111+
}}
104112
onChange={(excalidrawElements, appState, files) => {
105113
let draw = {
106114
elements: excalidrawElements,

0 commit comments

Comments
 (0)