@bwp-web/canvas 0.9.0 → 0.9.2
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
|
@@ -2826,6 +2826,9 @@ function useViewCanvas(options) {
|
|
|
2826
2826
|
const [zoom, setZoom] = useState2(1);
|
|
2827
2827
|
const [objects, setObjects] = useState2([]);
|
|
2828
2828
|
const [isLoading, setIsLoading] = useState2(false);
|
|
2829
|
+
const [lockLightMode, setLockLightMode] = useState2(
|
|
2830
|
+
void 0
|
|
2831
|
+
);
|
|
2829
2832
|
const onReady = useCallback2(
|
|
2830
2833
|
(canvas) => {
|
|
2831
2834
|
canvasRef.current = canvas;
|
|
@@ -2870,8 +2873,14 @@ function useViewCanvas(options) {
|
|
|
2870
2873
|
initPromise.then(async () => {
|
|
2871
2874
|
const onReadyResult = opts?.onReady?.(canvas);
|
|
2872
2875
|
await Promise.resolve(onReadyResult);
|
|
2876
|
+
if (canvas.lockLightMode !== void 0) {
|
|
2877
|
+
setLockLightMode(canvas.lockLightMode);
|
|
2878
|
+
}
|
|
2873
2879
|
if (opts?.invertBackground !== void 0) {
|
|
2874
|
-
setBackgroundInverted(
|
|
2880
|
+
setBackgroundInverted(
|
|
2881
|
+
canvas,
|
|
2882
|
+
opts.invertBackground && !canvas.lockLightMode
|
|
2883
|
+
);
|
|
2875
2884
|
}
|
|
2876
2885
|
if (opts?.autoFitToBackground !== false && canvas.backgroundImage) {
|
|
2877
2886
|
fitViewportToBackground(canvas);
|
|
@@ -2885,8 +2894,8 @@ function useViewCanvas(options) {
|
|
|
2885
2894
|
useEffect3(() => {
|
|
2886
2895
|
const canvas = canvasRef.current;
|
|
2887
2896
|
if (!canvas || options?.invertBackground === void 0) return;
|
|
2888
|
-
setBackgroundInverted(canvas, options.invertBackground);
|
|
2889
|
-
}, [options?.invertBackground]);
|
|
2897
|
+
setBackgroundInverted(canvas, options.invertBackground && !lockLightMode);
|
|
2898
|
+
}, [options?.invertBackground, lockLightMode]);
|
|
2890
2899
|
const { resetViewport: resetViewport2, zoomIn, zoomOut, panToObject, zoomToFit } = useViewportActions(canvasRef, viewportRef, setZoom);
|
|
2891
2900
|
const viewport = useMemo3(
|
|
2892
2901
|
() => ({
|
|
@@ -2969,11 +2978,13 @@ function useViewCanvas(options) {
|
|
|
2969
2978
|
/** Batch-update multiple objects' visual styles in one render. Keyed by `data.id`. */
|
|
2970
2979
|
setObjectStyles,
|
|
2971
2980
|
/** Apply a visual style to all objects whose `data.type` matches. */
|
|
2972
|
-
setObjectStyleByType
|
|
2981
|
+
setObjectStyleByType,
|
|
2982
|
+
/** Whether the canvas is locked to light mode. Read from loaded canvas data. */
|
|
2983
|
+
lockLightMode
|
|
2973
2984
|
}),
|
|
2974
2985
|
// Only reactive state in deps — refs and stable callbacks are omitted
|
|
2975
2986
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2976
|
-
[zoom, objects, isLoading, viewport]
|
|
2987
|
+
[zoom, objects, isLoading, viewport, lockLightMode]
|
|
2977
2988
|
);
|
|
2978
2989
|
}
|
|
2979
2990
|
|
|
@@ -3246,11 +3257,12 @@ function ViewCanvasProvider({
|
|
|
3246
3257
|
isLoading: canvas.isLoading,
|
|
3247
3258
|
setObjectStyle: canvas.setObjectStyle,
|
|
3248
3259
|
setObjectStyles: canvas.setObjectStyles,
|
|
3249
|
-
setObjectStyleByType: canvas.setObjectStyleByType
|
|
3260
|
+
setObjectStyleByType: canvas.setObjectStyleByType,
|
|
3261
|
+
lockLightMode: canvas.lockLightMode
|
|
3250
3262
|
}),
|
|
3251
3263
|
// Only reactive state — stable callbacks omitted
|
|
3252
3264
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3253
|
-
[canvas.objects, canvas.isLoading]
|
|
3265
|
+
[canvas.objects, canvas.isLoading, canvas.lockLightMode]
|
|
3254
3266
|
);
|
|
3255
3267
|
return /* @__PURE__ */ jsx3(CanvasRefContext.Provider, { value: canvas.canvasRef, children: /* @__PURE__ */ jsx3(ViewViewportContext.Provider, { value: viewportValue, children: /* @__PURE__ */ jsx3(ViewStateContext.Provider, { value: stateValue, children }) }) });
|
|
3256
3268
|
}
|