File tree Expand file tree Collapse file tree 3 files changed +80
-2
lines changed Expand file tree Collapse file tree 3 files changed +80
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' gitbook ' : patch
3
+ ---
4
+
5
+ Fix expandable block anchore resolution
Original file line number Diff line number Diff line change 1
1
import { describe , expect , it } from 'bun:test' ;
2
2
3
- import { isNodeEmpty } from './document' ;
3
+ import { getBlockTitle , isNodeEmpty } from './document' ;
4
4
5
5
describe ( 'isNodeEmpty' , ( ) => {
6
6
it ( 'should return true for a document with an empty paragraph' , ( ) => {
@@ -54,3 +54,76 @@ describe('isNodeEmpty', () => {
54
54
) . toEqual ( false ) ;
55
55
} ) ;
56
56
} ) ;
57
+
58
+ describe ( '#getBlockTitle' , ( ) => {
59
+ it ( 'should return the title of an expandable block' , ( ) => {
60
+ expect (
61
+ getBlockTitle ( {
62
+ object : 'block' ,
63
+ type : 'expandable' ,
64
+ isVoid : true ,
65
+ data : { } ,
66
+ key : 'OX8znB9VmbgK' ,
67
+ fragments : [
68
+ {
69
+ object : 'fragment' ,
70
+ nodes : [
71
+ {
72
+ object : 'block' ,
73
+ type : 'paragraph' ,
74
+ isVoid : false ,
75
+ data : { } ,
76
+ nodes : [
77
+ {
78
+ object : 'text' ,
79
+ leaves : [
80
+ {
81
+ object : 'leaf' ,
82
+ text : 'Title of expandable block' ,
83
+ marks : [ ] ,
84
+ } ,
85
+ ] ,
86
+ key : '7sZdCBHTw6Si' ,
87
+ } ,
88
+ ] ,
89
+ key : 'msYtjdwNmiAB' ,
90
+ } ,
91
+ ] ,
92
+ key : 'cNhmBygbrP8N' ,
93
+ fragment : 'expandable-title' ,
94
+ type : 'expandable-title' ,
95
+ } ,
96
+ {
97
+ object : 'fragment' ,
98
+ nodes : [
99
+ {
100
+ object : 'block' ,
101
+ type : 'paragraph' ,
102
+ isVoid : false ,
103
+ data : { } ,
104
+ nodes : [
105
+ {
106
+ object : 'text' ,
107
+ leaves : [
108
+ {
109
+ object : 'leaf' ,
110
+ text : 'And content of the expandable' ,
111
+ marks : [ ] ,
112
+ } ,
113
+ ] ,
114
+ key : '0GEghVKyWRBt' ,
115
+ } ,
116
+ ] ,
117
+ key : '9iEwdHdZ5y0S' ,
118
+ } ,
119
+ ] ,
120
+ key : 'newg71i9Ujjl' ,
121
+ fragment : 'expandable-body' ,
122
+ type : 'expandable-body' ,
123
+ } ,
124
+ ] ,
125
+ meta : { id : 'expandable-block' } ,
126
+ } ) ,
127
+ ) . toEqual ( 'Title of expandable block' ) ;
128
+ } ) ;
129
+ } ) ;
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ export function isNodeEmpty(
154
154
export function getBlockTitle ( block : DocumentBlock ) : string {
155
155
switch ( block . type ) {
156
156
case 'expandable' : {
157
- const titleFragment = getNodeFragmentByType ( block , 'title' ) ;
157
+ const titleFragment = getNodeFragmentByType ( block , 'expandable- title' ) ;
158
158
if ( titleFragment ) {
159
159
return getNodeText ( titleFragment ) ;
160
160
}
You can’t perform that action at this time.
0 commit comments