@@ -10,13 +10,18 @@ import {
1010 STRUCTURE_ONLY ,
1111} from 'src/stores/view/helpers/get-document-event-type' ;
1212
13- const defaultCache = ( ) => ( {
14- self : { } ,
15- 'direct-parent' : { } ,
16- 'any-parent' : { } ,
17- 'direct-children' : { } ,
18- 'any-children' : { } ,
19- } ) ;
13+ const defaultCache = ( ) =>
14+ ( {
15+ self : { } ,
16+ 'direct-parent' : { } ,
17+ 'any-parent' : { } ,
18+ 'direct-children' : { } ,
19+ 'any-children' : { } ,
20+ 'self-or-any-parent' : { } ,
21+ 'self-or-direct-parent' : { } ,
22+ 'self-or-any-children' : { } ,
23+ 'self-or-direct-children' : { } ,
24+ } ) satisfies Cache ;
2025
2126type Cache = {
2227 [ scope in StyleRuleTarget ] : {
@@ -63,22 +68,43 @@ export class TargetNodeResolver {
6368 break ;
6469 }
6570
66- case 'any-parent' :
71+ case 'self-or-direct-parent' : {
72+ const group = findGroupByNodeId ( this . columns , nodeId ) ;
73+ result = group ? [ group . parentId , nodeId ] : [ nodeId ] ;
74+ break ;
75+ }
76+
77+ case 'any-parent' : {
6778 result = traverseUp ( this . columns , nodeId ) ;
6879 break ;
80+ }
81+
82+ case 'self-or-any-parent' : {
83+ result = [ ...traverseUp ( this . columns , nodeId ) , nodeId ] ;
84+ break ;
85+ }
6986
7087 case 'direct-children' : {
7188 const childGroup = findChildGroup ( this . columns , nodeId ) ;
72- result = childGroup ? .nodes ?? [ ] ;
89+ result = childGroup ? childGroup . nodes : [ ] ;
7390 break ;
7491 }
7592
76- case 'any-children' :
93+ case 'self-or-direct-children' : {
94+ const childGroup = findChildGroup ( this . columns , nodeId ) ;
95+ result = childGroup ? [ nodeId , ...childGroup . nodes ] : [ nodeId ] ;
96+ break ;
97+ }
98+
99+ case 'any-children' : {
77100 result = getAllChildren ( this . columns , nodeId ) ;
78101 break ;
102+ }
79103
80- default :
81- result = [ ] ;
104+ case 'self-or-any-children' : {
105+ result = [ nodeId , ...getAllChildren ( this . columns , nodeId ) ] ;
106+ break ;
107+ }
82108 }
83109
84110 this . cacheResult ( nodeId , scope , result ) ;
0 commit comments