@superdoc-dev/mcp 0.3.0-next.91 → 0.3.0-next.93

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 +250 -122
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -51891,7 +51891,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
51891
51891
  emptyOptions2 = {};
51892
51892
  });
51893
51893
 
51894
- // ../../packages/superdoc/dist/chunks/SuperConverter-KEGUvaEC.es.js
51894
+ // ../../packages/superdoc/dist/chunks/SuperConverter-D-cFThyR.es.js
51895
51895
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
51896
51896
  const fieldValue = extension$1.config[field];
51897
51897
  if (typeof fieldValue === "function")
@@ -60727,20 +60727,23 @@ function combineProperties(propertiesArray, options = {}) {
60727
60727
  function isObject2(item) {
60728
60728
  return item != null && typeof item === "object" && !Array.isArray(item);
60729
60729
  }
60730
+ function dropConflictingFontSlots(target, source) {
60731
+ const result = { ...target };
60732
+ for (const [concreteKey, themeKey] of FONT_SLOT_THEME_PAIRS)
60733
+ if (source[themeKey] != null) {
60734
+ delete result[concreteKey];
60735
+ delete result[themeKey];
60736
+ } else if (source[concreteKey] != null)
60737
+ delete result[themeKey];
60738
+ return result;
60739
+ }
60730
60740
  function combineRunProperties(propertiesArray) {
60731
60741
  return combineProperties(propertiesArray, {
60732
60742
  fullOverrideProps: ["color"],
60733
60743
  specialHandling: { fontFamily: (target, source) => {
60734
60744
  const fontFamilySource = { ...source.fontFamily };
60735
- const fontFamilyTarget = { ...target.fontFamily };
60736
- if (fontFamilySource.asciiTheme != null) {
60737
- delete fontFamilyTarget.ascii;
60738
- delete fontFamilyTarget.asciiTheme;
60739
- }
60740
- if (fontFamilySource.ascii != null)
60741
- delete fontFamilyTarget.asciiTheme;
60742
60745
  return {
60743
- ...fontFamilyTarget,
60746
+ ...dropConflictingFontSlots(target.fontFamily ?? {}, fontFamilySource),
60744
60747
  ...fontFamilySource
60745
60748
  };
60746
60749
  } }
@@ -70360,6 +70363,27 @@ function resolveHypotheticalParagraphProperties(editor, $pos, inlineProps) {
70360
70363
  translatedLinkedStyles: editor.converter.translatedLinkedStyles
70361
70364
  }, inlineProps, tableStyleId);
70362
70365
  }
70366
+ function mergeFontFamilyPreservingThemeRefs(fromMarks, existing) {
70367
+ const merged = { ...fromMarks || {} };
70368
+ if (!existing || typeof existing !== "object")
70369
+ return merged;
70370
+ for (const [concreteKey, themeKey] of FONT_SLOT_THEME_PAIRS)
70371
+ if (existing[themeKey] != null) {
70372
+ merged[themeKey] = existing[themeKey];
70373
+ delete merged[concreteKey];
70374
+ }
70375
+ return merged;
70376
+ }
70377
+ function marksMatchExistingFontFamily(markFromMarks, existingFontFamily, encode$80, docx) {
70378
+ if (!existingFontFamily || typeof existingFontFamily !== "object")
70379
+ return false;
70380
+ if (!markFromMarks?.attrs)
70381
+ return false;
70382
+ const markFromExisting = encode$80({ fontFamily: existingFontFamily }, docx)?.[0];
70383
+ if (!markFromExisting?.attrs)
70384
+ return false;
70385
+ return markFromMarks.attrs.fontFamily === markFromExisting.attrs.fontFamily;
70386
+ }
70363
70387
  function getRunContext($pos) {
70364
70388
  let paragraphNode = null;
70365
70389
  let paragraphDepth = -1;
@@ -70479,10 +70503,13 @@ function getInlineRunProperties(runPropertiesFromMarks, runPropertiesFromStyles,
70479
70503
  const valueFromStyles = runPropertiesFromStyles[key];
70480
70504
  if (JSON.stringify(valueFromMarks) !== JSON.stringify(valueFromStyles))
70481
70505
  if (key === "fontFamily") {
70482
- const markFromStyles = encodeMarksFromRPr({ [key]: valueFromStyles }, editor.converter?.convertedXml ?? {})[0];
70483
- const markFromMarks = encodeMarksFromRPr({ [key]: valueFromMarks }, editor.converter?.convertedXml ?? {})[0];
70484
- if (JSON.stringify(markFromMarks?.attrs) !== JSON.stringify(markFromStyles?.attrs))
70485
- inlineRunProperties[key] = valueFromMarks;
70506
+ const docx = editor.converter?.convertedXml ?? {};
70507
+ const markFromStyles = encodeMarksFromRPr({ [key]: valueFromStyles }, docx)[0];
70508
+ const markFromMarks = encodeMarksFromRPr({ [key]: valueFromMarks }, docx)[0];
70509
+ if (JSON.stringify(markFromMarks?.attrs) !== JSON.stringify(markFromStyles?.attrs)) {
70510
+ const existingFontFamily = existingRunProperties?.[key];
70511
+ inlineRunProperties[key] = marksMatchExistingFontFamily(markFromMarks, existingFontFamily, encodeMarksFromRPr, docx) ? mergeFontFamilyPreservingThemeRefs(valueFromMarks, existingFontFamily) : valueFromMarks;
70512
+ }
70486
70513
  } else
70487
70514
  inlineRunProperties[key] = valueFromMarks;
70488
70515
  }
@@ -87419,10 +87446,32 @@ function removeSdtPrChild(sdtPr, childName) {
87419
87446
  };
87420
87447
  }
87421
87448
  function applyAttrsUpdate(editor, nodeId, attrsPatch) {
87422
- const updateCmd = editor.commands?.updateStructuredContentById;
87423
- if (typeof updateCmd !== "function")
87449
+ if (!editor?.state)
87424
87450
  return false;
87425
- return Boolean(updateCmd(nodeId, { attrs: attrsPatch }));
87451
+ let foundPos = null;
87452
+ editor.state.doc.descendants((node2, pos) => {
87453
+ if (foundPos !== null)
87454
+ return false;
87455
+ if (SDT_NODE_TYPES.has(node2.type.name) && String(node2.attrs.id) === String(nodeId)) {
87456
+ foundPos = pos;
87457
+ return false;
87458
+ }
87459
+ return true;
87460
+ });
87461
+ if (foundPos === null)
87462
+ return false;
87463
+ const tr = editor.state.tr;
87464
+ for (const [key, value] of Object.entries(attrsPatch))
87465
+ tr.setNodeAttribute(foundPos, key, value);
87466
+ if (tr.steps.length === 0)
87467
+ return true;
87468
+ if (editor.view?.dispatch)
87469
+ editor.view.dispatch(tr);
87470
+ else if (typeof editor.dispatch === "function")
87471
+ editor.dispatch(tr);
87472
+ else
87473
+ return false;
87474
+ return true;
87426
87475
  }
87427
87476
  function updateSdtPrChild(editor, target, childName, updater) {
87428
87477
  const currentSdtPr = resolveSdtByTarget(editor.state.doc, target).node.attrs.sdtPr ?? {
@@ -87656,6 +87705,59 @@ function buildContentControlInfoFromAttrs(attrs, kind) {
87656
87705
  }
87657
87706
  };
87658
87707
  }
87708
+ function assertNotSdtLocked(sdt, operation) {
87709
+ const mode = resolveLockMode(sdt.node.attrs);
87710
+ if (mode === "sdtLocked" || mode === "sdtContentLocked")
87711
+ throw new DocumentApiAdapterError("LOCK_VIOLATION", `Content control "${sdt.node.attrs.id}" has lock mode "${mode}" which prevents ${operation}.`, {
87712
+ lockMode: mode,
87713
+ operation
87714
+ });
87715
+ }
87716
+ function assertNotContentLocked(sdt, operation) {
87717
+ const mode = resolveLockMode(sdt.node.attrs);
87718
+ if (mode === "contentLocked" || mode === "sdtContentLocked")
87719
+ throw new DocumentApiAdapterError("LOCK_VIOLATION", `Content control "${sdt.node.attrs.id}" has lock mode "${mode}" which prevents ${operation}.`, {
87720
+ lockMode: mode,
87721
+ operation
87722
+ });
87723
+ }
87724
+ function assertControlType(sdt, expected, operation) {
87725
+ const actual = resolveControlType(sdt.node.attrs);
87726
+ const allowed = Array.isArray(expected) ? expected : [expected];
87727
+ if (!allowed.includes(actual))
87728
+ throw new DocumentApiAdapterError("TYPE_MISMATCH", `Operation "${operation}" requires control type ${allowed.join(" or ")}, but found "${actual}".`, {
87729
+ expected: allowed,
87730
+ actual,
87731
+ operation
87732
+ });
87733
+ }
87734
+ function buildMutationSuccess(target, updatedRef) {
87735
+ const result = {
87736
+ success: true,
87737
+ contentControl: target
87738
+ };
87739
+ if (updatedRef)
87740
+ result.updatedRef = updatedRef;
87741
+ return result;
87742
+ }
87743
+ function buildMutationFailure(code$1, message) {
87744
+ return {
87745
+ success: false,
87746
+ failure: {
87747
+ code: code$1,
87748
+ message
87749
+ }
87750
+ };
87751
+ }
87752
+ function applyPagination(items, opts) {
87753
+ const total = items.length;
87754
+ const offset = opts?.offset ?? 0;
87755
+ const limit = opts?.limit ?? total;
87756
+ return {
87757
+ items: items.slice(offset, offset + limit),
87758
+ total
87759
+ };
87760
+ }
87659
87761
  function resolveBlock(editor, nodeId) {
87660
87762
  const matches$1 = getBlockIndex(editor).candidates.filter((c$1) => c$1.nodeId === nodeId && (c$1.nodeType === "paragraph" || c$1.nodeType === "listItem"));
87661
87763
  if (matches$1.length === 0)
@@ -90906,7 +91008,7 @@ var isRegExp = (value) => {
90906
91008
  return true;
90907
91009
  }, areAttrsEqual = (attrsA = {}, attrsB = {}) => {
90908
91010
  return objectIncludes(attrsA, attrsB);
90909
- }, TrackInsertMarkName = "trackInsert", TrackDeleteMarkName = "trackDelete", TrackFormatMarkName = "trackFormat", TrackedFormatMarkNames, SUBSCRIPT_SUPERSCRIPT_SCALE = 0.65, BASELINE_SHIFT_EPSILON = 0.000001, TABLE_STYLE_ID_TABLE_GRID = "TableGrid", TABLE_FALLBACK_BORDER, TABLE_FALLBACK_BORDERS, TABLE_FALLBACK_CELL_PADDING, DEFAULT_TBL_LOOK, CNF_STYLE_MAP, TABLE_STYLE_PRECEDENCE, getToCssFontFamily = () => {
91011
+ }, TrackInsertMarkName = "trackInsert", TrackDeleteMarkName = "trackDelete", TrackFormatMarkName = "trackFormat", TrackedFormatMarkNames, SUBSCRIPT_SUPERSCRIPT_SCALE = 0.65, BASELINE_SHIFT_EPSILON = 0.000001, FONT_SLOT_THEME_PAIRS, TABLE_STYLE_ID_TABLE_GRID = "TableGrid", TABLE_FALLBACK_BORDER, TABLE_FALLBACK_BORDERS, TABLE_FALLBACK_CELL_PADDING, DEFAULT_TBL_LOOK, CNF_STYLE_MAP, TABLE_STYLE_PRECEDENCE, getToCssFontFamily = () => {
90910
91012
  return SuperConverter.toCssFontFamily;
90911
91013
  }, getSpacingStyle = (spacing, isListItem$1) => {
90912
91014
  let { before, after, line, lineRule, beforeAutospacing, afterAutospacing } = spacing;
@@ -105358,7 +105460,7 @@ var isRegExp = (value) => {
105358
105460
  if (id)
105359
105461
  return trackedChanges.filter(({ mark }) => mark.attrs.id === id);
105360
105462
  return trackedChanges;
105361
- }, DERIVED_ID_LENGTH = 24, groupedCache, SDT_NODE_NAMES, SDT_BLOCK_NAME = "structuredContentBlock", VALID_CONTROL_TYPES, VALID_LOCK_MODES, VALID_APPEARANCES, FIELD_LIKE_SDT_TYPES, liveDocumentCountsCache, BIBLIOGRAPHY_NAMESPACE_URI = "http://schemas.openxmlformats.org/officeDocument/2006/bibliography", CUSTOM_XML_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml", CUSTOM_XML_PROPS_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps", DEFAULT_SELECTED_STYLE = "/APA.XSL", DEFAULT_STYLE_NAME = "APA", DEFAULT_VERSION = "6", API_TO_OOXML_SOURCE_TYPE, OOXML_TO_API_SOURCE_TYPE, SIMPLE_FIELD_TO_XML_TAG, XML_TAG_TO_SIMPLE_FIELD, import_lib2, FONT_FAMILY_FALLBACKS, DEFAULT_GENERIC_FALLBACK = "sans-serif", DEFAULT_FONT_SIZE_PT = 10, CURRENT_APP_VERSION = "1.32.0", collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state }) => {
105463
+ }, DERIVED_ID_LENGTH = 24, groupedCache, SDT_NODE_NAMES, SDT_BLOCK_NAME = "structuredContentBlock", SDT_NODE_TYPES, VALID_CONTROL_TYPES, VALID_LOCK_MODES, VALID_APPEARANCES, FIELD_LIKE_SDT_TYPES, liveDocumentCountsCache, BIBLIOGRAPHY_NAMESPACE_URI = "http://schemas.openxmlformats.org/officeDocument/2006/bibliography", CUSTOM_XML_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml", CUSTOM_XML_PROPS_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps", DEFAULT_SELECTED_STYLE = "/APA.XSL", DEFAULT_STYLE_NAME = "APA", DEFAULT_VERSION = "6", API_TO_OOXML_SOURCE_TYPE, OOXML_TO_API_SOURCE_TYPE, SIMPLE_FIELD_TO_XML_TAG, XML_TAG_TO_SIMPLE_FIELD, import_lib2, FONT_FAMILY_FALLBACKS, DEFAULT_GENERIC_FALLBACK = "sans-serif", DEFAULT_FONT_SIZE_PT = 10, CURRENT_APP_VERSION = "1.32.0", collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state }) => {
105362
105464
  if (!runProps?.elements?.length || !state)
105363
105465
  return;
105364
105466
  const fontsNode = runProps.elements.find((el) => el.name === "w:rFonts");
@@ -105392,7 +105494,7 @@ var isRegExp = (value) => {
105392
105494
  state.kern = kernNode.attributes["w:val"];
105393
105495
  }
105394
105496
  }, SuperConverter;
