@superdoc-dev/cli 0.2.0-next.20 → 0.2.0-next.22

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 (2) hide show
  1. package/dist/index.js +332 -69
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -26618,7 +26618,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
26618
26618
  emptyOptions2 = {};
26619
26619
  });
26620
26620
 
26621
- // ../../packages/superdoc/dist/chunks/SuperConverter-CRrxAa8F.es.js
26621
+ // ../../packages/superdoc/dist/chunks/SuperConverter-BJBbuXuZ.es.js
26622
26622
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
26623
26623
  const fieldValue = extension$1.config[field];
26624
26624
  if (typeof fieldValue === "function")
@@ -30840,6 +30840,64 @@ function extractFillColor(spPr, style) {
30840
30840
  }
30841
30841
  return null;
30842
30842
  }
30843
+ function extractCustomGeometry(spPr) {
30844
+ const custGeom = spPr?.elements?.find((el) => el.name === "a:custGeom");
30845
+ if (!custGeom)
30846
+ return null;
30847
+ const pathLst = custGeom.elements?.find((el) => el.name === "a:pathLst");
30848
+ if (!pathLst?.elements)
30849
+ return null;
30850
+ const paths = pathLst.elements.filter((el) => el.name === "a:path").map((pathEl) => {
30851
+ const w = parseInt(pathEl.attributes?.["w"] || "0", 10);
30852
+ const h = parseInt(pathEl.attributes?.["h"] || "0", 10);
30853
+ return {
30854
+ d: convertDrawingMLPathToSvg(pathEl),
30855
+ w,
30856
+ h
30857
+ };
30858
+ }).filter((p) => p.d);
30859
+ if (paths.length === 0)
30860
+ return null;
30861
+ return { paths };
30862
+ }
30863
+ function convertDrawingMLPathToSvg(pathEl) {
30864
+ if (!pathEl?.elements)
30865
+ return "";
30866
+ const parts = [];
30867
+ for (const cmd of pathEl.elements)
30868
+ switch (cmd.name) {
30869
+ case "a:moveTo": {
30870
+ const pt = cmd.elements?.find((el) => el.name === "a:pt");
30871
+ if (pt)
30872
+ parts.push(`M ${pt.attributes?.["x"] || 0} ${pt.attributes?.["y"] || 0}`);
30873
+ break;
30874
+ }
30875
+ case "a:lnTo": {
30876
+ const pt = cmd.elements?.find((el) => el.name === "a:pt");
30877
+ if (pt)
30878
+ parts.push(`L ${pt.attributes?.["x"] || 0} ${pt.attributes?.["y"] || 0}`);
30879
+ break;
30880
+ }
30881
+ case "a:cubicBezTo": {
30882
+ const pts = cmd.elements?.filter((el) => el.name === "a:pt") || [];
30883
+ if (pts.length === 3)
30884
+ 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}`);
30885
+ break;
30886
+ }
30887
+ case "a:quadBezTo": {
30888
+ const pts = cmd.elements?.filter((el) => el.name === "a:pt") || [];
30889
+ if (pts.length === 2)
30890
+ parts.push(`Q ${pts[0].attributes?.["x"] || 0} ${pts[0].attributes?.["y"] || 0} ${pts[1].attributes?.["x"] || 0} ${pts[1].attributes?.["y"] || 0}`);
30891
+ break;
30892
+ }
30893
+ case "a:close":
30894
+ parts.push("Z");
30895
+ break;
30896
+ default:
30897
+ break;
30898
+ }
30899
+ return parts.join(" ");
30900
+ }
30843
30901
  function extractGradientFill(gradFill) {
30844
30902
  const gradient = {
30845
30903
  type: "gradient",
@@ -31867,7 +31925,7 @@ function extractTextFromTextBox(textBoxContent, bodyPr, params = {}) {
31867
31925
  wrap: wrap$1
31868
31926
  };
31869
31927
  }
31870
- function getVectorShape({ params, node: node3, graphicData, size, marginOffset, anchorData, wrap: wrap$1, isAnchor }) {
31928
+ function getVectorShape({ params, node: node3, graphicData, size, marginOffset, anchorData, wrap: wrap$1, isAnchor, customGeometry }) {
31871
31929
  const schemaAttrs = {};
31872
31930
  const drawingNode = params.nodes?.[0];
31873
31931
  if (drawingNode?.name === "w:drawing")
@@ -31879,9 +31937,14 @@ function getVectorShape({ params, node: node3, graphicData, size, marginOffset,
31879
31937
  if (!spPr)
31880
31938
  return null;
31881
31939
  const shapeKind = spPr.elements?.find((el) => el.name === "a:prstGeom")?.attributes?.["prst"];
31882
- if (!shapeKind)
31883
- console.warn("Shape kind not found");
31884
31940
  schemaAttrs.kind = shapeKind;
31941
+ if (customGeometry)
31942
+ schemaAttrs.customGeometry = customGeometry;
31943
+ else if (!shapeKind) {
31944
+ const extracted = extractCustomGeometry(spPr);
31945
+ if (extracted)
31946
+ schemaAttrs.customGeometry = extracted;
31947
+ }
31885
31948
  const width = size?.width ?? DEFAULT_SHAPE_WIDTH;
31886
31949
  const height = size?.height ?? DEFAULT_SHAPE_HEIGHT;
31887
31950
  const xfrm = spPr.elements?.find((el) => el.name === "a:xfrm");
@@ -48433,7 +48496,10 @@ var isRegExp = (value) => {
48433
48496
  }, handleShapeDrawing = (params, node3, graphicData, size, padding, marginOffset, anchorData, wrap$1, isAnchor, isHidden) => {
48434
48497
  const wsp = graphicData.elements.find((el) => el.name === "wps:wsp");
48435
48498
  const textBoxContent = wsp.elements.find((el) => el.name === "wps:txbx")?.elements?.find((el) => el.name === "w:txbxContent");
48436
- if (wsp.elements.find((el) => el.name === "wps:spPr")?.elements.find((el) => el.name === "a:prstGeom")?.attributes["prst"]) {
48499
+ const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
48500
+ const shapeType = spPr?.elements.find((el) => el.name === "a:prstGeom")?.attributes["prst"];
48501
+ const custGeom = !shapeType ? extractCustomGeometry(spPr) : null;
48502
+ if (shapeType || custGeom) {
48437
48503
  const result = getVectorShape({
48438
48504
  params,
48439
48505
  node: node3,
@@ -48442,7 +48508,8 @@ var isRegExp = (value) => {
48442
48508
  marginOffset,
48443
48509
  anchorData,
48444
48510
  wrap: wrap$1,
48445
- isAnchor
48511
+ isAnchor,
48512
+ customGeometry: custGeom
48446
48513
  });
48447
48514
  if (result?.attrs && isHidden)
48448
48515
  result.attrs.hidden = true;
@@ -48494,6 +48561,7 @@ var isRegExp = (value) => {
48494
48561
  if (!spPr)
48495
48562
  return null;
48496
48563
  const shapeKind = spPr.elements?.find((el) => el.name === "a:prstGeom")?.attributes?.["prst"];
48564
+ const customGeom = !shapeKind ? extractCustomGeometry(spPr) : null;
48497
48565
  const shapeXfrm = spPr.elements?.find((el) => el.name === "a:xfrm");
48498
48566
  const shapeOff = shapeXfrm?.elements?.find((el) => el.name === "a:off");
48499
48567
  const shapeExt = shapeXfrm?.elements?.find((el) => el.name === "a:ext");
@@ -48538,6 +48606,7 @@ var isRegExp = (value) => {
48538
48606
  shapeType: "vectorShape",
48539
48607
  attrs: {
48540
48608
  kind: shapeKind,
48609
+ customGeometry: customGeom || undefined,
48541
48610
  x,
48542
48611
  y,
48543
48612
  width,
@@ -53731,7 +53800,7 @@ var isRegExp = (value) => {
53731
53800
  state.kern = kernNode.attributes["w:val"];
53732
53801
  }
53733
53802
  }, SuperConverter;
53734
- var init_SuperConverter_CRrxAa8F_es = __esm(() => {
53803
+ var init_SuperConverter_BJBbuXuZ_es = __esm(() => {
53735
53804
  init_rolldown_runtime_B2q5OVn9_es();
53736
53805
  init_jszip_ChlR43oI_es();
53737
53806
  init_xml_js_DLE8mr0n_es();
@@ -93008,9 +93077,9 @@ var init_remark_gfm_CQ3Jg4PR_es = __esm(() => {
93008
93077
  init_remark_gfm_z_sDF4ss_es();
93009
93078
  });
93010
93079
 
93011
- // ../../packages/superdoc/dist/chunks/src-10daZ2Cr.es.js
93012
- var exports_src_10daZ2Cr_es = {};
93013
- __export(exports_src_10daZ2Cr_es, {
93080
+ // ../../packages/superdoc/dist/chunks/src-DCn8o9a0.es.js
93081
+ var exports_src_DCn8o9a0_es = {};
93082
+ __export(exports_src_DCn8o9a0_es, {
93014
93083
  zt: () => defineMark,
93015
93084
  z: () => cM,
93016
93085
  yt: () => removeAwarenessStates,
@@ -113465,7 +113534,8 @@ async function measureDrawingBlock(block, constraints) {
113465
113534
  const rotatedBounds = calculateRotatedBounds(geometry);
113466
113535
  const naturalWidth = Math.max(1, rotatedBounds.width);
113467
113536
  const naturalHeight = Math.max(1, rotatedBounds.height);
113468
- const maxWidth = fullWidthMax ?? (constraints.maxWidth > 0 ? constraints.maxWidth : naturalWidth);
113537
+ const isFloating = block.wrap?.type === "None";
113538
+ const maxWidth = fullWidthMax ?? (constraints.maxWidth > 0 && !isFloating ? constraints.maxWidth : naturalWidth);
113469
113539
  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;
113470
113540
  const widthScale = maxWidth / naturalWidth;
113471
113541
  const heightScale = maxHeight / naturalHeight;
@@ -143365,13 +143435,29 @@ var Node$13 = class Node$14 {
143365
143435
  day: "2-digit",
143366
143436
  year: "numeric"
143367
143437
  });
143368
- }, AnnotatorHelpers, updateYdocDocxData = async (editor, ydoc) => {
143438
+ }, AnnotatorHelpers, inFlightUpdates, updateYdocDocxData = (editor, ydoc) => {
143439
+ ydoc = ydoc || editor?.options?.ydoc;
143440
+ if (!ydoc || ydoc.isDestroyed)
143441
+ return Promise.resolve();
143442
+ if (!editor || editor.isDestroyed)
143443
+ return Promise.resolve();
143444
+ let ydocMap = inFlightUpdates.get(editor);
143445
+ if (!ydocMap) {
143446
+ ydocMap = /* @__PURE__ */ new WeakMap;
143447
+ inFlightUpdates.set(editor, ydocMap);
143448
+ }
143449
+ const existing = ydocMap.get(ydoc);
143450
+ if (existing)
143451
+ return existing;
143452
+ const promise = _doUpdateYdocDocxData(editor, ydoc).finally(() => {
143453
+ const map$22 = inFlightUpdates.get(editor);
143454
+ if (map$22 && map$22.get(ydoc) === promise)
143455
+ map$22.delete(ydoc);
143456
+ });
143457
+ ydocMap.set(ydoc, promise);
143458
+ return promise;
143459
+ }, _doUpdateYdocDocxData = async (editor, ydoc) => {
143369
143460
  try {
143370
- ydoc = ydoc || editor?.options?.ydoc;
143371
- if (!ydoc || ydoc.isDestroyed)
143372
- return;
143373
- if (!editor || editor.isDestroyed)
143374
- return;
143375
143461
  const metaMap = ydoc.getMap("meta");
143376
143462
  const docxValue = metaMap.get("docx");
143377
143463
  let docx = [];
@@ -143488,10 +143574,15 @@ var Node$13 = class Node$14 {
143488
143574
  if (value instanceof Set && value.has("docx"))
143489
143575
  return true;
143490
143576
  return false;
143577
+ }, debouncedDocxUpdateByEditor, cancelDebouncedDocxUpdate = (editor) => {
143578
+ const cancel = debouncedDocxUpdateByEditor.get(editor);
143579
+ if (cancel)
143580
+ cancel();
143491
143581
  }, initDocumentListener = ({ ydoc, editor }) => {
143492
143582
  const debouncedUpdate = debounce$2((editor$1) => {
143493
143583
  updateYdocDocxData(editor$1);
143494
143584
  }, 30000, { maxWait: 60000 });
143585
+ debouncedDocxUpdateByEditor.set(editor, () => debouncedUpdate.cancel());
143495
143586
  const afterTransactionHandler = (transaction) => {
143496
143587
  const { local } = transaction;
143497
143588
  if (!checkDocxChanged(transaction) && transaction.changed?.size && local)
@@ -143501,6 +143592,7 @@ var Node$13 = class Node$14 {
143501
143592
  return () => {
143502
143593
  ydoc.off("afterTransaction", afterTransactionHandler);
143503
143594
  debouncedUpdate.cancel();
143595
+ debouncedDocxUpdateByEditor.delete(editor);
143504
143596
  };
143505
143597
  }, debounce$2 = (fn, wait, { maxWait } = {}) => {
143506
143598
  let timeout$1 = null;
@@ -150348,6 +150440,7 @@ var Node$13 = class Node$14 {
150348
150440
  attrs: attrsWithPm,
150349
150441
  geometry,
150350
150442
  shapeKind: typeof rawAttrs.kind === "string" ? rawAttrs.kind : undefined,
150443
+ customGeometry: rawAttrs.customGeometry != null ? rawAttrs.customGeometry : undefined,
150351
150444
  fillColor: normalizeFillColor(rawAttrs.fillColor),
150352
150445
  strokeColor: normalizeStrokeColor(rawAttrs.strokeColor),
150353
150446
  strokeWidth: coerceNumber(rawAttrs.strokeWidth),
@@ -159843,7 +159936,8 @@ var Node$13 = class Node$14 {
159843
159936
  transforms.push(`scale(1, -1) translate(0, ${-height})`);
159844
159937
  if (transforms.length > 0)
159845
159938
  g$1.setAttribute("transform", transforms.join(" "));
159846
- const shapeKind = attrs.kind || "rect";
159939
+ const shapeKind = attrs.kind;
159940
+ const customGeometry = attrs.customGeometry;
159847
159941
  const fillColor = attrs.fillColor === null ? null : attrs.fillColor ?? "#5b9bd5";
159848
159942
  const strokeColor = attrs.strokeColor === null ? null : attrs.strokeColor ?? "#000000";
159849
159943
  const strokeWidth = attrs.strokeWidth ?? 1;
@@ -159885,9 +159979,66 @@ var Node$13 = class Node$14 {
159885
159979
  }
159886
159980
  return g$1;
159887
159981
  }
159982
+ if (customGeometry?.paths?.length) {
159983
+ const fillStr = fillValue === null ? "none" : typeof fillValue === "string" ? fillValue : "none";
159984
+ const strokeStr = strokeColor === null ? "none" : strokeColor;
159985
+ const strokeW = strokeColor === null ? 0 : strokeWidth;
159986
+ const firstPath = customGeometry.paths[0];
159987
+ const viewW = firstPath.w || width;
159988
+ const viewH = firstPath.h || height;
159989
+ if (viewW > 0 && viewH > 0) {
159990
+ const needsEdgeStroke = fillStr !== "none" && strokeStr === "none";
159991
+ const innerSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
159992
+ innerSvg.setAttribute("x", "0");
159993
+ innerSvg.setAttribute("y", "0");
159994
+ innerSvg.setAttribute("width", width.toString());
159995
+ innerSvg.setAttribute("height", height.toString());
159996
+ innerSvg.setAttribute("viewBox", `0 0 ${viewW} ${viewH}`);
159997
+ innerSvg.setAttribute("preserveAspectRatio", "none");
159998
+ for (const pathData of customGeometry.paths) {
159999
+ const pathEl = document.createElementNS("http://www.w3.org/2000/svg", "path");
160000
+ pathEl.setAttribute("d", pathData.d);
160001
+ pathEl.setAttribute("fill", fillStr);
160002
+ pathEl.setAttribute("fill-rule", "evenodd");
160003
+ if (strokeStr !== "none") {
160004
+ pathEl.setAttribute("stroke", strokeStr);
160005
+ pathEl.setAttribute("stroke-width", strokeW.toString());
160006
+ } else if (needsEdgeStroke) {
160007
+ pathEl.setAttribute("stroke", fillStr);
160008
+ pathEl.setAttribute("stroke-width", "0.5");
160009
+ pathEl.setAttribute("vector-effect", "non-scaling-stroke");
160010
+ } else {
160011
+ pathEl.setAttribute("stroke", "none");
160012
+ pathEl.setAttribute("stroke-width", "0");
160013
+ }
160014
+ const pathW = pathData.w || viewW;
160015
+ const pathH = pathData.h || viewH;
160016
+ if (pathW !== viewW || pathH !== viewH) {
160017
+ const scaleX = viewW / pathW;
160018
+ const scaleY = viewH / pathH;
160019
+ pathEl.setAttribute("transform", `scale(${scaleX}, ${scaleY})`);
160020
+ }
160021
+ innerSvg.appendChild(pathEl);
160022
+ }
160023
+ g$1.appendChild(innerSvg);
160024
+ }
160025
+ if (attrs.textContent && attrs.textContent.parts) {
160026
+ const pageNumber = this.editor?.options?.currentPageNumber;
160027
+ const totalPages = this.editor?.options?.totalPageCount;
160028
+ const textGroup = this.createTextElement(attrs.textContent, attrs.textAlign, width, height, {
160029
+ textVerticalAlign: attrs.textVerticalAlign,
160030
+ textInsets: attrs.textInsets,
160031
+ pageNumber,
160032
+ totalPages
160033
+ });
160034
+ if (textGroup)
160035
+ g$1.appendChild(textGroup);
160036
+ }
160037
+ return g$1;
160038
+ }
159888
160039
  try {
159889
160040
  const svgContent = k0({
159890
- preset: shapeKind,
160041
+ preset: shapeKind || "rect",
159891
160042
  styleOverrides: {
159892
160043
  fill: fillValue || "none",
159893
160044
  stroke: strokeColor === null ? "none" : strokeColor,
@@ -162390,9 +162541,9 @@ var Node$13 = class Node$14 {
162390
162541
  trackedChanges: context.trackedChanges ?? []
162391
162542
  });
162392
162543
  }, _hoisted_1$6, _hoisted_2$1, _hoisted_3, _hoisted_4, ContextMenu_default, _hoisted_1$5, BasicUpload_default, _hoisted_1$4, MIN_WIDTH = 200, PPI = 96, alignment = "flex-end", Ruler_default, GenericPopover_default, _hoisted_1$3, RESIZE_HANDLE_WIDTH_PX = 9, RESIZE_HANDLE_OFFSET_PX = 4, DRAG_OVERLAY_EXTENSION_PX = 1000, MIN_DRAG_OVERLAY_WIDTH_PX = 2000, THROTTLE_INTERVAL_MS = 16, MIN_RESIZE_DELTA_PX = 1, TableResizeOverlay_default, _hoisted_1$2, OVERLAY_EXPANSION_PX = 2000, RESIZE_HANDLE_SIZE_PX = 12, MOUSE_MOVE_THROTTLE_MS = 16, DIMENSION_CHANGE_THRESHOLD_PX = 1, Z_INDEX_OVERLAY = 10, Z_INDEX_HANDLE = 15, Z_INDEX_GUIDELINE = 20, ImageResizeOverlay_default, LINK_CLICK_DEBOUNCE_MS = 300, CURSOR_UPDATE_TIMEOUT_MS = 10, LinkClickHandler_default, _hoisted_1$1, _hoisted_2, DOCX2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", TABLE_RESIZE_HOVER_THRESHOLD = 8, TABLE_RESIZE_THROTTLE_MS = 16, SuperEditor_default, _hoisted_1, SuperInput_default, SlashMenu, Extensions;
162393
- var init_src_10daZ2Cr_es = __esm(() => {
162544
+ var init_src_DCn8o9a0_es = __esm(() => {
162394
162545
  init_rolldown_runtime_B2q5OVn9_es();
162395
- init_SuperConverter_CRrxAa8F_es();
162546
+ init_SuperConverter_BJBbuXuZ_es();
162396
162547
  init_jszip_ChlR43oI_es();
162397
162548
  init_uuid_2IzDu5nl_es();
162398
162549
  init_constants_Dw0kAsLd_es();
@@ -170313,6 +170464,7 @@ function print() { __p += __j.call(arguments, '') }
170313
170464
  annotateHeadersAndFooters,
170314
170465
  getAllHeaderFooterEditors
170315
170466
  };
170467
+ inFlightUpdates = /* @__PURE__ */ new WeakMap;
170316
170468
  new PluginKey("collaboration");
170317
170469
  headlessBindingStateByEditor = /* @__PURE__ */ new WeakMap;
170318
170470
  headlessCleanupRegisteredEditors = /* @__PURE__ */ new WeakSet;
@@ -170399,6 +170551,7 @@ function print() { __p += __j.call(arguments, '') }
170399
170551
  } };
170400
170552
  }
170401
170553
  });
170554
+ debouncedDocxUpdateByEditor = /* @__PURE__ */ new WeakMap;
170402
170555
  isHighContrastMode = ref2(false);
170403
170556
  ({ findChildren: findChildren$4 } = helpers_exports);
170404
170557
  ({ findChildren: findChildren$3 } = helpers_exports);
@@ -175389,7 +175542,8 @@ function print() { __p += __j.call(arguments, '') }
175389
175542
  this.#initMedia();
175390
175543
  this.initDefaultStyles();
175391
175544
  if (this.options.ydoc && this.options.collaborationProvider) {
175392
- updateYdocDocxData(this, this.options.ydoc);
175545
+ cancelDebouncedDocxUpdate(this);
175546
+ await updateYdocDocxData(this, this.options.ydoc);
175393
175547
  this.initializeCollaborationData();
175394
175548
  } else
175395
175549
  this.#insertNewFileData();
@@ -180644,9 +180798,11 @@ function print() { __p += __j.call(arguments, '') }
180644
180798
  contentContainer.style.top = `${offsetY}px`;
180645
180799
  contentContainer.style.width = `${innerWidth}px`;
180646
180800
  contentContainer.style.height = `${innerHeight$1}px`;
180647
- const svgMarkup = block.shapeKind ? this.tryCreatePresetSvg(block, innerWidth, innerHeight$1) : null;
180648
- if (svgMarkup) {
180649
- const svgElement = this.parseSafeSvg(svgMarkup);
180801
+ const customGeomSvg = block.customGeometry ? this.tryCreateCustomGeometrySvg(block, innerWidth, innerHeight$1) : null;
180802
+ const svgMarkup = !customGeomSvg && block.shapeKind ? this.tryCreatePresetSvg(block, innerWidth, innerHeight$1) : null;
180803
+ const resolvedSvgMarkup = customGeomSvg || svgMarkup;
180804
+ if (resolvedSvgMarkup) {
180805
+ const svgElement = this.parseSafeSvg(resolvedSvgMarkup);
180650
180806
  if (svgElement) {
180651
180807
  svgElement.setAttribute("width", "100%");
180652
180808
  svgElement.setAttribute("height", "100%");
@@ -180729,14 +180885,6 @@ function print() { __p += __j.call(arguments, '') }
180729
180885
  textDiv.style.minWidth = "0";
180730
180886
  textDiv.style.fontSize = "12px";
180731
180887
  textDiv.style.lineHeight = "1.2";
180732
- if (groupScaleX !== 1 || groupScaleY !== 1) {
180733
- const counterScaleX = 1 / groupScaleX;
180734
- const counterScaleY = 1 / groupScaleY;
180735
- textDiv.style.transform = `scale(${counterScaleX}, ${counterScaleY})`;
180736
- textDiv.style.transformOrigin = "top left";
180737
- textDiv.style.width = `${100 * groupScaleX}%`;
180738
- textDiv.style.height = `${100 * groupScaleY}%`;
180739
- }
180740
180888
  if (textAlign === "center")
180741
180889
  textDiv.style.textAlign = "center";
180742
180890
  else if (textAlign === "right" || textAlign === "r")
@@ -180819,6 +180967,39 @@ function print() { __p += __j.call(arguments, '') }
180819
180967
  return null;
180820
180968
  }
180821
180969
  }
180970
+ tryCreateCustomGeometrySvg(block, width, height) {
180971
+ const custGeom = block.customGeometry;
180972
+ if (!custGeom?.paths?.length)
180973
+ return null;
180974
+ let fillColor;
180975
+ if (block.fillColor === null)
180976
+ fillColor = "none";
180977
+ else if (typeof block.fillColor === "string")
180978
+ fillColor = block.fillColor;
180979
+ else
180980
+ fillColor = "#000000";
180981
+ const strokeColor = block.strokeColor === null ? "none" : typeof block.strokeColor === "string" ? block.strokeColor : "none";
180982
+ const strokeWidth = block.strokeColor === null ? 0 : block.strokeWidth ?? 0;
180983
+ const firstPath = custGeom.paths[0];
180984
+ const viewW = firstPath.w || width;
180985
+ const viewH = firstPath.h || height;
180986
+ if (viewW === 0 || viewH === 0)
180987
+ return null;
180988
+ const edgeStroke = fillColor !== "none" && strokeColor === "none" ? ` stroke="${fillColor}" stroke-width="0.5" vector-effect="non-scaling-stroke"` : "";
180989
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${viewW} ${viewH}" preserveAspectRatio="none">
180990
+ ${custGeom.paths.map((p$12) => {
180991
+ const pathW = p$12.w || viewW;
180992
+ const pathH = p$12.h || viewH;
180993
+ const needsTransform = pathW !== viewW || pathH !== viewH;
180994
+ const scaleX = viewW / pathW;
180995
+ const scaleY = viewH / pathH;
180996
+ const transform = needsTransform ? ` transform="scale(${scaleX}, ${scaleY})"` : "";
180997
+ const strokeAttr = strokeColor !== "none" ? ` stroke="${strokeColor}" stroke-width="${strokeWidth}"` : edgeStroke;
180998
+ return `<path d="${p$12.d}" fill="${fillColor}" fill-rule="evenodd"${strokeAttr}${transform} />`;
180999
+ }).join(`
181000
+ `)}
181001
+ </svg>`;
181002
+ }
180822
181003
  parseSafeSvg(markup) {
180823
181004
  const DOMParserCtor = this.doc?.defaultView?.DOMParser ?? (typeof DOMParser !== "undefined" ? DOMParser : null);
180824
181005
  if (!DOMParserCtor)
@@ -180983,43 +181164,32 @@ function print() { __p += __j.call(arguments, '') }
180983
181164
  groupEl.style.height = "100%";
180984
181165
  const groupTransform = block.groupTransform;
180985
181166
  let contentContainer = groupEl;
180986
- const groupScaleX = 1;
180987
- const groupScaleY = 1;
181167
+ const visibleWidth = groupTransform?.width ?? block.geometry.width ?? 0;
181168
+ const visibleHeight = groupTransform?.height ?? block.geometry.height ?? 0;
180988
181169
  if (groupTransform) {
180989
181170
  const inner = this.doc.createElement("div");
180990
181171
  inner.style.position = "absolute";
180991
181172
  inner.style.left = "0";
180992
181173
  inner.style.top = "0";
180993
- const childWidth = groupTransform.childWidth ?? groupTransform.width ?? block.geometry.width ?? 0;
180994
- const childHeight = groupTransform.childHeight ?? groupTransform.height ?? block.geometry.height ?? 0;
180995
- inner.style.width = `${Math.max(1, childWidth)}px`;
180996
- inner.style.height = `${Math.max(1, childHeight)}px`;
180997
- const transforms = [];
180998
- const offsetX = groupTransform.childX ?? 0;
180999
- const offsetY = groupTransform.childY ?? 0;
181000
- if (offsetX || offsetY)
181001
- transforms.push(`translate(${-offsetX}px, ${-offsetY}px)`);
181002
- if (transforms.length > 0) {
181003
- inner.style.transformOrigin = "top left";
181004
- inner.style.transform = transforms.join(" ");
181005
- }
181174
+ inner.style.width = `${Math.max(1, visibleWidth)}px`;
181175
+ inner.style.height = `${Math.max(1, visibleHeight)}px`;
181006
181176
  groupEl.appendChild(inner);
181007
181177
  contentContainer = inner;
181008
181178
  }
181009
181179
  block.shapes.forEach((child) => {
181010
- const childContent = this.createGroupChildContent(child, groupScaleX, groupScaleY, context);
181180
+ const childContent = this.createGroupChildContent(child, 1, 1, context);
181011
181181
  if (!childContent)
181012
181182
  return;
181013
181183
  const attrs = child.attrs ?? {};
181014
181184
  const wrapper = this.doc.createElement("div");
181015
181185
  wrapper.classList.add("superdoc-shape-group__child");
181016
181186
  wrapper.style.position = "absolute";
181017
- wrapper.style.left = `${attrs.x ?? 0}px`;
181018
- wrapper.style.top = `${attrs.y ?? 0}px`;
181019
- const childWidthValue = typeof attrs.width === "number" ? attrs.width : block.geometry.width;
181020
- const childHeightValue = typeof attrs.height === "number" ? attrs.height : block.geometry.height;
181021
- wrapper.style.width = `${Math.max(1, childWidthValue)}px`;
181022
- wrapper.style.height = `${Math.max(1, childHeightValue)}px`;
181187
+ wrapper.style.left = `${Number(attrs.x ?? 0)}px`;
181188
+ wrapper.style.top = `${Number(attrs.y ?? 0)}px`;
181189
+ const childW = typeof attrs.width === "number" ? attrs.width : block.geometry.width;
181190
+ const childH = typeof attrs.height === "number" ? attrs.height : block.geometry.height;
181191
+ wrapper.style.width = `${Math.max(1, childW)}px`;
181192
+ wrapper.style.height = `${Math.max(1, childH)}px`;
181023
181193
  wrapper.style.transformOrigin = "center";
181024
181194
  const transforms = [];
181025
181195
  if (attrs.rotation)
@@ -181060,6 +181230,7 @@ function print() { __p += __j.call(arguments, '') }
181060
181230
  drawingContentId: undefined,
181061
181231
  drawingContent: undefined,
181062
181232
  shapeKind: attrs.kind,
181233
+ customGeometry: attrs.customGeometry,
181063
181234
  fillColor: attrs.fillColor,
181064
181235
  strokeColor: attrs.strokeColor,
181065
181236
  strokeWidth: attrs.strokeWidth,
@@ -191171,6 +191342,10 @@ function print() { __p += __j.call(arguments, '') }
191171
191342
  return { "data-stroke-width": attrs.strokeWidth };
191172
191343
  }
191173
191344
  },
191345
+ customGeometry: {
191346
+ default: null,
191347
+ rendered: false
191348
+ },
191174
191349
  lineEnds: {
191175
191350
  default: null,
191176
191351
  rendered: false
@@ -195905,8 +196080,8 @@ function print() { __p += __j.call(arguments, '') }
195905
196080
  return isObjectLike_default(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
195906
196081
  };
195907
196082
  stubFalse_default = stubFalse;
195908
- freeExports$2 = typeof exports_src_10daZ2Cr_es == "object" && exports_src_10daZ2Cr_es && !exports_src_10daZ2Cr_es.nodeType && exports_src_10daZ2Cr_es;
195909
- freeModule$2 = freeExports$2 && typeof module_src_10daZ2Cr_es == "object" && module_src_10daZ2Cr_es && !module_src_10daZ2Cr_es.nodeType && module_src_10daZ2Cr_es;
196083
+ freeExports$2 = typeof exports_src_DCn8o9a0_es == "object" && exports_src_DCn8o9a0_es && !exports_src_DCn8o9a0_es.nodeType && exports_src_DCn8o9a0_es;
196084
+ freeModule$2 = freeExports$2 && typeof module_src_DCn8o9a0_es == "object" && module_src_DCn8o9a0_es && !module_src_DCn8o9a0_es.nodeType && module_src_DCn8o9a0_es;
195910
196085
  Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? _root_default.Buffer : undefined;
195911
196086
  isBuffer_default = (Buffer$1 ? Buffer$1.isBuffer : undefined) || stubFalse_default;
195912
196087
  typedArrayTags = {};
@@ -195914,8 +196089,8 @@ function print() { __p += __j.call(arguments, '') }
195914
196089
  typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
195915
196090
  _baseIsTypedArray_default = baseIsTypedArray;
195916
196091
  _baseUnary_default = baseUnary;
195917
- freeExports$1 = typeof exports_src_10daZ2Cr_es == "object" && exports_src_10daZ2Cr_es && !exports_src_10daZ2Cr_es.nodeType && exports_src_10daZ2Cr_es;
195918
- freeModule$1 = freeExports$1 && typeof module_src_10daZ2Cr_es == "object" && module_src_10daZ2Cr_es && !module_src_10daZ2Cr_es.nodeType && module_src_10daZ2Cr_es;
196092
+ freeExports$1 = typeof exports_src_DCn8o9a0_es == "object" && exports_src_DCn8o9a0_es && !exports_src_DCn8o9a0_es.nodeType && exports_src_DCn8o9a0_es;
196093
+ freeModule$1 = freeExports$1 && typeof module_src_DCn8o9a0_es == "object" && module_src_DCn8o9a0_es && !module_src_DCn8o9a0_es.nodeType && module_src_DCn8o9a0_es;
195919
196094
  freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && _freeGlobal_default.process;
195920
196095
  _nodeUtil_default = function() {
195921
196096
  try {
@@ -196020,8 +196195,8 @@ function print() { __p += __j.call(arguments, '') }
196020
196195
  Stack.prototype.has = _stackHas_default;
196021
196196
  Stack.prototype.set = _stackSet_default;
196022
196197
  _Stack_default = Stack;
196023
- freeExports = typeof exports_src_10daZ2Cr_es == "object" && exports_src_10daZ2Cr_es && !exports_src_10daZ2Cr_es.nodeType && exports_src_10daZ2Cr_es;
196024
- freeModule = freeExports && typeof module_src_10daZ2Cr_es == "object" && module_src_10daZ2Cr_es && !module_src_10daZ2Cr_es.nodeType && module_src_10daZ2Cr_es;
196198
+ freeExports = typeof exports_src_DCn8o9a0_es == "object" && exports_src_DCn8o9a0_es && !exports_src_DCn8o9a0_es.nodeType && exports_src_DCn8o9a0_es;
196199
+ freeModule = freeExports && typeof module_src_DCn8o9a0_es == "object" && module_src_DCn8o9a0_es && !module_src_DCn8o9a0_es.nodeType && module_src_DCn8o9a0_es;
196025
196200
  Buffer4 = freeModule && freeModule.exports === freeExports ? _root_default.Buffer : undefined;
196026
196201
  allocUnsafe = Buffer4 ? Buffer4.allocUnsafe : undefined;
196027
196202
  _cloneBuffer_default = cloneBuffer;
@@ -203673,8 +203848,8 @@ var init_zipper_Cnk_HjM2_es = __esm(() => {
203673
203848
 
203674
203849
  // ../../packages/superdoc/dist/super-editor.es.js
203675
203850
  var init_super_editor_es = __esm(() => {
203676
- init_src_10daZ2Cr_es();
203677
- init_SuperConverter_CRrxAa8F_es();
203851
+ init_src_DCn8o9a0_es();
203852
+ init_SuperConverter_BJBbuXuZ_es();
203678
203853
  init_jszip_ChlR43oI_es();
203679
203854
  init_xml_js_DLE8mr0n_es();
203680
203855
  init_constants_Dw0kAsLd_es();
@@ -236829,6 +237004,66 @@ function extractFillColor2(spPr, style3) {
236829
237004
  }
236830
237005
  return null;
236831
237006
  }
237007
+ function extractCustomGeometry2(spPr) {
237008
+ const custGeom = spPr?.elements?.find((el) => el.name === "a:custGeom");
237009
+ if (!custGeom)
237010
+ return null;
237011
+ const pathLst = custGeom.elements?.find((el) => el.name === "a:pathLst");
237012
+ if (!pathLst?.elements)
237013
+ return null;
237014
+ const paths = pathLst.elements.filter((el) => el.name === "a:path").map((pathEl) => {
237015
+ const w = parseInt(pathEl.attributes?.["w"] || "0", 10);
237016
+ const h3 = parseInt(pathEl.attributes?.["h"] || "0", 10);
237017
+ const d = convertDrawingMLPathToSvg2(pathEl);
237018
+ return { d, w, h: h3 };
237019
+ }).filter((p4) => p4.d);
237020
+ if (paths.length === 0)
237021
+ return null;
237022
+ return { paths };
237023
+ }
237024
+ function convertDrawingMLPathToSvg2(pathEl) {
237025
+ if (!pathEl?.elements)
237026
+ return "";
237027
+ const parts = [];
237028
+ for (const cmd of pathEl.elements) {
237029
+ switch (cmd.name) {
237030
+ case "a:moveTo": {
237031
+ const pt = cmd.elements?.find((el) => el.name === "a:pt");
237032
+ if (pt) {
237033
+ parts.push(`M ${pt.attributes?.["x"] || 0} ${pt.attributes?.["y"] || 0}`);
237034
+ }
237035
+ break;
237036
+ }
237037
+ case "a:lnTo": {
237038
+ const pt = cmd.elements?.find((el) => el.name === "a:pt");
237039
+ if (pt) {
237040
+ parts.push(`L ${pt.attributes?.["x"] || 0} ${pt.attributes?.["y"] || 0}`);
237041
+ }
237042
+ break;
237043
+ }
237044
+ case "a:cubicBezTo": {
237045
+ const pts = cmd.elements?.filter((el) => el.name === "a:pt") || [];
237046
+ if (pts.length === 3) {
237047
+ 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}`);
237048
+ }
237049
+ break;
237050
+ }
237051
+ case "a:quadBezTo": {
237052
+ const pts = cmd.elements?.filter((el) => el.name === "a:pt") || [];
237053
+ if (pts.length === 2) {
237054
+ parts.push(`Q ${pts[0].attributes?.["x"] || 0} ${pts[0].attributes?.["y"] || 0} ` + `${pts[1].attributes?.["x"] || 0} ${pts[1].attributes?.["y"] || 0}`);
237055
+ }
237056
+ break;
237057
+ }
237058
+ case "a:close":
237059
+ parts.push("Z");
237060
+ break;
237061
+ default:
237062
+ break;
237063
+ }
237064
+ }
237065
+ return parts.join(" ");
237066
+ }
236832
237067
  function extractGradientFill2(gradFill) {
236833
237068
  const gradient = {
236834
237069
  type: "gradient",
@@ -244096,7 +244331,17 @@ function extractTextFromTextBox2(textBoxContent, bodyPr, params3 = {}) {
244096
244331
  wrap: wrap6
244097
244332
  };
244098
244333
  }
244099
- function getVectorShape2({ params: params3, node: node4, graphicData, size: size3, marginOffset, anchorData, wrap: wrap6, isAnchor }) {
244334
+ function getVectorShape2({
244335
+ params: params3,
244336
+ node: node4,
244337
+ graphicData,
244338
+ size: size3,
244339
+ marginOffset,
244340
+ anchorData,
244341
+ wrap: wrap6,
244342
+ isAnchor,
244343
+ customGeometry
244344
+ }) {
244100
244345
  const schemaAttrs = {};
244101
244346
  const drawingNode = params3.nodes?.[0];
244102
244347
  if (drawingNode?.name === "w:drawing") {
@@ -244112,10 +244357,15 @@ function getVectorShape2({ params: params3, node: node4, graphicData, size: size
244112
244357
  }
244113
244358
  const prstGeom = spPr.elements?.find((el) => el.name === "a:prstGeom");
244114
244359
  const shapeKind = prstGeom?.attributes?.["prst"];
244115
- if (!shapeKind) {
244116
- console.warn("Shape kind not found");
244117
- }
244118
244360
  schemaAttrs.kind = shapeKind;
244361
+ if (customGeometry) {
244362
+ schemaAttrs.customGeometry = customGeometry;
244363
+ } else if (!shapeKind) {
244364
+ const extracted = extractCustomGeometry2(spPr);
244365
+ if (extracted) {
244366
+ schemaAttrs.customGeometry = extracted;
244367
+ }
244368
+ }
244119
244369
  const width = size3?.width ?? DEFAULT_SHAPE_WIDTH2;
244120
244370
  const height = size3?.height ?? DEFAULT_SHAPE_HEIGHT2;
244121
244371
  const xfrm = spPr.elements?.find((el) => el.name === "a:xfrm");
@@ -244236,8 +244486,19 @@ var DRAWING_XML_TAG2 = "w:drawing", SHAPE_URI2 = "http://schemas.microsoft.com/o
244236
244486
  const spPr = wsp.elements.find((el) => el.name === "wps:spPr");
244237
244487
  const prstGeom = spPr?.elements.find((el) => el.name === "a:prstGeom");
244238
244488
  const shapeType = prstGeom?.attributes["prst"];
244239
- if (shapeType) {
244240
- const result = getVectorShape2({ params: params3, node: node4, graphicData, size: size3, marginOffset, anchorData, wrap: wrap6, isAnchor });
244489
+ const custGeom = !shapeType ? extractCustomGeometry2(spPr) : null;
244490
+ if (shapeType || custGeom) {
244491
+ const result = getVectorShape2({
244492
+ params: params3,
244493
+ node: node4,
244494
+ graphicData,
244495
+ size: size3,
244496
+ marginOffset,
244497
+ anchorData,
244498
+ wrap: wrap6,
244499
+ isAnchor,
244500
+ customGeometry: custGeom
244501
+ });
244241
244502
  if (result?.attrs && isHidden2) {
244242
244503
  result.attrs.hidden = true;
244243
244504
  }
@@ -244294,6 +244555,7 @@ var DRAWING_XML_TAG2 = "w:drawing", SHAPE_URI2 = "http://schemas.microsoft.com/o
244294
244555
  return null;
244295
244556
  const prstGeom = spPr.elements?.find((el) => el.name === "a:prstGeom");
244296
244557
  const shapeKind = prstGeom?.attributes?.["prst"];
244558
+ const customGeom = !shapeKind ? extractCustomGeometry2(spPr) : null;
244297
244559
  const shapeXfrm = spPr.elements?.find((el) => el.name === "a:xfrm");
244298
244560
  const shapeOff = shapeXfrm?.elements?.find((el) => el.name === "a:off");
244299
244561
  const shapeExt = shapeXfrm?.elements?.find((el) => el.name === "a:ext");
@@ -244340,6 +244602,7 @@ var DRAWING_XML_TAG2 = "w:drawing", SHAPE_URI2 = "http://schemas.microsoft.com/o
244340
244602
  shapeType: "vectorShape",
244341
244603
  attrs: {
244342
244604
  kind: shapeKind,
244605
+ customGeometry: customGeom || undefined,
244343
244606
  x,
244344
244607
  y: y2,
244345
244608
  width,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.2.0-next.20",
3
+ "version": "0.2.0-next.22",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -20,19 +20,19 @@
20
20
  "@types/node": "22.19.2",
21
21
  "typescript": "^5.9.2",
22
22
  "@superdoc/document-api": "0.0.1",
23
- "@superdoc/super-editor": "0.0.1",
24
- "superdoc": "1.16.0"
23
+ "superdoc": "1.16.0",
24
+ "@superdoc/super-editor": "0.0.1"
25
25
  },
26
26
  "module": "src/index.ts",
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
30
  "optionalDependencies": {
31
- "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.20",
32
- "@superdoc-dev/cli-darwin-x64": "0.2.0-next.20",
33
- "@superdoc-dev/cli-linux-x64": "0.2.0-next.20",
34
- "@superdoc-dev/cli-windows-x64": "0.2.0-next.20",
35
- "@superdoc-dev/cli-linux-arm64": "0.2.0-next.20"
31
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.22",
32
+ "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.22",
33
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.22",
34
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.22",
35
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.22"
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "bun run src/index.ts",