@harbour-enterprises/superdoc 0.23.0-next.14 → 0.23.0-next.15

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 (36) hide show
  1. package/dist/chunks/{PdfViewer-D3cgkd9j.cjs → PdfViewer-1MZFKzXW.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BaaVD5bX.es.js → PdfViewer-NEyAcxt7.es.js} +1 -1
  3. package/dist/chunks/{eventemitter3-CR2eBWft.es.js → eventemitter3-BWEnUdTY.es.js} +1 -1
  4. package/dist/chunks/{eventemitter3-DSRogsNq.cjs → eventemitter3-DkXkH2rT.cjs} +1 -1
  5. package/dist/chunks/{index-CAHkANZY.cjs → index-CGtSnLpQ.cjs} +160 -465
  6. package/dist/chunks/{index-CESuSQe2.es.js → index-DAT3_wPu.es.js} +27 -332
  7. package/dist/chunks/{super-editor.es-BYutUrPg.cjs → super-editor.es-C7TgrpFl.cjs} +616 -116
  8. package/dist/chunks/{super-editor.es-BKb7p4fi.es.js → super-editor.es-Ctq_imo8.es.js} +616 -116
  9. package/dist/chunks/{xml-js-CWV8R-ek.cjs → xml-js-D_ZIzxu0.cjs} +1 -1
  10. package/dist/chunks/xml-js-Dx4FIjnp.es.js +2 -0
  11. package/dist/core/types/index.d.ts +19 -1
  12. package/dist/core/types/index.d.ts.map +1 -1
  13. package/dist/super-editor/ai-writer.es.js +2 -2
  14. package/dist/super-editor/chunks/{converter-DD7uNz2k.js → converter-vEmAnrOg.js} +665 -249
  15. package/dist/super-editor/chunks/{docx-zipper-DraPR30Z.js → docx-zipper-DA00N7eN.js} +1 -1
  16. package/dist/super-editor/chunks/{editor-xzhKWRFZ.js → editor-Das_uwlq.js} +94 -10
  17. package/dist/super-editor/chunks/{toolbar-D6SJTVWT.js → toolbar-CKugkxNQ.js} +2 -2
  18. package/dist/super-editor/converter.es.js +1 -1
  19. package/dist/super-editor/docx-zipper.es.js +2 -2
  20. package/dist/super-editor/editor.es.js +3 -3
  21. package/dist/super-editor/file-zipper.es.js +1 -1
  22. package/dist/super-editor/src/core/Editor.d.ts +57 -3
  23. package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +58 -2
  24. package/dist/super-editor/src/core/super-converter/exporter-docx-defs.d.ts +28 -39
  25. package/dist/super-editor/super-editor.es.js +6 -6
  26. package/dist/super-editor/toolbar.es.js +2 -2
  27. package/dist/super-editor.cjs +1 -1
  28. package/dist/super-editor.es.js +1 -1
  29. package/dist/superdoc.cjs +2 -3
  30. package/dist/superdoc.es.js +2 -3
  31. package/dist/superdoc.umd.js +641 -446
  32. package/dist/superdoc.umd.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunks/xml-js-Bbc0NeKa.es.js +0 -2
  35. package/dist/chunks/{jszip-DAXEPCUv.es.js → jszip-BDk3JBqp.es.js} +3 -3
  36. package/dist/chunks/{jszip-B4LDL19y.cjs → jszip-u4dvXAKa.cjs} +3 -3
@@ -7752,11 +7752,7 @@
7752
7752
  var __accessCheck$2 = (obj, member, msg2) => member.has(obj) || __typeError$2("Cannot " + msg2);
7753
7753
  var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7754
7754
  var __privateMethod$2 = (obj, member, method) => (__accessCheck$2(obj, member, "access private method"), method);
7755
- var _a, _DocxExporter_instances, generate_xml_as_list_fn, replaceSpecialCharacters_fn, generateXml_fn, _SuperConverter_instances, exportNumberingFile_fn, prepareCommentsXmlFilesForExport_fn, exportProcessHeadersFooters_fn, exportProcessNewRelationships_fn, exportProcessMediaFiles_fn;
7756
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
7757
- function getDefaultExportFromCjs$1$1(x) {
7758
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
7759
- }
7755
+ var _a, _DocxExporter_instances, generate_xml_as_list_fn, replaceSpecialCharacters_fn, generateXml_fn, _SuperConverter_instances, generateDocumentHash_fn, exportNumberingFile_fn, prepareCommentsXmlFilesForExport_fn, exportProcessHeadersFooters_fn, exportProcessNewRelationships_fn, exportProcessMediaFiles_fn;
7760
7756
  var buffer = {};
7761
7757
  var base64Js = {};
7762
7758
  base64Js.byteLength = byteLength;
@@ -9523,6 +9519,10 @@
9523
9519
  }
9524
9520
  })(buffer);
9525
9521
  const Buffer2 = buffer.Buffer;
9522
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
9523
+ function getDefaultExportFromCjs$2(x) {
9524
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
9525
+ }
9526
9526
  var sax = {};
9527
9527
  var events$2 = { exports: {} };
9528
9528
  var hasRequiredEvents;
@@ -9925,7 +9925,7 @@
9925
9925
  }
9926
9926
  return inherits_browser.exports;
9927
9927
  }
9928
- function getDefaultExportFromCjs$2(x) {
9928
+ function getDefaultExportFromCjs$1(x) {
9929
9929
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
9930
9930
  }
9931
9931
  var browser$1 = { exports: {} };
@@ -10086,7 +10086,7 @@
10086
10086
  return 0;
10087
10087
  };
10088
10088
  var browserExports = browser$1.exports;
10089
- const process$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$2(browserExports);
10089
+ const process$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(browserExports);
10090
10090
  var streamBrowser;
10091
10091
  var hasRequiredStreamBrowser;
10092
10092
  function requireStreamBrowser() {
@@ -19071,7 +19071,7 @@
19071
19071
  return lib;
19072
19072
  }
19073
19073
  var libExports = requireLib();
19074
- const xmljs = /* @__PURE__ */ getDefaultExportFromCjs$1$1(libExports);
19074
+ const xmljs = /* @__PURE__ */ getDefaultExportFromCjs$2(libExports);
19075
19075
  var getRandomValues$1;
19076
19076
  var rnds8$1 = new Uint8Array(16);
19077
19077
  function rng$1() {
@@ -19106,6 +19106,306 @@
19106
19106
  rnds[8] = rnds[8] & 63 | 128;
19107
19107
  return stringify$1(rnds);
19108
19108
  }
