Skip to content

Commit ca88af2

Browse files
update router query with selected node
1 parent 9a5946b commit ca88af2

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

editor-packages/editor-canvas/canvas/canvas.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type { XY, XYWH } from "../types";
1616

1717
const designq = utils.query;
1818

19-
const INITIAL_SCALE = 1;
19+
const INITIAL_SCALE = 0.5;
2020
const INITIAL_XY: XY = [0, 0];
2121
const LAYER_HOVER_HIT_MARGIN = 3.5;
2222
const MIN_ZOOM = 0.02;

editor/core/reducers/editor-reducer.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
import produce from "immer";
22
import { Action, SelectNodeAction, SelectPageAction } from "core/actions";
33
import { EditorState } from "core/states";
4+
import { useRouter } from "next/router";
45

56
export function editorReducer(state: EditorState, action: Action): EditorState {
7+
const router = useRouter();
8+
69
// TODO: handle actions here.
710
switch (action.type) {
811
case "select-node": {
912
const { node } = <SelectNodeAction>action;
1013
console.clear();
1114
console.info("cleard console by editorReducer#select-node");
15+
16+
// update router
17+
router.query.node = node ?? state.selectedPage;
18+
router.push(router);
19+
1220
return produce(state, (draft) => {
1321
draft.selectedNodes = [node].filter(Boolean);
1422
});
1523
}
1624
case "select-page": {
1725
const { page } = <SelectPageAction>action;
26+
27+
console.clear();
28+
console.info("cleard console by editorReducer#select-page");
29+
30+
// update router
31+
router.query.node = page;
32+
router.push(router);
33+
1834
return produce(state, (draft) => {
1935
draft.selectedPage = page;
36+
draft.selectedNodes = [];
2037
});
2138
}
2239
default:

0 commit comments

Comments
 (0)