@@ -4,14 +4,15 @@ import { SigninToContinueBannerPrmoptProvider } from "components/prompt-banner-s
44import { Editor , EditorDefaultProviders } from "scaffolds/editor" ;
55import { EditorSnapshot , StateProvider } from "core/states" ;
66import { WorkspaceAction } from "core/actions" ;
7- import { useDesignFile } from "hooks" ;
7+ import { useDesign , useDesignFile } from "hooks" ;
88
99import { warmup } from "scaffolds/editor" ;
1010
1111export default function FileEntryEditor ( ) {
1212 const router = useRouter ( ) ;
13- const { key } = router . query ;
13+ const { key, node } = router . query ;
1414 const filekey = key as string ;
15+ const nodeid = node as string ;
1516
1617 const [ loading , setLoading ] = useState < boolean > ( true ) ;
1718
@@ -111,3 +112,47 @@ export default function FileEntryEditor() {
111112 </ SigninToContinueBannerPrmoptProvider >
112113 ) ;
113114}
115+
116+ /**
117+ * TODO: support single design fetching
118+ // if target node is provided from query, use it.
119+ const design = useDesign({
120+ type: "use-file-node-id",
121+ file: filekey,
122+ node: nodeid,
123+ });
124+
125+
126+ useEffect(() => {
127+ if (!loading) {
128+ // if already loaded, ignore target node change.
129+ return;
130+ }
131+ if (design) {
132+ if (initialState.type === "success") return;
133+ initialDispatcher({
134+ type: "set",
135+ value: warmup.initializeDesign(design),
136+ });
137+ }
138+ }, [design, router.query, loading]);
139+
140+ // under main hook
141+ if (design) {
142+ const initialState = warmup.initializeDesign(design);
143+ val = {
144+ ...initialState,
145+ design: {
146+ ...initialState.design,
147+ pages: pages,
148+ },
149+ selectedPage: warmup.selectedPage(
150+ prevstate,
151+ pages,
152+ initialState.selectedNodes
153+ ),
154+ };
155+ } else {
156+
157+ }
158+ */
0 commit comments