File tree Expand file tree Collapse file tree
editor-packages/editor-canvas/canvas Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import type { XY, XYWH } from "../types";
1616
1717const designq = utils . query ;
1818
19- const INITIAL_SCALE = 1 ;
19+ const INITIAL_SCALE = 0.5 ;
2020const INITIAL_XY : XY = [ 0 , 0 ] ;
2121const LAYER_HOVER_HIT_MARGIN = 3.5 ;
2222const MIN_ZOOM = 0.02 ;
Original file line number Diff line number Diff line change 11import produce from "immer" ;
22import { Action , SelectNodeAction , SelectPageAction } from "core/actions" ;
33import { EditorState } from "core/states" ;
4+ import { useRouter } from "next/router" ;
45
56export 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 :
You can’t perform that action at this time.
0 commit comments