@harbour-enterprises/superdoc 1.17.0-next.24 → 1.17.0-next.27

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.
Files changed (24) hide show
  1. package/dist/chunks/{SuperConverter-Dpef8fg5.es.js → SuperConverter-B_fGJA0T.es.js} +63 -5
  2. package/dist/chunks/{SuperConverter-e9yseZkD.cjs → SuperConverter-EZm4rCaZ.cjs} +63 -5
  3. package/dist/chunks/{src-DDnXuxKk.es.js → src-BR5TDS4t.es.js} +147 -51
  4. package/dist/chunks/{src-CFQV4CPU.cjs → src-CC43Q5qq.cjs} +147 -51
  5. package/dist/super-editor/converter.cjs +1 -1
  6. package/dist/super-editor/converter.es.js +1 -1
  7. package/dist/super-editor/src/core/Editor.d.ts.map +1 -1
  8. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.d.ts +1 -1
  9. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.d.ts.map +1 -1
  10. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/vector-shape-helpers.d.ts +15 -0
  11. package/dist/super-editor/src/core/super-converter/v3/handlers/wp/helpers/vector-shape-helpers.d.ts.map +1 -1
  12. package/dist/super-editor/src/extensions/collaboration/collaboration-helpers.d.ts.map +1 -1
  13. package/dist/super-editor/src/extensions/collaboration/collaboration.d.ts +1 -0
  14. package/dist/super-editor/src/extensions/collaboration/collaboration.d.ts.map +1 -1
  15. package/dist/super-editor/src/extensions/run/wrapTextInRunsPlugin.d.ts.map +1 -1
  16. package/dist/super-editor/src/extensions/shape-group/ShapeGroupView.d.ts.map +1 -1
  17. package/dist/super-editor/src/extensions/vector-shape/vector-shape.d.ts.map +1 -1
  18. package/dist/super-editor.cjs +2 -2
  19. package/dist/super-editor.es.js +2 -2
  20. package/dist/superdoc.cjs +3 -3
  21. package/dist/superdoc.es.js +3 -3
  22. package/dist/superdoc.umd.js +210 -56
  23. package/dist/superdoc.umd.js.map +1 -1
  24. package/package.json +1 -1
@@ -10901,6 +10901,54 @@ function extractFillColor(spPr, style) {
10901
10901
  }
10902
10902
  return null;
10903
10903
  }
