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

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 +223 -97
  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-D-cFThyR.es.js
51894
+ // ../../packages/superdoc/dist/chunks/SuperConverter-1Voea3gd.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")
@@ -61147,7 +61147,7 @@ function encodeMarksFromRPr(runProperties, docx) {
61147
61147
  return [];
61148
61148
  const marks = [];
61149
61149
  const textStyleAttrs = {};
61150
- let highlightColor = null;
61150
+ let highlightAttrs = null;
61151
61151
  let hasHighlightTag = false;
61152
61152
  Object.keys(runProperties).forEach((key) => {
61153
61153
  const value = runProperties[key];
@@ -61224,7 +61224,9 @@ function encodeMarksFromRPr(runProperties, docx) {
61224
61224
  const color2 = getHighLightValue$1(value);
61225
61225
  if (color2) {
61226
61226
  hasHighlightTag = true;
61227
- highlightColor = color2;
61227
+ highlightAttrs = { color: color2 };
61228
+ if (color2.toLowerCase() === "transparent" && String(value?.["w:val"]).toLowerCase() === "none")
61229
+ highlightAttrs.ooxmlHighlightClear = true;
61228
61230
  }
61229
61231
  break;
61230
61232
  case "shading": {
@@ -61233,11 +61235,11 @@ function encodeMarksFromRPr(runProperties, docx) {
61233
61235
  const fill = value["fill"];
61234
61236
  const shdVal = value["val"];
61235
61237
  if (fill && String(fill).toLowerCase() !== "auto")
61236
- highlightColor = `#${String(fill).replace("#", "")}`;
61238
+ highlightAttrs = { color: `#${String(fill).replace("#", "")}` };
61237
61239
  else if (typeof shdVal === "string") {
61238
61240
  const normalized = shdVal.toLowerCase();
61239
61241
  if (normalized === "clear" || normalized === "nil" || normalized === "none")
61240
- highlightColor = "transparent";
61242
+ highlightAttrs = { color: "transparent" };
61241
61243
  }
61242
61244
  break;
61243
61245
  }
@@ -61259,10 +61261,10 @@ function encodeMarksFromRPr(runProperties, docx) {
61259
61261
  type: "textStyle",
61260
61262
  attrs: textStyleAttrs
61261
61263
  });
61262
- if (highlightColor)
61264
+ if (highlightAttrs)
61263
61265
  marks.push({
61264
61266
  type: "highlight",
61265
- attrs: { color: highlightColor }
61267
+ attrs: highlightAttrs
61266
61268
  });
61267
61269
  return marks;
61268
61270
  }
@@ -61545,10 +61547,6 @@ function decodeRPrFromMarks(marks) {
61545
61547
  case "italic":
61546
61548
  case "bold":
61547
61549
  runProperties[type] = mark.attrs.value !== "0" && mark.attrs.value !== false;
61548
- if (type === "bold")
61549
- runProperties.boldCs = runProperties.bold;
61550
- else if (type === "italic")
61551
- runProperties.italicCs = runProperties.italic;
61552
61550
  break;
61553
61551
  case "underline": {
61554
61552
  const { underlineType, underlineColor, underlineThemeColor, underlineThemeTint, underlineThemeShade } = mark.attrs;
@@ -61568,11 +61566,13 @@ function decodeRPrFromMarks(marks) {
61568
61566
  break;
61569
61567
  }
61570
61568
  case "highlight":
61571
- if (mark.attrs.color)
61572
- if (mark.attrs.color.toLowerCase() === "transparent")
61569
+ if (!mark.attrs.color)
61570
+ break;
61571
+ if (mark.attrs.color.toLowerCase() === "transparent") {
61572
+ if (mark.attrs.ooxmlHighlightClear)
61573
61573
  runProperties.highlight = { "w:val": "none" };
61574
- else
61575
- runProperties.highlight = { "w:val": mark.attrs.color };
61574
+ } else
61575
+ runProperties.highlight = { "w:val": mark.attrs.color };
61576
61576
  break;
61577
61577
  case "link":
61578
61578
  runProperties.styleId = "Hyperlink";
@@ -62915,6 +62915,12 @@ function extractAppearance(sdtPr) {
62915
62915
  function extractPlaceholder(sdtPr) {
62916
62916
  return sdtPr?.elements?.find((e) => e.name === "w:placeholder")?.elements?.find((e) => e.name === "w:docPart")?.attributes?.["w:val"] ?? null;
62917
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
+ }
62918
62924
  function handleStructuredContentNode(params) {
62919
62925
  const { nodes, nodeListHandler } = params;
62920
62926
  if (nodes.length === 0 || nodes[0].name !== "w:sdt")
@@ -62935,6 +62941,7 @@ function handleStructuredContentNode(params) {
62935
62941
  const controlType = detectControlType(sdtPr);
62936
62942
  const appearance = extractAppearance(sdtPr);
62937
62943
  const placeholder = extractPlaceholder(sdtPr);
62944
+ const temporary = extractTemporary(sdtPr);
62938
62945
  if (!sdtContent)
62939
62946
  return null;
62940
62947
  const paragraph2 = sdtContent.elements?.find((el) => el.name === "w:p");
@@ -62958,6 +62965,7 @@ function handleStructuredContentNode(params) {
62958
62965
  type: controlType,
62959
62966
  appearance,
62960
62967
  placeholder,
62968
+ ...temporary !== undefined ? { temporary } : {},
62961
62969
  sdtPr
62962
62970
  }
62963
62971
  };
@@ -70435,13 +70443,13 @@ function extractTableInfo($pos, depth) {
70435
70443
  return fallbackInfo;
70436
70444
  }
70437
70445
  }
70438
- function segmentRunByInlineProps(runNode, paragraphNode, tableInfo, $pos, editor, preservedDerivedKeys, preferExistingKeys) {
70446
+ function segmentRunByInlineProps(runNode, paragraphNode, tableInfo, $pos, editor, removedKeys, preservedDerivedKeys, preferExistingKeys) {
70439
70447
  const segments = [];
70440
70448
  let lastKey = null;
70441
70449
  let boundaryCounter = 0;
70442
70450
  runNode.forEach((child) => {
70443
70451
  if (child.isText) {
70444
- const { inlineProps: inlineProps$1, inlineKey: inlineKey$2 } = computeInlineRunProps(child.marks, runNode.attrs?.runProperties, paragraphNode, tableInfo, $pos, editor, preservedDerivedKeys, preferExistingKeys);
70452
+ const { inlineProps: inlineProps$1, inlineKey: inlineKey$2 } = computeInlineRunProps(child.marks, runNode.attrs?.runProperties, paragraphNode, tableInfo, $pos, editor, removedKeys, preservedDerivedKeys, preferExistingKeys);
70445
70453
  const last = segments[segments.length - 1];
70446
70454
  if (last && inlineKey$2 === lastKey)
70447
70455
  last.content.push(child);
@@ -70469,20 +70477,20 @@ function segmentRunByInlineProps(runNode, paragraphNode, tableInfo, $pos, editor
70469
70477
  firstInlineProps: segments[0]?.inlineProps ?? null
70470
70478
  };
70471
70479
  }
70472
- function computeInlineRunProps(marks, existingRunProperties, paragraphNode, tableInfo, $pos, editor, preservedDerivedKeys, preferExistingKeys) {
70480
+ function computeInlineRunProps(marks, existingRunProperties, paragraphNode, tableInfo, $pos, editor, removedKeys, preservedDerivedKeys, preferExistingKeys) {
70473
70481
  const runPropertiesFromMarks = decodeRPrFromMarks(marks);
70474
70482
  const paragraphProperties = getResolvedParagraphProperties(paragraphNode) || calculateResolvedParagraphProperties(editor, paragraphNode, $pos);
70475
70483
  const inlineRunProperties = getInlineRunProperties(runPropertiesFromMarks, resolveRunProperties({
70476
70484
  translatedNumbering: editor.converter?.translatedNumbering ?? {},
70477
70485
  translatedLinkedStyles: editor.converter?.translatedLinkedStyles ?? {}
70478
- }, existingRunProperties?.styleId != null ? { styleId: existingRunProperties?.styleId } : {}, paragraphProperties, tableInfo, false, Boolean(paragraphNode.attrs.paragraphProperties?.numberingProperties)), existingRunProperties, editor, preservedDerivedKeys, preferExistingKeys);
70486
+ }, existingRunProperties?.styleId != null ? { styleId: existingRunProperties?.styleId } : {}, paragraphProperties, tableInfo, false, Boolean(paragraphNode.attrs.paragraphProperties?.numberingProperties)), existingRunProperties, editor, removedKeys, preservedDerivedKeys, preferExistingKeys);
70479
70487
  const inlineProps = Object.keys(inlineRunProperties).length ? inlineRunProperties : null;
70480
70488
  return {
70481
70489
  inlineProps,
70482
70490
  inlineKey: stableStringifyInlineProps(inlineProps)
70483
70491
  };
70484
70492
  }
70485
- function getInlineRunProperties(runPropertiesFromMarks, runPropertiesFromStyles, existingRunProperties, editor, preservedDerivedKeys = /* @__PURE__ */ new Set, preferExistingKeys = /* @__PURE__ */ new Set) {
70493
+ function getInlineRunProperties(runPropertiesFromMarks, runPropertiesFromStyles, existingRunProperties, editor, removedKeys = /* @__PURE__ */ new Set, preservedDerivedKeys = /* @__PURE__ */ new Set, preferExistingKeys = /* @__PURE__ */ new Set) {
70486
70494
  const inlineRunProperties = {};
70487
70495
  for (const key in runPropertiesFromMarks) {
70488
70496
  if (preservedDerivedKeys.has(key)) {
@@ -70517,6 +70525,9 @@ function getInlineRunProperties(runPropertiesFromMarks, runPropertiesFromStyles,
70517
70525
  Object.keys(existingRunProperties).forEach((key) => {
70518
70526
  if (RUN_PROPERTIES_DERIVED_FROM_MARKS.has(key) && !preservedDerivedKeys.has(key))
70519
70527
  return;
70528
+ const baseKey = COMPANION_INLINE_KEYS[key];
70529
+ if (baseKey && removedKeys.has(baseKey))
70530
+ return;
70520
70531
  if (key === "styleId" && TRANSIENT_HYPERLINK_STYLE_IDS.has(existingRunProperties[key]) && (runPropertiesFromMarks.styleId == null || runPropertiesFromMarks.styleId === ""))
70521
70532
  return;
70522
70533
  if (key in inlineRunProperties)
@@ -82559,11 +82570,13 @@ function translateDocumentNode(params) {
82559
82570
  const mergedIgnorable = mergeMcIgnorable(DEFAULT_DOCX_DEFS["mc:Ignorable"], originalAttrs["mc:Ignorable"]);
82560
82571
  if (mergedIgnorable)
82561
82572
  attributes["mc:Ignorable"] = mergedIgnorable;
82562
- return [{
82573
+ const node2 = {
82563
82574
  name: "w:document",
82564
82575
  elements: [translatedBodyNode],
82565
82576
  attributes
82566
- }, params];
82577
+ };
82578
+ normalizePgMarTwipsInTree(node2);
82579
+ return [node2, params];
82567
82580
  }
82568
82581
  function wrapTextInRun(nodeOrNodes, marks) {
82569
82582
  let elements = [];
@@ -82682,6 +82695,8 @@ function translateMark(mark) {
82682
82695
  break;
82683
82696
  case "highlight": {
82684
82697
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
82698
+ if (String(highlightValue).trim().toLowerCase() === "transparent" && !attrs.ooxmlHighlightClear)
82699
+ return {};
82685
82700
  return translator$2.decode({ node: { attrs: { highlight: highlightValue } } }) || {};
82686
82701
  }
82687
82702
  case "strike":
@@ -91397,6 +91412,21 @@ var isRegExp = (value) => {
91397
91412
  if (!Array.isArray(node2.elements))
91398
91413
  return false;
91399
91414
  return node2.elements.some((child) => hasXmlNodeNamed(child, targetName));
91415
+ }, COMPLEX_SCRIPT_CODEPOINT_RANGES, textHasComplexScript = (text$2) => {
91416
+ for (const char of text$2) {
91417
+ const codePoint = char.codePointAt(0);
91418
+ if (COMPLEX_SCRIPT_CODEPOINT_RANGES.some(([start, end]) => codePoint >= start && codePoint <= end))
91419
+ return true;
91420
+ }
91421
+ return false;
91422
+ }, hasComplexScriptText = (node2) => {
91423
+ if (!node2 || typeof node2 !== "object")
91424
+ return false;
91425
+ if (typeof node2.text === "string" && textHasComplexScript(node2.text))
91426
+ return true;
91427
+ if (!Array.isArray(node2.content))
91428
+ return false;
91429
+ return node2.content.some((child) => hasComplexScriptText(child));
91400
91430
  }, getRunPropertiesNode = (runNode) => {
91401
91431
  if (!runNode)
91402
91432
  return null;
@@ -91607,6 +91637,12 @@ var isRegExp = (value) => {
91607
91637
  const shouldExport = (key) => (key in (runProperties || {})) && (!(Array.isArray(styleKeys) && styleKeys.includes(key)) || Array.isArray(overrideKeys) && overrideKeys.includes(key));
91608
91638
  const exportKeys = candidateKeys.filter(shouldExport);
91609
91639
  const runPropertiesToExport = exportKeys.length > 0 ? Object.fromEntries(exportKeys.map((k) => [k, runProperties[k]])) : {};
91640
+ if (hasComplexScriptText(runNodeForExport)) {
91641
+ if ("bold" in runPropertiesToExport && !("boldCs" in runPropertiesToExport))
91642
+ runPropertiesToExport.boldCs = runPropertiesToExport.bold;
91643
+ if ("italic" in runPropertiesToExport && !("italicCs" in runPropertiesToExport))
91644
+ runPropertiesToExport.italicCs = runPropertiesToExport.italic;
91645
+ }
91610
91646
  const exportParams = {
91611
91647
  ...params,
91612
91648
  node: runNodeForExport,
@@ -99325,7 +99361,7 @@ var isRegExp = (value) => {
99325
99361
  const { paragraphNode, paragraphPos, tableInfo } = getRunContext($pos);
99326
99362
  if (!paragraphNode || paragraphPos === undefined)
99327
99363
  return;
99328
- const { segments, firstInlineProps } = segmentRunByInlineProps(runNode, paragraphNode, tableInfo, $pos, editor, preservedDerivedKeys, preferExistingKeys);
99364
+ const { segments, firstInlineProps } = segmentRunByInlineProps(runNode, paragraphNode, tableInfo, $pos, editor, removedKeys, preservedDerivedKeys, preferExistingKeys);
99329
99365
  let runProperties = firstInlineProps ?? null;
99330
99366
  const existingInlineKeys = runNode.attrs?.runPropertiesInlineKeys || [];
99331
99367
  const hadInlineKeysMetadata = Array.isArray(runNode.attrs?.runPropertiesInlineKeys);
@@ -99390,6 +99426,9 @@ var isRegExp = (value) => {
99390
99426
  lostKeys.forEach((k) => {
99391
99427
  if (removedKeys.has(k))
99392
99428
  return;
99429
+ const baseKey = COMPANION_INLINE_KEYS[k];
99430
+ if (baseKey && removedKeys.has(baseKey))
99431
+ return;
99393
99432
  if (runNode.attrs?.runProperties?.[k] !== undefined)
99394
99433
  runProperties[k] = runNode.attrs.runProperties[k];
99395
99434
  });
@@ -104682,6 +104721,24 @@ var isRegExp = (value) => {
104682
104721
  pgMar.attributes[attrKey] = value;
104683
104722
  });
104684
104723
  return sectPr;
104724
+ }, normalizePgMarTwipsInTree = (node2) => {
104725
+ if (!node2 || typeof node2 !== "object")
104726
+ return;
104727
+ if (node2.name === "w:pgMar" && node2.attributes && typeof node2.attributes === "object")
104728
+ for (const key of Object.keys(node2.attributes)) {
104729
+ const value = node2.attributes[key];
104730
+ if (value == null)
104731
+ continue;
104732
+ const serialized = String(value).trim();
104733
+ if (!serialized)
104734
+ continue;
104735
+ const num = Number(serialized);
104736
+ if (Number.isFinite(num) && !/^-?\d+$/.test(serialized))
104737
+ node2.attributes[key] = String(Math.round(num));
104738
+ }
104739
+ if (Array.isArray(node2.elements))
104740
+ for (const child of node2.elements)
104741
+ normalizePgMarTwipsInTree(child);
104685
104742
  }, generateDefaultHeaderFooter = (type, id) => {
104686
104743
  return {
104687
104744
  type: "element",
@@ -105494,7 +105551,7 @@ var isRegExp = (value) => {
105494
105551
  state.kern = kernNode.attributes["w:val"];
105495
105552
  }
105496
105553
  }, SuperConverter;
105497
- var init_SuperConverter_D_cFThyR_es = __esm(() => {
105554
+ var init_SuperConverter_1Voea3gd_es = __esm(() => {
105498
105555
  init_rolldown_runtime_Bg48TavK_es();
105499
105556
  init_jszip_C49i9kUs_es();
105500
105557
  init_xml_js_CqGKpaft_es();
@@ -121643,6 +121700,14 @@ var init_SuperConverter_D_cFThyR_es = __esm(() => {
121643
121700
  "w:footnoteReference": "FootnoteReference",
121644
121701
  "w:endnoteReference": "EndnoteReference"
121645
121702
  };
121703
+ COMPLEX_SCRIPT_CODEPOINT_RANGES = [
121704
+ [1424, 2303],
121705
+ [2304, 4255],
121706
+ [6016, 6319],
121707
+ [7376, 7423],
121708
+ [43008, 43263],
121709
+ [43616, 43647]
121710
+ ];
121646
121711
  config$30 = {
121647
121712
  xmlName: XML_NODE_NAME$31,
121648
121713
  sdNodeOrKeyName: SD_KEY_NAME,
@@ -134769,9 +134834,7 @@ var init_SuperConverter_D_cFThyR_es = __esm(() => {
134769
134834
  RUN_PROPERTIES_DERIVED_FROM_MARKS = new Set([
134770
134835
  "strike",
134771
134836
  "italic",
134772
- "italicCs",
134773
134837
  "bold",
134774
- "boldCs",
134775
134838
  "underline",
134776
134839
  "highlight",
134777
134840
  "textTransform",
@@ -143368,7 +143431,7 @@ var init_SuperConverter_D_cFThyR_es = __esm(() => {
143368
143431
  };
143369
143432
  });
143370
143433
 
143371
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DkFBZ1T1.es.js
143434
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-cNPAdMd2.es.js
143372
143435
  function parseSizeUnit(val = "0") {
143373
143436
  const length = val.toString() || "0";
143374
143437
  const value = Number.parseFloat(length);
@@ -146090,8 +146153,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
146090
146153
  }
146091
146154
  };
146092
146155
  };
146093
- var init_create_headless_toolbar_DkFBZ1T1_es = __esm(() => {
146094
- init_SuperConverter_D_cFThyR_es();
146156
+ var init_create_headless_toolbar_cNPAdMd2_es = __esm(() => {
146157
+ init_SuperConverter_1Voea3gd_es();
146095
146158
  init_constants_DrU4EASo_es();
146096
146159
  init_dist_B8HfvhaK_es();
146097
146160
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
@@ -200310,7 +200373,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
200310
200373
  init_remark_gfm_BhnWr3yf_es();
200311
200374
  });
200312
200375
 
200313
- // ../../packages/superdoc/dist/chunks/src-CHVby7ed.es.js
200376
+ // ../../packages/superdoc/dist/chunks/src-GAfNMk63.es.js
200314
200377
  function deleteProps(obj, propOrProps) {
200315
200378
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
200316
200379
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -244927,7 +244990,7 @@ function resolveParagraphContent(fragment, block, measure) {
244927
244990
  const paraIndent = block.attrs?.indent;
244928
244991
  const paraIndentLeft = paraIndent?.left ?? 0;
244929
244992
  const paraIndentRight = paraIndent?.right ?? 0;
244930
- const { anchorIndentPx: paraMarkerAnchorIndent, firstLinePx: markerFirstLine, hangingPx: markerHanging } = resolveMarkerIndent(paraIndent, block.attrs?.direction === "rtl");
244993
+ const { anchorIndentPx: paraMarkerAnchorIndent, firstLinePx: markerFirstLine, hangingPx: markerHanging } = resolveMarkerIndent(paraIndent, getParagraphInlineDirection(block.attrs) === "rtl");
244931
244994
  const firstLineOffset = block.attrs?.suppressFirstLineIndent === true ? 0 : (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
244932
244995
  const paragraphEndsWithLineBreak = (block.runs.length > 0 ? block.runs[block.runs.length - 1] : null)?.kind === "lineBreak";
244933
244996
  const lines = fragment.lines ?? measure.lines.slice(fragment.fromLine, fragment.toLine);
@@ -272778,6 +272841,16 @@ var Node$13 = class Node$14 {
272778
272841
  targetTr.setSelection(Selection.near(targetTr.doc.resolve(boundedFrom), -1));
272779
272842
  }, require_lodash, import_lodash$1, normalizeAttrs = (attrs = {}) => {
272780
272843
  return Object.fromEntries(Object.entries(attrs).filter(([, value]) => value !== null && value !== undefined));
272844
+ }, stripUnsetInternalSnapshotAttrs = (attrs = {}) => {
272845
+ const nextAttrs = { ...attrs };
272846
+ if (nextAttrs.ooxmlHighlightClear === null || nextAttrs.ooxmlHighlightClear === undefined)
272847
+ delete nextAttrs.ooxmlHighlightClear;
272848
+ return nextAttrs;
272849
+ }, createMarkSnapshot = (type, attrs = {}) => {
272850
+ return {
272851
+ type,
272852
+ attrs: stripUnsetInternalSnapshotAttrs(attrs)
272853
+ };
272781
272854
  }, IDENTITY_ATTR_VALUES, ATTRIBUTE_ONLY_MARKS, normalizeSnapshotAttrs = (attrs = {}) => {
272782
272855
  const base4 = normalizeAttrs(attrs);
272783
272856
  return Object.fromEntries(Object.entries(base4).filter(([key2, value]) => IDENTITY_ATTR_VALUES[key2] !== value));
@@ -272818,14 +272891,14 @@ var Node$13 = class Node$14 {
272818
272891
  if (existing) {
272819
272892
  const merged = {
272820
272893
  ...existing,
272821
- attrs: {
272894
+ attrs: stripUnsetInternalSnapshotAttrs({
272822
272895
  ...existing.attrs,
272823
272896
  ...incoming.attrs
272824
- }
272897
+ })
272825
272898
  };
272826
272899
  return snapshots.map((mark2) => mark2 === existing ? merged : mark2);
272827
272900
  }
272828
- return [...snapshots, incoming];
272901
+ return [...snapshots, createMarkSnapshot(incoming.type, incoming.attrs)];
272829
272902
  }, markMatchesSnapshot = (mark2, snapshot2, exact = true) => {
272830
272903
  return marksMatch(mark2, snapshot2, exact);
272831
272904
  }, markAttrsIncludeSnapshotAttrs = (mark2, snapshot2) => {
@@ -272935,19 +273008,13 @@ var Node$13 = class Node$14 {
272935
273008
  before = [...beforeSnapshots];
272936
273009
  after = upsertMarkSnapshotByType(afterSnapshots, {
272937
273010
  type: step2.mark.type.name,
272938
- attrs: { ...step2.mark.attrs }
273011
+ attrs: step2.mark.attrs
272939
273012
  });
272940
273013
  }
272941
273014
  } else {
272942
273015
  const existingMarkOfSameType = liveMarks.find((mark2) => mark2.type.name === step2.mark.type.name && !["trackDelete", "trackFormat"].includes(mark2.type.name));
272943
- before = existingMarkOfSameType ? [{
272944
- type: existingMarkOfSameType.type.name,
272945
- attrs: { ...existingMarkOfSameType.attrs }
272946
- }] : [];
272947
- after = [{
272948
- type: step2.mark.type.name,
272949
- attrs: { ...step2.mark.attrs }
272950
- }];
273016
+ before = existingMarkOfSameType ? [createMarkSnapshot(existingMarkOfSameType.type.name, existingMarkOfSameType.attrs)] : [];
273017
+ after = [createMarkSnapshot(step2.mark.type.name, step2.mark.attrs)];
272951
273018
  }
272952
273019
  if (isTrackFormatNoOp(before, after)) {
272953
273020
  if (formatChangeMark)
@@ -273009,17 +273076,14 @@ var Node$13 = class Node$14 {
273009
273076
  after = [...formatChangeMark.attrs.after];
273010
273077
  before = upsertMarkSnapshotByType(formatChangeMark.attrs.before, {
273011
273078
  type: step2.mark.type.name,
273012
- attrs: { ...step2.mark.attrs }
273079
+ attrs: step2.mark.attrs
273013
273080
  });
273014
273081
  }
273015
273082
  else {
273016
273083
  after = [];
273017
273084
  let existingMark = node2.marks.find((mark2) => mark2.type === step2.mark.type);
273018
273085
  if (existingMark)
273019
- before = [{
273020
- type: step2.mark.type.name,
273021
- attrs: { ...existingMark.attrs }
273022
- }];
273086
+ before = [createMarkSnapshot(step2.mark.type.name, existingMark.attrs)];
273023
273087
  else
273024
273088
  before = [];
273025
273089
  }
@@ -285885,16 +285949,7 @@ menclose::after {
285885
285949
  }, isRtlBlock = (block) => {
285886
285950
  if (block.kind !== "paragraph")
285887
285951
  return false;
285888
- const attrs = block.attrs;
285889
- if (!attrs)
285890
- return false;
285891
- const directionContext = attrs.directionContext;
285892
- if (directionContext?.inlineDirection != null)
285893
- return directionContext.inlineDirection === "rtl";
285894
- const directionAttr = attrs.direction ?? attrs.dir;
285895
- if (typeof directionAttr === "string" && directionAttr.toLowerCase() === "rtl")
285896
- return true;
285897
- return false;
285952
+ return getParagraphInlineDirection(block.attrs) === "rtl";
285898
285953
  }, determineColumn = (layout, fragmentX) => {
285899
285954
  const columns = layout.columns;
285900
285955
  if (!columns || columns.count <= 1)
@@ -294133,12 +294188,12 @@ menclose::after {
294133
294188
  return;
294134
294189
  console.log(...args$1);
294135
294190
  }, 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;
294136
- var init_src_CHVby7ed_es = __esm(() => {
294191
+ var init_src_GAfNMk63_es = __esm(() => {
294137
294192
  init_rolldown_runtime_Bg48TavK_es();
294138
- init_SuperConverter_D_cFThyR_es();
294193
+ init_SuperConverter_1Voea3gd_es();
294139
294194
  init_jszip_C49i9kUs_es();
294140
294195
  init_uuid_qzgm05fK_es();
294141
- init_create_headless_toolbar_DkFBZ1T1_es();
294196
+ init_create_headless_toolbar_cNPAdMd2_es();
294142
294197
  init_constants_DrU4EASo_es();
294143
294198
  init_dist_B8HfvhaK_es();
294144
294199
  init_unified_Dsuw2be5_es();
@@ -305273,18 +305328,25 @@ ${err.toString()}`);
305273
305328
  return { htmlAttributes: {} };
305274
305329
  },
305275
305330
  addAttributes() {
305276
- return { color: {
305277
- default: null,
305278
- parseDOM: (element3) => cssColorToHex(element3.getAttribute("data-color") || element3.style.backgroundColor),
305279
- renderDOM: (attributes) => {
305280
- if (!attributes.color)
305281
- return {};
305282
- return {
305283
- "data-color": attributes.color,
305284
- style: `background-color: ${attributes.color}; color: inherit`
305285
- };
305331
+ return {
305332
+ color: {
305333
+ default: null,
305334
+ parseDOM: (element3) => cssColorToHex(element3.getAttribute("data-color") || element3.style.backgroundColor),
305335
+ renderDOM: (attributes) => {
305336
+ if (!attributes.color)
305337
+ return {};
305338
+ return {
305339
+ "data-color": attributes.color,
305340
+ style: `background-color: ${attributes.color}; color: inherit`
305341
+ };
305342
+ }
305343
+ },
305344
+ ooxmlHighlightClear: {
305345
+ default: null,
305346
+ parseDOM: () => null,
305347
+ renderDOM: () => ({})
305286
305348
  }
305287
- } };
305349
+ };
305288
305350
  },
305289
305351
  parseDOM() {
305290
305352
  return [{ tag: "mark" }, {
@@ -332181,11 +332243,11 @@ function print() { __p += __j.call(arguments, '') }
332181
332243
  ];
332182
332244
  });
332183
332245
 
332184
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-0ZhHPCRD.es.js
332246
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-C8mCHw5x.es.js
332185
332247
  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;
332186
- var init_create_super_doc_ui_0ZhHPCRD_es = __esm(() => {
332187
- init_SuperConverter_D_cFThyR_es();
332188
- init_create_headless_toolbar_DkFBZ1T1_es();
332248
+ var init_create_super_doc_ui_C8mCHw5x_es = __esm(() => {
332249
+ init_SuperConverter_1Voea3gd_es();
332250
+ init_create_headless_toolbar_cNPAdMd2_es();
332189
332251
  MOD_ALIASES = new Set([
332190
332252
  "Mod",
332191
332253
  "Meta",
@@ -332227,16 +332289,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
332227
332289
 
332228
332290
  // ../../packages/superdoc/dist/super-editor.es.js
332229
332291
  var init_super_editor_es = __esm(() => {
332230
- init_src_CHVby7ed_es();
332231
- init_SuperConverter_D_cFThyR_es();
332292
+ init_src_GAfNMk63_es();
332293
+ init_SuperConverter_1Voea3gd_es();
332232
332294
  init_jszip_C49i9kUs_es();
332233
332295
  init_xml_js_CqGKpaft_es();
332234
- init_create_headless_toolbar_DkFBZ1T1_es();
332296
+ init_create_headless_toolbar_cNPAdMd2_es();
332235
332297
  init_constants_DrU4EASo_es();
332236
332298
  init_dist_B8HfvhaK_es();
332237
332299
  init_unified_Dsuw2be5_es();
332238
332300
  init_DocxZipper_TPSo9G36_es();
332239
- init_create_super_doc_ui_0ZhHPCRD_es();
332301
+ init_create_super_doc_ui_C8mCHw5x_es();
332240
332302
  init_ui_CGB3qmy3_es();
332241
332303
  init_eventemitter3_UwU_CLPU_es();
332242
332304
  init_errors_C_DoKMoN_es();
@@ -394847,6 +394909,22 @@ var XML_NODE_NAME12 = "w:r", SD_KEY_NAME2 = "run", REFERENCE_RUN_STYLE_BY_XML_NA
394847
394909
  if (!Array.isArray(node4.elements))
394848
394910
  return false;
394849
394911
  return node4.elements.some((child) => hasXmlNodeNamed2(child, targetName));
394912
+ }, COMPLEX_SCRIPT_CODEPOINT_RANGES2, textHasComplexScript2 = (text7) => {
394913
+ for (const char of text7) {
394914
+ const codePoint = char.codePointAt(0);
394915
+ if (COMPLEX_SCRIPT_CODEPOINT_RANGES2.some(([start2, end]) => codePoint >= start2 && codePoint <= end)) {
394916
+ return true;
394917
+ }
394918
+ }
394919
+ return false;
394920
+ }, hasComplexScriptText2 = (node4) => {
394921
+ if (!node4 || typeof node4 !== "object")
394922
+ return false;
394923
+ if (typeof node4.text === "string" && textHasComplexScript2(node4.text))
394924
+ return true;
394925
+ if (!Array.isArray(node4.content))
394926
+ return false;
394927
+ return node4.content.some((child) => hasComplexScriptText2(child));
394850
394928
  }, getRunPropertiesNode2 = (runNode) => {
394851
394929
  if (!runNode)
394852
394930
  return null;
@@ -395037,6 +395115,14 @@ var XML_NODE_NAME12 = "w:r", SD_KEY_NAME2 = "run", REFERENCE_RUN_STYLE_BY_XML_NA
395037
395115
  const shouldExport = (key2) => (key2 in (runProperties || {})) && (!(Array.isArray(styleKeys) && styleKeys.includes(key2)) || Array.isArray(overrideKeys) && overrideKeys.includes(key2));
395038
395116
  const exportKeys = candidateKeys.filter(shouldExport);
395039
395117
  const runPropertiesToExport = exportKeys.length > 0 ? Object.fromEntries(exportKeys.map((k2) => [k2, runProperties[k2]])) : {};
395118
+ if (hasComplexScriptText2(runNodeForExport)) {
395119
+ if ("bold" in runPropertiesToExport && !("boldCs" in runPropertiesToExport)) {
395120
+ runPropertiesToExport.boldCs = runPropertiesToExport.bold;
395121
+ }
395122
+ if ("italic" in runPropertiesToExport && !("italicCs" in runPropertiesToExport)) {
395123
+ runPropertiesToExport.italicCs = runPropertiesToExport.italic;
395124
+ }
395125
+ }
395040
395126
  const exportParams = {
395041
395127
  ...params3,
395042
395128
  node: runNodeForExport,
@@ -395154,6 +395240,14 @@ var init_r_translator = __esm(() => {
395154
395240
  "w:footnoteReference": "FootnoteReference",
395155
395241
  "w:endnoteReference": "EndnoteReference"
395156
395242
  };
395243
+ COMPLEX_SCRIPT_CODEPOINT_RANGES2 = [
395244
+ [1424, 2303],
395245
+ [2304, 4255],
395246
+ [6016, 6319],
395247
+ [7376, 7423],
395248
+ [43008, 43263],
395249
+ [43616, 43647]
395250
+ ];
395157
395251
  config13 = {
395158
395252
  xmlName: XML_NODE_NAME12,
395159
395253
  sdNodeOrKeyName: SD_KEY_NAME2,
@@ -396881,6 +396975,12 @@ function extractPlaceholder2(sdtPr) {
396881
396975
  const docPart = el?.elements?.find((e) => e.name === "w:docPart");
396882
396976
  return docPart?.attributes?.["w:val"] ?? null;
396883
396977
  }
396978
+ function extractTemporary2(sdtPr) {
396979
+ const el = sdtPr?.elements?.find((e) => e.name === "w:temporary");
396980
+ if (!el)
396981
+ return;
396982
+ return parseStrictStOnOff2(el.attributes?.["w:val"], "temporary", "w:temporary");
396983
+ }
396884
396984
  function handleStructuredContentNode2(params3) {
396885
396985
  const { nodes, nodeListHandler } = params3;
396886
396986
  if (nodes.length === 0 || nodes[0].name !== "w:sdt") {
@@ -396899,6 +396999,7 @@ function handleStructuredContentNode2(params3) {
396899
396999
  const controlType = detectControlType2(sdtPr);
396900
397000
  const appearance = extractAppearance2(sdtPr);
396901
397001
  const placeholder = extractPlaceholder2(sdtPr);
397002
+ const temporary = extractTemporary2(sdtPr);
396902
397003
  if (!sdtContent) {
396903
397004
  return null;
396904
397005
  }
@@ -396925,6 +397026,7 @@ function handleStructuredContentNode2(params3) {
396925
397026
  type: controlType,
396926
397027
  appearance,
396927
397028
  placeholder,
397029
+ ...temporary !== undefined ? { temporary } : {},
396928
397030
  sdtPr
396929
397031
  }
396930
397032
  };
@@ -396932,6 +397034,7 @@ function handleStructuredContentNode2(params3) {
396932
397034
  }
396933
397035
  var init_handle_structured_content_node = __esm(() => {
396934
397036
  init_handle_annotation_node();
397037
+ init_utils();
396935
397038
  });
396936
397039
 
396937
397040
  // ../../packages/super-editor/src/editors/v1/core/super-converter/v3/handlers/w/sdt/helpers/sdt-node-type-strategy.js
@@ -424703,6 +424806,7 @@ function translateDocumentNode2(params3) {
424703
424806
  elements: [translatedBodyNode],
424704
424807
  attributes
424705
424808
  };
424809
+ normalizePgMarTwipsInTree2(node4);
424706
424810
  return [node4, params3];
424707
424811
  }
424708
424812
  function wrapTextInRun2(nodeOrNodes, marks) {
@@ -424825,6 +424929,9 @@ function translateMark2(mark2) {
424825
424929
  break;
424826
424930
  case "highlight": {
424827
424931
  const highlightValue = attrs.color ?? attrs.highlight ?? null;
424932
+ if (String(highlightValue).trim().toLowerCase() === "transparent" && !attrs.ooxmlHighlightClear) {
424933
+ return {};
424934
+ }
424828
424935
  const translated = translator64.decode({ node: { attrs: { highlight: highlightValue } } });
424829
424936
  return translated || {};
424830
424937
  }
@@ -424976,6 +425083,27 @@ var DEFAULT_SECTION_PROPS_TWIPS2, ensureSectionLayoutDefaults2 = (sectPr, conver
424976
425083
  pgMar.attributes[attrKey] = value;
424977
425084
  });
424978
425085
  return sectPr;
425086
+ }, normalizePgMarTwipsInTree2 = (node4) => {
425087
+ if (!node4 || typeof node4 !== "object")
425088
+ return;
425089
+ if (node4.name === "w:pgMar" && node4.attributes && typeof node4.attributes === "object") {
425090
+ for (const key2 of Object.keys(node4.attributes)) {
425091
+ const value = node4.attributes[key2];
425092
+ if (value == null)
425093
+ continue;
425094
+ const serialized = String(value).trim();
425095
+ if (!serialized)
425096
+ continue;
425097
+ const num = Number(serialized);
425098
+ if (Number.isFinite(num) && !/^-?\d+$/.test(serialized)) {
425099
+ node4.attributes[key2] = String(Math.round(num));
425100
+ }
425101
+ }
425102
+ }
425103
+ if (Array.isArray(node4.elements)) {
425104
+ for (const child of node4.elements)
425105
+ normalizePgMarTwipsInTree2(child);
425106
+ }
424979
425107
  }, generateDefaultHeaderFooter2 = (type, id2) => {
424980
425108
  return {
424981
425109
  type: "element",
@@ -428282,7 +428410,7 @@ function encodeMarksFromRPr2(runProperties, docx) {
428282
428410
  }
428283
428411
  const marks = [];
428284
428412
  const textStyleAttrs = {};
428285
- let highlightColor = null;
428413
+ let highlightAttrs = null;
428286
428414
  let hasHighlightTag = false;
428287
428415
  Object.keys(runProperties).forEach((key2) => {
428288
428416
  const value = runProperties[key2];
@@ -428364,7 +428492,10 @@ function encodeMarksFromRPr2(runProperties, docx) {
428364
428492
  const color3 = getHighLightValue3(value);
428365
428493
  if (color3) {
428366
428494
  hasHighlightTag = true;
428367
- highlightColor = color3;
428495
+ highlightAttrs = { color: color3 };
428496
+ if (color3.toLowerCase() === "transparent" && String(value?.["w:val"]).toLowerCase() === "none") {
428497
+ highlightAttrs.ooxmlHighlightClear = true;
428498
+ }
428368
428499
  }
428369
428500
  break;
428370
428501
  case "shading": {
@@ -428374,11 +428505,11 @@ function encodeMarksFromRPr2(runProperties, docx) {
428374
428505
  const fill = value["fill"];
428375
428506
  const shdVal = value["val"];
428376
428507
  if (fill && String(fill).toLowerCase() !== "auto") {
428377
- highlightColor = `#${String(fill).replace("#", "")}`;
428508
+ highlightAttrs = { color: `#${String(fill).replace("#", "")}` };
428378
428509
  } else if (typeof shdVal === "string") {
428379
428510
  const normalized = shdVal.toLowerCase();
428380
428511
  if (normalized === "clear" || normalized === "nil" || normalized === "none") {
428381
- highlightColor = "transparent";
428512
+ highlightAttrs = { color: "transparent" };
428382
428513
  }
428383
428514
  }
428384
428515
  break;
@@ -428403,8 +428534,8 @@ function encodeMarksFromRPr2(runProperties, docx) {
428403
428534
  if (Object.keys(textStyleAttrs).length) {
428404
428535
  marks.push({ type: "textStyle", attrs: textStyleAttrs });
428405
428536
  }
428406
- if (highlightColor) {
428407
- marks.push({ type: "highlight", attrs: { color: highlightColor } });
428537
+ if (highlightAttrs) {
428538
+ marks.push({ type: "highlight", attrs: highlightAttrs });
428408
428539
  }
428409
428540
  return marks;
428410
428541
  }
@@ -428420,11 +428551,6 @@ function decodeRPrFromMarks2(marks) {
428420
428551
  case "italic":
428421
428552
  case "bold":
428422
428553
  runProperties[type] = mark2.attrs.value !== "0" && mark2.attrs.value !== false;
428423
- if (type === "bold") {
428424
- runProperties.boldCs = runProperties.bold;
428425
- } else if (type === "italic") {
428426
- runProperties.italicCs = runProperties.italic;
428427
- }
428428
428554
  break;
428429
428555
  case "underline": {
428430
428556
  const { underlineType, underlineColor, underlineThemeColor, underlineThemeTint, underlineThemeShade } = mark2.attrs;
@@ -428450,12 +428576,14 @@ function decodeRPrFromMarks2(marks) {
428450
428576
  break;
428451
428577
  }
428452
428578
  case "highlight":
428453
- if (mark2.attrs.color) {
428454
- if (mark2.attrs.color.toLowerCase() === "transparent") {
428579
+ if (!mark2.attrs.color)
428580
+ break;
428581
+ if (mark2.attrs.color.toLowerCase() === "transparent") {
428582
+ if (mark2.attrs.ooxmlHighlightClear) {
428455
428583
  runProperties.highlight = { "w:val": "none" };
428456
- } else {
428457
- runProperties.highlight = { "w:val": mark2.attrs.color };
428458
428584
  }
428585
+ } else {
428586
+ runProperties.highlight = { "w:val": mark2.attrs.color };
428459
428587
  }
428460
428588
  break;
428461
428589
  case "link":
@@ -428658,9 +428786,7 @@ var init_calculateInlineRunPropertiesPlugin = __esm(() => {
428658
428786
  RUN_PROPERTIES_DERIVED_FROM_MARKS2 = new Set([
428659
428787
  "strike",
428660
428788
  "italic",
428661
- "italicCs",
428662
428789
  "bold",
428663
- "boldCs",
428664
428790
  "underline",
428665
428791
  "highlight",
428666
428792
  "textTransform",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.3.0-next.93",
3
+ "version": "0.3.0-next.95",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"