19109
+ function getDefaultExportFromCjs$3(x) {
19110
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
19111
+ }
19112
+ const CRC_TABLE = new Int32Array([
19113
+ 0,
19114
+ 1996959894,
19115
+ 3993919788,
19116
+ 2567524794,
19117
+ 124634137,
19118
+ 1886057615,
19119
+ 3915621685,
19120
+ 2657392035,
19121
+ 249268274,
19122
+ 2044508324,
19123
+ 3772115230,
19124
+ 2547177864,
19125
+ 162941995,
19126
+ 2125561021,
19127
+ 3887607047,
19128
+ 2428444049,
19129
+ 498536548,
19130
+ 1789927666,
19131
+ 4089016648,
19132
+ 2227061214,
19133
+ 450548861,
19134
+ 1843258603,
19135
+ 4107580753,
19136
+ 2211677639,
19137
+ 325883990,
19138
+ 1684777152,
19139
+ 4251122042,
19140
+ 2321926636,
19141
+ 335633487,
19142
+ 1661365465,
19143
+ 4195302755,
19144
+ 2366115317,
19145
+ 997073096,
19146
+ 1281953886,
19147
+ 3579855332,
19148
+ 2724688242,
19149
+ 1006888145,
19150
+ 1258607687,
19151
+ 3524101629,
19152
+ 2768942443,
19153
+ 901097722,
19154
+ 1119000684,
19155
+ 3686517206,
19156
+ 2898065728,
19157
+ 853044451,
19158
+ 1172266101,
19159
+ 3705015759,
19160
+ 2882616665,
19161
+ 651767980,
19162
+ 1373503546,
19163
+ 3369554304,
19164
+ 3218104598,
19165
+ 565507253,
19166
+ 1454621731,
19167
+ 3485111705,
19168
+ 3099436303,
19169
+ 671266974,
19170
+ 1594198024,
19171
+ 3322730930,
19172
+ 2970347812,
19173
+ 795835527,
19174
+ 1483230225,
19175
+ 3244367275,
19176
+ 3060149565,
19177
+ 1994146192,
19178
+ 31158534,
19179
+ 2563907772,
19180
+ 4023717930,
19181
+ 1907459465,
19182
+ 112637215,
19183
+ 2680153253,
19184
+ 3904427059,
19185
+ 2013776290,
19186
+ 251722036,
19187
+ 2517215374,
19188
+ 3775830040,
19189
+ 2137656763,
19190
+ 141376813,
19191
+ 2439277719,
19192
+ 3865271297,
19193
+ 1802195444,
19194
+ 476864866,
19195
+ 2238001368,
19196
+ 4066508878,
19197
+ 1812370925,
19198
+ 453092731,
19199
+ 2181625025,
19200
+ 4111451223,
19201
+ 1706088902,
19202
+ 314042704,
19203
+ 2344532202,
19204
+ 4240017532,
19205
+ 1658658271,
19206
+ 366619977,
19207
+ 2362670323,
19208
+ 4224994405,
19209
+ 1303535960,
19210
+ 984961486,
19211
+ 2747007092,
19212
+ 3569037538,
19213
+ 1256170817,
19214
+ 1037604311,
19215
+ 2765210733,
19216
+ 3554079995,
19217
+ 1131014506,
19218
+ 879679996,
19219
+ 2909243462,
19220
+ 3663771856,
19221
+ 1141124467,
19222
+ 855842277,
19223
+ 2852801631,
19224
+ 3708648649,
19225
+ 1342533948,
19226
+ 654459306,
19227
+ 3188396048,
19228
+ 3373015174,
19229
+ 1466479909,
19230
+ 544179635,
19231
+ 3110523913,
19232
+ 3462522015,
19233
+ 1591671054,
19234
+ 702138776,
19235
+ 2966460450,
19236
+ 3352799412,
19237
+ 1504918807,
19238
+ 783551873,
19239
+ 3082640443,
19240
+ 3233442989,
19241
+ 3988292384,
19242
+ 2596254646,
19243
+ 62317068,
19244
+ 1957810842,
19245
+ 3939845945,
19246
+ 2647816111,
19247
+ 81470997,
19248
+ 1943803523,
19249
+ 3814918930,
19250
+ 2489596804,
19251
+ 225274430,
19252
+ 2053790376,
19253
+ 3826175755,
19254
+ 2466906013,
19255
+ 167816743,
19256
+ 2097651377,
19257
+ 4027552580,
19258
+ 2265490386,
19259
+ 503444072,
19260
+ 1762050814,
19261
+ 4150417245,
19262
+ 2154129355,
19263
+ 426522225,
19264
+ 1852507879,
19265
+ 4275313526,
19266
+ 2312317920,
19267
+ 282753626,
19268
+ 1742555852,
19269
+ 4189708143,
19270
+ 2394877945,
19271
+ 397917763,
19272
+ 1622183637,
19273
+ 3604390888,
19274
+ 2714866558,
19275
+ 953729732,
19276
+ 1340076626,
19277
+ 3518719985,
19278
+ 2797360999,
19279
+ 1068828381,
19280
+ 1219638859,
19281
+ 3624741850,
19282
+ 2936675148,
19283
+ 906185462,
19284
+ 1090812512,
19285
+ 3747672003,
19286
+ 2825379669,
19287
+ 829329135,
19288
+ 1181335161,
19289
+ 3412177804,
19290
+ 3160834842,
19291
+ 628085408,
19292
+ 1382605366,
19293
+ 3423369109,
19294
+ 3138078467,
19295
+ 570562233,
19296
+ 1426400815,
19297
+ 3317316542,
19298
+ 2998733608,
19299
+ 733239954,
19300
+ 1555261956,
19301
+ 3268935591,
19302
+ 3050360625,
19303
+ 752459403,
19304
+ 1541320221,
19305
+ 2607071920,
19306
+ 3965973030,
19307
+ 1969922972,
19308
+ 40735498,
19309
+ 2617837225,
19310
+ 3943577151,
19311
+ 1913087877,
19312
+ 83908371,
19313
+ 2512341634,
19314
+ 3803740692,
19315
+ 2075208622,
19316
+ 213261112,
19317
+ 2463272603,
19318
+ 3855990285,
19319
+ 2094854071,
19320
+ 198958881,
19321
+ 2262029012,
19322
+ 4057260610,
19323
+ 1759359992,
19324
+ 534414190,
19325
+ 2176718541,
19326
+ 4139329115,
19327
+ 1873836001,
19328
+ 414664567,
19329
+ 2282248934,
19330
+ 4279200368,
19331
+ 1711684554,
19332
+ 285281116,
19333
+ 2405801727,
19334
+ 4167216745,
19335
+ 1634467795,
19336
+ 376229701,
19337
+ 2685067896,
19338
+ 3608007406,
19339
+ 1308918612,
19340
+ 956543938,
19341
+ 2808555105,
19342
+ 3495958263,
19343
+ 1231636301,
19344
+ 1047427035,
19345
+ 2932959818,
19346
+ 3654703836,
19347
+ 1088359270,
19348
+ 936918e3,
19349
+ 2847714899,
19350
+ 3736837829,
19351
+ 1202900863,
19352
+ 817233897,
19353
+ 3183342108,
19354
+ 3401237130,
19355
+ 1404277552,
19356
+ 615818150,
19357
+ 3134207493,
19358
+ 3453421203,
19359
+ 1423857449,
19360
+ 601450431,
19361
+ 3009837614,
19362
+ 3294710456,
19363
+ 1567103746,
19364
+ 711928724,
19365
+ 3020668471,
19366
+ 3272380065,
19367
+ 1510334235,
19368
+ 755167117
19369
+ ]);
19370
+ function ensureBuffer(input) {
19371
+ if (Buffer2.isBuffer(input)) {
19372
+ return input;
19373
+ }
19374
+ if (typeof input === "number") {
19375
+ return Buffer2.alloc(input);
19376
+ } else if (typeof input === "string") {
19377
+ return Buffer2.from(input);
19378
+ } else {
19379
+ throw new Error("input must be buffer, number, or string, received " + typeof input);
19380
+ }
19381
+ }
19382
+ function bufferizeInt(num) {
19383
+ const tmp = ensureBuffer(4);
19384
+ tmp.writeInt32BE(num, 0);
19385
+ return tmp;
19386
+ }
19387
+ function _crc32(buf, previous) {
19388
+ buf = ensureBuffer(buf);
19389
+ if (Buffer2.isBuffer(previous)) {
19390
+ previous = previous.readUInt32BE(0);
19391
+ }
19392
+ let crc = ~~previous ^ -1;
19393
+ for (var n = 0; n < buf.length; n++) {
19394
+ crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
19395
+ }
19396
+ return crc ^ -1;
19397
+ }
19398
+ function crc32() {
19399
+ return bufferizeInt(_crc32.apply(null, arguments));
19400
+ }
19401
+ crc32.signed = function() {
19402
+ return _crc32.apply(null, arguments);
19403
+ };
19404
+ crc32.unsigned = function() {
19405
+ return _crc32.apply(null, arguments) >>> 0;
19406
+ };
19407
+ var bufferCrc32 = crc32;
19408
+ const index$2 = /* @__PURE__ */ getDefaultExportFromCjs$3(bufferCrc32);
19109
19409
  function callOrGet(value, context = null, ...props) {
19110
19410
  if (typeof value === "function") {
19111
19411
  if (context) return value.bind(context)(...props);
@@ -22787,18 +23087,6 @@
22787
23087
  }
22788
23088
  ]
