@dfosco/storyboard-react 3.11.1 → 3.11.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/package.json +3 -3
- package/src/canvas/CanvasPage.jsx +14 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfosco/storyboard-react",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@dfosco/storyboard-core": "3.11.
|
|
7
|
-
"@dfosco/tiny-canvas": "3.11.
|
|
6
|
+
"@dfosco/storyboard-core": "3.11.3",
|
|
7
|
+
"@dfosco/tiny-canvas": "3.11.3",
|
|
8
8
|
"@neodrag/react": "^2.3.1",
|
|
9
9
|
"glob": "^11.0.0",
|
|
10
10
|
"jsonc-parser": "^3.3.1"
|
|
@@ -287,6 +287,7 @@ export default function CanvasPage({ name }) {
|
|
|
287
287
|
const zoomRef = useRef(initialViewport?.zoom ?? 100)
|
|
288
288
|
const scrollRef = useRef(null)
|
|
289
289
|
const pendingScrollRestore = useRef(initialViewport)
|
|
290
|
+
const initialWidgetParam = useRef(new URLSearchParams(window.location.search).has('widget'))
|
|
290
291
|
const [canvasTitle, setCanvasTitle] = useState(canvas?.title || name)
|
|
291
292
|
const titleInputRef = useRef(null)
|
|
292
293
|
const [localSources, setLocalSources] = useState(canvas?.sources ?? [])
|
|
@@ -395,6 +396,8 @@ export default function CanvasPage({ name }) {
|
|
|
395
396
|
setLocalWidgets(canvas?.widgets ?? null)
|
|
396
397
|
setLocalSources(canvas?.sources ?? [])
|
|
397
398
|
setCanvasTitle(canvas?.title || name)
|
|
399
|
+
setSnapEnabled(canvas?.snapToGrid ?? false)
|
|
400
|
+
setSnapGridSize(canvas?.gridSize || 40)
|
|
398
401
|
undoRedo.reset()
|
|
399
402
|
}
|
|
400
403
|
|
|
@@ -860,7 +863,7 @@ export default function CanvasPage({ name }) {
|
|
|
860
863
|
function handleSnapToggle() {
|
|
861
864
|
setSnapEnabled((prev) => {
|
|
862
865
|
const next = !prev
|
|
863
|
-
updateCanvas(name, { snapToGrid: next }).catch((err) =>
|
|
866
|
+
updateCanvas(name, { settings: { snapToGrid: next } }).catch((err) =>
|
|
864
867
|
console.error('[canvas] Failed to persist snap setting:', err)
|
|
865
868
|
)
|
|
866
869
|
return next
|
|
@@ -919,6 +922,16 @@ export default function CanvasPage({ name }) {
|
|
|
919
922
|
return () => document.removeEventListener('storyboard:canvas:zoom-to-fit', handleZoomToFit)
|
|
920
923
|
}, [localWidgets, localSources, jsxExports])
|
|
921
924
|
|
|
925
|
+
// On initial load without a ?widget= deep link, zoom to fit all objects.
|
|
926
|
+
// Wait for jsxExports when the canvas has a JSX module so components are
|
|
927
|
+
// included in the bounding-box calculation.
|
|
928
|
+
useEffect(() => {
|
|
929
|
+
if (loading || initialWidgetParam.current) return
|
|
930
|
+
if (canvas?._jsxModule && !jsxExports) return
|
|
931
|
+
initialWidgetParam.current = true // only once
|
|
932
|
+
document.dispatchEvent(new CustomEvent('storyboard:canvas:zoom-to-fit'))
|
|
933
|
+
}, [loading, jsxExports, canvas])
|
|
934
|
+
|
|
922
935
|
// Canvas background should follow toolbar theme target.
|
|
923
936
|
useEffect(() => {
|
|
924
937
|
function readMode() {
|