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

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-CJrsZCLf.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BaaVD5bX.es.js → PdfViewer-DfGIeWvO.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-CESuSQe2.es.js → index-CwhKMy0h.es.js} +27 -332
  6. package/dist/chunks/{index-CAHkANZY.cjs → index-DGSQ4Gfx.cjs} +160 -465
  7. package/dist/chunks/{super-editor.es-BYutUrPg.cjs → super-editor.es-b9ACFl9D.cjs} +649 -125
  8. package/dist/chunks/{super-editor.es-BKb7p4fi.es.js → super-editor.es-bIibjiHo.es.js} +649 -125
  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-CVzagv2Y.js} +127 -19
  17. package/dist/super-editor/chunks/{toolbar-D6SJTVWT.js → toolbar-BCJtFyig.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 +674 -455
  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
@@ -10,11 +10,7 @@ var __publicField$2 = (obj, key2, value) => __defNormalProp$2(obj, typeof key2 !
10
10
  var __accessCheck$2 = (obj, member, msg2) => member.has(obj) || __typeError$2("Cannot " + msg2);
11
11
  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);
12
12
  var __privateMethod$2 = (obj, member, method) => (__accessCheck$2(obj, member, "access private method"), method);
13
- 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;
14
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global$2 !== "undefined" ? global$2 : typeof self !== "undefined" ? self : {};
15
- function getDefaultExportFromCjs$1(x) {
16
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
17
- }
13
+ 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;
18
14
  var buffer = {};
19
15
  var base64Js = {};
20
16
  base64Js.byteLength = byteLength;
@@ -1781,6 +1777,10 @@ ieee754.write = function(buffer2, value, offset2, isLE, mLen, nBytes) {
1781
1777
  }
1782
1778
  })(buffer);
1783
1779
  const Buffer2 = buffer.Buffer;
1780
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global$2 !== "undefined" ? global$2 : typeof self !== "undefined" ? self : {};
1781
+ function getDefaultExportFromCjs$2(x) {
1782
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1783
+ }
1784
1784
  var sax = {};
1785
1785
  var events$1 = { exports: {} };
1786
1786
  var hasRequiredEvents;
@@ -2183,7 +2183,7 @@ function requireInherits_browser() {
2183
2183
  }
2184
2184
  return inherits_browser.exports;
2185
2185
  }