22789
23089
  };
22790
- const SETTINGS_CUSTOM_XML = {
22791
- elements: [
22792
- {
22793
- type: "element",
22794
- name: "w:settings",
22795
- attributes: {
22796
- "xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
22797
- },
22798
- elements: []
22799
- }
22800
- ]
22801
- };
22802
23090
  const COMMENT_REF = {
22803
23091
  type: "element",
22804
23092
  name: "w:r",
@@ -25135,15 +25423,15 @@
25135
25423
  if (base2 < 0 || $pos.parent.type.spec.isolating || !$pos.parent.canReplace($pos.index(), $pos.parent.childCount) || !innerType.type.validContent($pos.parent.content.cutByIndex($pos.index(), $pos.parent.childCount)))
25136
25424
  return false;
25137
25425
  for (let d2 = $pos.depth - 1, i2 = depth - 2; d2 > base2; d2--, i2--) {
25138
- let node = $pos.node(d2), index22 = $pos.index(d2);
25426
+ let node = $pos.node(d2), index3 = $pos.index(d2);
25139
25427
  if (node.type.spec.isolating)
25140
25428
  return false;
25141
- let rest = node.content.cutByIndex(index22, node.childCount);
25429
+ let rest = node.content.cutByIndex(index3, node.childCount);
25142
25430
  let overrideChild = typesAfter && typesAfter[i2 + 1];
25143
25431
  if (overrideChild)
25144
25432
  rest = rest.replaceChild(0, overrideChild.type.create(overrideChild.attrs));
25145
25433
  let after = typesAfter && typesAfter[i2] || node;
25146
- if (!node.canReplace(index22 + 1, node.childCount) || !after.type.validContent(rest))
25434
+ if (!node.canReplace(index3 + 1, node.childCount) || !after.type.validContent(rest))
25147
25435
  return false;
25148
25436
  }
25149
25437
  let index2 = $pos.indexAfter(base2);
@@ -37882,7 +38170,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37882
38170
  return he$2.exports;
37883
38171
  }
37884
38172
  var heExports = requireHe();
37885
- const he = /* @__PURE__ */ getDefaultExportFromCjs$1$1(heExports);
38173
+ const he = /* @__PURE__ */ getDefaultExportFromCjs$2(heExports);
37886
38174
  function translateFieldAnnotation(params2) {
37887
38175
  const { node, isFinalDoc, fieldsHighlightColor } = params2;
37888
38176
  const { attrs = {} } = node;
@@ -41020,7 +41308,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41020
41308
  fileType: filePath.split(".").pop()
41021
41309
  };
41022
41310
  });
41023
- converter.telemetry.trackFileStructure(
41311
+ const trackStructure = (documentIdentifier = null) => converter.telemetry.trackFileStructure(
41024
41312
  {
41025
41313
  totalFiles: files.length,
41026
41314
  maxDepth: Math.max(...files.map((f) => f.fileDepth)),
@@ -41028,9 +41316,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41028
41316
  files
41029
41317
  },
41030
41318
  converter.fileSource,
41031
- converter.documentId,
41319
+ converter.documentGuid ?? converter.documentId ?? null,
41320
+ documentIdentifier ?? converter.documentId ?? null,
41032
41321
  converter.documentInternalId
41033
41322
  );
41323
+ try {
41324
+ const identifierResult = converter.getDocumentIdentifier?.();
41325
+ if (identifierResult && typeof identifierResult.then === "function") {
41326
+ identifierResult.then(trackStructure).catch(() => trackStructure());
41327
+ } else {
41328
+ trackStructure(identifierResult);
41329
+ }
41330
+ } catch (error) {
41331
+ trackStructure();
41332
+ }
41034
41333
  }
41035
41334
  const nodeListHandler = defaultNodeListHandler();
41036
41335
  const bodyNode = json.elements[0].elements.find((el) => el.name === "w:body");
@@ -41581,6 +41880,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41581
41880
  this.documentInternalId = null;
41582
41881
  this.fileSource = params2?.fileSource || null;
41583
41882
  this.documentId = params2?.documentId || null;
41883
+ this.documentGuid = null;
41884
+ this.documentHash = null;
41885
+ this.documentModified = false;
41584
41886
  if (this.docx.length || this.xml) this.parseFromXml();
41585
41887
  }
41586
41888
  static getFontTableEntry(docx, fontName) {
@@ -41628,50 +41930,177 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41628
41930
  this.initialJSON = this.convertedXml["word/document.xml"];
41629
41931
  if (!this.initialJSON) this.initialJSON = this.parseXmlToJson(this.xml);
41630
41932
  this.declaration = this.initialJSON?.declaration;
41933
+ this.resolveDocumentGuid();
41631
41934
  }
41632
41935
  parseXmlToJson(xml) {
41633
41936
  const newXml = xml.replace(/(<w:t xml:space="preserve">)(\s+)(<\/w:t>)/g, "$1[[sdspace]]$2[[sdspace]]$3");
41634
41937
  return JSON.parse(xmljs.xml2json(newXml, null, 2));
41635
41938
  }
