@@ -252,9 +252,9 @@ export class EditorComponent implements OnDestroy, OnInit, AfterViewInit {
252
252
253
253
async parseReadalong ( text : string ) : Promise < string | undefined > {
254
254
const parser = new DOMParser ( ) ;
255
+
255
256
const readalong = parser . parseFromString ( text , "text/html" ) ;
256
257
const element = readalong . querySelector ( "read-along" ) ;
257
-
258
258
if ( element === undefined || element === null ) {
259
259
return undefined ;
260
260
}
@@ -263,16 +263,19 @@ export class EditorComponent implements OnDestroy, OnInit, AfterViewInit {
263
263
// Create missing body element
264
264
const body = document . createElement ( "body" ) ;
265
265
body . id = "t0b0" ;
266
- const textNode = element . children [ 0 ] ;
267
- if ( textNode ) {
268
- while ( textNode . hasChildNodes ( ) ) {
266
+ const textNode = element . querySelector ( "text" ) ;
267
+ if ( textNode ?. querySelector ( "body" ) == null ) {
268
+ while ( textNode ? .hasChildNodes ( ) ) {
269
269
// @ts -ignore
270
270
body . appendChild ( textNode . firstChild ) ;
271
271
}
272
- textNode . appendChild ( body ) ;
273
- }
272
+ textNode ? .appendChild ( body ) ;
273
+ } /**/
274
274
const serializer = new XMLSerializer ( ) ;
275
- const xmlString = serializer . serializeToString ( element ) ;
275
+ const xmlString = serializer
276
+ . serializeToString ( element )
277
+ . replace ( "arpabet=" , "ARPABET=" ) ;
278
+ console . log ( xmlString ) ;
276
279
this . editorService . rasControl$ . setValue (
277
280
parser . parseFromString ( xmlString , "text/xml" ) ,
278
281
) ; // re-parse as XML
0 commit comments