@superdoc-dev/cli 0.2.0-next.1 → 0.2.0-next.3

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 +553 -232
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -656,7 +656,7 @@ var init_operation_definitions = __esm(() => {
656
656
  },
657
657
  "format.apply": {
658
658
  memberPath: "format.apply",
659
- description: "Apply explicit mark changes (bold, italic, underline, strike) to the target range using boolean patch semantics.",
659
+ description: "Apply explicit inline style changes (bold, italic, underline, strike) to the target range using boolean patch semantics.",
660
660
  requiresDocumentContext: true,
661
661
  metadata: mutationOperation({
662
662
  idempotency: "conditional",
@@ -825,7 +825,7 @@ var init_operation_definitions = __esm(() => {
825
825
  supportsDryRun: false,
826
826
  supportsTrackedMode: false,
827
827
  possibleFailureCodes: ["INVALID_TARGET", "NO_OP"],
828
- throws: [...T_NOT_FOUND_COMMAND, "INVALID_TARGET"]
828
+ throws: [...T_NOT_FOUND_COMMAND, "INVALID_TARGET", "INVALID_INPUT"]
829
829
  }),
830
830
  referenceDocPath: "comments/patch.mdx",
831
831
  referenceGroup: "comments"
@@ -886,8 +886,8 @@ var init_operation_definitions = __esm(() => {
886
886
  referenceDocPath: "track-changes/get.mdx",
887
887
  referenceGroup: "trackChanges"
888
888
  },
889
- "review.decide": {
890
- memberPath: "review.decide",
889
+ "trackChanges.decide": {
890
+ memberPath: "trackChanges.decide",
891
891
  description: "Accept or reject a tracked change (by ID or scope: all).",
892
892
  requiresDocumentContext: true,
893
893
  metadata: mutationOperation({
@@ -895,10 +895,10 @@ var init_operation_definitions = __esm(() => {
895
895
  supportsDryRun: false,
896
896
  supportsTrackedMode: false,
897
897
  possibleFailureCodes: ["NO_OP"],
898
- throws: T_NOT_FOUND_COMMAND
898
+ throws: [...T_NOT_FOUND_COMMAND, "INVALID_INPUT", "INVALID_TARGET"]
899
899
  }),
900
- referenceDocPath: "review/decide.mdx",
901
- referenceGroup: "review"
900
+ referenceDocPath: "track-changes/decide.mdx",
901
+ referenceGroup: "trackChanges"
902
902
  },
903
903
  "query.match": {
904
904
  memberPath: "query.match",
@@ -1580,7 +1580,7 @@ var init_schemas = __esm(() => {
1580
1580
  "format.apply": {
1581
1581
  input: objectSchema({
1582
1582
  target: textAddressSchema,
1583
- marks: (() => {
1583
+ inline: (() => {
1584
1584
  const markProperties = Object.fromEntries(MARK_KEYS.map((key) => [key, { type: "boolean" }]));
1585
1585
  return {
1586
1586
  type: "object",
@@ -1589,7 +1589,7 @@ var init_schemas = __esm(() => {
1589
1589
  minProperties: 1
1590
1590
  };
1591
1591
  })()
1592
- }, ["target", "marks"]),
1592
+ }, ["target", "inline"]),
1593
1593
  output: textMutationResultSchemaFor("format.apply"),
1594
1594
  success: textMutationSuccessSchema,
1595
1595
  failure: textMutationFailureSchemaFor("format.apply")
@@ -1757,7 +1757,7 @@ var init_schemas = __esm(() => {
1757
1757
  input: objectSchema({ id: { type: "string" } }, ["id"]),
1758
1758
  output: trackChangeInfoSchema
1759
1759
  },
1760
- "review.decide": {
1760
+ "trackChanges.decide": {
1761
1761
  input: {
1762
1762
  type: "object",
1763
1763
  properties: {
@@ -1772,9 +1772,9 @@ var init_schemas = __esm(() => {
1772
1772
  required: ["decision", "target"],
1773
1773
  additionalProperties: false
1774
1774
  },
1775
- output: receiptResultSchemaFor("review.decide"),
1775
+ output: receiptResultSchemaFor("trackChanges.decide"),
1776
1776
  success: receiptSuccessSchema,
1777
- failure: receiptFailureResultSchemaFor("review.decide")
1777
+ failure: receiptFailureResultSchemaFor("trackChanges.decide")
1778
1778
  },
1779
1779
  "query.match": {
1780
1780
  input: objectSchema({
@@ -1893,14 +1893,9 @@ var init_reference_doc_map = __esm(() => {
1893
1893
  },
1894
1894
  trackChanges: {
1895
1895
  title: "Track Changes",
1896
- description: "Tracked-change inspection operations.",
1896
+ description: "Tracked-change inspection and review operations.",
1897
1897
  pagePath: "track-changes/index.mdx"
1898
1898
  },
1899
- review: {
1900
- title: "Review",
1901
- description: "Accept or reject tracked changes.",
1902
- pagePath: "review/index.mdx"
1903
- },
1904
1899
  query: {
1905
1900
  title: "Query",
1906
1901
  description: "Deterministic selector-based queries for mutation targeting.",
@@ -1918,6 +1913,9 @@ var init_reference_doc_map = __esm(() => {
1918
1913
  operations: OPERATION_IDS.filter((id) => OPERATION_DEFINITIONS[id].referenceGroup === key)
1919
1914
  }));
1920
1915
  });
1916
+
1917
+ // ../../packages/document-api/src/contract/reference-aliases.ts
1918
+ var init_reference_aliases = () => {};
1921
1919
  // ../../packages/document-api/src/contract/index.ts
1922
1920
  var init_contract = __esm(() => {
1923
1921
  init_types2();
@@ -1925,6 +1923,7 @@ var init_contract = __esm(() => {
1925
1923
  init_schemas();
1926
1924
  init_operation_map();
1927
1925
  init_reference_doc_map();
1926
+ init_reference_aliases();
1928
1927
  });
1929
1928
 
1930
1929
  // ../../packages/document-api/src/capabilities/capabilities.ts
@@ -2017,7 +2016,12 @@ function validateCreateCommentInput(input) {
2017
2016
  }
2018
2017
  return;
2019
2018
  }
2020
- if (hasTarget && !isTextAddress(target)) {
2019
+ if (!hasTarget) {
2020
+ throw new DocumentApiValidationError("INVALID_TARGET", "comments.create requires a target for root comments.", {
2021
+ field: "target"
2022
+ });
2023
+ }
2024
+ if (!isTextAddress(target)) {
2021
2025
  throw new DocumentApiValidationError("INVALID_TARGET", "target must be a text address object.", {
2022
2026
  field: "target",
2023
2027
  value: target
@@ -2037,6 +2041,14 @@ function validatePatchCommentInput(input) {
2037
2041
  value: commentId
2038
2042
  });
2039
2043
  }
2044
+ const mutationFields = ["text", "target", "status", "isInternal"];
2045
+ const providedFields = mutationFields.filter((f) => input[f] !== undefined);
2046
+ if (providedFields.length === 0) {
2047
+ throw new DocumentApiValidationError("INVALID_INPUT", "comments.patch requires exactly one mutation field (text, target, status, or isInternal).", { allowedFields: [...mutationFields] });
2048
+ }
2049
+ if (providedFields.length > 1) {
2050
+ throw new DocumentApiValidationError("INVALID_INPUT", `comments.patch accepts exactly one mutation field per call, got ${providedFields.length}: ${providedFields.join(", ")}.`, { providedFields: [...providedFields] });
2051
+ }
2040
2052
  const { status } = input;
2041
2053
  if (status !== undefined && status !== "resolved") {
2042
2054
  throw new DocumentApiValidationError("INVALID_TARGET", `status must be "resolved", got "${String(status)}".`, {
@@ -2060,20 +2072,19 @@ function executeCommentsCreate(adapter, input, options) {
2060
2072
  }
2061
2073
  function executeCommentsPatch(adapter, input, options) {
2062
2074
  validatePatchCommentInput(input);
2063
- let lastReceipt = { success: true };
2064
2075
  if (input.text !== undefined) {
2065
- lastReceipt = adapter.edit({ commentId: input.commentId, text: input.text }, options);
2076
+ return adapter.edit({ commentId: input.commentId, text: input.text }, options);
2066
2077
  }
2067
2078
  if (input.target !== undefined) {
2068
- lastReceipt = adapter.move({ commentId: input.commentId, target: input.target }, options);
2079
+ return adapter.move({ commentId: input.commentId, target: input.target }, options);
2069
2080
  }
2070
2081
  if (input.status === "resolved") {
2071
- lastReceipt = adapter.resolve({ commentId: input.commentId }, options);
2082
+ return adapter.resolve({ commentId: input.commentId }, options);
2072
2083
  }
2073
2084
  if (input.isInternal !== undefined) {
2074
- lastReceipt = adapter.setInternal({ commentId: input.commentId, isInternal: input.isInternal }, options);
2085
+ return adapter.setInternal({ commentId: input.commentId, isInternal: input.isInternal }, options);
2075
2086
  }
2076
- return lastReceipt;
2087
+ return { success: true };
2077
2088
  }
2078
2089
  function executeCommentsDelete(adapter, input, options) {
2079
2090
  return adapter.remove({ commentId: input.commentId }, options);
@@ -2153,7 +2164,7 @@ function validateStyleApplyInput(input) {
2153
2164
  throw new DocumentApiValidationError("INVALID_INPUT", "format.apply input must be a non-null object.");
2154
2165
  }
2155
2166
  assertNoUnknownFields(input, STYLE_APPLY_INPUT_ALLOWED_KEYS, "format.apply");
2156
- const { target, marks } = input;
2167
+ const { target, inline } = input;
2157
2168
  if (target === undefined) {
2158
2169
  throw new DocumentApiValidationError("INVALID_TARGET", "format.apply requires a target.");
2159
2170
  }
@@ -2163,30 +2174,30 @@ function validateStyleApplyInput(input) {
2163
2174
  value: target
2164
2175
  });
2165
2176
  }
2166
- if (marks === undefined || marks === null) {
2167
- throw new DocumentApiValidationError("INVALID_INPUT", "format.apply requires a marks object.");
2177
+ if (inline === undefined || inline === null) {
2178
+ throw new DocumentApiValidationError("INVALID_INPUT", "format.apply requires an inline object.");
2168
2179
  }
2169
- if (!isRecord(marks)) {
2170
- throw new DocumentApiValidationError("INVALID_INPUT", "marks must be a non-null object.", {
2171
- field: "marks",
2172
- value: marks
2180
+ if (!isRecord(inline)) {
2181
+ throw new DocumentApiValidationError("INVALID_INPUT", "inline must be a non-null object.", {
2182
+ field: "inline",
2183
+ value: inline
2173
2184
  });
2174
2185
  }
2175
- const markKeys = Object.keys(marks);
2176
- if (markKeys.length === 0) {
2177
- throw new DocumentApiValidationError("INVALID_INPUT", "marks must include at least one known key.");
2186
+ const inlineKeys = Object.keys(inline);
2187
+ if (inlineKeys.length === 0) {
2188
+ throw new DocumentApiValidationError("INVALID_INPUT", "inline must include at least one known key.");
2178
2189
  }
2179
- for (const key of markKeys) {
2190
+ for (const key of inlineKeys) {
2180
2191
  if (!MARK_KEY_SET.has(key)) {
2181
- throw new DocumentApiValidationError("INVALID_INPUT", `Unknown mark key "${key}". Known keys: bold, italic, underline, strike.`, {
2182
- field: "marks",
2192
+ throw new DocumentApiValidationError("INVALID_INPUT", `Unknown inline style key "${key}". Known keys: bold, italic, underline, strike.`, {
2193
+ field: "inline",
2183
2194
  key
2184
2195
  });
2185
2196
  }
2186
- const value = marks[key];
2197
+ const value = inline[key];
2187
2198
  if (typeof value !== "boolean") {
2188
- throw new DocumentApiValidationError("INVALID_INPUT", `Mark "${key}" must be a boolean, got ${typeof value}.`, {
2189
- field: "marks",
2199
+ throw new DocumentApiValidationError("INVALID_INPUT", `Inline style "${key}" must be a boolean, got ${typeof value}.`, {
2200
+ field: "inline",
2190
2201
  key,
2191
2202
  value
2192
2203
  });
@@ -2202,7 +2213,7 @@ var init_format = __esm(() => {
2202
2213
  init_style_policy_types();
2203
2214
  init_errors2();
2204
2215
  init_validation_primitives();
2205
- STYLE_APPLY_INPUT_ALLOWED_KEYS = new Set(["target", "marks"]);
2216
+ STYLE_APPLY_INPUT_ALLOWED_KEYS = new Set(["target", "inline"]);
2206
2217
  });
2207
2218
 
2208
2219
  // ../../packages/document-api/src/get-node/get-node.ts
@@ -2429,17 +2440,39 @@ function executeTrackChangesList(adapter, input) {
2429
2440
  function executeTrackChangesGet(adapter, input) {
2430
2441
  return adapter.get(input);
2431
2442
  }
2432
- function executeReviewDecide(adapter, input, options) {
2433
- const isAll = "scope" in input.target && input.target.scope === "all";
2443
+ function executeTrackChangesDecide(adapter, rawInput, options) {
2444
+ const raw = rawInput;
2445
+ if (typeof raw !== "object" || raw == null) {
2446
+ throw new DocumentApiValidationError("INVALID_INPUT", "trackChanges.decide input must be a non-null object.", {
2447
+ value: raw
2448
+ });
2449
+ }
2450
+ const input = raw;
2451
+ if (input.decision !== "accept" && input.decision !== "reject") {
2452
+ throw new DocumentApiValidationError("INVALID_INPUT", `trackChanges.decide decision must be "accept" or "reject", got "${String(input.decision)}".`, { field: "decision", value: input.decision });
2453
+ }
2454
+ if (typeof input.target !== "object" || input.target == null) {
2455
+ throw new DocumentApiValidationError("INVALID_TARGET", 'trackChanges.decide target must be an object with { id: string } or { scope: "all" }.', { field: "target", value: input.target });
2456
+ }
2457
+ const target = input.target;
2458
+ const isAll = target.scope === "all";
2459
+ if (!isAll) {
2460
+ if (typeof target.id !== "string" || target.id.length === 0) {
2461
+ throw new DocumentApiValidationError("INVALID_TARGET", 'trackChanges.decide target must have { id: string } or { scope: "all" }.', { field: "target", value: input.target });
2462
+ }
2463
+ }
2434
2464
  if (input.decision === "accept") {
2435
2465
  if (isAll)
2436
2466
  return adapter.acceptAll({}, options);
2437
- return adapter.accept({ id: input.target.id }, options);
2467
+ return adapter.accept({ id: target.id }, options);
2438
2468
  }
2439
2469
  if (isAll)
2440
2470
  return adapter.rejectAll({}, options);
2441
- return adapter.reject({ id: input.target.id }, options);
2471
+ return adapter.reject({ id: target.id }, options);
2442
2472
  }
2473
+ var init_track_changes = __esm(() => {
2474
+ init_errors2();
2475
+ });
2443
2476
 
2444
2477
  // ../../packages/document-api/src/invoke/invoke.ts
2445
2478
  function buildDispatchTable(api) {
@@ -2470,7 +2503,7 @@ function buildDispatchTable(api) {
2470
2503
  "comments.list": (input) => api.comments.list(input),
2471
2504
  "trackChanges.list": (input) => api.trackChanges.list(input),
2472
2505
  "trackChanges.get": (input) => api.trackChanges.get(input),
2473
- "review.decide": (input, options) => api.review.decide(input, options),
2506
+ "trackChanges.decide": (input, options) => api.trackChanges.decide(input, options),
2474
2507
  "query.match": (input) => api.query.match(input),
2475
2508
  "mutations.preview": (input) => api.mutations.preview(input),
2476
2509
  "mutations.apply": (input) => api.mutations.apply(input),
@@ -2533,16 +2566,16 @@ function createDocumentApi(adapters) {
2533
2566
  },
2534
2567
  format: {
2535
2568
  bold(input, options) {
2536
- return executeStyleApply(adapters.format, { ...input, marks: { bold: true } }, options);
2569
+ return executeStyleApply(adapters.format, { ...input, inline: { bold: true } }, options);
2537
2570
  },
2538
2571
  italic(input, options) {
2539
- return executeStyleApply(adapters.format, { ...input, marks: { italic: true } }, options);
2572
+ return executeStyleApply(adapters.format, { ...input, inline: { italic: true } }, options);
2540
2573
  },
2541
2574
  underline(input, options) {
2542
- return executeStyleApply(adapters.format, { ...input, marks: { underline: true } }, options);
2575
+ return executeStyleApply(adapters.format, { ...input, inline: { underline: true } }, options);
2543
2576
  },
2544
2577
  strikethrough(input, options) {
2545
- return executeStyleApply(adapters.format, { ...input, marks: { strike: true } }, options);
2578
+ return executeStyleApply(adapters.format, { ...input, inline: { strike: true } }, options);
2546
2579
  },
2547
2580
  apply(input, options) {
2548
2581
  return executeStyleApply(adapters.format, input, options);
@@ -2554,11 +2587,9 @@ function createDocumentApi(adapters) {
2554
2587
  },
2555
2588
  get(input) {
2556
2589
  return executeTrackChangesGet(adapters.trackChanges, input);
2557
- }
2558
- },
2559
- review: {
2590
+ },
2560
2591
  decide(input, options) {
2561
- return executeReviewDecide(adapters.trackChanges, input, options);
2592
+ return executeTrackChangesDecide(adapters.trackChanges, input, options);
2562
2593
  }
2563
2594
  },
2564
2595
  create: {
@@ -2628,6 +2659,7 @@ var init_src = __esm(() => {
2628
2659
  init_lists();
2629
2660
  init_replace();
2630
2661
  init_create();
2662
+ init_track_changes();
2631
2663
  init_capabilities();
2632
2664
  init_lists_types();
2633
2665
  init_errors2();
@@ -3278,7 +3310,7 @@ var init_operation_hints = __esm(() => {
3278
3310
  "comments.list": "listed comments",
3279
3311
  "trackChanges.list": "listed tracked changes",
3280
3312
  "trackChanges.get": "resolved tracked change",
3281
- "review.decide": "reviewed tracked change",
3313
+ "trackChanges.decide": "reviewed tracked change",
3282
3314
  "query.match": "matched selectors",
3283
3315
  "mutations.preview": "previewed mutations",
3284
3316
  "mutations.apply": "applied mutations",
@@ -3311,7 +3343,7 @@ var init_operation_hints = __esm(() => {
3311
3343
  "comments.list": "commentList",
3312
3344
  "trackChanges.list": "trackChangeList",
3313
3345
  "trackChanges.get": "trackChangeInfo",
3314
- "review.decide": "trackChangeMutationReceipt",
3346
+ "trackChanges.decide": "trackChangeMutationReceipt",
3315
3347
  "query.match": "plain",
3316
3348
  "mutations.preview": "plain",
3317
3349
  "mutations.apply": "plain",
@@ -3344,7 +3376,7 @@ var init_operation_hints = __esm(() => {
3344
3376
  "comments.list": "result",
3345
3377
  "trackChanges.list": "result",
3346
3378
  "trackChanges.get": "change",
3347
- "review.decide": "receipt",
3379
+ "trackChanges.decide": "receipt",
3348
3380
  "query.match": "result",
3349
3381
  "mutations.preview": "result",
3350
3382
  "mutations.apply": "result",
@@ -3383,7 +3415,7 @@ var init_operation_hints = __esm(() => {
3383
3415
  "comments.list": "comments",
3384
3416
  "trackChanges.list": "trackChanges",
3385
3417
  "trackChanges.get": "trackChanges",
3386
- "review.decide": "trackChanges",
3418
+ "trackChanges.decide": "trackChanges",
3387
3419
  "query.match": "query",
3388
3420
  "mutations.preview": "general",
3389
3421
  "mutations.apply": "general",
@@ -3695,8 +3727,6 @@ function deriveCategoryFromDocApi(docApiId) {
3695
3727
  if (group === "core" || group === "mutations") {
3696
3728
  return COMMAND_CATALOG[docApiId].mutates ? "mutation" : "query";
3697
3729
  }
3698
- if (group === "review")
3699
- return "trackChanges";
3700
3730
  return group;
3701
3731
  }
3702
3732
  function cliCategory(cliOpId) {
@@ -18015,7 +18045,7 @@ var init_constants_DBKi0Amm_es = __esm(() => {
18015
18045
  ]);
18016
18046
  });
18017
18047
 
18018
- // ../../packages/superdoc/dist/chunks/SuperConverter-D9XMPi6H.es.js
18048
+ // ../../packages/superdoc/dist/chunks/SuperConverter-Cf1y7bFA.es.js
18019
18049
  function getExtensionConfigField(extension, field, context = { name: "" }) {
18020
18050
  const fieldValue = extension.config[field];
18021
18051
  if (typeof fieldValue === "function")
@@ -35250,6 +35280,16 @@ var isRegExp = (value) => {
35250
35280
  i2++;
35251
35281
  continue;
35252
35282
  }
35283
+ const childElements = node2.elements || [];
35284
+ if (childElements.length > 0) {
35285
+ for (const child of childElements) {
35286
+ if (Array.isArray(child.elements))
35287
+ child.elements = preProcessPageFieldsOnly(child.elements, depth + 1).processedNodes;
35288
+ processedNodes.push(child);
35289
+ }
35290
+ i2++;
35291
+ continue;
35292
+ }
35253
35293
  }
35254
35294
  if (fldType === "begin") {
35255
35295
  const fieldInfo = scanFieldSequence(nodes, i2);
@@ -35271,6 +35311,12 @@ var isRegExp = (value) => {
35271
35311
  continue;
35272
35312
  }
35273
35313
  }
35314
+ if (node2.name === "w:r" && node2.elements?.some((el) => el.name === "w:pgNum")) {
35315
+ const processedField = preProcessPageInstruction([], "", node2.elements.find((el) => el.name === "w:rPr") || null);
35316
+ processedNodes.push(...processedField);
35317
+ i2++;
35318
+ continue;
35319
+ }
35274
35320
  if (Array.isArray(node2.elements))
35275
35321
  node2.elements = preProcessPageFieldsOnly(node2.elements, depth + 1).processedNodes;
35276
35322
  processedNodes.push(node2);
@@ -41750,7 +41796,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
41750
41796
  state.kern = kernNode.attributes["w:val"];
41751
41797
  }
41752
41798
  }, SuperConverter;
41753
- var init_SuperConverter_D9XMPi6H_es = __esm(() => {
41799
+ var init_SuperConverter_Cf1y7bFA_es = __esm(() => {
41754
41800
  init_rolldown_runtime_B2q5OVn9_es();
41755
41801
  init_jszip_ChlR43oI_es();
41756
41802
  init_xml_js_DLE8mr0n_es();
@@ -87138,9 +87184,9 @@ var init_remark_gfm_RDxetNVS_es = __esm(() => {
87138
87184
  emptyOptions4 = {};
87139
87185
  });
87140
87186
 
87141
- // ../../packages/superdoc/dist/chunks/src-0vZP1_ru.es.js
87142
- var exports_src_0vZP1_ru_es = {};
87143
- __export(exports_src_0vZP1_ru_es, {
87187
+ // ../../packages/superdoc/dist/chunks/src-eL3w4G7e.es.js
87188
+ var exports_src_eL3w4G7e_es = {};
87189
+ __export(exports_src_eL3w4G7e_es, {
87144
87190
  zt: () => defineMark,
87145
87191
  z: () => cM,
87146
87192
  yt: () => removeAwarenessStates,
@@ -93916,7 +93962,9 @@ function validateCreateCommentInput2(input2) {
93916
93962
  throw new DocumentApiValidationError2("INVALID_TARGET", "Cannot combine parentCommentId with target. Replies do not take a target.", { fields: ["parentCommentId", "target"] });
93917
93963
  return;
93918
93964
  }
93919
- if (hasTarget && !isTextAddress2(target))
93965
+ if (!hasTarget)
93966
+ throw new DocumentApiValidationError2("INVALID_TARGET", "comments.create requires a target for root comments.", { field: "target" });
93967
+ if (!isTextAddress2(target))
93920
93968
  throw new DocumentApiValidationError2("INVALID_TARGET", "target must be a text address object.", {
93921
93969
  field: "target",
93922
93970
  value: target
@@ -93933,6 +93981,17 @@ function validatePatchCommentInput2(input2) {
93933
93981
  field: "commentId",
93934
93982
  value: commentId
93935
93983
  });
93984
+ const mutationFields = [
93985
+ "text",
93986
+ "target",
93987
+ "status",
93988
+ "isInternal"
93989
+ ];
93990
+ const providedFields = mutationFields.filter((f) => input2[f] !== undefined);
93991
+ if (providedFields.length === 0)
93992
+ throw new DocumentApiValidationError2("INVALID_INPUT", "comments.patch requires exactly one mutation field (text, target, status, or isInternal).", { allowedFields: [...mutationFields] });
93993
+ if (providedFields.length > 1)
93994
+ throw new DocumentApiValidationError2("INVALID_INPUT", `comments.patch accepts exactly one mutation field per call, got ${providedFields.length}: ${providedFields.join(", ")}.`, { providedFields: [...providedFields] });
93936
93995
  const { status } = input2;
93937
93996
  if (status !== undefined && status !== "resolved")
93938
93997
  throw new DocumentApiValidationError2("INVALID_TARGET", `status must be "resolved", got "${String(status)}".`, {
@@ -93956,25 +94015,24 @@ function executeCommentsCreate2(adapter, input2, options) {
93956
94015
  }
93957
94016
  function executeCommentsPatch2(adapter, input2, options) {
93958
94017
  validatePatchCommentInput2(input2);
93959
- let lastReceipt = { success: true };
93960
94018
  if (input2.text !== undefined)
93961
- lastReceipt = adapter.edit({
94019
+ return adapter.edit({
93962
94020
  commentId: input2.commentId,
93963
94021
  text: input2.text
93964
94022
  }, options);
93965
94023
  if (input2.target !== undefined)
93966
- lastReceipt = adapter.move({
94024
+ return adapter.move({
93967
94025
  commentId: input2.commentId,
93968
94026
  target: input2.target
93969
94027
  }, options);
93970
94028
  if (input2.status === "resolved")
93971
- lastReceipt = adapter.resolve({ commentId: input2.commentId }, options);
94029
+ return adapter.resolve({ commentId: input2.commentId }, options);
93972
94030
  if (input2.isInternal !== undefined)
93973
- lastReceipt = adapter.setInternal({
94031
+ return adapter.setInternal({
93974
94032
  commentId: input2.commentId,
93975
94033
  isInternal: input2.isInternal
93976
94034
  }, options);
93977
- return lastReceipt;
94035
+ return { success: true };
93978
94036
  }
93979
94037
  function executeCommentsDelete2(adapter, input2, options) {
93980
94038
  return adapter.remove({ commentId: input2.commentId }, options);
@@ -94045,7 +94103,7 @@ function validateStyleApplyInput2(input2) {
94045
94103
  if (!isRecord3(input2))
94046
94104
  throw new DocumentApiValidationError2("INVALID_INPUT", "format.apply input must be a non-null object.");
94047
94105
  assertNoUnknownFields2(input2, STYLE_APPLY_INPUT_ALLOWED_KEYS2, "format.apply");
94048
- const { target, marks } = input2;
94106
+ const { target, inline } = input2;
94049
94107
  if (target === undefined)
94050
94108
  throw new DocumentApiValidationError2("INVALID_TARGET", "format.apply requires a target.");
94051
94109
  if (!isTextAddress2(target))
@@ -94053,26 +94111,26 @@ function validateStyleApplyInput2(input2) {
94053
94111
  field: "target",
94054
94112
  value: target
94055
94113
  });
94056
- if (marks === undefined || marks === null)
94057
- throw new DocumentApiValidationError2("INVALID_INPUT", "format.apply requires a marks object.");
94058
- if (!isRecord3(marks))
94059
- throw new DocumentApiValidationError2("INVALID_INPUT", "marks must be a non-null object.", {
94060
- field: "marks",
94061
- value: marks
94062
- });
94063
- const markKeys$1 = Object.keys(marks);
94064
- if (markKeys$1.length === 0)
94065
- throw new DocumentApiValidationError2("INVALID_INPUT", "marks must include at least one known key.");
94066
- for (const key$1 of markKeys$1) {
94114
+ if (inline === undefined || inline === null)
94115
+ throw new DocumentApiValidationError2("INVALID_INPUT", "format.apply requires an inline object.");
94116
+ if (!isRecord3(inline))
94117
+ throw new DocumentApiValidationError2("INVALID_INPUT", "inline must be a non-null object.", {
94118
+ field: "inline",
94119
+ value: inline
94120
+ });
94121
+ const inlineKeys = Object.keys(inline);
94122
+ if (inlineKeys.length === 0)
94123
+ throw new DocumentApiValidationError2("INVALID_INPUT", "inline must include at least one known key.");
94124
+ for (const key$1 of inlineKeys) {
94067
94125
  if (!MARK_KEY_SET2.has(key$1))
94068
- throw new DocumentApiValidationError2("INVALID_INPUT", `Unknown mark key "${key$1}". Known keys: bold, italic, underline, strike.`, {
94069
- field: "marks",
94126
+ throw new DocumentApiValidationError2("INVALID_INPUT", `Unknown inline style key "${key$1}". Known keys: bold, italic, underline, strike.`, {
94127
+ field: "inline",
94070
94128
  key: key$1
94071
94129
  });
94072
- const value = marks[key$1];
94130
+ const value = inline[key$1];
94073
94131
  if (typeof value !== "boolean")
94074
- throw new DocumentApiValidationError2("INVALID_INPUT", `Mark "${key$1}" must be a boolean, got ${typeof value}.`, {
94075
- field: "marks",
94132
+ throw new DocumentApiValidationError2("INVALID_INPUT", `Inline style "${key$1}" must be a boolean, got ${typeof value}.`, {
94133
+ field: "inline",
94076
94134
  key: key$1,
94077
94135
  value
94078
94136
  });
@@ -94263,16 +94321,38 @@ function executeTrackChangesList2(adapter, input2) {
94263
94321
  function executeTrackChangesGet2(adapter, input2) {
94264
94322
  return adapter.get(input2);
94265
94323
  }
94266
- function executeReviewDecide2(adapter, input2, options) {
94267
- const isAll = "scope" in input2.target && input2.target.scope === "all";
94324
+ function executeTrackChangesDecide2(adapter, rawInput, options) {
94325
+ const raw = rawInput;
94326
+ if (typeof raw !== "object" || raw == null)
94327
+ throw new DocumentApiValidationError2("INVALID_INPUT", "trackChanges.decide input must be a non-null object.", { value: raw });
94328
+ const input2 = raw;
94329
+ if (input2.decision !== "accept" && input2.decision !== "reject")
94330
+ throw new DocumentApiValidationError2("INVALID_INPUT", `trackChanges.decide decision must be "accept" or "reject", got "${String(input2.decision)}".`, {
94331
+ field: "decision",
94332
+ value: input2.decision
94333
+ });
94334
+ if (typeof input2.target !== "object" || input2.target == null)
94335
+ throw new DocumentApiValidationError2("INVALID_TARGET", 'trackChanges.decide target must be an object with { id: string } or { scope: "all" }.', {
94336
+ field: "target",
94337
+ value: input2.target
94338
+ });
94339
+ const target = input2.target;
94340
+ const isAll = target.scope === "all";
94341
+ if (!isAll) {
94342
+ if (typeof target.id !== "string" || target.id.length === 0)
94343
+ throw new DocumentApiValidationError2("INVALID_TARGET", 'trackChanges.decide target must have { id: string } or { scope: "all" }.', {
94344
+ field: "target",
94345
+ value: input2.target
94346
+ });
94347
+ }
94268
94348
  if (input2.decision === "accept") {
94269
94349
  if (isAll)
94270
94350
  return adapter.acceptAll({}, options);
94271
- return adapter.accept({ id: input2.target.id }, options);
94351
+ return adapter.accept({ id: target.id }, options);
94272
94352
  }
94273
94353
  if (isAll)
94274
94354
  return adapter.rejectAll({}, options);
94275
- return adapter.reject({ id: input2.target.id }, options);
94355
+ return adapter.reject({ id: target.id }, options);
94276
94356
  }
94277
94357
  function buildDispatchTable2(api) {
94278
94358
  return {
@@ -94302,7 +94382,7 @@ function buildDispatchTable2(api) {
94302
94382
  "comments.list": (input2) => api.comments.list(input2),
94303
94383
  "trackChanges.list": (input2) => api.trackChanges.list(input2),
94304
94384
  "trackChanges.get": (input2) => api.trackChanges.get(input2),
94305
- "review.decide": (input2, options) => api.review.decide(input2, options),
94385
+ "trackChanges.decide": (input2, options) => api.trackChanges.decide(input2, options),
94306
94386
  "query.match": (input2) => api.query.match(input2),
94307
94387
  "mutations.preview": (input2) => api.mutations.preview(input2),
94308
94388
  "mutations.apply": (input2) => api.mutations.apply(input2),
@@ -94357,25 +94437,25 @@ function createDocumentApi2(adapters) {
94357
94437
  bold(input2, options) {
94358
94438
  return executeStyleApply$1(adapters.format, {
94359
94439
  ...input2,
94360
- marks: { bold: true }
94440
+ inline: { bold: true }
94361
94441
  }, options);
94362
94442
  },
94363
94443
  italic(input2, options) {
94364
94444
  return executeStyleApply$1(adapters.format, {
94365
94445
  ...input2,
94366
- marks: { italic: true }
94446
+ inline: { italic: true }
94367
94447
  }, options);
94368
94448
  },
94369
94449
  underline(input2, options) {
94370
94450
  return executeStyleApply$1(adapters.format, {
94371
94451
  ...input2,
94372
- marks: { underline: true }
94452
+ inline: { underline: true }
94373
94453
  }, options);
94374
94454
  },
94375
94455
  strikethrough(input2, options) {
94376
94456
  return executeStyleApply$1(adapters.format, {
94377
94457
  ...input2,
94378
- marks: { strike: true }
94458
+ inline: { strike: true }
94379
94459
  }, options);
94380
94460
  },
94381
94461
  apply(input2, options) {
@@ -94388,11 +94468,11 @@ function createDocumentApi2(adapters) {
94388
94468
  },
94389
94469
  get(input2) {
94390
94470
  return executeTrackChangesGet2(adapters.trackChanges, input2);
94471
+ },
94472
+ decide(input2, options) {
94473
+ return executeTrackChangesDecide2(adapters.trackChanges, input2, options);
94391
94474
  }
94392
94475
  },
94393
- review: { decide(input2, options) {
94394
- return executeReviewDecide2(adapters.trackChanges, input2, options);
94395
- } },
94396
94476
  create: {
94397
94477
  paragraph(input2, options) {
94398
94478
  return executeCreateParagraph2(adapters.create, input2, options);
@@ -96392,22 +96472,22 @@ function executeStyleApply2(editor, tr, target, step, mapping) {
96392
96472
  const markEntries = [
96393
96473
  [
96394
96474
  "bold",
96395
- step.args.marks.bold,
96475
+ step.args.inline.bold,
96396
96476
  schema.marks.bold
96397
96477
  ],
96398
96478
  [
96399
96479
  "italic",
96400
- step.args.marks.italic,
96480
+ step.args.inline.italic,
96401
96481
  schema.marks.italic
96402
96482
  ],
96403
96483
  [
96404
96484
  "underline",
96405
- step.args.marks.underline,
96485
+ step.args.inline.underline,
96406
96486
  schema.marks.underline
96407
96487
  ],
96408
96488
  [
96409
96489
  "strike",
96410
- step.args.marks.strike,
96490
+ step.args.inline.strike,
96411
96491
  schema.marks.strike
96412
96492
  ]
96413
96493
  ];
@@ -96495,22 +96575,22 @@ function executeSpanStyleApply(editor, tr, target, step, mapping) {
96495
96575
  const markEntries = [
96496
96576
  [
96497
96577
  "bold",
96498
- step.args.marks.bold,
96578
+ step.args.inline.bold,
96499
96579
  schema.marks.bold
96500
96580
  ],
96501
96581
  [
96502
96582
  "italic",
96503
- step.args.marks.italic,
96583
+ step.args.inline.italic,
96504
96584
  schema.marks.italic
96505
96585
  ],
96506
96586
  [
96507
96587
  "underline",
96508
- step.args.marks.underline,
96588
+ step.args.inline.underline,
96509
96589
  schema.marks.underline
96510
96590
  ],
96511
96591
  [
96512
96592
  "strike",
96513
- step.args.marks.strike,
96593
+ step.args.inline.strike,
96514
96594
  schema.marks.strike
96515
96595
  ]
96516
96596
  ];
@@ -97155,7 +97235,7 @@ function styleApplyWrapper(editor, input2, options) {
97155
97235
  message: "format.apply requires a non-collapsed target range."
97156
97236
  }
97157
97237
  };
97158
- const markKeys$1 = Object.keys(input2.marks).filter((k$1) => input2.marks[k$1] !== undefined);
97238
+ const markKeys$1 = Object.keys(input2.inline).filter((k$1) => input2.inline[k$1] !== undefined);
97159
97239
  for (const key$1 of markKeys$1) {
97160
97240
  const schemaName = MARK_KEY_TO_SCHEMA_NAME[key$1];
97161
97241
  if (schemaName)
@@ -97179,7 +97259,7 @@ function styleApplyWrapper(editor, input2, options) {
97179
97259
  id: stepId,
97180
97260
  op: "format.apply",
97181
97261
  where: STUB_WHERE,
97182
- args: { marks: input2.marks }
97262
+ args: { inline: input2.inline }
97183
97263
  },
97184
97264
  targets: [{
97185
97265
  kind: "range",
@@ -107021,24 +107101,26 @@ function normalizeClientPoint(options, clientX, clientY) {
107021
107101
  const baseX = (clientX - rect.left + scrollLeft) / options.zoom;
107022
107102
  const baseY = (clientY - rect.top + scrollTop) / options.zoom;
107023
107103
  let adjustedX = baseX;
107024
- let adjustedY = baseY;
107104
+ let detectedPageIndex;
107105
+ let pageLocalY;
107025
107106
  const doc$2 = options.visibleHost.ownerDocument ?? document;
107026
107107
  const hitChain = typeof doc$2.elementsFromPoint === "function" ? doc$2.elementsFromPoint(clientX, clientY) : [];
107027
107108
  const pageEl = Array.isArray(hitChain) ? hitChain.find((el) => el?.classList?.contains("superdoc-page")) : null;
107028
107109
  if (pageEl) {
107029
107110
  const pageIndex = Number(pageEl.dataset.pageIndex ?? "NaN");
107030
107111
  if (Number.isFinite(pageIndex)) {
107112
+ detectedPageIndex = pageIndex;
107031
107113
  const pageOffsetX = options.getPageOffsetX(pageIndex);
107032
107114
  if (pageOffsetX != null)
107033
107115
  adjustedX = baseX - pageOffsetX;
107034
- const pageOffsetY = options.getPageOffsetY(pageIndex);
107035
- if (pageOffsetY != null)
107036
- adjustedY = baseY - pageOffsetY;
107116
+ pageLocalY = (clientY - pageEl.getBoundingClientRect().top) / options.zoom;
107037
107117
  }
107038
107118
  }
107039
107119
  return {
107040
107120
  x: adjustedX,
107041
- y: adjustedY
107121
+ y: baseY,
107122
+ pageIndex: detectedPageIndex,
107123
+ pageLocalY
107042
107124
  };
107043
107125
  }
107044
107126
  function denormalizeClientPoint(options, layoutX, layoutY, pageIndex, height) {
@@ -107410,7 +107492,9 @@ function publishSectionMetadata(sectionRanges, options) {
107410
107492
  footerRefs: section.footerRefs,
107411
107493
  numbering: section.numbering,
107412
107494
  titlePg: section.titlePg,
107413
- vAlign: section.vAlign
107495
+ vAlign: section.vAlign,
107496
+ margins: section.margins,
107497
+ pageSize: section.pageSize
107414
107498
  });
107415
107499
  });
107416
107500
  }
@@ -116191,6 +116275,84 @@ async function measureListBlock(block, constraints) {
116191
116275
  totalHeight
116192
116276
  };
116193
116277
  }
116278
+ function buildSectionContentWidth(section, fallback) {
116279
+ const pageW = section.pageSize?.w ?? fallback.pageWidth;
116280
+ const marginL = section.margins?.left ?? fallback.margins.left;
116281
+ const marginR = section.margins?.right ?? fallback.margins.right;
116282
+ return pageW - marginL - marginR;
116283
+ }
116284
+ function buildConstraintsForSection(section, fallback, minWidth) {
116285
+ const pageW = section.pageSize?.w ?? fallback.pageWidth;
116286
+ const marginL = section.margins?.left ?? fallback.margins.left;
116287
+ const marginR = section.margins?.right ?? fallback.margins.right;
116288
+ const contentWidth = pageW - marginL - marginR;
116289
+ const maxWidth = pageW - marginL;
116290
+ return {
116291
+ width: minWidth ? Math.min(Math.max(contentWidth, minWidth), maxWidth) : contentWidth,
116292
+ height: fallback.height,
116293
+ pageWidth: pageW,
116294
+ margins: {
116295
+ left: marginL,
116296
+ right: marginR
116297
+ }
116298
+ };
116299
+ }
116300
+ function getTableWidthSpec(blocks2) {
116301
+ let result;
116302
+ let maxResolvedWidth = 0;
116303
+ for (const block of blocks2) {
116304
+ if (block.kind !== "table")
116305
+ continue;
116306
+ const tableWidth = block.attrs?.tableWidth;
116307
+ const widthValue = tableWidth?.width ?? tableWidth?.value;
116308
+ if (tableWidth?.type === "pct" && typeof widthValue === "number" && widthValue > 0) {
116309
+ if (!result || result.type !== "pct" || widthValue > result.value) {
116310
+ result = {
116311
+ type: "pct",
116312
+ value: widthValue
116313
+ };
116314
+ maxResolvedWidth = Infinity;
116315
+ }
116316
+ } else if ((tableWidth?.type === "px" || tableWidth?.type === "pixel") && typeof widthValue === "number") {
116317
+ if (widthValue > maxResolvedWidth) {
116318
+ maxResolvedWidth = widthValue;
116319
+ result = {
116320
+ type: "px",
116321
+ value: widthValue
116322
+ };
116323
+ }
116324
+ } else if (block.columnWidths && block.columnWidths.length > 0) {
116325
+ const gridTotal = block.columnWidths.reduce((sum, w2) => sum + w2, 0);
116326
+ if (gridTotal > maxResolvedWidth) {
116327
+ maxResolvedWidth = gridTotal;
116328
+ result = {
116329
+ type: "grid",
116330
+ value: gridTotal
116331
+ };
116332
+ }
116333
+ }
116334
+ }
116335
+ return result;
116336
+ }
116337
+ function resolveTableMinWidth(spec, contentWidth) {
116338
+ if (!spec)
116339
+ return 0;
116340
+ if (spec.type === "pct")
116341
+ return contentWidth * (spec.value / OOXML_PCT_DIVISOR);
116342
+ return spec.value;
116343
+ }
116344
+ function resolveRIdPerSection(sectionMetadata, kind) {
116345
+ const result = /* @__PURE__ */ new Map;
116346
+ let inherited;
116347
+ for (const section of sectionMetadata) {
116348
+ const rId = (kind === "header" ? section.headerRefs : section.footerRefs)?.default;
116349
+ if (rId)
116350
+ inherited = rId;
116351
+ if (inherited)
116352
+ result.set(section.sectionIndex, inherited);
116353
+ }
116354
+ return result;
116355
+ }
116194
116356
  async function layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetadata, deps) {
116195
116357
  deps.headerLayoutsByRId.clear();
116196
116358
  deps.footerLayoutsByRId.clear();
@@ -116205,42 +116367,127 @@ async function layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetad
116205
116367
  totalPages
116206
116368
  };
116207
116369
  };
116208
- if (headerBlocksByRId)
116209
- for (const [rId, blocks2] of headerBlocksByRId) {
116210
- if (!blocks2 || blocks2.length === 0)
116211
- continue;
116212
- try {
116213
- const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, (block, c$3) => measureBlock(block, c$3), undefined, undefined, pageResolver);
116214
- if (batchResult.default)
116215
- deps.headerLayoutsByRId.set(rId, {
116216
- kind: "header",
116217
- type: "default",
116218
- layout: batchResult.default.layout,
116219
- blocks: batchResult.default.blocks,
116220
- measures: batchResult.default.measures
116221
- });
116222
- } catch (error) {
116223
- console.warn(`[PresentationEditor] Failed to layout header rId=${rId}:`, error);
116224
- }
116370
+ if (sectionMetadata.length > 1 && sectionMetadata.some((s2) => s2.margins || s2.pageSize)) {
116371
+ await layoutWithPerSectionConstraints("header", headerBlocksByRId, sectionMetadata, constraints, pageResolver, deps.headerLayoutsByRId);
116372
+ await layoutWithPerSectionConstraints("footer", footerBlocksByRId, sectionMetadata, constraints, pageResolver, deps.footerLayoutsByRId);
116373
+ } else {
116374
+ await layoutBlocksByRId("header", headerBlocksByRId, constraints, pageResolver, deps.headerLayoutsByRId);
116375
+ await layoutBlocksByRId("footer", footerBlocksByRId, constraints, pageResolver, deps.footerLayoutsByRId);
116376
+ }
116377
+ }
116378
+ async function layoutBlocksByRId(kind, blocksByRId, constraints, pageResolver, layoutsByRId) {
116379
+ if (!blocksByRId)
116380
+ return;
116381
+ for (const [rId, blocks2] of blocksByRId) {
116382
+ if (!blocks2 || blocks2.length === 0)
116383
+ continue;
116384
+ try {
116385
+ const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, (block, c$3) => measureBlock(block, c$3), undefined, undefined, pageResolver);
116386
+ if (batchResult.default)
116387
+ layoutsByRId.set(rId, {
116388
+ kind,
116389
+ type: "default",
116390
+ layout: batchResult.default.layout,
116391
+ blocks: batchResult.default.blocks,
116392
+ measures: batchResult.default.measures
116393
+ });
116394
+ } catch (error) {
116395
+ console.warn(`[PresentationEditor] Failed to layout ${kind} rId=${rId}:`, error);
116225
116396
  }
116226
- if (footerBlocksByRId)
116227
- for (const [rId, blocks2] of footerBlocksByRId) {
116228
- if (!blocks2 || blocks2.length === 0)
116397
+ }
116398
+ }
116399
+ function cloneHeaderFooterLayout(layout) {
116400
+ return {
116401
+ ...layout,
116402
+ pages: layout.pages.map((page) => ({
116403
+ ...page,
116404
+ fragments: page.fragments.map((f) => ({ ...f }))
116405
+ }))
116406
+ };
116407
+ }
116408
+ function adjustFramePositionsForContentWidth(layout, blocks2, effectiveWidth, contentWidth) {
116409
+ if (effectiveWidth <= contentWidth)
116410
+ return;
116411
+ const widthDiff = effectiveWidth - contentWidth;
116412
+ const blockById = /* @__PURE__ */ new Map;
116413
+ for (const block of blocks2)
116414
+ blockById.set(block.id, block);
116415
+ for (const page of layout.pages)
116416
+ for (const fragment of page.fragments) {
116417
+ if (fragment.kind !== "para")
116229
116418
  continue;
116230
- try {
116231
- const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, (block, c$3) => measureBlock(block, c$3), undefined, undefined, pageResolver);
116232
- if (batchResult.default)
116233
- deps.footerLayoutsByRId.set(rId, {
116234
- kind: "footer",
116419
+ const block = blockById.get(fragment.blockId);
116420
+ if (!block || block.kind !== "paragraph")
116421
+ continue;
116422
+ const frame = block.attrs?.frame;
116423
+ if (!frame || frame.wrap !== "none")
116424
+ continue;
116425
+ if (frame.xAlign === "right")
116426
+ fragment.x -= widthDiff;
116427
+ else if (frame.xAlign === "center")
116428
+ fragment.x -= widthDiff / 2;
116429
+ }
116430
+ }
116431
+ async function layoutWithPerSectionConstraints(kind, blocksByRId, sectionMetadata, fallbackConstraints, pageResolver, layoutsByRId) {
116432
+ if (!blocksByRId)
116433
+ return;
116434
+ const rIdPerSection = resolveRIdPerSection(sectionMetadata, kind);
116435
+ const tableWidthSpecByRId = /* @__PURE__ */ new Map;
116436
+ for (const [rId, blocks2] of blocksByRId) {
116437
+ const spec = getTableWidthSpec(blocks2);
116438
+ if (spec)
116439
+ tableWidthSpecByRId.set(rId, spec);
116440
+ }
116441
+ const groups = /* @__PURE__ */ new Map;
116442
+ for (const section of sectionMetadata) {
116443
+ const rId = rIdPerSection.get(section.sectionIndex);
116444
+ if (!rId || !blocksByRId.has(rId))
116445
+ continue;
116446
+ const contentWidth = buildSectionContentWidth(section, fallbackConstraints);
116447
+ const sectionConstraints = buildConstraintsForSection(section, fallbackConstraints, resolveTableMinWidth(tableWidthSpecByRId.get(rId), contentWidth) || undefined);
116448
+ const effectiveWidth = sectionConstraints.width;
116449
+ const groupKey = `${rId}::w${effectiveWidth}`;
116450
+ let group = groups.get(groupKey);
116451
+ if (!group) {
116452
+ group = {
116453
+ sectionConstraints,
116454
+ sectionIndices: [],
116455
+ rId,
116456
+ effectiveWidth
116457
+ };
116458
+ groups.set(groupKey, group);
116459
+ }
116460
+ group.sectionIndices.push(section.sectionIndex);
116461
+ }
116462
+ for (const [, group] of groups) {
116463
+ const blocks2 = blocksByRId.get(group.rId);
116464
+ if (!blocks2 || blocks2.length === 0)
116465
+ continue;
116466
+ try {
116467
+ const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, (block, c$3) => measureBlock(block, c$3), undefined, undefined, pageResolver);
116468
+ if (batchResult.default)
116469
+ for (const sectionIndex of group.sectionIndices) {
116470
+ const contentWidth = buildSectionContentWidth(sectionMetadata.find((s2) => s2.sectionIndex === sectionIndex), fallbackConstraints);
116471
+ const needsFrameAdjust = group.effectiveWidth > contentWidth;
116472
+ let layout = batchResult.default.layout;
116473
+ if (needsFrameAdjust) {
116474
+ layout = cloneHeaderFooterLayout(layout);
116475
+ adjustFramePositionsForContentWidth(layout, batchResult.default.blocks, group.effectiveWidth, contentWidth);
116476
+ }
116477
+ const result = {
116478
+ kind,
116235
116479
  type: "default",
116236
- layout: batchResult.default.layout,
116480
+ layout,
116237
116481
  blocks: batchResult.default.blocks,
116238
- measures: batchResult.default.measures
116239
- });
116240
- } catch (error) {
116241
- console.warn(`[PresentationEditor] Failed to layout footer rId=${rId}:`, error);
116242
- }
116482
+ measures: batchResult.default.measures,
116483
+ effectiveWidth: needsFrameAdjust ? group.effectiveWidth : undefined
116484
+ };
116485
+ layoutsByRId.set(`${group.rId}::s${sectionIndex}`, result);
116486
+ }
116487
+ } catch (error) {
116488
+ console.warn(`[PresentationEditor] Failed to layout ${kind} rId=${group.rId}:`, error);
116243
116489
  }
116490
+ }
116244
116491
  }
116245
116492
  function dropCursor(options = {}) {
116246
116493
  return new Plugin({ view(editorView) {
@@ -143463,11 +143710,13 @@ var Node$13 = class Node$14 {
143463
143710
  return;
143464
143711
  }
143465
143712
  if ((this.#deps.getHeaderFooterSession()?.session?.mode ?? "body") !== "body") {
143466
- if (this.#handleClickInHeaderFooterMode(event, x2, y$1))
143713
+ if (this.#handleClickInHeaderFooterMode(event, x2, y$1, normalizedPoint.pageIndex, normalizedPoint.pageLocalY))
143467
143714
  return;
143468
143715
  }
143469
- if (this.#callbacks.hitTestHeaderFooterRegion?.(x2, y$1))
143716
+ if (this.#callbacks.hitTestHeaderFooterRegion?.(x2, y$1, normalizedPoint.pageIndex, normalizedPoint.pageLocalY)) {
143717
+ event.preventDefault();
143470
143718
  return;
143719
+ }
143471
143720
  const viewportHost = this.#deps.getViewportHost();
143472
143721
  const pageGeometryHelper = this.#deps.getPageGeometryHelper();
143473
143722
  const rawHit = clickToPosition(layoutState.layout, layoutState.blocks, layoutState.measures, {
@@ -143694,15 +143943,10 @@ var Node$13 = class Node$14 {
143694
143943
  }
143695
143944
  if (!this.#deps.getLayoutState().layout)
143696
143945
  return;
143697
- const viewportHost = this.#deps.getViewportHost();
143698
- const visibleHost = this.#deps.getVisibleHost();
143699
- const zoom = this.#deps.getZoom();
143700
- const rect = viewportHost.getBoundingClientRect();
143701
- const scrollLeft = visibleHost.scrollLeft ?? 0;
143702
- const scrollTop = visibleHost.scrollTop ?? 0;
143703
- const x2 = (event.clientX - rect.left + scrollLeft) / zoom;
143704
- const y$1 = (event.clientY - rect.top + scrollTop) / zoom;
143705
- const region = this.#callbacks.hitTestHeaderFooterRegion?.(x2, y$1);
143946
+ const normalized = this.#callbacks.normalizeClientPoint?.(event.clientX, event.clientY);
143947
+ if (!normalized)
143948
+ return;
143949
+ const region = this.#callbacks.hitTestHeaderFooterRegion?.(normalized.x, normalized.y, normalized.pageIndex, normalized.pageLocalY);
143706
143950
  if (region) {
143707
143951
  event.preventDefault();
143708
143952
  event.stopPropagation();
@@ -143956,15 +144200,15 @@ var Node$13 = class Node$14 {
143956
144200
  document.activeElement.blur();
143957
144201
  this.#focusEditorAtFirstPosition();
143958
144202
  }
143959
- #handleClickInHeaderFooterMode(event, x2, y$1) {
144203
+ #handleClickInHeaderFooterMode(event, x2, y$1, pageIndex, pageLocalY) {
143960
144204
  const activeEditorHost = this.#deps?.getHeaderFooterSession()?.overlayManager?.getActiveEditorHost?.();
143961
144205
  if (activeEditorHost && (activeEditorHost.contains(event.target) || activeEditorHost === event.target))
143962
144206
  return true;
143963
- if (!this.#callbacks.hitTestHeaderFooterRegion?.(x2, y$1)) {
144207
+ if (!this.#callbacks.hitTestHeaderFooterRegion?.(x2, y$1, pageIndex, pageLocalY)) {
143964
144208
  this.#callbacks.exitHeaderFooterMode?.();
143965
144209
  return false;
143966
144210
  }
143967
- return true;
144211
+ return false;
143968
144212
  }
143969
144213
  #handleInlineImageClick(event, targetImg, rawHit, doc$2, epochMapper) {
143970
144214
  if (!targetImg)
@@ -144166,7 +144410,7 @@ var Node$13 = class Node$14 {
144166
144410
  this.#callbacks.clearHoverRegion?.();
144167
144411
  return;
144168
144412
  }
144169
- const region = this.#callbacks.hitTestHeaderFooterRegion?.(normalized.x, normalized.y);
144413
+ const region = this.#callbacks.hitTestHeaderFooterRegion?.(normalized.x, normalized.y, normalized.pageIndex, normalized.pageLocalY);
144170
144414
  if (!region) {
144171
144415
  this.#callbacks.clearHoverRegion?.();
144172
144416
  return;
@@ -144936,6 +145180,7 @@ var Node$13 = class Node$14 {
144936
145180
  pm.style.minHeight = "100%";
144937
145181
  pm.style.outline = "none";
144938
145182
  pm.style.border = "none";
145183
+ pm.classList.add("sd-header-footer");
144939
145184
  pm.setAttribute("role", "textbox");
144940
145185
  pm.setAttribute("aria-multiline", true);
144941
145186
  pm.setAttribute("aria-label", `${type} content area. Double click to start typing.`);
@@ -145178,7 +145423,7 @@ var Node$13 = class Node$14 {
145178
145423
  position: "absolute",
145179
145424
  pointerEvents: "auto",
145180
145425
  visibility: "hidden",
145181
- overflow: "hidden",
145426
+ overflow: "visible",
145182
145427
  boxSizing: "border-box"
145183
145428
  });
145184
145429
  if (decorationContainer)
@@ -145605,12 +145850,14 @@ var Node$13 = class Node$14 {
145605
145850
  const actualPageHeight = page.size?.h ?? pageHeight;
145606
145851
  const headerPayload = this.#headerDecorationProvider?.(page.number, margins, page);
145607
145852
  const headerBox = this.#computeDecorationBox("header", margins, actualPageHeight);
145853
+ const displayPageNumber = page.numberText ?? String(page.number);
145608
145854
  this.#headerRegions.set(pageIndex, {
145609
145855
  kind: "header",
145610
145856
  headerId: headerPayload?.headerId,
145611
145857
  sectionType: headerPayload?.sectionType ?? this.#computeExpectedSectionType("header", page, sectionFirstPageNumbers),
145612
145858
  pageIndex,
145613
145859
  pageNumber: page.number,
145860
+ displayPageNumber,
145614
145861
  localX: headerPayload?.hitRegion?.x ?? headerBox.x,
145615
145862
  localY: headerPayload?.hitRegion?.y ?? headerBox.offset,
145616
145863
  width: headerPayload?.hitRegion?.width ?? headerBox.width,
@@ -145625,6 +145872,7 @@ var Node$13 = class Node$14 {
145625
145872
  sectionType: footerPayload?.sectionType ?? this.#computeExpectedSectionType("footer", page, sectionFirstPageNumbers),
145626
145873
  pageIndex,
145627
145874
  pageNumber: page.number,
145875
+ displayPageNumber,
145628
145876
  localX: footerPayload?.hitRegion?.x ?? footerBox.x,
145629
145877
  localY: footerPayload?.hitRegion?.y ?? footerBox.offset,
145630
145878
  width: footerPayload?.hitRegion?.width ?? footerBox.width,
@@ -145634,16 +145882,29 @@ var Node$13 = class Node$14 {
145634
145882
  });
145635
145883
  });
145636
145884
  }
145637
- hitTestRegion(x2, y$1, layout) {
145885
+ hitTestRegion(x2, y$1, layout, knownPageIndex, knownPageLocalY) {
145638
145886
  if (!layout)
145639
145887
  return null;
145640
145888
  const layoutOptions = this.#deps?.getLayoutOptions() ?? {};
145641
- const pageHeight = layout.pageSize?.h ?? layoutOptions.pageSize?.h ?? this.#options.defaultPageSize.h;
145889
+ const defaultPageHeight = layout.pageSize?.h ?? layoutOptions.pageSize?.h ?? this.#options.defaultPageSize.h;
145642
145890
  const pageGap = layout.pageGap ?? 0;
145643
- if (pageHeight <= 0)
145891
+ if (defaultPageHeight <= 0)
145644
145892
  return null;
145645
- const pageIndex = Math.max(0, Math.floor(y$1 / (pageHeight + pageGap)));
145646
- const pageLocalY = y$1 - pageIndex * (pageHeight + pageGap);
145893
+ let pageIndex;
145894
+ let pageLocalY;
145895
+ if (knownPageIndex != null && knownPageLocalY != null) {
145896
+ pageIndex = knownPageIndex;
145897
+ pageLocalY = knownPageLocalY;
145898
+ } else if (knownPageIndex != null) {
145899
+ pageIndex = knownPageIndex;
145900
+ let pageTopY = 0;
145901
+ for (let i$1 = 0;i$1 < pageIndex && i$1 < layout.pages.length; i$1++)
145902
+ pageTopY += (layout.pages[i$1].size?.h ?? defaultPageHeight) + pageGap;
145903
+ pageLocalY = y$1 - pageTopY;
145904
+ } else {
145905
+ pageIndex = Math.max(0, Math.floor(y$1 / (defaultPageHeight + pageGap)));
145906
+ pageLocalY = y$1 - pageIndex * (defaultPageHeight + pageGap);
145907
+ }
145647
145908
  const headerRegion = this.#headerRegions.get(pageIndex);
145648
145909
  if (headerRegion && this.#pointInRegion(headerRegion, x2, pageLocalY))
145649
145910
  return headerRegion;
@@ -145731,6 +145992,15 @@ var Node$13 = class Node$14 {
145731
145992
  this.clearHover();
145732
145993
  return;
145733
145994
  }
145995
+ if (this.#session.mode !== "body") {
145996
+ if (this.#activeEditor) {
145997
+ this.#activeEditor.setEditable(false);
145998
+ this.#activeEditor.setOptions({ documentMode: "viewing" });
145999
+ }
146000
+ this.#overlayManager.hideEditingOverlay();
146001
+ this.#activeEditor = null;
146002
+ this.#session = { mode: "body" };
146003
+ }
145734
146004
  const descriptor = this.#resolveDescriptorForRegion(region);
145735
146005
  if (!descriptor) {
145736
146006
  console.warn("[HeaderFooterSessionManager] No descriptor found for region:", region);
@@ -145785,7 +146055,7 @@ var Node$13 = class Node$14 {
145785
146055
  });
145786
146056
  return;
145787
146057
  }
145788
- const layout = this.#headerLayoutResults?.[0]?.layout;
146058
+ const bodyPageCount = this.#deps?.getBodyPageCount() ?? 1;
145789
146059
  let editor;
145790
146060
  try {
145791
146061
  editor = await this.#headerFooterManager.ensureEditor(descriptor, {
@@ -145793,7 +146063,7 @@ var Node$13 = class Node$14 {
145793
146063
  availableWidth: region.width,
145794
146064
  availableHeight: region.height,
145795
146065
  currentPageNumber: region.pageNumber,
145796
- totalPageCount: layout?.pages?.length ?? 1
146066
+ totalPageCount: bodyPageCount
145797
146067
  });
145798
146068
  } catch (editorError) {
145799
146069
  console.error("[HeaderFooterSessionManager] Error creating editor:", editorError);
@@ -146246,8 +146516,10 @@ var Node$13 = class Node$14 {
146246
146516
  }
146247
146517
  if (!headerFooterType)
146248
146518
  return null;
146249
- if (sectionRId && layoutsByRId.has(sectionRId)) {
146250
- const rIdLayout = layoutsByRId.get(sectionRId);
146519
+ const compositeKey = sectionRId ? `${sectionRId}::s${sectionIndex}` : undefined;
146520
+ const rIdLayoutKey = compositeKey && layoutsByRId.has(compositeKey) && compositeKey || sectionRId && layoutsByRId.has(sectionRId) && sectionRId || undefined;
146521
+ if (rIdLayoutKey) {
146522
+ const rIdLayout = layoutsByRId.get(rIdLayoutKey);
146251
146523
  if (!rIdLayout)
146252
146524
  console.warn(`[HeaderFooterSessionManager] Inconsistent state: layoutsByRId.has('${sectionRId}') returned true but get() returned undefined`);
146253
146525
  else {
@@ -146258,6 +146530,7 @@ var Node$13 = class Node$14 {
146258
146530
  const margins$1 = pageMargins ?? layout.pages[0]?.margins ?? layoutOptions.margins ?? defaultMargins;
146259
146531
  const decorationMargins$1 = kind === "footer" ? this.#stripFootnoteReserveFromBottomMargin(margins$1, page ?? null) : margins$1;
146260
146532
  const box$1 = this.#computeDecorationBox(kind, decorationMargins$1, pageHeight$1);
146533
+ const effectiveWidth = rIdLayout.effectiveWidth ?? box$1.width;
146261
146534
  const rawLayoutHeight$1 = rIdLayout.layout.height ?? 0;
146262
146535
  const metrics$1 = this.#computeMetrics(kind, rawLayoutHeight$1, box$1, pageHeight$1, margins$1?.footer ?? 0);
146263
146536
  const layoutMinY$1 = rIdLayout.layout.minY ?? 0;
@@ -146270,20 +146543,20 @@ var Node$13 = class Node$14 {
146270
146543
  contentHeight: metrics$1.layoutHeight > 0 ? metrics$1.layoutHeight : metrics$1.containerHeight,
146271
146544
  offset: metrics$1.offset,
146272
146545
  marginLeft: box$1.x,
146273
- contentWidth: box$1.width,
146546
+ contentWidth: effectiveWidth,
146274
146547
  headerId: sectionRId,
146275
146548
  sectionType: headerFooterType,
146276
146549
  minY: layoutMinY$1,
146277
146550
  box: {
146278
146551
  x: box$1.x,
146279
146552
  y: metrics$1.offset,
146280
- width: box$1.width,
146553
+ width: effectiveWidth,
146281
146554
  height: metrics$1.containerHeight
146282
146555
  },
146283
146556
  hitRegion: {
146284
146557
  x: box$1.x,
146285
146558
  y: metrics$1.offset,
146286
- width: box$1.width,
146559
+ width: effectiveWidth,
146287
146560
  height: metrics$1.containerHeight
146288
146561
  }
146289
146562
  };
@@ -148858,7 +149131,7 @@ var Node$13 = class Node$14 {
148858
149131
  };
148859
149132
  case "total-page-number":
148860
149133
  return {
148861
- text: editor.options.parentEditor?.currentTotalPages || "1",
149134
+ text: editor.options.totalPageCount || editor.options.parentEditor?.currentTotalPages || "1",
148862
149135
  className: "sd-editor-auto-total-pages",
148863
149136
  dataId: "auto-total-pages",
148864
149137
  ariaLabel: "Total page count node"
@@ -148920,6 +149193,10 @@ var Node$13 = class Node$14 {
148920
149193
  if (!incomingType || incomingType !== currentType)
148921
149194
  return false;
148922
149195
  this.node = node3;
149196
+ const attrs = getNodeAttributes(this.node.type.name, this.editor);
149197
+ const newText = String(attrs.text);
149198
+ if (this.dom.textContent !== newText)
149199
+ this.dom.textContent = newText;
148923
149200
  return true;
148924
149201
  }
148925
149202
  }, getMarksFromNeighbors = (currentPos, view) => {
@@ -152068,9 +152345,9 @@ var Node$13 = class Node$14 {
152068
152345
  trackedChanges: context.trackedChanges ?? []
152069
152346
  });
152070
152347
  }, _hoisted_1$6, _hoisted_2$1, _hoisted_3, _hoisted_4, ContextMenu_default, _hoisted_1$5, BasicUpload_default, _hoisted_1$4, MIN_WIDTH = 200, PPI = 96, alignment = "flex-end", Ruler_default, GenericPopover_default, _hoisted_1$3, RESIZE_HANDLE_WIDTH_PX = 9, RESIZE_HANDLE_OFFSET_PX = 4, DRAG_OVERLAY_EXTENSION_PX = 1000, MIN_DRAG_OVERLAY_WIDTH_PX = 2000, THROTTLE_INTERVAL_MS = 16, MIN_RESIZE_DELTA_PX = 1, TableResizeOverlay_default, _hoisted_1$2, OVERLAY_EXPANSION_PX = 2000, RESIZE_HANDLE_SIZE_PX = 12, MOUSE_MOVE_THROTTLE_MS = 16, DIMENSION_CHANGE_THRESHOLD_PX = 1, Z_INDEX_OVERLAY = 10, Z_INDEX_HANDLE = 15, Z_INDEX_GUIDELINE = 20, ImageResizeOverlay_default, LINK_CLICK_DEBOUNCE_MS = 300, CURSOR_UPDATE_TIMEOUT_MS = 10, LinkClickHandler_default, _hoisted_1$1, _hoisted_2, DOCX2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", TABLE_RESIZE_HOVER_THRESHOLD = 8, TABLE_RESIZE_THROTTLE_MS = 16, SuperEditor_default, _hoisted_1, SuperInput_default, SlashMenu, Extensions;
152071
- var init_src_0vZP1_ru_es = __esm(() => {
152348
+ var init_src_eL3w4G7e_es = __esm(() => {
152072
152349
  init_rolldown_runtime_B2q5OVn9_es();
152073
- init_SuperConverter_D9XMPi6H_es();
152350
+ init_SuperConverter_Cf1y7bFA_es();
152074
152351
  init_jszip_ChlR43oI_es();
152075
152352
  init_uuid_2IzDu5nl_es();
152076
152353
  init_constants_DBKi0Amm_es();
@@ -160298,7 +160575,7 @@ function print() { __p += __j.call(arguments, '') }
160298
160575
  },
160299
160576
  "format.apply": {
160300
160577
  memberPath: "format.apply",
160301
- description: "Apply explicit mark changes (bold, italic, underline, strike) to the target range using boolean patch semantics.",
160578
+ description: "Apply explicit inline style changes (bold, italic, underline, strike) to the target range using boolean patch semantics.",
160302
160579
  requiresDocumentContext: true,
160303
160580
  metadata: mutationOperation2({
160304
160581
  idempotency: "conditional",
@@ -160479,7 +160756,11 @@ function print() { __p += __j.call(arguments, '') }
160479
160756
  supportsDryRun: false,
160480
160757
  supportsTrackedMode: false,
160481
160758
  possibleFailureCodes: ["INVALID_TARGET", "NO_OP"],
160482
- throws: [...T_NOT_FOUND_COMMAND2, "INVALID_TARGET"]
160759
+ throws: [
160760
+ ...T_NOT_FOUND_COMMAND2,
160761
+ "INVALID_TARGET",
160762
+ "INVALID_INPUT"
160763
+ ]
160483
160764
  }),
160484
160765
  referenceDocPath: "comments/patch.mdx",
160485
160766
  referenceGroup: "comments"
@@ -160536,8 +160817,8 @@ function print() { __p += __j.call(arguments, '') }
160536
160817
  referenceDocPath: "track-changes/get.mdx",
160537
160818
  referenceGroup: "trackChanges"
160538
160819
  },
160539
- "review.decide": {
160540
- memberPath: "review.decide",
160820
+ "trackChanges.decide": {
160821
+ memberPath: "trackChanges.decide",
160541
160822
  description: "Accept or reject a tracked change (by ID or scope: all).",
160542
160823
  requiresDocumentContext: true,
160543
160824
  metadata: mutationOperation2({
@@ -160545,10 +160826,14 @@ function print() { __p += __j.call(arguments, '') }
160545
160826
  supportsDryRun: false,
160546
160827
  supportsTrackedMode: false,
160547
160828
  possibleFailureCodes: ["NO_OP"],
160548
- throws: T_NOT_FOUND_COMMAND2
160829
+ throws: [
160830
+ ...T_NOT_FOUND_COMMAND2,
160831
+ "INVALID_INPUT",
160832
+ "INVALID_TARGET"
160833
+ ]
160549
160834
  }),
160550
- referenceDocPath: "review/decide.mdx",
160551
- referenceGroup: "review"
160835
+ referenceDocPath: "track-changes/decide.mdx",
160836
+ referenceGroup: "trackChanges"
160552
160837
  },
160553
160838
  "query.match": {
160554
160839
  memberPath: "query.match",
@@ -161097,7 +161382,7 @@ function print() { __p += __j.call(arguments, '') }
161097
161382
  text: { type: "string" }
161098
161383
  }, ["target", "text"]), textMutationResultSchemaFor2("replace"), textMutationFailureSchemaFor2("replace"), objectSchema2({ target: textAddressSchema2 }, ["target"]), textMutationResultSchemaFor2("delete"), textMutationFailureSchemaFor2("delete"), objectSchema2({
161099
161384
  target: textAddressSchema2,
161100
- marks: (() => {
161385
+ inline: (() => {
161101
161386
  return {
161102
161387
  type: "object",
161103
161388
  properties: Object.fromEntries(MARK_KEYS2.map((key$1) => [key$1, { type: "boolean" }])),
@@ -161105,7 +161390,7 @@ function print() { __p += __j.call(arguments, '') }
161105
161390
  minProperties: 1
161106
161391
  };
161107
161392
  })()
161108
- }, ["target", "marks"]), textMutationResultSchemaFor2("format.apply"), textMutationFailureSchemaFor2("format.apply"), objectSchema2({
161393
+ }, ["target", "inline"]), textMutationResultSchemaFor2("format.apply"), textMutationFailureSchemaFor2("format.apply"), objectSchema2({
161109
161394
  at: { oneOf: [
161110
161395
  objectSchema2({ kind: { const: "documentStart" } }, ["kind"]),
161111
161396
  objectSchema2({ kind: { const: "documentEnd" } }, ["kind"]),
@@ -161170,7 +161455,7 @@ function print() { __p += __j.call(arguments, '') }
161170
161455
  "delete",
161171
161456
  "format"
161172
161457
  ] }
161173
- }), objectSchema2({ id: { type: "string" } }, ["id"]), objectSchema2({ id: { type: "string" } }, ["id"]), objectSchema2({ scope: { enum: ["all"] } }, ["scope"]), receiptResultSchemaFor2("review.decide"), receiptFailureResultSchemaFor2("review.decide"), objectSchema2({
161458
+ }), objectSchema2({ id: { type: "string" } }, ["id"]), objectSchema2({ id: { type: "string" } }, ["id"]), objectSchema2({ scope: { enum: ["all"] } }, ["scope"]), receiptResultSchemaFor2("trackChanges.decide"), receiptFailureResultSchemaFor2("trackChanges.decide"), objectSchema2({
161174
161459
  select: { oneOf: [textSelectorSchema2, nodeSelectorSchema2] },
161175
161460
  within: nodeAddressSchema2,
161176
161461
  require: { enum: [
@@ -161310,14 +161595,9 @@ function print() { __p += __j.call(arguments, '') }
161310
161595
  },
161311
161596
  trackChanges: {
161312
161597
  title: "Track Changes",
161313
- description: "Tracked-change inspection operations.",
161598
+ description: "Tracked-change inspection and review operations.",
161314
161599
  pagePath: "track-changes/index.mdx"
161315
161600
  },
161316
- review: {
161317
- title: "Review",
161318
- description: "Accept or reject tracked changes.",
161319
- pagePath: "review/index.mdx"
161320
- },
161321
161601
  query: {
161322
161602
  title: "Query",
161323
161603
  description: "Deterministic selector-based queries for mutation targeting.",
@@ -161362,7 +161642,7 @@ function print() { __p += __j.call(arguments, '') }
161362
161642
  "status",
161363
161643
  "isInternal"
161364
161644
  ]);
161365
- STYLE_APPLY_INPUT_ALLOWED_KEYS2 = new Set(["target", "marks"]);
161645
+ STYLE_APPLY_INPUT_ALLOWED_KEYS2 = new Set(["target", "inline"]);
161366
161646
  DELETE_INPUT_ALLOWED_KEYS2 = new Set(["target"]);
161367
161647
  INSERT_INPUT_ALLOWED_KEYS2 = new Set(["text", "target"]);
161368
161648
  REPLACE_INPUT_ALLOWED_KEYS2 = new Set(["text", "target"]);
@@ -161387,7 +161667,7 @@ function print() { __p += __j.call(arguments, '') }
161387
161667
  "setCommentInternal"
161388
161668
  ],
161389
161669
  "comments.delete": ["removeComment"],
161390
- "review.decide": [
161670
+ "trackChanges.decide": [
161391
161671
  "acceptTrackedChangeById",
161392
161672
  "rejectTrackedChangeById",
161393
161673
  "acceptAllTrackedChanges",
@@ -170686,8 +170966,10 @@ function print() { __p += __j.call(arguments, '') }
170686
170966
  updateOptions.availableWidth = options.availableWidth;
170687
170967
  if (options.availableHeight !== undefined)
170688
170968
  updateOptions.availableHeight = options.availableHeight;
170689
- if (Object.keys(updateOptions).length > 0)
170969
+ if (Object.keys(updateOptions).length > 0) {
170690
170970
  existing.editor.setOptions(updateOptions);
170971
+ this.#refreshPageNumberDisplay(existing.editor);
170972
+ }
170691
170973
  }
170692
170974
  return existing.editor;
170693
170975
  }
@@ -170718,6 +171000,25 @@ function print() { __p += __j.call(arguments, '') }
170718
171000
  this.#pendingCreations.set(descriptor.id, creationPromise);
170719
171001
  return creationPromise;
170720
171002
  }
171003
+ #refreshPageNumberDisplay(editor) {
171004
+ const container = editor.view?.dom;
171005
+ if (!container)
171006
+ return;
171007
+ const opts = editor.options;
171008
+ const parentEditor = opts.parentEditor;
171009
+ const currentPage = String(opts.currentPageNumber || "1");
171010
+ const totalPages = String(opts.totalPageCount || parentEditor?.currentTotalPages || "1");
171011
+ const pageNumberEls = container.querySelectorAll('[data-id="auto-page-number"]');
171012
+ const totalPagesEls = container.querySelectorAll('[data-id="auto-total-pages"]');
171013
+ pageNumberEls.forEach((el) => {
171014
+ if (el.textContent !== currentPage)
171015
+ el.textContent = currentPage;
171016
+ });
171017
+ totalPagesEls.forEach((el) => {
171018
+ if (el.textContent !== totalPages)
171019
+ el.textContent = totalPages;
171020
+ });
171021
+ }
170721
171022
  getEditor(descriptor) {
170722
171023
  if (!descriptor?.id)
170723
171024
  return null;
@@ -172398,7 +172699,7 @@ function print() { __p += __j.call(arguments, '') }
172398
172699
  goToAnchor: (href) => this.goToAnchor(href),
172399
172700
  emit: (event, payload) => this.emit(event, payload),
172400
172701
  normalizeClientPoint: (clientX, clientY) => this.#normalizeClientPoint(clientX, clientY),
172401
- hitTestHeaderFooterRegion: (x2, y$1) => this.#hitTestHeaderFooterRegion(x2, y$1),
172702
+ hitTestHeaderFooterRegion: (x2, y$1, pageIndex, pageLocalY) => this.#hitTestHeaderFooterRegion(x2, y$1, pageIndex, pageLocalY),
172402
172703
  exitHeaderFooterMode: () => this.#exitHeaderFooterMode(),
172403
172704
  activateHeaderFooterRegion: (region) => this.#activateHeaderFooterRegion(region),
172404
172705
  createDefaultHeaderFooter: (region) => this.#createDefaultHeaderFooter(region),
@@ -172521,7 +172822,8 @@ function print() { __p += __j.call(arguments, '') }
172521
172822
  scheduleRerender: () => this.#scheduleRerender(),
172522
172823
  setPendingDocChange: () => {
172523
172824
  this.#pendingDocChange = true;
172524
- }
172825
+ },
172826
+ getBodyPageCount: () => this.#layoutState?.layout?.pages?.length ?? 1
172525
172827
  });
172526
172828
  this.#headerFooterSession.setCallbacks({
172527
172829
  onModeChanged: (session) => {
@@ -173437,8 +173739,8 @@ function print() { __p += __j.call(arguments, '') }
173437
173739
  #updateDecorationProviders(layout) {
173438
173740
  this.#headerFooterSession?.updateDecorationProviders(layout);
173439
173741
  }
173440
- #hitTestHeaderFooterRegion(x2, y$1) {
173441
- return this.#headerFooterSession?.hitTestRegion(x2, y$1, this.#layoutState.layout) ?? null;
173742
+ #hitTestHeaderFooterRegion(x2, y$1, pageIndex, pageLocalY) {
173743
+ return this.#headerFooterSession?.hitTestRegion(x2, y$1, this.#layoutState.layout, pageIndex, pageLocalY) ?? null;
173442
173744
  }
173443
173745
  #activateHeaderFooterRegion(region) {
173444
173746
  this.#headerFooterSession?.activateRegion(region);
@@ -178190,7 +178492,7 @@ function print() { __p += __j.call(arguments, '') }
178190
178492
  const { schema } = state;
178191
178493
  if (!schema.nodes?.["total-page-number"])
178192
178494
  return false;
178193
- const currentPages = editor?.options?.parentEditor?.currentTotalPages || 1;
178495
+ const currentPages = editor?.options?.totalPageCount || editor?.options?.parentEditor?.currentTotalPages || 1;
178194
178496
  const pageNumberNode = {
178195
178497
  type: "total-page-number",
178196
178498
  content: [{
@@ -183515,8 +183817,8 @@ function print() { __p += __j.call(arguments, '') }
183515
183817
  return isObjectLike_default(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
183516
183818
  };
183517
183819
  stubFalse_default = stubFalse;
183518
- freeExports$2 = typeof exports_src_0vZP1_ru_es == "object" && exports_src_0vZP1_ru_es && !exports_src_0vZP1_ru_es.nodeType && exports_src_0vZP1_ru_es;
183519
- freeModule$2 = freeExports$2 && typeof module_src_0vZP1_ru_es == "object" && module_src_0vZP1_ru_es && !module_src_0vZP1_ru_es.nodeType && module_src_0vZP1_ru_es;
183820
+ freeExports$2 = typeof exports_src_eL3w4G7e_es == "object" && exports_src_eL3w4G7e_es && !exports_src_eL3w4G7e_es.nodeType && exports_src_eL3w4G7e_es;
183821
+ freeModule$2 = freeExports$2 && typeof module_src_eL3w4G7e_es == "object" && module_src_eL3w4G7e_es && !module_src_eL3w4G7e_es.nodeType && module_src_eL3w4G7e_es;
183520
183822
  Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? _root_default.Buffer : undefined;
183521
183823
  isBuffer_default = (Buffer$1 ? Buffer$1.isBuffer : undefined) || stubFalse_default;
183522
183824
  typedArrayTags = {};
@@ -183524,8 +183826,8 @@ function print() { __p += __j.call(arguments, '') }
183524
183826
  typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
183525
183827
  _baseIsTypedArray_default = baseIsTypedArray;
183526
183828
  _baseUnary_default = baseUnary;
183527
- freeExports$1 = typeof exports_src_0vZP1_ru_es == "object" && exports_src_0vZP1_ru_es && !exports_src_0vZP1_ru_es.nodeType && exports_src_0vZP1_ru_es;
183528
- freeModule$1 = freeExports$1 && typeof module_src_0vZP1_ru_es == "object" && module_src_0vZP1_ru_es && !module_src_0vZP1_ru_es.nodeType && module_src_0vZP1_ru_es;
183829
+ freeExports$1 = typeof exports_src_eL3w4G7e_es == "object" && exports_src_eL3w4G7e_es && !exports_src_eL3w4G7e_es.nodeType && exports_src_eL3w4G7e_es;
183830
+ freeModule$1 = freeExports$1 && typeof module_src_eL3w4G7e_es == "object" && module_src_eL3w4G7e_es && !module_src_eL3w4G7e_es.nodeType && module_src_eL3w4G7e_es;
183529
183831
  freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && _freeGlobal_default.process;
183530
183832
  _nodeUtil_default = function() {
183531
183833
  try {
@@ -183630,8 +183932,8 @@ function print() { __p += __j.call(arguments, '') }
183630
183932
  Stack.prototype.has = _stackHas_default;
183631
183933
  Stack.prototype.set = _stackSet_default;
183632
183934
  _Stack_default = Stack;
183633
- freeExports = typeof exports_src_0vZP1_ru_es == "object" && exports_src_0vZP1_ru_es && !exports_src_0vZP1_ru_es.nodeType && exports_src_0vZP1_ru_es;
183634
- freeModule = freeExports && typeof module_src_0vZP1_ru_es == "object" && module_src_0vZP1_ru_es && !module_src_0vZP1_ru_es.nodeType && module_src_0vZP1_ru_es;
183935
+ freeExports = typeof exports_src_eL3w4G7e_es == "object" && exports_src_eL3w4G7e_es && !exports_src_eL3w4G7e_es.nodeType && exports_src_eL3w4G7e_es;
183936
+ freeModule = freeExports && typeof module_src_eL3w4G7e_es == "object" && module_src_eL3w4G7e_es && !module_src_eL3w4G7e_es.nodeType && module_src_eL3w4G7e_es;
183635
183937
  Buffer4 = freeModule && freeModule.exports === freeExports ? _root_default.Buffer : undefined;
183636
183938
  allocUnsafe = Buffer4 ? Buffer4.allocUnsafe : undefined;
183637
183939
  _cloneBuffer_default = cloneBuffer;
@@ -191250,8 +191552,8 @@ var init_zipper_BJHqrQMq_es = __esm(() => {
191250
191552
 
191251
191553
  // ../../packages/superdoc/dist/super-editor.es.js
191252
191554
  var init_super_editor_es = __esm(() => {
191253
- init_src_0vZP1_ru_es();
191254
- init_SuperConverter_D9XMPi6H_es();
191555
+ init_src_eL3w4G7e_es();
191556
+ init_SuperConverter_Cf1y7bFA_es();
191255
191557
  init_jszip_ChlR43oI_es();
191256
191558
  init_xml_js_DLE8mr0n_es();
191257
191559
  init_constants_DBKi0Amm_es();
@@ -191408,7 +191710,7 @@ var init_capabilities_adapter = __esm(() => {
191408
191710
  "comments.create": ["addComment", "setTextSelection", "addCommentReply"],
191409
191711
  "comments.patch": ["editComment", "moveComment", "resolveComment", "setCommentInternal"],
191410
191712
  "comments.delete": ["removeComment"],
191411
- "review.decide": [
191713
+ "trackChanges.decide": [
191412
191714
  "acceptTrackedChangeById",
191413
191715
  "rejectTrackedChangeById",
191414
191716
  "acceptAllTrackedChanges",
@@ -198013,10 +198315,10 @@ function executeStyleApply3(editor, tr, target, step, mapping) {
198013
198315
  const { schema } = editor.state;
198014
198316
  let changed = false;
198015
198317
  const markEntries = [
198016
- ["bold", step.args.marks.bold, schema.marks.bold],
198017
- ["italic", step.args.marks.italic, schema.marks.italic],
198018
- ["underline", step.args.marks.underline, schema.marks.underline],
198019
- ["strike", step.args.marks.strike, schema.marks.strike]
198318
+ ["bold", step.args.inline.bold, schema.marks.bold],
198319
+ ["italic", step.args.inline.italic, schema.marks.italic],
198320
+ ["underline", step.args.inline.underline, schema.marks.underline],
198321
+ ["strike", step.args.inline.strike, schema.marks.strike]
198020
198322
  ];
198021
198323
  for (const [, value, markType] of markEntries) {
198022
198324
  if (value === undefined || !markType)
@@ -198106,10 +198408,10 @@ function executeSpanStyleApply2(editor, tr, target, step, mapping) {
198106
198408
  const absFrom = mapping.map(firstSeg.absFrom, 1);
198107
198409
  const absTo = mapping.map(lastSeg.absTo, -1);
198108
198410
  const markEntries = [
198109
- ["bold", step.args.marks.bold, schema.marks.bold],
198110
- ["italic", step.args.marks.italic, schema.marks.italic],
198111
- ["underline", step.args.marks.underline, schema.marks.underline],
198112
- ["strike", step.args.marks.strike, schema.marks.strike]
198411
+ ["bold", step.args.inline.bold, schema.marks.bold],
198412
+ ["italic", step.args.inline.italic, schema.marks.italic],
198413
+ ["underline", step.args.inline.underline, schema.marks.underline],
198414
+ ["strike", step.args.inline.strike, schema.marks.strike]
198113
198415
  ];
198114
198416
  for (const [, value, markType] of markEntries) {
198115
198417
  if (value === undefined || !markType)
@@ -198717,7 +199019,7 @@ function styleApplyWrapper2(editor, input2, options) {
198717
199019
  failure: { code: "INVALID_TARGET", message: "format.apply requires a non-collapsed target range." }
198718
199020
  };
198719
199021
  }
198720
- const markKeys2 = Object.keys(input2.marks).filter((k3) => input2.marks[k3] !== undefined);
199022
+ const markKeys2 = Object.keys(input2.inline).filter((k3) => input2.inline[k3] !== undefined);
198721
199023
  for (const key2 of markKeys2) {
198722
199024
  const schemaName = MARK_KEY_TO_SCHEMA_NAME2[key2];
198723
199025
  if (schemaName) {
@@ -198736,7 +199038,7 @@ function styleApplyWrapper2(editor, input2, options) {
198736
199038
  id: stepId,
198737
199039
  op: "format.apply",
198738
199040
  where: STUB_WHERE2,
198739
- args: { marks: input2.marks }
199041
+ args: { inline: input2.inline }
198740
199042
  };
198741
199043
  const target = {
198742
199044
  kind: "range",
@@ -219339,6 +219641,18 @@ var SKIP_FIELD_PROCESSING_NODE_NAMES3, shouldSkipFieldProcessing3 = (node3) => S
219339
219641
  i4++;
219340
219642
  continue;
219341
219643
  }
219644
+ const childElements = node3.elements || [];
219645
+ if (childElements.length > 0) {
219646
+ for (const child of childElements) {
219647
+ if (Array.isArray(child.elements)) {
219648
+ const childResult = preProcessPageFieldsOnly2(child.elements, depth + 1);
219649
+ child.elements = childResult.processedNodes;
219650
+ }
219651
+ processedNodes.push(child);
219652
+ }
219653
+ i4++;
219654
+ continue;
219655
+ }
219342
219656
  }
219343
219657
  if (fldType === "begin") {
219344
219658
  const fieldInfo = scanFieldSequence2(nodes, i4);
@@ -219364,6 +219678,13 @@ var SKIP_FIELD_PROCESSING_NODE_NAMES3, shouldSkipFieldProcessing3 = (node3) => S
219364
219678
  }
219365
219679
  }
219366
219680
  }
219681
+ if (node3.name === "w:r" && node3.elements?.some((el) => el.name === "w:pgNum")) {
219682
+ const rPr = node3.elements.find((el) => el.name === "w:rPr") || null;
219683
+ const processedField = preProcessPageInstruction2([], "", rPr);
219684
+ processedNodes.push(...processedField);
219685
+ i4++;
219686
+ continue;
219687
+ }
219367
219688
  if (Array.isArray(node3.elements)) {
219368
219689
  const childResult = preProcessPageFieldsOnly2(node3.elements, depth + 1);
219369
219690
  node3.elements = childResult.processedNodes;
@@ -238980,7 +239301,7 @@ var resolveTrackChangeId = (input2, context) => {
238980
239301
  var init_special_handlers = __esm(() => {
238981
239302
  PRE_INVOKE_HOOKS = {
238982
239303
  "trackChanges.get": resolveTrackChangeId,
238983
- "review.decide": resolveReviewDecideId
239304
+ "trackChanges.decide": resolveReviewDecideId
238984
239305
  };
238985
239306
  POST_INVOKE_HOOKS = {
238986
239307
  "trackChanges.list": normalizeTrackChangesListIds,
@@ -239609,7 +239930,7 @@ var init_helper_commands = __esm(() => {
239609
239930
  {
239610
239931
  tokens: ["format", "bold"],
239611
239932
  canonicalOperationId: "format.apply",
239612
- defaultInput: { marks: { bold: true } },
239933
+ defaultInput: { inline: { bold: true } },
239613
239934
  description: "Apply bold formatting to a text range.",
239614
239935
  category: "format",
239615
239936
  mutates: true,
@@ -239621,7 +239942,7 @@ var init_helper_commands = __esm(() => {
239621
239942
  {
239622
239943
  tokens: ["format", "italic"],
239623
239944
  canonicalOperationId: "format.apply",
239624
- defaultInput: { marks: { italic: true } },
239945
+ defaultInput: { inline: { italic: true } },
239625
239946
  description: "Apply italic formatting to a text range.",
239626
239947
  category: "format",
239627
239948
  mutates: true,
@@ -239630,7 +239951,7 @@ var init_helper_commands = __esm(() => {
239630
239951
  {
239631
239952
  tokens: ["format", "underline"],
239632
239953
  canonicalOperationId: "format.apply",
239633
- defaultInput: { marks: { underline: true } },
239954
+ defaultInput: { inline: { underline: true } },
239634
239955
  description: "Apply underline formatting to a text range.",
239635
239956
  category: "format",
239636
239957
  mutates: true,
@@ -239639,7 +239960,7 @@ var init_helper_commands = __esm(() => {
239639
239960
  {
239640
239961
  tokens: ["format", "strikethrough"],
239641
239962
  canonicalOperationId: "format.apply",
239642
- defaultInput: { marks: { strike: true } },
239963
+ defaultInput: { inline: { strike: true } },
239643
239964
  description: "Apply strikethrough formatting to a text range.",
239644
239965
  category: "format",
239645
239966
  mutates: true,
@@ -239647,7 +239968,7 @@ var init_helper_commands = __esm(() => {
239647
239968
  },
239648
239969
  {
239649
239970
  tokens: ["track-changes", "accept"],
239650
- canonicalOperationId: "review.decide",
239971
+ canonicalOperationId: "trackChanges.decide",
239651
239972
  defaultInput: { decision: "accept" },
239652
239973
  description: "Accept a tracked change by ID.",
239653
239974
  category: "trackChanges",
@@ -239658,7 +239979,7 @@ var init_helper_commands = __esm(() => {
239658
239979
  },
239659
239980
  {
239660
239981
  tokens: ["track-changes", "reject"],
239661
- canonicalOperationId: "review.decide",
239982
+ canonicalOperationId: "trackChanges.decide",
239662
239983
  defaultInput: { decision: "reject" },
239663
239984
  description: "Reject a tracked change by ID.",
239664
239985
  category: "trackChanges",
@@ -239669,7 +239990,7 @@ var init_helper_commands = __esm(() => {
239669
239990
  },
239670
239991
  {
239671
239992
  tokens: ["track-changes", "accept-all"],
239672
- canonicalOperationId: "review.decide",
239993
+ canonicalOperationId: "trackChanges.decide",
239673
239994
  defaultInput: { decision: "accept", target: { scope: "all" } },
239674
239995
  description: "Accept all tracked changes.",
239675
239996
  category: "trackChanges",
@@ -239678,7 +239999,7 @@ var init_helper_commands = __esm(() => {
239678
239999
  },
239679
240000
  {
239680
240001
  tokens: ["track-changes", "reject-all"],
239681
- canonicalOperationId: "review.decide",
240002
+ canonicalOperationId: "trackChanges.decide",
239682
240003
  defaultInput: { decision: "reject", target: { scope: "all" } },
239683
240004
  description: "Reject all tracked changes.",
239684
240005
  category: "trackChanges",