@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
@@ -1,4 +1,4 @@
1
- import { p as process$1, aw as commonjsGlobal, B as Buffer, ax as getDefaultExportFromCjs, ay as getContentTypesFromXml, az as xmljs } from "./converter-DD7uNz2k.js";
1
+ import { p as process$1, aw as commonjsGlobal, B as Buffer, ax as getDefaultExportFromCjs, ay as getContentTypesFromXml, az as xmljs } from "./converter-vEmAnrOg.js";
2
2
  function commonjsRequire(path) {
3
3
  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.');
4
4
  }
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as updateDOMAttributes, ah as findChildren$5, ai as htmlHandler, aj as generateRandomSigned32BitIntStrId, ak as InputRule, al as kebabCase, am as findParentNodeClosestToPos, an as getListItemStyleDefinitions, ao as docxNumberigHelpers, ap as parseIndentElement, aq as combineIndents, ar as SelectionRange, as as Transform, at as isInTable$1, au as generateDocxRandomId, av as insertNewRelationship } from "./converter-DD7uNz2k.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as updateDOMAttributes, ah as findChildren$5, ai as htmlHandler, aj as generateRandomSigned32BitIntStrId, ak as InputRule, al as kebabCase, am as findParentNodeClosestToPos, an as getListItemStyleDefinitions, ao as docxNumberigHelpers, ap as parseIndentElement, aq as combineIndents, ar as SelectionRange, as as Transform, at as isInTable$1, au as generateDocxRandomId, av as insertNewRelationship } from "./converter-vEmAnrOg.js";
16
16
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
17
- import { D as DocxZipper } from "./docx-zipper-DraPR30Z.js";
17
+ import { D as DocxZipper } from "./docx-zipper-DA00N7eN.js";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
20
20
  };
