@superdoc/mcp 1.9.0-next.8 → 1.9.0-next.9

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 +76 -4
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31620,7 +31620,7 @@ var init_host = __esm(() => {
31620
31620
  });
31621
31621
 
31622
31622
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31623
- var SDK_VERSION = "2.22.0-next.8";
31623
+ var SDK_VERSION = "2.22.0-next.9";
31624
31624
 
31625
31625
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31626
31626
  import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
@@ -328259,6 +328259,7 @@ function convertHtmlToFragment(html, options = {}) {
328259
328259
  }
328260
328260
  const context = {
328261
328261
  source: html,
328262
+ tableSpanPolicy: options.tableSpanPolicy ?? "html",
328262
328263
  limits,
328263
328264
  sheet,
328264
328265
  diagnostics,
@@ -328949,6 +328950,8 @@ function usesDefaultWordOrderedLevelShape(descriptor) {
328949
328950
  function convertTable(table, context, inherited, path6) {
328950
328951
  let structurallyRejected = false;
328951
328952
  const rows = collectTableRows(table, path6);
328953
+ if (context.tableSpanPolicy === "strict" && !validateTableSpans(rows, context))
328954
+ return null;
328952
328955
  for (const { row, path: rowPath } of rows) {
328953
328956
  let rowGridColumns = 0;
328954
328957
  for (let cellIndex = 0;cellIndex < row.childNodes.length; cellIndex += 1) {
@@ -329464,6 +329467,72 @@ function orderedListItemValue(item, definition, context, path6) {
329464
329467
  });
329465
329468
  return null;
329466
329469
  }
329470
+ function validateTableSpans(rows, context) {
329471
+ const occupiedUntil = Array.from({ length: MAX_WORD_TABLE_GRID_COLUMNS }, () => 0);
329472
+ let valid = true;
329473
+ const reject2 = (cell, path6, attribute2, message) => {
329474
+ valid = false;
329475
+ addDiagnostic(context, {
329476
+ code: "conversion-malformed-input",
329477
+ severity: "error",
329478
+ message,
329479
+ construct: attribute2 === "rowspan" ? "rowSpan" : "colSpan",
329480
+ disposition: "rejected",
329481
+ lossy: true,
329482
+ path: [...path6, `@${attribute2}`],
329483
+ range: sourceRangeForAttribute(cell, attribute2) ?? sourceRangeForNode(cell)
329484
+ });
329485
+ };
329486
+ const span = (cell, path6, attribute2) => {
329487
+ const raw = attributeValue2(cell, attribute2);
329488
+ if (raw === undefined)
329489
+ return 1;
329490
+ const trimmed = raw.replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g, "");
329491
+ const value2 = Number(trimmed);
329492
+ if (/^\d+$/.test(trimmed) && Number.isSafeInteger(value2) && value2 >= (attribute2 === "rowspan" ? 0 : 1))
329493
+ return value2;
329494
+ reject2(cell, path6, attribute2, `Table cell ${attribute2} must be a valid ${attribute2 === "rowspan" ? "non-negative" : "positive"} integer.`);
329495
+ return;
329496
+ };
329497
+ for (let rowIndex = 0;rowIndex < rows.length; rowIndex += 1) {
329498
+ const { row, path: path6, remainingGroupRows } = rows[rowIndex];
329499
+ let column = 0;
329500
+ for (let cellIndex = 0;cellIndex < row.childNodes.length; cellIndex += 1) {
329501
+ const cell = row.childNodes[cellIndex];
329502
+ if (!isElement(cell) || cell.tagName !== "td" && cell.tagName !== "th")
329503
+ continue;
329504
+ const cellPath = [...path6, cellIndex];
329505
+ const authoredRowSpan = span(cell, cellPath, "rowspan");
329506
+ const rowSpan = authoredRowSpan === 0 ? remainingGroupRows : authoredRowSpan;
329507
+ const colSpan = span(cell, cellPath, "colspan");
329508
+ if (rowSpan === undefined || colSpan === undefined)
329509
+ continue;
329510
+ if (rowSpan > remainingGroupRows) {
329511
+ reject2(cell, cellPath, "rowspan", "Table cell rowspan extends beyond its HTML row group.");
329512
+ continue;
329513
+ }
329514
+ while (column < MAX_WORD_TABLE_GRID_COLUMNS && occupiedUntil[column] > rowIndex)
329515
+ column += 1;
329516
+ if (column + colSpan > MAX_WORD_TABLE_GRID_COLUMNS) {
329517
+ reject2(cell, cellPath, "colspan", `Table rows cannot exceed ${MAX_WORD_TABLE_GRID_COLUMNS} grid columns, including vertical continuations.`);
329518
+ break;
329519
+ }
329520
+ let overlaps2 = false;
329521
+ for (let slot = column;slot < column + colSpan; slot += 1) {
329522
+ if (occupiedUntil[slot] > rowIndex)
329523
+ overlaps2 = true;
329524
+ }
329525
+ if (overlaps2) {
329526
+ reject2(cell, cellPath, "colspan", "Table cell colspan overlaps an active rowspan.");
329527
+ } else {
329528
+ for (let slot = column;slot < column + colSpan; slot += 1)
329529
+ occupiedUntil[slot] = rowIndex + rowSpan;
329530
+ }
329531
+ column += colSpan;
329532
+ }
329533
+ }
329534
+ return valid;
329535
+ }
329467
329536
  function positiveIntegerAttribute(element, attribute2, context, path6, construct) {
329468
329537
  const raw = attributeValue2(element, attribute2);
329469
329538
  if (raw === undefined)
@@ -341225,7 +341294,7 @@ var init_markdown = __esm(() => {
341225
341294
 
341226
341295
  // ../../../v2/document-api-v2-adapter/dist/conversion/convert-to-fragment.js
341227
341296
  function convertContentToFragment(request) {
341228
- return request.format === "html" ? convertHtmlToFragment(request.source, request.options) : convertMarkdownToFragment(request.source, request.options);
341297
+ return request.format === "html" ? convertHtmlToFragment(request.source, { tableSpanPolicy: "strict", ...request.options }) : convertMarkdownToFragment(request.source, request.options);
341229
341298
  }
341230
341299
  var init_convert_to_fragment = __esm(() => {
341231
341300
  init_html2();
@@ -341774,6 +341843,9 @@ function lowerTable(node4, path7, images) {
341774
341843
  if (col + gridSpan > MAX_WORD_TABLE_GRID_COLUMNS3) {
341775
341844
  invalid3([...rowPath, "cells"], `Table rows cannot exceed ${MAX_WORD_TABLE_GRID_COLUMNS3} grid columns.`);
341776
341845
  }
341846
+ if (activeSpans.some((span) => span.remaining > 0 && span.col > col && span.col < col + gridSpan)) {
341847
+ invalid3([...cellPath, "colSpan"], "Table cell colspan overlaps an active rowspan.");
341848
+ }
341777
341849
  if (cell.content.length === 0)
341778
341850
  invalid3([...cellPath, "content"], "Table cells must contain a paragraph.");
341779
341851
  const blocks = cell.content.flatMap((content3, contentIndex) => {
@@ -344478,7 +344550,7 @@ function planFromHtml(payload, html, options, rejectUnsafeContent = false) {
344478
344550
  const converted = convertContentToFragment({
344479
344551
  format: "html",
344480
344552
  source: rewritten,
344481
- options: { limits: {
344553
+ options: { tableSpanPolicy: "html", limits: {
344482
344554
  maxSourceCodeUnits: DEFAULT_HTML_CONVERSION_LIMITS.maxSourceCodeUnits + allowance,
344483
344555
  maxOutputCodeUnits: DEFAULT_HTML_CONVERSION_LIMITS.maxOutputCodeUnits + allowance,
344484
344556
  ...allowance > 0 ? { maxNestingDepth: MAX_WORD_VML_RECOVERY_NESTING_DEPTH } : {}
@@ -469362,7 +469434,7 @@ function mirrorStorySurfaceFromSession(input) {
469362
469434
  const actorType = readActorAttributionFromPrepared(input.prepared);
469363
469435
  tx.meta.set(ACTOR_ATTRIBUTION_META_KEY, actorType);
469364
469436
  scope.meta.set(STORY_META_KEY.lastEditActorType, actorType);
469365
- const groups = extension2.contentControlRewrite || hasContentControlGroups(scope) ? prepareStoryContentControlGroups(input.session, storyId, doc2) : null;
469437
+ const groups = extension2.contentControlRewrite || extension2.family === "storyPaste" || hasContentControlGroups(scope) ? prepareStoryContentControlGroups(input.session, storyId, doc2) : null;
469366
469438
  mirrorFamilyIntoStory({
469367
469439
  session: input.session,
469368
469440
  prepared: input.prepared,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.9.0-next.8",
3
+ "version": "1.9.0-next.9",
4
4
  "description": "Model Context Protocol server for SuperDoc, giving an AI agent tools to read and edit .docx files.",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0",
@@ -24,13 +24,13 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@modelcontextprotocol/sdk": "^1.26.0",
27
- "@superdoc/sdk": "2.22.0-next.8",
27
+ "@superdoc/sdk": "2.22.0-next.9",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.25.0-next.8",
33
- "@superdoc/docx-engine": "0.24.0-next.8",
32
+ "superdoc": "2.25.0-next.9",
33
+ "@superdoc/docx-engine": "0.24.0-next.9",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",