@superdoc-dev/mcp 0.3.0-next.92 → 0.3.0-next.94

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 +240 -130
  2. package/package.json +2 -2
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-B-EF8ijE.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
  } }
@@ -62912,6 +62915,12 @@ function extractAppearance(sdtPr) {
62912
62915
  function extractPlaceholder(sdtPr) {
62913
62916
  return sdtPr?.elements?.find((e) => e.name === "w:placeholder")?.elements?.find((e) => e.name === "w:docPart")?.attributes?.["w:val"] ?? null;
62914
62917
  }
62918
+ function extractTemporary(sdtPr) {
62919
+ const el = sdtPr?.elements?.find((e) => e.name === "w:temporary");
62920
+ if (!el)
62921
+ return;
62922
+ return parseStrictStOnOff(el.attributes?.["w:val"], "temporary", "w:temporary");
62923
+ }
62915
62924
  function handleStructuredContentNode(params) {
62916
62925
  const { nodes, nodeListHandler } = params;
62917
62926
  if (nodes.length === 0 || nodes[0].name !== "w:sdt")
@@ -62932,6 +62941,7 @@ function handleStructuredContentNode(params) {
62932
62941
  const controlType = detectControlType(sdtPr);
62933
62942
  const appearance = extractAppearance(sdtPr);
62934
62943
  const placeholder = extractPlaceholder(sdtPr);
62944
+ const temporary = extractTemporary(sdtPr);
62935
62945
  if (!sdtContent)
62936
62946
  return null;
62937
62947
  const paragraph2 = sdtContent.elements?.find((el) => el.name === "w:p");
@@ -62955,6 +62965,7 @@ function handleStructuredContentNode(params) {
62955
62965
  type: controlType,
62956
62966
  appearance,
62957
62967
  placeholder,
62968
+ ...temporary !== undefined ? { temporary } : {},
62958
62969
  sdtPr
62959
62970
  }
62960
62971
  };
@@ -70360,6 +70371,27 @@ function resolveHypotheticalParagraphProperties(editor, $pos, inlineProps) {
70360
70371
  translatedLinkedStyles: editor.converter.translatedLinkedStyles
70361
70372
  }, inlineProps, tableStyleId);
70362
70373
  }
70374
+ function mergeFontFamilyPreservingThemeRefs(fromMarks, existing) {
70375
+ const merged = { ...fromMarks || {} };
70376
+ if (!existing || typeof existing !== "object")
70377
+ return merged;
70378
+ for (const [concreteKey, themeKey] of FONT_SLOT_THEME_PAIRS)
70379
+ if (existing[themeKey] != null) {
70380
+ merged[themeKey] = existing[themeKey];
70381
+ delete merged[concreteKey];
70382
+ }
70383
+ return merged;
70384
+ }
70385
+ function marksMatchExistingFontFamily(markFromMarks, existingFontFamily, encode$80, docx) {
70386
+ if (!existingFontFamily || typeof existingFontFamily !== "object")
70387
+ return false;
70388
+ if (!markFromMarks?.attrs)
70389
+ return false;
70390
+ const markFromExisting = encode$80({ fontFamily: existingFontFamily }, docx)?.[0];
70391
+ if (!markFromExisting?.attrs)
70392
+ return false;
70393
+ return markFromMarks.attrs.fontFamily === markFromExisting.attrs.fontFamily;
70394
+ }
70363
70395
  function getRunContext($pos) {
70364
70396
  let paragraphNode = null;
70365
70397
  let paragraphDepth = -1;
@@ -70479,10 +70511,13 @@ function getInlineRunProperties(runPropertiesFromMarks, runPropertiesFromStyles,
70479
70511
  const valueFromStyles = runPropertiesFromStyles[key];
70480
70512
  if (JSON.stringify(valueFromMarks) !== JSON.stringify(valueFromStyles))
70481
70513
  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;
70514
+ const docx = editor.converter?.convertedXml ?? {};
70515
+ const markFromStyles = encodeMarksFromRPr({ [key]: valueFromStyles }, docx)[0];
70516
+ const markFromMarks = encodeMarksFromRPr({ [key]: valueFromMarks }, docx)[0];
70517
+ if (JSON.stringify(markFromMarks?.attrs) !== JSON.stringify(markFromStyles?.attrs)) {
70518
+ const existingFontFamily = existingRunProperties?.[key];
70519
+ inlineRunProperties[key] = marksMatchExistingFontFamily(markFromMarks, existingFontFamily, encodeMarksFromRPr, docx) ? mergeFontFamilyPreservingThemeRefs(valueFromMarks, existingFontFamily) : valueFromMarks;
70520
+ }
70486
70521
  } else
70487
70522
  inlineRunProperties[key] = valueFromMarks;
70488
70523
  }
