Skip to content

Commit 9b9e74a

Browse files
committed
fix: cannot download other formats
1 parent e752637 commit 9b9e74a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

packages/studio-web/src/app/editor/editor.component.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ export class EditorComponent implements OnDestroy, OnInit, AfterViewInit {
252252

253253
async parseReadalong(text: string): Promise<string | undefined> {
254254
const parser = new DOMParser();
255+
255256
const readalong = parser.parseFromString(text, "text/html");
256257
const element = readalong.querySelector("read-along");
257-
258258
if (element === undefined || element === null) {
259259
return undefined;
260260
}
@@ -263,16 +263,19 @@ export class EditorComponent implements OnDestroy, OnInit, AfterViewInit {
263263
// Create missing body element
264264
const body = document.createElement("body");
265265
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()) {
269269
// @ts-ignore
270270
body.appendChild(textNode.firstChild);
271271
}
272-
textNode.appendChild(body);
273-
}
272+
textNode?.appendChild(body);
273+
} /**/
274274
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);
276279
this.editorService.rasControl$.setValue(
277280
parser.parseFromString(xmlString, "text/xml"),
278281
); // re-parse as XML

0 commit comments

Comments
 (0)