@dfosco/storyboard-react 3.11.1 → 3.11.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/package.json +3 -3
- package/src/canvas/CanvasPage.jsx +10 -0
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfosco/storyboard-react",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.2",
|
|
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.2",
|
|
7
|
+
"@dfosco/tiny-canvas": "3.11.2",
|
|
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
|
|
|
@@ -919,6 +922,13 @@ 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
|
+
useEffect(() => {
|
|
927
|
+
if (loading || initialWidgetParam.current) return
|
|
928
|
+
initialWidgetParam.current = true // only once
|
|
929
|
+
document.dispatchEvent(new CustomEvent('storyboard:canvas:zoom-to-fit'))
|
|
930
|
+
}, [loading])
|
|
931
|
+
|
|
922
932
|
// Canvas background should follow toolbar theme target.
|
|
923
933
|
useEffect(() => {
|
|
924
934
|
function readMode() {
|