@harbour-enterprises/superdoc 0.12.29 → 0.12.30-rev.1

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 (35) hide show
  1. package/dist/chunks/{super-editor.es-DnY3YVQy.cjs → super-editor.es-3Ibj8IyF.cjs} +72 -30
  2. package/dist/chunks/{super-editor.es-DiznnaH9.es.js → super-editor.es-Cs2w1rLv.es.js} +85 -43
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/super-editor/ai-writer.es.js +2 -2
  6. package/dist/super-editor/chunks/{converter-C3avHVhj.js → converter-B3YG794p.js} +2 -2
  7. package/dist/super-editor/chunks/{docx-zipper-CmhOMHgz.js → docx-zipper-CjIsb1a6.js} +1 -1
  8. package/dist/super-editor/chunks/{editor-BXIiZe6R.js → editor-HCMuRikV.js} +73 -31
  9. package/dist/super-editor/chunks/{toolbar-D53fQfyS.js → toolbar-DNy-8F3W.js} +2 -2
  10. package/dist/super-editor/converter.es.js +1 -1
  11. package/dist/super-editor/core/Editor.d.ts +1 -1
  12. package/dist/super-editor/core/Editor.d.ts.map +1 -1
  13. package/dist/super-editor/core/EventEmitter.d.ts +19 -9
  14. package/dist/super-editor/core/EventEmitter.d.ts.map +1 -1
  15. package/dist/super-editor/core/helpers/annotator.d.ts +5 -3
  16. package/dist/super-editor/core/helpers/annotator.d.ts.map +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.d.ts +2 -0
  20. package/dist/super-editor/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.d.ts.map +1 -0
  21. package/dist/super-editor/extensions/field-annotation/fieldAnnotationHelpers/index.d.ts +1 -0
  22. package/dist/super-editor/file-zipper.es.js +1 -1
  23. package/dist/super-editor/index.d.ts +1 -1
  24. package/dist/super-editor/super-editor.es.js +8 -7
  25. package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts +3 -0
  26. package/dist/super-editor/tests/e2e/test-app/dist/assets/index-BTMvkUyI.d.ts.map +1 -0
  27. package/dist/super-editor/tests/e2e/test-app/vite.config.d.ts +1 -1
  28. package/dist/super-editor/toolbar.es.js +2 -2
  29. package/dist/super-editor.cjs +2 -1
  30. package/dist/super-editor.es.js +15 -14
  31. package/dist/superdoc.cjs +3 -2
  32. package/dist/superdoc.es.js +201 -200
  33. package/dist/superdoc.umd.js +73 -31
  34. package/dist/superdoc.umd.js.map +1 -1
  35. package/package.json +1 -1
@@ -30667,7 +30667,7 @@
30667
30667
  return;
30668
30668
  }
30669
30669
  }
30670
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.29") {
30670
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.30-rev.1") {
30671
30671
  const customLocation = "docProps/custom.xml";