105395
- var init_SuperConverter_KEGUvaEC_es = __esm(() => {
105497
+ var init_SuperConverter_D_cFThyR_es = __esm(() => {
105396
105498
  init_rolldown_runtime_Bg48TavK_es();
105397
105499
  init_jszip_C49i9kUs_es();
105398
105500
  init_xml_js_CqGKpaft_es();
@@ -121058,6 +121160,12 @@ var init_SuperConverter_KEGUvaEC_es = __esm(() => {
121058
121160
  "highlight",
121059
121161
  "link"
121060
121162
  ];
121163
+ FONT_SLOT_THEME_PAIRS = [
121164
+ ["ascii", "asciiTheme"],
121165
+ ["hAnsi", "hAnsiTheme"],
121166
+ ["eastAsia", "eastAsiaTheme"],
121167
+ ["cs", "cstheme"]
121168
+ ];
121061
121169
  TABLE_FALLBACK_BORDER = {
121062
121170
  val: "single",
121063
121171
  size: 4,
@@ -142117,6 +142225,7 @@ var init_SuperConverter_KEGUvaEC_es = __esm(() => {
142117
142225
  };
142118
142226
  groupedCache = /* @__PURE__ */ new WeakMap;
142119
142227
  SDT_NODE_NAMES = ["structuredContent", "structuredContentBlock"];
142228
+ SDT_NODE_TYPES = new Set(SDT_NODE_NAMES);
142120
142229
  VALID_CONTROL_TYPES = [
142121
142230
  "text",
142122
142231
  "richText",
@@ -143259,7 +143368,7 @@ var init_SuperConverter_KEGUvaEC_es = __esm(() => {
143259
143368
  };
143260
143369
  });
143261
143370
 
143262
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DwiDDjhC.es.js
143371
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DkFBZ1T1.es.js
143263
143372
  function parseSizeUnit(val = "0") {
143264
143373
  const length = val.toString() || "0";
143265
143374
  const value = Number.parseFloat(length);
@@ -145981,8 +146090,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
145981
146090
  }
145982
146091
  };
145983
146092
  };
145984
- var init_create_headless_toolbar_DwiDDjhC_es = __esm(() => {
145985
- init_SuperConverter_KEGUvaEC_es();
146093
+ var init_create_headless_toolbar_DkFBZ1T1_es = __esm(() => {
146094
+ init_SuperConverter_D_cFThyR_es();
145986
146095
  init_constants_DrU4EASo_es();
145987
146096
  init_dist_B8HfvhaK_es();
145988
146097
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
@@ -200201,7 +200310,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
200201
200310
  init_remark_gfm_BhnWr3yf_es();
200202
200311
  });
200203
200312
 
200204
- // ../../packages/superdoc/dist/chunks/src-C1MFxjAm.es.js
200313
+ // ../../packages/superdoc/dist/chunks/src-CHVby7ed.es.js
200205
200314
  function deleteProps(obj, propOrProps) {
200206
200315
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
200207
200316
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -200456,6 +200565,16 @@ function getParagraphInlineDirection(attrs) {
200456
200565
  if (attrs?.direction === "ltr" || attrs?.dir === "ltr" || attrs?.rtl === false || ppRtl === false)
200457
200566
  return "ltr";
200458
200567
  }
200568
+ function getTableVisualDirection(attrs) {
200569
+ const fromContext = attrs?.tableDirectionContext?.visualDirection;
200570
+ if (fromContext != null)
200571
+ return fromContext;
200572
+ const tp = attrs?.tableProperties;
200573
+ if (tp?.rightToLeft === true || tp?.bidiVisual === true)
200574
+ return "rtl";
200575
+ if (tp?.rightToLeft === false || tp?.bidiVisual === false)
200576
+ return "ltr";
200577
+ }
200459
200578
  function resolveTableWidthAttr(value) {
200460
200579
  if (!value || typeof value !== "object")
200461
200580
  return null;
@@ -200979,59 +201098,6 @@ function getSuperdocVersion() {
200979
201098
  return "unknown";
200980
201099
  }
200981
201100
  }
200982
- function assertNotSdtLocked(sdt, operation) {
200983
- const mode = resolveLockMode(sdt.node.attrs);
200984
- if (mode === "sdtLocked" || mode === "sdtContentLocked")
200985
- throw new DocumentApiAdapterError("LOCK_VIOLATION", `Content control "${sdt.node.attrs.id}" has lock mode "${mode}" which prevents ${operation}.`, {
200986
- lockMode: mode,
200987
- operation
200988
- });
200989
- }
200990
- function assertNotContentLocked(sdt, operation) {
200991
- const mode = resolveLockMode(sdt.node.attrs);
200992
- if (mode === "contentLocked" || mode === "sdtContentLocked")
200993
- throw new DocumentApiAdapterError("LOCK_VIOLATION", `Content control "${sdt.node.attrs.id}" has lock mode "${mode}" which prevents ${operation}.`, {
200994
- lockMode: mode,
200995
- operation
200996
- });
200997
- }
200998
- function assertControlType(sdt, expected, operation) {
200999
- const actual = resolveControlType(sdt.node.attrs);
201000
- const allowed = Array.isArray(expected) ? expected : [expected];
201001
- if (!allowed.includes(actual))
201002
- throw new DocumentApiAdapterError("TYPE_MISMATCH", `Operation "${operation}" requires control type ${allowed.join(" or ")}, but found "${actual}".`, {
201003
- expected: allowed,
201004
- actual,
201005
- operation
201006
- });
201007
- }
201008
- function buildMutationSuccess(target, updatedRef) {
201009
- const result = {
201010
- success: true,
201011
- contentControl: target
201012
- };
201013
- if (updatedRef)
201014
- result.updatedRef = updatedRef;
201015
- return result;
201016
- }
201017
- function buildMutationFailure(code7, message) {
201018
- return {
201019
- success: false,
201020
- failure: {
201021
- code: code7,
201022
- message
201023
- }
201024
- };
201025
- }
201026
- function applyPagination(items, opts) {
201027
- const total = items.length;
201028
- const offset$1 = opts?.offset ?? 0;
201029
- const limit = opts?.limit ?? total;
201030
- return {
201031
- items: items.slice(offset$1, offset$1 + limit),
201032
- total
201033
- };
201034
- }
201035
201101
  function getFocusMeta(tr) {
201036
201102
  return tr.getMeta(CustomSelectionPluginKey);
201037
201103
  }
@@ -204955,7 +205021,7 @@ function getTableContext($head) {
204955
205021
  };
204956
205022
  }
204957
205023
  function isRtlTable(table2) {
204958
- return table2?.attrs?.tableProperties?.rightToLeft === true;
205024
+ return getTableVisualDirection(table2?.attrs) === "rtl";
204959
205025
  }
204960
205026
  function getCellRect(context) {
204961
205027
  const map$12 = TableMap.get(context.table);
@@ -235714,22 +235780,24 @@ function alreadyMatchesPlainTextReplacement(sdt, expectedText) {
235714
235780
  }
235715
235781
  function replaceSdtTextContent(editor, target, text5) {
235716
235782
  const resolved = resolveSdtByTarget(editor.state.doc, target);
235783
+ const { tr } = editor.state;
235784
+ const innerFrom = resolved.pos + 1;
235785
+ const innerTo = resolved.pos + resolved.node.nodeSize - 1;
235717
235786
  if (resolved.kind === "inline") {
235718
- const updateCmd = editor.commands?.updateStructuredContentById;
235719
- if (text5.length > 0)
235720
- return Boolean(updateCmd?.(target.nodeId, { text: text5 }));
235721
- const updatedNode$1 = resolved.node.type.create({ ...resolved.node.attrs }, null, resolved.node.marks);
235722
- const { tr: tr$1 } = editor.state;
235723
- tr$1.replaceWith(resolved.pos, resolved.pos + resolved.node.nodeSize, updatedNode$1);
235724
- dispatchTransaction(editor, tr$1);
235787
+ if (text5.length > 0) {
235788
+ const textNode = editor.schema.text(text5);
235789
+ tr.replaceWith(innerFrom, innerTo, textNode);
235790
+ } else
235791
+ tr.delete(innerFrom, innerTo);
235792
+ dispatchTransaction(editor, tr);
235725
235793
  return true;
235726
235794
  }
235727
235795
  const paragraph2 = buildEmptyBlockContent(editor, resolved.node);
235796
+ if (!paragraph2)
235797
+ return false;
235728
235798
  const paragraphText = text5.length > 0 ? buildTextWithTabs(editor.schema, text5, undefined) : null;
235729
- const updatedParagraph = paragraph2?.type.create(paragraph2.attrs ?? null, paragraphText, paragraph2.marks) ?? null;
235730
- const updatedNode = resolved.node.type.create({ ...resolved.node.attrs }, updatedParagraph, resolved.node.marks);
235731
- const { tr } = editor.state;
235732
- tr.replaceWith(resolved.pos, resolved.pos + resolved.node.nodeSize, updatedNode);
235799
+ const updatedParagraph = paragraph2.type.create(paragraph2.attrs ?? null, paragraphText, paragraph2.marks);
235800
+ tr.replaceWith(innerFrom, innerTo, updatedParagraph);
235733
235801
  dispatchTransaction(editor, tr);
235734
235802
  return true;
235735
235803
  }
@@ -246725,7 +246793,7 @@ function resolveRenderedTableWidth(columnWidth, measuredWidth, attrs) {
246725
246793
  function resolveTableFrame(baseX, columnWidth, tableWidth, attrs) {
246726
246794
  const width = resolveRenderedTableWidth(columnWidth, tableWidth, attrs);
246727
246795
  const explicitJustification = typeof attrs?.justification === "string" ? attrs.justification : undefined;
246728
- const isRtlTable$1 = attrs?.tableProperties?.rightToLeft === true;
246796
+ const isRtlTable$1 = getTableVisualDirection(attrs) === "rtl";
246729
246797
  const effectiveJustification = explicitJustification ?? (isRtlTable$1 ? "end" : undefined);
246730
246798
  const tableIndent = getTableIndentWidth(attrs);
246731
246799
  if (effectiveJustification === "center")
@@ -257048,6 +257116,12 @@ function tableNodeToBlock(node2, { nextBlockId, positions, storyKey, trackedChan
257048
257116
  const tableProperties = node2.attrs?.tableProperties;
257049
257117
  if (tableProperties && typeof tableProperties === "object")
257050
257118
  tableAttrs.tableProperties = tableProperties;
257119
+ const styleResolvedTableProps = effectiveStyleId && converterContext?.translatedLinkedStyles ? resolveTableProperties(effectiveStyleId, converterContext.translatedLinkedStyles) : undefined;
257120
+ const inlineProps = rawTableProperties;
257121
+ const styleProps = styleResolvedTableProps;
257122
+ const inlineVisual = inlineProps?.rightToLeft ?? inlineProps?.bidiVisual;
257123
+ const styleVisual = styleProps?.rightToLeft ?? styleProps?.bidiVisual;
257124
+ tableAttrs.tableDirectionContext = resolveTableDirection({ rightToLeft: inlineVisual ?? styleVisual }, converterContext?.sectionDirectionContext ?? resolveSectionDirection(undefined));
257051
257125
  let columnWidths = undefined;
257052
257126
  const twipsToPixels$2 = (twips) => {
257053
257127
  return twips / 1440 * 96;
@@ -281617,7 +281691,7 @@ menclose::after {
281617
281691
  const tableBorders = block.attrs?.borders;
281618
281692
  const tableIndentValue = block.attrs?.tableIndent?.width;
281619
281693
  const tableIndent = typeof tableIndentValue === "number" && Number.isFinite(tableIndentValue) ? tableIndentValue : 0;
281620
- const isRtl = block.attrs?.tableProperties?.rightToLeft === true;
281694
+ const isRtl = getTableVisualDirection(block.attrs) === "rtl";
281621
281695
  const container = doc$12.createElement("div");
281622
281696
  container.classList.add(CLASS_NAMES$1.fragment);
281623
281697
  applyStyles$2(container, fragmentStyles);
@@ -287135,6 +287209,16 @@ menclose::after {
287135
287209
  mutated = true;
287136
287210
  }
287137
287211
  return mutated ? mirrored : indent2;
287212
+ }, resolveTableDirection = (tableProperties, parentSection) => {
287213
+ let visualDirection;
287214
+ if (tableProperties?.rightToLeft === true || tableProperties?.bidiVisual === true)
287215
+ visualDirection = "rtl";
287216
+ else if (tableProperties?.rightToLeft === false || tableProperties?.bidiVisual === false)
287217
+ visualDirection = "ltr";
287218
+ return {
287219
+ visualDirection,
287220
+ parentSection
287221
+ };
287138
287222
  }, writingModeFromTextDirection = (val) => {
287139
287223
  switch (val) {
287140
287224
  case "lrTb":
@@ -294049,12 +294133,12 @@ menclose::after {
294049
294133
  return;
294050
294134
  console.log(...args$1);
294051
294135
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
294052
- var init_src_C1MFxjAm_es = __esm(() => {
294136
+ var init_src_CHVby7ed_es = __esm(() => {
294053
294137
  init_rolldown_runtime_Bg48TavK_es();
294054
- init_SuperConverter_KEGUvaEC_es();
294138
+ init_SuperConverter_D_cFThyR_es();
294055
294139
  init_jszip_C49i9kUs_es();
294056
294140
  init_uuid_qzgm05fK_es();
294057
- init_create_headless_toolbar_DwiDDjhC_es();
294141
+ init_create_headless_toolbar_DkFBZ1T1_es();
294058
294142
  init_constants_DrU4EASo_es();
294059
294143
  init_dist_B8HfvhaK_es();
294060
294144
  init_unified_Dsuw2be5_es();
@@ -332097,11 +332181,11 @@ function print() { __p += __j.call(arguments, '') }
332097
332181
  ];
332098
332182
  });
332099
332183
 
332100
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-BEAzL3ry.es.js
332184
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-0ZhHPCRD.es.js
332101
332185
  var MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS;
332102
- var init_create_super_doc_ui_BEAzL3ry_es = __esm(() => {
332103
- init_SuperConverter_KEGUvaEC_es();
332104
- init_create_headless_toolbar_DwiDDjhC_es();
332186
+ var init_create_super_doc_ui_0ZhHPCRD_es = __esm(() => {
332187
+ init_SuperConverter_D_cFThyR_es();
332188
+ init_create_headless_toolbar_DkFBZ1T1_es();
332105
332189
  MOD_ALIASES = new Set([
332106
332190
  "Mod",
332107
332191
  "Meta",
@@ -332143,16 +332227,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
332143
332227
 
332144
332228
  // ../../packages/superdoc/dist/super-editor.es.js
332145
332229
  var init_super_editor_es = __esm(() => {
332146
- init_src_C1MFxjAm_es();
332147
- init_SuperConverter_KEGUvaEC_es();
332230
+ init_src_CHVby7ed_es();
332231
+ init_SuperConverter_D_cFThyR_es();
332148
332232
  init_jszip_C49i9kUs_es();
332149
332233
  init_xml_js_CqGKpaft_es();
332150
- init_create_headless_toolbar_DwiDDjhC_es();
332234
+ init_create_headless_toolbar_DkFBZ1T1_es();
332151
332235
  init_constants_DrU4EASo_es();
332152
332236
  init_dist_B8HfvhaK_es();
332153
332237
  init_unified_Dsuw2be5_es();
332154
332238
  init_DocxZipper_TPSo9G36_es();
332155
- init_create_super_doc_ui_BEAzL3ry_es();
332239
+ init_create_super_doc_ui_0ZhHPCRD_es();
332156
332240
  init_ui_CGB3qmy3_es();
332157
332241
  init_eventemitter3_UwU_CLPU_es();
332158
332242
  init_errors_C_DoKMoN_es();
@@ -371184,10 +371268,34 @@ function removeSdtPrChild2(sdtPr, childName) {
371184
371268
  return { ...sdtPr, elements: sdtPr.elements.filter((el) => el.name !== childName) };
371185
371269
  }
371186
371270
  function applyAttrsUpdate2(editor, nodeId, attrsPatch) {
371187
- const updateCmd = editor.commands?.updateStructuredContentById;
371188
- if (typeof updateCmd !== "function")
371271
+ if (!editor?.state)
371272
+ return false;
371273
+ let foundPos = null;
371274
+ editor.state.doc.descendants((node3, pos) => {
371275
+ if (foundPos !== null)
371276
+ return false;
371277
+ if (SDT_NODE_TYPES2.has(node3.type.name) && String(node3.attrs.id) === String(nodeId)) {
371278
+ foundPos = pos;
371279
+ return false;
371280
+ }
371281
+ return true;
371282
+ });
371283
+ if (foundPos === null)
371284
+ return false;
371285
+ const tr = editor.state.tr;
371286
+ for (const [key2, value] of Object.entries(attrsPatch)) {
371287
+ tr.setNodeAttribute(foundPos, key2, value);
371288
+ }
371289
+ if (tr.steps.length === 0)
371290
+ return true;
371291
+ if (editor.view?.dispatch) {
371292
+ editor.view.dispatch(tr);
371293
+ } else if (typeof editor.dispatch === "function") {
371294
+ editor.dispatch(tr);
371295
+ } else {
371189
371296
  return false;
371190
- return Boolean(updateCmd(nodeId, { attrs: attrsPatch }));
371297
+ }
371298
+ return true;
371191
371299
  }
371192
371300
  function updateSdtPrChild2(editor, target, childName, updater) {
371193
371301
  const resolved = resolveSdtByTarget2(editor.state.doc, target);
@@ -371224,8 +371332,10 @@ function replaceSdtPrSubElements2(editor, target, childName, elements) {
371224
371332
  elements
371225
371333
  }));
371226
371334
  }
371335
+ var SDT_NODE_TYPES2;
371227
371336
  var init_sdt_properties_write = __esm(() => {
371228
371337
  init_target_resolution();
371338
+ SDT_NODE_TYPES2 = new Set(SDT_NODE_NAMES2);
371229
371339
  });
371230
371340
 
371231
371341
  // ../../packages/super-editor/src/editors/v1/document-api-adapters/helpers/content-controls/sdt-info-builder.ts
@@ -372730,20 +372840,25 @@ function combineProperties2(propertiesArray, options = {}) {
372730
372840
  function isObject4(item) {
372731
372841
  return item != null && typeof item === "object" && !Array.isArray(item);
372732
372842
  }
372843
+ function dropConflictingFontSlots2(target, source) {
372844
+ const result = { ...target };
372845
+ for (const [concreteKey, themeKey] of FONT_SLOT_THEME_PAIRS2) {
372846
+ if (source[themeKey] != null) {
372847
+ delete result[concreteKey];
372848
+ delete result[themeKey];
372849
+ } else if (source[concreteKey] != null) {
372850
+ delete result[themeKey];
372851
+ }
372852
+ }
372853
+ return result;
372854
+ }
372733
372855
  function combineRunProperties2(propertiesArray) {
372734
372856
  return combineProperties2(propertiesArray, {
372735
372857
  fullOverrideProps: ["color"],
372736
372858
  specialHandling: {
372737
372859
  fontFamily: (target, source) => {
372738
372860
  const fontFamilySource = { ...source.fontFamily };
372739
- const fontFamilyTarget = { ...target.fontFamily };
372740
- if (fontFamilySource.asciiTheme != null) {
372741
- delete fontFamilyTarget.ascii;
372742
- delete fontFamilyTarget.asciiTheme;
372743
- }
372744
- if (fontFamilySource.ascii != null) {
372745
- delete fontFamilyTarget.asciiTheme;
372746
- }
372861
+ const fontFamilyTarget = dropConflictingFontSlots2(target.fontFamily ?? {}, fontFamilySource);
372747
372862
  return { ...fontFamilyTarget, ...fontFamilySource };
372748
372863
  }
372749
372864
  }
@@ -372768,6 +372883,15 @@ function combineIndentProperties2(indentChain) {
372768
372883
  }
372769
372884
  });
372770
372885
  }
372886
+ var FONT_SLOT_THEME_PAIRS2;
372887
+ var init_cascade = __esm(() => {
372888
+ FONT_SLOT_THEME_PAIRS2 = [
372889
+ ["ascii", "asciiTheme"],
372890
+ ["hAnsi", "hAnsiTheme"],
372891
+ ["eastAsia", "eastAsiaTheme"],
372892
+ ["cs", "cstheme"]
372893
+ ];
372894
+ });
372771
372895
 
372772
372896
  // ../../packages/layout-engine/style-engine/src/ooxml/table-style-selection.ts
372773
372897
  function isKnownTableStyleId2(styleId, translatedLinkedStyles) {
@@ -373144,6 +373268,7 @@ function determineCellStyleTypes2(tblLook, rowIndex, cellIndex, numRows, numCell
373144
373268
  }
373145
373269
  var DEFAULT_TBL_LOOK2, CNF_STYLE_MAP2, TABLE_STYLE_PRECEDENCE2;
373146
373270
  var init_ooxml = __esm(() => {
373271
+ init_cascade();
373147
373272
  init_table_style_selection();
373148
373273
  DEFAULT_TBL_LOOK2 = {
373149
373274
  firstRow: true,
@@ -428528,6 +428653,7 @@ var RUN_PROPERTIES_DERIVED_FROM_MARKS2, TRANSIENT_HYPERLINK_STYLE_IDS2;
428528
428653
  var init_calculateInlineRunPropertiesPlugin = __esm(() => {
428529
428654
  init_dist10();
428530
428655
  init_styles3();
428656
+ init_ooxml();
428531
428657
  init_resolvedPropertiesCache();
428532
428658
  RUN_PROPERTIES_DERIVED_FROM_MARKS2 = new Set([
428533
428659
  "strike",
@@ -458201,23 +458327,25 @@ function alreadyMatchesPlainTextReplacement2(sdt, expectedText) {
458201
458327
  }
458202
458328
  function replaceSdtTextContent2(editor, target, text9) {
458203
458329
  const resolved = resolveSdtByTarget2(editor.state.doc, target);
458330
+ const { tr } = editor.state;
458331
+ const innerFrom = resolved.pos + 1;
458332
+ const innerTo = resolved.pos + resolved.node.nodeSize - 1;
458204
458333
  if (resolved.kind === "inline") {
458205
- const updateCmd = editor.commands?.updateStructuredContentById;
458206
458334
  if (text9.length > 0) {
458207
- return Boolean(updateCmd?.(target.nodeId, { text: text9 }));
458335
+ const textNode = editor.schema.text(text9);
458336
+ tr.replaceWith(innerFrom, innerTo, textNode);
458337
+ } else {
458338
+ tr.delete(innerFrom, innerTo);
458208
458339
  }
458209
- const updatedNode2 = resolved.node.type.create({ ...resolved.node.attrs }, null, resolved.node.marks);
458210
- const { tr: tr2 } = editor.state;
458211
- tr2.replaceWith(resolved.pos, resolved.pos + resolved.node.nodeSize, updatedNode2);
458212
- dispatchTransaction4(editor, tr2);
458340
+ dispatchTransaction4(editor, tr);
458213
458341
  return true;
458214
458342
  }
458215
458343
  const paragraph4 = buildEmptyBlockContent2(editor, resolved.node);
458344
+ if (!paragraph4)
458345
+ return false;
458216
458346
  const paragraphText = text9.length > 0 ? buildTextWithTabs2(editor.schema, text9, undefined) : null;
458217
- const updatedParagraph = paragraph4?.type.create(paragraph4.attrs ?? null, paragraphText, paragraph4.marks) ?? null;
458218
- const updatedNode = resolved.node.type.create({ ...resolved.node.attrs }, updatedParagraph, resolved.node.marks);
458219
- const { tr } = editor.state;
458220
- tr.replaceWith(resolved.pos, resolved.pos + resolved.node.nodeSize, updatedNode);
458347
+ const updatedParagraph = paragraph4.type.create(paragraph4.attrs ?? null, paragraphText, paragraph4.marks);
458348
+ tr.replaceWith(innerFrom, innerTo, updatedParagraph);
458221
458349
  dispatchTransaction4(editor, tr);
458222
458350
  return true;
458223
458351
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.3.0-next.91",
3
+ "version": "0.3.0-next.93",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"