10904
+ function extractCustomGeometry(spPr) {
10905
+ const custGeom = spPr?.elements?.find((el) => el.name === "a:custGeom");
10906
+ if (!custGeom) return null;
10907
+ const pathLst = custGeom.elements?.find((el) => el.name === "a:pathLst");
10908
+ if (!pathLst?.elements) return null;
10909
+ const paths = pathLst.elements.filter((el) => el.name === "a:path").map((pathEl) => {
10910
+ const w = parseInt(pathEl.attributes?.["w"] || "0", 10);
10911
+ const h = parseInt(pathEl.attributes?.["h"] || "0", 10);
10912
+ return {
10913
+ d: convertDrawingMLPathToSvg(pathEl),
10914
+ w,
10915
+ h
10916
+ };
10917
+ }).filter((p) => p.d);
10918
+ if (paths.length === 0) return null;
10919
+ return { paths };
10920
+ }
10921
+ function convertDrawingMLPathToSvg(pathEl) {
10922
+ if (!pathEl?.elements) return "";
10923
+ const parts = [];
10924
+ for (const cmd of pathEl.elements) switch (cmd.name) {
10925
+ case "a:moveTo": {
10926
+ const pt = cmd.elements?.find((el) => el.name === "a:pt");
10927
+ if (pt) parts.push(`M ${pt.attributes?.["x"] || 0} ${pt.attributes?.["y"] || 0}`);
10928
+ break;
10929
+ }
10930
+ case "a:lnTo": {
10931
+ const pt = cmd.elements?.find((el) => el.name === "a:pt");
10932
+ if (pt) parts.push(`L ${pt.attributes?.["x"] || 0} ${pt.attributes?.["y"] || 0}`);
10933
+ break;
10934
+ }
10935
+ case "a:cubicBezTo": {
10936
+ const pts = cmd.elements?.filter((el) => el.name === "a:pt") || [];
10937
+ if (pts.length === 3) parts.push(`C ${pts[0].attributes?.["x"] || 0} ${pts[0].attributes?.["y"] || 0} ${pts[1].attributes?.["x"] || 0} ${pts[1].attributes?.["y"] || 0} ${pts[2].attributes?.["x"] || 0} ${pts[2].attributes?.["y"] || 0}`);
10938
+ break;
10939
+ }
10940
+ case "a:quadBezTo": {
10941
+ const pts = cmd.elements?.filter((el) => el.name === "a:pt") || [];
10942
+ if (pts.length === 2) parts.push(`Q ${pts[0].attributes?.["x"] || 0} ${pts[0].attributes?.["y"] || 0} ${pts[1].attributes?.["x"] || 0} ${pts[1].attributes?.["y"] || 0}`);
10943
+ break;
10944
+ }
10945
+ case "a:close":
10946
+ parts.push("Z");
10947
+ break;
10948
+ default: break;
10949
+ }
10950
+ return parts.join(" ");
10951
+ }
10904
10952
  function extractGradientFill(gradFill) {
10905
10953
  const gradient = {
10906
10954
  type: "gradient",
@@ -16734,7 +16782,10 @@ function handleImageNode(node, params, isAnchor) {
16734
16782
  var handleShapeDrawing = (params, node, graphicData, size, padding, marginOffset, anchorData, wrap$1, isAnchor, isHidden) => {
16735
16783
  const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
16736
16784
  const textBoxContent = wsp.elements.find((el) => el.name === "wps:txbx")?.elements?.find((el) => el.name === "w:txbxContent");
16737
- if ((wsp.elements.find((el) => el.name === "wps:spPr")?.elements.find((el) => el.name === "a:prstGeom"))?.attributes["prst"]) {
16785
+ const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
16786
+ const shapeType = (spPr?.elements.find((el) => el.name === "a:prstGeom"))?.attributes["prst"];
16787
+ const custGeom = !shapeType ? extractCustomGeometry(spPr) : null;
16788
+ if (shapeType || custGeom) {
16738
16789
  const result = getVectorShape({
16739
16790
  params,
16740
16791
  node,
@@ -16743,7 +16794,8 @@ var handleShapeDrawing = (params, node, graphicData, size, padding, marginOffset
16743
16794
  marginOffset,
16744
16795
  anchorData,
16745
16796
  wrap: wrap$1,
16746
- isAnchor
16797
+ isAnchor,
16798
+ customGeometry: custGeom
16747
16799
  });
16748
16800
  if (result?.attrs && isHidden) result.attrs.hidden = true;
16749
16801
  if (result) return result;
@@ -16812,6 +16864,7 @@ var handleShapeGroup = (params, node, graphicData, size, padding, marginOffset,
16812
16864
  const spPr = wsp.elements?.find((el) => el.name === "wps:spPr");
16813
16865
  if (!spPr) return null;
16814
16866
  const shapeKind = (spPr.elements?.find((el) => el.name === "a:prstGeom"))?.attributes?.["prst"];
16867
+ const customGeom = !shapeKind ? extractCustomGeometry(spPr) : null;
16815
16868
  const shapeXfrm = spPr.elements?.find((el) => el.name === "a:xfrm");
16816
16869
  const shapeOff = shapeXfrm?.elements?.find((el) => el.name === "a:off");
16817
16870
  const shapeExt = shapeXfrm?.elements?.find((el) => el.name === "a:ext");
@@ -16855,6 +16908,7 @@ var handleShapeGroup = (params, node, graphicData, size, padding, marginOffset,
16855
16908
  shapeType: "vectorShape",
16856
16909
  attrs: {
16857
16910
  kind: shapeKind,
16911
+ customGeometry: customGeom || void 0,
16858
16912
  x,
16859
16913
  y,
16860
16914
  width,
@@ -17081,7 +17135,7 @@ var buildShapePlaceholder = (node, size, padding, marginOffset, shapeType) => {
17081
17135
  attrs
17082
17136
  };
17083
17137
  };
17084
- function getVectorShape({ params, node, graphicData, size, marginOffset, anchorData, wrap: wrap$1, isAnchor }) {
17138
+ function getVectorShape({ params, node, graphicData, size, marginOffset, anchorData, wrap: wrap$1, isAnchor, customGeometry }) {
17085
17139
  const schemaAttrs = {};
17086
17140
  const drawingNode = params.nodes?.[0];
17087
17141
  if (drawingNode?.name === "w:drawing") schemaAttrs.drawingContent = drawingNode;
@@ -17090,8 +17144,12 @@ function getVectorShape({ params, node, graphicData, size, marginOffset, anchorD
17090
17144
  const spPr = wsp.elements?.find((el) => el.name === "wps:spPr");
17091
17145
  if (!spPr) return null;
17092
17146
  const shapeKind = (spPr.elements?.find((el) => el.name === "a:prstGeom"))?.attributes?.["prst"];
17093
- if (!shapeKind) console.warn("Shape kind not found");
17094
17147
  schemaAttrs.kind = shapeKind;
17148
+ if (customGeometry) schemaAttrs.customGeometry = customGeometry;
17149
+ else if (!shapeKind) {
17150
+ const extracted = extractCustomGeometry(spPr);
17151
+ if (extracted) schemaAttrs.customGeometry = extracted;
17152
+ }
17095
17153
  const width = size?.width ?? DEFAULT_SHAPE_WIDTH;
17096
17154
  const height = size?.height ?? DEFAULT_SHAPE_HEIGHT;
17097
17155
  const xfrm = spPr.elements?.find((el) => el.name === "a:xfrm");
@@ -37099,7 +37157,7 @@ var SuperConverter = class SuperConverter {
37099
37157
  static getStoredSuperdocVersion(docx) {
37100
37158
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
37101
37159
  }
37102
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.17.0-next.24") {
37160
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.17.0-next.27") {
37103
37161
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
37104
37162
  }
37105
37163
  static generateWordTimestamp() {
@@ -10912,6 +10912,54 @@ function extractFillColor(spPr, style) {
10912
10912
  }
10913
10913
  return null;
10914
10914
  }
10915
+ function extractCustomGeometry(spPr) {
10916
+ const custGeom = spPr?.elements?.find((el) => el.name === "a:custGeom");
10917
+ if (!custGeom) return null;
10918
+ const pathLst = custGeom.elements?.find((el) => el.name === "a:pathLst");
10919
+ if (!pathLst?.elements) return null;
10920
+ const paths = pathLst.elements.filter((el) => el.name === "a:path").map((pathEl) => {
10921
+ const w = parseInt(pathEl.attributes?.["w"] || "0", 10);
10922
+ const h = parseInt(pathEl.attributes?.["h"] || "0", 10);
10923
+ return {
10924
+ d: convertDrawingMLPathToSvg(pathEl),
10925
+ w,
10926
+ h
10927
+ };
10928
+ }).filter((p) => p.d);
10929
+ if (paths.length === 0) return null;
10930
+ return { paths };
10931
+ }
10932
+ function convertDrawingMLPathToSvg(pathEl) {
10933
+ if (!pathEl?.elements) return "";
10934
+ const parts = [];
10935
+ for (const cmd of pathEl.elements) switch (cmd.name) {
10936
+ case "a:moveTo": {
10937
+ const pt = cmd.elements?.find((el) => el.name === "a:pt");
10938
+ if (pt) parts.push(`M ${pt.attributes?.["x"] || 0} ${pt.attributes?.["y"] || 0}`);
10939
+ break;
10940
+ }
10941
+ case "a:lnTo": {
10942
+ const pt = cmd.elements?.find((el) => el.name === "a:pt");
10943
+ if (pt) parts.push(`L ${pt.attributes?.["x"] || 0} ${pt.attributes?.["y"] || 0}`);
10944
+ break;
10945
+ }
10946
+ case "a:cubicBezTo": {
10947
+ const pts = cmd.elements?.filter((el) => el.name === "a:pt") || [];
10948
+ if (pts.length === 3) parts.push(`C ${pts[0].attributes?.["x"] || 0} ${pts[0].attributes?.["y"] || 0} ${pts[1].attributes?.["x"] || 0} ${pts[1].attributes?.["y"] || 0} ${pts[2].attributes?.["x"] || 0} ${pts[2].attributes?.["y"] || 0}`);
10949
+ break;
10950
+ }
10951
+ case "a:quadBezTo": {
10952
+ const pts = cmd.elements?.filter((el) => el.name === "a:pt") || [];
10953
+ if (pts.length === 2) parts.push(`Q ${pts[0].attributes?.["x"] || 0} ${pts[0].attributes?.["y"] || 0} ${pts[1].attributes?.["x"] || 0} ${pts[1].attributes?.["y"] || 0}`);
10954
+ break;
10955
+ }
10956
+ case "a:close":
10957
+ parts.push("Z");
10958
+ break;
10959
+ default: break;
10960
+ }
10961
+ return parts.join(" ");
10962
+ }
10915
10963
  function extractGradientFill(gradFill) {
10916
10964
  const gradient = {
10917
10965
  type: "gradient",
@@ -16745,7 +16793,10 @@ function handleImageNode(node, params, isAnchor) {
16745
16793
  var handleShapeDrawing = (params, node, graphicData, size, padding, marginOffset, anchorData, wrap$1, isAnchor, isHidden) => {
16746
16794
  const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
16747
16795
  const textBoxContent = wsp.elements.find((el) => el.name === "wps:txbx")?.elements?.find((el) => el.name === "w:txbxContent");
16748
- if ((wsp.elements.find((el) => el.name === "wps:spPr")?.elements.find((el) => el.name === "a:prstGeom"))?.attributes["prst"]) {
16796
+ const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
16797
+ const shapeType = (spPr?.elements.find((el) => el.name === "a:prstGeom"))?.attributes["prst"];
16798
+ const custGeom = !shapeType ? extractCustomGeometry(spPr) : null;
16799
+ if (shapeType || custGeom) {
16749
16800
  const result = getVectorShape({
16750
16801
  params,
16751
16802
  node,
@@ -16754,7 +16805,8 @@ var handleShapeDrawing = (params, node, graphicData, size, padding, marginOffset
16754
16805
  marginOffset,
16755
16806
  anchorData,
16756
16807
  wrap: wrap$1,
16757
- isAnchor
16808
+ isAnchor,
16809
+ customGeometry: custGeom
16758
16810
  });
16759
16811
  if (result?.attrs && isHidden) result.attrs.hidden = true;
16760
16812
  if (result) return result;
@@ -16823,6 +16875,7 @@ var handleShapeGroup = (params, node, graphicData, size, padding, marginOffset,
16823
16875
  const spPr = wsp.elements?.find((el) => el.name === "wps:spPr");
16824
16876
  if (!spPr) return null;
16825
16877
  const shapeKind = (spPr.elements?.find((el) => el.name === "a:prstGeom"))?.attributes?.["prst"];
16878
+ const customGeom = !shapeKind ? extractCustomGeometry(spPr) : null;
16826
16879
  const shapeXfrm = spPr.elements?.find((el) => el.name === "a:xfrm");
16827
16880
  const shapeOff = shapeXfrm?.elements?.find((el) => el.name === "a:off");
16828
16881
  const shapeExt = shapeXfrm?.elements?.find((el) => el.name === "a:ext");
@@ -16866,6 +16919,7 @@ var handleShapeGroup = (params, node, graphicData, size, padding, marginOffset,
16866
16919
  shapeType: "vectorShape",
16867
16920
  attrs: {
16868
16921
  kind: shapeKind,
16922
+ customGeometry: customGeom || void 0,
16869
16923
  x,
16870
16924
  y,
16871
16925
  width,
@@ -17092,7 +17146,7 @@ var buildShapePlaceholder = (node, size, padding, marginOffset, shapeType) => {
17092
17146
  attrs
17093
17147
  };
17094
17148
  };
17095
- function getVectorShape({ params, node, graphicData, size, marginOffset, anchorData, wrap: wrap$1, isAnchor }) {
17149
+ function getVectorShape({ params, node, graphicData, size, marginOffset, anchorData, wrap: wrap$1, isAnchor, customGeometry }) {
17096
17150
  const schemaAttrs = {};
17097
17151
  const drawingNode = params.nodes?.[0];
17098
17152
  if (drawingNode?.name === "w:drawing") schemaAttrs.drawingContent = drawingNode;
@@ -17101,8 +17155,12 @@ function getVectorShape({ params, node, graphicData, size, marginOffset, anchorD
17101
17155
  const spPr = wsp.elements?.find((el) => el.name === "wps:spPr");
17102
17156
  if (!spPr) return null;
17103
17157
  const shapeKind = (spPr.elements?.find((el) => el.name === "a:prstGeom"))?.attributes?.["prst"];
17104
- if (!shapeKind) console.warn("Shape kind not found");
17105
17158
  schemaAttrs.kind = shapeKind;
17159
+ if (customGeometry) schemaAttrs.customGeometry = customGeometry;
17160
+ else if (!shapeKind) {
17161
+ const extracted = extractCustomGeometry(spPr);
17162
+ if (extracted) schemaAttrs.customGeometry = extracted;
17163
+ }
17106
17164
  const width = size?.width ?? DEFAULT_SHAPE_WIDTH;
17107
17165
  const height = size?.height ?? DEFAULT_SHAPE_HEIGHT;
17108
17166
  const xfrm = spPr.elements?.find((el) => el.name === "a:xfrm");
@@ -37119,7 +37177,7 @@ var SuperConverter = class SuperConverter {
37119
37177
  static getStoredSuperdocVersion(docx) {
37120
37178
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
37121
37179
  }
37122
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.17.0-next.24") {
37180
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.17.0-next.27") {
37123
37181
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
37124
37182
  }
37125
37183
  static generateWordTimestamp() {
@@ -1,5 +1,5 @@
1
1
  import { a as __toCommonJS, n as __esmMin, r as __export, t as __commonJSMin } from "./rolldown-runtime-B2q5OVn9.es.js";
2
- import { $ as Selection, A as findChildren$1, At as DOMSerializer, B as findParentNode, C as calculateResolvedParagraphProperties, Ct as resolveTableCellProperties, D as CommandService, Dt as TrackInsertMarkName, E as generateOrderedListIndex, Et as TrackFormatMarkName, F as isNodeActive, Ft as minMax, G as cleanSchemaItem, H as defaultBlockAt$1, I as getSchemaTypeNameByName, It as callOrGet, J as AllSelection, K as getSchemaTypeByName, L as isMarkActive, Lt as getExtensionConfigField, M as findMark, Mt as Mark$1, N as getMarksFromSelection, Nt as Schema$1, O as isInTable, Ot as carbonCopy, P as isActive, Pt as Slice, Q as PluginKey, R as getMarkRange, S as isList, St as resolveRunProperties, T as docxNumberingHelpers, Tt as TrackDeleteMarkName, U as getMarkType, V as findParentNodeClosestToPos, W as getNodeType, X as NodeSelection, Y as EditorState, Z as Plugin, _ as inputRulesPlugin, _t as encodeCSSFromPPr, a as translator, at as ReplaceAroundStep$1, b as changeListLevel, bt as resolveDocxFontFamily, c as updateDOMAttributes, ct as canJoin, d as markdownToPmFragment, dt as joinPoint, et as SelectionRange, f as createDocFromHTML, ft as liftTarget, g as htmlHandler, gt as decodeRPrFromMarks, h as handleClipboardPaste, ht as generateRandomSigned32BitIntStrId, it as RemoveMarkStep, j as getActiveFormatting, jt as Fragment$1, k as posToDOMRect, kt as DOMParser$1, l as processContent, lt as canSplit, m as InputRule, mt as generateDocxRandomId, n as kebabCase$1, nt as AddMarkStep, o as _getReferencedTableStyles, ot as ReplaceStep, p as createCellBorders, pt as replaceStep$1, q as createDocument, r as insertNewRelationship, rt as Mapping, s as helpers_exports, st as Transform, t as SuperConverter, tt as TextSelection$1, u as createDocFromMarkdown, ut as dropPoint, v as unflattenListsInHtml, vt as encodeCSSFromRPr, w as getResolvedParagraphProperties, wt as getUnderlineCssString, x as updateNumberingProperties, xt as resolveParagraphProperties, y as ListHelpers, yt as encodeMarksFromRPr, z as isTextSelection } from "./SuperConverter-Dpef8fg5.es.js";
2
+ import { $ as Selection, A as findChildren$1, At as DOMSerializer, B as findParentNode, C as calculateResolvedParagraphProperties, Ct as resolveTableCellProperties, D as CommandService, Dt as TrackInsertMarkName, E as generateOrderedListIndex, Et as TrackFormatMarkName, F as isNodeActive, Ft as minMax, G as cleanSchemaItem, H as defaultBlockAt$1, I as getSchemaTypeNameByName, It as callOrGet, J as AllSelection, K as getSchemaTypeByName, L as isMarkActive, Lt as getExtensionConfigField, M as findMark, Mt as Mark$1, N as getMarksFromSelection, Nt as Schema$1, O as isInTable, Ot as carbonCopy, P as isActive, Pt as Slice, Q as PluginKey, R as getMarkRange, S as isList, St as resolveRunProperties, T as docxNumberingHelpers, Tt as TrackDeleteMarkName, U as getMarkType, V as findParentNodeClosestToPos, W as getNodeType, X as NodeSelection, Y as EditorState, Z as Plugin, _ as inputRulesPlugin, _t as encodeCSSFromPPr, a as translator, at as ReplaceAroundStep$1, b as changeListLevel, bt as resolveDocxFontFamily, c as updateDOMAttributes, ct as canJoin, d as markdownToPmFragment, dt as joinPoint, et as SelectionRange, f as createDocFromHTML, ft as liftTarget, g as htmlHandler, gt as decodeRPrFromMarks, h as handleClipboardPaste, ht as generateRandomSigned32BitIntStrId, it as RemoveMarkStep, j as getActiveFormatting, jt as Fragment$1, k as posToDOMRect, kt as DOMParser$1, l as processContent, lt as canSplit, m as InputRule, mt as generateDocxRandomId, n as kebabCase$1, nt as AddMarkStep, o as _getReferencedTableStyles, ot as ReplaceStep, p as createCellBorders, pt as replaceStep$1, q as createDocument, r as insertNewRelationship, rt as Mapping, s as helpers_exports, st as Transform, t as SuperConverter, tt as TextSelection$1, u as createDocFromMarkdown, ut as dropPoint, v as unflattenListsInHtml, vt as encodeCSSFromRPr, w as getResolvedParagraphProperties, wt as getUnderlineCssString, x as updateNumberingProperties, xt as resolveParagraphProperties, y as ListHelpers, yt as encodeMarksFromRPr, z as isTextSelection } from "./SuperConverter-B_fGJA0T.es.js";
3
3
  import { a as init_dist$2, i as global, n as init_dist, o as Buffer$3, r as process$1, s as init_dist$1 } from "./jszip-ChlR43oI.es.js";
4
4
  import { t as v4_default } from "./uuid-2IzDu5nl.es.js";
5
5
  import { A as ptToTwips, D as pixelsToTwips, F as twipsToInches, I as twipsToLines, L as twipsToPixels, S as linesToTwips, b as inchesToTwips, c as convertSizeToCSS, j as resolveOpcTargetPath, m as getArrayBufferFromUrl, t as COMMENT_FILE_BASENAMES, v as halfPointToPoints, y as inchesToPixels } from "./constants-Dw0kAsLd.es.js";
@@ -260,7 +260,7 @@ var v_click_outside_default = {
260
260
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
261
261
  function getSuperdocVersion() {
262
262
  try {
263
- return "1.17.0-next.24";
263
+ return "1.17.0-next.27";
264
264
  } catch {
265
265
  return "unknown";
266
266
  }
@@ -19443,11 +19443,27 @@ const AnnotatorHelpers = {
19443
19443
  annotateHeadersAndFooters,
19444
19444
  getAllHeaderFooterEditors
19445
19445
  };
19446
- const updateYdocDocxData = async (editor, ydoc) => {
19446
+ var inFlightUpdates = /* @__PURE__ */ new WeakMap();
19447
+ const updateYdocDocxData = (editor, ydoc) => {
19448
+ ydoc = ydoc || editor?.options?.ydoc;
19449
+ if (!ydoc || ydoc.isDestroyed) return Promise.resolve();
19450
+ if (!editor || editor.isDestroyed) return Promise.resolve();
19451
+ let ydocMap = inFlightUpdates.get(editor);
19452
+ if (!ydocMap) {
19453
+ ydocMap = /* @__PURE__ */ new WeakMap();
19454
+ inFlightUpdates.set(editor, ydocMap);
19455
+ }
19456
+ const existing = ydocMap.get(ydoc);
19457
+ if (existing) return existing;
19458
+ const promise = _doUpdateYdocDocxData(editor, ydoc).finally(() => {
19459
+ const map$2 = inFlightUpdates.get(editor);
19460
+ if (map$2 && map$2.get(ydoc) === promise) map$2.delete(ydoc);
19461
+ });
19462
+ ydocMap.set(ydoc, promise);
19463
+ return promise;
19464
+ };
19465
+ var _doUpdateYdocDocxData = async (editor, ydoc) => {
19447
19466
  try {
19448
- ydoc = ydoc || editor?.options?.ydoc;
19449
- if (!ydoc || ydoc.isDestroyed) return;
19450
- if (!editor || editor.isDestroyed) return;
19451
19467
  const metaMap = ydoc.getMap("meta");
19452
19468
  const docxValue = metaMap.get("docx");
19453
19469
  let docx = [];
@@ -19633,10 +19649,16 @@ var checkDocxChanged = (transaction) => {
19633
19649
  for (const [, value] of transaction.changed.entries()) if (value instanceof Set && value.has("docx")) return true;
19634
19650
  return false;
19635
19651
  };
19652
+ var debouncedDocxUpdateByEditor = /* @__PURE__ */ new WeakMap();
19653
+ const cancelDebouncedDocxUpdate = (editor) => {
19654
+ const cancel = debouncedDocxUpdateByEditor.get(editor);
19655
+ if (cancel) cancel();
19656
+ };
19636
19657
  var initDocumentListener = ({ ydoc, editor }) => {
19637
19658
  const debouncedUpdate = debounce$2((editor$1) => {
19638
19659
  updateYdocDocxData(editor$1);
19639
19660
  }, 3e4, { maxWait: 6e4 });
19661
+ debouncedDocxUpdateByEditor.set(editor, () => debouncedUpdate.cancel());
19640
19662
  const afterTransactionHandler = (transaction) => {
19641
19663
  const { local } = transaction;
19642
19664
  if (!checkDocxChanged(transaction) && transaction.changed?.size && local) debouncedUpdate(editor);
@@ -19645,6 +19667,7 @@ var initDocumentListener = ({ ydoc, editor }) => {
19645
19667
  return () => {
19646
19668
  ydoc.off("afterTransaction", afterTransactionHandler);
19647
19669
  debouncedUpdate.cancel();
19670
+ debouncedDocxUpdateByEditor.delete(editor);
19648
19671
  };
19649
19672
  };
19650
19673
  var debounce$2 = (fn, wait, { maxWait } = {}) => {
@@ -20756,7 +20779,7 @@ const canUseDOM = () => {
20756
20779
  return false;
20757
20780
  }
20758
20781
  };
20759
- var summaryVersion = "1.17.0-next.24";
20782
+ var summaryVersion = "1.17.0-next.27";
20760
20783
  var nodeKeys = [
20761
20784
  "group",
20762
20785
  "content",
@@ -35471,7 +35494,7 @@ var Editor = class Editor extends EventEmitter$1 {
35471
35494
  return migrations.length > 0;
35472
35495
  }
35473
35496
  processCollaborationMigrations() {
35474
- console.debug("[checkVersionMigrations] Current editor version", "1.17.0-next.24");
35497
+ console.debug("[checkVersionMigrations] Current editor version", "1.17.0-next.27");
35475
35498
  if (!this.options.ydoc) return;
35476
35499
  let docVersion = this.options.ydoc.getMap("meta").get("version");
35477
35500
  if (!docVersion) docVersion = "initial";
@@ -35505,7 +35528,8 @@ var Editor = class Editor extends EventEmitter$1 {
35505
35528
  this.#initMedia();
35506
35529
  this.initDefaultStyles();
35507
35530
  if (this.options.ydoc && this.options.collaborationProvider) {
35508
- updateYdocDocxData(this, this.options.ydoc);
35531
+ cancelDebouncedDocxUpdate(this);
35532
+ await updateYdocDocxData(this, this.options.ydoc);
35509
35533
  this.initializeCollaborationData();
35510
35534
  } else this.#insertNewFileData();
35511
35535
  if (!this.options.ydoc) this.#initComments();
@@ -43864,7 +43888,8 @@ async function measureDrawingBlock(block, constraints) {
43864
43888
  const rotatedBounds = calculateRotatedBounds(geometry);
43865
43889
  const naturalWidth = Math.max(1, rotatedBounds.width);
43866
43890
  const naturalHeight = Math.max(1, rotatedBounds.height);
43867
- const maxWidth = fullWidthMax ?? (constraints.maxWidth > 0 ? constraints.maxWidth : naturalWidth);
43891
+ const isFloating = block.wrap?.type === "None";
43892
+ const maxWidth = fullWidthMax ?? (constraints.maxWidth > 0 && !isFloating ? constraints.maxWidth : naturalWidth);
43868
43893
  const maxHeight = block.anchor?.isAnchored && (typeof block.anchor?.offsetV === "number" && block.anchor.offsetV < 0 || typeof block.margin?.top === "number" && block.margin.top < 0) || !constraints.maxHeight || constraints.maxHeight <= 0 ? Infinity : constraints.maxHeight;
43869
43894
  const widthScale = maxWidth / naturalWidth;
43870
43895
  const heightScale = maxHeight / naturalHeight;
@@ -51306,9 +51331,11 @@ var DomPainter = class DomPainter {
51306
51331
  contentContainer.style.top = `${offsetY}px`;
51307
51332
  contentContainer.style.width = `${innerWidth}px`;
51308
51333
  contentContainer.style.height = `${innerHeight$1}px`;
51309
- const svgMarkup = block.shapeKind ? this.tryCreatePresetSvg(block, innerWidth, innerHeight$1) : null;
51310
- if (svgMarkup) {
51311
- const svgElement = this.parseSafeSvg(svgMarkup);
51334
+ const customGeomSvg = block.customGeometry ? this.tryCreateCustomGeometrySvg(block, innerWidth, innerHeight$1) : null;
51335
+ const svgMarkup = !customGeomSvg && block.shapeKind ? this.tryCreatePresetSvg(block, innerWidth, innerHeight$1) : null;
51336
+ const resolvedSvgMarkup = customGeomSvg || svgMarkup;
51337
+ if (resolvedSvgMarkup) {
51338
+ const svgElement = this.parseSafeSvg(resolvedSvgMarkup);
51312
51339
  if (svgElement) {
51313
51340
  svgElement.setAttribute("width", "100%");
51314
51341
  svgElement.setAttribute("height", "100%");
@@ -51376,14 +51403,6 @@ var DomPainter = class DomPainter {
51376
51403
  textDiv.style.minWidth = "0";
51377
51404
  textDiv.style.fontSize = "12px";
51378
51405
  textDiv.style.lineHeight = "1.2";
51379
- if (groupScaleX !== 1 || groupScaleY !== 1) {
51380
- const counterScaleX = 1 / groupScaleX;
51381
- const counterScaleY = 1 / groupScaleY;
51382
- textDiv.style.transform = `scale(${counterScaleX}, ${counterScaleY})`;
51383
- textDiv.style.transformOrigin = "top left";
51384
- textDiv.style.width = `${100 * groupScaleX}%`;
51385
- textDiv.style.height = `${100 * groupScaleY}%`;
51386
- }
51387
51406
  if (textAlign === "center") textDiv.style.textAlign = "center";
51388
51407
  else if (textAlign === "right" || textAlign === "r") textDiv.style.textAlign = "right";
51389
51408
  else textDiv.style.textAlign = "left";
@@ -51452,6 +51471,33 @@ var DomPainter = class DomPainter {
51452
51471
  return null;
51453
51472
  }
51454
51473
  }
51474
+ tryCreateCustomGeometrySvg(block, width, height) {
51475
+ const custGeom = block.customGeometry;
51476
+ if (!custGeom?.paths?.length) return null;
51477
+ let fillColor;
51478
+ if (block.fillColor === null) fillColor = "none";
51479
+ else if (typeof block.fillColor === "string") fillColor = block.fillColor;
51480
+ else fillColor = "#000000";
51481
+ const strokeColor = block.strokeColor === null ? "none" : typeof block.strokeColor === "string" ? block.strokeColor : "none";
51482
+ const strokeWidth = block.strokeColor === null ? 0 : block.strokeWidth ?? 0;
51483
+ const firstPath = custGeom.paths[0];
51484
+ const viewW = firstPath.w || width;
51485
+ const viewH = firstPath.h || height;
51486
+ if (viewW === 0 || viewH === 0) return null;
51487
+ const edgeStroke = fillColor !== "none" && strokeColor === "none" ? ` stroke="${fillColor}" stroke-width="0.5" vector-effect="non-scaling-stroke"` : "";
51488
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${viewW} ${viewH}" preserveAspectRatio="none">
51489
+ ${custGeom.paths.map((p$1) => {
51490
+ const pathW = p$1.w || viewW;
51491
+ const pathH = p$1.h || viewH;
51492
+ const needsTransform = pathW !== viewW || pathH !== viewH;
51493
+ const scaleX = viewW / pathW;
51494
+ const scaleY = viewH / pathH;
51495
+ const transform = needsTransform ? ` transform="scale(${scaleX}, ${scaleY})"` : "";
51496
+ const strokeAttr = strokeColor !== "none" ? ` stroke="${strokeColor}" stroke-width="${strokeWidth}"` : edgeStroke;
51497
+ return `<path d="${p$1.d}" fill="${fillColor}" fill-rule="evenodd"${strokeAttr}${transform} />`;
51498
+ }).join("\n ")}
51499
+ </svg>`;
51500
+ }
51455
51501
  parseSafeSvg(markup) {
51456
51502
  const DOMParserCtor = this.doc?.defaultView?.DOMParser ?? (typeof DOMParser !== "undefined" ? DOMParser : null);
51457
51503
  if (!DOMParserCtor) return null;
@@ -51599,41 +51645,31 @@ var DomPainter = class DomPainter {
51599
51645
  groupEl.style.height = "100%";
51600
51646
  const groupTransform = block.groupTransform;
51601
51647
  let contentContainer = groupEl;
51602
- const groupScaleX = 1;
51603
- const groupScaleY = 1;
51648
+ const visibleWidth = groupTransform?.width ?? block.geometry.width ?? 0;
51649
+ const visibleHeight = groupTransform?.height ?? block.geometry.height ?? 0;
51604
51650
  if (groupTransform) {
51605
51651
  const inner = this.doc.createElement("div");
51606
51652
  inner.style.position = "absolute";
51607
51653
  inner.style.left = "0";
51608
51654
  inner.style.top = "0";
51609
- const childWidth = groupTransform.childWidth ?? groupTransform.width ?? block.geometry.width ?? 0;
51610
- const childHeight = groupTransform.childHeight ?? groupTransform.height ?? block.geometry.height ?? 0;
51611
- inner.style.width = `${Math.max(1, childWidth)}px`;
51612
- inner.style.height = `${Math.max(1, childHeight)}px`;
51613
- const transforms = [];
51614
- const offsetX = groupTransform.childX ?? 0;
51615
- const offsetY = groupTransform.childY ?? 0;
51616
- if (offsetX || offsetY) transforms.push(`translate(${-offsetX}px, ${-offsetY}px)`);
51617
- if (transforms.length > 0) {
51618
- inner.style.transformOrigin = "top left";
51619
- inner.style.transform = transforms.join(" ");
51620
- }
51655
+ inner.style.width = `${Math.max(1, visibleWidth)}px`;
51656
+ inner.style.height = `${Math.max(1, visibleHeight)}px`;
51621
51657
  groupEl.appendChild(inner);
51622
51658
  contentContainer = inner;
51623
51659
  }
51624
51660
  block.shapes.forEach((child) => {
51625
- const childContent = this.createGroupChildContent(child, groupScaleX, groupScaleY, context);
51661
+ const childContent = this.createGroupChildContent(child, 1, 1, context);
51626
51662
  if (!childContent) return;
51627
51663
  const attrs = child.attrs ?? {};
51628
51664
  const wrapper = this.doc.createElement("div");
51629
51665
  wrapper.classList.add("superdoc-shape-group__child");
51630
51666
  wrapper.style.position = "absolute";
51631
- wrapper.style.left = `${attrs.x ?? 0}px`;
51632
- wrapper.style.top = `${attrs.y ?? 0}px`;
51633
- const childWidthValue = typeof attrs.width === "number" ? attrs.width : block.geometry.width;
51634
- const childHeightValue = typeof attrs.height === "number" ? attrs.height : block.geometry.height;
51635
- wrapper.style.width = `${Math.max(1, childWidthValue)}px`;
51636
- wrapper.style.height = `${Math.max(1, childHeightValue)}px`;
51667
+ wrapper.style.left = `${Number(attrs.x ?? 0)}px`;
51668
+ wrapper.style.top = `${Number(attrs.y ?? 0)}px`;
51669
+ const childW = typeof attrs.width === "number" ? attrs.width : block.geometry.width;
51670
+ const childH = typeof attrs.height === "number" ? attrs.height : block.geometry.height;
51671
+ wrapper.style.width = `${Math.max(1, childW)}px`;
51672
+ wrapper.style.height = `${Math.max(1, childH)}px`;
51637
51673
  wrapper.style.transformOrigin = "center";
51638
51674
  const transforms = [];
51639
51675
  if (attrs.rotation) transforms.push(`rotate(${attrs.rotation}deg)`);
@@ -51670,6 +51706,7 @@ var DomPainter = class DomPainter {
51670
51706
  drawingContentId: void 0,
51671
51707
  drawingContent: void 0,
51672
51708
  shapeKind: attrs.kind,
51709
+ customGeometry: attrs.customGeometry,
51673
51710
  fillColor: attrs.fillColor,
51674
51711
  strokeColor: attrs.strokeColor,
51675
51712
  strokeWidth: attrs.strokeWidth,
@@ -55924,11 +55961,8 @@ var NotInlineNodeError = class extends Error {
55924
55961
  const applyInlineRunProperties = (run, runProperties, converterContext) => {
55925
55962
  if (!runProperties) return run;
55926
55963
  const runAttrs = computeRunAttrs(runProperties, converterContext);
55927
- const merged = {
55928
- ...run,
55929
- ...runAttrs
55930
- };
55931
- if (runAttrs.color === void 0 && run.color !== void 0) merged.color = run.color;
55964
+ const merged = { ...run };
55965
+ for (const key$1 of Object.keys(runAttrs)) if (runAttrs[key$1] !== void 0) merged[key$1] = runAttrs[key$1];
55932
55966
  return merged;
55933
55967
  };
55934
55968
  function textNodeToRun({ node, positions, defaultFont, defaultSize, inheritedMarks = [], sdtMetadata, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, enableComments, runProperties, converterContext }) {
@@ -57012,6 +57046,7 @@ const buildDrawingBlock = (rawAttrs, nextBlockId, positions, node, geometry, dra
57012
57046
  attrs: attrsWithPm,
57013
57047
  geometry,
57014
57048
  shapeKind: typeof rawAttrs.kind === "string" ? rawAttrs.kind : void 0,
57049
+ customGeometry: rawAttrs.customGeometry != null ? rawAttrs.customGeometry : void 0,
57015
57050
  fillColor: normalizeFillColor(rawAttrs.fillColor),
57016
57051
  strokeColor: normalizeStrokeColor(rawAttrs.strokeColor),
57017
57052
  strokeWidth: coerceNumber(rawAttrs.strokeWidth),
@@ -73676,13 +73711,13 @@ var buildWrapTransaction = (state, ranges, runType, editor, markDefsFromMeta = [
73676
73711
  const metaStyleMarks = createMarksFromDefs(state.schema, markDefsFromMeta);
73677
73712
  ranges.forEach(({ from: from$1, to }) => {
73678
73713
  state.doc.nodesBetween(from$1, to, (node, pos, parent, index) => {
73679
- if (!node.isText || !parent || parent.type === runType || parent.type?.name === "structuredContent") return;
73714
+ if (!node.isText || !parent || parent.type === runType) return;
73680
73715
  const match$1 = parent.contentMatchAt ? parent.contentMatchAt(index) : null;
73681
73716
  if (match$1 && !match$1.matchType(runType)) return;
73682
73717
  if (!match$1 && !parent.type.contentMatch.matchType(runType)) return;
73683
73718
  let runProperties;
73684
73719
  let textNode = node;
73685
- if (index === 0) ({runProperties, textNode} = copyRunPropertiesFromPreviousParagraph(state, pos, textNode, runType, editor));
73720
+ if (index === 0 && parent.type.name === "paragraph") ({runProperties, textNode} = copyRunPropertiesFromPreviousParagraph(state, pos, textNode, runType, editor));
73686
73721
  if (metaStyleMarks.length) {
73687
73722
  const mergedMarks = metaStyleMarks.reduce((set, mark) => mark.addToSet(set), textNode.marks);
73688
73723
  textNode = textNode.mark(mergedMarks);
@@ -80733,6 +80768,10 @@ const VectorShape = Node$1.create({
80733
80768
  return { "data-stroke-width": attrs.strokeWidth };
80734
80769
  }
80735
80770
  },
80771
+ customGeometry: {
80772
+ default: null,
80773
+ rendered: false
80774
+ },
80736
80775
  lineEnds: {
80737
80776
  default: null,
80738
80777
  rendered: false
@@ -80926,7 +80965,8 @@ var ShapeGroupView = class {
80926
80965
  if (attrs.flipH) transforms.push(`scale(-1, 1) translate(${-width}, 0)`);
80927
80966
  if (attrs.flipV) transforms.push(`scale(1, -1) translate(0, ${-height})`);
80928
80967
  if (transforms.length > 0) g$1.setAttribute("transform", transforms.join(" "));
80929
- const shapeKind = attrs.kind || "rect";
80968
+ const shapeKind = attrs.kind;
80969
+ const customGeometry = attrs.customGeometry;
80930
80970
  const fillColor = attrs.fillColor === null ? null : attrs.fillColor ?? "#5b9bd5";
80931
80971
  const strokeColor = attrs.strokeColor === null ? null : attrs.strokeColor ?? "#000000";
80932
80972
  const strokeWidth = attrs.strokeWidth ?? 1;
@@ -80965,9 +81005,65 @@ var ShapeGroupView = class {
80965
81005
  }
80966
81006
  return g$1;
80967
81007
  }
81008
+ if (customGeometry?.paths?.length) {
81009
+ const fillStr = fillValue === null ? "none" : typeof fillValue === "string" ? fillValue : "none";
81010
+ const strokeStr = strokeColor === null ? "none" : strokeColor;
81011
+ const strokeW = strokeColor === null ? 0 : strokeWidth;
81012
+ const firstPath = customGeometry.paths[0];
81013
+ const viewW = firstPath.w || width;
81014
+ const viewH = firstPath.h || height;
81015
+ if (viewW > 0 && viewH > 0) {
81016
+ const needsEdgeStroke = fillStr !== "none" && strokeStr === "none";
81017
+ const innerSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
81018
+ innerSvg.setAttribute("x", "0");
81019
+ innerSvg.setAttribute("y", "0");
81020
+ innerSvg.setAttribute("width", width.toString());
81021
+ innerSvg.setAttribute("height", height.toString());
81022
+ innerSvg.setAttribute("viewBox", `0 0 ${viewW} ${viewH}`);
81023
+ innerSvg.setAttribute("preserveAspectRatio", "none");
81024
+ for (const pathData of customGeometry.paths) {
81025
+ const pathEl = document.createElementNS("http://www.w3.org/2000/svg", "path");
81026
+ pathEl.setAttribute("d", pathData.d);
81027
+ pathEl.setAttribute("fill", fillStr);
81028
+ pathEl.setAttribute("fill-rule", "evenodd");
81029
+ if (strokeStr !== "none") {
81030
+ pathEl.setAttribute("stroke", strokeStr);
81031
+ pathEl.setAttribute("stroke-width", strokeW.toString());
81032
+ } else if (needsEdgeStroke) {
81033
+ pathEl.setAttribute("stroke", fillStr);
81034
+ pathEl.setAttribute("stroke-width", "0.5");
81035
+ pathEl.setAttribute("vector-effect", "non-scaling-stroke");
81036
+ } else {
81037
+ pathEl.setAttribute("stroke", "none");
81038
+ pathEl.setAttribute("stroke-width", "0");
81039
+ }
81040
+ const pathW = pathData.w || viewW;
81041
+ const pathH = pathData.h || viewH;
81042
+ if (pathW !== viewW || pathH !== viewH) {
81043
+ const scaleX = viewW / pathW;
81044
+ const scaleY = viewH / pathH;
81045
+ pathEl.setAttribute("transform", `scale(${scaleX}, ${scaleY})`);
81046
+ }
81047
+ innerSvg.appendChild(pathEl);
81048
+ }
81049
+ g$1.appendChild(innerSvg);
81050
+ }
81051
+ if (attrs.textContent && attrs.textContent.parts) {
81052
+ const pageNumber = this.editor?.options?.currentPageNumber;
81053
+ const totalPages = this.editor?.options?.totalPageCount;
81054
+ const textGroup = this.createTextElement(attrs.textContent, attrs.textAlign, width, height, {
81055
+ textVerticalAlign: attrs.textVerticalAlign,
81056
+ textInsets: attrs.textInsets,
81057
+ pageNumber,
81058
+ totalPages
81059
+ });
81060
+ if (textGroup) g$1.appendChild(textGroup);
81061
+ }
81062
+ return g$1;
81063
+ }
80968
81064
  try {
80969
81065
  const svgContent = k0({
80970
- preset: shapeKind,
81066
+ preset: shapeKind || "rect",
80971
81067
  styleOverrides: {
80972
81068
  fill: fillValue || "none",
80973
81069
  stroke: strokeColor === null ? "none" : strokeColor,