@superdoc-dev/cli 0.7.0-next.30 → 0.7.0-next.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +413 -86
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -65501,7 +65501,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
65501
65501
  emptyOptions2 = {};
65502
65502
  });
65503
65503
 
65504
- // ../../packages/superdoc/dist/chunks/SuperConverter-CpoUNyba.es.js
65504
+ // ../../packages/superdoc/dist/chunks/SuperConverter-BeDVoX0d.es.js
65505
65505
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
65506
65506
  const fieldValue = extension$1.config[field];
65507
65507
  if (typeof fieldValue === "function")
@@ -93344,7 +93344,7 @@ function assignInternalId(element, idMap, context, insideTrackedChange) {
93344
93344
  author: element.attributes?.["w:author"] ?? "",
93345
93345
  date: element.attributes?.["w:date"] ?? ""
93346
93346
  };
93347
- if (context.lastTrackedChange && isReplacementPair(context.lastTrackedChange, current)) {
93347
+ if (context.replacements === "paired" && context.lastTrackedChange && isReplacementPair(context.lastTrackedChange, current)) {
93348
93348
  if (!idMap.has(wordId))
93349
93349
  idMap.set(wordId, context.lastTrackedChange.internalId);
93350
93350
  context.lastTrackedChange = null;
@@ -93364,7 +93364,10 @@ function walkElements(elements, idMap, context, insideTrackedChange = false) {
93364
93364
  if (TRACKED_CHANGE_NAMES.has(element.name)) {
93365
93365
  assignInternalId(element, idMap, context, insideTrackedChange);
93366
93366
  if (element.elements)
93367
- walkElements(element.elements, idMap, { lastTrackedChange: null }, true);
93367
+ walkElements(element.elements, idMap, {
93368
+ lastTrackedChange: null,
93369
+ replacements: context.replacements
93370
+ }, true);
93368
93371
  } else {
93369
93372
  if (!PAIRING_TRANSPARENT_NAMES.has(element.name))
93370
93373
  context.lastTrackedChange = null;
@@ -93372,12 +93375,16 @@ function walkElements(elements, idMap, context, insideTrackedChange = false) {
93372
93375
  walkElements(element.elements, idMap, context, insideTrackedChange);
93373
93376
  }
93374
93377
  }
93375
- function buildTrackedChangeIdMap(docx) {
93378
+ function buildTrackedChangeIdMap(docx, options = {}) {
93376
93379
  const body = docx?.["word/document.xml"]?.elements?.[0];
93377
93380
  if (!body?.elements)
93378
93381
  return /* @__PURE__ */ new Map;
93382
+ const replacements = options.replacements === "independent" ? "independent" : "paired";
93379
93383
  const idMap = /* @__PURE__ */ new Map;
93380
- walkElements(body.elements, idMap, { lastTrackedChange: null });
93384
+ walkElements(body.elements, idMap, {
93385
+ lastTrackedChange: null,
93386
+ replacements
93387
+ });
93381
93388
  return idMap;
93382
93389
  }
93383
93390
  function importNoteEntries({ partXml, childElementName, filename, docx, editor, converter, nodeListHandler, numbering }) {
@@ -114445,21 +114452,28 @@ var isRegExp = (value) => {
114445
114452
  }, config$13, translator$21, XML_NODE_NAME$12 = "sd:tableOfContents", SD_NODE_NAME$10 = "tableOfContents", encode$16 = (params3) => {
114446
114453
  const { nodes = [], nodeListHandler } = params3 || {};
114447
114454
  const node3 = nodes[0];
114448
- let processedContent = nodeListHandler.handler({
114455
+ const normalizedContent = (nodeListHandler.handler({
114449
114456
  ...params3,
114450
114457
  nodes: node3.elements || []
114451
- });
114452
- if (!(processedContent || []).some((child) => child?.type === "paragraph"))
114453
- processedContent = [{
114454
- type: "paragraph",
114455
- content: processedContent.filter((child) => Boolean(child && child.type))
114456
- }];
114457
- const attrs = { instruction: node3.attributes?.instruction || "" };
114458
- attrs.rightAlignPageNumbers = deriveRightAlignPageNumbers(processedContent);
114458
+ }) || []).reduce((acc, child) => {
114459
+ if (!child || !child.type)
114460
+ return acc;
114461
+ if (child.type === "paragraph")
114462
+ acc.push(child);
114463
+ else
114464
+ acc.push({
114465
+ type: "paragraph",
114466
+ content: [child]
114467
+ });
114468
+ return acc;
114469
+ }, []);
114459
114470
  return {
114460
114471
  type: "tableOfContents",
114461
- attrs,
114462
- content: processedContent
114472
+ attrs: {
114473
+ instruction: node3.attributes?.instruction || "",
114474
+ rightAlignPageNumbers: deriveRightAlignPageNumbers(normalizedContent)
114475
+ },
114476
+ content: normalizedContent
114463
114477
  };
114464
114478
  }, decode$16 = (params3) => {
114465
114479
  const { node: node3 } = params3;
@@ -116086,7 +116100,7 @@ var isRegExp = (value) => {
116086
116100
  const inlineDocumentFonts = [];
116087
116101
  patchNumberingDefinitions(docx);
116088
116102
  const numbering = getNumberingDefinitions(docx);
116089
- converter.trackedChangeIdMap = buildTrackedChangeIdMap(docx);
116103
+ converter.trackedChangeIdMap = buildTrackedChangeIdMap(docx, { replacements: converter.trackedChangesOptions?.replacements ?? "paired" });
116090
116104
  const comments = importCommentData({
116091
116105
  docx,
116092
116106
  nodeListHandler,
@@ -117255,7 +117269,7 @@ var isRegExp = (value) => {
117255
117269
  state.kern = kernNode.attributes["w:val"];
117256
117270
  }
117257
117271
  }, SuperConverter;
117258
- var init_SuperConverter_CpoUNyba_es = __esm(() => {
117272
+ var init_SuperConverter_BeDVoX0d_es = __esm(() => {
117259
117273
  init_rolldown_runtime_Bg48TavK_es();
117260
117274
  init_jszip_C49i9kUs_es();
117261
117275
  init_xml_js_CqGKpaft_es();
@@ -153650,6 +153664,7 @@ var init_SuperConverter_CpoUNyba_es = __esm(() => {
153650
153664
  this.docx = params3?.docx || [];
153651
153665
  this.media = params3?.media || {};
153652
153666
  this.fonts = params3?.fonts || {};
153667
+ this.trackedChangesOptions = params3?.trackedChangesOptions || null;
153653
153668
  this.addedMedia = {};
153654
153669
  this.comments = [];
153655
153670
  this.footnotes = [];
@@ -154535,7 +154550,7 @@ var init_SuperConverter_CpoUNyba_es = __esm(() => {
154535
154550
  };
154536
154551
  });
154537
154552
 
154538
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-Dp1bWeQT.es.js
154553
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DazI5Z1K.es.js
154539
154554
  function parseSizeUnit(val = "0") {
154540
154555
  const length3 = val.toString() || "0";
154541
154556
  const value = Number.parseFloat(length3);
@@ -157127,8 +157142,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
157127
157142
  }
157128
157143
  };
157129
157144
  };
157130
- var init_create_headless_toolbar_Dp1bWeQT_es = __esm(() => {
157131
- init_SuperConverter_CpoUNyba_es();
157145
+ var init_create_headless_toolbar_DazI5Z1K_es = __esm(() => {
157146
+ init_SuperConverter_BeDVoX0d_es();
157132
157147
  init_constants_CGhJRd87_es();
157133
157148
  init_dist_B8HfvhaK_es();
157134
157149
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
@@ -205815,7 +205830,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
205815
205830
  init_remark_gfm_BhnWr3yf_es();
205816
205831
  });
205817
205832
 
205818
- // ../../packages/superdoc/dist/chunks/src-Ces3ijYl.es.js
205833
+ // ../../packages/superdoc/dist/chunks/src-D3ohvIgD.es.js
205819
205834
  function deleteProps(obj, propOrProps) {
205820
205835
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
205821
205836
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -205879,11 +205894,10 @@ function computeTabStops$1(context) {
205879
205894
  const clearPositions = explicitStops.filter((stop) => stop.val === "clear").map((stop) => stop.pos);
205880
205895
  const filteredExplicitStops = explicitStops.filter((stop) => stop.val !== "clear").filter((stop) => stop.pos >= effectiveMinIndent);
205881
205896
  const maxExplicit = filteredExplicitStops.reduce((max$2, stop) => Math.max(max$2, stop.pos), 0);
205882
- const hasExplicit = filteredExplicitStops.length > 0;
205883
205897
  const stops = [...filteredExplicitStops];
205884
- const defaultStart = hasExplicit ? Math.max(maxExplicit, leftIndent) : 0;
205898
+ const defaultStart = !filteredExplicitStops.some((stop) => stop.val === "start") ? 0 : Math.max(maxExplicit, leftIndent);
205885
205899
  let pos = defaultStart;
205886
- const targetLimit = Math.max(defaultStart, leftIndent) + 14400;
205900
+ const targetLimit = Math.max(defaultStart, leftIndent, maxExplicit) + 14400;
205887
205901
  while (pos < targetLimit) {
205888
205902
  pos += defaultTabInterval;
205889
205903
  const hasExplicitStop = filteredExplicitStops.some((s2) => Math.abs(s2.pos - pos) < 20);
@@ -247343,12 +247357,60 @@ function applyParagraphBordersAndShading(paraWrapper, block) {
247343
247357
  if (shadingFill)
247344
247358
  paraWrapper.style.backgroundColor = shadingFill;
247345
247359
  }
247346
- function classifyMathText(text5) {
247347
- if (/^\d*\.?\d+$/.test(text5))
247348
- return "mn";
247349
- if (text5.length === 1 && OPERATOR_CHARS.has(text5))
247350
- return "mo";
247351
- return "mi";
247360
+ function isDigit(ch) {
247361
+ return ch >= "0" && ch <= "9";
247362
+ }
247363
+ function codePointUnitLength(text5, i4) {
247364
+ const hi = text5.charCodeAt(i4);
247365
+ if (hi >= 55296 && hi <= 56319 && i4 + 1 < text5.length) {
247366
+ const lo = text5.charCodeAt(i4 + 1);
247367
+ if (lo >= 56320 && lo <= 57343)
247368
+ return 2;
247369
+ }
247370
+ return 1;
247371
+ }
247372
+ function tokenizeMathText(text5) {
247373
+ const atoms = [];
247374
+ let i4 = 0;
247375
+ while (i4 < text5.length) {
247376
+ const step3 = codePointUnitLength(text5, i4);
247377
+ const ch = text5.slice(i4, i4 + step3);
247378
+ if (step3 === 1 && isDigit(ch)) {
247379
+ let end$1 = i4 + 1;
247380
+ let sawDot = false;
247381
+ while (end$1 < text5.length) {
247382
+ const c = text5[end$1];
247383
+ if (isDigit(c)) {
247384
+ end$1++;
247385
+ continue;
247386
+ }
247387
+ if (c === "." && !sawDot && end$1 + 1 < text5.length && isDigit(text5[end$1 + 1])) {
247388
+ sawDot = true;
247389
+ end$1++;
247390
+ continue;
247391
+ }
247392
+ break;
247393
+ }
247394
+ atoms.push({
247395
+ tag: "mn",
247396
+ content: text5.slice(i4, end$1)
247397
+ });
247398
+ i4 = end$1;
247399
+ } else if (step3 === 1 && OPERATOR_CHARS.has(ch)) {
247400
+ atoms.push({
247401
+ tag: "mo",
247402
+ content: ch
247403
+ });
247404
+ i4++;
247405
+ } else {
247406
+ atoms.push({
247407
+ tag: "mi",
247408
+ content: ch
247409
+ });
247410
+ i4 += step3;
247411
+ }
247412
+ }
247413
+ return atoms;
247352
247414
  }
247353
247415
  function resolveMathVariant(rPr) {
247354
247416
  const elements = rPr?.elements ?? [];
@@ -247362,6 +247424,87 @@ function resolveMathVariant(rPr) {
247362
247424
  return "normal";
247363
247425
  return null;
247364
247426
  }
247427
+ function extractText(node3) {
247428
+ let text5 = "";
247429
+ for (const child of node3.elements ?? [])
247430
+ if (child.name === "m:t") {
247431
+ for (const tc of child.elements ?? [])
247432
+ if (tc.type === "text" && typeof tc.text === "string")
247433
+ text5 += tc.text;
247434
+ }
247435
+ return text5;
247436
+ }
247437
+ function tokenizeFunctionNameText(text5) {
247438
+ const atoms = [];
247439
+ let i4 = 0;
247440
+ while (i4 < text5.length) {
247441
+ const step3 = codePointUnitLength(text5, i4);
247442
+ const ch = text5.slice(i4, i4 + step3);
247443
+ if (step3 === 1 && isDigit(ch)) {
247444
+ let end$1 = i4 + 1;
247445
+ let sawDot = false;
247446
+ while (end$1 < text5.length) {
247447
+ const c = text5[end$1];
247448
+ if (isDigit(c)) {
247449
+ end$1++;
247450
+ continue;
247451
+ }
247452
+ if (c === "." && !sawDot && end$1 + 1 < text5.length && isDigit(text5[end$1 + 1])) {
247453
+ sawDot = true;
247454
+ end$1++;
247455
+ continue;
247456
+ }
247457
+ break;
247458
+ }
247459
+ atoms.push({
247460
+ tag: "mn",
247461
+ content: text5.slice(i4, end$1)
247462
+ });
247463
+ i4 = end$1;
247464
+ } else if (step3 === 1 && OPERATOR_CHARS.has(ch)) {
247465
+ atoms.push({
247466
+ tag: "mo",
247467
+ content: ch
247468
+ });
247469
+ i4++;
247470
+ } else {
247471
+ let end$1 = i4 + step3;
247472
+ while (end$1 < text5.length) {
247473
+ const s2 = codePointUnitLength(text5, end$1);
247474
+ const c = text5.slice(end$1, end$1 + s2);
247475
+ if (s2 === 1 && (isDigit(c) || OPERATOR_CHARS.has(c)))
247476
+ break;
247477
+ end$1 += s2;
247478
+ }
247479
+ atoms.push({
247480
+ tag: "mi",
247481
+ content: text5.slice(i4, end$1)
247482
+ });
247483
+ i4 = end$1;
247484
+ }
247485
+ }
247486
+ return atoms;
247487
+ }
247488
+ function convertMathRunAsFunctionName(node3, doc$12) {
247489
+ const text5 = extractText(node3);
247490
+ if (!text5)
247491
+ return null;
247492
+ const variant = resolveMathVariant((node3.elements ?? []).find((el) => el.name === "m:rPr"));
247493
+ const atoms = tokenizeFunctionNameText(text5);
247494
+ const createAtom = (atom) => {
247495
+ const el = doc$12.createElementNS(MATHML_NS$19, atom.tag);
247496
+ el.textContent = atom.content;
247497
+ if (variant)
247498
+ el.setAttribute("mathvariant", variant);
247499
+ return el;
247500
+ };
247501
+ if (atoms.length === 1)
247502
+ return createAtom(atoms[0]);
247503
+ const fragment2 = doc$12.createDocumentFragment();
247504
+ for (const atom of atoms)
247505
+ fragment2.appendChild(createAtom(atom));
247506
+ return fragment2;
247507
+ }
247365
247508
  function forceNormalMathVariant(root3) {
247366
247509
  for (const child of Array.from(root3.children)) {
247367
247510
  if (MATH_VARIANT_BOUNDARY_ELEMENTS.has(child.localName))
@@ -247371,6 +247514,34 @@ function forceNormalMathVariant(root3) {
247371
247514
  forceNormalMathVariant(child);
247372
247515
  }
247373
247516
  }
247517
+ function collapseFunctionNameBases(root3) {
247518
+ for (const child of Array.from(root3.children))
247519
+ if (BASE_BEARING_ELEMENTS.has(child.localName)) {
247520
+ const base5 = child.children[0];
247521
+ if (base5) {
247522
+ collapseMrowToSingleMi(base5);
247523
+ collapseFunctionNameBases(base5);
247524
+ }
247525
+ } else
247526
+ collapseFunctionNameBases(child);
247527
+ }
247528
+ function collapseMrowToSingleMi(container) {
247529
+ const children = Array.from(container.children);
247530
+ if (children.length < 2)
247531
+ return;
247532
+ if (!children.every((c) => c.localName === "mi"))
247533
+ return;
247534
+ const variant = children[0].getAttribute("mathvariant");
247535
+ if (!children.every((c) => c.getAttribute("mathvariant") === variant))
247536
+ return;
247537
+ const merged = container.ownerDocument.createElementNS(MATHML_NS$16, "mi");
247538
+ merged.textContent = children.map((c) => c.textContent ?? "").join("");
247539
+ if (variant)
247540
+ merged.setAttribute("mathvariant", variant);
247541
+ container.insertBefore(merged, children[0]);
247542
+ for (const c of children)
247543
+ c.remove();
247544
+ }
247374
247545
  function getDelimiterValue(properties, name, fallback) {
247375
247546
  const property = properties?.elements?.find((element3) => element3.name === name);
247376
247547
  if (!property)
@@ -257199,16 +257370,16 @@ function pageReferenceNodeToBlock(params$1) {
257199
257370
  if (bookmarkId) {
257200
257371
  let fallbackText = "??";
257201
257372
  if (Array.isArray(node3.content) && node3.content.length > 0) {
257202
- const extractText = (n) => {
257373
+ const extractText$1 = (n) => {
257203
257374
  if (n.type === "run")
257204
257375
  runProperties = n.attrs?.runProperties ?? {};
257205
257376
  if (n.type === "text" && n.text)
257206
257377
  return n.text;
257207
257378
  if (Array.isArray(n.content))
257208
- return n.content.map(extractText).join("");
257379
+ return n.content.map(extractText$1).join("");
257209
257380
  return "";
257210
257381
  };
257211
- fallbackText = node3.content.map(extractText).join("").trim() || "??";
257382
+ fallbackText = node3.content.map(extractText$1).join("").trim() || "??";
257212
257383
  }
257213
257384
  const pageRefPos = positions.get(node3);
257214
257385
  const resolvedRunProperties = resolveRunProperties(converterContext, runProperties, paragraphProperties, null, false, false);
@@ -257240,14 +257411,14 @@ function fieldAnnotationNodeToRun({ node: node3, positions }) {
257240
257411
  const fieldMetadata = resolveNodeSdtMetadata(node3, "fieldAnnotation");
257241
257412
  let contentText;
257242
257413
  if (Array.isArray(node3.content) && node3.content.length > 0) {
257243
- const extractText = (n) => {
257414
+ const extractText$1 = (n) => {
257244
257415
  if (n.type === "text" && typeof n.text === "string")
257245
257416
  return n.text;
257246
257417
  if (Array.isArray(n.content))
257247
- return n.content.map(extractText).join("");
257418
+ return n.content.map(extractText$1).join("");
257248
257419
  return "";
257249
257420
  };
257250
- contentText = node3.content.map(extractText).join("");
257421
+ contentText = node3.content.map(extractText$1).join("");
257251
257422
  }
257252
257423
  const attrs = (contentText && contentText.length > 0 ? {
257253
257424
  ...node3,
@@ -260954,6 +261125,10 @@ async function measureParagraphBlock(block, maxWidth) {
260954
261125
  else
260955
261126
  initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
260956
261127
  const tabStops = buildTabStopsPx(indent2, block.attrs?.tabs, block.attrs?.tabIntervalTwips);
261128
+ const alignmentTabStopsPx = tabStops.map((stop, index2) => ({
261129
+ stop,
261130
+ index: index2
261131
+ })).filter(({ stop }) => stop.val === "end" || stop.val === "center" || stop.val === "decimal");
260957
261132
  const decimalSeparator = sanitizeDecimalSeparator(block.attrs?.decimalSeparator);
260958
261133
  const barTabStops = tabStops.filter((stop) => stop.val === "bar");
260959
261134
  const addBarTabsToLine = (line) => {
@@ -261084,7 +261259,7 @@ async function measureParagraphBlock(block, maxWidth) {
261084
261259
  segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx$1, runContext, segmentStartChar) : 0;
261085
261260
  return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
261086
261261
  };
261087
- const runsToProcess = [];
261262
+ let runsToProcess = [];
261088
261263
  for (const run2 of normalizedRuns)
261089
261264
  if (run2.text && typeof run2.text === "string" && run2.text.includes(`
261090
261265
  `)) {
@@ -261113,6 +261288,57 @@ async function measureParagraphBlock(block, maxWidth) {
261113
261288
  });
261114
261289
  } else
261115
261290
  runsToProcess.push(run2);
261291
+ if (runsToProcess.some((run2) => isTextRun$1(run2) && typeof run2.text === "string" && run2.text.includes("\t"))) {
261292
+ const expandedRuns = [];
261293
+ for (const run2 of runsToProcess) {
261294
+ if (!isTextRun$1(run2) || typeof run2.text !== "string" || !run2.text.includes("\t")) {
261295
+ expandedRuns.push(run2);
261296
+ continue;
261297
+ }
261298
+ const textRun = run2;
261299
+ let buffer3 = "";
261300
+ let cursor = textRun.pmStart ?? 0;
261301
+ const text5 = textRun.text;
261302
+ for (let i4 = 0;i4 < text5.length; i4 += 1) {
261303
+ const char = text5[i4];
261304
+ if (char === "\t") {
261305
+ if (buffer3.length > 0) {
261306
+ expandedRuns.push({
261307
+ ...textRun,
261308
+ text: buffer3,
261309
+ pmStart: cursor - buffer3.length,
261310
+ pmEnd: cursor
261311
+ });
261312
+ buffer3 = "";
261313
+ }
261314
+ const tabRun = {
261315
+ kind: "tab",
261316
+ text: "\t",
261317
+ pmStart: cursor,
261318
+ pmEnd: cursor + 1,
261319
+ tabStops: block.attrs?.tabs,
261320
+ indent: indent2,
261321
+ leader: textRun?.leader ?? null,
261322
+ sdt: textRun.sdt
261323
+ };
261324
+ expandedRuns.push(tabRun);
261325
+ cursor += 1;
261326
+ continue;
261327
+ }
261328
+ buffer3 += char;
261329
+ cursor += 1;
261330
+ }
261331
+ if (buffer3.length > 0)
261332
+ expandedRuns.push({
261333
+ ...textRun,
261334
+ text: buffer3,
261335
+ pmStart: cursor - buffer3.length,
261336
+ pmEnd: cursor
261337
+ });
261338
+ }
261339
+ runsToProcess = expandedRuns;
261340
+ }
261341
+ const totalTabRuns = runsToProcess.reduce((count2, run2) => isTabRun(run2) ? count2 + 1 : count2, 0);
261116
261342
  const trimTrailingWrapSpaces = (lineToTrim) => {
261117
261343
  const lastRun = runsToProcess[lineToTrim.toRun];
261118
261344
  if (!lastRun || !("text" in lastRun) || typeof lastRun.text !== "string")
@@ -261139,6 +261365,18 @@ async function measureParagraphBlock(block, maxWidth) {
261139
261365
  if (lineToTrim.naturalWidth != null && typeof lineToTrim.naturalWidth === "number")
261140
261366
  lineToTrim.naturalWidth = roundValue(Math.max(0, lineToTrim.naturalWidth - delta));
261141
261367
  };
261368
+ const getAlignmentStopForOrdinal = (ordinal) => {
261369
+ if (alignmentTabStopsPx.length === 0 || totalTabRuns === 0 || !Number.isFinite(ordinal))
261370
+ return null;
261371
+ if (ordinal < 0 || ordinal >= totalTabRuns)
261372
+ return null;
261373
+ const remainingTabs = totalTabRuns - ordinal - 1;
261374
+ const targetIndex = alignmentTabStopsPx.length - 1 - remainingTabs;
261375
+ if (targetIndex < 0 || targetIndex >= alignmentTabStopsPx.length)
261376
+ return null;
261377
+ return alignmentTabStopsPx[targetIndex];
261378
+ };
261379
+ let sequentialTabIndex = 0;
261142
261380
  for (let runIndex = 0;runIndex < runsToProcess.length; runIndex++) {
261143
261381
  const run2 = runsToProcess[runIndex];
261144
261382
  if (run2.kind === "break") {
@@ -261236,8 +261474,21 @@ async function measureParagraphBlock(block, maxWidth) {
261236
261474
  const originX = currentLine.width;
261237
261475
  const effectiveIndent = lines.length === 0 ? indentLeft + rawFirstLineOffset : indentLeft;
261238
261476
  const absCurrentX = currentLine.width + effectiveIndent;
261239
- const { target, nextIndex, stop } = getNextTabStopPx(absCurrentX, tabStops, tabStopCursor);
261240
- tabStopCursor = nextIndex;
261477
+ let stop;
261478
+ let target;
261479
+ const resolvedTabIndex = typeof run2.tabIndex === "number" && Number.isFinite(run2.tabIndex) ? run2.tabIndex : sequentialTabIndex;
261480
+ sequentialTabIndex = Math.max(sequentialTabIndex, resolvedTabIndex + 1);
261481
+ const forcedAlignment = getAlignmentStopForOrdinal(resolvedTabIndex);
261482
+ if (forcedAlignment && forcedAlignment.stop.pos > absCurrentX + TAB_EPSILON) {
261483
+ stop = forcedAlignment.stop;
261484
+ target = forcedAlignment.stop.pos;
261485
+ tabStopCursor = forcedAlignment.index + 1;
261486
+ } else {
261487
+ const nextStop = getNextTabStopPx(absCurrentX, tabStops, tabStopCursor);
261488
+ target = nextStop.target;
261489
+ tabStopCursor = nextStop.nextIndex;
261490
+ stop = nextStop.stop;
261491
+ }
261241
261492
  const maxAbsWidth = currentLine.maxWidth + effectiveIndent;
261242
261493
  const clampedTarget = Math.min(target, maxAbsWidth);
261243
261494
  const tabAdvance = Math.max(0, clampedTarget - absCurrentX);
@@ -271185,7 +271436,7 @@ var Node$13 = class Node$14 {
271185
271436
  } catch {
271186
271437
  return step3;
271187
271438
  }
271188
- }, replaceStep2 = ({ state, tr, step: step3, newTr, map: map$12, user, date, originalStep, originalStepIndex }) => {
271439
+ }, replaceStep2 = ({ state, tr, step: step3, newTr, map: map$12, user, date, originalStep, originalStepIndex, replacements = "paired" }) => {
271189
271440
  const originalRange = {
271190
271441
  from: step3.from,
271191
271442
  to: step3.to,
@@ -271301,7 +271552,7 @@ var Node$13 = class Node$14 {
271301
271552
  to: step3.to,
271302
271553
  user,
271303
271554
  date,
271304
- id: meta2.insertedMark?.attrs?.id
271555
+ id: replacements === "paired" ? meta2.insertedMark?.attrs?.id : undefined
271305
271556
  });
271306
271557
  meta2.deletionNodes = deletionNodes;
271307
271558
  meta2.deletionMark = deletionMark;
@@ -271917,7 +272168,7 @@ var Node$13 = class Node$14 {
271917
272168
  placeholderChar: insertedText,
271918
272169
  authorEmail: user.email
271919
272170
  };
271920
- }, trackedTransaction = ({ tr, state, user }) => {
272171
+ }, trackedTransaction = ({ tr, state, user, replacements = "paired" }) => {
271921
272172
  const onlyInputTypeMeta = [
271922
272173
  "inputType",
271923
272174
  "uiEvent",
@@ -271971,7 +272222,8 @@ var Node$13 = class Node$14 {
271971
272222
  user,
271972
272223
  date,
271973
272224
  originalStep,
271974
- originalStepIndex
272225
+ originalStepIndex,
272226
+ replacements
271975
272227
  });
271976
272228
  else if (step3 instanceof AddMarkStep)
271977
272229
  addMarkStep({
@@ -272072,7 +272324,7 @@ var Node$13 = class Node$14 {
272072
272324
  return formatList.filter((format) => Object.hasOwn(format, "type") && Object.hasOwn(format, "attrs"));
272073
272325
  }, trackFormatClass = "track-format", TrackFormat, hasExpandedSelection = (selection) => {
272074
272326
  return Number.isFinite(selection?.from) && Number.isFinite(selection?.to) && selection.from !== selection.to;
272075
- }, TrackChanges, TRACKED_CHANGE_MARKS, getTrackedMark = (node3) => node3?.marks?.find((mark2) => TRACKED_CHANGE_MARKS.includes(mark2.type.name)) ?? null, getTrackedChangeActionSelection = ({ state, editor }) => {
272327
+ }, readReplacementsMode = (editor) => editor?.options?.trackedChanges?.replacements === "independent" ? "independent" : "paired", TrackChanges, TRACKED_CHANGE_MARKS, getTrackedMark = (node3) => node3?.marks?.find((mark2) => TRACKED_CHANGE_MARKS.includes(mark2.type.name)) ?? null, getTrackedChangeActionSelection = ({ state, editor }) => {
272076
272328
  const currentSelection = state?.selection;
272077
272329
  if (hasExpandedSelection(currentSelection))
272078
272330
  return currentSelection;
@@ -273607,6 +273859,21 @@ var Node$13 = class Node$14 {
273607
273859
  timeout$1 = args$1 = null;
273608
273860
  };
273609
273861
  return throttled;
273862
+ }, normalizeFontOption = (option) => {
273863
+ if (!option)
273864
+ return option;
273865
+ const fontFamily = option.props?.style?.fontFamily ?? option.key ?? option.label;
273866
+ return {
273867
+ ...option,
273868
+ props: {
273869
+ ...option.props,
273870
+ style: {
273871
+ ...option.props?.style,
273872
+ fontFamily
273873
+ },
273874
+ "data-item": option.props?.["data-item"] ?? "btn-fontFamily-option"
273875
+ }
273876
+ };
273610
273877
  }, useToolbarItem = (options) => {
273611
273878
  if (![
273612
273879
  "button",
@@ -273806,7 +274073,7 @@ var Node$13 = class Node$14 {
273806
274073
  tooltip: toolbarTexts$1.bold,
273807
274074
  attributes: { ariaLabel: "Bold" }
273808
274075
  });
273809
- const fontOptions = [...toolbarFonts ? toolbarFonts : TOOLBAR_FONTS];
274076
+ const fontOptions = (toolbarFonts ?? TOOLBAR_FONTS).map(normalizeFontOption);
273810
274077
  const fontButton = useToolbarItem({
273811
274078
  type: "dropdown",
273812
274079
  name: "fontFamily",
@@ -279290,24 +279557,24 @@ menclose::after {
279290
279557
  element3.style.textAlign = resolveTextAlign(attrs?.alignment, rtl);
279291
279558
  return rtl;
279292
279559
  }, shouldUseSegmentPositioning = (hasExplicitPositioning, hasSegments, isRtl) => hasExplicitPositioning && hasSegments && !isRtl, MATHML_NS$19 = "http://www.w3.org/1998/Math/MathML", OPERATOR_CHARS, STY_TO_VARIANT, SCR_TO_VARIANT, convertMathRun = (node3, doc$12) => {
279293
- const elements = node3.elements ?? [];
279294
- let text5 = "";
279295
- for (const child of elements)
279296
- if (child.name === "m:t") {
279297
- const textChildren = child.elements ?? [];
279298
- for (const tc of textChildren)
279299
- if (tc.type === "text" && typeof tc.text === "string")
279300
- text5 += tc.text;
279301
- }
279560
+ const text5 = extractText(node3);
279302
279561
  if (!text5)
279303
279562
  return null;
279304
- const variant = resolveMathVariant(elements.find((el$1) => el$1.name === "m:rPr"));
279305
- const tag = classifyMathText(text5);
279306
- const el = doc$12.createElementNS(MATHML_NS$19, tag);
279307
- el.textContent = text5;
279308
- if (variant)
279309
- el.setAttribute("mathvariant", variant);
279310
- return el;
279563
+ const variant = resolveMathVariant((node3.elements ?? []).find((el) => el.name === "m:rPr"));
279564
+ const atoms = tokenizeMathText(text5);
279565
+ const createAtom = (atom) => {
279566
+ const el = doc$12.createElementNS(MATHML_NS$19, atom.tag);
279567
+ el.textContent = atom.content;
279568
+ if (variant)
279569
+ el.setAttribute("mathvariant", variant);
279570
+ return el;
279571
+ };
279572
+ if (atoms.length === 1)
279573
+ return createAtom(atoms[0]);
279574
+ const fragment2 = doc$12.createDocumentFragment();
279575
+ for (const atom of atoms)
279576
+ fragment2.appendChild(createAtom(atom));
279577
+ return fragment2;
279311
279578
  }, MATHML_NS$18 = "http://www.w3.org/1998/Math/MathML", convertFraction = (node3, doc$12, convertChildren) => {
279312
279579
  const elements = node3.elements ?? [];
279313
279580
  const num = elements.find((e) => e.name === "m:num");
@@ -279334,13 +279601,23 @@ menclose::after {
279334
279601
  accent.textContent = "‾";
279335
279602
  wrapper.appendChild(accent);
279336
279603
  return wrapper;
279337
- }, MATHML_NS$16 = "http://www.w3.org/1998/Math/MathML", FUNCTION_APPLY_OPERATOR = "⁡", MATH_VARIANT_BOUNDARY_ELEMENTS, convertFunction = (node3, doc$12, convertChildren) => {
279604
+ }, MATHML_NS$16 = "http://www.w3.org/1998/Math/MathML", FUNCTION_APPLY_OPERATOR = "⁡", MATH_VARIANT_BOUNDARY_ELEMENTS, BASE_BEARING_ELEMENTS, convertFunction = (node3, doc$12, convertChildren) => {
279338
279605
  const elements = node3.elements ?? [];
279339
279606
  const functionName = elements.find((element3) => element3.name === "m:fName");
279340
279607
  const argument = elements.find((element3) => element3.name === "m:e");
279341
279608
  const wrapper = doc$12.createElementNS(MATHML_NS$16, "mrow");
279342
279609
  const functionNameRow = doc$12.createElementNS(MATHML_NS$16, "mrow");
279343
- functionNameRow.appendChild(convertChildren(functionName?.elements ?? []));
279610
+ for (const child of functionName?.elements ?? [])
279611
+ if (child.name === "m:r") {
279612
+ const atom = convertMathRunAsFunctionName(child, doc$12);
279613
+ if (atom)
279614
+ functionNameRow.appendChild(atom);
279615
+ } else {
279616
+ const converted = convertChildren([child]);
279617
+ if (converted.childNodes.length > 0)
279618
+ functionNameRow.appendChild(converted);
279619
+ }
279620
+ collapseFunctionNameBases(functionNameRow);
279344
279621
  forceNormalMathVariant(functionNameRow);
279345
279622
  if (functionNameRow.childNodes.length > 0)
279346
279623
  wrapper.appendChild(functionNameRow);
@@ -281809,6 +282086,32 @@ menclose::after {
281809
282086
  beforeDecimalWidth
281810
282087
  };
281811
282088
  }, applyTabLayoutToLines = (lines, runs2, tabStops, decimalSeparator, indentLeft, rawFirstLineOffset) => {
282089
+ const totalTabRuns = runs2.reduce((count2, run2) => run2.kind === "tab" ? count2 + 1 : count2, 0);
282090
+ const alignmentTabStopsPx = tabStops.map((stop, index2) => ({
282091
+ stop,
282092
+ index: index2
282093
+ })).filter(({ stop }) => stop.val === "end" || stop.val === "center" || stop.val === "decimal");
282094
+ const getAlignmentStopForOrdinal = (ordinal) => {
282095
+ if (alignmentTabStopsPx.length === 0 || totalTabRuns === 0 || !Number.isFinite(ordinal))
282096
+ return null;
282097
+ if (ordinal < 0 || ordinal >= totalTabRuns)
282098
+ return null;
282099
+ const remainingTabs = totalTabRuns - ordinal - 1;
282100
+ const targetIndex = alignmentTabStopsPx.length - 1 - remainingTabs;
282101
+ if (targetIndex < 0 || targetIndex >= alignmentTabStopsPx.length)
282102
+ return null;
282103
+ return alignmentTabStopsPx[targetIndex];
282104
+ };
282105
+ let sequentialTabIndex = 0;
282106
+ const consumeTabOrdinal = (explicitIndex) => {
282107
+ if (typeof explicitIndex === "number" && Number.isFinite(explicitIndex)) {
282108
+ sequentialTabIndex = Math.max(sequentialTabIndex, explicitIndex + 1);
282109
+ return explicitIndex;
282110
+ }
282111
+ const ordinal = sequentialTabIndex;
282112
+ sequentialTabIndex += 1;
282113
+ return ordinal;
282114
+ };
281812
282115
  lines.forEach((line, lineIndex) => {
281813
282116
  let cursorX = 0;
281814
282117
  let lineWidth = 0;
@@ -281818,10 +282121,22 @@ menclose::after {
281818
282121
  const leaders = [];
281819
282122
  const effectiveIndent = lineIndex === 0 ? indentLeft + rawFirstLineOffset : indentLeft;
281820
282123
  const maxAbsWidth = typeof line.maxWidth === "number" && Number.isFinite(line.maxWidth) ? line.maxWidth + effectiveIndent : Number.POSITIVE_INFINITY;
281821
- const applyTab = (startRunIndex, startChar, run2) => {
282124
+ const applyTab = (startRunIndex, startChar, run2, tabOrdinal) => {
281822
282125
  const originX = cursorX;
281823
- const { target, nextIndex, stop } = getNextTabStopPx$1(cursorX + effectiveIndent, tabStops, tabStopCursor);
281824
- tabStopCursor = nextIndex;
282126
+ const absCurrentX = cursorX + effectiveIndent;
282127
+ let stop;
282128
+ let target;
282129
+ const forcedAlignment = typeof tabOrdinal === "number" && Number.isFinite(tabOrdinal) ? getAlignmentStopForOrdinal(tabOrdinal) : null;
282130
+ if (forcedAlignment && forcedAlignment.stop.pos > absCurrentX + TAB_EPSILON$1) {
282131
+ stop = forcedAlignment.stop;
282132
+ target = forcedAlignment.stop.pos;
282133
+ tabStopCursor = forcedAlignment.index + 1;
282134
+ } else {
282135
+ const next2 = getNextTabStopPx$1(absCurrentX, tabStops, tabStopCursor);
282136
+ stop = next2.stop;
282137
+ target = next2.target;
282138
+ tabStopCursor = next2.nextIndex;
282139
+ }
281825
282140
  const clampedTarget = Number.isFinite(maxAbsWidth) ? Math.min(target, maxAbsWidth) : target;
281826
282141
  const relativeTarget = clampedTarget - effectiveIndent;
281827
282142
  lineWidth = Math.max(lineWidth, relativeTarget);
@@ -281862,7 +282177,8 @@ menclose::after {
281862
282177
  if (!run2)
281863
282178
  continue;
281864
282179
  if (run2.kind === "tab") {
281865
- applyTab(runIndex + 1, 0, run2);
282180
+ const ordinal = consumeTabOrdinal(run2.tabIndex);
282181
+ applyTab(runIndex + 1, 0, run2, ordinal);
281866
282182
  continue;
281867
282183
  }
281868
282184
  const text5 = runText(run2);
@@ -281896,7 +282212,8 @@ menclose::after {
281896
282212
  lineWidth = Math.max(lineWidth, cursorX);
281897
282213
  segments.push(segment);
281898
282214
  }
281899
- applyTab(runIndex, i4 + 1);
282215
+ const ordinal = consumeTabOrdinal();
282216
+ applyTab(runIndex, i4 + 1, undefined, ordinal);
281900
282217
  segmentStart = i4 + 1;
281901
282218
  }
281902
282219
  if (segmentStart < sliceEnd) {
@@ -289981,12 +290298,12 @@ menclose::after {
289981
290298
  return;
289982
290299
  console.log(...args$1);
289983
290300
  }, 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;
289984
- var init_src_Ces3ijYl_es = __esm(() => {
290301
+ var init_src_D3ohvIgD_es = __esm(() => {
289985
290302
  init_rolldown_runtime_Bg48TavK_es();
289986
- init_SuperConverter_CpoUNyba_es();
290303
+ init_SuperConverter_BeDVoX0d_es();
289987
290304
  init_jszip_C49i9kUs_es();
289988
290305
  init_uuid_qzgm05fK_es();
289989
- init_create_headless_toolbar_Dp1bWeQT_es();
290306
+ init_create_headless_toolbar_DazI5Z1K_es();
289990
290307
  init_constants_CGhJRd87_es();
289991
290308
  init_dist_B8HfvhaK_es();
289992
290309
  init_unified_Dsuw2be5_es();
@@ -306787,8 +307104,12 @@ function print() { __p += __j.call(arguments, '') }
306787
307104
  const date = (/* @__PURE__ */ new Date()).toISOString();
306788
307105
  const tr = state.tr;
306789
307106
  const marks = state.doc.resolve(from$1).marks();
306790
- const sharedId = id2 ?? (from$1 !== to && text5 ? v4_default() : null);
306791
- let changeId = sharedId;
307107
+ const pairedReplacements = readReplacementsMode(editor) === "paired";
307108
+ const isReplacement = from$1 !== to && text5;
307109
+ const primaryId = id2 ?? v4_default();
307110
+ const insertionId = primaryId;
307111
+ const deletionId = pairedReplacements || !isReplacement ? primaryId : null;
307112
+ const changeId = primaryId;
306792
307113
  let insertPos = to;
306793
307114
  let deletionMark = null;
306794
307115
  let deletionNodes = [];
@@ -306799,12 +307120,10 @@ function print() { __p += __j.call(arguments, '') }
306799
307120
  to,
306800
307121
  user: resolvedUser,
306801
307122
  date,
306802
- id: sharedId
307123
+ id: deletionId
306803
307124
  });
306804
307125
  deletionMark = result.deletionMark;
306805
307126
  deletionNodes = result.nodes || [];
306806
- if (!changeId)
306807
- changeId = deletionMark.attrs.id;
306808
307127
  insertPos = result.deletionMap.map(to);
306809
307128
  }
306810
307129
  let insertedMark = null;
@@ -306818,10 +307137,8 @@ function print() { __p += __j.call(arguments, '') }
306818
307137
  to: insertPos + insertedNode.nodeSize,
306819
307138
  user: resolvedUser,
306820
307139
  date,
306821
- id: sharedId
307140
+ id: insertionId
306822
307141
  });
306823
- if (!changeId)
306824
- changeId = insertedMark.attrs.id;
306825
307142
  }
306826
307143
  const mockStep = insertedNode ? { slice: { content: { content: [insertedNode] } } } : null;
306827
307144
  tr.setMeta(TrackChangesBasePluginKey, {
@@ -314251,7 +314568,8 @@ function print() { __p += __j.call(arguments, '') }
314251
314568
  documentId: this.options.documentId,
314252
314569
  mockWindow: this.options.mockWindow ?? null,
314253
314570
  mockDocument: this.options.mockDocument ?? null,
314254
- isNewFile: this.options.isNewFile ?? false
314571
+ isNewFile: this.options.isNewFile ?? false,
314572
+ trackedChangesOptions: this.options.trackedChanges ?? null
314255
314573
  });
314256
314574
  }
314257
314575
  async#loadBlankDocxTemplate() {
@@ -314604,7 +314922,8 @@ function print() { __p += __j.call(arguments, '') }
314604
314922
  transactionToApply = shouldTrack ? trackedTransaction({
314605
314923
  tr: transactionToApply,
314606
314924
  state: prevState,
314607
- user: this.options.user
314925
+ user: this.options.user,
314926
+ replacements: this.options.trackedChanges?.replacements === "independent" ? "independent" : "paired"
314608
314927
  }) : transactionToApply;
314609
314928
  const { state: appliedState } = prevState.applyTransaction(transactionToApply);
314610
314929
  nextState = appliedState;
@@ -315592,7 +315911,6 @@ function print() { __p += __j.call(arguments, '') }
315592
315911
  "∑",
315593
315912
  "∏",
315594
315913
  "√",
315595
- "∞",
315596
315914
  "∧",
315597
315915
  "∨",
315598
315916
  "∩",
@@ -315638,6 +315956,15 @@ function print() { __p += __j.call(arguments, '') }
315638
315956
  "mtr",
315639
315957
  "mtd"
315640
315958
  ]);
315959
+ BASE_BEARING_ELEMENTS = new Set([
315960
+ "munder",
315961
+ "mover",
315962
+ "munderover",
315963
+ "msub",
315964
+ "msup",
315965
+ "msubsup",
315966
+ "mmultiscripts"
315967
+ ]);
315641
315968
  COMBINING_TO_SPACING = {
315642
315969
  "̀": "`",
315643
315970
  "́": "´",
@@ -324824,11 +325151,11 @@ var init_zipper_DbkgrypV_es = __esm(() => {
324824
325151
 
324825
325152
  // ../../packages/superdoc/dist/super-editor.es.js
324826
325153
  var init_super_editor_es = __esm(() => {
324827
- init_src_Ces3ijYl_es();
324828
- init_SuperConverter_CpoUNyba_es();
325154
+ init_src_D3ohvIgD_es();
325155
+ init_SuperConverter_BeDVoX0d_es();
324829
325156
  init_jszip_C49i9kUs_es();
324830
325157
  init_xml_js_CqGKpaft_es();
324831
- init_create_headless_toolbar_Dp1bWeQT_es();
325158
+ init_create_headless_toolbar_DazI5Z1K_es();
324832
325159
  init_constants_CGhJRd87_es();
324833
325160
  init_dist_B8HfvhaK_es();
324834
325161
  init_unified_Dsuw2be5_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.7.0-next.30",
3
+ "version": "0.7.0-next.32",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -26,19 +26,19 @@
26
26
  "typescript": "^5.9.2",
27
27
  "@superdoc/document-api": "0.0.1",
28
28
  "@superdoc/pm-adapter": "0.0.0",
29
- "superdoc": "1.26.0",
30
- "@superdoc/super-editor": "0.0.1"
29
+ "@superdoc/super-editor": "0.0.1",
30
+ "superdoc": "1.26.0"
31
31
  },
32
32
  "module": "src/index.ts",
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@superdoc-dev/cli-darwin-arm64": "0.7.0-next.30",
38
- "@superdoc-dev/cli-linux-x64": "0.7.0-next.30",
39
- "@superdoc-dev/cli-darwin-x64": "0.7.0-next.30",
40
- "@superdoc-dev/cli-windows-x64": "0.7.0-next.30",
41
- "@superdoc-dev/cli-linux-arm64": "0.7.0-next.30"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.7.0-next.32",
38
+ "@superdoc-dev/cli-darwin-x64": "0.7.0-next.32",
39
+ "@superdoc-dev/cli-linux-arm64": "0.7.0-next.32",
40
+ "@superdoc-dev/cli-windows-x64": "0.7.0-next.32",
41
+ "@superdoc-dev/cli-linux-x64": "0.7.0-next.32"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",