41636
- static getStoredSuperdocVersion(docx) {
41939
+ /**
41940
+ * Generic method to get a stored custom property from docx
41941
+ * @static
41942
+ * @param {Array} docx - Array of docx file objects
41943
+ * @param {string} propertyName - Name of the property to retrieve
41944
+ * @returns {string|null} The property value or null if not found
41945
+ */
41946
+ static getStoredCustomProperty(docx, propertyName) {
41637
41947
  try {
41638
41948
  const customXml = docx.find((doc2) => doc2.name === "docProps/custom.xml");
41639
- if (!customXml) return;
41949
+ if (!customXml) return null;
41640
41950
  const converter = new _SuperConverter2();
41641
41951
  const content = customXml.content;
41642
41952
  const contentJson = converter.parseXmlToJson(content);
41643
41953
  const properties = contentJson.elements.find((el) => el.name === "Properties");
41644
- if (!properties.elements) return;
41645
- const superdocVersion = properties.elements.find(
41646
- (el) => el.name === "property" && el.attributes.name === "SuperdocVersion"
41647
- );
41648
- if (!superdocVersion) return;
41649
- const version2 = superdocVersion.elements[0].elements[0].text;
41650
- return version2;
41954
+ if (!properties.elements) return null;
41955
+ const property2 = properties.elements.find((el) => el.name === "property" && el.attributes.name === propertyName);
41956
+ if (!property2) return null;
41957
+ return property2.elements[0].elements[0].text;
41651
41958
  } catch (e) {
41652
- console.warn("Error getting Superdoc version", e);
41653
- return;
41959
+ console.warn(`Error getting custom property ${propertyName}:`, e);
41960
+ return null;
41654
41961
  }
41655
41962
  }
41656
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.22.0") {
41963
+ /**
41964
+ * Generic method to set a stored custom property in docx
41965
+ * @static
41966
+ * @param {Object} docx - The docx object to store the property in
41967
+ * @param {string} propertyName - Name of the property
41968
+ * @param {string|Function} value - Value or function that returns the value
41969
+ * @param {boolean} preserveExisting - If true, won't overwrite existing values
41970
+ * @returns {string} The stored value
41971
+ */
41972
+ static setStoredCustomProperty(docx, propertyName, value, preserveExisting = false) {
41657
41973
  const customLocation = "docProps/custom.xml";
41658
- if (!docx[customLocation]) {
41659
- docx[customLocation] = generateCustomXml();
41660
- }
41661
- const customXml = docx["docProps/custom.xml"];
41662
- if (!customXml) return;
41663
- const properties = customXml.elements.find((el) => el.name === "Properties");
41974
+ if (!docx[customLocation]) docx[customLocation] = generateCustomXml();
41975
+ const customXml = docx[customLocation];
41976
+ const properties = customXml.elements?.find((el) => el.name === "Properties");
41977
+ if (!properties) return null;
41664
41978
  if (!properties.elements) properties.elements = [];
41665
- const superdocVersion = properties.elements.find(
41666
- (el) => el.name === "property" && el.attributes.name === "SuperdocVersion"
41667
- );
41668
- if (!superdocVersion) {
41669
- const newCustomXml = generateSuperdocVersion();
41670
- properties.elements.push(newCustomXml);
41979
+ let property2 = properties.elements.find((el) => el.name === "property" && el.attributes.name === propertyName);
41980
+ if (property2 && preserveExisting) {
41981
+ return property2.elements[0].elements[0].text;
41982
+ }
41983
+ const finalValue = typeof value === "function" ? value() : value;
41984
+ if (!property2) {
41985
+ const existingPids = properties.elements.filter((el) => el.attributes?.pid).map((el) => parseInt(el.attributes.pid, 10)).filter(Number.isInteger);
41986
+ const pid = existingPids.length > 0 ? Math.max(...existingPids) + 1 : 2;
41987
+ property2 = {
41988
+ type: "element",
41989
+ name: "property",
41990
+ attributes: {
41991
+ name: propertyName,
41992
+ fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
41993
+ pid
41994
+ },
41995
+ elements: [
41996
+ {
41997
+ type: "element",
41998
+ name: "vt:lpwstr",
41999
+ elements: [
42000
+ {
42001
+ type: "text",
42002
+ text: finalValue
42003
+ }
42004
+ ]
42005
+ }
42006
+ ]
42007
+ };
42008
+ properties.elements.push(property2);
41671
42009
  } else {
41672
- superdocVersion.elements[0].elements[0].elements[0].text = version2;
42010
+ property2.elements[0].elements[0].text = finalValue;
42011
+ }
42012
+ return finalValue;
42013
+ }
42014
+ static getStoredSuperdocVersion(docx) {
42015
+ return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42016
+ }
42017
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.22.0") {
42018
+ return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42019
+ }
42020
+ /**
42021
+ * Get document GUID from docx files (static method)
42022
+ * @static
42023
+ * @param {Array} docx - Array of docx file objects
42024
+ * @returns {string|null} The document GUID
42025
+ */
42026
+ static extractDocumentGuid(docx) {
42027
+ try {
42028
+ const settingsXml = docx.find((doc2) => doc2.name === "word/settings.xml");
42029
+ if (!settingsXml) return null;
42030
+ const converter = new _SuperConverter2();
42031
+ const settingsJson = converter.parseXmlToJson(settingsXml.content);
42032
+ const settings = settingsJson.elements?.[0];
42033
+ if (!settings) return null;
42034
+ const docIdElement = settings.elements?.find((el) => el.name === "w15:docId");
42035
+ if (docIdElement?.attributes?.["w15:val"]) {
42036
+ return docIdElement.attributes["w15:val"].replace(/[{}]/g, "");
42037
+ }
42038
+ } catch {
41673
42039
  }
41674
- return docx;
42040
+ return _SuperConverter2.getStoredCustomProperty(docx, "DocumentGuid");
42041
+ }
42042
+ /**
42043
+ * Get the permanent document GUID
42044
+ * @returns {string|null} The document GUID (only for modified documents)
42045
+ */
42046
+ getDocumentGuid() {
42047
+ return this.documentGuid;
42048
+ }
42049
+ /**
42050
+ * Get the SuperDoc version for this converter instance
42051
+ * @returns {string|null} The SuperDoc version or null if not available
42052
+ */
42053
+ getSuperdocVersion() {
42054
+ if (this.docx) {
42055
+ return _SuperConverter2.getStoredSuperdocVersion(this.docx);
42056
+ }
42057
+ return null;
42058
+ }
42059
+ /**
42060
+ * Resolve existing document GUID (synchronous)
42061
+ */
42062
+ resolveDocumentGuid() {
42063
+ const microsoftGuid = this.getMicrosoftDocId();
42064
+ if (microsoftGuid) {
42065
+ this.documentGuid = microsoftGuid;
42066
+ return;
42067
+ }
42068
+ const customGuid = _SuperConverter2.getStoredCustomProperty(this.docx, "DocumentGuid");
42069
+ if (customGuid) {
42070
+ this.documentGuid = customGuid;
42071
+ }
42072
+ }
42073
+ /**
42074
+ * Get Microsoft's docId from settings.xml (READ ONLY)
42075
+ */
42076
+ getMicrosoftDocId() {
42077
+ this.getDocumentInternalId();
42078
+ if (this.documentInternalId) {
42079
+ return this.documentInternalId.replace(/[{}]/g, "");
42080
+ }
42081
+ return null;
42082
+ }
42083
+ /**
42084
+ * Get document identifier (GUID or hash) - async for lazy hash generation
42085
+ */
42086
+ async getDocumentIdentifier() {
42087
+ if (this.documentGuid) {
42088
+ return this.documentGuid;
42089
+ }
42090
+ if (!this.documentHash && this.fileSource) {
42091
+ this.documentHash = await __privateMethod$2(this, _SuperConverter_instances, generateDocumentHash_fn).call(this);
42092
+ }
42093
+ return this.documentHash;
42094
+ }
42095
+ /**
42096
+ * Promote from hash to GUID on first edit
42097
+ */
42098
+ promoteToGuid() {
42099
+ if (this.documentGuid) return this.documentGuid;
42100
+ this.documentGuid = this.getMicrosoftDocId() || v4$1();
42101
+ this.documentModified = true;
42102
+ this.documentHash = null;
42103
+ return this.documentGuid;
41675
42104
  }
41676
42105
  getDocumentDefaultStyles() {
41677
42106
  const styles = this.convertedXml["word/styles.xml"];
@@ -41760,20 +42189,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41760
42189
  getDocumentInternalId() {
41761
42190
  const settingsLocation = "word/settings.xml";
41762
42191
  if (!this.convertedXml[settingsLocation]) {
41763
- this.convertedXml[settingsLocation] = SETTINGS_CUSTOM_XML;
42192
+ return;
41764
42193
  }
41765
- const settings = Object.assign({}, this.convertedXml[settingsLocation]);
41766
- if (!settings.elements[0]?.elements?.length) {
41767
- const idElement = this.createDocumentIdElement(settings);
41768
- settings.elements[0].elements = [idElement];
41769
- if (!settings.elements[0].attributes["xmlns:w15"]) {
41770
- settings.elements[0].attributes["xmlns:w15"] = "http://schemas.microsoft.com/office/word/2012/wordml";
41771
- }
41772
- this.convertedXml[settingsLocation] = settings;
42194
+ const settings = this.convertedXml[settingsLocation];
42195
+ if (!settings.elements?.[0]?.elements?.length) {
41773
42196
  return;
41774
42197
  }
41775
42198
  const w15DocId = settings.elements[0].elements.find((el) => el.name === "w15:docId");
41776
- this.documentInternalId = w15DocId?.attributes["w15:val"];
42199
+ this.documentInternalId = w15DocId?.attributes?.["w15:val"];
41777
42200
  }
41778
42201
  createDocumentIdElement() {
41779
42202
  const docId = v4$1().toUpperCase();
@@ -41862,7 +42285,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41862
42285
  this.convertedXml = { ...this.convertedXml, ...updatedXml };
41863
42286
  const headFootRels = __privateMethod$2(this, _SuperConverter_instances, exportProcessHeadersFooters_fn).call(this, { isFinalDoc });
41864
42287
  __privateMethod$2(this, _SuperConverter_instances, exportProcessNewRelationships_fn).call(this, [...params2.relationships, ...commentsRels, ...headFootRels]);
41865
- storeSuperdocVersion(this.convertedXml);
42288
+ _SuperConverter2.setStoredSuperdocVersion(this.convertedXml);
42289
+ if (this.documentModified || this.documentGuid) {
42290
+ if (!this.documentGuid) {
42291
+ this.documentGuid = this.getMicrosoftDocId() || v4$1();
42292
+ }
42293
+ _SuperConverter2.setStoredCustomProperty(this.convertedXml, "DocumentGuid", this.documentGuid, true);
42294
+ }
41866
42295
  __privateMethod$2(this, _SuperConverter_instances, exportNumberingFile_fn).call(this, params2);
41867
42296
  return xml;
41868
42297
  }
@@ -41897,8 +42326,38 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41897
42326
  });
41898
42327
  return { result, params: params2 };
41899
42328
  }
