superdoc 1.17.0-next.25 → 1.17.0-next.26

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.
@@ -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.25") {
37160
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.17.0-next.26") {
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.25") {
37180
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.17.0-next.26") {
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-CDrrUqnT.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-BTdYC9eH.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.25";
263
+ return "1.17.0-next.26";
264
264
  } catch {
265
265
  return "unknown";
266
266
  }
@@ -20756,7 +20756,7 @@ const canUseDOM = () => {
20756
20756
  return false;
20757
20757
  }
20758
20758
  };
20759
- var summaryVersion = "1.17.0-next.25";
20759
+ var summaryVersion = "1.17.0-next.26";
20760
20760
  var nodeKeys = [
20761
20761
  "group",
20762
20762
  "content",
@@ -35471,7 +35471,7 @@ var Editor = class Editor extends EventEmitter$1 {
35471
35471
  return migrations.length > 0;
35472
35472
  }
35473
35473
  processCollaborationMigrations() {
35474
- console.debug("[checkVersionMigrations] Current editor version", "1.17.0-next.25");
35474
+ console.debug("[checkVersionMigrations] Current editor version", "1.17.0-next.26");
35475
35475
  if (!this.options.ydoc) return;
35476
35476
  let docVersion = this.options.ydoc.getMap("meta").get("version");
35477
35477
  if (!docVersion) docVersion = "initial";
@@ -43864,7 +43864,8 @@ async function measureDrawingBlock(block, constraints) {
43864
43864
  const rotatedBounds = calculateRotatedBounds(geometry);
43865
43865
  const naturalWidth = Math.max(1, rotatedBounds.width);
43866
43866
  const naturalHeight = Math.max(1, rotatedBounds.height);
43867
- const maxWidth = fullWidthMax ?? (constraints.maxWidth > 0 ? constraints.maxWidth : naturalWidth);
43867
+ const isFloating = block.wrap?.type === "None";
43868
+ const maxWidth = fullWidthMax ?? (constraints.maxWidth > 0 && !isFloating ? constraints.maxWidth : naturalWidth);
43868
43869
  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
43870
  const widthScale = maxWidth / naturalWidth;
43870
43871
  const heightScale = maxHeight / naturalHeight;
@@ -51306,9 +51307,11 @@ var DomPainter = class DomPainter {
51306
51307
  contentContainer.style.top = `${offsetY}px`;
51307
51308
  contentContainer.style.width = `${innerWidth}px`;
51308
51309
  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);
51310
+ const customGeomSvg = block.customGeometry ? this.tryCreateCustomGeometrySvg(block, innerWidth, innerHeight$1) : null;
51311
+ const svgMarkup = !customGeomSvg && block.shapeKind ? this.tryCreatePresetSvg(block, innerWidth, innerHeight$1) : null;
51312
+ const resolvedSvgMarkup = customGeomSvg || svgMarkup;
51313
+ if (resolvedSvgMarkup) {
51314
+ const svgElement = this.parseSafeSvg(resolvedSvgMarkup);
51312
51315
  if (svgElement) {
51313
51316
  svgElement.setAttribute("width", "100%");
51314
51317
  svgElement.setAttribute("height", "100%");
@@ -51376,14 +51379,6 @@ var DomPainter = class DomPainter {
51376
51379
  textDiv.style.minWidth = "0";
51377
51380
  textDiv.style.fontSize = "12px";
51378
51381
  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
51382
  if (textAlign === "center") textDiv.style.textAlign = "center";
51388
51383
  else if (textAlign === "right" || textAlign === "r") textDiv.style.textAlign = "right";
51389
51384
  else textDiv.style.textAlign = "left";
@@ -51452,6 +51447,33 @@ var DomPainter = class DomPainter {
51452
51447
  return null;
51453
51448
  }
51454
51449
  }
51450
+ tryCreateCustomGeometrySvg(block, width, height) {
51451
+ const custGeom = block.customGeometry;
51452
+ if (!custGeom?.paths?.length) return null;
51453
+ let fillColor;
51454
+ if (block.fillColor === null) fillColor = "none";
51455
+ else if (typeof block.fillColor === "string") fillColor = block.fillColor;
51456
+ else fillColor = "#000000";
51457
+ const strokeColor = block.strokeColor === null ? "none" : typeof block.strokeColor === "string" ? block.strokeColor : "none";
51458
+ const strokeWidth = block.strokeColor === null ? 0 : block.strokeWidth ?? 0;
51459
+ const firstPath = custGeom.paths[0];
51460
+ const viewW = firstPath.w || width;
51461
+ const viewH = firstPath.h || height;
51462
+ if (viewW === 0 || viewH === 0) return null;
51463
+ const edgeStroke = fillColor !== "none" && strokeColor === "none" ? ` stroke="${fillColor}" stroke-width="0.5" vector-effect="non-scaling-stroke"` : "";
51464
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${viewW} ${viewH}" preserveAspectRatio="none">
51465
+ ${custGeom.paths.map((p$1) => {
51466
+ const pathW = p$1.w || viewW;
51467
+ const pathH = p$1.h || viewH;
51468
+ const needsTransform = pathW !== viewW || pathH !== viewH;
51469
+ const scaleX = viewW / pathW;
51470
+ const scaleY = viewH / pathH;
51471
+ const transform = needsTransform ? ` transform="scale(${scaleX}, ${scaleY})"` : "";
51472
+ const strokeAttr = strokeColor !== "none" ? ` stroke="${strokeColor}" stroke-width="${strokeWidth}"` : edgeStroke;
51473
+ return `<path d="${p$1.d}" fill="${fillColor}" fill-rule="evenodd"${strokeAttr}${transform} />`;
51474
+ }).join("\n ")}
51475
+ </svg>`;
51476
+ }
51455
51477
  parseSafeSvg(markup) {
51456
51478
  const DOMParserCtor = this.doc?.defaultView?.DOMParser ?? (typeof DOMParser !== "undefined" ? DOMParser : null);
51457
51479
  if (!DOMParserCtor) return null;
@@ -51599,41 +51621,31 @@ var DomPainter = class DomPainter {
51599
51621
  groupEl.style.height = "100%";
51600
51622
  const groupTransform = block.groupTransform;
51601
51623
  let contentContainer = groupEl;
51602
- const groupScaleX = 1;
51603
- const groupScaleY = 1;
51624
+ const visibleWidth = groupTransform?.width ?? block.geometry.width ?? 0;
51625
+ const visibleHeight = groupTransform?.height ?? block.geometry.height ?? 0;
51604
51626
  if (groupTransform) {
51605
51627
  const inner = this.doc.createElement("div");
51606
51628
  inner.style.position = "absolute";
51607
51629
  inner.style.left = "0";
51608
51630
  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
- }
51631
+ inner.style.width = `${Math.max(1, visibleWidth)}px`;
51632
+ inner.style.height = `${Math.max(1, visibleHeight)}px`;
51621
51633
  groupEl.appendChild(inner);
51622
51634
  contentContainer = inner;
51623
51635
  }
51624
51636
  block.shapes.forEach((child) => {
51625
- const childContent = this.createGroupChildContent(child, groupScaleX, groupScaleY, context);
51637
+ const childContent = this.createGroupChildContent(child, 1, 1, context);
51626
51638
  if (!childContent) return;
51627
51639
  const attrs = child.attrs ?? {};
51628
51640
  const wrapper = this.doc.createElement("div");
51629
51641
  wrapper.classList.add("superdoc-shape-group__child");
51630
51642
  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`;
51643
+ wrapper.style.left = `${Number(attrs.x ?? 0)}px`;
51644
+ wrapper.style.top = `${Number(attrs.y ?? 0)}px`;
51645
+ const childW = typeof attrs.width === "number" ? attrs.width : block.geometry.width;
51646
+ const childH = typeof attrs.height === "number" ? attrs.height : block.geometry.height;
51647
+ wrapper.style.width = `${Math.max(1, childW)}px`;
51648
+ wrapper.style.height = `${Math.max(1, childH)}px`;
51637
51649
  wrapper.style.transformOrigin = "center";
51638
51650
  const transforms = [];
51639
51651
  if (attrs.rotation) transforms.push(`rotate(${attrs.rotation}deg)`);
@@ -51670,6 +51682,7 @@ var DomPainter = class DomPainter {
51670
51682
  drawingContentId: void 0,
51671
51683
  drawingContent: void 0,
51672
51684
  shapeKind: attrs.kind,
51685
+ customGeometry: attrs.customGeometry,
51673
51686
  fillColor: attrs.fillColor,
51674
51687
  strokeColor: attrs.strokeColor,
51675
51688
  strokeWidth: attrs.strokeWidth,
@@ -57009,6 +57022,7 @@ const buildDrawingBlock = (rawAttrs, nextBlockId, positions, node, geometry, dra
57009
57022
  attrs: attrsWithPm,
57010
57023
  geometry,
57011
57024
  shapeKind: typeof rawAttrs.kind === "string" ? rawAttrs.kind : void 0,
57025
+ customGeometry: rawAttrs.customGeometry != null ? rawAttrs.customGeometry : void 0,
57012
57026
  fillColor: normalizeFillColor(rawAttrs.fillColor),
57013
57027
  strokeColor: normalizeStrokeColor(rawAttrs.strokeColor),
57014
57028
  strokeWidth: coerceNumber(rawAttrs.strokeWidth),
@@ -80730,6 +80744,10 @@ const VectorShape = Node$1.create({
80730
80744
  return { "data-stroke-width": attrs.strokeWidth };
80731
80745
  }
80732
80746
  },
80747
+ customGeometry: {
80748
+ default: null,
80749
+ rendered: false
80750
+ },
80733
80751
  lineEnds: {
80734
80752
  default: null,
80735
80753
  rendered: false
@@ -80923,7 +80941,8 @@ var ShapeGroupView = class {
80923
80941
  if (attrs.flipH) transforms.push(`scale(-1, 1) translate(${-width}, 0)`);
80924
80942
  if (attrs.flipV) transforms.push(`scale(1, -1) translate(0, ${-height})`);
80925
80943
  if (transforms.length > 0) g$1.setAttribute("transform", transforms.join(" "));
80926
- const shapeKind = attrs.kind || "rect";
80944
+ const shapeKind = attrs.kind;
80945
+ const customGeometry = attrs.customGeometry;
80927
80946
  const fillColor = attrs.fillColor === null ? null : attrs.fillColor ?? "#5b9bd5";
80928
80947
  const strokeColor = attrs.strokeColor === null ? null : attrs.strokeColor ?? "#000000";
80929
80948
  const strokeWidth = attrs.strokeWidth ?? 1;
@@ -80962,9 +80981,65 @@ var ShapeGroupView = class {
80962
80981
  }
80963
80982
  return g$1;
80964
80983
  }
80984
+ if (customGeometry?.paths?.length) {
80985
+ const fillStr = fillValue === null ? "none" : typeof fillValue === "string" ? fillValue : "none";
80986
+ const strokeStr = strokeColor === null ? "none" : strokeColor;
80987
+ const strokeW = strokeColor === null ? 0 : strokeWidth;
80988
+ const firstPath = customGeometry.paths[0];
80989
+ const viewW = firstPath.w || width;
80990
+ const viewH = firstPath.h || height;
80991
+ if (viewW > 0 && viewH > 0) {
80992
+ const needsEdgeStroke = fillStr !== "none" && strokeStr === "none";
80993
+ const innerSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
80994
+ innerSvg.setAttribute("x", "0");
80995
+ innerSvg.setAttribute("y", "0");
80996
+ innerSvg.setAttribute("width", width.toString());
80997
+ innerSvg.setAttribute("height", height.toString());
80998
+ innerSvg.setAttribute("viewBox", `0 0 ${viewW} ${viewH}`);
80999
+ innerSvg.setAttribute("preserveAspectRatio", "none");
81000
+ for (const pathData of customGeometry.paths) {
81001
+ const pathEl = document.createElementNS("http://www.w3.org/2000/svg", "path");
81002
+ pathEl.setAttribute("d", pathData.d);
81003
+ pathEl.setAttribute("fill", fillStr);
81004
+ pathEl.setAttribute("fill-rule", "evenodd");
81005
+ if (strokeStr !== "none") {
81006
+ pathEl.setAttribute("stroke", strokeStr);
81007
+ pathEl.setAttribute("stroke-width", strokeW.toString());
81008
+ } else if (needsEdgeStroke) {
81009
+ pathEl.setAttribute("stroke", fillStr);
81010
+ pathEl.setAttribute("stroke-width", "0.5");
81011
+ pathEl.setAttribute("vector-effect", "non-scaling-stroke");
81012
+ } else {
81013
+ pathEl.setAttribute("stroke", "none");
81014
+ pathEl.setAttribute("stroke-width", "0");
81015
+ }
81016
+ const pathW = pathData.w || viewW;
81017
+ const pathH = pathData.h || viewH;
81018
+ if (pathW !== viewW || pathH !== viewH) {
81019
+ const scaleX = viewW / pathW;
81020
+ const scaleY = viewH / pathH;
81021
+ pathEl.setAttribute("transform", `scale(${scaleX}, ${scaleY})`);
81022
+ }
81023
+ innerSvg.appendChild(pathEl);
81024
+ }
81025
+ g$1.appendChild(innerSvg);
81026
+ }
81027
+ if (attrs.textContent && attrs.textContent.parts) {
81028
+ const pageNumber = this.editor?.options?.currentPageNumber;
81029
+ const totalPages = this.editor?.options?.totalPageCount;
81030
+ const textGroup = this.createTextElement(attrs.textContent, attrs.textAlign, width, height, {
81031
+ textVerticalAlign: attrs.textVerticalAlign,
81032
+ textInsets: attrs.textInsets,
81033
+ pageNumber,
81034
+ totalPages
81035
+ });
81036
+ if (textGroup) g$1.appendChild(textGroup);
81037
+ }
81038
+ return g$1;
81039
+ }
80965
81040
  try {
80966
81041
  const svgContent = k0({
80967
- preset: shapeKind,
81042
+ preset: shapeKind || "rect",
80968
81043
  styleOverrides: {
80969
81044
  fill: fillValue || "none",
80970
81045
  stroke: strokeColor === null ? "none" : strokeColor,