@superdoc-dev/cli 0.22.2 → 0.23.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.
package/dist/index.js CHANGED
@@ -68358,7 +68358,7 @@ var init_remark_gfm_BUJjZJLy_es = __esm(() => {
68358
68358
  emptyOptions2 = {};
68359
68359
  });
68360
68360
 
68361
- // ../../packages/superdoc/dist/chunks/SuperConverter-C3RaGqYm.es.js
68361
+ // ../../packages/superdoc/dist/chunks/SuperConverter-8mCA-0Qr.es.js
68362
68362
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
68363
68363
  const fieldValue = extension$1.config[field];
68364
68364
  if (typeof fieldValue === "function")
@@ -77361,6 +77361,29 @@ function stampImportTrackingAttrs(input) {
77361
77361
  } : null
77362
77362
  };
77363
77363
  }
77364
+ function resolveExportWordId(params3, attrs) {
77365
+ const sourceId = attrs?.sourceId;
77366
+ let exportSourceId;
77367
+ if (typeof sourceId === "string" || typeof sourceId === "number")
77368
+ exportSourceId = sourceId;
77369
+ else if (sourceId === null)
77370
+ exportSourceId = null;
77371
+ else if (sourceId === undefined)
77372
+ exportSourceId = undefined;
77373
+ else
77374
+ exportSourceId = String(sourceId);
77375
+ const logicalId = typeof attrs?.id === "string" ? attrs.id : "";
77376
+ const exportParams = params3;
77377
+ const allocator = exportParams?.converter?.wordIdAllocator;
77378
+ const partPath = exportParams?.currentPartPath || (typeof exportParams?.filename === "string" && exportParams.filename.length > 0 ? `word/${exportParams.filename}` : "word/document.xml");
77379
+ if (allocator)
77380
+ return allocator.allocate({
77381
+ partPath,
77382
+ sourceId: exportSourceId,
77383
+ logicalId
77384
+ });
77385
+ return sourceId || logicalId;
77386
+ }
77364
77387
  function decode$67(params3) {
77365
77388
  const { node: node3 } = params3;
77366
77389
  if (!node3 || !node3.type)
@@ -77379,7 +77402,7 @@ function decode$67(params3) {
77379
77402
  return {
77380
77403
  name: "w:ins",
77381
77404
  attributes: {
77382
- "w:id": resolveExportWordId$1(params3, trackedMark.attrs),
77405
+ "w:id": resolveExportWordId(params3, trackedMark.attrs),
77383
77406
  "w:author": trackedMark.attrs.author,
77384
77407
  "w:authorEmail": trackedMark.attrs.authorEmail,
77385
77408
  "w:date": trackedMark.attrs.date
@@ -77387,29 +77410,6 @@ function decode$67(params3) {
77387
77410
  elements: [translatedTextNode]
77388
77411
  };
77389
77412
  }
77390
- function resolveExportWordId$1(params3, attrs) {
77391
- const sourceId = attrs?.sourceId;
77392
- let exportSourceId;
77393
- if (typeof sourceId === "string" || typeof sourceId === "number")
77394
- exportSourceId = sourceId;
77395
- else if (sourceId === null)
77396
- exportSourceId = null;
77397
- else if (sourceId === undefined)
77398
- exportSourceId = undefined;
77399
- else
77400
- exportSourceId = String(sourceId);
77401
- const logicalId = typeof attrs?.id === "string" ? attrs.id : "";
77402
- const exportParams = params3;
77403
- const allocator = exportParams?.converter?.wordIdAllocator;
77404
- const partPath = exportParams?.currentPartPath || (typeof exportParams?.filename === "string" && exportParams.filename.length > 0 ? `word/${exportParams.filename}` : "word/document.xml");
77405
- if (allocator)
77406
- return allocator.allocate({
77407
- partPath,
77408
- sourceId: exportSourceId,
77409
- logicalId
77410
- });
77411
- return sourceId || logicalId;
77412
- }
77413
77413
  function decode$66(params3) {
77414
77414
  const { node: node3 } = params3;
77415
77415
  if (!node3 || !node3.type)
@@ -77419,15 +77419,14 @@ function decode$66(params3) {
77419
77419
  if (!trackedMark)
77420
77420
  return null;
77421
77421
  node3.marks = marks.filter((m) => m.type !== "trackDelete");
77422
- const translatedTextNode = exportSchemaToJson({
77422
+ const translatedResult = exportSchemaToJson({
77423
77423
  ...params3,
77424
77424
  node: node3
77425
77425
  });
77426
77426
  if (params3.isFinalDoc)
77427
77427
  return null;
77428
- (translatedTextNode.elements || []).filter((n) => n.name === "w:t").forEach((n) => {
77429
- n.name = "w:delText";
77430
- });
77428
+ const translatedNodes = Array.isArray(translatedResult) ? translatedResult : [translatedResult];
77429
+ translatedNodes.forEach(renameTextElementsForDeletion);
77431
77430
  return {
77432
77431
  name: "w:del",
77433
77432
  attributes: {
@@ -77436,32 +77435,9 @@ function decode$66(params3) {
77436
77435
  "w:authorEmail": trackedMark.attrs.authorEmail,
77437
77436
  "w:date": trackedMark.attrs.date
77438
77437
  },
77439
- elements: [translatedTextNode]
77438
+ elements: translatedNodes
77440
77439
  };
77441
77440
  }
77442
- function resolveExportWordId(params3, attrs) {
77443
- const sourceId = attrs?.sourceId;
77444
- let exportSourceId;
77445
- if (typeof sourceId === "string" || typeof sourceId === "number")
77446
- exportSourceId = sourceId;
77447
- else if (sourceId === null)
77448
- exportSourceId = null;
77449
- else if (sourceId === undefined)
77450
- exportSourceId = undefined;
77451
- else
77452
- exportSourceId = String(sourceId);
77453
- const logicalId = typeof attrs?.id === "string" ? attrs.id : "";
77454
- const exportParams = params3;
77455
- const allocator = exportParams?.converter?.wordIdAllocator;
77456
- const partPath = exportParams?.currentPartPath || (typeof exportParams?.filename === "string" && exportParams.filename.length > 0 ? `word/${exportParams.filename}` : "word/document.xml");
77457
- if (allocator)
77458
- return allocator.allocate({
77459
- partPath,
77460
- sourceId: exportSourceId,
77461
- logicalId
77462
- });
77463
- return sourceId || logicalId;
77464
- }
77465
77441
  function decode$65(params3, decodedAttrs = {}) {
77466
77442
  const { node: node3 } = params3 || {};
77467
77443
  if (!node3)
@@ -77616,12 +77592,12 @@ function decode$64(params3, decodedAttrs = {}) {
77616
77592
  ...params3,
77617
77593
  node: node3
77618
77594
  });
77619
- const childElements = Array.isArray(childContent) ? childContent : childContent ? [childContent] : [];
77595
+ const childElements$1 = Array.isArray(childContent) ? childContent : childContent ? [childContent] : [];
77620
77596
  const elements = [];
77621
77597
  const smartTagPr = node3.attrs?.smartTagPr;
77622
77598
  if (smartTagPr)
77623
77599
  elements.push(cloneXmlNode(smartTagPr));
77624
- elements.push(...childElements);
77600
+ elements.push(...childElements$1);
77625
77601
  return {
77626
77602
  name: "w:smartTag",
77627
77603
  attributes: { ...decodedAttrs },
@@ -80588,9 +80564,9 @@ function parseProperties(node3) {
80588
80564
  attributes["paragraphProperties"] = paragraphProperties;
80589
80565
  if (marks && node3.name === "w:p")
80590
80566
  marks.forEach((mark) => {
80591
- const attrValue = Object.keys(mark.attrs ?? {})[0];
80592
- if (attrValue)
80593
- attributes[attrValue] = mark.attrs[attrValue];
80567
+ const attrValue$1 = Object.keys(mark.attrs ?? {})[0];
80568
+ if (attrValue$1)
80569
+ attributes[attrValue$1] = mark.attrs[attrValue$1];
80594
80570
  });
80595
80571
  return {
80596
80572
  elements: nodes,
@@ -80861,6 +80837,37 @@ function insertRunPropertiesInOrder(pPr, runProperties) {
80861
80837
  else
80862
80838
  pPr.elements.splice(terminalIdx, 0, runProperties);
80863
80839
  }
80840
+ function appendParagraphMarkDeletion(pPr, markTrackChange, wordId) {
80841
+ if (!pPr || !markTrackChange)
80842
+ return pPr;
80843
+ if (!Array.isArray(pPr.elements))
80844
+ pPr.elements = [];
80845
+ const existingRunProperties = pPr.elements.find((element) => element?.name === "w:rPr");
80846
+ const runProperties = existingRunProperties || {
80847
+ type: "element",
80848
+ name: "w:rPr",
80849
+ elements: []
80850
+ };
80851
+ if (!Array.isArray(runProperties.elements))
80852
+ runProperties.elements = [];
80853
+ if (runProperties.elements.some((element) => element?.name === "w:del"))
80854
+ return pPr;
80855
+ const attributes = { "w:id": String(wordId ?? markTrackChange.sourceId ?? markTrackChange.id ?? "") };
80856
+ if (markTrackChange.author)
80857
+ attributes["w:author"] = markTrackChange.author;
80858
+ if (markTrackChange.authorEmail)
80859
+ attributes["w:authorEmail"] = markTrackChange.authorEmail;
80860
+ if (markTrackChange.date)
80861
+ attributes["w:date"] = markTrackChange.date;
80862
+ runProperties.elements.push({
80863
+ type: "element",
80864
+ name: "w:del",
80865
+ attributes
80866
+ });
80867
+ if (!existingRunProperties)
80868
+ insertRunPropertiesInOrder(pPr, runProperties);
80869
+ return pPr;
80870
+ }
80864
80871
  function prependParagraphSplitInsertion(pPr, insertionElement) {
80865
80872
  if (!pPr || !insertionElement)
80866
80873
  return pPr;
@@ -80915,6 +80922,9 @@ function generateParagraphProperties(params3) {
80915
80922
  if (insertionElement)
80916
80923
  pPr = prependParagraphSplitInsertion(ensureParagraphPropertiesNode(pPr), insertionElement);
80917
80924
  }
80925
+ const markTrackChange = node3.attrs?.markTrackChange;
80926
+ if (!params3?.isFinalDoc && markTrackChange?.type === "paragraphMarkDelete")
80927
+ pPr = appendParagraphMarkDeletion(ensureParagraphPropertiesNode(pPr), markTrackChange, resolveExportWordId(params3, markTrackChange));
80918
80928
  const sectPr = node3.attrs?.paragraphProperties?.sectPr;
80919
80929
  if (sectPr) {
80920
80930
  if (!pPr)
@@ -81047,6 +81057,8 @@ function translateParagraphNode(params3) {
81047
81057
  if (htmlAnnotationChild)
81048
81058
  return htmlAnnotationChild.elements;
81049
81059
  const pPr = generateParagraphProperties(params3);
81060
+ if (params3.isFinalDoc && params3.node?.attrs?.markTrackChange?.type === "paragraphMarkDelete" && !elements.length)
81061
+ return;
81050
81062
  if (pPr)
81051
81063
  elements.unshift(pPr);
81052
81064
  let attributes = {};
@@ -81300,6 +81312,11 @@ function translateTableCell(params3) {
81300
81312
  ...params3,
81301
81313
  tableCell: params3.node
81302
81314
  });
81315
+ if (!elements.length)
81316
+ elements.push({
81317
+ name: "w:p",
81318
+ elements: []
81319
+ });
81303
81320
  const cellProps = generateTableCellProperties(params3.node);
81304
81321
  elements.unshift(cellProps);
81305
81322
  return {
@@ -84623,7 +84640,7 @@ function normalizeChartTarget(target) {
84623
84640
  function resolveChartPart(docx, chartRelId, filename) {
84624
84641
  if (!chartRelId || !docx)
84625
84642
  return null;
84626
- const chartRel = findChild$1(docx[`word/_rels/${filename || "document.xml"}.rels`] || docx["word/_rels/document.xml.rels"], "Relationships")?.elements?.find((el) => getAttr(el, "Id") === chartRelId);
84643
+ const chartRel = findChild$2(docx[`word/_rels/${filename || "document.xml"}.rels`] || docx["word/_rels/document.xml.rels"], "Relationships")?.elements?.find((el) => getAttr(el, "Id") === chartRelId);
84627
84644
  if (!chartRel)
84628
84645
  return null;
84629
84646
  const target = getAttr(chartRel, "Target");
@@ -84635,11 +84652,11 @@ function resolveChartPart(docx, chartRelId, filename) {
84635
84652
  };
84636
84653
  }
84637
84654
  function parseChartXml(chartXml) {
84638
- const chartSpace = chartXml?.name === "c:chartSpace" ? chartXml : findChild$1(chartXml, "c:chartSpace");
84639
- const chart = findChild$1(chartSpace, "c:chart");
84655
+ const chartSpace = chartXml?.name === "c:chartSpace" ? chartXml : findChild$2(chartXml, "c:chartSpace");
84656
+ const chart = findChild$2(chartSpace, "c:chart");
84640
84657
  if (!chart)
84641
84658
  return null;
84642
- const plotArea = findChild$1(chart, "c:plotArea");
84659
+ const plotArea = findChild$2(chart, "c:plotArea");
84643
84660
  if (!plotArea)
84644
84661
  return null;
84645
84662
  const chartTypeEntry = findChartTypeElement(plotArea);
@@ -84680,22 +84697,22 @@ function findChartTypeElement(plotArea) {
84680
84697
  return null;
84681
84698
  }
84682
84699
  function extractGrouping(chartTypeEl) {
84683
- return getAttr(findChild$1(chartTypeEl, "c:grouping"), "val") || undefined;
84700
+ return getAttr(findChild$2(chartTypeEl, "c:grouping"), "val") || undefined;
84684
84701
  }
84685
84702
  function extractBarDirection(chartTypeEl) {
84686
- const val = getAttr(findChild$1(chartTypeEl, "c:barDir"), "val");
84703
+ const val = getAttr(findChild$2(chartTypeEl, "c:barDir"), "val");
84687
84704
  return val === "col" || val === "bar" ? val : undefined;
84688
84705
  }
84689
84706
  function parseSeries(chartTypeEl, chartType) {
84690
- return findChildren$2(chartTypeEl, "c:ser").map((seriesEl) => parseOneSeries(seriesEl, chartType));
84707
+ return findChildren$3(chartTypeEl, "c:ser").map((seriesEl) => parseOneSeries(seriesEl, chartType));
84691
84708
  }
84692
84709
  function parseOneSeries(serEl, chartType) {
84693
84710
  const name = extractSeriesName(serEl);
84694
- const categories = extractCachedStrings(findChild$1(serEl, "c:cat"));
84695
- const values = extractCachedNumbers(findChild$1(serEl, "c:val"));
84696
- const xValues = extractCachedNumbers(findChild$1(serEl, "c:xVal"));
84697
- const yValues = extractCachedNumbers(findChild$1(serEl, "c:yVal"));
84698
- const bubbleSizes = extractCachedNumbers(findChild$1(serEl, "c:bubbleSize"));
84711
+ const categories = extractCachedStrings(findChild$2(serEl, "c:cat"));
84712
+ const values = extractCachedNumbers(findChild$2(serEl, "c:val"));
84713
+ const xValues = extractCachedNumbers(findChild$2(serEl, "c:xVal"));
84714
+ const yValues = extractCachedNumbers(findChild$2(serEl, "c:yVal"));
84715
+ const bubbleSizes = extractCachedNumbers(findChild$2(serEl, "c:bubbleSize"));
84699
84716
  if (chartType === "scatterChart" || chartType === "bubbleChart") {
84700
84717
  const parsedCategoryValues = categories.map((value) => Number(value));
84701
84718
  const numericCategoryValues = parsedCategoryValues.every((value) => Number.isFinite(value)) ? parsedCategoryValues : [];
@@ -84723,36 +84740,36 @@ function formatChartLabel(value, fallbackIndex) {
84723
84740
  return String(Number(value.toFixed(3)));
84724
84741
  }
84725
84742
  function extractSeriesName(serEl) {
84726
- return findChild$1(findChild$1(findChild$1(findChild$1(findChild$1(serEl, "c:tx"), "c:strRef"), "c:strCache"), "c:pt"), "c:v")?.elements?.[0]?.text ?? `Series ${getAttr(findChild$1(serEl, "c:idx"), "val") ?? ""}`.trim();
84743
+ return findChild$2(findChild$2(findChild$2(findChild$2(findChild$2(serEl, "c:tx"), "c:strRef"), "c:strCache"), "c:pt"), "c:v")?.elements?.[0]?.text ?? `Series ${getAttr(findChild$2(serEl, "c:idx"), "val") ?? ""}`.trim();
84727
84744
  }
84728
84745
  function extractCachedStrings(parentEl) {
84729
84746
  if (!parentEl)
84730
84747
  return [];
84731
- const strCache = findChild$1(findChild$1(parentEl, "c:strRef"), "c:strCache");
84732
- const numCache = findChild$1(findChild$1(parentEl, "c:numRef"), "c:numCache");
84748
+ const strCache = findChild$2(findChild$2(parentEl, "c:strRef"), "c:strCache");
84749
+ const numCache = findChild$2(findChild$2(parentEl, "c:numRef"), "c:numCache");
84733
84750
  const cache = strCache || numCache;
84734
84751
  if (!cache)
84735
84752
  return [];
84736
- return findChildren$2(cache, "c:pt").sort((a, b) => (Number(getAttr(a, "idx")) || 0) - (Number(getAttr(b, "idx")) || 0)).map((pt) => findChild$1(pt, "c:v")?.elements?.[0]?.text ?? "");
84753
+ return findChildren$3(cache, "c:pt").sort((a, b) => (Number(getAttr(a, "idx")) || 0) - (Number(getAttr(b, "idx")) || 0)).map((pt) => findChild$2(pt, "c:v")?.elements?.[0]?.text ?? "");
84737
84754
  }
84738
84755
  function extractCachedNumbers(parentEl) {
84739
84756
  if (!parentEl)
84740
84757
  return [];
84741
- const numCache = findChild$1(findChild$1(parentEl, "c:numRef"), "c:numCache");
84758
+ const numCache = findChild$2(findChild$2(parentEl, "c:numRef"), "c:numCache");
84742
84759
  if (!numCache)
84743
84760
  return [];
84744
- return findChildren$2(numCache, "c:pt").sort((a, b) => (Number(getAttr(a, "idx")) || 0) - (Number(getAttr(b, "idx")) || 0)).map((pt) => {
84745
- const text$2 = findChild$1(pt, "c:v")?.elements?.[0]?.text;
84761
+ return findChildren$3(numCache, "c:pt").sort((a, b) => (Number(getAttr(a, "idx")) || 0) - (Number(getAttr(b, "idx")) || 0)).map((pt) => {
84762
+ const text$2 = findChild$2(pt, "c:v")?.elements?.[0]?.text;
84746
84763
  const num = Number(text$2);
84747
84764
  return Number.isFinite(num) ? num : 0;
84748
84765
  });
84749
84766
  }
84750
84767
  function parseAxis(plotArea, axisName) {
84751
- const axis = findChild$1(plotArea, axisName);
84768
+ const axis = findChild$2(plotArea, axisName);
84752
84769
  if (!axis)
84753
84770
  return;
84754
- const title = extractAxisTitle(findChild$1(axis, "c:title"));
84755
- const orientation = getAttr(findChild$1(findChild$1(axis, "c:scaling"), "c:orientation"), "val");
84771
+ const title = extractAxisTitle(findChild$2(axis, "c:title"));
84772
+ const orientation = getAttr(findChild$2(findChild$2(axis, "c:scaling"), "c:orientation"), "val");
84756
84773
  const config$43 = {};
84757
84774
  if (title)
84758
84775
  config$43.title = title;
@@ -84763,25 +84780,25 @@ function parseAxis(plotArea, axisName) {
84763
84780
  function extractAxisTitle(titleEl) {
84764
84781
  if (!titleEl)
84765
84782
  return;
84766
- return findChild$1(findChild$1(findChild$1(findChild$1(findChild$1(titleEl, "c:tx"), "c:rich"), "a:p"), "a:r"), "a:t")?.elements?.[0]?.text || undefined;
84783
+ return findChild$2(findChild$2(findChild$2(findChild$2(findChild$2(titleEl, "c:tx"), "c:rich"), "a:p"), "a:r"), "a:t")?.elements?.[0]?.text || undefined;
84767
84784
  }
84768
84785
  function parseLegendPosition(chart) {
84769
- const legend = findChild$1(chart, "c:legend");
84786
+ const legend = findChild$2(chart, "c:legend");
84770
84787
  if (!legend)
84771
84788
  return;
84772
- return getAttr(findChild$1(legend, "c:legendPos"), "val") || undefined;
84789
+ return getAttr(findChild$2(legend, "c:legendPos"), "val") || undefined;
84773
84790
  }
84774
84791
  function parseStyleId(chartSpace) {
84775
- const altContent = findChild$1(chartSpace, "mc:AlternateContent");
84792
+ const altContent = findChild$2(chartSpace, "mc:AlternateContent");
84776
84793
  if (altContent) {
84777
- const val$1 = getAttr(findChild$1(findChild$1(altContent, "mc:Choice"), "c14:style"), "val");
84794
+ const val$1 = getAttr(findChild$2(findChild$2(altContent, "mc:Choice"), "c14:style"), "val");
84778
84795
  if (val$1 != null)
84779
84796
  return Number(val$1);
84780
- const fallbackVal = getAttr(findChild$1(findChild$1(altContent, "mc:Fallback"), "c:style"), "val");
84797
+ const fallbackVal = getAttr(findChild$2(findChild$2(altContent, "mc:Fallback"), "c:style"), "val");
84781
84798
  if (fallbackVal != null)
84782
84799
  return Number(fallbackVal);
84783
84800
  }
84784
- const val = getAttr(findChild$1(chartSpace, "c:style"), "val");
84801
+ const val = getAttr(findChild$2(chartSpace, "c:style"), "val");
84785
84802
  return val != null ? Number(val) : undefined;
84786
84803
  }
84787
84804
  function stripRunNodeMarks(nodes) {
@@ -90691,7 +90708,7 @@ function getActiveAttributes(state) {
90691
90708
  return {};
90692
90709
  }
90693
90710
  }
90694
- function findChildren$1(node3, predicate) {
90711
+ function findChildren$2(node3, predicate) {
90695
90712
  const nodesWithPos = [];
90696
90713
  node3.descendants((child, pos) => {
90697
90714
  if (predicate(child))
@@ -99743,16 +99760,16 @@ function translateStructuredContent(params3) {
99743
99760
  ...params3,
99744
99761
  node: node3
99745
99762
  });
99746
- const childElements = Array.isArray(childContent) ? childContent : [childContent];
99763
+ const childElements$1 = Array.isArray(childContent) ? childContent : [childContent];
99747
99764
  if (isFinalDoc && !preserveSdtWrappers) {
99748
99765
  if (node3?.type === "structuredContent")
99749
- return convertSdtContentToRuns(childElements);
99766
+ return convertSdtContentToRuns(childElements$1);
99750
99767
  if (node3?.type === "structuredContentBlock")
99751
- return childElements.length === 1 ? childElements[0] : childElements;
99768
+ return childElements$1.length === 1 ? childElements$1[0] : childElements$1;
99752
99769
  }
99753
99770
  const sdtContent = {
99754
99771
  name: "w:sdtContent",
99755
- elements: childElements
99772
+ elements: childElements$1
99756
99773
  };
99757
99774
  return {
99758
99775
  name: "w:sdt",
@@ -99981,28 +99998,25 @@ function _getReferencedTableStyles(tableStyleReference, params3) {
99981
99998
  return null;
99982
99999
  const stylesToReturn = {};
99983
100000
  const { docx } = params3;
99984
- const { elements } = docx["word/styles.xml"].elements[0];
99985
- const styleElements = elements.filter((el) => el.name === "w:style");
99986
- const styleTag = styleElements.find((el) => el.attributes["w:styleId"] === tableStyleReference);
100001
+ const styles = docx?.["word/styles.xml"];
100002
+ const styleElements = findChildren$1(childElements(styles)[0], "w:style");
100003
+ const styleTag = styleElements.find((el) => attrValue(el, "w:styleId") === tableStyleReference);
99987
100004
  if (!styleTag)
99988
100005
  return null;
99989
- stylesToReturn.name = styleTag.elements.find((el) => el.name === "w:name");
99990
- const basedOn = styleTag.elements.find((el) => el.name === "w:basedOn");
100006
+ stylesToReturn.name = findChild$1(styleTag, "w:name");
100007
+ const basedOn = findChild$1(styleTag, "w:basedOn");
99991
100008
  let baseTblPr;
99992
100009
  if (basedOn?.attributes) {
99993
- const baseStyles = styleElements.find((el) => el.attributes["w:styleId"] === basedOn.attributes["w:val"]);
99994
- baseTblPr = baseStyles ? baseStyles.elements.find((el) => el.name === "w:tblPr") : {};
99995
- }
99996
- const pPr = styleTag.elements.find((el) => el.name === "w:pPr");
99997
- if (pPr) {
99998
- const justification = pPr.elements.find((el) => el.name === "w:jc");
99999
- if (justification?.attributes)
100000
- stylesToReturn.justification = justification.attributes["w:val"];
100010
+ const baseStyles = styleElements.find((el) => attrValue(el, "w:styleId") === attrValue(basedOn, "w:val"));
100011
+ baseTblPr = baseStyles ? findChild$1(baseStyles, "w:tblPr") : {};
100001
100012
  }
100002
- const rPr = styleTag?.elements.find((el) => el.name === "w:rPr");
100013
+ const justification = findChild$1(findChild$1(styleTag, "w:pPr"), "w:jc");
100014
+ if (justification?.attributes)
100015
+ stylesToReturn.justification = attrValue(justification, "w:val");
100016
+ const rPr = findChild$1(styleTag, "w:rPr");
100003
100017
  if (rPr) {
100004
- const fonts = rPr.elements.find((el) => el.name === "w:rFonts");
100005
- if (fonts) {
100018
+ const fonts = findChild$1(rPr, "w:rFonts");
100019
+ if (fonts?.attributes) {
100006
100020
  const { "w:ascii": ascii, "w:hAnsi": hAnsi, "w:cs": cs } = fonts.attributes;
100007
100021
  stylesToReturn.fonts = {
100008
100022
  ascii,
@@ -100010,11 +100024,11 @@ function _getReferencedTableStyles(tableStyleReference, params3) {
100010
100024
  cs
100011
100025
  };
100012
100026
  }
100013
- const fontSize = rPr.elements.find((el) => el.name === "w:sz");
100027
+ const fontSize = findChild$1(rPr, "w:sz");
100014
100028
  if (fontSize?.attributes)
100015
- stylesToReturn.fontSize = halfPointToPoints(fontSize.attributes["w:val"]) + "pt";
100029
+ stylesToReturn.fontSize = halfPointToPoints(attrValue(fontSize, "w:val")) + "pt";
100016
100030
  }
100017
- const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
100031
+ const tblPr = findChild$1(styleTag, "w:tblPr");
100018
100032
  if (tblPr && tblPr.elements) {
100019
100033
  const mergedTblPr = baseTblPr?.elements?.length > 0 ? {
100020
100034
  name: tblPr.name,
@@ -100043,16 +100057,15 @@ function _getReferencedTableStyles(tableStyleReference, params3) {
100043
100057
  stylesToReturn.tableCellSpacing = tableProperties.tableCellSpacing;
100044
100058
  }
100045
100059
  }
100046
- const tblStylePr = styleTag.elements.filter((el) => el.name === "w:tblStylePr");
100047
- let styleProps = {};
100048
- if (tblStylePr)
100049
- styleProps = tblStylePr.reduce((acc, el) => {
100050
- acc[el.attributes["w:type"]] = translator$204.encode({
100060
+ const styleProps = findChildren$1(styleTag, "w:tblStylePr").reduce((acc, el) => {
100061
+ const conditionalType = attrValue(el, "w:type");
100062
+ if (conditionalType)
100063
+ acc[conditionalType] = translator$204.encode({
100051
100064
  ...params3,
100052
100065
  nodes: [el]
100053
100066
  });
100054
- return acc;
100055
- }, {});
100067
+ return acc;
100068
+ }, {});
100056
100069
  return {
100057
100070
  ...stylesToReturn,
100058
100071
  ...styleProps
@@ -100782,6 +100795,9 @@ function importCommentData({ docx, editor, converter }) {
100782
100795
  function isReplacementPair(previous$1, current) {
100783
100796
  return previous$1.type !== current.type && previous$1.author === current.author && previous$1.date === current.date;
100784
100797
  }
100798
+ function isSameTypeChainContinuation(previous$1, current) {
100799
+ return previous$1.type === current.type && previous$1.author === current.author && previous$1.date === current.date;
100800
+ }
100785
100801
  function trackedChangeEntryFromElement(element) {
100786
100802
  return {
100787
100803
  type: element.name,
@@ -100820,21 +100836,40 @@ function assignInternalId(element, idMap, context, insideTrackedChange, nextTrac
100820
100836
  const current = trackedChangeEntryFromElement(element);
100821
100837
  const shouldPair = context.replacements === "paired";
100822
100838
  const shouldKeepChildSides = context.lastTrackedChange && isChildReplacementInsideDeletion(context.beforeLastTrackedChange, context.lastTrackedChange, current, nextTrackedChange);
100823
- if (shouldPair && context.lastTrackedChange && !shouldKeepChildSides && isReplacementPair(context.lastTrackedChange, current)) {
100839
+ const canPair = shouldPair && context.lastTrackedChange && !context.lastTrackedChange.chained && !shouldKeepChildSides && isReplacementPair(context.lastTrackedChange, current);
100840
+ const canChain = !canPair && context.lastTrackedChange && context.lastTrackedChange.chainable !== false && isSameTypeChainContinuation(context.lastTrackedChange, current) && !idMap.has(wordId);
100841
+ if (canPair) {
100824
100842
  if (!idMap.has(wordId))
100825
100843
  idMap.set(wordId, context.lastTrackedChange.internalId);
100826
100844
  context.lastTrackedChange = null;
100827
100845
  context.beforeLastTrackedChange = null;
100846
+ } else if (canChain) {
100847
+ const internalId = context.lastTrackedChange.internalId;
100848
+ idMap.set(wordId, internalId);
100849
+ context.beforeLastTrackedChange = context.lastTrackedChange;
100850
+ context.lastTrackedChange = {
100851
+ ...current,
100852
+ internalId,
100853
+ chained: true,
100854
+ chainable: true
100855
+ };
100828
100856
  } else {
100857
+ const wasAlreadyMapped = idMap.has(wordId);
100829
100858
  const internalId = idMap.get(wordId) ?? v4_default();
100830
100859
  idMap.set(wordId, internalId);
100831
100860
  context.beforeLastTrackedChange = context.lastTrackedChange;
100832
100861
  context.lastTrackedChange = {
100833
100862
  ...current,
100834
- internalId
100863
+ internalId,
100864
+ chainable: !wasAlreadyMapped
100835
100865
  };
100836
100866
  }
100837
100867
  }
100868
+ function getParagraphMarkTrackedChangeElement(pElement) {
100869
+ if (pElement?.name !== "w:p")
100870
+ return null;
100871
+ return pElement.elements?.find((el) => el.name === "w:pPr")?.elements?.find((el) => el.name === "w:rPr")?.elements?.find((el) => TRACKED_CHANGE_NAMES.has(el.name)) ?? null;
100872
+ }
100838
100873
  function walkElements(elements, idMap, context, insideTrackedChange = false) {
100839
100874
  if (!Array.isArray(elements))
100840
100875
  return;
@@ -100848,6 +100883,32 @@ function walkElements(elements, idMap, context, insideTrackedChange = false) {
100848
100883
  lastTrackedChange: null,
100849
100884
  replacements: context.replacements
100850
100885
  }, true);
100886
+ } else if (element.name === "w:p" && !insideTrackedChange) {
100887
+ const paragraphMarkElement = getParagraphMarkTrackedChangeElement(element);
100888
+ if (!(paragraphMarkElement && context.lastTrackedChange && isSameTypeChainContinuation(context.lastTrackedChange, trackedChangeEntryFromElement(paragraphMarkElement)))) {
100889
+ context.lastTrackedChange = null;
100890
+ context.beforeLastTrackedChange = null;
100891
+ if (element.elements)
100892
+ walkElements(element.elements, idMap, context, insideTrackedChange);
100893
+ } else {
100894
+ const pPr = element.elements.find((el) => el.name === "w:pPr");
100895
+ const rPr = pPr?.elements?.find((el) => el.name === "w:rPr");
100896
+ assignInternalId(paragraphMarkElement, idMap, context, false, null);
100897
+ if (pPr?.elements) {
100898
+ walkElements(pPr.elements.filter((el) => el !== rPr), idMap, {
100899
+ beforeLastTrackedChange: null,
100900
+ lastTrackedChange: null,
100901
+ replacements: context.replacements
100902
+ }, insideTrackedChange);
100903
+ if (rPr?.elements)
100904
+ walkElements(rPr.elements.filter((el) => el !== paragraphMarkElement), idMap, {
100905
+ beforeLastTrackedChange: null,
100906
+ lastTrackedChange: null,
100907
+ replacements: context.replacements
100908
+ }, insideTrackedChange);
100909
+ }
100910
+ walkElements(element.elements.filter((el) => el !== pPr), idMap, context, insideTrackedChange);
100911
+ }
100851
100912
  } else {
100852
100913
  if (!PAIRING_TRANSPARENT_NAMES.has(element.name)) {
100853
100914
  context.lastTrackedChange = null;
@@ -100921,9 +100982,9 @@ function importNoteEntries({ partXml, childElementName, filename, docx, editor,
100921
100982
  }
100922
100983
  if (!Number.isFinite(idNumber) || idNumber < 0)
100923
100984
  return;
100924
- const childElements = Array.isArray(el.elements) ? el.elements : [];
100985
+ const childElements$1 = Array.isArray(el.elements) ? el.elements : [];
100925
100986
  const stripped = stripNoteMarkerNodes(handler$1.handler({
100926
- nodes: childElements,
100987
+ nodes: childElements$1,
100927
100988
  nodeListHandler: handler$1,
100928
100989
  docx,
100929
100990
  editor,
@@ -101404,28 +101465,12 @@ function getStyleDefinitions(docx) {
101404
101465
  const styles = docx["word/styles.xml"];
101405
101466
  if (!styles)
101406
101467
  return [];
101407
- const elements = styles.elements?.[0]?.elements ?? [];
101408
- const styleDefinitions = elements.filter((el) => el.name === "w:style");
101409
- const latentStyles = elements.find((el) => el.name === "w:latentStyles");
101410
- const matchedLatentStyles = [];
101411
- (latentStyles?.elements ?? []).forEach((el) => {
101412
- const { attributes } = el;
101413
- if (styleDefinitions.find((style) => style.attributes["w:styleId"] === attributes["w:name"]))
101414
- matchedLatentStyles.push(el);
101415
- });
101416
- const allParsedStyles = [];
101417
- styleDefinitions.forEach((style) => {
101418
- const id2 = style.attributes["w:styleId"];
101419
- const parsedStyle = getDefaultStyleDefinition(id2, docx);
101420
- const importedStyle = {
101421
- id: style.attributes["w:styleId"],
101422
- type: style.attributes["w:type"],
101423
- definition: parsedStyle,
101424
- attributes: {}
101425
- };
101426
- allParsedStyles.push(importedStyle);
101427
- });
101428
- return allParsedStyles;
101468
+ return (styles.elements?.[0]?.elements ?? []).filter((el) => el.name === "w:style" && attrValue(el, "w:styleId")).map((style) => ({
101469
+ id: attrValue(style, "w:styleId"),
101470
+ type: attrValue(style, "w:type"),
101471
+ definition: getDefaultStyleDefinition(attrValue(style, "w:styleId"), docx),
101472
+ attributes: {}
101473
+ }));
101429
101474
  }
101430
101475
  function translateStyleDefinitions(docx) {
101431
101476
  const styles = docx["word/styles.xml"];
@@ -113315,6 +113360,47 @@ function getTrackedChangeGroupKey(attrs, markType, fallbackId) {
113315
113360
  const sourceId = toNonEmptyString(attrs.sourceId);
113316
113361
  return sourceId ? `word:${markType}:${sourceId}` : fallbackId;
113317
113362
  }
113363
+ function coalesceSameTypeImportedChains(byRawId, segmentsByRawId) {
113364
+ const canonicalKeyByChain = /* @__PURE__ */ new Map;
113365
+ for (const [groupKey, draft] of byRawId) {
113366
+ const id2 = toNonEmptyString(draft.attrs.id);
113367
+ const sourceId = toNonEmptyString(draft.attrs.sourceId);
113368
+ if (!id2 || !sourceId)
113369
+ continue;
113370
+ const isPureInsert = draft.hasInsert && !draft.hasDelete && !draft.hasFormat;
113371
+ const isPureDelete = draft.hasDelete && !draft.hasInsert && !draft.hasFormat;
113372
+ if (!isPureInsert && !isPureDelete)
113373
+ continue;
113374
+ const chainKey = `${isPureInsert ? TrackInsertMarkName : TrackDeleteMarkName}:${id2}`;
113375
+ const canonicalKey = canonicalKeyByChain.get(chainKey);
113376
+ if (!canonicalKey) {
113377
+ canonicalKeyByChain.set(chainKey, groupKey);
113378
+ continue;
113379
+ }
113380
+ if (canonicalKey === groupKey)
113381
+ continue;
113382
+ const canonical = byRawId.get(canonicalKey);
113383
+ if (!canonical)
113384
+ continue;
113385
+ canonical.from = Math.min(canonical.from, draft.from);
113386
+ canonical.to = Math.max(canonical.to, draft.to);
113387
+ for (let i$1 = 0;i$1 < draft.excerptParts.length; i$1 += 1) {
113388
+ const range = draft.excerptRanges[i$1];
113389
+ if (!canonical.excerptRanges.some((counted) => rangesOverlap(counted, range))) {
113390
+ canonical.excerptRanges.push(range);
113391
+ canonical.excerptParts.push(draft.excerptParts[i$1]);
113392
+ }
113393
+ }
113394
+ if (draft.wordRevisionIds)
113395
+ for (const key of Object.keys(draft.wordRevisionIds))
113396
+ canonical.wordRevisionIds = mergeWordRevisionId(canonical.wordRevisionIds, key, draft.wordRevisionIds[key]);
113397
+ const canonicalSegments = segmentsByRawId.get(canonicalKey) ?? [];
113398
+ const draftSegments = segmentsByRawId.get(groupKey) ?? [];
113399
+ segmentsByRawId.set(canonicalKey, canonicalSegments.concat(draftSegments));
113400
+ segmentsByRawId.delete(groupKey);
113401
+ byRawId.delete(groupKey);
113402
+ }
113403
+ }
113318
113404
  function isTrackedMarkName(markType) {
113319
113405
  return markType === "trackInsert" || markType === "trackDelete" || markType === "trackFormat";
113320
113406
  }
@@ -113598,6 +113684,7 @@ function groupTrackedChanges(editor) {
113598
113684
  if (wordRevisionIdKey)
113599
113685
  existing.wordRevisionIds = mergeWordRevisionId(existing.wordRevisionIds, wordRevisionIdKey, wordRevisionId ?? undefined);
113600
113686
  }
113687
+ coalesceSameTypeImportedChains(byRawId, segmentsByRawId);
113601
113688
  const grouped = Array.from(byRawId.values()).map(({ excerptParts, excerptRanges: _excerptRanges, ...change }) => {
113602
113689
  const hasWordSourceId = Boolean(toNonEmptyString(change.attrs.sourceId));
113603
113690
  const rawExcerpt = excerptParts.join("");
@@ -117346,8 +117433,15 @@ var isRegExp = (value) => {
117346
117433
  },
117347
117434
  trackingMarksByType
117348
117435
  };
117349
- }, TRACKABLE_RUN_CONTENT_TYPES, applyTrackedMarkToRunContent = (subElements = [], markType, attrs) => {
117436
+ }, TRACKABLE_RUN_CONTENT_TYPES, TRACKABLE_WHOLE_NODE_TYPES, applyTrackedMarkToRunContent = (subElements = [], markType, attrs) => {
117350
117437
  subElements.forEach((subElement) => {
117438
+ if (subElement && TRACKABLE_WHOLE_NODE_TYPES.has(subElement.type)) {
117439
+ subElement.marks = [...Array.isArray(subElement.marks) ? subElement.marks : [], {
117440
+ type: markType,
117441
+ attrs
117442
+ }];
117443
+ return;
117444
+ }
117351
117445
  subElement.marks = [];
117352
117446
  (Array.isArray(subElement?.content) ? subElement.content : []).forEach((child) => {
117353
117447
  if (!child || !TRACKABLE_RUN_CONTENT_TYPES.has(child.type))
@@ -117373,6 +117467,8 @@ var isRegExp = (value) => {
117373
117467
  return;
117374
117468
  if (node3.name === "w:t")
117375
117469
  node3.name = "w:delText";
117470
+ if (node3.name === "w:instrText")
117471
+ node3.name = "w:delInstrText";
117376
117472
  if (Array.isArray(node3.elements))
117377
117473
  node3.elements.forEach(renameTextElementsForDeletion);
117378
117474
  }, ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Map, options = {}) => {
@@ -117884,6 +117980,20 @@ var isRegExp = (value) => {
117884
117980
  schemaNode.attrs.paragraphProperties = inlineParagraphProperties;
117885
117981
  schemaNode.attrs.rsidRDefault = node3.attributes?.["w:rsidRDefault"];
117886
117982
  schemaNode.attrs.filename = filename;
117983
+ const markDeletionElement = pPr?.elements?.find((el) => el.name === "w:rPr")?.elements?.find((el) => el.name === "w:del");
117984
+ if (markDeletionElement) {
117985
+ const markAttributes = markDeletionElement.attributes || {};
117986
+ const { sourceId, logicalId } = resolveTrackedChangeImportIds(params3, markAttributes["w:id"]);
117987
+ schemaNode.attrs.markTrackChange = {
117988
+ type: "paragraphMarkDelete",
117989
+ id: logicalId || (sourceId ? String(sourceId) : ""),
117990
+ sourceId: sourceId ? String(sourceId) : undefined,
117991
+ author: markAttributes["w:author"] || "",
117992
+ authorEmail: markAttributes["w:authorEmail"] || "",
117993
+ date: markAttributes["w:date"] || "",
117994
+ importedAuthor: `${markAttributes["w:author"] || ""} (imported)`
117995
+ };
117996
+ }
117887
117997
  const sectPr = pPr?.elements?.find((el) => el.name === "w:sectPr");
117888
117998
  if (sectPr) {
117889
117999
  schemaNode.attrs.paragraphProperties.sectPr = sectPr;
@@ -118294,7 +118404,7 @@ var isRegExp = (value) => {
118294
118404
  };
118295
118405
  if (!exportParams.editor)
118296
118406
  exportParams.editor = { extensionService: { extensions: [] } };
118297
- const childElements = translateChildNodes(exportParams) || [];
118407
+ const childElements$1 = translateChildNodes(exportParams) || [];
118298
118408
  let runPropertiesElement = Object.keys(runPropertiesToExport).length > 0 ? translator$133.decode({
118299
118409
  ...params3,
118300
118410
  node: { attrs: { runProperties: runPropertiesToExport } }
@@ -118317,7 +118427,7 @@ var isRegExp = (value) => {
118317
118427
  });
118318
118428
  };
118319
118429
  const runs = [];
118320
- childElements.forEach((child) => {
118430
+ childElements$1.forEach((child) => {
118321
118431
  if (!child)
118322
118432
  return;
118323
118433
  if (child.name === "w:r") {
@@ -118978,13 +119088,13 @@ var isRegExp = (value) => {
118978
119088
  const translatedContent = [];
118979
119089
  const parentPath = [sdtContent];
118980
119090
  (sdtContent?.elements || []).forEach((child) => {
118981
- const childElements = Array.isArray(child?.elements) ? child.elements : [];
118982
- const tocElements = child?.name === PARAGRAPH_XML_NAME ? childElements.filter((el) => el?.name === SD_TOC_XML_NAME) : [];
119091
+ const childElements$1 = Array.isArray(child?.elements) ? child.elements : [];
119092
+ const tocElements = child?.name === PARAGRAPH_XML_NAME ? childElements$1.filter((el) => el?.name === SD_TOC_XML_NAME) : [];
118983
119093
  if (tocElements.length === 0) {
118984
119094
  translatedContent.push(...translateNodes(params3, [child], parentPath));
118985
119095
  return;
118986
119096
  }
118987
- const remainingElements = childElements.filter((el) => el?.name !== SD_TOC_XML_NAME);
119097
+ const remainingElements = childElements$1.filter((el) => el?.name !== SD_TOC_XML_NAME);
118988
119098
  if (hasMeaningfulParagraphContent$1(remainingElements))
118989
119099
  translatedContent.push(...translateNodes(params3, [{
118990
119100
  ...child,
@@ -123505,7 +123615,7 @@ var isRegExp = (value) => {
123505
123615
  return;
123506
123616
  }
123507
123617
  const fldType = node3.elements?.find((el) => el.name === "w:fldChar")?.attributes?.["w:fldCharType"];
123508
- const instrTextEl = node3.elements?.find((el) => el.name === "w:instrText");
123618
+ const instrTextEl = node3.elements?.find((el) => el.name === "w:instrText" || el.name === "w:delInstrText");
123509
123619
  if (node3.name === "w:fldSimple") {
123510
123620
  const instr = node3.attributes?.["w:instr"];
123511
123621
  if (typeof instr === "string") {
@@ -123747,7 +123857,7 @@ var isRegExp = (value) => {
123747
123857
  const elements = Array.isArray(node3?.elements) ? node3.elements : [];
123748
123858
  const tokens = [];
123749
123859
  elements.forEach((el) => {
123750
- if (el?.name === "w:instrText") {
123860
+ if (el?.name === "w:instrText" || el?.name === "w:delInstrText") {
123751
123861
  const text$2 = (el.elements || []).map((child) => typeof child?.text === "string" ? child.text : "").join("");
123752
123862
  tokens.push({
123753
123863
  type: "text",
@@ -123836,9 +123946,9 @@ var isRegExp = (value) => {
123836
123946
  i$1++;
123837
123947
  continue;
123838
123948
  }
123839
- const childElements = node3.elements || [];
123840
- if (childElements.length > 0) {
123841
- for (const child of childElements) {
123949
+ const childElements$1 = node3.elements || [];
123950
+ if (childElements$1.length > 0) {
123951
+ for (const child of childElements$1) {
123842
123952
  if (Array.isArray(child.elements))
123843
123953
  child.elements = preProcessPageFieldsOnly(child.elements, depth + 1).processedNodes;
123844
123954
  processedNodes.push(child);
@@ -123880,7 +123990,7 @@ var isRegExp = (value) => {
123880
123990
  i$1++;
123881
123991
  }
123882
123992
  return { processedNodes };
123883
- }, HEADER_FOOTER_FILENAME_PATTERN, DEFAULT_TAB_INTERVAL_TWIPS$1 = 720, CHART_TYPE_MAP, CHART_TYPE_NAMES, findChild$1 = (node3, name) => node3?.elements?.find((el) => el.name === name), findChildren$2 = (node3, name) => node3?.elements?.filter((el) => el.name === name) ?? [], getAttr = (node3, attr) => node3?.attributes?.[attr], PARAGRAPH_PROPERTIES_XML_NAME = "w:pPr", hasMeaningfulParagraphContent = (elements = []) => elements.some((element) => element?.name && element.name !== PARAGRAPH_PROPERTIES_XML_NAME), findParagraphProperties = (elements = []) => elements.find((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME) ?? null, hasParagraphProperties = (elements = []) => elements.some((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME), cloneParagraphPropertiesForRenderedResult = (paragraphProperties) => {
123993
+ }, HEADER_FOOTER_FILENAME_PATTERN, DEFAULT_TAB_INTERVAL_TWIPS$1 = 720, CHART_TYPE_MAP, CHART_TYPE_NAMES, findChild$2 = (node3, name) => node3?.elements?.find((el) => el.name === name), findChildren$3 = (node3, name) => node3?.elements?.filter((el) => el.name === name) ?? [], getAttr = (node3, attr) => node3?.attributes?.[attr], PARAGRAPH_PROPERTIES_XML_NAME = "w:pPr", hasMeaningfulParagraphContent = (elements = []) => elements.some((element) => element?.name && element.name !== PARAGRAPH_PROPERTIES_XML_NAME), findParagraphProperties = (elements = []) => elements.find((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME) ?? null, hasParagraphProperties = (elements = []) => elements.some((element) => element?.name === PARAGRAPH_PROPERTIES_XML_NAME), cloneParagraphPropertiesForRenderedResult = (paragraphProperties) => {
123884
123994
  const elements = (paragraphProperties.elements || []).filter((element) => element?.name !== "w:sectPr").map((element) => carbonCopy(element));
123885
123995
  if (elements.length === 0)
123886
123996
  return null;
@@ -128640,7 +128750,7 @@ var isRegExp = (value) => {
128640
128750
  if (!Number.isFinite(numeric))
128641
128751
  return null;
128642
128752
  return Object.fromEntries(Object.entries(tblLookBitmask).map(([key, mask]) => [key, (numeric & mask) === mask]));
128643
- }, translator$165, translator$166, translator$168, translator$169, translator$170, translator$171, translator$172, baseConfig, orderedConfig, translator$158, propertyTranslators$3, translator$167, propertyTranslators$2, attributeHandlers$1, translator$204, getColspan = (cell) => {
128753
+ }, translator$165, translator$166, translator$168, translator$169, translator$170, translator$171, translator$172, baseConfig, orderedConfig, translator$158, propertyTranslators$3, translator$167, propertyTranslators$2, attributeHandlers$1, translator$204, childElements = (node3) => Array.isArray(node3?.elements) ? node3.elements : [], findChild$1 = (node3, name) => childElements(node3).find((el) => el?.name === name), findChildren$1 = (node3, name) => childElements(node3).filter((el) => el?.name === name), attrValue = (node3, name) => node3?.attributes?.[name], getColspan = (cell) => {
128644
128754
  const rawColspan = cell?.attrs?.colspan;
128645
128755
  const numericColspan = typeof rawColspan === "string" ? parseInt(rawColspan, 10) : rawColspan;
128646
128756
  return Number.isFinite(numericColspan) && numericColspan > 0 ? numericColspan : 1;
@@ -129491,6 +129601,8 @@ var isRegExp = (value) => {
129491
129601
  };
129492
129602
  }, decode$21 = (params3) => {
129493
129603
  const { node: node3 } = params3;
129604
+ if (node3.marks?.find((m) => m.type === "trackDelete"))
129605
+ return translator$59.decode(params3);
129494
129606
  const outputMarks = processOutputMarks(node3.attrs?.marksAsAttrs || []);
129495
129607
  const contentNodes = buildFieldResultRuns(params3, outputMarks);
129496
129608
  const instructionElements = buildInstructionElements(node3.attrs?.instruction, node3.attrs?.instructionTokens);
@@ -130402,11 +130514,11 @@ var isRegExp = (value) => {
130402
130514
  const originalXml = carbonCopy(node3) || {};
130403
130515
  const originalElementsSource = originalXml.elements;
130404
130516
  const originalElements = originalElementsSource ? carbonCopy(originalElementsSource) : [];
130405
- const childElements = Array.isArray(node3.elements) ? node3.elements : [];
130406
- if (childElements.length && params3.nodeListHandler?.handler)
130517
+ const childElements$1 = Array.isArray(node3.elements) ? node3.elements : [];
130518
+ if (childElements$1.length && params3.nodeListHandler?.handler)
130407
130519
  params3.nodeListHandler.handler({
130408
130520
  ...params3,
130409
- nodes: childElements,
130521
+ nodes: childElements$1,
130410
130522
  path: [...params3.path || [], node3]
130411
130523
  });
130412
130524
  if (originalElements?.length)
@@ -131075,7 +131187,7 @@ var isRegExp = (value) => {
131075
131187
  ...path2 && path2.length > 0 ? { path: path2 } : {},
131076
131188
  ...customFormat ? { customFormat } : {}
131077
131189
  };
131078
- }, getDefaultStyleDefinition = (defaultStyleId, docx) => {
131190
+ }, findInAnyRecord = (records, name) => records.map((record) => findChild$1(record, name)).find(Boolean), getDefaultStyleDefinition = (defaultStyleId, docx) => {
131079
131191
  const result = {
131080
131192
  lineSpaceBefore: null,
131081
131193
  lineSpaceAfter: null
@@ -131085,25 +131197,19 @@ var isRegExp = (value) => {
131085
131197
  const styles = docx["word/styles.xml"];
131086
131198
  if (!styles)
131087
131199
  return result;
131088
- const { elements } = styles.elements[0];
131089
- const elementsWithId = elements.filter((el) => {
131090
- const { attributes } = el;
131091
- return attributes && attributes["w:styleId"] === defaultStyleId;
131092
- });
131200
+ const elementsWithId = childElements(childElements(styles)[0]).filter((el) => attrValue(el, "w:styleId") === defaultStyleId);
131093
131201
  const firstMatch = elementsWithId[0];
131094
131202
  if (!firstMatch)
131095
131203
  return result;
131096
131204
  if (!firstMatch.elements)
131097
131205
  return result;
131098
- const qFormat = elementsWithId.find((el) => {
131099
- return el.elements.find((innerEl) => innerEl.name === "w:qFormat");
131100
- });
131101
- const name = elementsWithId.find((el) => el.elements.some((inner) => inner.name === "w:name"))?.elements.find((inner) => inner.name === "w:name")?.attributes["w:val"];
131102
- const pPr = firstMatch.elements.find((el) => el.name === "w:pPr");
131103
- const spacing = pPr?.elements?.find((el) => el.name === "w:spacing");
131104
- const justify = pPr?.elements?.find((el) => el.name === "w:jc");
131105
- const indent2 = pPr?.elements?.find((el) => el.name === "w:ind");
131106
- const tabs = pPr?.elements?.find((el) => el.name === "w:tabs");
131206
+ const qFormat = findInAnyRecord(elementsWithId, "w:qFormat");
131207
+ const name = attrValue(findInAnyRecord(elementsWithId, "w:name"), "w:val");
131208
+ const pPr = findChild$1(firstMatch, "w:pPr");
131209
+ const spacing = findChild$1(pPr, "w:spacing");
131210
+ const justify = findChild$1(pPr, "w:jc");
131211
+ const indent2 = findChild$1(pPr, "w:ind");
131212
+ const tabs = findChild$1(pPr, "w:tabs");
131107
131213
  let lineSpaceBefore, lineSpaceAfter, line;
131108
131214
  if (spacing?.attributes) {
131109
131215
  lineSpaceBefore = twipsToPixels(spacing.attributes["w:before"]);
@@ -131117,52 +131223,51 @@ var isRegExp = (value) => {
131117
131223
  rightIndent = twipsToPixels(indent2.attributes["w:right"]);
131118
131224
  firstLine = twipsToPixels(indent2.attributes["w:firstLine"]);
131119
131225
  }
131120
- let tabStops = [];
131121
- if (tabs)
131122
- tabStops = (tabs.elements || []).filter((el) => el.name === "w:tab").map((tab) => {
131123
- let val = tab.attributes["w:val"];
131124
- if (val == "left")
131125
- val = "start";
131126
- else if (val == "right")
131127
- val = "end";
131128
- return {
131129
- val,
131130
- pos: twipsToPixels(tab.attributes["w:pos"]),
131131
- leader: tab.attributes["w:leader"]
131132
- };
131133
- });
131134
- const keepNext = pPr?.elements?.find((el) => el.name === "w:keepNext");
131135
- const keepLines = pPr?.elements?.find((el) => el.name === "w:keepLines");
131136
- const outlineLevel = pPr?.elements?.find((el) => el.name === "w:outlineLvl");
131137
- const outlineLvlValue = outlineLevel?.attributes["w:val"];
131138
- const pageBreakBefore = pPr?.elements?.find((el) => el.name === "w:pageBreakBefore");
131226
+ const tabStops = findChildren$1(tabs, "w:tab").map((tab) => {
131227
+ let val = attrValue(tab, "w:val");
131228
+ if (val == "left")
131229
+ val = "start";
131230
+ else if (val == "right")
131231
+ val = "end";
131232
+ const rawPos = attrValue(tab, "w:pos")?.trim();
131233
+ return {
131234
+ val,
131235
+ pos: rawPos ? twipsToPixels(rawPos) : undefined,
131236
+ leader: attrValue(tab, "w:leader")
131237
+ };
131238
+ }).filter((stop) => stop.val != null && Number.isFinite(stop.pos));
131239
+ const keepNext = findChild$1(pPr, "w:keepNext");
131240
+ const keepLines = findChild$1(pPr, "w:keepLines");
131241
+ const outlineLvlRaw = attrValue(findChild$1(pPr, "w:outlineLvl"), "w:val")?.trim();
131242
+ const outlineLvlValue = /^[+-]?\d+$/.test(outlineLvlRaw ?? "") ? Number(outlineLvlRaw) : NaN;
131243
+ const pageBreakBefore = findChild$1(pPr, "w:pageBreakBefore");
131139
131244
  let pageBreakBeforeVal = 0;
131140
131245
  if (pageBreakBefore)
131141
131246
  if (!pageBreakBefore.attributes?.["w:val"])
131142
131247
  pageBreakBeforeVal = 1;
131143
131248
  else
131144
131249
  pageBreakBeforeVal = Number(pageBreakBefore?.attributes?.["w:val"]);
131145
- const pageBreakAfter = pPr?.elements?.find((el) => el.name === "w:pageBreakAfter");
131250
+ const pageBreakAfter = findChild$1(pPr, "w:pageBreakAfter");
131146
131251
  let pageBreakAfterVal;
131147
131252
  if (pageBreakAfter)
131148
131253
  if (!pageBreakAfter.attributes?.["w:val"])
131149
131254
  pageBreakAfterVal = 1;
131150
131255
  else
131151
131256
  pageBreakAfterVal = Number(pageBreakAfter?.attributes?.["w:val"]);
131152
- const basedOn = elementsWithId.find((el) => el.elements.some((inner) => inner.name === "w:basedOn"))?.elements.find((inner) => inner.name === "w:basedOn")?.attributes["w:val"];
131153
- const linkToCharacterStyle = firstMatch.elements.find((el) => el.name === "w:link")?.attributes?.["w:val"] ?? null;
131257
+ const basedOn = attrValue(findInAnyRecord(elementsWithId, "w:basedOn"), "w:val");
131258
+ const linkToCharacterStyle = attrValue(findChild$1(firstMatch, "w:link"), "w:val") ?? null;
131154
131259
  const parsedAttrs = {
131155
131260
  name,
131156
131261
  qFormat: qFormat ? true : false,
131157
131262
  keepNext: keepNext ? true : false,
131158
131263
  keepLines: keepLines ? true : false,
131159
- outlineLevel: outlineLevel ? parseInt(outlineLvlValue) : null,
131264
+ outlineLevel: Number.isInteger(outlineLvlValue) ? outlineLvlValue : null,
131160
131265
  pageBreakBefore: pageBreakBeforeVal ? true : false,
131161
131266
  pageBreakAfter: pageBreakAfterVal ? true : false,
131162
131267
  basedOn: basedOn ?? null,
131163
131268
  link: linkToCharacterStyle
131164
131269
  };
131165
- const parsedMarks = parseMarks(firstMatch.elements.find((el) => el.name === "w:rPr"), [], docx) || [];
131270
+ const parsedMarks = parseMarks(findChild$1(firstMatch, "w:rPr"), [], docx) || [];
131166
131271
  const parsedStyles = {
131167
131272
  spacing: {
131168
131273
  lineSpaceAfter,
@@ -136966,7 +137071,7 @@ Docs: https://docs.superdoc.dev/getting-started/fonts`);
136966
137071
  return out;
136967
137072
  }
136968
137073
  return out;
136969
- }, groupedCache, SDT_NODE_NAMES, SDT_BLOCK_NAME = "structuredContentBlock", SDT_INLINE_NAME = "structuredContent", SDT_NODE_TYPES, VALID_CONTROL_TYPES, VALID_LOCK_MODES2, VALID_APPEARANCES, FIELD_LIKE_SDT_TYPES, liveDocumentCountsCache, BIBLIOGRAPHY_NAMESPACE_URI = "http://schemas.openxmlformats.org/officeDocument/2006/bibliography", CUSTOM_XML_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml", CUSTOM_XML_PROPS_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps", DEFAULT_SELECTED_STYLE = "/APA.XSL", DEFAULT_STYLE_NAME = "APA", DEFAULT_VERSION = "6", API_TO_OOXML_SOURCE_TYPE, OOXML_TO_API_SOURCE_TYPE, SIMPLE_FIELD_TO_XML_TAG, XML_TAG_TO_SIMPLE_FIELD, import_lib2, FONT_FAMILY_FALLBACKS, DEFAULT_GENERIC_FALLBACK = "sans-serif", DEFAULT_FONT_SIZE_PT = 10, CURRENT_APP_VERSION = "1.45.1", SUPERDOC_DOCUMENT_ORIGIN_PROPERTY = "SuperdocDocumentOrigin", STORED_DOCUMENT_ORIGINS, collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state }) => {
137074
+ }, groupedCache, SDT_NODE_NAMES, SDT_BLOCK_NAME = "structuredContentBlock", SDT_INLINE_NAME = "structuredContent", SDT_NODE_TYPES, VALID_CONTROL_TYPES, VALID_LOCK_MODES2, VALID_APPEARANCES, FIELD_LIKE_SDT_TYPES, liveDocumentCountsCache, BIBLIOGRAPHY_NAMESPACE_URI = "http://schemas.openxmlformats.org/officeDocument/2006/bibliography", CUSTOM_XML_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml", CUSTOM_XML_PROPS_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps", DEFAULT_SELECTED_STYLE = "/APA.XSL", DEFAULT_STYLE_NAME = "APA", DEFAULT_VERSION = "6", API_TO_OOXML_SOURCE_TYPE, OOXML_TO_API_SOURCE_TYPE, SIMPLE_FIELD_TO_XML_TAG, XML_TAG_TO_SIMPLE_FIELD, import_lib2, FONT_FAMILY_FALLBACKS, DEFAULT_GENERIC_FALLBACK = "sans-serif", DEFAULT_FONT_SIZE_PT = 10, CURRENT_APP_VERSION = "1.46.0", SUPERDOC_DOCUMENT_ORIGIN_PROPERTY = "SuperdocDocumentOrigin", STORED_DOCUMENT_ORIGINS, collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state }) => {
136970
137075
  if (!runProps?.elements?.length || !state)
136971
137076
  return;
136972
137077
  const fontsNode = runProps.elements.find((el) => el.name === "w:rFonts");
@@ -137000,7 +137105,7 @@ Docs: https://docs.superdoc.dev/getting-started/fonts`);
137000
137105
  state.kern = kernNode.attributes["w:val"];
137001
137106
  }
137002
137107
  }, SuperConverter;
137003
- var init_SuperConverter_C3RaGqYm_es = __esm(() => {
137108
+ var init_SuperConverter_8mCA_0Qr_es = __esm(() => {
137004
137109
  init_rolldown_runtime_Bg48TavK_es();
137005
137110
  init_jszip_C49i9kUs_es();
137006
137111
  init_xml_js_CqGKpaft_es();
@@ -141397,6 +141502,7 @@ var init_SuperConverter_C3RaGqYm_es = __esm(() => {
141397
141502
  "link"
141398
141503
  ];
141399
141504
  TRACKABLE_RUN_CONTENT_TYPES = new Set(["text", "noBreakHyphen"]);
141505
+ TRACKABLE_WHOLE_NODE_TYPES = new Set(["crossReference"]);
141400
141506
  validXmlAttributes$12 = [
141401
141507
  createAttributeHandler("w:id", "id"),
141402
141508
  createAttributeHandler("w:date", "date"),
@@ -154100,7 +154206,11 @@ var init_SuperConverter_C3RaGqYm_es = __esm(() => {
154100
154206
  CONSTRUCTIVE_TRACK_CHANGE_ELEMENT_NAMES = new Set(["w:ins", "w:moveTo"]);
154101
154207
  SKIP_FIELD_PROCESSING_NODE_NAMES$1 = new Set(["w:drawing", "w:pict"]);
154102
154208
  FIELD_CONTROL_ELEMENT_NAMES = new Set(["w:fldChar"]);
154103
- INSTRUCTION_ELEMENT_NAMES = new Set(["w:instrText", "w:tab"]);
154209
+ INSTRUCTION_ELEMENT_NAMES = new Set([
154210
+ "w:instrText",
154211
+ "w:delInstrText",
154212
+ "w:tab"
154213
+ ]);
154104
154214
  SKIP_FIELD_PROCESSING_NODE_NAMES = new Set(["w:drawing", "w:pict"]);
154105
154215
  HEADER_FOOTER_FILENAME_PATTERN = /^(header|footer)\d*\.xml$/i;
154106
154216
  CHART_TYPE_MAP = {
@@ -157156,7 +157266,7 @@ var init_SuperConverter_C3RaGqYm_es = __esm(() => {
157156
157266
  createDocFromMarkdown: () => createDocFromMarkdown,
157157
157267
  createDocument: () => createDocument,
157158
157268
  defaultBlockAt: () => defaultBlockAt,
157159
- findChildren: () => findChildren$1,
157269
+ findChildren: () => findChildren$2,
157160
157270
  findMark: () => findMark,
157161
157271
  findParentNode: () => findParentNode,
157162
157272
  findParentNodeClosestToPos: () => findParentNodeClosestToPos,
@@ -166012,7 +166122,7 @@ var init_SuperConverter_C3RaGqYm_es = __esm(() => {
166012
166122
  };
166013
166123
  });
166014
166124
 
166015
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BHTMK7GC.es.js
166125
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-ZRFg_kat.es.js
166016
166126
  function parseSizeUnit(val = "0") {
166017
166127
  const length3 = val.toString() || "0";
166018
166128
  const value = Number.parseFloat(length3);
@@ -176833,9 +176943,9 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, MARK_KEYS, STEP_OP_CATALOG_UNFROZEN2, P
176833
176943
  }
176834
176944
  };
176835
176945
  };
176836
- var init_create_headless_toolbar_BHTMK7GC_es = __esm(() => {
176946
+ var init_create_headless_toolbar_ZRFg_kat_es = __esm(() => {
176837
176947
  init_rolldown_runtime_Bg48TavK_es();
176838
- init_SuperConverter_C3RaGqYm_es();
176948
+ init_SuperConverter_8mCA_0Qr_es();
176839
176949
  init_jszip_C49i9kUs_es();
176840
176950
  init_uuid_B2wVPhPi_es();
176841
176951
  init_constants_D9qj59G2_es();
@@ -226928,7 +227038,7 @@ var init_remark_gfm_DCND_V_3_es = __esm(() => {
226928
227038
  init_remark_gfm_BUJjZJLy_es();
226929
227039
  });
226930
227040
 
226931
- // ../../packages/superdoc/dist/chunks/src-DESpQKJd.es.js
227041
+ // ../../packages/superdoc/dist/chunks/src-D8bG2biJ.es.js
226932
227042
  function deleteProps(obj, propOrProps) {
226933
227043
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
226934
227044
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -227072,7 +227182,7 @@ function prosemirrorToYXmlFragment(doc$12, xmlFragment) {
227072
227182
  }
227073
227183
  function getSuperdocVersion() {
227074
227184
  try {
227075
- return "1.45.1";
227185
+ return "1.46.0";
227076
227186
  } catch {
227077
227187
  return "unknown";
227078
227188
  }
@@ -229084,7 +229194,29 @@ function collectSDTNodes(doc$12) {
229084
229194
  });
229085
229195
  return sdtNodes;
229086
229196
  }
229087
- function checkLockViolation(sdtNodes, from$1, to) {
229197
+ function collectPreservedSDTNodes(previousSdtNodes, nextDoc) {
229198
+ const nextNodesById = /* @__PURE__ */ new Map;
229199
+ for (const nextSdt of collectSDTNodes(nextDoc)) {
229200
+ const id2 = nextSdt.node.attrs.id;
229201
+ if (id2 == null)
229202
+ continue;
229203
+ const key2 = String(id2);
229204
+ const matches2 = nextNodesById.get(key2) ?? [];
229205
+ matches2.push(nextSdt.node);
229206
+ nextNodesById.set(key2, matches2);
229207
+ }
229208
+ const preserved = /* @__PURE__ */ new Set;
229209
+ for (const previousSdt of previousSdtNodes) {
229210
+ const id2 = previousSdt.node.attrs.id;
229211
+ if (id2 == null)
229212
+ continue;
229213
+ const matches2 = nextNodesById.get(String(id2));
229214
+ if (matches2?.length === 1 && matches2[0].eq(previousSdt.node))
229215
+ preserved.add(previousSdt);
229216
+ }
229217
+ return preserved;
229218
+ }
229219
+ function checkLockViolation(sdtNodes, from$1, to, preservedSdtNodes) {
229088
229220
  for (const sdt of sdtNodes) {
229089
229221
  if (!(from$1 < sdt.end && to > sdt.pos))
229090
229222
  continue;
@@ -229096,7 +229228,7 @@ function checkLockViolation(sdtNodes, from$1, to) {
229096
229228
  const wouldModifyContent = insideSDT && !containsSDT;
229097
229229
  const isSdtLocked = sdt.lockMode === "sdtLocked" || sdt.lockMode === "sdtContentLocked";
229098
229230
  const isContentLocked = sdt.lockMode === "contentLocked" || sdt.lockMode === "sdtContentLocked";
229099
- if (isSdtLocked && wouldDamageWrapper)
229231
+ if (isSdtLocked && wouldDamageWrapper && !preservedSdtNodes?.has(sdt))
229100
229232
  return {
229101
229233
  blocked: true,
229102
229234
  reason: `Cannot delete SDT wrapper (${sdt.lockMode})`
@@ -229261,10 +229393,11 @@ function createStructuredContentLockPlugin() {
229261
229393
  const sdtNodes = STRUCTURED_CONTENT_LOCK_KEY.getState(state);
229262
229394
  if (sdtNodes.length === 0)
229263
229395
  return true;
229396
+ const preservedSdtNodes = tr.getMeta?.("structuredContentWrapperPreserving") ? collectPreservedSDTNodes(sdtNodes, tr.doc) : undefined;
229264
229397
  for (const step3 of tr.steps) {
229265
229398
  if (step3.from === undefined || step3.to === undefined)
229266
229399
  continue;
229267
- if (checkLockViolation(sdtNodes, step3.from, step3.to).blocked)
229400
+ if (checkLockViolation(sdtNodes, step3.from, step3.to, preservedSdtNodes).blocked)
229268
229401
  return false;
229269
229402
  }
229270
229403
  return true;
@@ -229468,7 +229601,7 @@ function createStructuredContentSelectPlugin(editor) {
229468
229601
  });
229469
229602
  }
229470
229603
  function getStructuredContentTagsById(idOrIds, state) {
229471
- return findChildren$1(state.doc, (node3) => {
229604
+ return findChildren$2(state.doc, (node3) => {
229472
229605
  const isStructuredContent = ["structuredContent", "structuredContentBlock"].includes(node3.type.name);
229473
229606
  if (Array.isArray(idOrIds))
229474
229607
  return isStructuredContent && idOrIds.includes(node3.attrs.id);
@@ -229501,7 +229634,7 @@ function getGroup(tag) {
229501
229634
  }
229502
229635
  function getStructuredContentByGroup(groupOrGroups, state) {
229503
229636
  const searchGroups = Array.isArray(groupOrGroups) ? groupOrGroups : [groupOrGroups];
229504
- return findChildren$1(state.doc, (node3) => {
229637
+ return findChildren$2(state.doc, (node3) => {
229505
229638
  if (!["structuredContent", "structuredContentBlock"].includes(node3.type.name))
229506
229639
  return false;
229507
229640
  const nodeGroup = getGroup(node3.attrs.tag);
@@ -229511,15 +229644,15 @@ function getStructuredContentByGroup(groupOrGroups, state) {
229511
229644
  });
229512
229645
  }
229513
229646
  function getStructuredContentTags(state) {
229514
- return findChildren$1(state.doc, (node3) => {
229647
+ return findChildren$2(state.doc, (node3) => {
229515
229648
  return node3.type.name === "structuredContent" || node3.type.name === "structuredContentBlock";
229516
229649
  });
229517
229650
  }
229518
229651
  function getStructuredContentInlineTags(state) {
229519
- return findChildren$1(state.doc, (node3) => node3.type.name === "structuredContent");
229652
+ return findChildren$2(state.doc, (node3) => node3.type.name === "structuredContent");
229520
229653
  }
229521
229654
  function getStructuredContentBlockTags(state) {
229522
- return findChildren$1(state.doc, (node3) => node3.type.name === "structuredContentBlock");
229655
+ return findChildren$2(state.doc, (node3) => node3.type.name === "structuredContentBlock");
229523
229656
  }
229524
229657
  function getStructuredContentTablesById(id2, state) {
229525
229658
  if (!id2 || !state)
@@ -233183,7 +233316,7 @@ function findRemovedFieldAnnotations(tr) {
233183
233316
  });
233184
233317
  if (removedNodes.length) {
233185
233318
  const removedNodesIds = removedNodes.map((item) => item.node.attrs.fieldId);
233186
- const found2 = findChildren$1(tr.doc, (node3) => node3.type.name === "fieldAnnotation" && removedNodesIds.includes(node3.attrs.fieldId));
233319
+ const found2 = findChildren$2(tr.doc, (node3) => node3.type.name === "fieldAnnotation" && removedNodesIds.includes(node3.attrs.fieldId));
233187
233320
  const foundSet = new Set(found2.map((item) => item.node.attrs.fieldId));
233188
233321
  removedNodes = removedNodes.filter((item) => !foundSet.has(item.node.attrs.fieldId));
233189
233322
  }
@@ -233210,7 +233343,7 @@ function trackFieldAnnotationsDeletion(editor, tr) {
233210
233343
  }, 0);
233211
233344
  }
233212
233345
  function getAllFieldAnnotations(state) {
233213
- return findChildren$1(state.doc, (node3) => node3.type.name === "fieldAnnotation");
233346
+ return findChildren$2(state.doc, (node3) => node3.type.name === "fieldAnnotation");
233214
233347
  }
233215
233348
  function handleDropOutside({ fieldAnnotation, editor, view, event }) {
233216
233349
  let sourceField;
@@ -233232,7 +233365,7 @@ function handleDropOutside({ fieldAnnotation, editor, view, event }) {
233232
233365
  });
233233
233366
  }
233234
233367
  function findFieldAnnotationsByFieldId(fieldIdOrArray, state) {
233235
- return findChildren$1(state.doc, (node3) => {
233368
+ return findChildren$2(state.doc, (node3) => {
233236
233369
  let isFieldAnnotation = node3.type.name === "fieldAnnotation";
233237
233370
  if (Array.isArray(fieldIdOrArray))
233238
233371
  return isFieldAnnotation && fieldIdOrArray.includes(node3.attrs.fieldId);
@@ -249471,11 +249604,17 @@ function blocksDeleteWrapper(editor, input2, options) {
249471
249604
  };
249472
249605
  checkRevision(editor, options?.expectedRevision);
249473
249606
  const tr = editor.state.tr;
249474
- tr.delete(candidate.pos, candidate.end);
249475
- if (mode === "tracked")
249476
- applyTrackedMutationMeta(tr);
249477
- else
249607
+ if (mode === "tracked" && isParagraphShaped(candidate)) {
249608
+ if (!authorTrackedBlockDeletion(editor, tr, candidate))
249609
+ throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", "blocks.delete could not record a tracked deletion for this block.", { reason: "tracked_authoring_failed" });
249478
249610
  applyDirectMutationMeta(tr);
249611
+ } else {
249612
+ tr.delete(candidate.pos, candidate.end);
249613
+ if (mode === "tracked")
249614
+ applyTrackedMutationMeta(tr);
249615
+ else
249616
+ applyDirectMutationMeta(tr);
249617
+ }
249479
249618
  editor.dispatch(tr);
249480
249619
  clearIndexCache(editor);
249481
249620
  return {
@@ -249484,6 +249623,45 @@ function blocksDeleteWrapper(editor, input2, options) {
249484
249623
  deletedBlock
249485
249624
  };
249486
249625
  }
249626
+ function isParagraphShaped(candidate) {
249627
+ return candidate.node?.type?.name === "paragraph" || candidate.node?.type?.name === "heading";
249628
+ }
249629
+ function authorTrackedBlockDeletion(editor, tr, candidate) {
249630
+ const user = editor.options.user;
249631
+ if (!user)
249632
+ return false;
249633
+ const node3 = candidate.node;
249634
+ if (!node3 || !node3.isTextblock)
249635
+ return false;
249636
+ const id2 = v4_default();
249637
+ const date = (/* @__PURE__ */ new Date()).toISOString();
249638
+ const from$1 = candidate.pos + 1;
249639
+ const to = candidate.pos + node3.nodeSize - 1;
249640
+ if (to > from$1)
249641
+ markDeletion({
249642
+ tr,
249643
+ from: from$1,
249644
+ to,
249645
+ user,
249646
+ date,
249647
+ id: id2
249648
+ });
249649
+ const markedPos = tr.mapping.map(candidate.pos, 1);
249650
+ const markedNode = tr.doc.nodeAt(markedPos);
249651
+ if (!markedNode || !markedNode.isTextblock)
249652
+ return false;
249653
+ tr.setNodeMarkup(markedPos, undefined, {
249654
+ ...markedNode.attrs,
249655
+ markTrackChange: {
249656
+ type: "paragraphMarkDelete",
249657
+ id: id2,
249658
+ author: user.name || "",
249659
+ authorEmail: user.email || "",
249660
+ date
249661
+ }
249662
+ });
249663
+ return true;
249664
+ }
249487
249665
  function hasSectionBreak(candidate) {
249488
249666
  const pPr = candidate.node.attrs?.paragraphProperties;
249489
249667
  return pPr?.sectPr != null && typeof pPr.sectPr === "object";
@@ -259459,6 +259637,13 @@ function executeSdtMutation(editor, target, options, handler2) {
259459
259637
  return buildMutationFailure("NO_OP", "The mutation had no effect.");
259460
259638
  return buildMutationSuccess(target, updatedRef);
259461
259639
  }
259640
+ function executeSdtWrappingMutation(editor, target, options, handler2) {
259641
+ const documentBefore = editor.state.doc;
259642
+ const result = executeSdtMutation(editor, target, options, handler2);
259643
+ if (!options?.dryRun && result.success && editor.state.doc === documentBefore)
259644
+ return buildMutationFailure("NO_OP", "The mutation reported success without changing the document.");
259645
+ return result;
259646
+ }
259462
259647
  function dispatchTransaction$1(editor, tr) {
259463
259648
  if (editor.view?.dispatch) {
259464
259649
  editor.view.dispatch(tr);
@@ -259615,7 +259800,7 @@ function wrapWrapper(editor, input2, options) {
259615
259800
  nodeType: "sdt",
259616
259801
  nodeId: id2
259617
259802
  };
259618
- return executeSdtMutation(editor, input2.target, options, () => {
259803
+ return executeSdtWrappingMutation(editor, input2.target, options, () => {
259619
259804
  const resolved = resolveSdtByTarget(editor.state.doc, input2.target);
259620
259805
  const nodeTypeName = input2.kind === "block" ? SDT_BLOCK_NAME : "structuredContent";
259621
259806
  const nodeType = editor.schema.nodes[nodeTypeName];
@@ -259632,6 +259817,7 @@ function wrapWrapper(editor, input2, options) {
259632
259817
  }, resolved.node);
259633
259818
  const { tr } = editor.state;
259634
259819
  tr.replaceWith(resolved.pos, resolved.pos + resolved.node.nodeSize, wrapperNode);
259820
+ tr.setMeta(STRUCTURED_CONTENT_WRAPPER_PRESERVING_META, true);
259635
259821
  dispatchTransaction$1(editor, tr);
259636
259822
  return wrapperTarget;
259637
259823
  });
@@ -260514,7 +260700,7 @@ function repeatingSectionSetAllowInsertDeleteWrapper(editor, input2, options) {
260514
260700
  function groupWrapWrapper(editor, input2, options) {
260515
260701
  resolveSdtByTarget(editor.state.doc, input2.target);
260516
260702
  const target = input2.target;
260517
- return executeSdtMutation(editor, target, options, () => {
260703
+ return executeSdtWrappingMutation(editor, target, options, () => {
260518
260704
  const resolved = resolveSdtByTarget(editor.state.doc, input2.target);
260519
260705
  const groupNodeType = editor.schema.nodes[SDT_BLOCK_NAME];
260520
260706
  if (!groupNodeType)
@@ -260527,6 +260713,7 @@ function groupWrapWrapper(editor, input2, options) {
260527
260713
  }, resolved.node);
260528
260714
  const { tr } = editor.state;
260529
260715
  tr.replaceWith(resolved.pos, resolved.pos + resolved.node.nodeSize, groupNode);
260716
+ tr.setMeta(STRUCTURED_CONTENT_WRAPPER_PRESERVING_META, true);
260530
260717
  dispatchTransaction$1(editor, tr);
260531
260718
  return {
260532
260719
  kind: "block",
@@ -291421,7 +291608,7 @@ var Node$13 = class Node$14 {
291421
291608
  return !!(node3?.isBlock && node3?.type?.spec?.attrs?.[SD_BLOCK_REV_ATTRIBUTE_NAME]);
291422
291609
  }, nodeNeedsSdBlockId = (node3) => {
291423
291610
  return !node3?.attrs?.[SD_BLOCK_ID_ATTRIBUTE_NAME];
291424
- }, STRUCTURED_CONTENT_LOCK_KEY, SELECT_INLINE_SDT_BEFORE_RUN_START_META = "selectInlineSdtBeforeRunStart", selectInlineSdtBeforeRunStart = () => ({ state, dispatch }) => {
291611
+ }, STRUCTURED_CONTENT_LOCK_KEY, STRUCTURED_CONTENT_WRAPPER_PRESERVING_META = "structuredContentWrapperPreserving", SELECT_INLINE_SDT_BEFORE_RUN_START_META = "selectInlineSdtBeforeRunStart", selectInlineSdtBeforeRunStart = () => ({ state, dispatch }) => {
291425
291612
  const { selection } = state;
291426
291613
  if (!selection.empty)
291427
291614
  return false;
@@ -297747,16 +297934,43 @@ var Node$13 = class Node$14 {
297747
297934
  if (deterministicJson(a2.sourceIds) !== deterministicJson(b$1.sourceIds))
297748
297935
  return false;
297749
297936
  return true;
297750
- }, BODY_STORY, buildReviewGraph = ({ state, story = BODY_STORY, replacementsMode = "paired" }) => {
297937
+ }, BODY_STORY, enumerateParagraphMarkDeletions = (state) => {
297938
+ const doc$12 = state?.doc;
297939
+ if (!doc$12)
297940
+ return [];
297941
+ const out = [];
297942
+ try {
297943
+ doc$12.descendants((node3, pos) => {
297944
+ if (node3.isText)
297945
+ return false;
297946
+ const record = node3?.attrs?.markTrackChange;
297947
+ if (record && record.type === "paragraphMarkDelete" && typeof record.id === "string" && record.id)
297948
+ out.push({
297949
+ id: record.id,
297950
+ from: pos,
297951
+ to: pos + node3.nodeSize,
297952
+ author: record.author || "",
297953
+ authorEmail: record.authorEmail || "",
297954
+ authorImage: record.authorImage || "",
297955
+ date: record.date || "",
297956
+ subtype: "paragraph-mark-deletion"
297957
+ });
297958
+ });
297959
+ } catch {
297960
+ return out;
297961
+ }
297962
+ return out;
297963
+ }, buildReviewGraph = ({ state, story = BODY_STORY, replacementsMode = "paired" }) => {
297751
297964
  return buildGraphFromSpans({
297752
297965
  spans: enumerateTrackedMarkSpans(state),
297753
297966
  structuralChanges: enumerateStructuralRowChanges(state),
297754
297967
  pprChanges: enumeratePprChanges(state),
297968
+ paragraphMarkChanges: enumerateParagraphMarkDeletions(state),
297755
297969
  doc: state?.doc ?? null,
297756
297970
  story,
297757
297971
  replacementsMode
297758
297972
  });
297759
- }, buildGraphFromSpans = ({ spans, structuralChanges = [], pprChanges = [], doc: doc$12, story, replacementsMode }) => {
297973
+ }, buildGraphFromSpans = ({ spans, structuralChanges = [], pprChanges = [], paragraphMarkChanges = [], doc: doc$12, story, replacementsMode }) => {
297760
297974
  const mergedSegments = mergeAdjacentSpans(spans.map((span) => ({
297761
297975
  attrs: readTrackedAttrs(span.mark, span.mark.type.name),
297762
297976
  span
@@ -297850,6 +298064,24 @@ var Node$13 = class Node$14 {
297850
298064
  changes.set(logical.id, logical);
297851
298065
  appendToMap(byRevisionGroupId, logical.revisionGroupId, logical.id);
297852
298066
  }
298067
+ for (const mark2 of paragraphMarkChanges) {
298068
+ if (changes.has(mark2.id))
298069
+ continue;
298070
+ const logical = buildParagraphMarkLogicalChange({
298071
+ mark: mark2,
298072
+ doc: doc$12,
298073
+ story
298074
+ });
298075
+ if (!logical)
298076
+ continue;
298077
+ const internalKey = `paragraphmark:${mark2.from}`;
298078
+ if (changes.has(internalKey))
298079
+ continue;
298080
+ changes.set(internalKey, logical);
298081
+ if (logical.id && logical.id !== internalKey && !changes.has(logical.id))
298082
+ changes.set(logical.id, logical);
298083
+ appendToMap(byRevisionGroupId, logical.revisionGroupId, logical.id);
298084
+ }
297853
298085
  const segments = mergedSegments.slice().sort((a2, b$1) => a2.from - b$1.from || a2.to - b$1.to);
297854
298086
  const graph = {
297855
298087
  changes,
@@ -298188,6 +298420,83 @@ var Node$13 = class Node$14 {
298188
298420
  enumerable: false
298189
298421
  });
298190
298422
  return logical;
298423
+ }, buildParagraphMarkLogicalChange = ({ mark: mark2, doc: doc$12, story }) => {
298424
+ const from$1 = mark2.from;
298425
+ const to = mark2.to;
298426
+ if (!(from$1 < to))
298427
+ return null;
298428
+ const side = SegmentSide.Deleted;
298429
+ const attrs = {
298430
+ id: mark2.id,
298431
+ revisionGroupId: mark2.id,
298432
+ splitFromId: "",
298433
+ changeType: CanonicalChangeType.Deletion,
298434
+ replacementGroupId: "",
298435
+ replacementSideId: "",
298436
+ overlapParentId: "",
298437
+ sourceIds: {},
298438
+ sourceId: "",
298439
+ importedAuthor: "",
298440
+ origin: "",
298441
+ author: mark2.author,
298442
+ authorId: "",
298443
+ authorEmail: mark2.authorEmail,
298444
+ authorImage: mark2.authorImage,
298445
+ date: mark2.date,
298446
+ markType: "",
298447
+ side,
298448
+ subtype: mark2.subtype,
298449
+ explicitChangeType: CanonicalChangeType.Deletion,
298450
+ hasReviewMetadata: true
298451
+ };
298452
+ const segments = [{
298453
+ segmentId: `${mark2.id}:paragraphmark:${from$1}:${to}:0`,
298454
+ changeId: mark2.id,
298455
+ markType: "",
298456
+ side,
298457
+ from: from$1,
298458
+ to,
298459
+ text: "",
298460
+ mark: null,
298461
+ markRuns: [],
298462
+ attrs,
298463
+ parentId: "",
298464
+ parentSide: "",
298465
+ overlapRole: "standalone",
298466
+ paragraphMarkChange: true
298467
+ }];
298468
+ const logical = {
298469
+ id: mark2.id,
298470
+ type: CanonicalChangeType.Deletion,
298471
+ subtype: mark2.subtype,
298472
+ state: "open",
298473
+ segments,
298474
+ coverageSegments: [...segments],
298475
+ insertedSegments: [],
298476
+ deletedSegments: [...segments],
298477
+ formattingSegments: [],
298478
+ replacement: null,
298479
+ author: mark2.author,
298480
+ authorId: "",
298481
+ authorEmail: mark2.authorEmail,
298482
+ authorImage: mark2.authorImage,
298483
+ date: mark2.date,
298484
+ sourceIds: {},
298485
+ revisionGroupId: mark2.id,
298486
+ splitFromId: "",
298487
+ sourcePlatform: "",
298488
+ story,
298489
+ parent: null,
298490
+ children: [],
298491
+ before: [],
298492
+ after: [],
298493
+ excerpt: ""
298494
+ };
298495
+ Object.defineProperty(logical, "paragraphMarkChange", {
298496
+ value: mark2,
298497
+ enumerable: false
298498
+ });
298499
+ return logical;
298191
298500
  }, aggregateSourceIds = (segments) => {
298192
298501
  const out = {};
298193
298502
  const sorted = [...segments].sort((a2, b$1) => {
@@ -301339,7 +301648,7 @@ var Node$13 = class Node$14 {
301339
301648
  };
301340
301649
  }
301341
301650
  touched.add(change.id);
301342
- if (isFull && !change.pprChange)
301651
+ if (isFull && !change.pprChange && !change.paragraphMarkChange)
301343
301652
  for (const segment of change.segments)
301344
301653
  resolvedRanges.push({
301345
301654
  from: segment.from,
@@ -301358,6 +301667,18 @@ var Node$13 = class Node$14 {
301358
301667
  ok: false,
301359
301668
  failure: pprResult.failure
301360
301669
  };
301670
+ } else if (change.paragraphMarkChange) {
301671
+ const markResult = planParagraphMarkDecision({
301672
+ ops,
301673
+ change,
301674
+ decision,
301675
+ retired
301676
+ });
301677
+ if (!markResult.ok)
301678
+ return {
301679
+ ok: false,
301680
+ failure: markResult.failure
301681
+ };
301361
301682
  } else if (change.type === CanonicalChangeType.Structural) {
301362
301683
  const structuralResult = planStructuralDecision({
301363
301684
  ops,
@@ -301585,8 +301906,15 @@ var Node$13 = class Node$14 {
301585
301906
  cause: `accept-deletion:${change.id}`
301586
301907
  });
301587
301908
  }
301588
- if (isFull)
301909
+ if (isFull) {
301910
+ pushParagraphMarkOps({
301911
+ ops,
301912
+ change,
301913
+ decision: "accept",
301914
+ ranges: ranges$1
301915
+ });
301589
301916
  retired.add(change.id);
301917
+ }
301590
301918
  return;
301591
301919
  }
301592
301920
  const ranges = isFull ? change.deletedSegments.map((s2) => ({
@@ -301601,8 +301929,26 @@ var Node$13 = class Node$14 {
301601
301929
  changeId: change.id,
301602
301930
  side: SegmentSide.Deleted
301603
301931
  });
301604
- if (isFull)
301932
+ if (isFull) {
301933
+ pushParagraphMarkOps({
301934
+ ops,
301935
+ change,
301936
+ decision: "reject",
301937
+ ranges
301938
+ });
301605
301939
  retired.add(change.id);
301940
+ }
301941
+ }, pushParagraphMarkOps = ({ ops, change, decision, ranges }) => {
301942
+ const anchor = ranges[0];
301943
+ if (!anchor)
301944
+ return;
301945
+ ops.push({
301946
+ kind: decision === "accept" ? "collapseParagraphMark" : "clearParagraphMark",
301947
+ from: anchor.from,
301948
+ to: anchor.to,
301949
+ changeId: change.id,
301950
+ side: SegmentSide.Deleted
301951
+ });
301606
301952
  }, planStructuralDecision = ({ ops, change, decision, removedRanges, retired }) => {
301607
301953
  const structural = change.structural;
301608
301954
  if (!structural)
@@ -301659,6 +302005,22 @@ var Node$13 = class Node$14 {
301659
302005
  });
301660
302006
  retired.add(change.id);
301661
302007
  return { ok: true };
302008
+ }, planParagraphMarkDecision = ({ ops, change, decision, retired }) => {
302009
+ const mark2 = change.paragraphMarkChange;
302010
+ if (!mark2)
302011
+ return {
302012
+ ok: false,
302013
+ failure: failure$3("CAPABILITY_UNAVAILABLE", `change "${change.id}" is not a paragraph-mark deletion.`)
302014
+ };
302015
+ ops.push({
302016
+ kind: decision === "accept" ? "collapseParagraphMark" : "clearParagraphMark",
302017
+ from: mark2.from,
302018
+ to: mark2.to,
302019
+ changeId: change.id,
302020
+ side: SegmentSide.Deleted
302021
+ });
302022
+ retired.add(change.id);
302023
+ return { ok: true };
301662
302024
  }, planReplacementDecision = ({ ops, graph, change, decision, removedRanges, retired }) => {
301663
302025
  const inserted = change.insertedSegments;
301664
302026
  const deleted = change.deletedSegments;
@@ -302100,6 +302462,25 @@ var Node$13 = class Node$14 {
302100
302462
  };
302101
302463
  }
302102
302464
  return null;
302465
+ }, findParagraphMarkChangeAt = (tr, pos, changeId) => {
302466
+ const carries = (node3) => node3?.attrs?.markTrackChange?.id === changeId;
302467
+ const clamped = Math.max(0, Math.min(pos, tr.doc.content.size));
302468
+ const block = findTextblockAt(tr.doc, clamped);
302469
+ if (block && carries(block.node))
302470
+ return block;
302471
+ let found2 = null;
302472
+ tr.doc.descendants((node3, nodePos) => {
302473
+ if (found2)
302474
+ return false;
302475
+ if (node3.isTextblock && carries(node3)) {
302476
+ found2 = {
302477
+ pos: nodePos,
302478
+ node: node3
302479
+ };
302480
+ return false;
302481
+ }
302482
+ });
302483
+ return found2;
302103
302484
  }, rejectParagraphSplitAt = (tr, from$1, anchor = "inserted") => {
302104
302485
  const block = findTextblockAt(tr.doc, from$1);
302105
302486
  if (!block)
@@ -302116,6 +302497,7 @@ var Node$13 = class Node$14 {
302116
302497
  const markOps = sortedOps.filter((op) => op.kind !== "removeContent");
302117
302498
  const contentOps = sortedOps.filter((op) => op.kind === "removeContent").reverse();
302118
302499
  const splitJoinOps = sortedOps.filter((op) => op.kind === "rejectParagraphSplit").reverse();
302500
+ const paragraphMarkOps = sortedOps.filter((op) => op.kind === "collapseParagraphMark").reverse();
302119
302501
  try {
302120
302502
  for (const op of markOps) {
302121
302503
  if (op.kind === "removeMark" && op.mark) {
@@ -302160,6 +302542,15 @@ var Node$13 = class Node$14 {
302160
302542
  });
302161
302543
  continue;
302162
302544
  }
302545
+ if (op.kind === "clearParagraphMark") {
302546
+ const target = findParagraphMarkChangeAt(tr, tr.mapping.map(op.from, 1), op.changeId);
302547
+ if (target)
302548
+ tr.setNodeMarkup(target.pos, undefined, {
302549
+ ...target.node.attrs,
302550
+ markTrackChange: null
302551
+ });
302552
+ continue;
302553
+ }
302163
302554
  if (op.kind === "resolvePprChange") {
302164
302555
  const mappedFrom = tr.mapping.map(op.from, 1);
302165
302556
  const node3 = tr.doc.nodeAt(mappedFrom);
@@ -302191,6 +302582,19 @@ var Node$13 = class Node$14 {
302191
302582
  for (const op of splitJoinOps)
302192
302583
  if (!rejectParagraphSplitAt(tr, tr.mapping.map(op.from, 1), op.anchor))
302193
302584
  throw new Error(`could not join paragraph split for tracked change "${op.changeId ?? ""}".`);
302585
+ for (const op of paragraphMarkOps) {
302586
+ const target = findParagraphMarkChangeAt(tr, tr.mapping.map(op.from, 1), op.changeId);
302587
+ if (!target)
302588
+ continue;
302589
+ tr.setNodeMarkup(target.pos, undefined, {
302590
+ ...target.node.attrs,
302591
+ markTrackChange: null
302592
+ });
302593
+ const joinPos = target.pos + tr.doc.nodeAt(target.pos).nodeSize;
302594
+ if (joinPos <= 0 || joinPos >= tr.doc.content.size || !canJoin(tr.doc, joinPos))
302595
+ continue;
302596
+ tr.join(joinPos);
302597
+ }
302194
302598
  } catch (error3) {
302195
302599
  return {
302196
302600
  ok: false,
@@ -306421,7 +306825,7 @@ var Node$13 = class Node$14 {
306421
306825
  domAvailabilityCache = false;
306422
306826
  return false;
306423
306827
  }
306424
- }, summaryVersion = "1.45.1", nodeKeys, markKeys, transformListsInCopiedContent = (html3) => {
306828
+ }, summaryVersion = "1.46.0", nodeKeys, markKeys, transformListsInCopiedContent = (html3) => {
306425
306829
  const container = document.createElement("div");
306426
306830
  container.innerHTML = html3;
306427
306831
  const result = [];
@@ -307607,7 +308011,7 @@ var Node$13 = class Node$14 {
307607
308011
  return () => {};
307608
308012
  const handle3 = setInterval(callback, intervalMs);
307609
308013
  return () => clearInterval(handle3);
307610
- }, HISTORY_UNSAFE_OPS, CANONICAL_COMMENT_IGNORED_KEYS, INITIAL_HASH, ROUND_CONSTANTS, V1_COVERAGE, V2_COVERAGE, SNAPSHOT_VERSION_V2 = "sd-diff-snapshot/v2", PAYLOAD_VERSION_V1 = "sd-diff-payload/v1", PAYLOAD_VERSION_V2 = "sd-diff-payload/v2", ENGINE_ID = "super-editor", STAGED_CONVERTER_KEYS, DiffServiceError, TC_LEVEL_MIN = 1, TC_LEVEL_MAX = 9, ALLOWED_WRAP_ATTRS, WRAP_TYPES_SUPPORTING_SIDE, WRAP_TYPES_SUPPORTING_DISTANCES, RELATIVE_HEIGHT_MIN = 0, RELATIVE_HEIGHT_MAX = 4294967295, FORBIDDEN_RAW_PATCH_NAMES, CONTROL_TYPE_SDT_PR_ELEMENTS, DEFAULT_CHECKBOX_SYMBOL_FONT2 = "MS Gothic", DEFAULT_CHECKBOX_CHECKED_HEX2 = "2612", DEFAULT_CHECKBOX_UNCHECKED_HEX2 = "2610", VARIANT_ORDER, KIND_ORDER, HEADER_RELATIONSHIP_TYPE3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_RELATIONSHIP_TYPE3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", DOCUMENT_RELS_PATH2 = "word/_rels/document.xml.rels", HEADER_FILE_PATTERN2, FOOTER_FILE_PATTERN2, BOOKMARK_SCAN_REVISION_PREFIX = "bookmark-scan:", SETTINGS_PART, VALID_DISPLAYS, REFERENCE_BLOCK_PREFIX, CAPTION_STYLE_NAMES, CAPTION_PARAGRAPH_STYLE_ID = "Caption", CAPTION_FORMAT_TO_OOXML, DOCUMENT_STAT_FIELD_TYPES, TOA_LEADER_REVERSE_MAP, EDGE_NODE_TYPES, CONTENT_TYPES_PART_ID = "[Content_Types].xml", CONTENT_TYPES_NS = "http://schemas.openxmlformats.org/package/2006/content-types", contentTypesPartDescriptor, empty_exports, init_empty, CURRENT_APP_VERSION2 = "1.45.1", PIXELS_PER_INCH2 = 96, MAX_HEIGHT_BUFFER_PX = 50, MAX_WIDTH_BUFFER_PX = 20, TRACKED_REVIEW_MARK_NAMES2, isTrackedReviewMark = (mark2) => Boolean(mark2?.type?.name && TRACKED_REVIEW_MARK_NAMES2.has(mark2.type.name)), trackedReviewMarkKey = (mark2) => {
308014
+ }, HISTORY_UNSAFE_OPS, CANONICAL_COMMENT_IGNORED_KEYS, INITIAL_HASH, ROUND_CONSTANTS, V1_COVERAGE, V2_COVERAGE, SNAPSHOT_VERSION_V2 = "sd-diff-snapshot/v2", PAYLOAD_VERSION_V1 = "sd-diff-payload/v1", PAYLOAD_VERSION_V2 = "sd-diff-payload/v2", ENGINE_ID = "super-editor", STAGED_CONVERTER_KEYS, DiffServiceError, TC_LEVEL_MIN = 1, TC_LEVEL_MAX = 9, ALLOWED_WRAP_ATTRS, WRAP_TYPES_SUPPORTING_SIDE, WRAP_TYPES_SUPPORTING_DISTANCES, RELATIVE_HEIGHT_MIN = 0, RELATIVE_HEIGHT_MAX = 4294967295, FORBIDDEN_RAW_PATCH_NAMES, CONTROL_TYPE_SDT_PR_ELEMENTS, DEFAULT_CHECKBOX_SYMBOL_FONT2 = "MS Gothic", DEFAULT_CHECKBOX_CHECKED_HEX2 = "2612", DEFAULT_CHECKBOX_UNCHECKED_HEX2 = "2610", VARIANT_ORDER, KIND_ORDER, HEADER_RELATIONSHIP_TYPE3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_RELATIONSHIP_TYPE3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", DOCUMENT_RELS_PATH2 = "word/_rels/document.xml.rels", HEADER_FILE_PATTERN2, FOOTER_FILE_PATTERN2, BOOKMARK_SCAN_REVISION_PREFIX = "bookmark-scan:", SETTINGS_PART, VALID_DISPLAYS, REFERENCE_BLOCK_PREFIX, CAPTION_STYLE_NAMES, CAPTION_PARAGRAPH_STYLE_ID = "Caption", CAPTION_FORMAT_TO_OOXML, DOCUMENT_STAT_FIELD_TYPES, TOA_LEADER_REVERSE_MAP, EDGE_NODE_TYPES, CONTENT_TYPES_PART_ID = "[Content_Types].xml", CONTENT_TYPES_NS = "http://schemas.openxmlformats.org/package/2006/content-types", contentTypesPartDescriptor, empty_exports, init_empty, CURRENT_APP_VERSION2 = "1.46.0", PIXELS_PER_INCH2 = 96, MAX_HEIGHT_BUFFER_PX = 50, MAX_WIDTH_BUFFER_PX = 20, TRACKED_REVIEW_MARK_NAMES2, isTrackedReviewMark = (mark2) => Boolean(mark2?.type?.name && TRACKED_REVIEW_MARK_NAMES2.has(mark2.type.name)), trackedReviewMarkKey = (mark2) => {
307611
308015
  if (!isTrackedReviewMark(mark2))
307612
308016
  return null;
307613
308017
  const id2 = typeof mark2.attrs?.id === "string" ? mark2.attrs.id : "";
@@ -328494,13 +328898,13 @@ menclose::after {
328494
328898
  return;
328495
328899
  console.log(...args$1);
328496
328900
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions, TRACKED_MARK_NAMES;
328497
- var init_src_DESpQKJd_es = __esm(() => {
328901
+ var init_src_D8bG2biJ_es = __esm(() => {
328498
328902
  init_rolldown_runtime_Bg48TavK_es();
328499
- init_SuperConverter_C3RaGqYm_es();
328903
+ init_SuperConverter_8mCA_0Qr_es();
328500
328904
  init_jszip_C49i9kUs_es();
328501
328905
  init_xml_js_CqGKpaft_es();
328502
328906
  init_uuid_B2wVPhPi_es();
328503
- init_create_headless_toolbar_BHTMK7GC_es();
328907
+ init_create_headless_toolbar_ZRFg_kat_es();
328504
328908
  init_constants_D9qj59G2_es();
328505
328909
  init_unified_BDuVPlMu_es();
328506
328910
  init_remark_gfm_BUJjZJLy_es();
@@ -338186,6 +338590,11 @@ ${err.toString()}`);
338186
338590
  attributes: { rendered: false },
338187
338591
  filename: { rendered: false },
338188
338592
  paragraphProperties: { rendered: false },
338593
+ markTrackChange: {
338594
+ default: null,
338595
+ rendered: false,
338596
+ keepOnSplit: false
338597
+ },
338189
338598
  pageBreakSource: { rendered: false },
338190
338599
  tocSourceId: { rendered: false },
338191
338600
  sectionMargins: { rendered: false },
@@ -371820,11 +372229,11 @@ function print() { __p += __j.call(arguments, '') }
371820
372229
  ]);
371821
372230
  });
371822
372231
 
371823
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DEUyIO6F.es.js
372232
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-BNgSojVQ.es.js
371824
372233
  var DEFAULT_TEXT_ALIGN_OPTIONS, DEFAULT_LINE_HEIGHT_OPTIONS, DEFAULT_ZOOM_OPTIONS, DEFAULT_DOCUMENT_MODE_OPTIONS, DEFAULT_FONT_SIZE_OPTIONS, headlessToolbarConstants, MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS, FONT_SIZE_OPTIONS;
371825
- var init_create_super_doc_ui_DEUyIO6F_es = __esm(() => {
371826
- init_SuperConverter_C3RaGqYm_es();
371827
- init_create_headless_toolbar_BHTMK7GC_es();
372234
+ var init_create_super_doc_ui_BNgSojVQ_es = __esm(() => {
372235
+ init_SuperConverter_8mCA_0Qr_es();
372236
+ init_create_headless_toolbar_ZRFg_kat_es();
371828
372237
  DEFAULT_TEXT_ALIGN_OPTIONS = [
371829
372238
  {
371830
372239
  label: "Left",
@@ -372115,15 +372524,15 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
372115
372524
 
372116
372525
  // ../../packages/superdoc/dist/super-editor.es.js
372117
372526
  var init_super_editor_es = __esm(() => {
372118
- init_src_DESpQKJd_es();
372119
- init_SuperConverter_C3RaGqYm_es();
372527
+ init_src_D8bG2biJ_es();
372528
+ init_SuperConverter_8mCA_0Qr_es();
372120
372529
  init_jszip_C49i9kUs_es();
372121
372530
  init_xml_js_CqGKpaft_es();
372122
- init_create_headless_toolbar_BHTMK7GC_es();
372531
+ init_create_headless_toolbar_ZRFg_kat_es();
372123
372532
  init_constants_D9qj59G2_es();
372124
372533
  init_unified_BDuVPlMu_es();
372125
372534
  init_DocxZipper_BzS208BW_es();
372126
- init_create_super_doc_ui_DEUyIO6F_es();
372535
+ init_create_super_doc_ui_BNgSojVQ_es();
372127
372536
  init_ui_CGB3qmy3_es();
372128
372537
  init_eventemitter3_UwU_CLPU_es();
372129
372538
  init_errors_C_DoKMoN_es();
@@ -693454,6 +693863,112 @@ async function runDeleteText(doc3, args3) {
693454
693863
  return failedReceipt("delete_text", err, pre);
693455
693864
  }
693456
693865
  }
693866
+ async function runDeleteBlocks(doc3, args3) {
693867
+ const domains = new Set(["blocks", "trackedChanges"]);
693868
+ for (const selector of args3.selectors) {
693869
+ for (const domain2 of snapshotDomainsForSelector(selector))
693870
+ domains.add(domain2);
693871
+ }
693872
+ const pre = await buildDocumentSnapshot(doc3, { includeDomains: [...domains] });
693873
+ try {
693874
+ if (args3.selectors.length === 0) {
693875
+ return failedReceipt("delete_blocks", new Error("selectors must be non-empty"), pre);
693876
+ }
693877
+ const deleteFn = maybeMethod2(doc3, ["blocks", "delete"]);
693878
+ if (!deleteFn) {
693879
+ throw new SuperDocCliError("doc.blocks.delete is not available on the document handle.", {
693880
+ code: "TOOL_DISPATCH_NOT_FOUND"
693881
+ });
693882
+ }
693883
+ const targets = [];
693884
+ const unresolved = [];
693885
+ const wrongShape = [];
693886
+ const seen = new Set;
693887
+ for (const selector of args3.selectors) {
693888
+ const target2 = selectorToBlockTarget(selector, pre);
693889
+ if (!target2) {
693890
+ unresolved.push(selector);
693891
+ continue;
693892
+ }
693893
+ if (!DELETABLE_BLOCK_NODE_TYPES3.has(target2.nodeType)) {
693894
+ wrongShape.push({ selector, nodeType: target2.nodeType });
693895
+ continue;
693896
+ }
693897
+ if (seen.has(target2.nodeId))
693898
+ continue;
693899
+ seen.add(target2.nodeId);
693900
+ targets.push({ selector, nodeId: target2.nodeId, nodeType: target2.nodeType });
693901
+ }
693902
+ const errors2 = [];
693903
+ for (const selector of unresolved) {
693904
+ errors2.push({
693905
+ code: "ACTION_FAILED",
693906
+ message: `selector did not resolve to a unique body block: ${JSON.stringify(selector)}`,
693907
+ recovery: { kind: "reinspect" }
693908
+ });
693909
+ }
693910
+ for (const entry of wrongShape) {
693911
+ errors2.push({
693912
+ code: "INVALID_ARGUMENT",
693913
+ message: `delete_blocks removes paragraph-shaped blocks (list items, paragraphs, headings); ` + `${JSON.stringify(entry.selector)} resolved to a "${entry.nodeType}"` + (entry.nodeType === "table" ? " — use delete_table for a whole table." : "."),
693914
+ recovery: { kind: "reinspect" }
693915
+ });
693916
+ }
693917
+ if (targets.length === 0) {
693918
+ return {
693919
+ status: "failed",
693920
+ intent: "delete_blocks",
693921
+ preSnapshot: { revision: pre.revision, counts: pre.counts },
693922
+ selectedTargets: [],
693923
+ executedOperations: [],
693924
+ verification: [],
693925
+ errors: errors2
693926
+ };
693927
+ }
693928
+ const changeMode = parseChangeMode4(args3.changeMode);
693929
+ const executedOperations = [];
693930
+ const deleted = [];
693931
+ for (const target2 of targets) {
693932
+ try {
693933
+ const result2 = await deleteFn({
693934
+ target: { kind: "block", nodeType: target2.nodeType, nodeId: target2.nodeId },
693935
+ ...changeMode ? { changeMode } : {}
693936
+ });
693937
+ executedOperations.push({ operationId: "doc.blocks.delete", result: compactOpResult(result2) });
693938
+ deleted.push({ nodeId: target2.nodeId, nodeType: target2.nodeType });
693939
+ } catch (err) {
693940
+ errors2.push({
693941
+ code: "ACTION_FAILED",
693942
+ message: `blocks.delete failed for ${target2.nodeType} ${target2.nodeId}: ${err instanceof Error ? err.message : String(err)}`,
693943
+ recovery: { kind: "reinspect" }
693944
+ });
693945
+ }
693946
+ }
693947
+ const post = await buildDocumentSnapshot(doc3, { includeDomains: [...domains] });
693948
+ const checks2 = changeMode === "tracked" ? [{ kind: "tracked-change-count-delta", delta: deleted.length }] : [...new Set(deleted.map((entry) => entry.nodeType))].map((nodeType2) => ({
693949
+ kind: "block-count-delta",
693950
+ nodeType: nodeType2,
693951
+ delta: -deleted.filter((entry) => entry.nodeType === nodeType2).length
693952
+ }));
693953
+ const verification = evaluateChecks(pre, post, checks2);
693954
+ const allApplied = deleted.length === args3.selectors.length && errors2.length === 0;
693955
+ const verified = verification.every((v) => v.passed);
693956
+ return {
693957
+ status: !verified || deleted.length === 0 ? "failed" : allApplied ? "ok" : "partial",
693958
+ intent: `delete_blocks: ${deleted.length} block(s)`,
693959
+ preSnapshot: { revision: pre.revision, counts: pre.counts },
693960
+ postSnapshot: { revision: post.revision, counts: post.counts },
693961
+ selectedTargets: targets.map((target2) => ({ selector: target2.selector, matched: [target2.nodeId] })),
693962
+ executedOperations,
693963
+ verification,
693964
+ deletedBlocks: deleted,
693965
+ ...errors2.length ? { errors: errors2 } : {},
693966
+ ...errors2.length ? { nextStep: "Re-inspect the document and retry the selectors that did not resolve to one block." } : {}
693967
+ };
693968
+ } catch (err) {
693969
+ return failedReceipt("delete_blocks", err, pre);
693970
+ }
693971
+ }
693457
693972
  async function runAppendList(doc3, args3) {
693458
693973
  const pre = await buildDocumentSnapshot(doc3);
693459
693974
  try {
@@ -696411,6 +696926,21 @@ async function superdocPerformAction(doc3, args3) {
696411
696926
  changeMode: parseChangeMode4(args3.changeMode)
696412
696927
  });
696413
696928
  }
696929
+ case "delete_blocks": {
696930
+ const rawSelectors = Array.isArray(args3.selectors) ? args3.selectors : args3.selectors != null ? [args3.selectors] : args3.selector != null ? [args3.selector] : [];
696931
+ if (rawSelectors.length === 0) {
696932
+ throw new SuperDocCliError('delete_blocks requires a non-empty "selectors" array, each entry resolving to one block (e.g. {kind:"nodeId",nodeId:"…"})', { code: "INVALID_ARGUMENT" });
696933
+ }
696934
+ const selectors = [];
696935
+ for (const [index2, raw] of rawSelectors.entries()) {
696936
+ const parsed = parseSelector2(raw);
696937
+ if (!parsed) {
696938
+ throw new SuperDocCliError(`delete_blocks selectors[${index2}] is not a valid selector (e.g. {kind:"nodeId",nodeId:"…"}); no blocks were deleted`, { code: "INVALID_ARGUMENT" });
696939
+ }
696940
+ selectors.push(parsed);
696941
+ }
696942
+ return runDeleteBlocks(doc3, { action, selectors, changeMode: parseChangeMode4(args3.changeMode) });
696943
+ }
696414
696944
  case "append_list": {
696415
696945
  const items2 = parseStringArray(args3.items);
696416
696946
  if (!items2 || items2.length === 0) {
@@ -697049,7 +697579,7 @@ function parseSelector2(value2) {
697049
697579
  }
697050
697580
  return;
697051
697581
  }
697052
- var ACTION_NAMES, ACTION_HINTS, ACTION_GROUPS, ACTION_ARGS, NAMED_COLORS, HEX_COLOR_PATTERN, normMarker = (m2) => m2.trim().replace(/\.$/, ""), ACTION_NAMES_LIST;
697582
+ var ACTION_NAMES, ACTION_HINTS, ACTION_GROUPS, ACTION_ARGS, DELETABLE_BLOCK_NODE_TYPES3, NAMED_COLORS, HEX_COLOR_PATTERN, normMarker = (m2) => m2.trim().replace(/\.$/, ""), ACTION_NAMES_LIST;
697053
697583
  var init_actions = __esm(() => {
697054
697584
  init_errors3();
697055
697585
  init_list_transform();
@@ -697061,6 +697591,7 @@ var init_actions = __esm(() => {
697061
697591
  "insert_heading",
697062
697592
  "replace_text",
697063
697593
  "delete_text",
697594
+ "delete_blocks",
697064
697595
  "append_list",
697065
697596
  "create_table",
697066
697597
  "comment_paragraphs",
@@ -697102,7 +697633,8 @@ var init_actions = __esm(() => {
697102
697633
  insert_paragraphs: "texts[] (or text for a single paragraph), placement?, headingLevel? (first item as heading 1-6), changeMode?",
697103
697634
  insert_heading: "text, level, placement?, changeMode?",
697104
697635
  replace_text: "edits[{find,replace}], optional selector to scope replacements to one inspected block, caseSensitive?, changeMode?",
697105
- delete_text: "finds[], optional selector to scope deletions to ONE inspected block (required to delete stray whitespace — an unscoped whitespace find matches document-wide), caseSensitive?, changeMode?",
697636
+ delete_text: "finds[], optional selector to scope deletions to ONE inspected block (required to delete stray whitespace — an unscoped whitespace find matches document-wide), caseSensitive?, changeMode? — deletes TEXT ONLY, leaving the block (and a list item's bullet/number) in place. To remove a whole list item, paragraph or heading use delete_blocks",
697637
+ delete_blocks: 'selectors[] (each resolving to ONE inspected block: list item, paragraph or heading), changeMode? — THE way to DELETE a whole LIST ITEM, paragraph or heading, bullet/number included. Use for "remove the first item under Article II" / "delete that clause". delete_text only strikes the text and leaves an empty numbered item behind. Deletes several blocks in ONE call; use delete_table for a whole table',
697106
697638
  append_list: 'items[], kind?: ordered|bullet, headingText?, headingLevel?, placement? {at:"after"|"before",selector} builds the list at that block instead of document end',
697107
697639
  create_table: 'rows, columns, cellTexts?, placement?, changeMode? — changeMode:"tracked" makes the table insertion itself a tracked change',
697108
697640
  rewrite_block: "selector, text, changeMode?",
@@ -697148,6 +697680,7 @@ var init_actions = __esm(() => {
697148
697680
  "insert_heading",
697149
697681
  "replace_text",
697150
697682
  "delete_text",
697683
+ "delete_blocks",
697151
697684
  "append_list",
697152
697685
  "create_table",
697153
697686
  "rewrite_block",
@@ -697194,6 +697727,7 @@ var init_actions = __esm(() => {
697194
697727
  insert_heading: ["text", "level", "placement", "changeMode"],
697195
697728
  replace_text: ["edits", "selector", "caseSensitive", "changeMode"],
697196
697729
  delete_text: ["finds", "selector", "caseSensitive", "changeMode"],
697730
+ delete_blocks: ["selectors", "selector", "changeMode"],
697197
697731
  append_list: ["items", "kind", "headingText", "headingLevel", "placement", "changeMode"],
697198
697732
  create_table: ["rows", "columns", "cellTexts", "placement", "changeMode"],
697199
697733
  comment_paragraphs: ["commentText", "scope", "excludeBlockQuotes"],
@@ -697244,6 +697778,7 @@ var init_actions = __esm(() => {
697244
697778
  insert_page_break: ["selector"],
697245
697779
  add_hyperlink: ["text", "url", "tooltip"]
697246
697780
  };
697781
+ DELETABLE_BLOCK_NODE_TYPES3 = new Set(["paragraph", "heading", "listItem"]);
697247
697782
  NAMED_COLORS = {
697248
697783
  black: "000000",
697249
697784
  blue: "0000FF",
@@ -698696,7 +699231,8 @@ ACTIONS (superdoc_perform_action with flat args)
698696
699231
  - redo_changes: steps (1-25, default 1). Steps history FORWARD to re-apply edits a prior undo removed — THE recovery for an undo overshoot. Only reaches the forward branch until a NEW edit is made.
698697
699232
  - attach_numbering: anchorText (text of the block) or nodeId, likeMarker (rendered marker of a sibling clause, e.g. "10."). Makes an EXISTING block a numbered clause at the same scheme/level — "make this the section 11 heading" in a clause-numbered document is exactly this (it will render as the next number).
698698
699233
  - replace_text: edits:[{find,replace}], caseSensitive default false. selector to scope. changeMode:"tracked" if asked. The receipt reports editsApplied and editsSkipped per find — READ IT: a skipped find is not in the selected block; re-target instead of assuming success.
698699
- - delete_text: finds:[string]. selector to scope deletions to ONE block — REQUIRED for whitespace-only finds (unscoped whitespace matches document-wide and is refused). changeMode:"tracked" if asked.
699234
+ - delete_text: finds:[string]. selector to scope deletions to ONE block — REQUIRED for whitespace-only finds (unscoped whitespace matches document-wide and is refused). changeMode:"tracked" if asked. Deletes TEXT ONLY: the block survives, so a list item keeps its bullet/number and an accepted tracked deletion leaves an empty numbered item behind. To remove the item itself use delete_blocks.
699235
+ - delete_blocks: selectors:[…], each resolving to ONE block (list item, paragraph or heading). changeMode:"tracked" if asked. THE way to DELETE a whole LIST ITEM, paragraph or heading — the bullet/number goes with it and the remaining items renumber. "Delete the first item under Article II" / "remove that clause" is exactly this, NOT delete_text. Pass every target in ONE call. Use delete_table for a whole table.
698700
699236
  - rewrite_block: selector, text. Inspect first to gather current text; never ask the user to paste text already in the doc.
698701
699237
  - create_table: rows, columns, optional cellTexts (2D array). rows counts ALL rows INCLUDING the header — header plus one data row is rows:2. placement defaults to document end. changeMode:"tracked" if asked ("track-changes table") — the insertion itself becomes a tracked change.
698702
699238
  - comment_paragraphs: commentText. excludeBlockQuotes:true to skip block quotes. Applies the SAME text to every BODY paragraph (it does NOT comment the title/heading) — broadcast notes only, never review feedback (see REVIEW rule). To comment a heading too, add_comments on it explicitly.