@harbour-enterprises/superdoc 0.23.0-next.25 → 0.23.0-next.26

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 (29) hide show
  1. package/dist/chunks/{PdfViewer-CYMwWMP6.cjs → PdfViewer-Ba9s5reX.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-D5j64OT4.es.js → PdfViewer-D_3AuXzb.es.js} +1 -1
  3. package/dist/chunks/{index-CIz8zQ3h.cjs → index-A1XH4hzI.cjs} +2 -2
  4. package/dist/chunks/{index-ePxDRT3A.es.js → index-CZ9iIRr8.es.js} +2 -2
  5. package/dist/chunks/{super-editor.es-BhyobyII.es.js → super-editor.es-CcuilWh0.es.js} +120 -24
  6. package/dist/chunks/{super-editor.es-DZWnc89F.cjs → super-editor.es-DhxK40cW.cjs} +120 -24
  7. package/dist/super-editor/ai-writer.es.js +2 -2
  8. package/dist/super-editor/chunks/{converter-CL8NqbzP.js → converter-B2Y-pDXk.js} +120 -24
  9. package/dist/super-editor/chunks/{docx-zipper-Ab__pf6Y.js → docx-zipper-bhLh8OB6.js} +1 -1
  10. package/dist/super-editor/chunks/{editor-DDXA7n3I.js → editor-GN9xFFdh.js} +2 -2
  11. package/dist/super-editor/chunks/{toolbar-BkZURoPS.js → toolbar-UX3FTiEj.js} +2 -2
  12. package/dist/super-editor/converter.es.js +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/file-zipper.es.js +1 -1
  16. package/dist/super-editor/super-editor/src/core/super-converter/field-references/fld-preprocessors/num-pages-preprocessor.d.ts +1 -3
  17. package/dist/super-editor/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-preprocessor.d.ts +1 -3
  18. package/dist/super-editor/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-ref-preprocessor.d.ts +1 -2
  19. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pict/helpers/handle-shape-textbox-import.d.ts +1 -1
  20. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/pict/helpers/handle-v-rect-import.d.ts +1 -1
  21. package/dist/super-editor/super-editor.es.js +6 -6
  22. package/dist/super-editor/toolbar.es.js +2 -2
  23. package/dist/super-editor.cjs +1 -1
  24. package/dist/super-editor.es.js +1 -1
  25. package/dist/superdoc.cjs +2 -2
  26. package/dist/superdoc.es.js +2 -2
  27. package/dist/superdoc.umd.js +120 -24
  28. package/dist/superdoc.umd.js.map +1 -1
  29. package/package.json +1 -1
@@ -35813,9 +35813,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35813
35813
  const tagValue = tag?.attributes["w:val"];
35814
35814
  const shouldProcessAsJson = tagValue?.startsWith("{") && tagValue?.endsWith("}");
35815
35815
  let attrs = {};
