File tree Expand file tree Collapse file tree 4 files changed +14
-3
lines changed Expand file tree Collapse file tree 4 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 44} from "./tree" ;
55
66import { toggleCollapse } from "./node" ;
7+ import { restoreCollapsedStatus } from "./store" ;
78
89import { DomContainer } from "./types" ;
910
@@ -15,6 +16,7 @@ export const Hooks = {
1516 container . addEventListener ( "toggle_collapse" , toggleCollapse ) ;
1617
1718 moveHtmlChildNodesToDataPosition ( container ) ;
19+ restoreCollapsedStatus ( container ) ;
1820 setCursorToEndOfFirstChildNode ( container ) ;
1921 } ,
2022 //updated() {},
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ function getDomNodeById(uuid: UUID | undefined) {
3535 return document . getElementById ( `nodes-form-${ uuid } ` ) as DomNode | null ;
3636}
3737
38- function getDataNodeFromDomNode ( node : DomNode ) : DataNode {
38+ export function getDataNodeFromDomNode ( node : DomNode ) : DataNode {
3939 const uuid = getUUID ( node ) ;
4040 const parent_id = getAttribute ( node , "parent" ) ;
4141 const prev_id = getAttribute ( node , "prev" ) ;
Original file line number Diff line number Diff line change 1- import { UUID } from "./types" ;
1+ import { getDataNodeFromDomNode } from "./node" ;
2+ import { DomContainer , DomNode , UUID } from "./types" ;
3+
4+ export function restoreCollapsedStatus ( container : DomContainer ) {
5+ const status = loadCollapsedStatus ( container . id ) ;
6+
7+ container . querySelectorAll ( ".node" ) . forEach ( ( node ) => {
8+ const { uuid } = getDataNodeFromDomNode ( node as DomNode ) ;
9+ status [ uuid ] && node . classList . add ( "collapsed" ) ;
10+ } ) ;
11+ }
212
313export function saveCollapseStatus ( id : string , uuid : UUID , collapsed : boolean ) {
414 const status = loadCollapsedStatus ( id ) ;
Original file line number Diff line number Diff line change @@ -8,4 +8,3 @@ export function moveHtmlChildNodesToDataPosition(container: DomContainer) {
88 moveDomNodeToDataPosition ( node as DomNode ) ;
99 } ) ;
1010}
11-
You can’t perform that action at this time.
0 commit comments