@harbour-enterprises/superdoc 0.15.5-next.2 → 0.15.5-next.4

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 (31) hide show
  1. package/dist/chunks/{super-editor.es-Bdf_jgkg.cjs → super-editor.es-B26cbPcK.cjs} +126 -84
  2. package/dist/chunks/{super-editor.es-DyA8_U6m.es.js → super-editor.es-CGGB0kc-.es.js} +126 -84
  3. package/dist/super-editor/ai-writer.es.js +2 -2
  4. package/dist/super-editor/chunks/{converter-CE735VKL.js → converter-BS2nDFTr.js} +34 -29
  5. package/dist/super-editor/chunks/{docx-zipper-BkMHQVwL.js → docx-zipper-CbJNdmKy.js} +1 -1
  6. package/dist/super-editor/chunks/{editor-DPbOzyDd.js → editor-Dv6VP0hc.js} +108 -71
  7. package/dist/super-editor/chunks/{toolbar-B3yMPU4P.js → toolbar-D5_dnZxK.js} +2 -2
  8. package/dist/super-editor/converter.es.js +2 -2
  9. package/dist/super-editor/core/helpers/annotator.d.ts +0 -2
  10. package/dist/super-editor/core/helpers/annotator.d.ts.map +1 -1
  11. package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
  12. package/dist/super-editor/core/super-converter/v2/importer/annotationImporter.d.ts.map +1 -1
  13. package/dist/super-editor/docx-zipper.es.js +2 -2
  14. package/dist/super-editor/editor.es.js +3 -3
  15. package/dist/super-editor/extensions/field-annotation/cleanup-commands/cleanUpListsWithAnnotations.d.ts +2 -0
  16. package/dist/super-editor/extensions/field-annotation/cleanup-commands/cleanUpListsWithAnnotations.d.ts.map +1 -0
  17. package/dist/super-editor/extensions/field-annotation/cleanup-commands/cleanUpParagraphWithAnnotations.d.ts +2 -0
  18. package/dist/super-editor/extensions/field-annotation/cleanup-commands/cleanUpParagraphWithAnnotations.d.ts.map +1 -0
  19. package/dist/super-editor/extensions/field-annotation/cleanup-commands/index.d.ts +7 -0
  20. package/dist/super-editor/extensions/field-annotation/cleanup-commands/index.d.ts.map +1 -0
  21. package/dist/super-editor/extensions/field-annotation/field-annotation.d.ts.map +1 -1
  22. package/dist/super-editor/file-zipper.es.js +1 -1
  23. package/dist/super-editor/super-editor.es.js +17 -17
  24. package/dist/super-editor/toolbar.es.js +2 -2
  25. package/dist/super-editor.cjs +1 -1
  26. package/dist/super-editor.es.js +1 -1
  27. package/dist/superdoc.cjs +2 -2
  28. package/dist/superdoc.es.js +3 -3
  29. package/dist/superdoc.umd.js +127 -85
  30. package/dist/superdoc.umd.js.map +1 -1
  31. package/package.json +1 -1