35816
+ const aliasLabel = getSafeString(alias?.attributes?.["w:val"]);
35816
35817
  if (shouldProcessAsJson) {
35817
35818
  const parsedAttrs = parseTagValueJSON(tagValue);
35818
- const attrsFromJSON = {
35819
+ attrs = {
35819
35820
  type: parsedAttrs.fieldTypeShort,
35820
35821
  fieldId: parsedAttrs.fieldId,
35821
35822
  displayLabel: parsedAttrs.displayLabel,
@@ -35829,10 +35830,27 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35829
35830
  textHighlight: parsedAttrs.fieldTextHighlight,
35830
35831
  hash: parsedAttrs.hash
35831
35832
  };
35832
- attrs = attrsFromJSON;
35833
35833
  } else {
35834
- const attrsFromElements = getAttrsFromElements({ sdtPr, tag, alias, sdtId });
35835
- attrs = attrsFromElements;
35834
+ attrs = getAttrsFromElements({ sdtPr, tag, alias, sdtId });
35835
+ }
35836
+ const initialDisplayLabel = getSafeString(attrs.displayLabel);
35837
+ const extractedContent = getTextFromSdtContent(sdtContent);
35838
+ if (!attrs.defaultDisplayLabel) {
35839
+ if (initialDisplayLabel) {
35840
+ attrs.defaultDisplayLabel = initialDisplayLabel;
35841
+ } else if (aliasLabel) {
35842
+ attrs.defaultDisplayLabel = aliasLabel;
35843
+ }
35844
+ }
35845
+ const placeholderLabel = getPlaceholderLabel(attrs, aliasLabel);
35846
+ const placeholderText = ensurePlaceholderFormat(placeholderLabel);
35847
+ const isAnnotationsEnabled = Boolean(params2.editor?.options?.annotations);
35848
+ const contentIsDistinct = shouldUseSdtContent(extractedContent, placeholderText);
35849
+ const shouldUseContent = !isAnnotationsEnabled && contentIsDistinct && (hasMoustache(extractedContent) || !placeholderText);
35850
+ if (contentIsDistinct) {
35851
+ attrs.displayLabel = extractedContent;
35852
+ } else if (!attrs.displayLabel && placeholderLabel) {
35853
+ attrs.displayLabel = placeholderLabel;
35836
35854
  }
35837
35855
  const { attrs: marksAsAttrs, marks } = parseAnnotationMarks(sdtContent);
35838
35856
  const allAttrs = { ...attrs, ...marksAsAttrs };
@@ -35840,13 +35858,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35840
35858
  if (!attrs.fieldId || !attrs.type) {
35841
35859
  return null;
35842
35860
  }
35861
+ const textContent2 = shouldUseContent ? extractedContent : placeholderText;
35843
35862
  let result = {
35844
35863
  type: "text",
35845
- text: `{{${attrs.displayLabel}}}`,
35864
+ text: textContent2,
35846
35865
  attrs: allAttrs,
35847
35866
  marks
35848
35867
  };
35849
- if (params2.editor.options.annotations) {
35868
+ if (isAnnotationsEnabled) {
35850
35869
  result = {
35851
35870
  type: "fieldAnnotation",
35852
35871
  attrs: allAttrs
@@ -35907,6 +35926,84 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35907
35926
  };
35908
35927
  return attrs;
35909
35928
  }
35929
+ function getTextFromSdtContent(sdtContent) {
35930
+ if (!sdtContent?.elements?.length) return "";
35931
+ const chunks = [];
35932
+ collectTextChunks(sdtContent.elements, chunks);
35933
+ if (chunks.length && chunks[chunks.length - 1] === "\n") {
35934
+ chunks.pop();
35935
+ }
35936
+ const text = chunks.join("");
35937
+ return text.replace(/\u00a0/g, " ");
35938
+ }
35939
+ function getPlaceholderLabel(attrs, aliasValue) {
35940
+ const displayLabel = trimSafeString(attrs.displayLabel);
35941
+ if (displayLabel) return displayLabel;
35942
+ const defaultLabel = trimSafeString(attrs.defaultDisplayLabel);
35943
+ if (defaultLabel) return defaultLabel;
35944
+ return trimSafeString(aliasValue);
35945
+ }
35946
+ function shouldUseSdtContent(extractedContent, placeholderText) {
35947
+ const normalizedContent = normalizePlaceholderText(extractedContent);
35948
+ if (!normalizedContent) return false;
35949
+ const normalizedPlaceholder = normalizePlaceholderText(placeholderText);
35950
+ return normalizedContent !== normalizedPlaceholder;
35951
+ }
35952
+ function ensurePlaceholderFormat(label) {
35953
+ const trimmed = trimSafeString(label);
35954
+ if (!trimmed) return "";
35955
+ if (trimmed.startsWith("{{") && trimmed.endsWith("}}")) {
35956
+ return trimmed;
35957
+ }
35958
+ return `{{${trimmed}}}`;
35959
+ }
35960
+ function normalizePlaceholderText(value = "") {
35961
+ const trimmed = trimSafeString(value);
35962
+ if (!trimmed) return "";
35963
+ return stripPlaceholderBraces(trimmed).toLowerCase();
35964
+ }
35965
+ function stripPlaceholderBraces(value = "") {
35966
+ if (value.startsWith("{{") && value.endsWith("}}")) {
35967
+ return trimSafeString(value.slice(2, -2));
35968
+ }
35969
+ return value;
35970
+ }
35971
+ function hasMoustache(value = "") {
35972
+ return /\{\{\s*.+?\s*\}\}/.test(getSafeString(value));
35973
+ }
35974
+ function collectTextChunks(elements, chunks) {
35975
+ if (!elements) return;
35976
+ elements.forEach((element) => {
35977
+ if (!element) return;
35978
+ if (element.type === "text") {
35979
+ chunks.push(element.text || "");
35980
+ return;
35981
+ }
35982
+ if (element.name === "w:tab") {
35983
+ chunks.push(" ");
35984
+ return;
35985
+ }
35986
+ if (element.name === "w:br") {
35987
+ chunks.push("\n");
35988
+ return;
35989
+ }
35990
+ const isParagraph = element.name === "w:p";
35991
+ const initialLength = chunks.length;
35992
+ if (element.elements?.length) {
35993
+ collectTextChunks(element.elements, chunks);
35994
+ }
35995
+ if (isParagraph && chunks.length > initialLength) {
35996
+ chunks.push("\n");
35997
+ }
35998
+ });
35999
+ }
36000
+ function getSafeString(value) {
36001
+ if (typeof value !== "string") return "";
36002
+ return value;
36003
+ }
36004
+ function trimSafeString(value) {
36005
+ return getSafeString(value).replace(/\u00a0/g, " ").trim();
36006
+ }
35910
36007
  function handleDocPartObj(params2) {
35911
36008
  const { nodes } = params2;
35912
36009
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
@@ -38566,7 +38663,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38566
38663
  });
38567
38664
  const XML_NODE_NAME$4 = "w:commentRange";
38568
38665
  const SD_NODE_NAME$4 = "commentRange";
38569
- const decode$4 = (params2, decodedAttrs) => {
38666
+ const decode$4 = (params2) => {
38570
38667
  const { node, comments, commentsExportType, exportedCommentDefs } = params2;
38571
38668
  if (!node) return;
38572
38669
  if (!comments) return;
@@ -38621,7 +38718,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38621
38718
  const commentRangeEndTranslator = NodeTranslator.from(getConfig("End"));
38622
38719
  const XML_NODE_NAME$3 = "sd:pageReference";
38623
38720
  const SD_NODE_NAME$3 = "pageReference";
38624
- const encode$3 = (params2, _2) => {
38721
+ const encode$3 = (params2) => {
38625
38722
  const { nodes = [], nodeListHandler } = params2 || {};
38626
38723
  const node = nodes[0];
38627
38724
  const processedText = nodeListHandler.handler({
@@ -38638,7 +38735,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38638
38735
  };
38639
38736
  return processedNode;
38640
38737
  };
38641
- const decode$3 = (params2, _2) => {
38738
+ const decode$3 = (params2) => {
38642
38739
  const { node } = params2;
38643
38740
  const outputMarks = processOutputMarks(node.attrs?.marksAsAttrs || []);
38644
38741
  const contentNodes = (node.content ?? []).flatMap((n) => exportSchemaToJson({ ...params2, node: n }));
@@ -38721,7 +38818,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38721
38818
  const translator$3 = NodeTranslator.from(config$3);
38722
38819
  const XML_NODE_NAME$2 = "sd:tableOfContents";
38723
38820
  const SD_NODE_NAME$2 = "tableOfContents";
38724
- const encode$2 = (params2, _2) => {
38821
+ const encode$2 = (params2) => {
38725
38822
  const { nodes = [], nodeListHandler } = params2 || {};
38726
38823
  const node = nodes[0];
38727
38824
  const processedContent = nodeListHandler.handler({
@@ -38737,7 +38834,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38737
38834
  };
38738
38835
  return processedNode;
38739
38836
  };
38740
- const decode$2 = (params2, _2) => {
38837
+ const decode$2 = (params2) => {
38741
38838
  const { node } = params2;
38742
38839
  const contentNodes = node.content.map((n) => exportSchemaToJson({ ...params2, node: n }));
38743
38840
  const tocBeginElements = [
@@ -38800,7 +38897,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38800
38897
  return acc;
38801
38898
  }, {});
38802
38899
  }
38803
- function handleVRectImport({ params: params2, pNode, pict }) {
38900
+ function handleVRectImport({ pNode, pict }) {
38804
38901
  const rect = pict.elements?.find((el) => el.name === "v:rect");
38805
38902
  const schemaAttrs = {};
38806
38903
  const rectAttrs = rect.attributes || {};
@@ -39779,7 +39876,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39779
39876
  handler: handleTabNode
39780
39877
  };
39781
39878
  const tableOfContentsHandlerEntity = generateV2HandlerEntity("tableOfContentsHandler", translator$2);
39782
- function preProcessPageInstruction(nodesToCombine, _2, __) {
39879
+ function preProcessPageInstruction(nodesToCombine) {
39783
39880
  const pageNumNode = {
39784
39881
  name: "sd:autoPageNumber",
39785
39882
  type: "element"
@@ -39790,7 +39887,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39790
39887
  });
39791
39888
  return [pageNumNode];
39792
39889
  }
39793
- function preProcessNumPagesInstruction(nodesToCombine, _2, __) {
39890
+ function preProcessNumPagesInstruction(nodesToCombine) {
39794
39891
  const totalPageNumNode = {
39795
39892
  name: "sd:totalPageNumber",
39796
39893
  type: "element"
@@ -39801,7 +39898,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39801
39898
  });
39802
39899
  return [totalPageNumNode];
39803
39900
  }
39804
- function preProcessPageRefInstruction(nodesToCombine, instrText, _2) {
39901
+ function preProcessPageRefInstruction(nodesToCombine, instrText) {
39805
39902
  const pageRefNode = {
39806
39903
  name: "sd:pageReference",
39807
39904
  type: "element",
@@ -39837,15 +39934,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
39837
39934
  }
39838
39935
  } else {
39839
39936
  const availableSwitches = {
39840
- "w:anchor": `l "(?<value>[^"]+)"`,
39841
- new_window: `
39842
- `,
39843
- "w:tgtFrame": ` "(?<value>[^"]+)"`,
39844
- "w:tooltip": `o "(?<value>[^"]+)"`
39937
+ "w:anchor": /(?:\\)?l "(?<value>[^"]+)"/,
39938
+ new_window: /(?:\\n|\n)/,
39939
+ "w:tgtFrame": /(?:\\t|\t) "(?<value>[^"]+)"/,
39940
+ "w:tooltip": /(?:\\)?o "(?<value>[^"]+)"/
39845
39941
  };
39846
39942
  const parsedSwitches = {};
39847
- for (const [key2, regex] of Object.entries(availableSwitches)) {
39848
- const match = instruction.match(new RegExp(regex));
39943
+ for (const [key2, pattern] of Object.entries(availableSwitches)) {
39944
+ const match = instruction.match(pattern);
39849
39945
  if (match) {
39850
39946
  parsedSwitches[key2] = match.groups?.value || true;
39851
39947
  }
@@ -40009,7 +40105,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40009
40105
  } else {
40010
40106
  trackStructure(identifierResult);
40011
40107
  }
40012
- } catch (error) {
40108
+ } catch {
40013
40109
  trackStructure();
40014
40110
  }
40015
40111
  }
@@ -40487,7 +40583,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40487
40583
  const evenOdd = elements.find((el) => el.name === "w:evenAndOddHeaders");
40488
40584
  return !!evenOdd;
40489
40585
  };
40490
- function handleShapeTextboxImport({ params: params2, pNode, pict }) {
40586
+ function handleShapeTextboxImport({ params: params2, pict }) {
40491
40587
  const shape = pict.elements?.find((el) => el.name === "v:shape");
40492
40588
  const schemaAttrs = {};
40493
40589
  const schemaTextboxAttrs = {};