@ones-editor/editor 4.0.2 → 4.0.3-beta.ONES22301663.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -87372,15 +87372,23 @@ ${docStr}
87372
87372
  throw err;
87373
87373
  }
87374
87374
  const domParser = new DOMParser();
87375
- const xml = domParser.parseFromString(svgCode, "image/svg+xml");
87376
- const xmlSvg = xml.firstChild;
87377
- const maxWidth = xmlSvg.style.maxWidth;
87375
+ const html = domParser.parseFromString(svgCode, "text/html");
87376
+ const svg = html.querySelector("svg");
87377
+ if (!(svg instanceof SVGSVGElement)) {
87378
+ throw new Error("Mermaid render result does not contain an SVG root element");
87379
+ }
87380
+ const maxWidth = svg.style.maxWidth;
87378
87381
  if (maxWidth) {
87379
- xmlSvg.setAttribute("width", maxWidth);
87382
+ svg.setAttribute("width", maxWidth);
87380
87383
  }
87381
87384
  const xmlSerializer = new XMLSerializer();
87382
- const xmlSvgStr = xmlSerializer.serializeToString(xmlSvg);
87383
- return xmlSvgStr;
87385
+ const svgCodeForXml = xmlSerializer.serializeToString(svg);
87386
+ const xml = domParser.parseFromString(svgCodeForXml, "image/svg+xml");
87387
+ const xmlSvg = xml.documentElement;
87388
+ if (xml.querySelector("parsererror") || xmlSvg.localName !== "svg" || xmlSvg.namespaceURI !== "http://www.w3.org/2000/svg") {
87389
+ throw new Error("Mermaid render result is not a valid SVG document");
87390
+ }
87391
+ return xmlSerializer.serializeToString(xmlSvg);
87384
87392
  }
87385
87393
  async function mermaidCodeToObjectUrl(editor, code) {
87386
87394
  const svg = await mermaidCodeToSvg(editor, code);
@@ -97203,7 +97211,7 @@ ${JSON.stringify(error2, null, 2)}`);
97203
97211
  }
97204
97212
  }
97205
97213
  });
97206
- editor.version = "4.0.2";
97214
+ editor.version = "4.0.3-beta.ONES22301663.1";
97207
97215
  return editor;
97208
97216
  }
97209
97217
  function isDoc(doc2) {
@@ -97339,7 +97347,7 @@ ${JSON.stringify(error2, null, 2)}`);
97339
97347
  OnesEditorDropTarget.register(editor);
97340
97348
  OnesEditorTocProvider.register(editor);
97341
97349
  OnesEditorExclusiveBlock.register(editor);
97342
- editor.version = "4.0.2";
97350
+ editor.version = "4.0.3-beta.ONES22301663.1";
97343
97351
  return editor;
97344
97352
  } catch (error2) {
97345
97353
  try {
@@ -97482,7 +97490,7 @@ ${JSON.stringify(error2, null, 2)}`);
97482
97490
  }
97483
97491
  }
97484
97492
  });
97485
- editor.version = "4.0.2";
97493
+ editor.version = "4.0.3-beta.ONES22301663.1";
97486
97494
  return editor;
97487
97495
  }
97488
97496
  const emojis$1 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "4.0.2",
3
+ "version": "4.0.3-beta.ONES22301663.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {