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 4
4
} from "./tree" ;
5
5
6
6
import { toggleCollapse } from "./node" ;
7
+ import { restoreCollapsedStatus } from "./store" ;
7
8
8
9
import { DomContainer } from "./types" ;
9
10
@@ -15,6 +16,7 @@ export const Hooks = {
15
16
container . addEventListener ( "toggle_collapse" , toggleCollapse ) ;
16
17
17
18
moveHtmlChildNodesToDataPosition ( container ) ;
19
+ restoreCollapsedStatus ( container ) ;
18
20
setCursorToEndOfFirstChildNode ( container ) ;
19
21
} ,
20
22
//updated() {},
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ function getDomNodeById(uuid: UUID | undefined) {
35
35
return document . getElementById ( `nodes-form-${ uuid } ` ) as DomNode | null ;
36
36
}
37
37
38
- function getDataNodeFromDomNode ( node : DomNode ) : DataNode {
38
+ export function getDataNodeFromDomNode ( node : DomNode ) : DataNode {
39
39
const uuid = getUUID ( node ) ;
40
40
const parent_id = getAttribute ( node , "parent" ) ;
41
41
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
+ }
2
12
3
13
export function saveCollapseStatus ( id : string , uuid : UUID , collapsed : boolean ) {
4
14
const status = loadCollapsedStatus ( id ) ;
Original file line number Diff line number Diff line change @@ -8,4 +8,3 @@ export function moveHtmlChildNodesToDataPosition(container: DomContainer) {
8
8
moveDomNodeToDataPosition ( node as DomNode ) ;
9
9
} ) ;
10
10
}
11
-
You can’t perform that action at this time.
0 commit comments