@harbour-enterprises/superdoc 0.12.31-next.1 → 0.12.31-next.2

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 (30) hide show
  1. package/dist/chunks/{super-editor.es-Bt5pMkY-.es.js → super-editor.es-B4lJkgrf.es.js} +63 -37
  2. package/dist/chunks/{super-editor.es-CzfjXQ8V.cjs → super-editor.es-Du18AHQE.cjs} +50 -24
  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-LyqpytFD.js → converter-CP_Na8aB.js} +2 -2
  7. package/dist/super-editor/chunks/{docx-zipper-CSx2w--M.js → docx-zipper-BqcYpY0b.js} +1 -1
  8. package/dist/super-editor/chunks/{editor-czvDp00c.js → editor-CFxAdvpz.js} +51 -25
  9. package/dist/super-editor/chunks/{toolbar-BnvzLMKn.js → toolbar-CNZaB4OD.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/helpers/annotator.d.ts +5 -3
  14. package/dist/super-editor/core/helpers/annotator.d.ts.map +1 -1
  15. package/dist/super-editor/docx-zipper.es.js +2 -2
  16. package/dist/super-editor/editor.es.js +3 -3
  17. package/dist/super-editor/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.d.ts +2 -0
  18. package/dist/super-editor/extensions/field-annotation/fieldAnnotationHelpers/getHeaderFooterAnnotations.d.ts.map +1 -0
  19. package/dist/super-editor/extensions/field-annotation/fieldAnnotationHelpers/index.d.ts +1 -0
  20. package/dist/super-editor/file-zipper.es.js +1 -1
  21. package/dist/super-editor/index.d.ts +1 -1
  22. package/dist/super-editor/super-editor.es.js +8 -7
  23. package/dist/super-editor/toolbar.es.js +2 -2
  24. package/dist/super-editor.cjs +2 -1
  25. package/dist/super-editor.es.js +15 -14
  26. package/dist/superdoc.cjs +3 -2
  27. package/dist/superdoc.es.js +201 -200
  28. package/dist/superdoc.umd.js +51 -25
  29. package/dist/superdoc.umd.js.map +1 -1
  30. 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.31-next.1") {
30670
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.31-next.2") {
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.31-next.1") {
31136
+ function generateSuperdocVersion(pid = 2, version2 = "0.12.31-next.2") {
31137
31137
  return {
31138
31138
  type: "element",
31139
31139
  name: "property",
@@ -47430,11 +47430,12 @@
47430
47430
  const getAnnotationValue = (id, annotationValues) => {
47431
47431
  return annotationValues.find((value) => value.input_id === id)?.input_value || null;
47432
47432
  };
47433
- const annotateHeadersAndFooters = ({ editor, annotationValues = [], hiddenFieldIds = [] }) => {
47433
+ const getAllHeaderFooterEditors = (editor) => {
47434
47434
  const sections = {
47435
47435
  header: editor.converter.headers || {},
47436
47436
  footer: editor.converter.footers || {}
47437
47437
  };
47438
+ const allEditors = [];
47438
47439
  Object.entries(sections).forEach(([type2, items]) => {
47439
47440
  const editorsKey = `${type2}Editors`;
47440
47441
  Object.entries(items).forEach(([sectionId, data]) => {
@@ -47452,25 +47453,38 @@
47452
47453
  })
47453
47454
  };
47454
47455
  editor.converter[editorsKey].push(sectionEditor);
47456
+ allEditors.push({
47457
+ ...sectionEditor,
47458
+ key: editorsKey,
47459
+ type: type2,
47460
+ sectionId
47461
+ });
47455
47462
  }
47456
- sectionEditor.editor.annotate(annotationValues, hiddenFieldIds);
47457
- onHeaderFooterDataUpdate(
47458
- { editor: sectionEditor.editor },
47459
- editor,
47460
- sectionId,
47461
- type2
47462
- );
47463
47463
  });
47464
47464
  });
47465
+ return allEditors;
47466
+ };
47467
+ const annotateHeadersAndFooters = ({ editor, annotationValues = [], hiddenFieldIds = [], removeEmptyFields = false }) => {
47468
+ const allEditors = getAllHeaderFooterEditors(editor);
47469
+ allEditors.forEach(({ sectionId, editor: sectionEditor, type: type2 }) => {
47470
+ sectionEditor.annotate(annotationValues, hiddenFieldIds, removeEmptyFields);
47471
+ onHeaderFooterDataUpdate(
47472
+ { editor: sectionEditor },
47473
+ editor,
47474
+ sectionId,
47475
+ type2
47476
+ );
47477
+ });
47465
47478
  };
47466
47479
  const annotateDocument = ({
47467
47480
  annotationValues = [],
47468
47481
  hiddenFieldIds = [],
47482
+ removeEmptyFields = false,
47469
47483
  schema,
47470
47484
  tr,
47471
47485
  editor
47472
47486
  }) => {
47473
- annotateHeadersAndFooters({ editor, annotationValues, hiddenFieldIds });
47487
+ annotateHeadersAndFooters({ editor, annotationValues, hiddenFieldIds, removeEmptyFields });
47474
47488
  const annotations = [];
47475
47489
  const FieldType = schema.nodes.fieldAnnotation;
47476
47490
  tr.doc.descendants((node2, pos) => {
@@ -47523,11 +47537,13 @@
47523
47537
  });
47524
47538
  }
47525
47539
  }