@@ -87419,10 +87454,32 @@ function removeSdtPrChild(sdtPr, childName) {
87419
87454
  };
87420
87455
  }
87421
87456
  function applyAttrsUpdate(editor, nodeId, attrsPatch) {
87422
- const updateCmd = editor.commands?.updateStructuredContentById;
87423
- if (typeof updateCmd !== "function")
87457
+ if (!editor?.state)
87458
+ return false;
87459
+ let foundPos = null;
87460
+ editor.state.doc.descendants((node2, pos) => {
87461
+ if (foundPos !== null)
87462
+ return false;
87463
+ if (SDT_NODE_TYPES.has(node2.type.name) && String(node2.attrs.id) === String(nodeId)) {
87464
+ foundPos = pos;
87465
+ return false;
87466
+ }
87467
+ return true;
87468
+ });
87469
+ if (foundPos === null)
87470
+ return false;
87471
+ const tr = editor.state.tr;
87472
+ for (const [key, value] of Object.entries(attrsPatch))
87473
+ tr.setNodeAttribute(foundPos, key, value);
87474
+ if (tr.steps.length === 0)
87475
+ return true;
87476
+ if (editor.view?.dispatch)
87477
+ editor.view.dispatch(tr);
87478
+ else if (typeof editor.dispatch === "function")
87479
+ editor.dispatch(tr);
87480
+ else
87424
87481
  return false;
87425
- return Boolean(updateCmd(nodeId, { attrs: attrsPatch }));
87482
+ return true;
87426
87483
  }
87427
87484
  function updateSdtPrChild(editor, target, childName, updater) {
87428
87485
  const currentSdtPr = resolveSdtByTarget(editor.state.doc, target).node.attrs.sdtPr ?? {
@@ -87656,6 +87713,59 @@ function buildContentControlInfoFromAttrs(attrs, kind) {
87656
87713
  }
87657
87714
  };
87658
87715
  }