42329
+ // Deprecated methods for backward compatibility
42330
+ static getStoredSuperdocId(docx) {
42331
+ console.warn("getStoredSuperdocId is deprecated, use getDocumentGuid instead");
42332
+ return _SuperConverter2.extractDocumentGuid(docx);
42333
+ }
42334
+ static updateDocumentVersion(docx, version2) {
42335
+ console.warn("updateDocumentVersion is deprecated, use setStoredSuperdocVersion instead");
42336
+ return _SuperConverter2.setStoredSuperdocVersion(docx, version2);
42337
+ }
41900
42338
  };
41901
42339
  _SuperConverter_instances = /* @__PURE__ */ new WeakSet();
42340
+ generateDocumentHash_fn = async function() {
42341
+ if (!this.fileSource) return `HASH-${Date.now()}`;
42342
+ try {
42343
+ let buffer2;
42344
+ if (Buffer2.isBuffer(this.fileSource)) {
42345
+ buffer2 = this.fileSource;
42346
+ } else if (this.fileSource instanceof ArrayBuffer) {
42347
+ buffer2 = Buffer2.from(this.fileSource);
42348
+ } else if (this.fileSource instanceof Blob || this.fileSource instanceof File) {
42349
+ const arrayBuffer = await this.fileSource.arrayBuffer();
42350
+ buffer2 = Buffer2.from(arrayBuffer);
42351
+ } else {
42352
+ return `HASH-${Date.now()}`;
42353
+ }
42354
+ const hash2 = index$2(buffer2);
42355
+ return `HASH-${hash2.toString("hex").toUpperCase()}`;
42356
+ } catch (e) {
42357
+ console.warn("Could not generate document hash:", e);
42358
+ return `HASH-${Date.now()}`;
42359
+ }
42360
+ };
41902
42361
  exportNumberingFile_fn = function() {
41903
42362
  const numberingPath = "word/numbering.xml";
41904
42363
  let numberingXml = this.convertedXml[numberingPath];
@@ -42119,52 +42578,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42119
42578
  }));
42120
42579
  __publicField$2(_SuperConverter, "elements", /* @__PURE__ */ new Set(["w:document", "w:body", "w:p", "w:r", "w:t", "w:delText"]));
42121
42580
  let SuperConverter = _SuperConverter;
42122
- function storeSuperdocVersion(docx) {
42123
- const customLocation = "docProps/custom.xml";
42124
- if (!docx[customLocation]) docx[customLocation] = generateCustomXml();
42125
- const customXml = docx[customLocation];
42126
- const properties = customXml.elements.find((el) => el.name === "Properties");
42127
- if (!properties.elements) properties.elements = [];
42128
- const elements = properties.elements;
42129
- const cleanProperties = elements.filter((prop) => typeof prop === "object" && prop !== null).filter((prop) => {
42130
- const { attributes } = prop;
42131
- return attributes.name !== "SuperdocVersion";
42132
- });
42133
- let pid = 2;
42134
- try {
42135
- pid = cleanProperties.length ? Math.max(...elements.map((el) => el.attributes.pid)) + 1 : 2;
42136
- } catch {
42137
- }
42138
- cleanProperties.push(generateSuperdocVersion(pid));
42139
- properties.elements = cleanProperties;
42140
- return docx;
42141
- }
42142
42581
  function generateCustomXml() {
42143
42582
  return DEFAULT_CUSTOM_XML;
42144
42583
  }
42145
- function generateSuperdocVersion(pid = 2, version2 = "0.22.0") {
42146
- return {
42147
- type: "element",
42148
- name: "property",
42149
- attributes: {
42150
- name: "SuperdocVersion",
42151
- fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
42152
- pid
42153
- },
42154
- elements: [
42155
- {
42156
- type: "element",
42157
- name: "vt:lpwstr",
42158
- elements: [
42159
- {
42160
- type: "text",
42161
- text: version2
42162
- }
42163
- ]
42164
- }
42165
- ]
42166
- };
42167
- }
42168
42584
  function commonjsRequire(path) {
42169
42585
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
42170
42586
  }
@@ -44480,7 +44896,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
44480
44896
  return jszip_min.exports;
44481
44897
  }
44482
44898
  var jszip_minExports = requireJszip_min();
44483
- const JSZip = /* @__PURE__ */ getDefaultExportFromCjs$1$1(jszip_minExports);
44899
+ const JSZip = /* @__PURE__ */ getDefaultExportFromCjs$2(jszip_minExports);
44484
44900
  const isXmlLike = (name) => /\.xml$|\.rels$/i.test(name);
