@bwp-web/canvas 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -2566,6 +2566,16 @@ function useEditCanvas(options) {
|
|
|
2566
2566
|
canvas.on("object:modified", markDirtyIfNotLoading);
|
|
2567
2567
|
canvas.on("background:modified", markDirtyIfNotLoading);
|
|
2568
2568
|
}
|
|
2569
|
+
canvas.on("object:added", (e) => {
|
|
2570
|
+
if (!isInitialLoadRef.current && e.target) {
|
|
2571
|
+
setObjects((prev) => [...prev, e.target]);
|
|
2572
|
+
}
|
|
2573
|
+
});
|
|
2574
|
+
canvas.on("object:removed", (e) => {
|
|
2575
|
+
if (!isInitialLoadRef.current && e.target) {
|
|
2576
|
+
setObjects((prev) => prev.filter((o) => o !== e.target));
|
|
2577
|
+
}
|
|
2578
|
+
});
|
|
2569
2579
|
if (opts?.history) {
|
|
2570
2580
|
const syncHistoryState = () => {
|
|
2571
2581
|
const h = historyRef.current;
|
|
@@ -2873,12 +2883,15 @@ function useViewCanvas(options) {
|
|
|
2873
2883
|
initPromise.then(async () => {
|
|
2874
2884
|
const onReadyResult = opts?.onReady?.(canvas);
|
|
2875
2885
|
await Promise.resolve(onReadyResult);
|
|
2876
|
-
if (opts?.invertBackground !== void 0) {
|
|
2877
|
-
setBackgroundInverted(canvas, opts.invertBackground);
|
|
2878
|
-
}
|
|
2879
2886
|
if (canvas.lockLightMode !== void 0) {
|
|
2880
2887
|
setLockLightMode(canvas.lockLightMode);
|
|
2881
2888
|
}
|
|
2889
|
+
if (opts?.invertBackground !== void 0) {
|
|
2890
|
+
setBackgroundInverted(
|
|
2891
|
+
canvas,
|
|
2892
|
+
opts.invertBackground && !canvas.lockLightMode
|
|
2893
|
+
);
|
|
2894
|
+
}
|
|
2882
2895
|
if (opts?.autoFitToBackground !== false && canvas.backgroundImage) {
|
|
2883
2896
|
fitViewportToBackground(canvas);
|
|
2884
2897
|
syncZoom(canvasRef, setZoom);
|
|
@@ -2891,8 +2904,8 @@ function useViewCanvas(options) {
|
|
|
2891
2904
|
useEffect3(() => {
|
|
2892
2905
|
const canvas = canvasRef.current;
|
|
2893
2906
|
if (!canvas || options?.invertBackground === void 0) return;
|
|
2894
|
-
setBackgroundInverted(canvas, options.invertBackground);
|
|
2895
|
-
}, [options?.invertBackground]);
|
|
2907
|
+
setBackgroundInverted(canvas, options.invertBackground && !lockLightMode);
|
|
2908
|
+
}, [options?.invertBackground, lockLightMode]);
|
|
2896
2909
|
const { resetViewport: resetViewport2, zoomIn, zoomOut, panToObject, zoomToFit } = useViewportActions(canvasRef, viewportRef, setZoom);
|
|
2897
2910
|
const viewport = useMemo3(
|
|
2898
2911
|
() => ({
|