30672
30672
  if (!docx[customLocation]) {
30673
30673
  docx[customLocation] = generateCustomXml();
@@ -31133,7 +31133,7 @@
31133
31133
  function generateCustomXml() {
31134
31134
  return DEFAULT_CUSTOM_XML;
31135
31135
  }
31136
- function generateSuperdocVersion(pid = 2, version2 = "0.12.29") {
31136
+ function generateSuperdocVersion(pid = 2, version2 = "0.12.30-rev.1") {
31137
31137
  return {
31138
31138
  type: "element",
31139
31139
  name: "property",
@@ -44987,8 +44987,9 @@
44987
44987
  }
44988
44988
  /**
44989
44989
  * Subscribe to the event.
44990
- * @param name Event name.
44991
- * @param fn Callback.
44990
+ * @param {string} name Event name.
44991
+ * @param {(...args: any[]) => void} fn Callback.
44992
+ * @returns {void}
44992
44993
  */
44993
44994
  on(name, fn2) {
44994
44995
  const callbacks2 = __privateGet$1(this, _events).get(name);
@@ -44997,8 +44998,9 @@
44997
44998
  }
44998
44999
  /**
44999
45000
  * Emit event.
45000
- * @param name Event name.
45001
- * @param args Arguments.
45001
+ * @param {string} name Event name.
45002
+ * @param {...any} args – Arguments to pass to each listener.
45003
+ * @returns {void}
45002
45004
  */
45003
45005
  emit(name, ...args) {
45004
45006
  const callbacks2 = __privateGet$1(this, _events).get(name);
@@ -45010,8 +45012,9 @@
45010
45012
  /**
45011
45013
  * Remove a specific callback from event
45012
45014
  * or all event subscriptions.
45013
- * @param name Event name.
45014
- * @param fn Callback.
45015
+ * @param {string} name Event name.
45016
+ * @param {(...args: any[]) => void} fn Callback.
45017
+ * @returns {void}
45015
45018
  */
45016
45019
  off(name, fn2) {
45017
45020
  const callbacks2 = __privateGet$1(this, _events).get(name);
@@ -45025,6 +45028,19 @@
45025
45028
  __privateGet$1(this, _events).delete(name);
45026
45029
  }
45027
45030
  }
45031
+ /**
45032
+ * Subscribe to an event that will be called only once.
45033
+ * @param {string} name Event name.
45034
+ * @param {(...args: any[]) => void} fn Callback.
45035
+ * @returns {void}
45036
+ */
45037
+ once(name, fn2) {
45038
+ const wrapper = (...args) => {
45039
+ this.off(name, wrapper);
45040
+ fn2.apply(this, args);
45041
+ };
45042
+ this.on(name, wrapper);
45043
+ }
45028
45044
  /**
45029
45045
  * Remove all registered events and subscriptions.
45030
45046
  */
@@ -47408,11 +47424,12 @@
47408
47424
  const getAnnotationValue = (id, annotationValues) => {
47409
47425
  return annotationValues.find((value) => value.input_id === id)?.input_value || null;
47410
47426
  };
47411
- const annotateHeadersAndFooters = ({ editor, annotationValues = [], hiddenFieldIds = [] }) => {
47427
+ const getAllHeaderFooterEditors = (editor) => {
47412
47428
  const sections = {
47413
47429
  header: editor.converter.headers || {},
47414
47430
  footer: editor.converter.footers || {}
47415
47431
  };
47432
+ const allEditors = [];
47416
47433
  Object.entries(sections).forEach(([type2, items]) => {
47417
47434
  const editorsKey = `${type2}Editors`;
47418
47435
  Object.entries(items).forEach(([sectionId, data]) => {
@@ -47430,25 +47447,38 @@
47430
47447
  })
47431
47448
  };
47432
47449
  editor.converter[editorsKey].push(sectionEditor);
47450
+ allEditors.push({
47451
+ ...sectionEditor,
47452
+ key: editorsKey,
47453
+ type: type2,
47454
+ sectionId
47455
+ });
47433
47456
  }
47434
- sectionEditor.editor.annotate(annotationValues, hiddenFieldIds);
47435
- onHeaderFooterDataUpdate(
47436
- { editor: sectionEditor.editor },
47437
- editor,
47438
- sectionId,
47439
- type2
47440
- );
47441
47457
  });
47442
47458
  });
47459
+ return allEditors;
47460
+ };
47461
+ const annotateHeadersAndFooters = ({ editor, annotationValues = [], hiddenFieldIds = [], removeEmptyFields = false }) => {
47462
+ const allEditors = getAllHeaderFooterEditors(editor);
47463
+ allEditors.forEach(({ sectionId, editor: sectionEditor, type: type2 }) => {
47464
+ sectionEditor.annotate(annotationValues, hiddenFieldIds, removeEmptyFields);
47465
+ onHeaderFooterDataUpdate(
47466
+ { editor: sectionEditor },
47467
+ editor,
47468
+ sectionId,
47469
+ type2
47470
+ );
47471
+ });
47443
47472
  };
47444
47473
  const annotateDocument = ({
47445
47474
  annotationValues = [],
47446
47475
  hiddenFieldIds = [],
47476
+ removeEmptyFields = false,
47447
47477
  schema,
47448
47478
  tr,
47449
47479
  editor
47450
47480
  }) => {
47451
- annotateHeadersAndFooters({ editor, annotationValues, hiddenFieldIds });
47481
+ annotateHeadersAndFooters({ editor, annotationValues, hiddenFieldIds, removeEmptyFields });
47452
47482
  const annotations = [];
47453
47483
  const FieldType = schema.nodes.fieldAnnotation;
47454
47484
  tr.doc.descendants((node2, pos) => {
@@ -47501,11 +47531,13 @@
47501
47531
  });
47502
47532
  }
47503
47533
  }
47504
- Array.from(toDelete).sort((a, b) => b - a).forEach((pos) => {
47505
- const ann = annotations.find((a) => a.pos === pos);
47506
- if (!ann) return;
47507
- tr = tr.delete(pos, pos + ann.node.nodeSize);
47508
- });
47534
+ if (removeEmptyFields) {
47535
+ Array.from(toDelete).sort((a, b) => b - a).forEach((pos) => {
47536
+ const ann = annotations.find((a) => a.pos === pos);
47537
+ if (!ann) return;
47538
+ tr = tr.delete(pos, pos + ann.node.nodeSize);
47539
+ });
47540
+ }
47509
47541
  return tr;
47510
47542
  };