47526
- Array.from(toDelete).sort((a, b) => b - a).forEach((pos) => {
47527
- const ann = annotations.find((a) => a.pos === pos);
47528
- if (!ann) return;
47529
- tr = tr.delete(pos, pos + ann.node.nodeSize);
47530
- });
47540
+ if (removeEmptyFields) {
47541
+ Array.from(toDelete).sort((a, b) => b - a).forEach((pos) => {
47542
+ const ann = annotations.find((a) => a.pos === pos);
47543
+ if (!ann) return;
47544
+ tr = tr.delete(pos, pos + ann.node.nodeSize);
47545
+ });
47546
+ }
47531
47547
  return tr;
47532
47548
  };
47533
47549
  const getFormattedDate = (input = null, format = "") => {
@@ -47545,7 +47561,7 @@
47545
47561
  // e.g. “2025”
47546
47562
  });
47547
47563
  };
47548
- const AnnotatorServices = {
47564
+ const AnnotatorHelpers = {
47549
47565
  getFieldAttrs,
47550
47566
  processTables,
47551
47567
  annotateDocument,
@@ -48354,7 +48370,7 @@
48354
48370
  * @returns {Object | void} Migration results
48355
48371
  */
48356
48372
  processCollaborationMigrations() {
48357
- console.debug("[checkVersionMigrations] Current editor version", "0.12.31-next.1");
48373
+ console.debug("[checkVersionMigrations] Current editor version", "0.12.31-next.2");
48358
48374
  if (!this.options.ydoc) return;
48359
48375
  const metaMap = this.options.ydoc.getMap("meta");
48360
48376
  let docVersion = metaMap.get("version");
@@ -48443,10 +48459,8 @@
48443
48459
  */
48444
48460
  prepareForAnnotations(annotationValues = []) {
48445
48461
  const { tr } = this.state;
48446
- const { dispatch } = this.view;
48447
- const newTr = AnnotatorServices.processTables({ state: this.state, tr, annotationValues });
48462
+ const newTr = AnnotatorHelpers.processTables({ state: this.state, tr, annotationValues });
48448
48463
  this.view.dispatch(newTr);
48449
- AnnotatorServices.annotateHeadersAndFooters({ editor: this, annotationValues });
48450
48464
  }
48451
48465
  /**
48452
48466
  * Annotate the document with the given annotation values.
@@ -48455,15 +48469,16 @@
48455
48469
  * @param {String[]} hiddenIds List of field ids to remove from the document.
48456
48470
  * @returns {void}
48457
48471
  */
48458
- annotate(annotationValues = [], hiddenIds = []) {
48472
+ annotate(annotationValues = [], hiddenIds = [], removeEmptyFields = false) {
48459
48473
  const { state: state2, view, schema } = this;
48460
48474
  let tr = state2.tr;
48461
- tr = AnnotatorServices.processTables({ state: this.state, tr, annotationValues });
48462
- tr = AnnotatorServices.annotateDocument({
48475
+ tr = AnnotatorHelpers.processTables({ state: this.state, tr, annotationValues });
48476
+ tr = AnnotatorHelpers.annotateDocument({
48463
48477
  tr,
48464
48478
  schema,
48465
48479
  annotationValues,
48466
48480
  hiddenFieldIds: hiddenIds,
48481
+ removeEmptyFields,
48467
48482
  editor: this
48468
48483
  });
48469
48484
  if (tr.docChanged) view.dispatch(tr.scrollIntoView());
@@ -54712,6 +54727,15 @@
54712
54727
  });
54713
54728
  return fieldAnnotations;
54714
54729
  }
54730
+ const getHeaderFooterAnnotations = (editor) => {
54731
+ const editors = getAllHeaderFooterEditors(editor);
54732
+ const allAnnotations = [];
54733
+ editors.forEach(({ id, editor: editor2 }) => {
54734
+ const annotations = getAllFieldAnnotations(editor2.state);
54735
+ allAnnotations.push(...annotations);
54736
+ });
54737
+ return allAnnotations;
54738
+ };
54715
54739
  const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
54716
54740
  __proto__: null,
54717
54741
  findFieldAnnotations,
@@ -54721,6 +54745,7 @@
54721
54745
  findRemovedFieldAnnotations,
54722
54746
  getAllFieldAnnotations,
54723
54747
  getAllFieldAnnotationsWithRect,
54748
+ getHeaderFooterAnnotations,
54724
54749
  trackFieldAnnotationsDeletion
54725
54750
  }, Symbol.toStringTag, { value: "Module" }));
54726
54751
  function guard(low, high, value) {
@@ -89807,7 +89832,7 @@ ${style2}
89807
89832
  this.config.colors = shuffleArray(this.config.colors);
89808
89833
  this.userColorMap = /* @__PURE__ */ new Map();
89809
89834
  this.colorIndex = 0;
89810
- this.version = "0.12.31-next.1";
89835
+ this.version = "0.12.31-next.2";
89811
89836
  console.debug("🦋 [superdoc] Using SuperDoc version:", this.version);
89812
89837
  this.superdocId = config.superdocId || v4();
89813
89838
  this.colors = this.config.colors;
@@ -90375,6 +90400,7 @@ ${style2}
90375
90400
  this.highContrastModeStore.setHighContrastMode(isHighContrast);
90376
90401
  }
90377
90402
  }
90403
+ exports2.AnnotatorHelpers = AnnotatorHelpers;
90378
90404
  exports2.BlankDOCX = BlankDOCX;
90379
90405
  exports2.DOCX = DOCX;
90380
90406
  exports2.Editor = Editor;