@@ -9674,15 +9674,39 @@ const toggleList = (listType) => ({ editor, state, tr, dispatch }) => {
9674
9674
  if (near) {
9675
9675
  const isSameAsTarget = nearKind === targetKind;
9676
9676
  if (isSameAsTarget) {
9677
- const { pos: pos2, node } = near;
9678
- const spanFromBefore2 = pos2;
9679
- const spanToBefore2 = pos2 + node.nodeSize;
9680
- const paras = [];
9681
- for (let i = 0; i < node.childCount; i++) {
9682
- const li = node.child(i);
9683
- paras.push(li.firstChild || editor.schema.nodes.paragraph.create());
9684
- }
9685
- tr.replaceWith(pos2, pos2 + node.nodeSize, paras);
9677
+ const candidateLists = collectIntersectingTopLists({ doc: doc2, selection, OrderedType, BulletType });
9678
+ let listsToUnwrap = candidateLists.filter(({ node }) => getEffectiveListKind(node) === targetKind);
9679
+ if (listsToUnwrap.length === 0 && getEffectiveListKind(near.node) === targetKind) {
9680
+ listsToUnwrap = [{ node: near.node, pos: near.pos, depth: near.depth ?? null }];
9681
+ }
9682
+ if (listsToUnwrap.length === 0) return false;
9683
+ let spanFromBefore2 = listsToUnwrap[0].pos;
9684
+ let spanToBefore2 = listsToUnwrap[0].pos + listsToUnwrap[0].node.nodeSize;
9685
+ for (let i = 1; i < listsToUnwrap.length; i++) {
9686
+ const { node, pos: pos2 } = listsToUnwrap[i];
9687
+ spanFromBefore2 = Math.min(spanFromBefore2, pos2);
9688
+ spanToBefore2 = Math.max(spanToBefore2, pos2 + node.nodeSize);
9689
+ }
9690
+ const ParagraphType = editor.schema.nodes.paragraph;
9691
+ listsToUnwrap.sort((a, b) => b.pos - a.pos);
9692
+ for (const { node, pos: pos2 } of listsToUnwrap) {
9693
+ const mappedFrom = tr.mapping.map(pos2, -1);
9694
+ const mappedTo = tr.mapping.map(pos2 + node.nodeSize, 1);
9695
+ const currentListNode = tr.doc.nodeAt(mappedFrom);
9696
+ const sourceListNode = currentListNode && (currentListNode.type === OrderedType || currentListNode.type === BulletType) ? currentListNode : node;
9697
+ const paragraphs = [];
9698
+ for (let i = 0; i < sourceListNode.childCount; i++) {
9699
+ const li = sourceListNode.child(i);
9700
+ if (li.type !== editor.schema.nodes.listItem) continue;
9701
+ const firstChild = li.firstChild;
9702
+ paragraphs.push(firstChild || ParagraphType.create());
9703
+ }
9704
+ if (paragraphs.length === 0) {
9705
+ paragraphs.push(ParagraphType.create());
9706
+ }
9707
+ const replacement = paragraphs.length === 1 ? paragraphs[0] : Fragment.from(paragraphs);
9708
+ tr.replaceWith(mappedFrom, mappedTo, replacement);
9709
+ }
9686
9710
  setMappedSelectionSpan(tr, spanFromBefore2, spanToBefore2);
9687
9711
  if (dispatch) dispatch(tr);
9688
9712
  return true;
@@ -14531,19 +14555,34 @@ const _Editor = class _Editor extends EventEmitter {
14531
14555
  * @returns {string} Document version
14532
14556
  */
14533
14557
  static getDocumentVersion(doc2) {
14534
- const version2 = SuperConverter.getStoredSuperdocVersion(doc2);
14535
- return version2;
14558
+ return SuperConverter.getStoredSuperdocVersion(doc2);
14536
14559
  }
14537
14560
  /**
14538
- * Update the document version
14561
+ * Set the document version
14539
14562
  * @static
14540
14563
  * @param {Object} doc - Document object
14541
14564
  * @param {string} version - New version
14542
- * @returns {Object}
14565
+ * @returns {string} The set version
14566
+ */
14567
+ static setDocumentVersion(doc2, version2) {
14568
+ return SuperConverter.setStoredSuperdocVersion(doc2, version2);
14569
+ }
14570
+ /**
14571
+ * Get the document GUID
14572
+ * @static
14573
+ * @param {Object} doc - Document object
14574
+ * @returns {string|null} Document GUID
14575
+ */
14576
+ static getDocumentGuid(doc2) {
14577
+ return SuperConverter.extractDocumentGuid(doc2);
14578
+ }
14579
+ // Deprecated
14580
+ /**
14581
+ * @deprecated use setDocumentVersion instead
14543
14582
  */
14544
14583
  static updateDocumentVersion(doc2, version2) {
14545
- const updatedContent = SuperConverter.updateDocumentVersion(doc2, version2);
14546
- return updatedContent;
14584
+ console.warn("updateDocumentVersion is deprecated, use setDocumentVersion instead");
14585
+ return _Editor.setDocumentVersion(doc2, version2);
14547
14586
  }
14548
14587
  /**
14549
14588
  * Creates all node views.
@@ -14679,6 +14718,43 @@ const _Editor = class _Editor extends EventEmitter {
14679
14718
  }
14680
14719
  window.addEventListener("resize", () => handleResize);
14681
14720
  }
14721
+ /**
14722
+ * Get document identifier for telemetry (async - may generate hash)
14723
+ * @returns {Promise<string>} GUID for modified docs, hash for unmodified
14724
+ */
14725
+ async getDocumentIdentifier() {
14726
+ return await this.converter?.getDocumentIdentifier() || null;
14727
+ }
14728
+ /**
14729
+ * Get permanent document GUID (sync - only for modified documents)
14730
+ * @returns {string|null} GUID or null if document hasn't been modified
14731
+ */
14732
+ getDocumentGuid() {
14733
+ return this.converter?.documentGuid || null;
14734
+ }
14735
+ /**
14736
+ * Check if document has been modified
14737
+ * @returns {boolean}
14738
+ */
14739
+ isDocumentModified() {
14740
+ return this.converter?.documentModified || false;
14741
+ }
14742
+ /**
14743
+ * Get telemetry data (async because of lazy hash generation)
14744
+ */
14745
+ async getTelemetryData() {
14746
+ return {
14747
+ documentId: await this.getDocumentIdentifier(),
14748
+ isModified: this.isDocumentModified(),
14749
+ isPermanentId: !!this.converter?.documentGuid,
14750
+ version: this.converter?.getSuperdocVersion()
14751
+ };
14752
+ }
14753
+ // Deprecated for backward compatibility
14754
+ getDocumentId() {
14755
+ console.warn("getDocumentId is deprecated, use getDocumentGuid instead");
14756
+ return this.getDocumentGuid();
14757
+ }
14682
14758
  /**
14683
14759
  * Get attrs of the currently selected node or mark.
14684
14760
  * @param {String} nameOrType
@@ -14710,6 +14786,21 @@ const _Editor = class _Editor extends EventEmitter {
14710
14786
  getJSON() {
14711
14787
  return this.state.doc.toJSON();
14712
14788
  }
14789
+ /**
14790
+ * Get document metadata including GUID, modification status, and version
14791
+ * @returns {{
14792
+ * documentGuid: string | null,
14793
+ * isModified: boolean,
14794
+ * version: string | null
14795
+ * }} Document metadata
14796
+ */
14797
+ getMetadata() {
14798
+ return {
14799
+ documentGuid: this.converter?.documentGuid || null,
14800
+ isModified: this.isDocumentModified(),
14801
+ version: this.converter?.getSuperdocVersion() || null
14802
+ };
14803
+ }
14713
14804
  /**
14714
14805
  * Get the editor content as HTML
14715
14806
  * @param {Object} options - Options for the HTML serializer
@@ -14727,6 +14818,13 @@ const _Editor = class _Editor extends EventEmitter {
14727
14818
  }
14728
14819
  return html;
14729
14820
  }
14821
+ /**
14822
+ * Get the document version from the converter
14823
+ * @returns {string|null} The SuperDoc version stored in the document
14824
+ */
14825
+ getDocumentVersion() {
14826
+ return this.converter?.getSuperdocVersion() || null;
14827
+ }
14730
14828
  /**
14731
14829
  * Create a child editor linked to this editor.
14732
14830
  * This is useful for creating header/footer editors that are linked to the main editor.
@@ -14809,7 +14907,8 @@ const _Editor = class _Editor extends EventEmitter {
14809
14907
  if (exportXmlOnly || exportJsonOnly) return documentXml;
14810
14908
  const customXml = this.converter.schemaToXml(this.converter.convertedXml["docProps/custom.xml"].elements[0]);
14811
14909
  const styles = this.converter.schemaToXml(this.converter.convertedXml["word/styles.xml"].elements[0]);
14812
- const customSettings = this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"].elements[0]);
14910
+ const hasCustomSettings = !!this.converter.convertedXml["word/settings.xml"]?.elements?.length;
14911
+ const customSettings = hasCustomSettings ? this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"]?.elements?.[0]) : null;
14813
14912
  const rels = this.converter.schemaToXml(this.converter.convertedXml["word/_rels/document.xml.rels"].elements[0]);
14814
14913
  const media = this.converter.addedMedia;
14815
14914
  const updatedHeadersFooters = {};
@@ -14825,13 +14924,15 @@ const _Editor = class _Editor extends EventEmitter {
14825
14924
  ...this.options.customUpdatedFiles,
14826
14925
  "word/document.xml": String(documentXml),
14827
14926
  "docProps/custom.xml": String(customXml),
14828
- "word/settings.xml": String(customSettings),
14829
14927
  "word/_rels/document.xml.rels": String(rels),
14830
14928
  "word/numbering.xml": String(numbering),
14831
14929
  // Replace & with &amp; in styles.xml as DOCX viewers can't handle it
14832
14930
  "word/styles.xml": String(styles).replace(/&/gi, "&amp;"),
14833
14931
  ...updatedHeadersFooters
14834
14932
  };
14933
+ if (hasCustomSettings) {
14934
+ updatedDocs["word/settings.xml"] = String(customSettings);
14935
+ }
14835
14936
  if (comments.length) {
14836
14937
  const commentsXml = this.converter.schemaToXml(this.converter.convertedXml["word/comments.xml"].elements[0]);
14837
14938
  const commentsExtendedXml = this.converter.schemaToXml(
@@ -15542,6 +15643,13 @@ dispatchTransaction_fn = function(transaction) {
15542
15643
  if (!transaction.docChanged) {
15543
15644
  return;
15544
15645
  }
15646
+ if (transaction.docChanged && this.converter) {
15647
+ if (!this.converter.documentGuid) {
15648
+ this.converter.promoteToGuid();
15649
+ console.debug("Document modified - assigned GUID:", this.converter.documentGuid);
15650
+ }
15651
+ this.converter.documentModified = true;
15652
+ }
15545
15653
  this.emit("update", {
15546
15654
  editor: this,
15547
15655
  transaction
@@ -1,6 +1,6 @@
1
1
  import { computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeClass, normalizeStyle, ref, withKeys, unref, withModifiers, createBlock, toDisplayString, withDirectives, vModelText, nextTick, getCurrentInstance, createVNode, readonly, watch, onMounted, onBeforeUnmount, reactive, onBeforeMount, inject, onActivated, onDeactivated, createTextVNode, Fragment, Comment, defineComponent, provide, h, Teleport, toRef, renderSlot, isVNode, shallowRef, watchEffect, mergeProps, Transition, vShow, cloneVNode, Text, renderList, withCtx } from "vue";
2
- import { p as process$1 } from "./converter-DD7uNz2k.js";
3
- import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-xzhKWRFZ.js";
2
+ import { p as process$1 } from "./converter-vEmAnrOg.js";
3
+ import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-CVzagv2Y.js";
4
4
  const sanitizeNumber = (value, defaultNumber) => {
5
5
  let sanitized = value.replace(/[^0-9.]/g, "");
6
6
  sanitized = parseFloat(sanitized);
@@ -1,4 +1,4 @@
1
- import { a5 } from "./chunks/converter-DD7uNz2k.js";
1
+ import { a5 } from "./chunks/converter-vEmAnrOg.js";
2
2
  import "vue";
3
3
  export {
4
4
  a5 as SuperConverter
@@ -1,5 +1,5 @@
1
- import "./chunks/converter-DD7uNz2k.js";
2
- import { D } from "./chunks/docx-zipper-DraPR30Z.js";
1
+ import "./chunks/converter-vEmAnrOg.js";
2
+ import { D } from "./chunks/docx-zipper-DA00N7eN.js";
3
3
  export {
4
4
  D as default
5
5
  };
@@ -1,6 +1,6 @@
1
- import { E } from "./chunks/editor-xzhKWRFZ.js";
2
- import "./chunks/converter-DD7uNz2k.js";
3
- import "./chunks/docx-zipper-DraPR30Z.js";
1
+ import { E } from "./chunks/editor-CVzagv2Y.js";
2
+ import "./chunks/converter-vEmAnrOg.js";
3
+ import "./chunks/docx-zipper-DA00N7eN.js";
4
4
  export {
5
5
  E as Editor
6
6
  };
@@ -1,4 +1,4 @@
1
- import { J as JSZip } from "./chunks/docx-zipper-DraPR30Z.js";
1
+ import { J as JSZip } from "./chunks/docx-zipper-DA00N7eN.js";
2
2
  async function createZip(blobs, fileNames) {
3
3
  const zip = new JSZip();
4
4
  blobs.forEach((blob, index) => {
@@ -118,13 +118,24 @@ export class Editor extends EventEmitter {
118
118
  */
119
119
  static getDocumentVersion(doc: any): string;
120
120
  /**
121
- * Update the document version
121
+ * Set the document version
122
122
  * @static
123
123
  * @param {Object} doc - Document object
124
124
  * @param {string} version - New version
125
- * @returns {Object}
125
+ * @returns {string} The set version
126
126
  */
127
- static updateDocumentVersion(doc: any, version: string): any;
127
+ static setDocumentVersion(doc: any, version: string): string;
128
+ /**
129
+ * Get the document GUID
130
+ * @static
131
+ * @param {Object} doc - Document object
132
+ * @returns {string|null} Document GUID
133
+ */
134
+ static getDocumentGuid(doc: any): string | null;
135
+ /**
136
+ * @deprecated use setDocumentVersion instead
137
+ */
138
+ static updateDocumentVersion(doc: any, version: any): string;
128
139
  /**
129
140
  * Check if migrations are needed for the data
130
141
  * @static
@@ -381,6 +392,31 @@ export class Editor extends EventEmitter {
381
392
  * @returns {void}
382
393
  */
383
394
  initMobileStyles(element: HTMLElement | void): void;
395
+ /**
396
+ * Get document identifier for telemetry (async - may generate hash)
397
+ * @returns {Promise<string>} GUID for modified docs, hash for unmodified
398
+ */
399
+ getDocumentIdentifier(): Promise<string>;
400
+ /**
401
+ * Get permanent document GUID (sync - only for modified documents)
402
+ * @returns {string|null} GUID or null if document hasn't been modified
403
+ */
404
+ getDocumentGuid(): string | null;
405
+ /**
406
+ * Check if document has been modified
407
+ * @returns {boolean}
408
+ */
409
+ isDocumentModified(): boolean;
410
+ /**
411
+ * Get telemetry data (async because of lazy hash generation)
412
+ */
413
+ getTelemetryData(): Promise<{
414
+ documentId: string;
415
+ isModified: boolean;
416
+ isPermanentId: boolean;
417
+ version: any;
418
+ }>;
419
+ getDocumentId(): string;
384
420
  /**
385
421
  * Get attrs of the currently selected node or mark.
386
422
  * @param {String} nameOrType
@@ -404,6 +440,19 @@ export class Editor extends EventEmitter {
404
440
  * @returns {Object} Editor content as JSON
405
441
  */
406
442
  getJSON(): any;
443
+ /**
444
+ * Get document metadata including GUID, modification status, and version
445
+ * @returns {{
446
+ * documentGuid: string | null,
447
+ * isModified: boolean,
448
+ * version: string | null
449
+ * }} Document metadata
450
+ */
451
+ getMetadata(): {
452
+ documentGuid: string | null;
453
+ isModified: boolean;
454
+ version: string | null;
455
+ };
407
456
  /**
408
457
  * Get the editor content as HTML
409
458
  * @param {Object} options - Options for the HTML serializer
@@ -413,6 +462,11 @@ export class Editor extends EventEmitter {
413
462
  getHTML({ unflattenLists }?: {
414
463
  unflattenLists?: boolean;
415
464
  }): string;
465
+ /**
466
+ * Get the document version from the converter
467
+ * @returns {string|null} The SuperDoc version stored in the document
468
+ */
469
+ getDocumentVersion(): string | null;
416
470
  /**
417
471
  * Create a child editor linked to this editor.
418
472
  * This is useful for creating header/footer editors that are linked to the main editor.
@@ -50,8 +50,35 @@ export class SuperConverter {
50
50
  static getFontTableEntry(docx: any, fontName: any): any;
51
51
  static getFallbackFromFontTable(docx: any, fontName: any): any;
52
52
  static toCssFontFamily(fontName: any, docx: any): any;
53
- static getStoredSuperdocVersion(docx: any): any;
54
- static updateDocumentVersion(docx?: any, version?: any): any;
53
+ /**
54
+ * Generic method to get a stored custom property from docx
55
+ * @static
56
+ * @param {Array} docx - Array of docx file objects
57
+ * @param {string} propertyName - Name of the property to retrieve
58
+ * @returns {string|null} The property value or null if not found
59
+ */
60
+ static getStoredCustomProperty(docx: any[], propertyName: string): string | null;
61
+ /**
62
+ * Generic method to set a stored custom property in docx
63
+ * @static
64
+ * @param {Object} docx - The docx object to store the property in
65
+ * @param {string} propertyName - Name of the property
66
+ * @param {string|Function} value - Value or function that returns the value
67
+ * @param {boolean} preserveExisting - If true, won't overwrite existing values
68
+ * @returns {string} The stored value
69
+ */
70
+ static setStoredCustomProperty(docx: any, propertyName: string, value: string | Function, preserveExisting?: boolean): string;
71
+ static getStoredSuperdocVersion(docx: any): string;
72
+ static setStoredSuperdocVersion(docx?: any, version?: any): string;
73
+ /**
74
+ * Get document GUID from docx files (static method)
75
+ * @static
76
+ * @param {Array} docx - Array of docx file objects
77
+ * @returns {string|null} The document GUID
78
+ */
79
+ static extractDocumentGuid(docx: any[]): string | null;
80
+ static getStoredSuperdocId(docx: any): string;
81
+ static updateDocumentVersion(docx: any, version: any): string;
55
82
  constructor(params?: any);
56
83
  debug: any;
57
84
  declaration: any;
@@ -91,6 +118,9 @@ export class SuperConverter {
91
118
  documentInternalId: any;
92
119
  fileSource: any;
93
120
  documentId: any;
121
+ documentGuid: any;
122
+ documentHash: string;
123
+ documentModified: boolean;
94
124
  /**
95
125
  * Get the DocxHelpers object that contains utility functions for working with docx files.
96
126
  * @returns {import('./docx-helpers/docx-helpers.js').DocxHelpers} The DocxHelpers object.
@@ -98,6 +128,32 @@ export class SuperConverter {
98
128
  get docxHelpers(): any;
99
129
  parseFromXml(): void;
100
130
  parseXmlToJson(xml: any): any;
131
+ /**
132
+ * Get the permanent document GUID
133
+ * @returns {string|null} The document GUID (only for modified documents)
134
+ */
135
+ getDocumentGuid(): string | null;
136
+ /**
137
+ * Get the SuperDoc version for this converter instance
138
+ * @returns {string|null} The SuperDoc version or null if not available
139
+ */
140
+ getSuperdocVersion(): string | null;
141
+ /**
142
+ * Resolve existing document GUID (synchronous)
143
+ */
144
+ resolveDocumentGuid(): void;
145
+ /**
146
+ * Get Microsoft's docId from settings.xml (READ ONLY)
147
+ */
148
+ getMicrosoftDocId(): any;
149
+ /**
150
+ * Get document identifier (GUID or hash) - async for lazy hash generation
151
+ */
152
+ getDocumentIdentifier(): Promise<any>;
153
+ /**
154
+ * Promote from hash to GUID on first edit
155
+ */
156
+ promoteToGuid(): any;
101
157
  getDocumentDefaultStyles(): {};
102
158
  getDocumentFonts(): string;
103
159
  getDocumentInternalId(): void;