2186
- function getDefaultExportFromCjs(x) {
2186
+ function getDefaultExportFromCjs$1(x) {
2187
2187
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
2188
2188
  }
2189
2189
  var browser$1 = { exports: {} };
@@ -2344,7 +2344,7 @@ process$1.umask = function() {
2344
2344
  return 0;
2345
2345
  };
2346
2346
  var browserExports = browser$1.exports;
2347
- const process$1$1 = /* @__PURE__ */ getDefaultExportFromCjs(browserExports);
2347
+ const process$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(browserExports);
2348
2348
  var streamBrowser;
2349
2349
  var hasRequiredStreamBrowser;
2350
2350
  function requireStreamBrowser() {
@@ -11329,7 +11329,7 @@ function requireLib() {
11329
11329
  return lib;
11330
11330
  }
11331
11331
  var libExports = requireLib();
11332
- const xmljs = /* @__PURE__ */ getDefaultExportFromCjs$1(libExports);
11332
+ const xmljs = /* @__PURE__ */ getDefaultExportFromCjs$2(libExports);
11333
11333
  var getRandomValues;
11334
11334
  var rnds8 = new Uint8Array(16);
11335
11335
  function rng() {
@@ -11364,6 +11364,306 @@ function v4(options, buf, offset2) {
11364
11364
  rnds[8] = rnds[8] & 63 | 128;
11365
11365
  return stringify(rnds);
11366
11366
  }
11367
+ function getDefaultExportFromCjs(x) {
11368
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
11369
+ }
11370
+ const CRC_TABLE = new Int32Array([
11371
+ 0,
11372
+ 1996959894,
11373
+ 3993919788,
11374
+ 2567524794,
11375
+ 124634137,
11376
+ 1886057615,
11377
+ 3915621685,
11378
+ 2657392035,
11379
+ 249268274,
11380
+ 2044508324,
11381
+ 3772115230,
11382
+ 2547177864,
11383
+ 162941995,
11384
+ 2125561021,
11385
+ 3887607047,
11386
+ 2428444049,
11387
+ 498536548,
11388
+ 1789927666,
11389
+ 4089016648,
11390
+ 2227061214,
11391
+ 450548861,
11392
+ 1843258603,
11393
+ 4107580753,
11394
+ 2211677639,
11395
+ 325883990,
11396
+ 1684777152,
11397
+ 4251122042,
11398
+ 2321926636,
11399
+ 335633487,
11400
+ 1661365465,
11401
+ 4195302755,
11402
+ 2366115317,
11403
+ 997073096,
11404
+ 1281953886,
11405
+ 3579855332,
11406
+ 2724688242,
11407
+ 1006888145,
11408
+ 1258607687,
11409
+ 3524101629,
11410
+ 2768942443,
11411
+ 901097722,
11412
+ 1119000684,
11413
+ 3686517206,
11414
+ 2898065728,
11415
+ 853044451,
11416
+ 1172266101,
11417
+ 3705015759,
11418
+ 2882616665,
11419
+ 651767980,
11420
+ 1373503546,
11421
+ 3369554304,
11422
+ 3218104598,
11423
+ 565507253,
11424
+ 1454621731,
11425
+ 3485111705,
11426
+ 3099436303,
11427
+ 671266974,
11428
+ 1594198024,
11429
+ 3322730930,
11430
+ 2970347812,
11431
+ 795835527,
11432
+ 1483230225,
11433
+ 3244367275,
11434
+ 3060149565,
11435
+ 1994146192,
11436
+ 31158534,
11437
+ 2563907772,
11438
+ 4023717930,
11439
+ 1907459465,
11440
+ 112637215,
11441
+ 2680153253,
11442
+ 3904427059,
11443
+ 2013776290,
11444
+ 251722036,
11445
+ 2517215374,
11446
+ 3775830040,
11447
+ 2137656763,
11448
+ 141376813,
11449
+ 2439277719,
11450
+ 3865271297,
11451
+ 1802195444,
11452
+ 476864866,
11453
+ 2238001368,
11454
+ 4066508878,
11455
+ 1812370925,
11456
+ 453092731,
11457
+ 2181625025,
11458
+ 4111451223,
11459
+ 1706088902,
11460
+ 314042704,
11461
+ 2344532202,
11462
+ 4240017532,
11463
+ 1658658271,
11464
+ 366619977,
11465
+ 2362670323,
11466
+ 4224994405,
11467
+ 1303535960,
11468
+ 984961486,
11469
+ 2747007092,
11470
+ 3569037538,
11471
+ 1256170817,
11472
+ 1037604311,
11473
+ 2765210733,
11474
+ 3554079995,
11475
+ 1131014506,
11476
+ 879679996,
11477
+ 2909243462,
11478
+ 3663771856,
11479
+ 1141124467,
11480
+ 855842277,
11481
+ 2852801631,
11482
+ 3708648649,
11483
+ 1342533948,
11484
+ 654459306,
11485
+ 3188396048,
11486
+ 3373015174,
11487
+ 1466479909,
11488
+ 544179635,
11489
+ 3110523913,
11490
+ 3462522015,
11491
+ 1591671054,
11492
+ 702138776,
11493
+ 2966460450,
11494
+ 3352799412,
11495
+ 1504918807,
11496
+ 783551873,
11497
+ 3082640443,
11498
+ 3233442989,
11499
+ 3988292384,
11500
+ 2596254646,
11501
+ 62317068,
11502
+ 1957810842,
11503
+ 3939845945,
11504
+ 2647816111,
11505
+ 81470997,
11506
+ 1943803523,
11507
+ 3814918930,
11508
+ 2489596804,
11509
+ 225274430,
11510
+ 2053790376,
11511
+ 3826175755,
11512
+ 2466906013,
11513
+ 167816743,
11514
+ 2097651377,
11515
+ 4027552580,
11516
+ 2265490386,
11517
+ 503444072,
11518
+ 1762050814,
11519
+ 4150417245,
11520
+ 2154129355,
11521
+ 426522225,
11522
+ 1852507879,
11523
+ 4275313526,
11524
+ 2312317920,
11525
+ 282753626,
11526
+ 1742555852,
11527
+ 4189708143,
11528
+ 2394877945,
11529
+ 397917763,
11530
+ 1622183637,
11531
+ 3604390888,
11532
+ 2714866558,
11533
+ 953729732,
11534
+ 1340076626,
11535
+ 3518719985,
11536
+ 2797360999,
11537
+ 1068828381,
11538
+ 1219638859,
11539
+ 3624741850,
11540
+ 2936675148,
11541
+ 906185462,
11542
+ 1090812512,
11543
+ 3747672003,
11544
+ 2825379669,
11545
+ 829329135,
11546
+ 1181335161,
11547
+ 3412177804,
11548
+ 3160834842,
11549
+ 628085408,
11550
+ 1382605366,
11551
+ 3423369109,
11552
+ 3138078467,
11553
+ 570562233,
11554
+ 1426400815,
11555
+ 3317316542,
11556
+ 2998733608,
11557
+ 733239954,
11558
+ 1555261956,
11559
+ 3268935591,
11560
+ 3050360625,
11561
+ 752459403,
11562
+ 1541320221,
11563
+ 2607071920,
11564
+ 3965973030,
11565
+ 1969922972,
11566
+ 40735498,
11567
+ 2617837225,
11568
+ 3943577151,
11569
+ 1913087877,
11570
+ 83908371,
11571
+ 2512341634,
11572
+ 3803740692,
11573
+ 2075208622,
11574
+ 213261112,
11575
+ 2463272603,
11576
+ 3855990285,
11577
+ 2094854071,
11578
+ 198958881,
11579
+ 2262029012,
11580
+ 4057260610,
11581
+ 1759359992,
11582
+ 534414190,
11583
+ 2176718541,
11584
+ 4139329115,
11585
+ 1873836001,
11586
+ 414664567,
11587
+ 2282248934,
11588
+ 4279200368,
11589
+ 1711684554,
11590
+ 285281116,
11591
+ 2405801727,
11592
+ 4167216745,
11593
+ 1634467795,
11594
+ 376229701,
11595
+ 2685067896,
11596
+ 3608007406,
11597
+ 1308918612,
11598
+ 956543938,
11599
+ 2808555105,
11600
+ 3495958263,
11601
+ 1231636301,
11602
+ 1047427035,
11603
+ 2932959818,
11604
+ 3654703836,
11605
+ 1088359270,
11606
+ 936918e3,
11607
+ 2847714899,
11608
+ 3736837829,
11609
+ 1202900863,
11610
+ 817233897,
11611
+ 3183342108,
11612
+ 3401237130,
11613
+ 1404277552,
11614
+ 615818150,
11615
+ 3134207493,
11616
+ 3453421203,
11617
+ 1423857449,
11618
+ 601450431,
11619
+ 3009837614,
11620
+ 3294710456,
11621
+ 1567103746,
11622
+ 711928724,
11623
+ 3020668471,
11624
+ 3272380065,
11625
+ 1510334235,
11626
+ 755167117
11627
+ ]);
11628
+ function ensureBuffer(input) {
11629
+ if (Buffer2.isBuffer(input)) {
11630
+ return input;
11631
+ }
11632
+ if (typeof input === "number") {
11633
+ return Buffer2.alloc(input);
11634
+ } else if (typeof input === "string") {
11635
+ return Buffer2.from(input);
11636
+ } else {
11637
+ throw new Error("input must be buffer, number, or string, received " + typeof input);
11638
+ }
11639
+ }
11640
+ function bufferizeInt(num) {
11641
+ const tmp = ensureBuffer(4);
11642
+ tmp.writeInt32BE(num, 0);
11643
+ return tmp;
11644
+ }
11645
+ function _crc32(buf, previous) {
11646
+ buf = ensureBuffer(buf);
11647
+ if (Buffer2.isBuffer(previous)) {
11648
+ previous = previous.readUInt32BE(0);
11649
+ }
11650
+ let crc = ~~previous ^ -1;
11651
+ for (var n = 0; n < buf.length; n++) {
11652
+ crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
11653
+ }
11654
+ return crc ^ -1;
11655
+ }
11656
+ function crc32() {
11657
+ return bufferizeInt(_crc32.apply(null, arguments));
11658
+ }
11659
+ crc32.signed = function() {
11660
+ return _crc32.apply(null, arguments);
11661
+ };
11662
+ crc32.unsigned = function() {
11663
+ return _crc32.apply(null, arguments) >>> 0;
11664
+ };
11665
+ var bufferCrc32 = crc32;
11666
+ const index$2 = /* @__PURE__ */ getDefaultExportFromCjs(bufferCrc32);
11367
11667
  function callOrGet(value, context = null, ...props) {
11368
11668
  if (typeof value === "function") {
11369
11669
  if (context) return value.bind(context)(...props);
@@ -15045,18 +15345,6 @@ const DEFAULT_CUSTOM_XML = {
15045
15345
  }
15046
15346
  ]
15047
15347
  };
15048
- const SETTINGS_CUSTOM_XML = {
15049
- elements: [
15050
- {
15051
- type: "element",
15052
- name: "w:settings",
15053
- attributes: {
15054
- "xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
15055
- },
15056
- elements: []
15057
- }
15058
- ]
15059
- };
15060
15348
  const COMMENT_REF = {
15061
15349
  type: "element",
15062
15350
  name: "w:r",
@@ -17393,15 +17681,15 @@ function canSplit(doc2, pos, depth = 1, typesAfter) {
17393
17681
  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)))
17394
17682
  return false;
17395
17683
  for (let d2 = $pos.depth - 1, i = depth - 2; d2 > base2; d2--, i--) {
17396
- let node = $pos.node(d2), index22 = $pos.index(d2);
17684
+ let node = $pos.node(d2), index3 = $pos.index(d2);
17397
17685
  if (node.type.spec.isolating)
17398
17686
  return false;
17399
- let rest = node.content.cutByIndex(index22, node.childCount);
17687
+ let rest = node.content.cutByIndex(index3, node.childCount);
17400
17688
  let overrideChild = typesAfter && typesAfter[i + 1];
17401
17689
  if (overrideChild)
17402
17690
  rest = rest.replaceChild(0, overrideChild.type.create(overrideChild.attrs));
17403
17691
  let after = typesAfter && typesAfter[i] || node;
17404
- if (!node.canReplace(index22 + 1, node.childCount) || !after.type.validContent(rest))
17692
+ if (!node.canReplace(index3 + 1, node.childCount) || !after.type.validContent(rest))
17405
17693
  return false;
17406
17694
  }
17407
17695
  let index2 = $pos.indexAfter(base2);
@@ -30140,7 +30428,7 @@ function requireHe() {
30140
30428
  return he$2.exports;
30141
30429
  }
30142
30430
  var heExports = requireHe();
30143
- const he = /* @__PURE__ */ getDefaultExportFromCjs$1(heExports);
30431
+ const he = /* @__PURE__ */ getDefaultExportFromCjs$2(heExports);
30144
30432
  function translateFieldAnnotation(params2) {
30145
30433
  const { node, isFinalDoc, fieldsHighlightColor } = params2;
30146
30434
  const { attrs = {} } = node;
@@ -33305,7 +33593,7 @@ const createDocumentJson = (docx, converter, editor) => {
33305
33593
  fileType: filePath.split(".").pop()
33306
33594
  };
33307
33595
  });
33308
- converter.telemetry.trackFileStructure(
33596
+ const trackStructure = (documentIdentifier = null) => converter.telemetry.trackFileStructure(
33309
33597
  {
33310
33598
  totalFiles: files.length,
33311
33599
  maxDepth: Math.max(...files.map((f) => f.fileDepth)),
@@ -33313,9 +33601,20 @@ const createDocumentJson = (docx, converter, editor) => {
33313
33601
  files
33314
33602
  },
33315
33603
  converter.fileSource,
33316
- converter.documentId,
33604
+ converter.documentGuid ?? converter.documentId ?? null,
33605
+ documentIdentifier ?? converter.documentId ?? null,
33317
33606
  converter.documentInternalId
33318
33607
  );
33608
+ try {
33609
+ const identifierResult = converter.getDocumentIdentifier?.();
33610
+ if (identifierResult && typeof identifierResult.then === "function") {
33611
+ identifierResult.then(trackStructure).catch(() => trackStructure());
33612
+ } else {
33613
+ trackStructure(identifierResult);
33614
+ }
33615
+ } catch (error) {
33616
+ trackStructure();
33617
+ }
33319
33618
  }
33320
33619
  const nodeListHandler = defaultNodeListHandler();
33321
33620
  const bodyNode = json.elements[0].elements.find((el) => el.name === "w:body");
@@ -33866,6 +34165,9 @@ const _SuperConverter = class _SuperConverter2 {
33866
34165
  this.documentInternalId = null;
33867
34166
  this.fileSource = params2?.fileSource || null;
33868
34167
  this.documentId = params2?.documentId || null;
34168
+ this.documentGuid = null;
34169
+ this.documentHash = null;
34170
+ this.documentModified = false;
33869
34171
  if (this.docx.length || this.xml) this.parseFromXml();
33870
34172
  }
33871
34173
  static getFontTableEntry(docx, fontName) {
@@ -33913,50 +34215,177 @@ const _SuperConverter = class _SuperConverter2 {
33913
34215
  this.initialJSON = this.convertedXml["word/document.xml"];
33914
34216
  if (!this.initialJSON) this.initialJSON = this.parseXmlToJson(this.xml);
33915
34217
  this.declaration = this.initialJSON?.declaration;
34218
+ this.resolveDocumentGuid();
33916
34219
  }
33917
34220
  parseXmlToJson(xml) {
33918
34221
  const newXml = xml.replace(/(<w:t xml:space="preserve">)(\s+)(<\/w:t>)/g, "$1[[sdspace]]$2[[sdspace]]$3");
33919
34222
  return JSON.parse(xmljs.xml2json(newXml, null, 2));
33920
34223
  }
33921
- static getStoredSuperdocVersion(docx) {
34224
+ /**
34225
+ * Generic method to get a stored custom property from docx
34226
+ * @static
34227
+ * @param {Array} docx - Array of docx file objects
34228
+ * @param {string} propertyName - Name of the property to retrieve
34229
+ * @returns {string|null} The property value or null if not found
34230
+ */
34231
+ static getStoredCustomProperty(docx, propertyName) {
33922
34232
  try {
33923
34233
  const customXml = docx.find((doc2) => doc2.name === "docProps/custom.xml");
33924
- if (!customXml) return;
34234
+ if (!customXml) return null;
33925
34235
  const converter = new _SuperConverter2();
33926
34236
  const content = customXml.content;
33927
34237
  const contentJson = converter.parseXmlToJson(content);
33928
34238
  const properties = contentJson.elements.find((el) => el.name === "Properties");
33929
- if (!properties.elements) return;
33930
- const superdocVersion = properties.elements.find(
33931
- (el) => el.name === "property" && el.attributes.name === "SuperdocVersion"
33932
- );
33933
- if (!superdocVersion) return;
33934
- const version2 = superdocVersion.elements[0].elements[0].text;
33935
- return version2;
34239
+ if (!properties.elements) return null;
34240
+ const property2 = properties.elements.find((el) => el.name === "property" && el.attributes.name === propertyName);
34241
+ if (!property2) return null;
34242
+ return property2.elements[0].elements[0].text;
33936
34243
  } catch (e) {
33937
- console.warn("Error getting Superdoc version", e);
33938
- return;
34244
+ console.warn(`Error getting custom property ${propertyName}:`, e);
34245
+ return null;
33939
34246
  }
33940
34247
  }
33941
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.22.0") {
34248
+ /**
34249
+ * Generic method to set a stored custom property in docx
34250
+ * @static
34251
+ * @param {Object} docx - The docx object to store the property in
34252
+ * @param {string} propertyName - Name of the property
34253
+ * @param {string|Function} value - Value or function that returns the value
34254
+ * @param {boolean} preserveExisting - If true, won't overwrite existing values
34255
+ * @returns {string} The stored value
34256
+ */
34257
+ static setStoredCustomProperty(docx, propertyName, value, preserveExisting = false) {
33942
34258
  const customLocation = "docProps/custom.xml";
33943
- if (!docx[customLocation]) {
33944
- docx[customLocation] = generateCustomXml();
33945
- }
33946
- const customXml = docx["docProps/custom.xml"];
33947
- if (!customXml) return;
33948
- const properties = customXml.elements.find((el) => el.name === "Properties");
34259
+ if (!docx[customLocation]) docx[customLocation] = generateCustomXml();
34260
+ const customXml = docx[customLocation];
34261
+ const properties = customXml.elements?.find((el) => el.name === "Properties");
34262
+ if (!properties) return null;
33949
34263
  if (!properties.elements) properties.elements = [];
33950
- const superdocVersion = properties.elements.find(
33951
- (el) => el.name === "property" && el.attributes.name === "SuperdocVersion"
33952
- );
33953
- if (!superdocVersion) {
33954
- const newCustomXml = generateSuperdocVersion();
33955
- properties.elements.push(newCustomXml);
34264
+ let property2 = properties.elements.find((el) => el.name === "property" && el.attributes.name === propertyName);
34265
+ if (property2 && preserveExisting) {
34266
+ return property2.elements[0].elements[0].text;
34267
+ }
34268
+ const finalValue = typeof value === "function" ? value() : value;
34269
+ if (!property2) {
34270
+ const existingPids = properties.elements.filter((el) => el.attributes?.pid).map((el) => parseInt(el.attributes.pid, 10)).filter(Number.isInteger);
34271
+ const pid = existingPids.length > 0 ? Math.max(...existingPids) + 1 : 2;
34272
+ property2 = {
34273
+ type: "element",
34274
+ name: "property",
34275
+ attributes: {
34276
+ name: propertyName,
34277
+ fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
34278
+ pid
34279
+ },
34280
+ elements: [
34281
+ {
34282
+ type: "element",
34283
+ name: "vt:lpwstr",
34284
+ elements: [
34285
+ {
34286
+ type: "text",
34287
+ text: finalValue
34288
+ }
34289
+ ]
34290
+ }
34291
+ ]
34292
+ };
34293
+ properties.elements.push(property2);
33956
34294
  } else {
33957
- superdocVersion.elements[0].elements[0].elements[0].text = version2;
34295
+ property2.elements[0].elements[0].text = finalValue;
34296
+ }
34297
+ return finalValue;
34298
+ }
34299
+ static getStoredSuperdocVersion(docx) {
34300
+ return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
34301
+ }
34302
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.22.0") {
34303
+ return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
34304
+ }
34305
+ /**
34306
+ * Get document GUID from docx files (static method)
34307
+ * @static
34308
+ * @param {Array} docx - Array of docx file objects
34309
+ * @returns {string|null} The document GUID
34310
+ */
34311
+ static extractDocumentGuid(docx) {
34312
+ try {
34313
+ const settingsXml = docx.find((doc2) => doc2.name === "word/settings.xml");
34314
+ if (!settingsXml) return null;
34315
+ const converter = new _SuperConverter2();
34316
+ const settingsJson = converter.parseXmlToJson(settingsXml.content);
34317
+ const settings = settingsJson.elements?.[0];
34318
+ if (!settings) return null;
34319
+ const docIdElement = settings.elements?.find((el) => el.name === "w15:docId");
34320
+ if (docIdElement?.attributes?.["w15:val"]) {
34321
+ return docIdElement.attributes["w15:val"].replace(/[{}]/g, "");
34322
+ }
34323
+ } catch {
34324
+ }
34325
+ return _SuperConverter2.getStoredCustomProperty(docx, "DocumentGuid");
34326
+ }
34327
+ /**
34328
+ * Get the permanent document GUID
34329
+ * @returns {string|null} The document GUID (only for modified documents)
34330
+ */
34331
+ getDocumentGuid() {
34332
+ return this.documentGuid;
34333
+ }
34334
+ /**
34335
+ * Get the SuperDoc version for this converter instance
34336
+ * @returns {string|null} The SuperDoc version or null if not available
34337
+ */
34338
+ getSuperdocVersion() {
34339
+ if (this.docx) {
34340
+ return _SuperConverter2.getStoredSuperdocVersion(this.docx);
34341
+ }
34342
+ return null;
34343
+ }
34344
+ /**
34345
+ * Resolve existing document GUID (synchronous)
34346
+ */
34347
+ resolveDocumentGuid() {
34348
+ const microsoftGuid = this.getMicrosoftDocId();
34349
+ if (microsoftGuid) {
34350
+ this.documentGuid = microsoftGuid;
34351
+ return;
34352
+ }
34353
+ const customGuid = _SuperConverter2.getStoredCustomProperty(this.docx, "DocumentGuid");
34354
+ if (customGuid) {
34355
+ this.documentGuid = customGuid;
34356
+ }
34357
+ }
34358
+ /**
34359
+ * Get Microsoft's docId from settings.xml (READ ONLY)
34360
+ */
34361
+ getMicrosoftDocId() {
34362
+ this.getDocumentInternalId();
34363
+ if (this.documentInternalId) {
34364
+ return this.documentInternalId.replace(/[{}]/g, "");
34365
+ }
34366
+ return null;
34367
+ }
34368
+ /**
34369
+ * Get document identifier (GUID or hash) - async for lazy hash generation
34370
+ */
34371
+ async getDocumentIdentifier() {
34372
+ if (this.documentGuid) {
34373
+ return this.documentGuid;
34374
+ }
34375
+ if (!this.documentHash && this.fileSource) {
34376
+ this.documentHash = await __privateMethod$2(this, _SuperConverter_instances, generateDocumentHash_fn).call(this);
33958
34377
  }
33959
- return docx;
34378
+ return this.documentHash;
34379
+ }
34380
+ /**
34381
+ * Promote from hash to GUID on first edit
34382
+ */
34383
+ promoteToGuid() {
34384
+ if (this.documentGuid) return this.documentGuid;
34385
+ this.documentGuid = this.getMicrosoftDocId() || v4();
34386
+ this.documentModified = true;
34387
+ this.documentHash = null;
34388
+ return this.documentGuid;
33960
34389
  }
33961
34390
  getDocumentDefaultStyles() {
33962
34391
  const styles = this.convertedXml["word/styles.xml"];
@@ -34045,20 +34474,14 @@ const _SuperConverter = class _SuperConverter2 {
34045
34474
  getDocumentInternalId() {
34046
34475
  const settingsLocation = "word/settings.xml";
34047
34476
  if (!this.convertedXml[settingsLocation]) {
34048
- this.convertedXml[settingsLocation] = SETTINGS_CUSTOM_XML;
34477
+ return;
34049
34478
  }
34050
- const settings = Object.assign({}, this.convertedXml[settingsLocation]);
34051
- if (!settings.elements[0]?.elements?.length) {
34052
- const idElement = this.createDocumentIdElement(settings);
34053
- settings.elements[0].elements = [idElement];
34054
- if (!settings.elements[0].attributes["xmlns:w15"]) {
34055
- settings.elements[0].attributes["xmlns:w15"] = "http://schemas.microsoft.com/office/word/2012/wordml";
34056
- }
34057
- this.convertedXml[settingsLocation] = settings;
34479
+ const settings = this.convertedXml[settingsLocation];
34480
+ if (!settings.elements?.[0]?.elements?.length) {
34058
34481
  return;
34059
34482
  }
34060
34483
  const w15DocId = settings.elements[0].elements.find((el) => el.name === "w15:docId");
34061
- this.documentInternalId = w15DocId?.attributes["w15:val"];
34484
+ this.documentInternalId = w15DocId?.attributes?.["w15:val"];
34062
34485
  }
34063
34486
  createDocumentIdElement() {
34064
34487
  const docId = v4().toUpperCase();
@@ -34147,7 +34570,13 @@ const _SuperConverter = class _SuperConverter2 {
34147
34570
  this.convertedXml = { ...this.convertedXml, ...updatedXml };
34148
34571
  const headFootRels = __privateMethod$2(this, _SuperConverter_instances, exportProcessHeadersFooters_fn).call(this, { isFinalDoc });
34149
34572
  __privateMethod$2(this, _SuperConverter_instances, exportProcessNewRelationships_fn).call(this, [...params2.relationships, ...commentsRels, ...headFootRels]);
34150
- storeSuperdocVersion(this.convertedXml);
34573
+ _SuperConverter2.setStoredSuperdocVersion(this.convertedXml);
34574
+ if (this.documentModified || this.documentGuid) {
34575
+ if (!this.documentGuid) {
34576
+ this.documentGuid = this.getMicrosoftDocId() || v4();
34577
+ }
34578
+ _SuperConverter2.setStoredCustomProperty(this.convertedXml, "DocumentGuid", this.documentGuid, true);
34579
+ }
34151
34580
  __privateMethod$2(this, _SuperConverter_instances, exportNumberingFile_fn).call(this, params2);
34152
34581
  return xml;
34153
34582
  }
@@ -34182,8 +34611,38 @@ const _SuperConverter = class _SuperConverter2 {
34182
34611
  });
34183
34612
  return { result, params: params2 };
34184
34613
  }
34614
+ // Deprecated methods for backward compatibility
34615
+ static getStoredSuperdocId(docx) {
34616
+ console.warn("getStoredSuperdocId is deprecated, use getDocumentGuid instead");
34617
+ return _SuperConverter2.extractDocumentGuid(docx);
34618
+ }
34619
+ static updateDocumentVersion(docx, version2) {
34620
+ console.warn("updateDocumentVersion is deprecated, use setStoredSuperdocVersion instead");
34621
+ return _SuperConverter2.setStoredSuperdocVersion(docx, version2);
34622
+ }
34185
34623
  };
34186
34624
  _SuperConverter_instances = /* @__PURE__ */ new WeakSet();
34625
+ generateDocumentHash_fn = async function() {
34626
+ if (!this.fileSource) return `HASH-${Date.now()}`;
34627
+ try {
34628
+ let buffer2;
34629
+ if (Buffer2.isBuffer(this.fileSource)) {
34630
+ buffer2 = this.fileSource;
34631
+ } else if (this.fileSource instanceof ArrayBuffer) {
34632
+ buffer2 = Buffer2.from(this.fileSource);
34633
+ } else if (this.fileSource instanceof Blob || this.fileSource instanceof File) {
34634
+ const arrayBuffer = await this.fileSource.arrayBuffer();
34635
+ buffer2 = Buffer2.from(arrayBuffer);
34636
+ } else {
34637
+ return `HASH-${Date.now()}`;
34638
+ }
34639
+ const hash2 = index$2(buffer2);
34640
+ return `HASH-${hash2.toString("hex").toUpperCase()}`;
34641
+ } catch (e) {
34642
+ console.warn("Could not generate document hash:", e);
34643
+ return `HASH-${Date.now()}`;
34644
+ }
34645
+ };
34187
34646
  exportNumberingFile_fn = function() {
34188
34647
  const numberingPath = "word/numbering.xml";
34189
34648
  let numberingXml = this.convertedXml[numberingPath];
@@ -34404,52 +34863,9 @@ __publicField$2(_SuperConverter, "propertyTypes", Object.freeze({
34404
34863
  }));
34405
34864
  __publicField$2(_SuperConverter, "elements", /* @__PURE__ */ new Set(["w:document", "w:body", "w:p", "w:r", "w:t", "w:delText"]));
34406
34865
  let SuperConverter = _SuperConverter;
34407
- function storeSuperdocVersion(docx) {
34408
- const customLocation = "docProps/custom.xml";
34409
- if (!docx[customLocation]) docx[customLocation] = generateCustomXml();
34410
- const customXml = docx[customLocation];
34411
- const properties = customXml.elements.find((el) => el.name === "Properties");
34412
- if (!properties.elements) properties.elements = [];
34413
- const elements = properties.elements;
34414
- const cleanProperties = elements.filter((prop) => typeof prop === "object" && prop !== null).filter((prop) => {
34415
- const { attributes } = prop;
34416
- return attributes.name !== "SuperdocVersion";
34417
- });
34418
- let pid = 2;
34419
- try {
34420
- pid = cleanProperties.length ? Math.max(...elements.map((el) => el.attributes.pid)) + 1 : 2;
34421
- } catch {
34422
- }
34423
- cleanProperties.push(generateSuperdocVersion(pid));
34424
- properties.elements = cleanProperties;
34425
- return docx;
34426
- }
34427
34866
  function generateCustomXml() {
34428
34867
  return DEFAULT_CUSTOM_XML;
34429
34868
  }
34430
- function generateSuperdocVersion(pid = 2, version2 = "0.22.0") {
34431
- return {
34432
- type: "element",
34433
- name: "property",
34434
- attributes: {
34435
- name: "SuperdocVersion",
34436
- fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
34437
- pid
34438
- },
34439
- elements: [
34440
- {
34441
- type: "element",
34442
- name: "vt:lpwstr",
34443
- elements: [
34444
- {
34445
- type: "text",
34446
- text: version2
34447
- }
34448
- ]
34449
- }
34450
- ]
34451
- };
34452
- }
34453
34869
  function commonjsRequire(path) {
34454
34870
  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.');
34455
34871
  }
@@ -36765,7 +37181,7 @@ function requireJszip_min() {
36765
37181
  return jszip_min.exports;
36766
37182
  }
36767
37183
  var jszip_minExports = requireJszip_min();
36768
- const JSZip = /* @__PURE__ */ getDefaultExportFromCjs$1(jszip_minExports);
37184
+ const JSZip = /* @__PURE__ */ getDefaultExportFromCjs$2(jszip_minExports);
36769
37185
  const isXmlLike = (name) => /\.xml$|\.rels$/i.test(name);
36770
37186
  function sniffEncoding(u8) {
36771
37187
  if (u8.length >= 2) {
@@ -46720,15 +47136,39 @@ const toggleList = (listType) => ({ editor, state: state2, tr, dispatch }) => {
46720
47136
  if (near) {
46721
47137
  const isSameAsTarget = nearKind === targetKind;
46722
47138
  if (isSameAsTarget) {
46723
- const { pos: pos2, node } = near;
46724
- const spanFromBefore2 = pos2;
46725
- const spanToBefore2 = pos2 + node.nodeSize;
46726
- const paras = [];
46727
- for (let i = 0; i < node.childCount; i++) {
46728
- const li = node.child(i);
46729
- paras.push(li.firstChild || editor.schema.nodes.paragraph.create());
46730
- }
46731
- tr.replaceWith(pos2, pos2 + node.nodeSize, paras);
47139
+ const candidateLists = collectIntersectingTopLists({ doc: doc2, selection, OrderedType, BulletType });
47140
+ let listsToUnwrap = candidateLists.filter(({ node }) => getEffectiveListKind(node) === targetKind);
47141
+ if (listsToUnwrap.length === 0 && getEffectiveListKind(near.node) === targetKind) {
47142
+ listsToUnwrap = [{ node: near.node, pos: near.pos, depth: near.depth ?? null }];
47143
+ }
47144
+ if (listsToUnwrap.length === 0) return false;
47145
+ let spanFromBefore2 = listsToUnwrap[0].pos;
47146
+ let spanToBefore2 = listsToUnwrap[0].pos + listsToUnwrap[0].node.nodeSize;
47147
+ for (let i = 1; i < listsToUnwrap.length; i++) {
47148
+ const { node, pos: pos2 } = listsToUnwrap[i];
47149
+ spanFromBefore2 = Math.min(spanFromBefore2, pos2);
47150
+ spanToBefore2 = Math.max(spanToBefore2, pos2 + node.nodeSize);
47151
+ }
47152
+ const ParagraphType = editor.schema.nodes.paragraph;
47153
+ listsToUnwrap.sort((a, b2) => b2.pos - a.pos);
47154
+ for (const { node, pos: pos2 } of listsToUnwrap) {
47155
+ const mappedFrom = tr.mapping.map(pos2, -1);
47156
+ const mappedTo = tr.mapping.map(pos2 + node.nodeSize, 1);
47157
+ const currentListNode = tr.doc.nodeAt(mappedFrom);
47158
+ const sourceListNode = currentListNode && (currentListNode.type === OrderedType || currentListNode.type === BulletType) ? currentListNode : node;
47159
+ const paragraphs = [];
47160
+ for (let i = 0; i < sourceListNode.childCount; i++) {
47161
+ const li = sourceListNode.child(i);
47162
+ if (li.type !== editor.schema.nodes.listItem) continue;
47163
+ const firstChild = li.firstChild;
47164
+ paragraphs.push(firstChild || ParagraphType.create());
47165
+ }
47166
+ if (paragraphs.length === 0) {
47167
+ paragraphs.push(ParagraphType.create());
47168
+ }
47169
+ const replacement = paragraphs.length === 1 ? paragraphs[0] : Fragment.from(paragraphs);
47170
+ tr.replaceWith(mappedFrom, mappedTo, replacement);
47171
+ }
46732
47172
  setMappedSelectionSpan(tr, spanFromBefore2, spanToBefore2);
46733
47173
  if (dispatch) dispatch(tr);
46734
47174
  return true;
@@ -51525,19 +51965,34 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
51525
51965
  * @returns {string} Document version
51526
51966
  */
51527
51967
  static getDocumentVersion(doc2) {
51528
- const version2 = SuperConverter.getStoredSuperdocVersion(doc2);
51529
- return version2;
51968
+ return SuperConverter.getStoredSuperdocVersion(doc2);
51530
51969
  }
51531
51970
  /**
51532
- * Update the document version
51971
+ * Set the document version
51533
51972
  * @static
51534
51973
  * @param {Object} doc - Document object
51535
51974
  * @param {string} version - New version
51536
- * @returns {Object}
51975
+ * @returns {string} The set version
51976
+ */
51977
+ static setDocumentVersion(doc2, version2) {
51978
+ return SuperConverter.setStoredSuperdocVersion(doc2, version2);
51979
+ }
51980
+ /**
51981
+ * Get the document GUID
51982
+ * @static
51983
+ * @param {Object} doc - Document object
51984
+ * @returns {string|null} Document GUID
51985
+ */
51986
+ static getDocumentGuid(doc2) {
51987
+ return SuperConverter.extractDocumentGuid(doc2);
51988
+ }
51989
+ // Deprecated
51990
+ /**
51991
+ * @deprecated use setDocumentVersion instead
51537
51992
  */
51538
51993
  static updateDocumentVersion(doc2, version2) {
51539
- const updatedContent = SuperConverter.updateDocumentVersion(doc2, version2);
51540
- return updatedContent;
51994
+ console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead");
51995
+ return _Editor2.setDocumentVersion(doc2, version2);
51541
51996
  }
51542
51997
  /**
51543
51998
  * Creates all node views.
@@ -51673,6 +52128,43 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
51673
52128
  }
51674
52129
  window.addEventListener("resize", () => handleResize);
51675
52130
  }
52131
+ /**
52132
+ * Get document identifier for telemetry (async - may generate hash)
52133
+ * @returns {Promise<string>} GUID for modified docs, hash for unmodified
52134
+ */
52135
+ async getDocumentIdentifier() {
52136
+ return await this.converter?.getDocumentIdentifier() || null;
52137
+ }
52138
+ /**
52139
+ * Get permanent document GUID (sync - only for modified documents)
52140
+ * @returns {string|null} GUID or null if document hasn't been modified
52141
+ */
52142
+ getDocumentGuid() {
52143
+ return this.converter?.documentGuid || null;
52144
+ }
52145
+ /**
52146
+ * Check if document has been modified
52147
+ * @returns {boolean}
52148
+ */
52149
+ isDocumentModified() {
52150
+ return this.converter?.documentModified || false;
52151
+ }
52152
+ /**
52153
+ * Get telemetry data (async because of lazy hash generation)
52154
+ */
52155
+ async getTelemetryData() {
52156
+ return {
52157
+ documentId: await this.getDocumentIdentifier(),
52158
+ isModified: this.isDocumentModified(),
52159
+ isPermanentId: !!this.converter?.documentGuid,
52160
+ version: this.converter?.getSuperdocVersion()
52161
+ };
52162
+ }
52163
+ // Deprecated for backward compatibility
52164
+ getDocumentId() {
52165
+ console.warn("getDocumentId is deprecated, use getDocumentGuid instead");
52166
+ return this.getDocumentGuid();
52167
+ }
51676
52168
  /**
51677
52169
  * Get attrs of the currently selected node or mark.
51678
52170
  * @param {String} nameOrType
@@ -51704,6 +52196,21 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
51704
52196
  getJSON() {
51705
52197
  return this.state.doc.toJSON();
51706
52198
  }
52199
+ /**
52200
+ * Get document metadata including GUID, modification status, and version
52201
+ * @returns {{
52202
+ * documentGuid: string | null,
52203
+ * isModified: boolean,
52204
+ * version: string | null
52205
+ * }} Document metadata
52206
+ */
52207
+ getMetadata() {
52208
+ return {
52209
+ documentGuid: this.converter?.documentGuid || null,
52210
+ isModified: this.isDocumentModified(),
52211
+ version: this.converter?.getSuperdocVersion() || null
52212
+ };
52213
+ }
51707
52214
  /**
51708
52215
  * Get the editor content as HTML
51709
52216
  * @param {Object} options - Options for the HTML serializer
@@ -51721,6 +52228,13 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
51721
52228
  }
51722
52229
  return html;
51723
52230
  }
52231
+ /**
52232
+ * Get the document version from the converter
52233
+ * @returns {string|null} The SuperDoc version stored in the document
52234
+ */
52235
+ getDocumentVersion() {
52236
+ return this.converter?.getSuperdocVersion() || null;
52237
+ }
51724
52238
  /**
51725
52239
  * Create a child editor linked to this editor.
51726
52240
  * This is useful for creating header/footer editors that are linked to the main editor.
@@ -51803,7 +52317,8 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
51803
52317
  if (exportXmlOnly || exportJsonOnly) return documentXml;
51804
52318
  const customXml = this.converter.schemaToXml(this.converter.convertedXml["docProps/custom.xml"].elements[0]);
51805
52319
  const styles = this.converter.schemaToXml(this.converter.convertedXml["word/styles.xml"].elements[0]);
51806
- const customSettings = this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"].elements[0]);
52320
+ const hasCustomSettings = !!this.converter.convertedXml["word/settings.xml"]?.elements?.length;
52321
+ const customSettings = hasCustomSettings ? this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"]?.elements?.[0]) : null;
51807
52322
  const rels = this.converter.schemaToXml(this.converter.convertedXml["word/_rels/document.xml.rels"].elements[0]);
51808
52323
  const media = this.converter.addedMedia;
51809
52324
  const updatedHeadersFooters = {};
@@ -51819,13 +52334,15 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
51819
52334
  ...this.options.customUpdatedFiles,
51820
52335
  "word/document.xml": String(documentXml),
51821
52336
  "docProps/custom.xml": String(customXml),
51822
- "word/settings.xml": String(customSettings),
51823
52337
  "word/_rels/document.xml.rels": String(rels),
51824
52338
  "word/numbering.xml": String(numbering),
51825
52339
  // Replace & with &amp; in styles.xml as DOCX viewers can't handle it
51826
52340
  "word/styles.xml": String(styles).replace(/&/gi, "&amp;"),
51827
52341
  ...updatedHeadersFooters
51828
52342
  };
52343
+ if (hasCustomSettings) {
52344
+ updatedDocs["word/settings.xml"] = String(customSettings);
52345
+ }
51829
52346
  if (comments.length) {
51830
52347
  const commentsXml = this.converter.schemaToXml(this.converter.convertedXml["word/comments.xml"].elements[0]);
51831
52348
  const commentsExtendedXml = this.converter.schemaToXml(
@@ -52445,6 +52962,13 @@ dispatchTransaction_fn = function(transaction) {
52445
52962
  if (!transaction.docChanged) {
52446
52963
  return;
52447
52964
  }
52965
+ if (transaction.docChanged && this.converter) {
52966
+ if (!this.converter.documentGuid) {
52967
+ this.converter.promoteToGuid();
52968
+ console.debug("Document modified - assigned GUID:", this.converter.documentGuid);
52969
+ }
52970
+ this.converter.documentModified = true;
52971
+ }
52448
52972
  this.emit("update", {
52449
52973
  editor: this,
52450
52974
  transaction
@@ -82078,7 +82602,7 @@ function requireEventemitter3() {
82078
82602
  return eventemitter3.exports;
82079
82603
  }
82080
82604
  var eventemitter3Exports = requireEventemitter3();
82081
- const EventEmitter2 = /* @__PURE__ */ getDefaultExportFromCjs$1(eventemitter3Exports);
82605
+ const EventEmitter2 = /* @__PURE__ */ getDefaultExportFromCjs$2(eventemitter3Exports);
82082
82606
  const useToolbarItem = (options) => {
82083
82607
  const types2 = ["button", "options", "separator", "dropdown", "overflow"];
82084
82608
  if (!types2.includes(options.type)) {