@@ -140,7 +140,7 @@ function mdastToDelta(tree) {
140140 for ( const node of tree . children ) {
141141 traverseMdastNode ( node , delta ) ;
142142 }
143-
143+
144144 return delta ;
145145}
146146
@@ -152,90 +152,93 @@ function mdastToDelta(tree) {
152152 */
153153function traverseMdastNode ( node , delta , attributes = { } ) {
154154 if ( ! node ) return ;
155-
155+
156156 switch ( node . type ) {
157- case ' root' :
157+ case " root" :
158158 for ( const child of node . children || [ ] ) {
159159 traverseMdastNode ( child , delta ) ;
160160 }
161161 break ;
162-
163- case ' paragraph' :
162+
163+ case " paragraph" :
164164 for ( const child of node . children || [ ] ) {
165165 traverseMdastNode ( child , delta , attributes ) ;
166166 }
167- delta . ops . push ( { insert : '\n' } ) ;
167+ delta . ops . push ( { insert : "\n" } ) ;
168168 break ;
169-
170- case ' heading' :
169+
170+ case " heading" :
171171 for ( const child of node . children || [ ] ) {
172172 traverseMdastNode ( child , delta , { header : node . depth } ) ;
173173 }
174- delta . ops . push ( { insert : '\n' , attributes : { header : node . depth } } ) ;
174+ delta . ops . push ( { insert : "\n" , attributes : { header : node . depth } } ) ;
175175 break ;
176-
177- case ' text' :
178- delta . ops . push ( { insert : node . value || '' , attributes } ) ;
176+
177+ case " text" :
178+ delta . ops . push ( { insert : node . value || "" , attributes } ) ;
179179 break ;
180-
181- case ' strong' :
180+
181+ case " strong" :
182182 for ( const child of node . children || [ ] ) {
183183 traverseMdastNode ( child , delta , { ...attributes , bold : true } ) ;
184184 }
185185 break ;
186-
187- case ' emphasis' :
186+
187+ case " emphasis" :
188188 for ( const child of node . children || [ ] ) {
189189 traverseMdastNode ( child , delta , { ...attributes , italic : true } ) ;
190190 }
191191 break ;
192-
193- case ' link' :
192+
193+ case " link" :
194194 for ( const child of node . children || [ ] ) {
195195 traverseMdastNode ( child , delta , { ...attributes , link : node . url } ) ;
196196 }
197197 break ;
198-
199- case ' image' :
200- delta . ops . push ( {
198+
199+ case " image" :
200+ delta . ops . push ( {
201201 insert : { image : node . url } ,
202- attributes : { alt : node . alt || '' }
202+ attributes : { alt : node . alt || "" } ,
203203 } ) ;
204204 break ;
205-
206- case ' list' :
205+
206+ case " list" :
207207 for ( const child of node . children || [ ] ) {
208- traverseMdastNode ( child , delta , {
209- ...attributes ,
210- list : node . ordered ? ' ordered' : ' bullet'
208+ traverseMdastNode ( child , delta , {
209+ ...attributes ,
210+ list : node . ordered ? " ordered" : " bullet" ,
211211 } ) ;
212212 }
213213 break ;
214-
215- case ' listItem' :
214+
215+ case " listItem" :
216216 for ( const child of node . children || [ ] ) {
217217 traverseMdastNode ( child , delta , attributes ) ;
218218 }
219219 break ;
220-
221- case ' blockquote' :
220+
221+ case " blockquote" :
222222 for ( const child of node . children || [ ] ) {
223223 traverseMdastNode ( child , delta , { ...attributes , blockquote : true } ) ;
224224 }
225225 break ;
226-
227- case 'code' :
228- delta . ops . push ( {
229- insert : node . value || '' ,
230- attributes : { 'code-block' : node . lang || 'plain' }
226+
227+ case "code" :
228+ delta . ops . push ( {
229+ insert : node . value || "" ,
230+ attributes : { "code-block" : node . lang || "plain" } ,
231+ } ) ;
232+ delta . ops . push ( {
233+ insert : "\n" ,
234+ attributes : { "code-block" : node . lang || "plain" } ,
231235 } ) ;
232- delta . ops . push ( { insert : '\n' , attributes : { 'code-block' : node . lang || 'plain' } } ) ;
233236 break ;
234-
235- case ' inlineCode' :
236- delta . ops . push ( { insert : node . value || '' , attributes : { code : true } } ) ;
237+
238+ case " inlineCode" :
239+ delta . ops . push ( { insert : node . value || "" , attributes : { code : true } } ) ;
237240 break ;
238-
241+
239242 default :
240243 if ( node . children ) {
241244 for ( const child of node . children ) {
0 commit comments