47511
47543
  const getFormattedDate = (input = null, format = "") => {
@@ -47523,7 +47555,7 @@
47523
47555
  // e.g. “2025”
47524
47556
  });
47525
47557
  };
47526
- const AnnotatorServices = {
47558
+ const AnnotatorHelpers = {
47527
47559
  getFieldAttrs,
47528
47560
  processTables,
47529
47561
  annotateDocument,
@@ -48316,7 +48348,7 @@
48316
48348
  * @returns {Object | void} Migration results
48317
48349
  */
48318
48350
  processCollaborationMigrations() {
48319
- console.debug("[checkVersionMigrations] Current editor version", "0.12.29");
48351
+ console.debug("[checkVersionMigrations] Current editor version", "0.12.30-rev.1");
48320
48352
  if (!this.options.ydoc) return;
48321
48353
  const metaMap = this.options.ydoc.getMap("meta");
48322
48354
  let docVersion = metaMap.get("version");
@@ -48405,10 +48437,8 @@
48405
48437
  */
48406
48438
  prepareForAnnotations(annotationValues = []) {
48407
48439
  const { tr } = this.state;
48408
- const { dispatch } = this.view;
48409
- const newTr = AnnotatorServices.processTables({ state: this.state, tr, annotationValues });
48440
+ const newTr = AnnotatorHelpers.processTables({ state: this.state, tr, annotationValues });
48410
48441
  this.view.dispatch(newTr);
48411
- AnnotatorServices.annotateHeadersAndFooters({ editor: this, annotationValues });
48412
48442
  }
48413
48443
  /**
48414
48444
  * Annotate the document with the given annotation values.
@@ -48417,15 +48447,16 @@
48417
48447
  * @param {String[]} hiddenIds List of field ids to remove from the document.
48418
48448
  * @returns {void}
48419
48449
  */
48420
- annotate(annotationValues = [], hiddenIds = []) {
48450
+ annotate(annotationValues = [], hiddenIds = [], removeEmptyFields = false) {
48421
48451
  const { state: state2, view, schema } = this;
48422
48452
  let tr = state2.tr;
48423
- tr = AnnotatorServices.processTables({ state: this.state, tr, annotationValues });
48424
- tr = AnnotatorServices.annotateDocument({
48453
+ tr = AnnotatorHelpers.processTables({ state: this.state, tr, annotationValues });
48454
+ tr = AnnotatorHelpers.annotateDocument({
48425
48455
  tr,
48426
48456
  schema,
48427
48457
  annotationValues,
48428
48458
  hiddenFieldIds: hiddenIds,
48459
+ removeEmptyFields,
48429
48460
  editor: this
48430
48461
  });
48431
48462
  if (tr.docChanged) view.dispatch(tr.scrollIntoView());
@@ -54649,6 +54680,15 @@
54649
54680
  });
54650
54681
  return fieldAnnotations;
54651
54682
  }
54683
+ const getHeaderFooterAnnotations = (editor) => {
54684
+ const editors = getAllHeaderFooterEditors(editor);
54685
+ const allAnnotations = [];
54686
+ editors.forEach(({ id, editor: editor2 }) => {
54687
+ const annotations = getAllFieldAnnotations(editor2.state);
54688
+ allAnnotations.push(...annotations);
54689
+ });
54690
+ return allAnnotations;
54691
+ };
54652
54692
  const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
54653
54693
  __proto__: null,
54654
54694
  findFieldAnnotations,
@@ -54658,6 +54698,7 @@
54658
54698
  findRemovedFieldAnnotations,
54659
54699
  getAllFieldAnnotations,
54660
54700
  getAllFieldAnnotationsWithRect,
54701
+ getHeaderFooterAnnotations,
54661
54702
  trackFieldAnnotationsDeletion
54662
54703
  }, Symbol.toStringTag, { value: "Module" }));
54663
54704
  function guard(low, high, value) {
@@ -89513,7 +89554,7 @@ ${style2}
89513
89554
  this.config.colors = shuffleArray(this.config.colors);
89514
89555
  this.userColorMap = /* @__PURE__ */ new Map();
89515
89556
  this.colorIndex = 0;
89516
- this.version = "0.12.29";
89557
+ this.version = "0.12.30-rev.1";
89517
89558
  console.debug("🦋 [superdoc] Using SuperDoc version:", this.version);
89518
89559
  this.superdocId = config.superdocId || v4();
89519
89560
  this.colors = this.config.colors;
@@ -90070,6 +90111,7 @@ ${style2}
90070
90111
  }
90071
90112
  }
90072
90113
  }
90114
+ exports2.AnnotatorHelpers = AnnotatorHelpers;
90073
90115
  exports2.BlankDOCX = BlankDOCX;
90074
90116
  exports2.DOCX = DOCX;
90075
90117
  exports2.Editor = Editor;