@superdoc-dev/cli 0.3.0-next.19 → 0.3.0-next.20

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 +73 -22
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -39076,7 +39076,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
39076
39076
  emptyOptions2 = {};
39077
39077
  });
39078
39078
 
39079
- // ../../packages/superdoc/dist/chunks/SuperConverter-hvBoS9gB.es.js
39079
+ // ../../packages/superdoc/dist/chunks/SuperConverter-CW9LgOv_.es.js
39080
39080
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
39081
39081
  const fieldValue = extension$1.config[field];
39082
39082
  if (typeof fieldValue === "function")
@@ -62650,9 +62650,9 @@ function buildHlinkClickElement(attrs, hlinkRId) {
62650
62650
  attributes: hlinkAttrs
62651
62651
  };
62652
62652
  }
62653
- function buildDocPrElement(attrs, imageName, hlinkRId) {
62653
+ function buildDocPrElement(attrs, imageName, hlinkRId, drawingId) {
62654
62654
  const docPrAttrs = {
62655
- id: attrs.id || 0,
62655
+ id: drawingId,
62656
62656
  name: attrs.alt || `Picture ${imageName}`
62657
62657
  };
62658
62658
  if (!attrs.decorative && attrs.title)
@@ -62682,7 +62682,7 @@ function buildDocPrElement(attrs, imageName, hlinkRId) {
62682
62682
  ...children.length ? { elements: children } : {}
62683
62683
  };
62684
62684
  }
62685
- function buildNvPicPrElement(attrs, imageName, hlinkRId) {
62685
+ function buildNvPicPrElement(attrs, imageName, hlinkRId, drawingId) {
62686
62686
  const cNvPrChildren = [];
62687
62687
  const hlinkEl = buildHlinkClickElement(attrs, hlinkRId);
62688
62688
  if (hlinkEl)
@@ -62692,7 +62692,7 @@ function buildNvPicPrElement(attrs, imageName, hlinkRId) {
62692
62692
  elements: [{
62693
62693
  name: "pic:cNvPr",
62694
62694
  attributes: {
62695
- id: attrs.id || 0,
62695
+ id: drawingId,
62696
62696
  name: attrs.alt || `Picture ${imageName}`
62697
62697
  },
62698
62698
  ...cNvPrChildren.length ? { elements: cNvPrChildren } : {}
@@ -62841,7 +62841,9 @@ function translateShapeGroup(params) {
62841
62841
  });
62842
62842
  }
62843
62843
  function mergeDrawingChildren({ order: order2, generated, original }) {
62844
- return mergeWithOrder(order2, groupByName(generated), groupByIndex(original));
62844
+ const merged = mergeWithOrder(order2, groupByName(generated), groupByIndex(original));
62845
+ fixZeroDrawingIds(merged, generated);
62846
+ return merged;
62845
62847
  }
62846
62848
  function groupByIndex(entries = []) {
62847
62849
  const map3 = /* @__PURE__ */ new Map;
@@ -62900,6 +62902,17 @@ function groupByName(nodes = []) {
62900
62902
  });
62901
62903
  return map3;
62902
62904
  }
62905
+ function fixZeroDrawingIds(merged, generated) {
62906
+ const validId = generated?.find((el) => el?.name === "wp:docPr")?.attributes?.id;
62907
+ if (!validId || !(Number(validId) > 0))
62908
+ return;
62909
+ const docPr = merged.find((el) => el?.name === "wp:docPr");
62910
+ if (docPr?.attributes && !(Number(docPr.attributes.id) > 0))
62911
+ docPr.attributes.id = validId;
62912
+ const cNvPr = merged.find((el) => el?.name === "a:graphic")?.elements?.find((el) => el?.name === "a:graphicData")?.elements?.find((el) => el?.name === "pic:pic")?.elements?.find((el) => el?.name === "pic:nvPicPr")?.elements?.find((el) => el?.name === "pic:cNvPr");
62913
+ if (cNvPr?.attributes && !(Number(cNvPr.attributes.id) > 0))
62914
+ cNvPr.attributes.id = validId;
62915
+ }
62903
62916
  function translateAnchorNode(params) {
62904
62917
  const { attrs } = params.node;
62905
62918
  const anchorElements = [];
@@ -62960,6 +62973,8 @@ function translateAnchorNode(params) {
62960
62973
  });
62961
62974
  }
62962
62975
  const nodeElements = translateImageNode(params);
62976
+ if (!nodeElements?.elements?.some((el) => el?.name === "wp:extent"))
62977
+ return nodeElements;
62963
62978
  const inlineAttrs = {
62964
62979
  ...attrs.originalAttributes || {},
62965
62980
  ...nodeElements.attributes || {}
@@ -63069,6 +63084,8 @@ function handleInlineNode(params) {
63069
63084
  function translateInlineNode(params) {
63070
63085
  const { attrs } = params.node;
63071
63086
  const nodeElements = translateImageNode(params);
63087
+ if (!nodeElements?.elements?.some((el) => el?.name === "wp:extent"))
63088
+ return nodeElements;
63072
63089
  const inlineAttrs = {
63073
63090
  ...attrs.originalAttributes || {},
63074
63091
  ...nodeElements.attributes || {}
@@ -63131,9 +63148,12 @@ function decode$46(params) {
63131
63148
  return null;
63132
63149
  if (node3.type === "chart" && node3.attrs.originalXml)
63133
63150
  return wrapTextInRun(carbonCopy(node3.attrs.originalXml), []);
63151
+ const resultNode = (node3.attrs.isAnchor ? translator$197 : translator$198).decode(params);
63152
+ if (!resultNode || resultNode.name !== "wp:inline" && resultNode.name !== "wp:anchor")
63153
+ return resultNode;
63134
63154
  return wrapTextInRun({
63135
63155
  name: "w:drawing",
63136
- elements: [(node3.attrs.isAnchor ? translator$197 : translator$198).decode(params)]
63156
+ elements: [resultNode]
63137
63157
  }, []);
63138
63158
  }
63139
63159
  function getTextNodeForExport(text$2, marks, params) {
@@ -78730,6 +78750,7 @@ var isRegExp = (value) => {
78730
78750
  }
78731
78751
  });
78732
78752
  const hlinkRId = resolveHyperlinkRId(attrs, params);
78753
+ const drawingId = attrs.id && Number(attrs.id) > 0 ? attrs.id : Math.max(1, parseInt(generateDocxRandomId(), 16));
78733
78754
  return {
78734
78755
  attributes: inlineAttrs,
78735
78756
  elements: [
@@ -78744,7 +78765,7 @@ var isRegExp = (value) => {
78744
78765
  name: "wp:effectExtent",
78745
78766
  attributes: effectExtentAttrs
78746
78767
  },
78747
- buildDocPrElement(attrs, imageName, hlinkRId),
78768
+ buildDocPrElement(attrs, imageName, hlinkRId, drawingId),
78748
78769
  {
78749
78770
  name: "wp:cNvGraphicFramePr",
78750
78771
  elements: [{
@@ -78765,7 +78786,7 @@ var isRegExp = (value) => {
78765
78786
  name: "pic:pic",
78766
78787
  attributes: { "xmlns:pic": pictureXmlns },
78767
78788
  elements: [
78768
- buildNvPicPrElement(attrs, imageName, hlinkRId),
78789
+ buildNvPicPrElement(attrs, imageName, hlinkRId, drawingId),
78769
78790
  {
78770
78791
  name: "pic:blipFill",
78771
78792
  elements: [
@@ -82522,7 +82543,7 @@ var isRegExp = (value) => {
82522
82543
  state.kern = kernNode.attributes["w:val"];
82523
82544
  }
82524
82545
  }, SuperConverter;
82525
- var init_SuperConverter_hvBoS9gB_es = __esm(() => {
82546
+ var init_SuperConverter_CW9LgOv__es = __esm(() => {
82526
82547
  init_rolldown_runtime_B2q5OVn9_es();
82527
82548
  init_jszip_ChlR43oI_es();
82528
82549
  init_xml_js_BtmJ6bNs_es();
@@ -144386,7 +144407,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
144386
144407
  init_remark_gfm_z_sDF4ss_es();
144387
144408
  });
144388
144409
 
144389
- // ../../packages/superdoc/dist/chunks/src-B23kCZxx.es.js
144410
+ // ../../packages/superdoc/dist/chunks/src-C3vsNW1f.es.js
144390
144411
  function deleteProps(obj, propOrProps) {
144391
144412
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
144392
144413
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -225047,9 +225068,9 @@ var Node$13 = class Node$14 {
225047
225068
  return false;
225048
225069
  return Boolean(checker(attrs));
225049
225070
  }, SuperToolbar, ICONS, TEXTS, tableActionsOptions;
225050
- var init_src_B23kCZxx_es = __esm(() => {
225071
+ var init_src_C3vsNW1f_es = __esm(() => {
225051
225072
  init_rolldown_runtime_B2q5OVn9_es();
225052
- init_SuperConverter_hvBoS9gB_es();
225073
+ init_SuperConverter_CW9LgOv__es();
225053
225074
  init_jszip_ChlR43oI_es();
225054
225075
  init_uuid_qzgm05fK_es();
225055
225076
  init_constants_ep1_Gwqi_es();
@@ -258135,8 +258156,8 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
258135
258156
 
258136
258157
  // ../../packages/superdoc/dist/super-editor.es.js
258137
258158
  var init_super_editor_es = __esm(() => {
258138
- init_src_B23kCZxx_es();
258139
- init_SuperConverter_hvBoS9gB_es();
258159
+ init_src_C3vsNW1f_es();
258160
+ init_SuperConverter_CW9LgOv__es();
258140
258161
  init_jszip_ChlR43oI_es();
258141
258162
  init_xml_js_BtmJ6bNs_es();
258142
258163
  init_constants_ep1_Gwqi_es();
@@ -309488,9 +309509,9 @@ function buildHlinkClickElement2(attrs, hlinkRId) {
309488
309509
  }
309489
309510
  return { name: "a:hlinkClick", attributes: hlinkAttrs };
309490
309511
  }
309491
- function buildDocPrElement2(attrs, imageName, hlinkRId) {
309512
+ function buildDocPrElement2(attrs, imageName, hlinkRId, drawingId) {
309492
309513
  const docPrAttrs = {
309493
- id: attrs.id || 0,
309514
+ id: drawingId,
309494
309515
  name: attrs.alt || `Picture ${imageName}`
309495
309516
  };
309496
309517
  if (!attrs.decorative && attrs.title) {
@@ -309523,7 +309544,7 @@ function buildDocPrElement2(attrs, imageName, hlinkRId) {
309523
309544
  ...children.length ? { elements: children } : {}
309524
309545
  };
309525
309546
  }
309526
- function buildNvPicPrElement2(attrs, imageName, hlinkRId) {
309547
+ function buildNvPicPrElement2(attrs, imageName, hlinkRId, drawingId) {
309527
309548
  const cNvPrChildren = [];
309528
309549
  const hlinkEl = buildHlinkClickElement2(attrs, hlinkRId);
309529
309550
  if (hlinkEl)
@@ -309534,7 +309555,7 @@ function buildNvPicPrElement2(attrs, imageName, hlinkRId) {
309534
309555
  {
309535
309556
  name: "pic:cNvPr",
309536
309557
  attributes: {
309537
- id: attrs.id || 0,
309558
+ id: drawingId,
309538
309559
  name: attrs.alt || `Picture ${imageName}`
309539
309560
  },
309540
309561
  ...cNvPrChildren.length ? { elements: cNvPrChildren } : {}
@@ -309792,6 +309813,7 @@ var DECORATIVE_EXT_URI2 = "{C183D7F6-B498-43B3-948B-1728B52AA6E4}", DECORATIVE_N
309792
309813
  });
309793
309814
  }
309794
309815
  const hlinkRId = resolveHyperlinkRId2(attrs, params3);
309816
+ const drawingId = attrs.id && Number(attrs.id) > 0 ? attrs.id : Math.max(1, parseInt(generateDocxRandomId2(), 16));
309795
309817
  return {
309796
309818
  attributes: inlineAttrs,
309797
309819
  elements: [
@@ -309806,7 +309828,7 @@ var DECORATIVE_EXT_URI2 = "{C183D7F6-B498-43B3-948B-1728B52AA6E4}", DECORATIVE_N
309806
309828
  name: "wp:effectExtent",
309807
309829
  attributes: effectExtentAttrs
309808
309830
  },
309809
- buildDocPrElement2(attrs, imageName, hlinkRId),
309831
+ buildDocPrElement2(attrs, imageName, hlinkRId, drawingId),
309810
309832
  {
309811
309833
  name: "wp:cNvGraphicFramePr",
309812
309834
  elements: [
@@ -309831,7 +309853,7 @@ var DECORATIVE_EXT_URI2 = "{C183D7F6-B498-43B3-948B-1728B52AA6E4}", DECORATIVE_N
309831
309853
  name: "pic:pic",
309832
309854
  attributes: { "xmlns:pic": pictureXmlns },
309833
309855
  elements: [
309834
- buildNvPicPrElement2(attrs, imageName, hlinkRId),
309856
+ buildNvPicPrElement2(attrs, imageName, hlinkRId, drawingId),
309835
309857
  {
309836
309858
  name: "pic:blipFill",
309837
309859
  elements: [
@@ -309906,7 +309928,9 @@ var init_decode_image_node_helpers = __esm(() => {
309906
309928
  function mergeDrawingChildren2({ order: order4, generated, original }) {
309907
309929
  const genQueues = groupByName2(generated);
309908
309930
  const originalsByIndex = groupByIndex2(original);
309909
- return mergeWithOrder2(order4, genQueues, originalsByIndex);
309931
+ const merged = mergeWithOrder2(order4, genQueues, originalsByIndex);
309932
+ fixZeroDrawingIds2(merged, generated);
309933
+ return merged;
309910
309934
  }
309911
309935
  function groupByIndex2(entries = []) {
309912
309936
  const map9 = new Map;
@@ -309967,6 +309991,24 @@ function groupByName2(nodes = []) {
309967
309991
  });
309968
309992
  return map9;
309969
309993
  }
309994
+ function fixZeroDrawingIds2(merged, generated) {
309995
+ const genDocPr = generated?.find((el) => el?.name === "wp:docPr");
309996
+ const validId = genDocPr?.attributes?.id;
309997
+ if (!validId || !(Number(validId) > 0))
309998
+ return;
309999
+ const docPr = merged.find((el) => el?.name === "wp:docPr");
310000
+ if (docPr?.attributes && !(Number(docPr.attributes.id) > 0)) {
310001
+ docPr.attributes.id = validId;
310002
+ }
310003
+ const graphic = merged.find((el) => el?.name === "a:graphic");
310004
+ const graphicData = graphic?.elements?.find((el) => el?.name === "a:graphicData");
310005
+ const pic = graphicData?.elements?.find((el) => el?.name === "pic:pic");
310006
+ const nvPicPr = pic?.elements?.find((el) => el?.name === "pic:nvPicPr");
310007
+ const cNvPr = nvPicPr?.elements?.find((el) => el?.name === "pic:cNvPr");
310008
+ if (cNvPr?.attributes && !(Number(cNvPr.attributes.id) > 0)) {
310009
+ cNvPr.attributes.id = validId;
310010
+ }
310011
+ }
309970
310012
  var init_merge_drawing_children = () => {};
309971
310013
 
309972
310014
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/anchor/helpers/translate-anchor-node.js
@@ -310023,6 +310065,9 @@ function translateAnchorNode2(params3) {
310023
310065
  });
310024
310066
  }
310025
310067
  const nodeElements = translateImageNode2(params3);
310068
+ if (!nodeElements?.elements?.some((el) => el?.name === "wp:extent")) {
310069
+ return nodeElements;
310070
+ }
310026
310071
  const inlineAttrs = {
310027
310072
  ...attrs.originalAttributes || {},
310028
310073
  ...nodeElements.attributes || {}
@@ -310198,6 +310243,9 @@ var init_handle_inline_node = __esm(() => {
310198
310243
  function translateInlineNode2(params3) {
310199
310244
  const { attrs } = params3.node;
310200
310245
  const nodeElements = translateImageNode2(params3);
310246
+ if (!nodeElements?.elements?.some((el) => el?.name === "wp:extent")) {
310247
+ return nodeElements;
310248
+ }
310201
310249
  const inlineAttrs = {
310202
310250
  ...attrs.originalAttributes || {},
310203
310251
  ...nodeElements.attributes || {}
@@ -310293,6 +310341,9 @@ function decode38(params3) {
310293
310341
  }
310294
310342
  const childTranslator = node4.attrs.isAnchor ? translator151 : translator152;
310295
310343
  const resultNode = childTranslator.decode(params3);
310344
+ if (!resultNode || resultNode.name !== "wp:inline" && resultNode.name !== "wp:anchor") {
310345
+ return resultNode;
310346
+ }
310296
310347
  return wrapTextInRun2({
310297
310348
  name: "w:drawing",
310298
310349
  elements: [resultNode]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.3.0-next.19",
3
+ "version": "0.3.0-next.20",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -20,21 +20,21 @@
20
20
  "@types/bun": "^1.3.8",
21
21
  "@types/node": "22.19.2",
22
22
  "typescript": "^5.9.2",
23
- "@superdoc/pm-adapter": "0.0.0",
24
23
  "@superdoc/document-api": "0.0.1",
25
- "@superdoc/super-editor": "0.0.1",
26
- "superdoc": "1.19.0"
24
+ "@superdoc/pm-adapter": "0.0.0",
25
+ "superdoc": "1.19.0",
26
+ "@superdoc/super-editor": "0.0.1"
27
27
  },
28
28
  "module": "src/index.ts",
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
32
  "optionalDependencies": {
33
- "@superdoc-dev/cli-darwin-arm64": "0.3.0-next.19",
34
- "@superdoc-dev/cli-darwin-x64": "0.3.0-next.19",
35
- "@superdoc-dev/cli-linux-x64": "0.3.0-next.19",
36
- "@superdoc-dev/cli-windows-x64": "0.3.0-next.19",
37
- "@superdoc-dev/cli-linux-arm64": "0.3.0-next.19"
33
+ "@superdoc-dev/cli-darwin-arm64": "0.3.0-next.20",
34
+ "@superdoc-dev/cli-darwin-x64": "0.3.0-next.20",
35
+ "@superdoc-dev/cli-linux-x64": "0.3.0-next.20",
36
+ "@superdoc-dev/cli-linux-arm64": "0.3.0-next.20",
37
+ "@superdoc-dev/cli-windows-x64": "0.3.0-next.20"
38
38
  },
39
39
  "scripts": {
40
40
  "dev": "bun run src/index.ts",