44485
44901
  function sniffEncoding(u8) {
44486
44902
  if (u8.length >= 2) {
@@ -59240,19 +59656,34 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59240
59656
  * @returns {string} Document version
59241
59657
  */
59242
59658
  static getDocumentVersion(doc2) {
59243
- const version2 = SuperConverter.getStoredSuperdocVersion(doc2);
59244
- return version2;
59659
+ return SuperConverter.getStoredSuperdocVersion(doc2);
59245
59660
  }
59246
59661
  /**
59247
- * Update the document version
59662
+ * Set the document version
59248
59663
  * @static
59249
59664
  * @param {Object} doc - Document object
59250
59665
  * @param {string} version - New version
59251
- * @returns {Object}
59666
+ * @returns {string} The set version
59667
+ */
59668
+ static setDocumentVersion(doc2, version2) {
59669
+ return SuperConverter.setStoredSuperdocVersion(doc2, version2);
59670
+ }
59671
+ /**
59672
+ * Get the document GUID
59673
+ * @static
59674
+ * @param {Object} doc - Document object
59675
+ * @returns {string|null} Document GUID
59676
+ */
59677
+ static getDocumentGuid(doc2) {
59678
+ return SuperConverter.extractDocumentGuid(doc2);
59679
+ }
59680
+ // Deprecated
59681
+ /**
59682
+ * @deprecated use setDocumentVersion instead
59252
59683
  */
59253
59684
  static updateDocumentVersion(doc2, version2) {
59254
- const updatedContent = SuperConverter.updateDocumentVersion(doc2, version2);
59255
- return updatedContent;
59685
+ console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead");
59686
+ return _Editor2.setDocumentVersion(doc2, version2);
59256
59687
  }
59257
59688
  /**
59258
59689
  * Creates all node views.
@@ -59388,6 +59819,43 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59388
59819
  }
59389
59820
  window.addEventListener("resize", () => handleResize);
59390
59821
  }
59822
+ /**
59823
+ * Get document identifier for telemetry (async - may generate hash)
59824
+ * @returns {Promise<string>} GUID for modified docs, hash for unmodified
59825
+ */
59826
+ async getDocumentIdentifier() {
59827
+ return await this.converter?.getDocumentIdentifier() || null;
59828
+ }
59829
+ /**
59830
+ * Get permanent document GUID (sync - only for modified documents)
59831
+ * @returns {string|null} GUID or null if document hasn't been modified
59832
+ */
59833
+ getDocumentGuid() {
59834
+ return this.converter?.documentGuid || null;
59835
+ }
59836
+ /**
59837
+ * Check if document has been modified
59838
+ * @returns {boolean}
59839
+ */
59840
+ isDocumentModified() {
59841
+ return this.converter?.documentModified || false;
59842
+ }
59843
+ /**
59844
+ * Get telemetry data (async because of lazy hash generation)
59845
+ */
59846
+ async getTelemetryData() {
59847
+ return {
59848
+ documentId: await this.getDocumentIdentifier(),
59849
+ isModified: this.isDocumentModified(),
59850
+ isPermanentId: !!this.converter?.documentGuid,
59851
+ version: this.converter?.getSuperdocVersion()
59852
+ };
59853
+ }
59854
+ // Deprecated for backward compatibility
59855
+ getDocumentId() {
59856
+ console.warn("getDocumentId is deprecated, use getDocumentGuid instead");
59857
+ return this.getDocumentGuid();
59858
+ }
59391
59859
  /**
59392
59860
  * Get attrs of the currently selected node or mark.
59393
59861
  * @param {String} nameOrType
@@ -59419,6 +59887,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59419
59887
  getJSON() {
59420
59888
  return this.state.doc.toJSON();
59421
59889
  }
59890
+ /**
59891
+ * Get document metadata including GUID, modification status, and version
59892
+ * @returns {{
59893
+ * documentGuid: string | null,
59894
+ * isModified: boolean,
59895
+ * version: string | null
59896
+ * }} Document metadata
59897
+ */
59898
+ getMetadata() {
59899
+ return {
59900
+ documentGuid: this.converter?.documentGuid || null,
59901
+ isModified: this.isDocumentModified(),
59902
+ version: this.converter?.getSuperdocVersion() || null
59903
+ };
59904
+ }
59422
59905
  /**
59423
59906
  * Get the editor content as HTML
59424
59907
  * @param {Object} options - Options for the HTML serializer
@@ -59436,6 +59919,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59436
59919
  }
59437
59920
  return html;
59438
59921
  }
59922
+ /**
59923
+ * Get the document version from the converter
59924
+ * @returns {string|null} The SuperDoc version stored in the document
59925
+ */
59926
+ getDocumentVersion() {
59927
+ return this.converter?.getSuperdocVersion() || null;
59928
+ }
59439
59929
  /**
59440
59930
  * Create a child editor linked to this editor.
59441
59931
  * This is useful for creating header/footer editors that are linked to the main editor.
@@ -59518,7 +60008,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59518
60008
  if (exportXmlOnly || exportJsonOnly) return documentXml;
59519
60009
  const customXml = this.converter.schemaToXml(this.converter.convertedXml["docProps/custom.xml"].elements[0]);
59520
60010
  const styles = this.converter.schemaToXml(this.converter.convertedXml["word/styles.xml"].elements[0]);
59521
- const customSettings = this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"].elements[0]);
60011
+ const hasCustomSettings = !!this.converter.convertedXml["word/settings.xml"]?.elements?.length;
60012
+ const customSettings = hasCustomSettings ? this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"]?.elements?.[0]) : null;
59522
60013
  const rels = this.converter.schemaToXml(this.converter.convertedXml["word/_rels/document.xml.rels"].elements[0]);
59523
60014
  const media = this.converter.addedMedia;
59524
60015
  const updatedHeadersFooters = {};
@@ -59534,13 +60025,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
59534
60025
  ...this.options.customUpdatedFiles,
59535
60026
  "word/document.xml": String(documentXml),
59536
60027
  "docProps/custom.xml": String(customXml),
59537
- "word/settings.xml": String(customSettings),
59538
60028
  "word/_rels/document.xml.rels": String(rels),
59539
60029
  "word/numbering.xml": String(numbering),
59540
60030
  // Replace & with &amp; in styles.xml as DOCX viewers can't handle it
59541
60031
  "word/styles.xml": String(styles).replace(/&/gi, "&amp;"),
59542
60032
  ...updatedHeadersFooters
59543
60033
  };
60034
+ if (hasCustomSettings) {
60035
+ updatedDocs["word/settings.xml"] = String(customSettings);
60036
+ }
59544
60037
  if (comments.length) {
59545
60038
  const commentsXml = this.converter.schemaToXml(this.converter.convertedXml["word/comments.xml"].elements[0]);
59546
60039
  const commentsExtendedXml = this.converter.schemaToXml(
@@ -60160,6 +60653,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
60160
60653
  if (!transaction.docChanged) {
60161
60654
  return;
60162
60655
  }
60656
+ if (transaction.docChanged && this.converter) {
60657
+ if (!this.converter.documentGuid) {
60658
+ this.converter.promoteToGuid();
60659
+ console.debug("Document modified - assigned GUID:", this.converter.documentGuid);
60660
+ }
60661
+ this.converter.documentModified = true;
60662
+ }
60163
60663
  this.emit("update", {
60164
60664
  editor: this,
60165
60665
  transaction
@@ -73087,7 +73587,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73087
73587
  }
73088
73588
  return formatList.filter((format) => Object.hasOwn(format, "type") && Object.hasOwn(format, "attrs"));
73089
73589
  };
73090
- const index$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
73590
+ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
73091
73591
  __proto__: null,
73092
73592
  addMarkStep,
73093
73593
  documentHelpers,
@@ -89793,7 +90293,7 @@ ${style2}
89793
90293
  return eventemitter3$1.exports;
89794
90294
  }
89795
90295
  var eventemitter3Exports$1 = requireEventemitter3$1();
89796
- const EventEmitter$1 = /* @__PURE__ */ getDefaultExportFromCjs$1$1(eventemitter3Exports$1);
90296
+ const EventEmitter$1 = /* @__PURE__ */ getDefaultExportFromCjs$2(eventemitter3Exports$1);
89797
90297
  const useToolbarItem = (options) => {
89798
90298
  const types2 = ["button", "options", "separator", "dropdown", "overflow"];
89799
90299
  if (!types2.includes(options.type)) {
@@ -94601,306 +95101,6 @@ ${style2}
94601
95101
  delete el.__clickOutsideHandler;
94602
95102
  }
94603
95103
  };
94604
- function getDefaultExportFromCjs$1(x) {
94605
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
94606
- }
94607
- const CRC_TABLE = new Int32Array([
94608
- 0,
94609
- 1996959894,
94610
- 3993919788,
94611
- 2567524794,
94612
- 124634137,
94613
- 1886057615,
94614
- 3915621685,
94615
- 2657392035,
94616
- 249268274,
94617
- 2044508324,
94618
- 3772115230,
94619
- 2547177864,
94620
- 162941995,
94621
- 2125561021,
94622
- 3887607047,
94623
- 2428444049,
94624
- 498536548,
94625
- 1789927666,
94626
- 4089016648,
94627
- 2227061214,
94628
- 450548861,
94629
- 1843258603,
94630
- 4107580753,
94631
- 2211677639,
94632
- 325883990,
94633
- 1684777152,
94634
- 4251122042,
94635
- 2321926636,
94636
- 335633487,
94637
- 1661365465,
94638
- 4195302755,
94639
- 2366115317,
94640
- 997073096,
94641
- 1281953886,
94642
- 3579855332,
94643
- 2724688242,
94644
- 1006888145,
94645
- 1258607687,
94646
- 3524101629,
94647
- 2768942443,
94648
- 901097722,
94649
- 1119000684,
94650
- 3686517206,
94651
- 2898065728,
94652
- 853044451,
94653
- 1172266101,
94654
- 3705015759,
94655
- 2882616665,
94656
- 651767980,
94657
- 1373503546,
94658
- 3369554304,
94659
- 3218104598,
94660
- 565507253,
94661
- 1454621731,
94662
- 3485111705,
94663
- 3099436303,
94664
- 671266974,
94665
- 1594198024,
94666
- 3322730930,
94667
- 2970347812,
94668
- 795835527,
94669
- 1483230225,
94670
- 3244367275,
94671
- 3060149565,
94672
- 1994146192,
94673
- 31158534,
94674
- 2563907772,
94675
- 4023717930,
94676
- 1907459465,
94677
- 112637215,
94678
- 2680153253,
94679
- 3904427059,
94680
- 2013776290,
94681
- 251722036,
94682
- 2517215374,
94683
- 3775830040,
94684
- 2137656763,
94685
- 141376813,
94686
- 2439277719,
94687
- 3865271297,
94688
- 1802195444,
94689
- 476864866,
94690
- 2238001368,
94691
- 4066508878,
94692
- 1812370925,
94693
- 453092731,
94694
- 2181625025,
94695
- 4111451223,
94696
- 1706088902,
94697
- 314042704,
94698
- 2344532202,
94699
- 4240017532,
94700
- 1658658271,
94701
- 366619977,
94702
- 2362670323,
94703
- 4224994405,
94704
- 1303535960,
94705
- 984961486,
94706
- 2747007092,
94707
- 3569037538,
94708
- 1256170817,
94709
- 1037604311,
94710
- 2765210733,
94711
- 3554079995,
94712
- 1131014506,
94713
- 879679996,
94714
- 2909243462,
94715
- 3663771856,
94716
- 1141124467,
94717
- 855842277,
94718
- 2852801631,
94719
- 3708648649,
94720
- 1342533948,
94721
- 654459306,
94722
- 3188396048,
94723
- 3373015174,
94724
- 1466479909,
94725
- 544179635,
94726
- 3110523913,
94727
- 3462522015,
94728
- 1591671054,
94729
- 702138776,
94730
- 2966460450,
94731
- 3352799412,
94732
- 1504918807,
94733
- 783551873,
94734
- 3082640443,
94735
- 3233442989,
94736
- 3988292384,
94737
- 2596254646,
94738
- 62317068,
94739
- 1957810842,
94740
- 3939845945,
94741
- 2647816111,
94742
- 81470997,
94743
- 1943803523,
94744
- 3814918930,
94745
- 2489596804,
94746
- 225274430,
94747
- 2053790376,
94748
- 3826175755,
94749
- 2466906013,
94750
- 167816743,
94751
- 2097651377,
94752
- 4027552580,
94753
- 2265490386,
94754
- 503444072,
94755
- 1762050814,
94756
- 4150417245,
94757
- 2154129355,
94758
- 426522225,
94759
- 1852507879,
94760
- 4275313526,
94761
- 2312317920,
94762
- 282753626,
94763
- 1742555852,
94764
- 4189708143,
94765
- 2394877945,
94766
- 397917763,
94767
- 1622183637,
94768
- 3604390888,
94769
- 2714866558,
94770
- 953729732,
94771
- 1340076626,
94772
- 3518719985,
94773
- 2797360999,
94774
- 1068828381,
94775
- 1219638859,
94776
- 3624741850,
94777
- 2936675148,
94778
- 906185462,
94779
- 1090812512,
94780
- 3747672003,
94781
- 2825379669,
94782
- 829329135,
94783
- 1181335161,
94784
- 3412177804,
94785
- 3160834842,
94786
- 628085408,
94787
- 1382605366,
94788
- 3423369109,
94789
- 3138078467,
94790
- 570562233,
94791
- 1426400815,
94792
- 3317316542,
94793
- 2998733608,
94794
- 733239954,
94795
- 1555261956,
94796
- 3268935591,
94797
- 3050360625,
94798
- 752459403,
94799
- 1541320221,
94800
- 2607071920,
94801
- 3965973030,
94802
- 1969922972,
94803
- 40735498,
94804
- 2617837225,
94805
- 3943577151,
94806
- 1913087877,
94807
- 83908371,
94808
- 2512341634,
94809
- 3803740692,
94810
- 2075208622,
94811
- 213261112,
94812
- 2463272603,
94813
- 3855990285,
94814
- 2094854071,
94815
- 198958881,
94816
- 2262029012,
94817
- 4057260610,
94818
- 1759359992,
94819
- 534414190,
94820
- 2176718541,
94821
- 4139329115,
94822
- 1873836001,
94823
- 414664567,
94824
- 2282248934,
94825
- 4279200368,
94826
- 1711684554,
94827
- 285281116,
94828
- 2405801727,
94829
- 4167216745,
94830
- 1634467795,
94831
- 376229701,
94832
- 2685067896,
94833
- 3608007406,
94834
- 1308918612,
94835
- 956543938,
94836
- 2808555105,
94837
- 3495958263,
94838
- 1231636301,
94839
- 1047427035,
94840
- 2932959818,
94841
- 3654703836,
94842
- 1088359270,
94843
- 936918e3,
94844
- 2847714899,
94845
- 3736837829,
94846
- 1202900863,
94847
- 817233897,
94848
- 3183342108,
94849
- 3401237130,
94850
- 1404277552,
94851
- 615818150,
94852
- 3134207493,
94853
- 3453421203,
94854
- 1423857449,
94855
- 601450431,
94856
- 3009837614,
94857
- 3294710456,
94858
- 1567103746,
94859
- 711928724,
94860
- 3020668471,
94861
- 3272380065,
94862
- 1510334235,
94863
- 755167117
94864
- ]);
94865
- function ensureBuffer(input) {
94866
- if (Buffer.isBuffer(input)) {
94867
- return input;
94868
- }
94869
- if (typeof input === "number") {
94870
- return Buffer.alloc(input);
94871
- } else if (typeof input === "string") {
94872
- return Buffer.from(input);
94873
- } else {
94874
- throw new Error("input must be buffer, number, or string, received " + typeof input);
94875
- }
94876
- }
94877
- function bufferizeInt(num) {
94878
- const tmp = ensureBuffer(4);
94879
- tmp.writeInt32BE(num, 0);
94880
- return tmp;
94881
- }
94882
- function _crc32(buf, previous) {
94883
- buf = ensureBuffer(buf);
94884
- if (Buffer.isBuffer(previous)) {
94885
- previous = previous.readUInt32BE(0);
94886
- }
94887
- let crc = ~~previous ^ -1;
94888
- for (var n = 0; n < buf.length; n++) {
94889
- crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
94890
- }
94891
- return crc ^ -1;
94892
- }
94893
- function crc32() {
94894
- return bufferizeInt(_crc32.apply(null, arguments));
94895
- }
94896
- crc32.signed = function() {
94897
- return _crc32.apply(null, arguments);
94898
- };
94899
- crc32.unsigned = function() {
94900
- return _crc32.apply(null, arguments) >>> 0;
94901
- };
94902
- var bufferCrc32 = crc32;
94903
- const index = /* @__PURE__ */ getDefaultExportFromCjs$1(bufferCrc32);
94904
95104
  function randomBytes(length2) {
94905
95105
  const array = new Uint8Array(length2);
94906
95106
  for (let i2 = 0; i2 < length2; i2++) {
@@ -94912,7 +95112,9 @@ ${style2}
94912
95112
  /** @type {boolean} */
94913
95113
  enabled;
94914
95114
  /** @type {string} */
94915
- superdocId;
95115
+ documentGuid;
95116
+ /** @type {string} */
95117
+ documentIdentifier;
94916
95118
  /** @type {string} */
94917
95119
  superdocVersion;
94918
95120
  /** @type {string} */
@@ -94953,7 +95155,8 @@ ${style2}
94953
95155
  this.enabled = config2.enabled ?? true;
94954
95156
  this.licenseKey = config2.licenseKey ?? Telemetry.COMMUNITY_LICENSE_KEY;
94955
95157
  this.endpoint = config2.endpoint ?? Telemetry.DEFAULT_ENDPOINT;
94956
- this.superdocId = config2.superdocId;
95158
+ this.documentGuid = config2.documentGuid;
95159
+ this.documentIdentifier = config2.documentIdentifier;
94957
95160
  this.superdocVersion = config2.superdocVersion;
94958
95161
  this.sessionId = this.generateId();
94959
95162
  }
@@ -94985,7 +95188,10 @@ ${style2}
94985
95188
  type: "usage",
94986
95189
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
94987
95190
  sessionId: this.sessionId,
94988
- superdocId: this.superdocId,
95191
+ documentGuid: this.documentGuid,
95192
+ // Updated field name
95193
+ documentIdentifier: this.documentIdentifier,
95194
+ // Include both
94989
95195
  superdocVersion: this.superdocVersion,
94990
95196
  file: this.documentInfo,
94991
95197
  browser: this.getBrowserInfo(),
@@ -95052,13 +95258,17 @@ ${style2}
95052
95258
  * Track file structure
95053
95259
  * @param {Object} structure - File structure information
95054
95260
  * @param {File} fileSource - original file
95055
- * @param {String} documentId - document ID
95056
- * @param {string} internalId - document ID form settings.xml
95261
+ * @param {String} documentId - document GUID
95262
+ * @param {string} documentIdentifier - document identifier (GUID or hash)
95263
+ * @param {string} internalId - document ID from settings.xml
95057
95264
  */
95058
- async trackFileStructure(structure, fileSource, documentId, internalId) {
95265
+ async trackFileStructure(structure, fileSource, documentId, documentIdentifier, internalId) {
95059
95266
  this.fileStructure = structure;
95060
95267
  this.documentInfo = await this.processDocument(fileSource, {
95061
- id: documentId,
95268
+ guid: documentId,
95269
+ // Updated parameter name
95270
+ identifier: documentIdentifier,
95271
+ // New parameter
95062
95272
  internalId
95063
95273
  });
95064
95274
  }
@@ -95073,34 +95283,19 @@ ${style2}
95073
95283
  console.warn("Telemetry: missing file source");
95074
95284
  return {};
95075
95285
  }
95076
- let hash2 = "";
95077
- try {
95078
- hash2 = await this.generateCrc32Hash(file);
95079
- } catch (error) {
95080
- console.error("Failed to generate file hash:", error);
95081
- }
95082
95286
  return {
95083
- id: options.id,
95287
+ guid: options.guid,
95288
+ // Updated from 'id'
95289
+ identifier: options.identifier,
95290
+ // New field
95084
95291
  name: file.name,
95085
95292
  size: file.size,
95086
- crc32: hash2,
95087
95293
  lastModified: file.lastModified ? new Date(file.lastModified).toISOString() : null,
95088
95294
  type: file.type || "docx",
95089
95295
  internalId: options.internalId
95296
+ // Microsoft's GUID if present
95090
95297
  };
95091
95298
  }
95092
- /**
95093
- * Generate CRC32 hash for a file
95094
- * @param {File} file - File to hash
95095
- * @returns {Promise<string>} CRC32 hash
95096
- * @private
95097
- */
95098
- async generateCrc32Hash(file) {
95099
- const arrayBuffer = await file.arrayBuffer();
95100
- const buffer2 = Buffer.from(arrayBuffer);
95101
- const hashBuffer = index(buffer2);
95102
- return hashBuffer.toString("hex");
95103
- }
95104
95299
  isTelemetryDataChanged() {
95105
95300
  const initialStatistics = {};
95106
95301
  const initialFileStructure = {};
@@ -98103,7 +98298,7 @@ ${reason}`);
98103
98298
  }, 0);
98104
98299
  };
98105
98300
  const createCommentForTrackChanges = (editor) => {
98106
- let trackedChanges = index$2.getTrackChanges(editor.state);
98301
+ let trackedChanges = index.getTrackChanges(editor.state);
98107
98302
  const groupedChanges = groupChanges(trackedChanges);
98108
98303
  const { tr } = editor.view.state;
98109
98304
  const { dispatch } = editor.view;
@@ -112836,7 +113031,7 @@ ${style2}
112836
113031
  exports2.getRichTextExtensions = getRichTextExtensions;
112837
113032
  exports2.registeredHandlers = registeredHandlers;
112838
113033
  exports2.superEditorHelpers = helpers;
112839
- exports2.trackChangesHelpers = index$2;
113034
+ exports2.trackChangesHelpers = index;
112840
113035
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
112841
113036
  }));
112842
113037
  //# sourceMappingURL=superdoc.umd.js.map