@ones-editor/editor 3.1.2 → 3.1.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
@@ -87294,15 +87294,23 @@ ${docStr}
87294
87294
  throw err;
87295
87295
  }
87296
87296
  const domParser = new DOMParser();
87297
- const xml = domParser.parseFromString(svgCode, "image/svg+xml");
87298
- const xmlSvg = xml.firstChild;
87299
- const maxWidth = xmlSvg.style.maxWidth;
87297
+ const html = domParser.parseFromString(svgCode, "text/html");
87298
+ const svg = html.querySelector("svg");
87299
+ if (!(svg instanceof SVGSVGElement)) {
87300
+ throw new Error("Mermaid render result does not contain an SVG root element");
87301
+ }
87302
+ const maxWidth = svg.style.maxWidth;
87300
87303
  if (maxWidth) {
87301
- xmlSvg.setAttribute("width", maxWidth);
87304
+ svg.setAttribute("width", maxWidth);
87302
87305
  }
87303
87306
  const xmlSerializer = new XMLSerializer();
87304
- const xmlSvgStr = xmlSerializer.serializeToString(xmlSvg);
87305
- return xmlSvgStr;
87307
+ const svgCodeForXml = xmlSerializer.serializeToString(svg);
87308
+ const xml = domParser.parseFromString(svgCodeForXml, "image/svg+xml");
87309
+ const xmlSvg = xml.documentElement;
87310
+ if (xml.querySelector("parsererror") || xmlSvg.localName !== "svg" || xmlSvg.namespaceURI !== "http://www.w3.org/2000/svg") {
87311
+ throw new Error("Mermaid render result is not a valid SVG document");
87312
+ }
87313
+ return xmlSerializer.serializeToString(xmlSvg);
87306
87314
  }
87307
87315
  async function mermaidCodeToObjectUrl(editor, code) {
87308
87316
  const svg = await mermaidCodeToSvg(editor, code);
@@ -97100,7 +97108,7 @@ ${JSON.stringify(error2, null, 2)}`);
97100
97108
  }
97101
97109
  }
97102
97110
  });
97103
- editor.version = "3.1.2";
97111
+ editor.version = "3.1.3-beta.ONES22301663.1";
97104
97112
  return editor;
97105
97113
  }
97106
97114
  function isDoc(doc2) {
@@ -97241,7 +97249,7 @@ ${JSON.stringify(error2, null, 2)}`);
97241
97249
  OnesEditorDropTarget.register(editor);
97242
97250
  OnesEditorTocProvider.register(editor);
97243
97251
  OnesEditorExclusiveBlock.register(editor);
97244
- editor.version = "3.1.2";
97252
+ editor.version = "3.1.3-beta.ONES22301663.1";
97245
97253
  return editor;
97246
97254
  } catch (error2) {
97247
97255
  if (editorForCleanup) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "3.1.2",
3
+ "version": "3.1.3-beta.ONES22301663.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {