@superdoc-dev/mcp 0.3.0-next.85 → 0.3.0-next.87

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 +318 -79
  2. package/package.json +3 -3
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-B1Huzhur.es.js
51894
+ // ../../packages/superdoc/dist/chunks/SuperConverter-5Idv4fhC.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")
@@ -70340,6 +70340,15 @@ function calculateResolvedParagraphProperties(editor, node2, $pos) {
70340
70340
  resolvedParagraphPropertiesCache.set(node2, paragraphProperties);
70341
70341
  return paragraphProperties;
70342
70342
  }
70343
+ function resolveHypotheticalParagraphProperties(editor, $pos, inlineProps) {
70344
+ if (!editor?.converter)
70345
+ return inlineProps;
70346
+ const tableStyleId = findParentNodeClosestToPos($pos, (node2) => node2.type.name === "table")?.node.attrs.tableStyleId || null;
70347
+ return resolveParagraphProperties({
70348
+ translatedNumbering: editor.converter.translatedNumbering,
70349
+ translatedLinkedStyles: editor.converter.translatedLinkedStyles
70350
+ }, inlineProps, tableStyleId);
70351
+ }
70343
70352
  function getRunContext($pos) {
70344
70353
  let paragraphNode = null;
70345
70354
  let paragraphDepth = -1;
@@ -105335,7 +105344,7 @@ var isRegExp = (value) => {
105335
105344
  state.kern = kernNode.attributes["w:val"];
105336
105345
  }
105337
105346
  }, SuperConverter;
105338
- var init_SuperConverter_B1Huzhur_es = __esm(() => {
105347
+ var init_SuperConverter_5Idv4fhC_es = __esm(() => {
105339
105348
  init_rolldown_runtime_Bg48TavK_es();
105340
105349
  init_jszip_C49i9kUs_es();
105341
105350
  init_xml_js_CqGKpaft_es();
@@ -143204,7 +143213,7 @@ var init_SuperConverter_B1Huzhur_es = __esm(() => {
143204
143213
  };
143205
143214
  });
143206
143215
 
143207
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-B1ifCjiq.es.js
143216
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-CEUTigkM.es.js
143208
143217
  function parseSizeUnit(val = "0") {
143209
143218
  const length = val.toString() || "0";
143210
143219
  const value = Number.parseFloat(length);
@@ -145457,6 +145466,27 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
145457
145466
  }, getCurrentParagraphJustification = (context) => {
145458
145467
  const paragraphProperties = getCurrentResolvedParagraphProperties(context);
145459
145468
  return mapStoredJustificationToDisplayAlignment(paragraphProperties?.justification ?? null, paragraphProperties?.rightToLeft === true);
145469
+ }, createParagraphDirectionStateDeriver = (direction) => ({ context }) => {
145470
+ if (isCommandDisabled(context))
145471
+ return {
145472
+ active: false,
145473
+ disabled: true,
145474
+ value: null
145475
+ };
145476
+ const current = getCurrentResolvedParagraphProperties(context)?.rightToLeft ? "rtl" : "ltr";
145477
+ return {
145478
+ active: current === direction,
145479
+ disabled: false,
145480
+ value: current
145481
+ };
145482
+ }, createParagraphDirectionExecute = (direction) => ({ context }) => {
145483
+ const command = resolveStateEditor(context)?.commands.setParagraphDirection;
145484
+ if (typeof command !== "function")
145485
+ return false;
145486
+ return Boolean(command({
145487
+ direction,
145488
+ alignmentPolicy: "matchDirection"
145489
+ }));
145460
145490
  }, createTextAlignStateDeriver = () => ({ context }) => {
145461
145491
  if (isCommandDisabled(context))
145462
145492
  return {
@@ -145696,6 +145726,18 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
145696
145726
  state: createDisabledStateDeriver(),
145697
145727
  execute: createIndentDecreaseExecute()
145698
145728
  },
145729
+ "direction-ltr": {
145730
+ id: "direction-ltr",
145731
+ directCommandName: "setParagraphDirection",
145732
+ state: createParagraphDirectionStateDeriver("ltr"),
145733
+ execute: createParagraphDirectionExecute("ltr")
145734
+ },
145735
+ "direction-rtl": {
145736
+ id: "direction-rtl",
145737
+ directCommandName: "setParagraphDirection",
145738
+ state: createParagraphDirectionStateDeriver("rtl"),
145739
+ execute: createParagraphDirectionExecute("rtl")
145740
+ },
145699
145741
  undo: {
145700
145742
  id: "undo",
145701
145743
  directCommandName: "undo",
@@ -145893,8 +145935,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
145893
145935
  }
145894
145936
  };
145895
145937
  };
145896
- var init_create_headless_toolbar_B1ifCjiq_es = __esm(() => {
145897
- init_SuperConverter_B1Huzhur_es();
145938
+ var init_create_headless_toolbar_CEUTigkM_es = __esm(() => {
145939
+ init_SuperConverter_5Idv4fhC_es();
145898
145940
  init_constants_DrU4EASo_es();
145899
145941
  init_dist_B8HfvhaK_es();
145900
145942
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
@@ -200112,7 +200154,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
200112
200154
  init_remark_gfm_BhnWr3yf_es();
200113
200155
  });
200114
200156
 
200115
- // ../../packages/superdoc/dist/chunks/src-BiYFxw9u.es.js
200157
+ // ../../packages/superdoc/dist/chunks/src-OZOxpRA7.es.js
200116
200158
  function deleteProps(obj, propOrProps) {
200117
200159
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
200118
200160
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -200357,6 +200399,16 @@ function calculateTabWidth(params$1) {
200357
200399
  tabStopPosUsed: nextStop.pos
200358
200400
  };
200359
200401
  }
200402
+ function getParagraphInlineDirection(attrs) {
200403
+ const fromContext = attrs?.directionContext?.inlineDirection;
200404
+ if (fromContext != null)
200405
+ return fromContext;
200406
+ const ppRtl = attrs?.paragraphProperties?.rightToLeft;
200407
+ if (attrs?.direction === "rtl" || attrs?.dir === "rtl" || attrs?.rtl === true || ppRtl === true)
200408
+ return "rtl";
200409
+ if (attrs?.direction === "ltr" || attrs?.dir === "ltr" || attrs?.rtl === false || ppRtl === false)
200410
+ return "ltr";
200411
+ }
200360
200412
  function resolveTableWidthAttr(value) {
200361
200413
  if (!value || typeof value !== "object")
200362
200414
  return null;
@@ -202987,6 +203039,44 @@ function modifyIndentation(calcFunc, { resolveProps = false } = {}) {
202987
203039
  return success2;
202988
203040
  };
202989
203041
  }
203042
+ function walkParagraphs$1(transform2) {
203043
+ return ({ editor, state, dispatch }) => {
203044
+ const { from: from$1, to } = state.selection;
203045
+ const tr = state.tr;
203046
+ let touched = false;
203047
+ state.doc.nodesBetween(from$1, to, (node2, pos) => {
203048
+ if (node2.type.name !== "paragraph")
203049
+ return true;
203050
+ const existing = node2.attrs.paragraphProperties || {};
203051
+ const updated = transform2(existing, {
203052
+ editor,
203053
+ node: node2,
203054
+ $pos: state.doc.resolve(pos)
203055
+ });
203056
+ if (shallowEqual$2(existing, updated))
203057
+ return false;
203058
+ tr.setNodeMarkup(pos, undefined, {
203059
+ ...node2.attrs,
203060
+ paragraphProperties: updated
203061
+ });
203062
+ touched = true;
203063
+ return false;
203064
+ });
203065
+ if (touched && dispatch)
203066
+ dispatch(tr);
203067
+ return touched;
203068
+ };
203069
+ }
203070
+ function shallowEqual$2(a2, b$1) {
203071
+ const ka = Object.keys(a2);
203072
+ const kb = Object.keys(b$1);
203073
+ if (ka.length !== kb.length)
203074
+ return false;
203075
+ for (const k$1 of ka)
203076
+ if (a2[k$1] !== b$1[k$1])
203077
+ return false;
203078
+ return true;
203079
+ }
202990
203080
  function deleteFromEndOfRun(state, dispatch, $pos) {
202991
203081
  const rightRun = state.doc.nodeAt($pos.pos + 1);
202992
203082
  const $afterRightRunPos = state.doc.resolve($pos.pos + 2 + rightRun.nodeSize);
@@ -203962,7 +204052,7 @@ function isListParagraph(node2) {
203962
204052
  return node2?.type?.name === "paragraph" && node2.attrs?.paragraphProperties?.numberingProperties && node2.attrs?.listRendering;
203963
204053
  }
203964
204054
  function isRtlParagraph$1(node2) {
203965
- return node2?.attrs?.paragraphProperties?.rightToLeft === true || node2?.attrs?.direction === "rtl" || node2?.attrs?.rtl === true;
204055
+ return getParagraphInlineDirection(node2?.attrs) === "rtl";
203966
204056
  }
203967
204057
  function getParagraphContext$1($pos) {
203968
204058
  for (let depth = $pos.depth;depth >= 0; depth--) {
@@ -204808,6 +204898,9 @@ function getTableContext($head) {
204808
204898
  table: table2
204809
204899
  };
204810
204900
  }
204901
+ function isRtlTable(table2) {
204902
+ return table2?.attrs?.tableProperties?.rightToLeft === true;
204903
+ }
204811
204904
  function getCellRect(context) {
204812
204905
  const map$12 = TableMap.get(context.table);
204813
204906
  return {
@@ -204815,6 +204908,9 @@ function getCellRect(context) {
204815
204908
  rect: map$12.findCell(context.cellStart - context.tableStart)
204816
204909
  };
204817
204910
  }
204911
+ function getEffectiveTableDir(table2, dir) {
204912
+ return isRtlTable(table2) ? -dir : dir;
204913
+ }
204818
204914
  function isLastCellInTable(context) {
204819
204915
  if (!context)
204820
204916
  return false;
@@ -204906,7 +205002,8 @@ function getTableBoundaryExitSelection(state, dir) {
204906
205002
  const context = getTableContext(selection.$head);
204907
205003
  if (!context)
204908
205004
  return null;
204909
- const helpers = getDirectionHelpers(dir);
205005
+ const effectiveDir = getEffectiveTableDir(context.table, dir);
205006
+ const helpers = getDirectionHelpers(effectiveDir);
204910
205007
  if (!helpers.isEdgeParagraphInCell(selection.$head, context.cellDepth))
204911
205008
  return null;
204912
205009
  if (!helpers.isAtParagraphBoundary(selection.$head))
@@ -204917,7 +205014,38 @@ function getTableBoundaryExitSelection(state, dir) {
204917
205014
  const targetPos = helpers.findTextPosAcrossBoundary(state, boundaryPos);
204918
205015
  if (targetPos != null)
204919
205016
  return TextSelection.create(state.doc, targetPos);
204920
- return findSelectionNearBoundary(state, boundaryPos, dir);
205017
+ return findSelectionNearBoundary(state, boundaryPos, effectiveDir);
205018
+ }
205019
+ function getIntraTableArrowSelection(state, dir, expandSelection) {
205020
+ const selection = state.selection;
205021
+ if (!selection.empty)
205022
+ return null;
205023
+ const context = getTableContext(selection.$head);
205024
+ if (!context)
205025
+ return null;
205026
+ if (!isRtlTable(context.table))
205027
+ return null;
205028
+ const effectiveDir = getEffectiveTableDir(context.table, dir);
205029
+ const helpers = getDirectionHelpers(effectiveDir);
205030
+ if (!helpers.isEdgeParagraphInCell(selection.$head, context.cellDepth))
205031
+ return null;
205032
+ if (!helpers.isAtParagraphBoundary(selection.$head))
205033
+ return null;
205034
+ const { map: map$12 } = getCellRect(context);
205035
+ const currentCellRelativePos = context.cellStart - context.tableStart;
205036
+ const nextCellRelativePos = map$12.nextCell(currentCellRelativePos, "horiz", effectiveDir);
205037
+ if (nextCellRelativePos == null)
205038
+ return null;
205039
+ const nextCellAbsolutePos = context.tableStart + nextCellRelativePos;
205040
+ if (expandSelection)
205041
+ return CellSelection.create(state.doc, context.cellStart, nextCellAbsolutePos);
205042
+ const nextCellNode = state.doc.nodeAt(nextCellAbsolutePos);
205043
+ if (!nextCellNode)
205044
+ return null;
205045
+ const targetPos = effectiveDir > 0 ? findFirstTextPosInNode(nextCellNode, nextCellAbsolutePos) : findLastTextPosInNode(nextCellNode, nextCellAbsolutePos);
205046
+ if (targetPos != null)
205047
+ return TextSelection.create(state.doc, targetPos);
205048
+ return findSelectionNearBoundary(state, nextCellAbsolutePos, effectiveDir);
204921
205049
  }
204922
205050
  function getAdjacentTableEntrySelection(state, dir) {
204923
205051
  const selection = state.selection;
@@ -204934,13 +205062,14 @@ function getAdjacentTableEntrySelection(state, dir) {
204934
205062
  const adjacentNode = dir > 0 ? $boundary.nodeAfter : $boundary.nodeBefore;
204935
205063
  if (!adjacentNode || adjacentNode.type.spec.tableRole !== "table")
204936
205064
  return null;
204937
- if (dir > 0) {
204938
- const targetPos$1 = findFirstTextPosInNode(adjacentNode, boundaryPos);
205065
+ const effectiveDir = isRtlTable(adjacentNode) ? -dir : dir;
205066
+ const tablePos = dir > 0 ? boundaryPos : boundaryPos - adjacentNode.nodeSize;
205067
+ if (effectiveDir > 0) {
205068
+ const targetPos$1 = findFirstTextPosInNode(adjacentNode, tablePos);
204939
205069
  if (targetPos$1 != null)
204940
205070
  return TextSelection.create(state.doc, targetPos$1);
204941
- return findSelectionNearBoundary(state, boundaryPos, 1);
205071
+ return findSelectionNearBoundary(state, tablePos, 1);
204942
205072
  }
204943
- const tablePos = boundaryPos - adjacentNode.nodeSize;
204944
205073
  const targetPos = findLastTextPosInNode(adjacentNode, tablePos);
204945
205074
  if (targetPos != null)
204946
205075
  return TextSelection.create(state.doc, targetPos);
@@ -204952,7 +205081,7 @@ function createTableBoundaryNavigationPlugin() {
204952
205081
  props: { handleKeyDown(view, event) {
204953
205082
  if (event.defaultPrevented)
204954
205083
  return false;
204955
- if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey)
205084
+ if (event.altKey || event.ctrlKey || event.metaKey)
204956
205085
  return false;
204957
205086
  if ((event.key === "Backspace" || event.key === "Delete") && isInProtectedTrailingTableParagraph(view.state)) {
204958
205087
  event.preventDefault();
@@ -204961,7 +205090,14 @@ function createTableBoundaryNavigationPlugin() {
204961
205090
  const dir = event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
204962
205091
  if (!dir)
204963
205092
  return false;
204964
- const nextSelection = getTableBoundaryExitSelection(view.state, dir) ?? getAdjacentTableEntrySelection(view.state, dir);
205093
+ const context = getTableContext(view.state.selection.$head);
205094
+ const allowShiftInRtlTable = Boolean(event.shiftKey && context && isRtlTable(context.table));
205095
+ if (event.shiftKey && !allowShiftInRtlTable)
205096
+ return false;
205097
+ let nextSelection = getIntraTableArrowSelection(view.state, dir, event.shiftKey);
205098
+ if (!nextSelection && event.shiftKey)
205099
+ return false;
205100
+ nextSelection = nextSelection ?? getTableBoundaryExitSelection(view.state, dir) ?? getAdjacentTableEntrySelection(view.state, dir);
204965
205101
  if (!nextSelection)
204966
205102
  return false;
204967
205103
  view.dispatch(view.state.tr.setSelection(nextSelection).scrollIntoView());
@@ -246523,18 +246659,28 @@ function resolveRenderedTableWidth(columnWidth, measuredWidth, attrs) {
246523
246659
  }
246524
246660
  function resolveTableFrame(baseX, columnWidth, tableWidth, attrs) {
246525
246661
  const width = resolveRenderedTableWidth(columnWidth, tableWidth, attrs);
246526
- const justification = typeof attrs?.justification === "string" ? attrs.justification : undefined;
246527
- if (justification === "center")
246662
+ const explicitJustification = typeof attrs?.justification === "string" ? attrs.justification : undefined;
246663
+ const isRtlTable$1 = attrs?.tableProperties?.rightToLeft === true;
246664
+ const effectiveJustification = explicitJustification ?? (isRtlTable$1 ? "end" : undefined);
246665
+ const tableIndent = getTableIndentWidth(attrs);
246666
+ if (effectiveJustification === "center")
246528
246667
  return {
246529
246668
  x: baseX + (columnWidth - width) / 2,
246530
246669
  width
246531
246670
  };
246532
- if (justification === "right" || justification === "end")
246671
+ if (effectiveJustification === "right" || effectiveJustification === "end") {
246672
+ const rightAlignedX = baseX + (columnWidth - width);
246673
+ if (explicitJustification == null && isRtlTable$1 && tableIndent !== 0)
246674
+ return {
246675
+ x: rightAlignedX - tableIndent,
246676
+ width
246677
+ };
246533
246678
  return {
246534
- x: baseX + (columnWidth - width),
246679
+ x: rightAlignedX,
246535
246680
  width
246536
246681
  };
246537
- return applyTableIndent(baseX, width, getTableIndentWidth(attrs), columnWidth);
246682
+ }
246683
+ return applyTableIndent(baseX, width, tableIndent, columnWidth);
246538
246684
  }
246539
246685
  function calculateColumnMinWidth(measuredWidth) {
246540
246686
  if (!Number.isFinite(measuredWidth) || measuredWidth <= 0)
@@ -254905,30 +255051,61 @@ function isTableBorderValue(value) {
254905
255051
  function extractTableBorders(bordersInput, options) {
254906
255052
  if (!bordersInput || typeof bordersInput !== "object")
254907
255053
  return;
254908
- const sides = [
255054
+ const borders = {};
255055
+ const assignConverted = (side, raw) => {
255056
+ if (raw == null)
255057
+ return;
255058
+ if (isTableBorderValue(raw)) {
255059
+ borders[side] = raw;
255060
+ return;
255061
+ }
255062
+ const converted = convertTableBorderValue(raw, options);
255063
+ if (converted !== undefined)
255064
+ borders[side] = converted;
255065
+ };
255066
+ for (const side of [
254909
255067
  "top",
254910
255068
  "right",
254911
255069
  "bottom",
254912
255070
  "left",
254913
255071
  "insideH",
254914
255072
  "insideV"
254915
- ];
255073
+ ])
255074
+ assignConverted(side, bordersInput[side]);
255075
+ if (borders.left == null)
255076
+ assignConverted("left", bordersInput.start);
255077
+ if (borders.right == null)
255078
+ assignConverted("right", bordersInput.end);
255079
+ return Object.keys(borders).length > 0 ? borders : undefined;
255080
+ }
255081
+ function extractCellBorders(cellAttrs, _options) {
255082
+ if (!cellAttrs?.borders)
255083
+ return;
255084
+ const bordersData = cellAttrs.borders;
254916
255085
  const borders = {};
254917
- for (const side of sides) {
254918
- const raw = bordersInput[side];
254919
- if (raw == null)
254920
- continue;
254921
- if (isTableBorderValue(raw))
254922
- borders[side] = raw;
254923
- else {
254924
- const converted = convertTableBorderValue(raw, options);
254925
- if (converted !== undefined)
254926
- borders[side] = converted;
254927
- }
255086
+ for (const side of [
255087
+ "top",
255088
+ "right",
255089
+ "bottom",
255090
+ "left"
255091
+ ]) {
255092
+ const spec = convertBorderSpec(bordersData[side]);
255093
+ if (spec)
255094
+ borders[side] = spec;
255095
+ }
255096
+ if (borders.left == null) {
255097
+ const spec = convertBorderSpec(bordersData.start);
255098
+ if (spec)
255099
+ borders.left = spec;
255100
+ }
255101
+ if (borders.right == null) {
255102
+ const spec = convertBorderSpec(bordersData.end);
255103
+ if (spec)
255104
+ borders.right = spec;
254928
255105
  }
254929
255106
  return Object.keys(borders).length > 0 ? borders : undefined;
254930
255107
  }
254931
- function extractCellPadding(cellAttrs) {
255108
+ function extractCellPadding(cellAttrs, _options) {
254932
255109
  const cellMargins = cellAttrs?.cellMargins;
254933
255110
  if (!cellMargins || typeof cellMargins !== "object")
254934
255111
  return;
@@ -254942,6 +255119,12 @@ function extractCellPadding(cellAttrs) {
254942
255119
  padding.bottom = margins.bottom;
254943
255120
  if (typeof margins.left === "number")
254944
255121
  padding.left = margins.left;
255122
+ const marginStart = margins.marginStart;
255123
+ const marginEnd = margins.marginEnd;
255124
+ if (typeof marginStart === "number" && padding.left == null)
255125
+ padding.left = marginStart;
255126
+ if (typeof marginEnd === "number" && padding.right == null)
255127
+ padding.right = marginEnd;
254945
255128
  if (Object.keys(padding).length === 0)
254946
255129
  return;
254947
255130
  return normalizeCellPaddingTopBottom(padding);
@@ -256766,7 +256949,11 @@ function tableNodeToBlock(node2, { nextBlockId, positions, storyKey, trackedChan
256766
256949
  };
256767
256950
  };
256768
256951
  const borderSource = getBorderSource();
256769
- const tableBorders = borderSource ? extractTableBorders(borderSource.borders, { unit: borderSource.unit }) : undefined;
256952
+ const isRtlTable$1 = tablePropertiesForCascade?.rightToLeft === true;
256953
+ const tableBorders = borderSource ? extractTableBorders(borderSource.borders, {
256954
+ unit: borderSource.unit,
256955
+ isRtl: isRtlTable$1
256956
+ }) : undefined;
256770
256957
  if (tableBorders)
256771
256958
  tableAttrs.borders = tableBorders;
256772
256959
  if (node2.attrs?.borderCollapse)
@@ -258804,7 +258991,7 @@ function computeCaretLayoutRectGeometry({ layout, blocks: blocks2, measures, pai
258804
258991
  });
258805
258992
  const availableWidth = Math.max(0, fragment.width - (indentAdjust + indent2.right));
258806
258993
  const charX = measureCharacterX(block, line, pmOffset, availableWidth);
258807
- const resolvedCharX = block.attrs?.direction === "rtl" ? Math.max(0, availableWidth - charX) : charX;
258994
+ const resolvedCharX = getParagraphInlineDirection(block.attrs) === "rtl" ? Math.max(0, availableWidth - charX) : charX;
258808
258995
  const localX = fragment.x + indentAdjust + resolvedCharX;
258809
258996
  const lineOffset = lineHeightBeforeIndex(measure.lines, fragment.fromLine, index2);
258810
258997
  const localY = fragment.y + lineOffset;
@@ -267518,7 +267705,32 @@ var Node$13 = class Node$14 {
267518
267705
  });
267519
267706
  }, unsetLineHeight = () => ({ commands: commands$1 }) => {
267520
267707
  return commands$1.resetAttributes("paragraph", "paragraphProperties.spacing.line", "paragraphProperties.spacing.lineRule");
267521
- }, backspaceEmptyRunParagraph = () => ({ state, dispatch }) => {
267708
+ }, setParagraphDirection = ({ direction, alignmentPolicy } = {}) => {
267709
+ if (direction !== "ltr" && direction !== "rtl")
267710
+ return () => false;
267711
+ return walkParagraphs$1((pPr, { editor, $pos }) => {
267712
+ const next2 = { ...pPr };
267713
+ if (direction === "rtl")
267714
+ next2.rightToLeft = true;
267715
+ else {
267716
+ delete next2.rightToLeft;
267717
+ if (resolveHypotheticalParagraphProperties(editor, $pos, next2)?.rightToLeft === true)
267718
+ next2.rightToLeft = false;
267719
+ }
267720
+ if (alignmentPolicy === "matchDirection") {
267721
+ const j = pPr.justification;
267722
+ if (j === "left" && direction === "rtl")
267723
+ next2.justification = "right";
267724
+ else if (j === "right" && direction === "ltr")
267725
+ next2.justification = "left";
267726
+ }
267727
+ return next2;
267728
+ });
267729
+ }, clearParagraphDirection = () => walkParagraphs$1((pPr) => {
267730
+ const next2 = { ...pPr };
267731
+ delete next2.rightToLeft;
267732
+ return next2;
267733
+ }), backspaceEmptyRunParagraph = () => ({ state, dispatch }) => {
267522
267734
  const { $from } = state.selection;
267523
267735
  if (!state.selection.empty)
267524
267736
  return false;
@@ -281397,6 +281609,7 @@ menclose::after {
281397
281609
  min: boundary.minWidth,
281398
281610
  r: boundary.resizable ? 1 : 0
281399
281611
  })),
281612
+ rtl: isRtl,
281400
281613
  segments: boundarySegments.map((segs, colIndex) => segs.map((seg) => ({
281401
281614
  c: colIndex,
281402
281615
  y: seg.y + contentTop,
@@ -281415,7 +281628,7 @@ menclose::after {
281415
281628
  }
281416
281629
  if (block.id)
281417
281630
  container.setAttribute("data-sd-block-id", block.id);
281418
- if ((block.attrs?.borderCollapse ?? (block.attrs?.cellSpacing != null ? "separate" : "collapse")) === "separate" && block.attrs?.cellSpacing && tableBorders) {
281631
+ if ((block.attrs?.borderCollapse ?? (block.attrs?.cellSpacing != null ? "separate" : "collapse")) === "separate" && tableBorders) {
281419
281632
  applyBorder(container, "Top", borderValueToSpec(tableBorders.top));
281420
281633
  applyBorder(container, "Right", borderValueToSpec(isRtl ? tableBorders.left : tableBorders.right));
281421
281634
  applyBorder(container, "Bottom", borderValueToSpec(tableBorders.bottom));
@@ -281571,7 +281784,7 @@ menclose::after {
281571
281784
  y$1 += actualRowHeight + cellSpacingPx;
281572
281785
  }
281573
281786
  return container;
281574
- }, isRtlParagraph = (attrs) => attrs?.direction === "rtl", resolveTextAlign = (alignment$1, isRtl) => {
281787
+ }, isRtlParagraph = (attrs) => getParagraphInlineDirection(attrs) === "rtl", resolveTextAlign = (alignment$1, isRtl) => {
281575
281788
  switch (alignment$1) {
281576
281789
  case "center":
281577
281790
  case "right":
@@ -282895,7 +283108,7 @@ menclose::after {
282895
283108
  attrs.borders ? hashParagraphBorders$1(attrs.borders) : "",
282896
283109
  attrs.shading?.fill ?? "",
282897
283110
  attrs.shading?.color ?? "",
282898
- attrs.direction ?? "",
283111
+ getParagraphInlineDirection(attrs) ?? "",
282899
283112
  attrs.tabs?.length ? JSON.stringify(attrs.tabs) : ""
282900
283113
  ].join(":") : "";
282901
283114
  const sdtAttrs = block.attrs?.sdt;
@@ -283023,7 +283236,7 @@ menclose::after {
283023
283236
  hash$3 = hashNumber(hash$3, attrs.indent?.hanging ?? 0);
283024
283237
  hash$3 = hashString(hash$3, attrs.shading?.fill ?? "");
283025
283238
  hash$3 = hashString(hash$3, attrs.shading?.color ?? "");
283026
- hash$3 = hashString(hash$3, attrs.direction ?? "");
283239
+ hash$3 = hashString(hash$3, getParagraphInlineDirection(attrs) ?? "");
283027
283240
  if (attrs.borders)
283028
283241
  hash$3 = hashString(hash$3, hashParagraphBorders$1(attrs.borders));
283029
283242
  }
@@ -283739,8 +283952,9 @@ menclose::after {
283739
283952
  if (sh.color)
283740
283953
  parts.push(`shc:${sh.color}`);
283741
283954
  }
283742
- if (attrs.direction)
283743
- parts.push(`dir:${attrs.direction}`);
283955
+ const cellDir = getParagraphInlineDirection(attrs);
283956
+ if (cellDir)
283957
+ parts.push(`dir:${cellDir}`);
283744
283958
  if (parts.length > 0)
283745
283959
  cellHashes.push(`pa:${parts.join(":")}`);
283746
283960
  }
@@ -283846,8 +284060,9 @@ menclose::after {
283846
284060
  const tabsHash = attrs.tabs.map((t) => `${t.val ?? ""}:${t.pos ?? ""}:${t.leader ?? ""}`).join(",");
283847
284061
  parts.push(`tb:${tabsHash}`);
283848
284062
  }
283849
- if (attrs.direction)
283850
- parts.push(`dir:${attrs.direction}`);
284063
+ const dir = getParagraphInlineDirection(attrs);
284064
+ if (dir)
284065
+ parts.push(`dir:${dir}`);
283851
284066
  if (attrs.keepNext)
283852
284067
  parts.push("kn");
283853
284068
  if (attrs.keepLines)
@@ -288142,10 +288357,11 @@ menclose::after {
288142
288357
  }, EMPTY_CHART_DATA, hydrateTableStyleAttrs = (tableNode, context, effectiveStyleId) => {
288143
288358
  const hydration = {};
288144
288359
  const tableProps = tableNode.attrs?.tableProperties ?? null;
288360
+ const isRtlTable$1 = tableProps?.rightToLeft === true;
288145
288361
  let inlineBorders;
288146
288362
  let inlinePadding;
288147
288363
  if (tableProps) {
288148
- const padding = convertCellMarginsToPx(tableProps.cellMargins);
288364
+ const padding = convertCellMarginsToPx(tableProps.cellMargins, isRtlTable$1);
288149
288365
  if (padding)
288150
288366
  inlinePadding = normalizeCellPaddingTopBottom(padding);
288151
288367
  if (tableProps.borders && typeof tableProps.borders === "object")
@@ -288176,7 +288392,7 @@ menclose::after {
288176
288392
  } else if (inlineBorders)
288177
288393
  hydration.borders = inlineBorders;
288178
288394
  if (resolved.cellMargins) {
288179
- const stylePadding = convertCellMarginsToPx(resolved.cellMargins);
288395
+ const stylePadding = convertCellMarginsToPx(resolved.cellMargins, isRtlTable$1);
288180
288396
  if (stylePadding) {
288181
288397
  const normalizedStylePadding = normalizeCellPaddingTopBottom(stylePadding);
288182
288398
  hydration.cellPadding = inlinePadding ? {
@@ -288222,7 +288438,9 @@ menclose::after {
288222
288438
  "left",
288223
288439
  "right",
288224
288440
  "insideH",
288225
- "insideV"
288441
+ "insideV",
288442
+ "start",
288443
+ "end"
288226
288444
  ];
288227
288445
  const result = {};
288228
288446
  for (const side of sides) {
@@ -288240,7 +288458,7 @@ menclose::after {
288240
288458
  ...border,
288241
288459
  size: size$1
288242
288460
  } : border;
288243
- }, convertCellMarginsToPx = (margins) => {
288461
+ }, convertCellMarginsToPx = (margins, isRtlTable$1 = false) => {
288244
288462
  if (!margins || typeof margins !== "object")
288245
288463
  return;
288246
288464
  const spacing = {};
@@ -288253,8 +288471,8 @@ menclose::after {
288253
288471
  marginBottom: "bottom",
288254
288472
  marginLeft: "left",
288255
288473
  marginRight: "right",
288256
- marginStart: "left",
288257
- marginEnd: "right"
288474
+ marginStart: isRtlTable$1 ? "right" : "left",
288475
+ marginEnd: isRtlTable$1 ? "left" : "right"
288258
288476
  };
288259
288477
  Object.entries(margins).forEach(([key2, value]) => {
288260
288478
  const side = keyMap[key2];
@@ -288547,6 +288765,7 @@ menclose::after {
288547
288765
  return null;
288548
288766
  const cellAttrs = {};
288549
288767
  if (resolvedTcProps?.borders && typeof resolvedTcProps.borders === "object") {
288768
+ const resolvedBordersData = resolvedTcProps.borders;
288550
288769
  const resolvedBorders = {};
288551
288770
  for (const side of [
288552
288771
  "top",
@@ -288554,36 +288773,46 @@ menclose::after {
288554
288773
  "bottom",
288555
288774
  "left"
288556
288775
  ]) {
288557
- const spec = convertResolvedCellBorder(resolvedTcProps.borders[side]);
288776
+ const spec = convertResolvedCellBorder(resolvedBordersData[side]);
288558
288777
  if (spec)
288559
288778
  resolvedBorders[side] = spec;
288560
288779
  }
288780
+ if (resolvedBorders.left == null) {
288781
+ const spec = convertResolvedCellBorder(resolvedBordersData.start);
288782
+ if (spec)
288783
+ resolvedBorders.left = spec;
288784
+ }
288785
+ if (resolvedBorders.right == null) {
288786
+ const spec = convertResolvedCellBorder(resolvedBordersData.end);
288787
+ if (spec)
288788
+ resolvedBorders.right = spec;
288789
+ }
288561
288790
  if (Object.keys(resolvedBorders).length > 0)
288562
288791
  cellAttrs.borders = resolvedBorders;
288563
288792
  }
288564
288793
  if (!cellAttrs.borders && cellNode.attrs?.borders && typeof cellNode.attrs.borders === "object") {
288565
288794
  const legacy = cellNode.attrs.borders;
288566
- const fallback = {};
288795
+ const filteredLegacyBorders = {};
288567
288796
  for (const side of [
288568
288797
  "top",
288569
288798
  "right",
288570
288799
  "bottom",
288571
- "left"
288800
+ "left",
288801
+ "start",
288802
+ "end"
288572
288803
  ]) {
288573
288804
  const b$1 = legacy[side];
288574
- if (b$1 && b$1.val && typeof b$1.size === "number" && b$1.size > 0) {
288575
- const color2 = b$1.color ? b$1.color.startsWith("#") ? b$1.color : `#${b$1.color}` : "#000000";
288576
- fallback[side] = {
288577
- style: normalizeLegacyBorderStyle(b$1.val),
288578
- width: b$1.size,
288579
- color: color2
288805
+ if (b$1 && b$1.val && typeof b$1.size === "number" && b$1.size > 0)
288806
+ filteredLegacyBorders[side] = {
288807
+ ...b$1,
288808
+ val: normalizeLegacyBorderStyle(b$1.val)
288580
288809
  };
288581
- }
288582
288810
  }
288583
- if (Object.keys(fallback).length > 0)
288811
+ const fallback = extractCellBorders({ borders: filteredLegacyBorders }, { isRtl: tableProperties?.rightToLeft === true });
288812
+ if (fallback)
288584
288813
  cellAttrs.borders = fallback;
288585
288814
  }
288586
- const padding = extractCellPadding(cellNode.attrs ?? {}) ?? (defaultCellPadding ? { ...defaultCellPadding } : undefined);
288815
+ const padding = extractCellPadding(cellNode.attrs ?? {}, { isRtl: tableProperties?.rightToLeft === true }) ?? (defaultCellPadding ? { ...defaultCellPadding } : undefined);
288587
288816
  if (padding)
288588
288817
  cellAttrs.padding = padding;
288589
288818
  const verticalAlign = cellNode.attrs?.verticalAlign;
@@ -293729,12 +293958,12 @@ menclose::after {
293729
293958
  return;
293730
293959
  console.log(...args$1);
293731
293960
  }, 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;
293732
- var init_src_BiYFxw9u_es = __esm(() => {
293961
+ var init_src_OZOxpRA7_es = __esm(() => {
293733
293962
  init_rolldown_runtime_Bg48TavK_es();
293734
- init_SuperConverter_B1Huzhur_es();
293963
+ init_SuperConverter_5Idv4fhC_es();
293735
293964
  init_jszip_C49i9kUs_es();
293736
293965
  init_uuid_qzgm05fK_es();
293737
- init_create_headless_toolbar_B1ifCjiq_es();
293966
+ init_create_headless_toolbar_CEUTigkM_es();
293738
293967
  init_constants_DrU4EASo_es();
293739
293968
  init_dist_B8HfvhaK_es();
293740
293969
  init_unified_Dsuw2be5_es();
@@ -296496,6 +296725,7 @@ ${err.toString()}`);
296496
296725
  backspaceSkipEmptyRun: () => backspaceSkipEmptyRun,
296497
296726
  changeListLevel: () => changeListLevel,
296498
296727
  clearNodes: () => clearNodes,
296728
+ clearParagraphDirection: () => clearParagraphDirection,
296499
296729
  command: () => command,
296500
296730
  createParagraphNear: () => createParagraphNear$1,
296501
296731
  decreaseListIndent: () => decreaseListIndent,
@@ -296542,6 +296772,7 @@ ${err.toString()}`);
296542
296772
  setMark: () => setMark,
296543
296773
  setMeta: () => setMeta,
296544
296774
  setNode: () => setNode,
296775
+ setParagraphDirection: () => setParagraphDirection,
296545
296776
  setSectionHeaderFooterAtSelection: () => setSectionHeaderFooterAtSelection,
296546
296777
  setSectionPageMarginsAtSelection: () => setSectionPageMarginsAtSelection,
296547
296778
  setTextIndentation: () => setTextIndentation,
@@ -312705,6 +312936,10 @@ function print() { __p += __j.call(arguments, '') }
312705
312936
  numberedListLowerAlphaParen: list_lower_alpha_paren_solid_default,
312706
312937
  indentLeft: outdent_solid_default,
312707
312938
  indentRight: indent_solid_default,
312939
+ directionLtr: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M9 10v5h2V4h2v11h2V4h2V2H9C6.79 2 5 3.79 5 6s1.79 4 4 4zm12 8l-4-4v3H5v2h12v3l4-4z"/></svg>
312940
+ `,
312941
+ directionRtl: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M10 10v5h2V4h2v11h2V4h2V2h-8C7.79 2 6 3.79 6 6s1.79 4 4 4zm-2 7v-3l-4 4 4 4v-3h12v-2H8z"/></svg>
312942
+ `,
312708
312943
  pageBreak: file_half_dashed_solid_default,
312709
312944
  copyFormat: paint_roller_solid_default,
312710
312945
  clearFormatting: text_slash_solid_default,
@@ -314000,6 +314235,8 @@ function print() { __p += __j.call(arguments, '') }
314000
314235
  linkedStyles: "linked-style",
314001
314236
  indentleft: "indent-decrease",
314002
314237
  indentright: "indent-increase",
314238
+ directionLtr: "direction-ltr",
314239
+ directionRtl: "direction-rtl",
314003
314240
  clearFormatting: "clear-formatting",
314004
314241
  copyFormat: "copy-format"
314005
314242
  };
@@ -314990,7 +315227,7 @@ function print() { __p += __j.call(arguments, '') }
314990
315227
  emit("item-clicked");
314991
315228
  emit("command", {
314992
315229
  item,
314993
- argument
315230
+ argument: argument ?? item.argument?.value ?? null
314994
315231
  });
314995
315232
  };
314996
315233
  const handleToolbarButtonTextSubmit = (item, argument) => {
@@ -315281,7 +315518,7 @@ function print() { __p += __j.call(arguments, '') }
315281
315518
  }), 128))], 36);
315282
315519
  };
315283
315520
  }
315284
- }, [["__scopeId", "data-v-7dc120d3"]]);
315521
+ }, [["__scopeId", "data-v-223b4fea"]]);
315285
315522
  Toolbar_default = /* @__PURE__ */ __plugin_vue_export_helper_default({
315286
315523
  __name: "Toolbar",
315287
315524
  emits: [
@@ -315458,6 +315695,8 @@ function print() { __p += __j.call(arguments, '') }
315458
315695
  numberedList: "Numbered list",
315459
315696
  indentLeft: "Left indent",
315460
315697
  indentRight: "Right indent",
315698
+ directionLtr: "Left-to-right",
315699
+ directionRtl: "Right-to-left",
315461
315700
  zoom: "Zoom",
315462
315701
  undo: "Undo",
315463
315702
  redo: "Redo",
@@ -315871,7 +316110,7 @@ function print() { __p += __j.call(arguments, '') }
315871
316110
  this.#deactivateAll();
315872
316111
  return;
315873
316112
  }
315874
- this.toolbarItems.forEach((item) => {
316113
+ [...this.toolbarItems, ...this.overflowItems].forEach((item) => {
315875
316114
  item.resetDisabled();
315876
316115
  this.#applyHeadlessState(item);
315877
316116
  });
@@ -321784,7 +322023,7 @@ function print() { __p += __j.call(arguments, '') }
321784
322023
  const expandedRunsForBlock = expandRunsForInlineNewlines(block.runs);
321785
322024
  content3.lines.forEach((resolvedLine) => {
321786
322025
  const paragraphMarkLeftOffset = this.resolveResolvedListParagraphMarkOffset(resolvedLine.isListFirstLine ? resolvedMarker : undefined, fragment.markerTextWidth, resolvedLine.indentOffset);
321787
- const isRtl = block.attrs?.direction === "rtl";
322026
+ const isRtl = getParagraphInlineDirection(block.attrs) === "rtl";
321788
322027
  const lineEl = this.renderLine(block, resolvedLine.line, context, resolvedLine.availableWidth, resolvedLine.lineIndex, resolvedLine.skipJustify, expandedRunsForBlock, resolvedLine.resolvedListTextStartPx, resolvedLine.indentOffset, paragraphMarkLeftOffset);
321789
322028
  if (!resolvedLine.isListFirstLine) {
321790
322029
  if (resolvedLine.paddingLeftPx > 0)
@@ -321854,7 +322093,7 @@ function print() { __p += __j.call(arguments, '') }
321854
322093
  const paraIndent = block.attrs?.indent;
321855
322094
  const paraIndentLeft = paraIndent?.left ?? 0;
321856
322095
  const paraIndentRight = paraIndent?.right ?? 0;
321857
- const isRtl = block.attrs?.direction === "rtl";
322096
+ const isRtl = getParagraphInlineDirection(block.attrs) === "rtl";
321858
322097
  const { anchorIndentPx: paraMarkerAnchorIndent, firstLinePx: markerFirstLine, hangingPx: markerHanging } = resolveMarkerIndent(paraIndent, isRtl);
321859
322098
  const firstLineOffset = block.attrs?.suppressFirstLineIndent === true ? 0 : (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
321860
322099
  const expandedRunsForBlock = expandRunsForInlineNewlines(block.runs);
@@ -331765,11 +332004,11 @@ function print() { __p += __j.call(arguments, '') }
331765
332004
  ];
331766
332005
  });
331767
332006
 
331768
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-J9sjN7xC.es.js
332007
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-BGYHCZ5O.es.js
331769
332008
  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;
331770
- var init_create_super_doc_ui_J9sjN7xC_es = __esm(() => {
331771
- init_SuperConverter_B1Huzhur_es();
331772
- init_create_headless_toolbar_B1ifCjiq_es();
332009
+ var init_create_super_doc_ui_BGYHCZ5O_es = __esm(() => {
332010
+ init_SuperConverter_5Idv4fhC_es();
332011
+ init_create_headless_toolbar_CEUTigkM_es();
331773
332012
  MOD_ALIASES = new Set([
331774
332013
  "Mod",
331775
332014
  "Meta",
@@ -331811,16 +332050,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
331811
332050
 
331812
332051
  // ../../packages/superdoc/dist/super-editor.es.js
331813
332052
  var init_super_editor_es = __esm(() => {
331814
- init_src_BiYFxw9u_es();
331815
- init_SuperConverter_B1Huzhur_es();
332053
+ init_src_OZOxpRA7_es();
332054
+ init_SuperConverter_5Idv4fhC_es();
331816
332055
  init_jszip_C49i9kUs_es();
331817
332056
  init_xml_js_CqGKpaft_es();
331818
- init_create_headless_toolbar_B1ifCjiq_es();
332057
+ init_create_headless_toolbar_CEUTigkM_es();
331819
332058
  init_constants_DrU4EASo_es();
331820
332059
  init_dist_B8HfvhaK_es();
331821
332060
  init_unified_Dsuw2be5_es();
331822
332061
  init_DocxZipper_Dh4RtvcE_es();
331823
- init_create_super_doc_ui_J9sjN7xC_es();
332062
+ init_create_super_doc_ui_BGYHCZ5O_es();
331824
332063
  init_ui_CGB3qmy3_es();
331825
332064
  init_eventemitter3_UwU_CLPU_es();
331826
332065
  init_errors_C_DoKMoN_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.3.0-next.85",
3
+ "version": "0.3.0-next.87",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -19,9 +19,9 @@
19
19
  "@types/bun": "^1.3.8",
20
20
  "@types/node": "22.19.2",
21
21
  "typescript": "^5.9.2",
22
+ "@superdoc/super-editor": "0.0.1",
22
23
  "@superdoc/document-api": "0.0.1",
23
- "superdoc": "1.32.0",
24
- "@superdoc/super-editor": "0.0.1"
24
+ "superdoc": "1.32.0"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public"