@@ -26653,6 +26653,9 @@ function translateFieldAnnotation(params2) {
26653
26653
  if (!annotationHandler) return {};
26654
26654
  let processedNode;
26655
26655
  let sdtContentElements;
26656
+ if ((attrs.type === "image" || attrs.type === "signature") && !attrs.hash) {
26657
+ attrs.hash = generateDocxRandomId(4);
26658
+ }
26656
26659
  if (isFinalDoc) {
26657
26660
  return annotationHandler(params2);
26658
26661
  } else {
@@ -26674,7 +26677,8 @@ function translateFieldAnnotation(params2) {
26674
26677
  fieldFontFamily: attrs.fontFamily,
26675
26678
  fieldFontSize: attrs.fontSize,
26676
26679
  fieldTextColor: attrs.textColor,
26677
- fieldTextHighlight: attrs.textHighlight
26680
+ fieldTextHighlight: attrs.textHighlight,
26681
+ hash: attrs.hash
26678
26682
  };
26679
26683
  const annotationAttrsJson = JSON.stringify(annotationAttrs);
26680
26684
  const result = {
@@ -27742,7 +27746,8 @@ const handleAnnotationNode = (params2) => {
27742
27746
  fontFamily: parsedAttrs.fieldFontFamily,
27743
27747
  fontSize: parsedAttrs.fieldFontSize,
27744
27748
  textColor: parsedAttrs.fieldTextColor,
27745
- textHighlight: parsedAttrs.fieldTextHighlight
27749
+ textHighlight: parsedAttrs.fieldTextHighlight,
27750
+ hash: parsedAttrs.hash
27746
27751
  };
27747
27752
  attrs = attrsFromJSON;
27748
27753
  } else {
@@ -27751,7 +27756,7 @@ const handleAnnotationNode = (params2) => {
27751
27756
  }
27752
27757
  const { attrs: marksAsAttrs, marks } = parseAnnotationMarks(sdtContent);
27753
27758
  const allAttrs = { ...attrs, ...marksAsAttrs };
27754
- allAttrs.hash = generateDocxRandomId(4);
27759
+ if (!allAttrs.hash) allAttrs.hash = generateDocxRandomId(4);
27755
27760
  if (!attrs.fieldId || !attrs.displayLabel) {
27756
27761
  return { nodes: [], consumed: 0 };
27757
27762
  }
@@ -28795,7 +28800,7 @@ const _SuperConverter = class _SuperConverter2 {
28795
28800
  return;
28796
28801
  }
28797
28802
  }
28798
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.15.5-next.2") {
28803
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.15.5-next.4") {
28799
28804
  const customLocation = "docProps/custom.xml";
28800
28805
  if (!docx[customLocation]) {
28801
28806
  docx[customLocation] = generateCustomXml();
@@ -29190,7 +29195,7 @@ exportProcessNewRelationships_fn = function(rels = []) {
29190
29195
  exportProcessMediaFiles_fn = async function(media, editor) {
29191
29196
  const processedData = {};
29192
29197
  for (const filePath in media) {
29193
- if (typeof media[filePath] !== "string") return;
29198
+ if (typeof media[filePath] !== "string") continue;
29194
29199
  const name = filePath.split("/").pop();
29195
29200
  processedData[name] = await getArrayBufferFromUrl(media[filePath], editor.options.isHeadless);
29196
29201
  }
@@ -29274,7 +29279,7 @@ function storeSuperdocVersion(docx) {
29274
29279
  function generateCustomXml() {
29275
29280
  return DEFAULT_CUSTOM_XML;
29276
29281
  }
29277
- function generateSuperdocVersion(pid = 2, version2 = "0.15.5-next.2") {
29282
+ function generateSuperdocVersion(pid = 2, version2 = "0.15.5-next.4") {
29278
29283
  return {
29279
29284
  type: "element",
29280
29285
  name: "property",
@@ -34430,7 +34435,7 @@ const restoreSelection = () => ({ editor, state: state2, tr }) => {
34430
34435
  editor.view.dispatch(selectionTr);
34431
34436
  }
34432
34437
  };
34433
- const commands = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
34438
+ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
34434
34439
  __proto__: null,
34435
34440
  clearNodes,
34436
34441
  command,
@@ -34480,7 +34485,7 @@ const commands = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
34480
34485
  const Commands = Extension.create({
34481
34486
  name: "commands",
34482
34487
  addCommands() {
34483
- return { ...commands };
34488
+ return { ...commands$1 };
34484
34489
  }
34485
34490
  });
34486
34491
  const handleEnter = (editor) => {
@@ -44034,65 +44039,6 @@ const resetHeaderFooterFieldAnnotations = ({ editor }) => {
44034
44039
  onHeaderFooterDataUpdate({ editor: sectionEditor }, editor, sectionId, type2);
44035
44040
  });
44036
44041
  };
44037
- const cleanUpListsWithAnnotations = (fieldsToDelete = [], editor) => {
44038
- if (!Array.isArray(fieldsToDelete)) fieldsToDelete = [fieldsToDelete];
44039
- const { doc: doc2 } = editor.state;
44040
- const docxAnnotations = getAllFieldAnnotations(editor.state) || [];
44041
- const nodesToDelete = [];
44042
- fieldsToDelete.forEach((fieldId) => {
44043
- const matched = docxAnnotations.find((a) => a.node.attrs.fieldId === fieldId);
44044
- if (!matched) return;
44045
- const listItem = findParentNodeClosestToPos(doc2.resolve(matched.pos), (node22) => node22.type.name === "listItem");
44046
- if (!listItem) return;
44047
- let remainingNodes = 0;
44048
- listItem.node.descendants((node22) => {
44049
- if (node22.type.name === "fieldAnnotation") {
44050
- remainingNodes += 1;
44051
- }
44052
- });
44053
- let matchingNodesFound = 0;
44054
- let hasOtherNodes = false;
44055
- listItem.node.children.forEach((child, index2) => {
44056
- const { type: type2 } = child;
44057
- if (type2.name !== "paragraph" && type2.name !== "fieldAnnotation") return;
44058
- child.children.forEach((inline) => {
44059
- const isFieldToDelete = fieldsToDelete.includes(inline.attrs.fieldId);
44060
- const isFieldType = inline.type.name === "fieldAnnotation";
44061
- const isMatchingField = isFieldType && isFieldToDelete;
44062
- if (!isFieldType && !isMatchingField) hasOtherNodes = true;
44063
- if (isMatchingField) matchingNodesFound += 1;
44064
- });
44065
- });
44066
- if (!hasOtherNodes && matchingNodesFound > 0) {
44067
- remainingNodes -= matchingNodesFound;
44068
- }
44069
- if (remainingNodes > 0) {
44070
- return;
44071
- }
44072
- let { pos, node: node2, depth } = listItem;
44073
- let $pos = doc2.resolve(pos);
44074
- while (depth > 0) {
44075
- const parent = $pos.node(depth - 1);
44076
- if (parent.childCount === 1) {
44077
- depth -= 1;
44078
- pos = $pos.before(depth);
44079
- node2 = parent;
44080
- $pos = doc2.resolve(pos);
44081
- } else {
44082
- break;
44083
- }
44084
- }
44085
- if (!nodesToDelete.some((n) => n.pos === pos)) {
44086
- nodesToDelete.push({ pos, node: node2 });
44087
- }
44088
- });
44089
- if (!nodesToDelete.length) return;
44090
- const tr = editor.state.tr;
44091
- nodesToDelete.sort((a, b) => b.pos - a.pos).forEach(({ pos, node: node2 }) => {
44092
- tr.delete(pos, pos + node2.nodeSize);
44093
- });
44094
- editor.view.dispatch(tr);
44095
- };
44096
44042
  const AnnotatorHelpers = {
44097
44043
  getFieldAttrs,
44098
44044
  processTables,
@@ -44101,8 +44047,7 @@ const AnnotatorHelpers = {
44101
44047
  getAllHeaderFooterEditors,
44102
44048
  updateHeaderFooterFieldAnnotations,
44103
44049
  deleteHeaderFooterFieldAnnotations,
44104
- resetHeaderFooterFieldAnnotations,
44105
- cleanUpListsWithAnnotations
44050
+ resetHeaderFooterFieldAnnotations
44106
44051
  };
44107
44052
  const CollaborationPluginKey = new PluginKey("collaboration");
44108
44053
  const Collaboration = Extension.create({
@@ -45457,7 +45402,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
45457
45402
  * @returns {Object | void} Migration results
45458
45403
  */
45459
45404
  processCollaborationMigrations() {
45460
- console.debug("[checkVersionMigrations] Current editor version", "0.15.5-next.2");
45405
+ console.debug("[checkVersionMigrations] Current editor version", "0.15.5-next.4");
45461
45406
  if (!this.options.ydoc) return;
45462
45407
  const metaMap = this.options.ydoc.getMap("meta");
45463
45408
  let docVersion = metaMap.get("version");
@@ -52044,6 +51989,99 @@ function toHex(color) {
52044
51989
  };
52045
51990
  return `#${hex2(r2)}${hex2(g)}${hex2(b)}${a < 1 ? hex2(Math.round(a * 255)) : ""}`;
52046
51991
  }
51992
+ const cleanUpListsWithAnnotations = (fieldsToDelete = []) => ({ dispatch, tr, state: state2 }) => {
51993
+ if (!dispatch) return true;
51994
+ if (!Array.isArray(fieldsToDelete)) fieldsToDelete = [fieldsToDelete];
51995
+ const { doc: doc2 } = state2;
51996
+ const docxAnnotations = getAllFieldAnnotations(state2) || [];
51997
+ const nodesToDelete = [];
51998
+ fieldsToDelete.forEach((fieldId) => {
51999
+ const matched = docxAnnotations.find((a) => a.node.attrs.fieldId === fieldId);
52000
+ if (!matched) return;
52001
+ const listItem = findParentNodeClosestToPos(doc2.resolve(matched.pos), (node22) => node22.type.name === "listItem");
52002
+ if (!listItem) return;
52003
+ let remainingNodes = 0;
52004
+ listItem.node.descendants((node22) => {
52005
+ if (node22.type.name === "fieldAnnotation") {
52006
+ remainingNodes += 1;
52007
+ }
52008
+ });
52009
+ let matchingNodesFound = 0;
52010
+ let hasOtherNodes = false;
52011
+ listItem.node.children.forEach((child, index2) => {
52012
+ const { type: type2 } = child;
52013
+ if (type2.name !== "paragraph" && type2.name !== "fieldAnnotation") return;
52014
+ child.children.forEach((inline) => {
52015
+ const isFieldToDelete = fieldsToDelete.includes(inline.attrs.fieldId);
52016
+ const isFieldType = inline.type.name === "fieldAnnotation";
52017
+ const isMatchingField = isFieldType && isFieldToDelete;
52018
+ if (!isFieldType && !isMatchingField) hasOtherNodes = true;
52019
+ if (isMatchingField) matchingNodesFound += 1;
52020
+ });
52021
+ });
52022
+ if (!hasOtherNodes && matchingNodesFound > 0) {
52023
+ remainingNodes -= matchingNodesFound;
52024
+ }
52025
+ if (remainingNodes > 0) {
52026
+ return;
52027
+ }
52028
+ let { pos, node: node2, depth } = listItem;
52029
+ let $pos = doc2.resolve(pos);
52030
+ while (depth > 0) {
52031
+ const parent = $pos.node(depth - 1);
52032
+ if (parent.childCount === 1) {
52033
+ depth -= 1;
52034
+ pos = $pos.before(depth);
52035
+ node2 = parent;
52036
+ $pos = doc2.resolve(pos);
52037
+ } else {
52038
+ break;
52039
+ }
52040
+ }
52041
+ if (!nodesToDelete.some((n) => n.pos === pos)) {
52042
+ nodesToDelete.push({ pos, node: node2 });
52043
+ }
52044
+ });
52045
+ if (!nodesToDelete.length) return true;
52046
+ nodesToDelete.sort((a, b) => b.pos - a.pos).forEach(({ pos, node: node2 }) => {
52047
+ tr.delete(pos, pos + node2.nodeSize);
52048
+ });
52049
+ tr.setMeta("updateListSync", true);
52050
+ return true;
52051
+ };
52052
+ const cleanUpListsCommands = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
52053
+ __proto__: null,
52054
+ cleanUpListsWithAnnotations
52055
+ }, Symbol.toStringTag, { value: "Module" }));
52056
+ const cleanUpParagraphWithAnnotations = (fieldsToDelete = []) => ({ dispatch, tr, state: state2 }) => {
52057
+ if (!dispatch) return true;
52058
+ const annotations = findFieldAnnotationsByFieldId(fieldsToDelete, state2) || [];
52059
+ const nodesToDelete = [];
52060
+ const { doc: doc2 } = state2;
52061
+ annotations.forEach((annotation) => {
52062
+ let { pos, node: node2 } = annotation;
52063
+ let newPosFrom = tr.mapping.map(pos);
52064
+ const resolvedPos = doc2.resolve(newPosFrom);
52065
+ const parent = resolvedPos.parent;
52066
+ let currentNode = tr.doc.nodeAt(newPosFrom);
52067
+ if (node2.eq(currentNode) && parent?.children?.length < 2) {
52068
+ nodesToDelete.push({ pos: newPosFrom, node: parent });
52069
+ }
52070
+ });
52071
+ if (!nodesToDelete.length) return true;
52072
+ nodesToDelete.sort((a, b) => b.pos - a.pos).forEach(({ pos, node: node2 }) => {
52073
+ tr.delete(pos, pos + node2.nodeSize);
52074
+ });
52075
+ return true;
52076
+ };
52077
+ const cleanUpParagraphCommands = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
52078
+ __proto__: null,
52079
+ cleanUpParagraphWithAnnotations
52080
+ }, Symbol.toStringTag, { value: "Module" }));
52081
+ const commands = {
52082
+ ...cleanUpListsCommands,
52083
+ ...cleanUpParagraphCommands
52084
+ };
52047
52085
  const annotationClass = "annotation";
52048
52086
  const annotationContentClass = "annotation-content";
52049
52087
  const FieldAnnotation = Node$1.create({
@@ -52433,12 +52471,12 @@ const FieldAnnotation = Node$1.create({
52433
52471
  currentMarks = currentMarks.length ? [...currentMarks] : null;
52434
52472
  let formatAttrs = getFormatAttrsFromMarks(currentMarks);
52435
52473
  let defaultDisplayLabel = attrs.defaultDisplayLabel ? attrs.defaultDisplayLabel : attrs.displayLabel || "";
52436
- attrs.hash = generateDocxRandomId(4);
52437
52474
  let node2 = schema.nodes[this.name].create(
52438
52475
  {
52439
52476
  ...attrs,
52440
52477
  ...formatAttrs,
52441
- defaultDisplayLabel
52478
+ defaultDisplayLabel,
52479
+ hash: attrs.hash || generateDocxRandomId(4)
52442
52480
  },
52443
52481
  null,
52444
52482
  null
@@ -52479,7 +52517,8 @@ const FieldAnnotation = Node$1.create({
52479
52517
  let node2 = schema.nodes[this.name].create(
52480
52518
  {
52481
52519
  ...attrs,
52482
- defaultDisplayLabel
52520
+ defaultDisplayLabel,
52521
+ hash: attrs.hash || generateDocxRandomId(4)
52483
52522
  },
52484
52523
  null,
52485
52524
  null
@@ -52563,7 +52602,8 @@ const FieldAnnotation = Node$1.create({
52563
52602
  // reset attrs for specific types.
52564
52603
  imageSrc: null,
52565
52604
  rawHtml: null,
52566
- linkUrl: null
52605
+ linkUrl: null,
52606
+ hash: null
52567
52607
  });
52568
52608
  }
52569
52609
  });
@@ -52924,8 +52964,10 @@ const FieldAnnotation = Node$1.create({
52924
52964
  }
52925
52965
  }
52926
52966
  return true;
52927
- }
52967
+ },
52928
52968
  /// Formatting commands - end.
52969
+ // Clean up commands (after field deletion)
52970
+ ...commands
52929
52971
  };
52930
52972
  },
52931
52973
  addNodeView() {
@@ -71303,7 +71345,7 @@ function requireEventemitter3() {
71303
71345
  if (listeners.fn) return 1;
71304
71346
  return listeners.length;
71305
71347
  };
71306
- EventEmitter22.prototype.emit = function emit(event, a1, a22, a3, a4, a52) {
71348
+ EventEmitter22.prototype.emit = function emit(event, a12, a2, a3, a42, a5) {
71307
71349
  var evt = prefix2 ? prefix2 + event : event;
71308
71350
  if (!this._events[evt]) return false;
71309
71351
  var listeners = this._events[evt], len = arguments.length, args, i2;
@@ -71313,15 +71355,15 @@ function requireEventemitter3() {
71313
71355
  case 1:
71314
71356
  return listeners.fn.call(listeners.context), true;
71315
71357
  case 2:
71316
- return listeners.fn.call(listeners.context, a1), true;
71358
+ return listeners.fn.call(listeners.context, a12), true;
71317
71359
  case 3:
71318
- return listeners.fn.call(listeners.context, a1, a22), true;
71360
+ return listeners.fn.call(listeners.context, a12, a2), true;
71319
71361
  case 4:
71320
- return listeners.fn.call(listeners.context, a1, a22, a3), true;
71362
+ return listeners.fn.call(listeners.context, a12, a2, a3), true;
71321
71363
  case 5:
71322
- return listeners.fn.call(listeners.context, a1, a22, a3, a4), true;
71364
+ return listeners.fn.call(listeners.context, a12, a2, a3, a42), true;
71323
71365
  case 6:
71324
- return listeners.fn.call(listeners.context, a1, a22, a3, a4, a52), true;
71366
+ return listeners.fn.call(listeners.context, a12, a2, a3, a42, a5), true;
71325
71367
  }
71326
71368
  for (i2 = 1, args = new Array(len - 1); i2 < len; i2++) {
71327
71369
  args[i2 - 1] = arguments[i2];
@@ -71336,13 +71378,13 @@ function requireEventemitter3() {
71336
71378
  listeners[i2].fn.call(listeners[i2].context);
71337
71379
  break;
71338
71380
  case 2:
71339
- listeners[i2].fn.call(listeners[i2].context, a1);
71381
+ listeners[i2].fn.call(listeners[i2].context, a12);
71340
71382
  break;
71341
71383
  case 3:
71342
- listeners[i2].fn.call(listeners[i2].context, a1, a22);
71384
+ listeners[i2].fn.call(listeners[i2].context, a12, a2);
71343
71385
  break;
71344
71386
  case 4:
71345
- listeners[i2].fn.call(listeners[i2].context, a1, a22, a3);
71387
+ listeners[i2].fn.call(listeners[i2].context, a12, a2, a3);
71346
71388
  break;
71347
71389
  default:
71348
71390
  if (!args) for (j2 = 1, args = new Array(len - 1); j2 < len; j2++) {