87716
+ function assertNotSdtLocked(sdt, operation) {
87717
+ const mode = resolveLockMode(sdt.node.attrs);
87718
+ if (mode === "sdtLocked" || 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 assertNotContentLocked(sdt, operation) {
87725
+ const mode = resolveLockMode(sdt.node.attrs);
87726
+ if (mode === "contentLocked" || mode === "sdtContentLocked")
87727
+ throw new DocumentApiAdapterError("LOCK_VIOLATION", `Content control "${sdt.node.attrs.id}" has lock mode "${mode}" which prevents ${operation}.`, {
87728
+ lockMode: mode,
87729
+ operation
87730
+ });
87731
+ }
87732
+ function assertControlType(sdt, expected, operation) {
87733
+ const actual = resolveControlType(sdt.node.attrs);
87734
+ const allowed = Array.isArray(expected) ? expected : [expected];
87735
+ if (!allowed.includes(actual))
87736
+ throw new DocumentApiAdapterError("TYPE_MISMATCH", `Operation "${operation}" requires control type ${allowed.join(" or ")}, but found "${actual}".`, {
87737
+ expected: allowed,
87738
+ actual,
87739
+ operation
87740
+ });
87741
+ }
87742
+ function buildMutationSuccess(target, updatedRef) {
87743
+ const result = {
87744
+ success: true,
87745
+ contentControl: target
87746
+ };
87747
+ if (updatedRef)
87748
+ result.updatedRef = updatedRef;
87749
+ return result;
87750
+ }
87751
+ function buildMutationFailure(code$1, message) {
87752
+ return {
87753
+ success: false,
87754
+ failure: {
87755
+ code: code$1,
87756
+ message
87757
+ }
87758
+ };
87759
+ }
87760
+ function applyPagination(items, opts) {
87761
+ const total = items.length;
87762
+ const offset = opts?.offset ?? 0;
87763
+ const limit = opts?.limit ?? total;
87764
+ return {
87765
+ items: items.slice(offset, offset + limit),
87766
+ total
87767
+ };
87768
+ }
87659
87769
  function resolveBlock(editor, nodeId) {
87660
87770
  const matches$1 = getBlockIndex(editor).candidates.filter((c$1) => c$1.nodeId === nodeId && (c$1.nodeType === "paragraph" || c$1.nodeType === "listItem"));
87661
87771
  if (matches$1.length === 0)
@@ -90906,7 +91016,7 @@ var isRegExp = (value) => {
90906
91016
  return true;
90907
91017
  }, areAttrsEqual = (attrsA = {}, attrsB = {}) => {
90908
91018
  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 = () => {
91019
+ }, 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
91020
  return SuperConverter.toCssFontFamily;
90911
91021
  }, getSpacingStyle = (spacing, isListItem$1) => {
90912
91022
  let { before, after, line, lineRule, beforeAutospacing, afterAutospacing } = spacing;
@@ -105358,7 +105468,7 @@ var isRegExp = (value) => {
105358
105468
  if (id)
105359
105469
  return trackedChanges.filter(({ mark }) => mark.attrs.id === id);
105360
105470
  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 }) => {
105471
+ }, 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
105472
  if (!runProps?.elements?.length || !state)
105363
105473
  return;
105364
105474
  const fontsNode = runProps.elements.find((el) => el.name === "w:rFonts");
@@ -105392,7 +105502,7 @@ var isRegExp = (value) => {
105392
105502
  state.kern = kernNode.attributes["w:val"];
105393
105503
  }
105394
105504
  }, SuperConverter;
105395
- var init_SuperConverter_KEGUvaEC_es = __esm(() => {
105505
+ var init_SuperConverter_B_EF8ijE_es = __esm(() => {
105396
105506
  init_rolldown_runtime_Bg48TavK_es();
105397
105507
  init_jszip_C49i9kUs_es();
105398
105508
  init_xml_js_CqGKpaft_es();
@@ -121058,6 +121168,12 @@ var init_SuperConverter_KEGUvaEC_es = __esm(() => {
121058
121168
  "highlight",
121059
121169
  "link"
121060
121170
  ];
121171
+ FONT_SLOT_THEME_PAIRS = [
121172
+ ["ascii", "asciiTheme"],
121173
+ ["hAnsi", "hAnsiTheme"],
121174
+ ["eastAsia", "eastAsiaTheme"],
121175
+ ["cs", "cstheme"]
121176
+ ];
121061
121177
  TABLE_FALLBACK_BORDER = {
121062
121178
  val: "single",
121063
121179
  size: 4,
@@ -142117,6 +142233,7 @@ var init_SuperConverter_KEGUvaEC_es = __esm(() => {
142117
142233
  };
142118
142234
  groupedCache = /* @__PURE__ */ new WeakMap;
142119
142235
  SDT_NODE_NAMES = ["structuredContent", "structuredContentBlock"];
142236
+ SDT_NODE_TYPES = new Set(SDT_NODE_NAMES);
142120
142237
  VALID_CONTROL_TYPES = [
142121
142238
  "text",
142122
142239
  "richText",
@@ -143259,7 +143376,7 @@ var init_SuperConverter_KEGUvaEC_es = __esm(() => {
143259
143376
  };
143260
143377
  });
143261
143378
 
143262
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DwiDDjhC.es.js
143379
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-CAjt5qLD.es.js
143263
143380
  function parseSizeUnit(val = "0") {
143264
143381
  const length = val.toString() || "0";
143265
143382
  const value = Number.parseFloat(length);
@@ -145981,8 +146098,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
145981
146098
  }
145982
146099
  };
145983
146100
  };
145984
- var init_create_headless_toolbar_DwiDDjhC_es = __esm(() => {
145985
- init_SuperConverter_KEGUvaEC_es();
146101
+ var init_create_headless_toolbar_CAjt5qLD_es = __esm(() => {
146102
+ init_SuperConverter_B_EF8ijE_es();
145986
146103
  init_constants_DrU4EASo_es();
145987
146104
  init_dist_B8HfvhaK_es();
145988
146105
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
@@ -200201,7 +200318,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
200201
200318
  init_remark_gfm_BhnWr3yf_es();
200202
200319
  });
200203
200320
 
200204
- // ../../packages/superdoc/dist/chunks/src-XCAViTso.es.js
200321
+ // ../../packages/superdoc/dist/chunks/src-CuD4BbTF.es.js
200205
200322
  function deleteProps(obj, propOrProps) {
200206
200323
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
200207
200324
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -200989,59 +201106,6 @@ function getSuperdocVersion() {
200989
201106
  return "unknown";
200990
201107
  }
200991
201108
  }
200992
- function assertNotSdtLocked(sdt, operation) {
200993
- const mode = resolveLockMode(sdt.node.attrs);
200994
- if (mode === "sdtLocked" || mode === "sdtContentLocked")
200995
- throw new DocumentApiAdapterError("LOCK_VIOLATION", `Content control "${sdt.node.attrs.id}" has lock mode "${mode}" which prevents ${operation}.`, {
200996
- lockMode: mode,
200997
- operation
200998
- });
200999
- }
201000
- function assertNotContentLocked(sdt, operation) {
201001
- const mode = resolveLockMode(sdt.node.attrs);
201002
- if (mode === "contentLocked" || mode === "sdtContentLocked")
201003
- throw new DocumentApiAdapterError("LOCK_VIOLATION", `Content control "${sdt.node.attrs.id}" has lock mode "${mode}" which prevents ${operation}.`, {
201004
- lockMode: mode,
201005
- operation
201006
- });
201007
- }
201008
- function assertControlType(sdt, expected, operation) {
201009
- const actual = resolveControlType(sdt.node.attrs);
201010
- const allowed = Array.isArray(expected) ? expected : [expected];
201011
- if (!allowed.includes(actual))
201012
- throw new DocumentApiAdapterError("TYPE_MISMATCH", `Operation "${operation}" requires control type ${allowed.join(" or ")}, but found "${actual}".`, {
201013
- expected: allowed,
201014
- actual,
201015
- operation
201016
- });
201017
- }
201018
- function buildMutationSuccess(target, updatedRef) {
201019
- const result = {
201020
- success: true,
201021
- contentControl: target
201022
- };
201023
- if (updatedRef)
201024
- result.updatedRef = updatedRef;
201025
- return result;
201026
- }
201027
- function buildMutationFailure(code7, message) {
201028
- return {
201029
- success: false,
201030
- failure: {
201031
- code: code7,
201032
- message
201033
- }
201034
- };
201035
- }
201036
- function applyPagination(items, opts) {
201037
- const total = items.length;
201038
- const offset$1 = opts?.offset ?? 0;
201039
- const limit = opts?.limit ?? total;
201040
- return {
201041
- items: items.slice(offset$1, offset$1 + limit),
201042
- total
201043
- };
201044
- }
201045
201109
  function getFocusMeta(tr) {
201046
201110
  return tr.getMeta(CustomSelectionPluginKey);
201047
201111
  }
@@ -235724,22 +235788,24 @@ function alreadyMatchesPlainTextReplacement(sdt, expectedText) {
235724
235788
  }
235725
235789
  function replaceSdtTextContent(editor, target, text5) {
235726
235790
  const resolved = resolveSdtByTarget(editor.state.doc, target);
235791
+ const { tr } = editor.state;
235792
+ const innerFrom = resolved.pos + 1;
235793
+ const innerTo = resolved.pos + resolved.node.nodeSize - 1;
235727
235794
  if (resolved.kind === "inline") {
235728
- const updateCmd = editor.commands?.updateStructuredContentById;
235729
- if (text5.length > 0)
235730
- return Boolean(updateCmd?.(target.nodeId, { text: text5 }));
235731
- const updatedNode$1 = resolved.node.type.create({ ...resolved.node.attrs }, null, resolved.node.marks);
235732
- const { tr: tr$1 } = editor.state;
235733
- tr$1.replaceWith(resolved.pos, resolved.pos + resolved.node.nodeSize, updatedNode$1);
235734
- dispatchTransaction(editor, tr$1);
235795
+ if (text5.length > 0) {
235796
+ const textNode = editor.schema.text(text5);
235797
+ tr.replaceWith(innerFrom, innerTo, textNode);
235798
+ } else
235799
+ tr.delete(innerFrom, innerTo);
235800
+ dispatchTransaction(editor, tr);
235735
235801
  return true;
235736
235802
  }
235737
235803
  const paragraph2 = buildEmptyBlockContent(editor, resolved.node);
235804
+ if (!paragraph2)
235805
+ return false;
235738
235806
  const paragraphText = text5.length > 0 ? buildTextWithTabs(editor.schema, text5, undefined) : null;
235739
- const updatedParagraph = paragraph2?.type.create(paragraph2.attrs ?? null, paragraphText, paragraph2.marks) ?? null;
235740
- const updatedNode = resolved.node.type.create({ ...resolved.node.attrs }, updatedParagraph, resolved.node.marks);
235741
- const { tr } = editor.state;
235742
- tr.replaceWith(resolved.pos, resolved.pos + resolved.node.nodeSize, updatedNode);
235807
+ const updatedParagraph = paragraph2.type.create(paragraph2.attrs ?? null, paragraphText, paragraph2.marks);
235808
+ tr.replaceWith(innerFrom, innerTo, updatedParagraph);
235743
235809
  dispatchTransaction(editor, tr);
235744
235810
  return true;
235745
235811
  }
@@ -244869,7 +244935,7 @@ function resolveParagraphContent(fragment, block, measure) {
244869
244935
  const paraIndent = block.attrs?.indent;
244870
244936
  const paraIndentLeft = paraIndent?.left ?? 0;
244871
244937
  const paraIndentRight = paraIndent?.right ?? 0;
244872
- const { anchorIndentPx: paraMarkerAnchorIndent, firstLinePx: markerFirstLine, hangingPx: markerHanging } = resolveMarkerIndent(paraIndent, block.attrs?.direction === "rtl");
244938
+ const { anchorIndentPx: paraMarkerAnchorIndent, firstLinePx: markerFirstLine, hangingPx: markerHanging } = resolveMarkerIndent(paraIndent, getParagraphInlineDirection(block.attrs) === "rtl");
244873
244939
  const firstLineOffset = block.attrs?.suppressFirstLineIndent === true ? 0 : (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
244874
244940
  const paragraphEndsWithLineBreak = (block.runs.length > 0 ? block.runs[block.runs.length - 1] : null)?.kind === "lineBreak";
244875
244941
  const lines = fragment.lines ?? measure.lines.slice(fragment.fromLine, fragment.toLine);
@@ -285827,16 +285893,7 @@ menclose::after {
285827
285893
  }, isRtlBlock = (block) => {
285828
285894
  if (block.kind !== "paragraph")
285829
285895
  return false;
285830
- const attrs = block.attrs;
285831
- if (!attrs)
285832
- return false;
285833
- const directionContext = attrs.directionContext;
285834
- if (directionContext?.inlineDirection != null)
285835
- return directionContext.inlineDirection === "rtl";
285836
- const directionAttr = attrs.direction ?? attrs.dir;
285837
- if (typeof directionAttr === "string" && directionAttr.toLowerCase() === "rtl")
285838
- return true;
285839
- return false;
285896
+ return getParagraphInlineDirection(block.attrs) === "rtl";
285840
285897
  }, determineColumn = (layout, fragmentX) => {
285841
285898
  const columns = layout.columns;
285842
285899
  if (!columns || columns.count <= 1)
@@ -294075,12 +294132,12 @@ menclose::after {
294075
294132
  return;
294076
294133
  console.log(...args$1);
294077
294134
  }, 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;
294078
- var init_src_XCAViTso_es = __esm(() => {
294135
+ var init_src_CuD4BbTF_es = __esm(() => {
294079
294136
  init_rolldown_runtime_Bg48TavK_es();
294080
- init_SuperConverter_KEGUvaEC_es();
294137
+ init_SuperConverter_B_EF8ijE_es();
294081
294138
  init_jszip_C49i9kUs_es();
294082
294139
  init_uuid_qzgm05fK_es();
294083
- init_create_headless_toolbar_DwiDDjhC_es();
294140
+ init_create_headless_toolbar_CAjt5qLD_es();
294084
294141
  init_constants_DrU4EASo_es();
294085
294142
  init_dist_B8HfvhaK_es();
294086
294143
  init_unified_Dsuw2be5_es();
@@ -332123,11 +332180,11 @@ function print() { __p += __j.call(arguments, '') }
332123
332180
  ];
332124
332181
  });
332125
332182
 
332126
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-BEAzL3ry.es.js
332183
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DrS6dKfb.es.js
332127
332184
  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;
332128
- var init_create_super_doc_ui_BEAzL3ry_es = __esm(() => {
332129
- init_SuperConverter_KEGUvaEC_es();
332130
- init_create_headless_toolbar_DwiDDjhC_es();
332185
+ var init_create_super_doc_ui_DrS6dKfb_es = __esm(() => {
332186
+ init_SuperConverter_B_EF8ijE_es();
332187
+ init_create_headless_toolbar_CAjt5qLD_es();
332131
332188
  MOD_ALIASES = new Set([
332132
332189
  "Mod",
332133
332190
  "Meta",
@@ -332169,16 +332226,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
332169
332226
 
332170
332227
  // ../../packages/superdoc/dist/super-editor.es.js
332171
332228
  var init_super_editor_es = __esm(() => {
332172
- init_src_XCAViTso_es();
332173
- init_SuperConverter_KEGUvaEC_es();
332229
+ init_src_CuD4BbTF_es();
332230
+ init_SuperConverter_B_EF8ijE_es();
332174
332231
  init_jszip_C49i9kUs_es();
332175
332232
  init_xml_js_CqGKpaft_es();
332176
- init_create_headless_toolbar_DwiDDjhC_es();
332233
+ init_create_headless_toolbar_CAjt5qLD_es();
332177
332234
  init_constants_DrU4EASo_es();
332178
332235
  init_dist_B8HfvhaK_es();
332179
332236
  init_unified_Dsuw2be5_es();
332180
332237
  init_DocxZipper_TPSo9G36_es();
332181
- init_create_super_doc_ui_BEAzL3ry_es();
332238
+ init_create_super_doc_ui_DrS6dKfb_es();
332182
332239
  init_ui_CGB3qmy3_es();
332183
332240
  init_eventemitter3_UwU_CLPU_es();
332184
332241
  init_errors_C_DoKMoN_es();
@@ -371210,10 +371267,34 @@ function removeSdtPrChild2(sdtPr, childName) {
371210
371267
  return { ...sdtPr, elements: sdtPr.elements.filter((el) => el.name !== childName) };
371211
371268
  }
371212
371269
  function applyAttrsUpdate2(editor, nodeId, attrsPatch) {
371213
- const updateCmd = editor.commands?.updateStructuredContentById;
371214
- if (typeof updateCmd !== "function")
371270
+ if (!editor?.state)
371215
371271
  return false;
371216
- return Boolean(updateCmd(nodeId, { attrs: attrsPatch }));
371272
+ let foundPos = null;
371273
+ editor.state.doc.descendants((node3, pos) => {
371274
+ if (foundPos !== null)
371275
+ return false;
371276
+ if (SDT_NODE_TYPES2.has(node3.type.name) && String(node3.attrs.id) === String(nodeId)) {
371277
+ foundPos = pos;
371278
+ return false;
371279
+ }
371280
+ return true;
371281
+ });
371282
+ if (foundPos === null)
371283
+ return false;
371284
+ const tr = editor.state.tr;
371285
+ for (const [key2, value] of Object.entries(attrsPatch)) {
371286
+ tr.setNodeAttribute(foundPos, key2, value);
371287
+ }
371288
+ if (tr.steps.length === 0)
371289
+ return true;
371290
+ if (editor.view?.dispatch) {
371291
+ editor.view.dispatch(tr);
371292
+ } else if (typeof editor.dispatch === "function") {
371293
+ editor.dispatch(tr);
371294
+ } else {
371295
+ return false;
371296
+ }
371297
+ return true;
371217
371298
  }
371218
371299
  function updateSdtPrChild2(editor, target, childName, updater) {
371219
371300
  const resolved = resolveSdtByTarget2(editor.state.doc, target);
@@ -371250,8 +371331,10 @@ function replaceSdtPrSubElements2(editor, target, childName, elements) {
371250
371331
  elements
371251
371332
  }));
371252
371333
  }
371334
+ var SDT_NODE_TYPES2;
371253
371335
  var init_sdt_properties_write = __esm(() => {
371254
371336
  init_target_resolution();
371337
+ SDT_NODE_TYPES2 = new Set(SDT_NODE_NAMES2);
371255
371338
  });
371256
371339
 
371257
371340
  // ../../packages/super-editor/src/editors/v1/document-api-adapters/helpers/content-controls/sdt-info-builder.ts
@@ -372756,20 +372839,25 @@ function combineProperties2(propertiesArray, options = {}) {
372756
372839
  function isObject4(item) {
372757
372840
  return item != null && typeof item === "object" && !Array.isArray(item);
372758
372841
  }
372842
+ function dropConflictingFontSlots2(target, source) {
372843
+ const result = { ...target };
372844
+ for (const [concreteKey, themeKey] of FONT_SLOT_THEME_PAIRS2) {
372845
+ if (source[themeKey] != null) {
372846
+ delete result[concreteKey];
372847
+ delete result[themeKey];
372848
+ } else if (source[concreteKey] != null) {
372849
+ delete result[themeKey];
372850
+ }
372851
+ }
372852
+ return result;
372853
+ }
372759
372854
  function combineRunProperties2(propertiesArray) {
372760
372855
  return combineProperties2(propertiesArray, {
372761
372856
  fullOverrideProps: ["color"],
372762
372857
  specialHandling: {
372763
372858
  fontFamily: (target, source) => {
372764
372859
  const fontFamilySource = { ...source.fontFamily };
372765
- const fontFamilyTarget = { ...target.fontFamily };
372766
- if (fontFamilySource.asciiTheme != null) {
372767
- delete fontFamilyTarget.ascii;
372768
- delete fontFamilyTarget.asciiTheme;
372769
- }
372770
- if (fontFamilySource.ascii != null) {
372771
- delete fontFamilyTarget.asciiTheme;
372772
- }
372860
+ const fontFamilyTarget = dropConflictingFontSlots2(target.fontFamily ?? {}, fontFamilySource);
372773
372861
  return { ...fontFamilyTarget, ...fontFamilySource };
372774
372862
  }
372775
372863
  }
@@ -372794,6 +372882,15 @@ function combineIndentProperties2(indentChain) {
372794
372882
  }
372795
372883
  });
372796
372884
  }
372885
+ var FONT_SLOT_THEME_PAIRS2;
372886
+ var init_cascade = __esm(() => {
372887
+ FONT_SLOT_THEME_PAIRS2 = [
372888
+ ["ascii", "asciiTheme"],
372889
+ ["hAnsi", "hAnsiTheme"],
372890
+ ["eastAsia", "eastAsiaTheme"],
372891
+ ["cs", "cstheme"]
372892
+ ];
372893
+ });
372797
372894
 
372798
372895
  // ../../packages/layout-engine/style-engine/src/ooxml/table-style-selection.ts
372799
372896
  function isKnownTableStyleId2(styleId, translatedLinkedStyles) {
@@ -373170,6 +373267,7 @@ function determineCellStyleTypes2(tblLook, rowIndex, cellIndex, numRows, numCell
373170
373267
  }
373171
373268
  var DEFAULT_TBL_LOOK2, CNF_STYLE_MAP2, TABLE_STYLE_PRECEDENCE2;
373172
373269
  var init_ooxml = __esm(() => {
373270
+ init_cascade();
373173
373271
  init_table_style_selection();
373174
373272
  DEFAULT_TBL_LOOK2 = {
373175
373273
  firstRow: true,
@@ -396782,6 +396880,12 @@ function extractPlaceholder2(sdtPr) {
396782
396880
  const docPart = el?.elements?.find((e) => e.name === "w:docPart");
396783
396881
  return docPart?.attributes?.["w:val"] ?? null;
396784
396882
  }
396883
+ function extractTemporary2(sdtPr) {
396884
+ const el = sdtPr?.elements?.find((e) => e.name === "w:temporary");
396885
+ if (!el)
396886
+ return;
396887
+ return parseStrictStOnOff2(el.attributes?.["w:val"], "temporary", "w:temporary");
396888
+ }
396785
396889
  function handleStructuredContentNode2(params3) {
396786
396890
  const { nodes, nodeListHandler } = params3;
396787
396891
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
@@ -396800,6 +396904,7 @@ function handleStructuredContentNode2(params3) {
396800
396904
  const controlType = detectControlType2(sdtPr);
396801
396905
  const appearance = extractAppearance2(sdtPr);
396802
396906
  const placeholder = extractPlaceholder2(sdtPr);
396907
+ const temporary = extractTemporary2(sdtPr);
396803
396908
  if (!sdtContent) {
396804
396909
  return null;
396805
396910
  }
@@ -396826,6 +396931,7 @@ function handleStructuredContentNode2(params3) {
396826
396931
  type: controlType,
396827
396932
  appearance,
396828
396933
  placeholder,
396934
+ ...temporary !== undefined ? { temporary } : {},
396829
396935
  sdtPr
396830
396936
  }
396831
396937
  };
@@ -396833,6 +396939,7 @@ function handleStructuredContentNode2(params3) {
396833
396939
  }
396834
396940
  var init_handle_structured_content_node = __esm(() => {
396835
396941
  init_handle_annotation_node();
396942
+ init_utils();
396836
396943
  });
396837
396944
 
396838
396945
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/sdt/helpers/sdt-node-type-strategy.js
@@ -428554,6 +428661,7 @@ var RUN_PROPERTIES_DERIVED_FROM_MARKS2, TRANSIENT_HYPERLINK_STYLE_IDS2;
428554
428661
  var init_calculateInlineRunPropertiesPlugin = __esm(() => {
428555
428662
  init_dist10();
428556
428663
  init_styles3();
428664
+ init_ooxml();
428557
428665
  init_resolvedPropertiesCache();
428558
428666
  RUN_PROPERTIES_DERIVED_FROM_MARKS2 = new Set([
428559
428667
  "strike",
@@ -458227,23 +458335,25 @@ function alreadyMatchesPlainTextReplacement2(sdt, expectedText) {
458227
458335
  }
458228
458336
  function replaceSdtTextContent2(editor, target, text9) {
458229
458337
  const resolved = resolveSdtByTarget2(editor.state.doc, target);
458338
+ const { tr } = editor.state;
458339
+ const innerFrom = resolved.pos + 1;
458340
+ const innerTo = resolved.pos + resolved.node.nodeSize - 1;
458230
458341
  if (resolved.kind === "inline") {
458231
- const updateCmd = editor.commands?.updateStructuredContentById;
458232
458342
  if (text9.length > 0) {
458233
- return Boolean(updateCmd?.(target.nodeId, { text: text9 }));
458343
+ const textNode = editor.schema.text(text9);
458344
+ tr.replaceWith(innerFrom, innerTo, textNode);
458345
+ } else {
458346
+ tr.delete(innerFrom, innerTo);
458234
458347
  }
458235
- const updatedNode2 = resolved.node.type.create({ ...resolved.node.attrs }, null, resolved.node.marks);
458236
- const { tr: tr2 } = editor.state;
458237
- tr2.replaceWith(resolved.pos, resolved.pos + resolved.node.nodeSize, updatedNode2);
458238
- dispatchTransaction4(editor, tr2);
458348
+ dispatchTransaction4(editor, tr);
458239
458349
  return true;
458240
458350
  }
458241
458351
  const paragraph4 = buildEmptyBlockContent2(editor, resolved.node);
458352
+ if (!paragraph4)
458353
+ return false;
458242
458354
  const paragraphText = text9.length > 0 ? buildTextWithTabs2(editor.schema, text9, undefined) : null;
458243
- const updatedParagraph = paragraph4?.type.create(paragraph4.attrs ?? null, paragraphText, paragraph4.marks) ?? null;
458244
- const updatedNode = resolved.node.type.create({ ...resolved.node.attrs }, updatedParagraph, resolved.node.marks);
458245
- const { tr } = editor.state;
458246
- tr.replaceWith(resolved.pos, resolved.pos + resolved.node.nodeSize, updatedNode);
458355
+ const updatedParagraph = paragraph4.type.create(paragraph4.attrs ?? null, paragraphText, paragraph4.marks);
458356
+ tr.replaceWith(innerFrom, innerTo, updatedParagraph);
458247
458357
  dispatchTransaction4(editor, tr);
458248
458358
  return true;
458249
458359
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.3.0-next.92",
3
+ "version": "0.3.0-next.94",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -19,8 +19,8 @@
19
19
  "@types/bun": "^1.3.8",
20
20
  "@types/node": "22.19.2",
21
21
  "typescript": "^5.9.2",
22
- "@superdoc/document-api": "0.0.1",
23
22
  "@superdoc/super-editor": "0.0.1",
23
+ "@superdoc/document-api": "0.0.1",
24
24
  "superdoc": "1.32.0"
25
25
  },
26
26
  "publishConfig": {