@superdoc-dev/cli 0.8.0-next.85 → 0.8.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 +547 -153
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1065,7 +1065,7 @@ var init_inline_run_patch = __esm(() => {
1065
1065
  runAttribute("rtl", "boolean", "w:rtl", schemaBooleanOrNull()),
1066
1066
  runAttribute("cs", "boolean", "w:cs", schemaBooleanOrNull()),
1067
1067
  runAttribute("bCs", "boolean", "w:bCs", schemaBooleanOrNull(), "boldCs"),
1068
- runAttribute("iCs", "boolean", "w:iCs", schemaBooleanOrNull()),
1068
+ runAttribute("iCs", "boolean", "w:iCs", schemaBooleanOrNull(), "italicCs"),
1069
1069
  runAttribute("eastAsianLayout", "object", "w:eastAsianLayout", schemaObjectOrNull({
1070
1070
  id: { oneOf: [{ type: "string", minLength: 1 }, { type: "null" }] },
1071
1071
  combine: { oneOf: [{ type: "boolean" }, { type: "null" }] },
@@ -66095,7 +66095,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
66095
66095
  emptyOptions2 = {};
66096
66096
  });
66097
66097
 
66098
- // ../../packages/superdoc/dist/chunks/SuperConverter-C9I74vtg.es.js
66098
+ // ../../packages/superdoc/dist/chunks/SuperConverter-BecdrRIX.es.js
66099
66099
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
66100
66100
  const fieldValue = extension$1.config[field];
66101
66101
  if (typeof fieldValue === "function")
@@ -75746,6 +75746,10 @@ function decodeRPrFromMarks(marks) {
75746
75746
  case "italic":
75747
75747
  case "bold":
75748
75748
  runProperties[type] = mark.attrs.value !== "0" && mark.attrs.value !== false;
75749
+ if (type === "bold")
75750
+ runProperties.boldCs = runProperties.bold;
75751
+ else if (type === "italic")
75752
+ runProperties.italicCs = runProperties.italic;
75749
75753
  break;
75750
75754
  case "underline": {
75751
75755
  const { underlineType, underlineColor, underlineThemeColor, underlineThemeTint, underlineThemeShade } = mark.attrs;
@@ -75788,8 +75792,11 @@ function decodeRPrFromMarks(marks) {
75788
75792
  break;
75789
75793
  case "fontSize": {
75790
75794
  const points = parseFloat(value);
75791
- if (!isNaN(points))
75792
- runProperties.fontSize = points * 2;
75795
+ if (!isNaN(points)) {
75796
+ const halfPoints = points * 2;
75797
+ runProperties.fontSize = halfPoints;
75798
+ runProperties.fontSizeCs = halfPoints;
75799
+ }
75793
75800
  break;
75794
75801
  }
75795
75802
  case "letterSpacing": {
@@ -77013,6 +77020,18 @@ function handleDocPartObj(params3) {
77013
77020
  const sdtPr = node3.elements.find((el) => el.name === "w:sdtPr");
77014
77021
  const docPartGalleryType = sdtPr?.elements.find((el) => el.name === "w:docPartObj")?.elements.find((el) => el.name === "w:docPartGallery")?.attributes?.["w:val"] ?? null;
77015
77022
  const content$2 = node3?.elements.find((el) => el.name === "w:sdtContent");
77023
+ const isInsideParagraph = (params3.path || []).some((p) => p?.name === "w:p");
77024
+ const hasBlockChild = !!content$2?.elements?.some((el) => el?.name === "w:p" || el?.name === "w:tbl");
77025
+ if (isInsideParagraph && !hasBlockChild)
77026
+ return inlineDocPartHandler({
77027
+ ...params3,
77028
+ nodes: [content$2],
77029
+ extraParams: {
77030
+ ...params3.extraParams || {},
77031
+ sdtPr,
77032
+ docPartGalleryType
77033
+ }
77034
+ });
77016
77035
  return (validGalleryTypeMap[docPartGalleryType] || genericDocPartHandler)({
77017
77036
  ...params3,
77018
77037
  nodes: [content$2],
@@ -105388,11 +105407,17 @@ var isRegExp = (value) => {
105388
105407
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node3);
105389
105408
  const runTrackFormatMark = findTrackFormatMark(runNodeForExport.marks);
105390
105409
  const runAttrs = runNodeForExport.attrs || {};
105391
- const runProperties = runAttrs.runProperties || {};
105410
+ const rawRunProperties = runAttrs.runProperties || {};
105411
+ const runProperties = rawRunProperties?.italicCs == null && rawRunProperties?.iCs != null ? {
105412
+ ...rawRunProperties,
105413
+ italicCs: rawRunProperties.iCs
105414
+ } : rawRunProperties;
105392
105415
  const inlineKeys = runAttrs.runPropertiesInlineKeys;
105393
105416
  const styleKeys = runAttrs.runPropertiesStyleKeys;
105394
105417
  const overrideKeys = runAttrs.runPropertiesOverrideKeys;
105395
105418
  const candidateKeys = inlineKeys != null ? [...new Set([...inlineKeys || [], ...overrideKeys || []])] : Object.keys(runProperties);
105419
+ if (candidateKeys.includes("iCs") && !candidateKeys.includes("italicCs"))
105420
+ candidateKeys.push("italicCs");
105396
105421
  const shouldExport = (key) => (key in (runProperties || {})) && (!(Array.isArray(styleKeys) && styleKeys.includes(key)) || Array.isArray(overrideKeys) && overrideKeys.includes(key));
105397
105422
  const exportKeys = candidateKeys.filter(shouldExport);
105398
105423
  const runPropertiesToExport = exportKeys.length > 0 ? Object.fromEntries(exportKeys.map((k) => [k, runProperties[k]])) : {};
@@ -105810,6 +105835,27 @@ var isRegExp = (value) => {
105810
105835
  attrs,
105811
105836
  marks
105812
105837
  };
105838
+ }, inlineDocPartHandler = (params3) => {
105839
+ const node3 = params3.nodes[0];
105840
+ const translatedContent = params3.nodeListHandler.handler({
105841
+ ...params3,
105842
+ nodes: node3?.elements || [],
105843
+ path: [...params3.path || [], node3]
105844
+ });
105845
+ const sdtPr = params3.extraParams.sdtPr;
105846
+ const docPartGalleryType = params3.extraParams.docPartGalleryType;
105847
+ const id2 = sdtPr?.elements?.find((el) => el.name === "w:id")?.attributes?.["w:val"] || null;
105848
+ const docPartObj = sdtPr?.elements.find((el) => el.name === "w:docPartObj");
105849
+ return {
105850
+ type: "structuredContent",
105851
+ content: translatedContent,
105852
+ attrs: {
105853
+ id: id2,
105854
+ docPartGallery: docPartGalleryType ?? docPartObj?.elements?.find((el) => el.name === "w:docPartGallery")?.attributes?.["w:val"] ?? null,
105855
+ docPartUnique: docPartObj?.elements?.some((el) => el.name === "w:docPartUnique") ?? false,
105856
+ sdtPr
105857
+ }
105858
+ };
105813
105859
  }, tableOfContentsHandler = (params3) => {
105814
105860
  const node3 = params3.nodes[0];
105815
105861
  const normalizedContent = normalizeDocPartContent(translateTocSdtContent(node3, params3));
@@ -112919,7 +112965,7 @@ var isRegExp = (value) => {
112919
112965
  start: safeStart,
112920
112966
  end: safeEnd
112921
112967
  };
112922
- }, RUN_PROPERTIES_DERIVED_FROM_MARKS, TRANSIENT_HYPERLINK_STYLE_IDS, RUN_PROPERTY_PRESERVE_META_KEY = "sdPreserveRunPropertiesKeys", calculateInlineRunPropertiesPlugin = (editor) => new Plugin({ appendTransaction(transactions, _oldState, newState) {
112968
+ }, RUN_PROPERTIES_DERIVED_FROM_MARKS, TRANSIENT_HYPERLINK_STYLE_IDS, RUN_PROPERTY_PRESERVE_META_KEY = "sdPreserveRunPropertiesKeys", COMPANION_INLINE_KEYS, calculateInlineRunPropertiesPlugin = (editor) => new Plugin({ appendTransaction(transactions, _oldState, newState) {
112923
112969
  const tr = newState.tr;
112924
112970
  if (!transactions.some((t) => t.docChanged))
112925
112971
  return null;
@@ -112982,15 +113028,46 @@ var isRegExp = (value) => {
112982
113028
  const existingInlineKeys = runNode.attrs?.runPropertiesInlineKeys || [];
112983
113029
  const hadInlineKeysMetadata = Array.isArray(runNode.attrs?.runPropertiesInlineKeys);
112984
113030
  const styleKeys = runNode.attrs?.runPropertiesStyleKeys || [];
113031
+ const existingStyleComparableProps = resolveRunProperties({
113032
+ translatedNumbering: editor.converter?.translatedNumbering ?? {},
113033
+ translatedLinkedStyles: editor.converter?.translatedLinkedStyles ?? {}
113034
+ }, runNode.attrs?.runProperties?.styleId != null ? { styleId: runNode.attrs.runProperties.styleId } : {}, getResolvedParagraphProperties(paragraphNode) || calculateResolvedParagraphProperties(editor, paragraphNode, $pos), tableInfo, false, Boolean(paragraphNode.attrs.paragraphProperties?.numberingProperties));
112985
113035
  const keysFromMarks = (segment) => {
112986
113036
  const textNode = segment.content?.find((n) => n.isText);
112987
113037
  return Object.keys(decodeRPrFromMarks(textNode?.marks || []));
112988
113038
  };
112989
- const overrideKeysFromInlineProps = (inlineProps) => styleKeys.filter((k) => inlineProps && (k in inlineProps));
113039
+ const overrideKeysFromInlineProps = (inlineProps) => styleKeys.filter((k) => {
113040
+ if (!inlineProps || !(k in inlineProps))
113041
+ return false;
113042
+ if (!existingStyleComparableProps || !(k in existingStyleComparableProps))
113043
+ return true;
113044
+ return JSON.stringify(inlineProps[k]) !== JSON.stringify(existingStyleComparableProps[k]);
113045
+ });
112990
113046
  const existingRunPropsKeys = new Set(runNode.attrs?.runProperties ? Object.keys(runNode.attrs.runProperties) : []);
112991
113047
  const computeSegmentKeys = (segmentInlineProps, segment) => {
112992
- const hasNewInlineProps = segmentInlineProps != null && Object.keys(segmentInlineProps).some((k) => !existingRunPropsKeys.has(k));
112993
- const markKeysToAdd = !hadInlineKeysMetadata || existingInlineKeys.length > 0 || hasNewInlineProps ? keysFromMarks(segment) : [];
113048
+ const hasNewInlineProps = segmentInlineProps != null && Object.keys(segmentInlineProps).some((k) => {
113049
+ if (existingRunPropsKeys.has(k))
113050
+ return false;
113051
+ const baseKey = COMPANION_INLINE_KEYS[k];
113052
+ if (baseKey && existingRunPropsKeys.has(baseKey))
113053
+ return false;
113054
+ return true;
113055
+ });
113056
+ const hasChangedStyleComparableProps = segmentInlineProps != null && Object.keys(segmentInlineProps).some((k) => {
113057
+ if (!styleKeys.includes(k))
113058
+ return false;
113059
+ const current = segmentInlineProps[k];
113060
+ const fromStyle = existingStyleComparableProps?.[k];
113061
+ if (JSON.stringify(current) !== JSON.stringify(fromStyle))
113062
+ return true;
113063
+ const baseKey = COMPANION_INLINE_KEYS[k];
113064
+ if (!baseKey)
113065
+ return false;
113066
+ const currentBase = segmentInlineProps[baseKey];
113067
+ const styleBase = existingStyleComparableProps?.[baseKey];
113068
+ return JSON.stringify(currentBase) !== JSON.stringify(styleBase);
113069
+ });
113070
+ const markKeysToAdd = !hadInlineKeysMetadata || existingInlineKeys.length > 0 || hasNewInlineProps || hasChangedStyleComparableProps ? keysFromMarks(segment) : [];
112994
113071
  const keys$1 = [...new Set([...existingInlineKeys, ...markKeysToAdd])];
112995
113072
  const ok3 = overrideKeysFromInlineProps(segmentInlineProps);
112996
113073
  return {
@@ -119097,7 +119174,7 @@ var isRegExp = (value) => {
119097
119174
  state.kern = kernNode.attributes["w:val"];
119098
119175
  }
119099
119176
  }, SuperConverter;
119100
- var init_SuperConverter_C9I74vtg_es = __esm(() => {
119177
+ var init_SuperConverter_BecdrRIX_es = __esm(() => {
119101
119178
  init_rolldown_runtime_Bg48TavK_es();
119102
119179
  init_jszip_C49i9kUs_es();
119103
119180
  init_xml_js_CqGKpaft_es();
@@ -121767,7 +121844,7 @@ var init_SuperConverter_C9I74vtg_es = __esm(() => {
121767
121844
  runAttribute2("rtl", "boolean", "w:rtl", schemaBooleanOrNull2()),
121768
121845
  runAttribute2("cs", "boolean", "w:cs", schemaBooleanOrNull2()),
121769
121846
  runAttribute2("bCs", "boolean", "w:bCs", schemaBooleanOrNull2(), "boldCs"),
121770
- runAttribute2("iCs", "boolean", "w:iCs", schemaBooleanOrNull2()),
121847
+ runAttribute2("iCs", "boolean", "w:iCs", schemaBooleanOrNull2(), "italicCs"),
121771
121848
  runAttribute2("eastAsianLayout", "object", "w:eastAsianLayout", schemaObjectOrNull2({
121772
121849
  id: { oneOf: [{
121773
121850
  type: "string",
@@ -134545,7 +134622,7 @@ var init_SuperConverter_C9I74vtg_es = __esm(() => {
134545
134622
  });
134546
134623
  translator$134 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:rtl"));
134547
134624
  translator$56 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:cs"));
134548
- translator$78 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:iCs"));
134625
+ translator$78 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:iCs", "italicCs"));
134549
134626
  translator$196 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:webHidden"));
134550
134627
  translator$213 = NodeTranslator.from({
134551
134628
  xmlName: XML_NAME$4,
@@ -148364,18 +148441,26 @@ var init_SuperConverter_C9I74vtg_es = __esm(() => {
148364
148441
  RUN_PROPERTIES_DERIVED_FROM_MARKS = new Set([
148365
148442
  "strike",
148366
148443
  "italic",
148444
+ "italicCs",
148367
148445
  "bold",
148446
+ "boldCs",
148368
148447
  "underline",
148369
148448
  "highlight",
148370
148449
  "textTransform",
148371
148450
  "color",
148372
148451
  "fontSize",
148452
+ "fontSizeCs",
148373
148453
  "letterSpacing",
148374
148454
  "fontFamily",
148375
148455
  "vertAlign",
148376
148456
  "position"
148377
148457
  ]);
148378
148458
  TRANSIENT_HYPERLINK_STYLE_IDS = new Set(["Hyperlink", "FollowedHyperlink"]);
148459
+ COMPANION_INLINE_KEYS = {
148460
+ fontSizeCs: "fontSize",
148461
+ boldCs: "bold",
148462
+ italicCs: "italic"
148463
+ };
148379
148464
  init_dist4();
148380
148465
  DEFAULT_ALLOWED_PROTOCOLS = [
148381
148466
  "http",
@@ -156957,7 +157042,7 @@ var init_SuperConverter_C9I74vtg_es = __esm(() => {
156957
157042
  };
156958
157043
  });
156959
157044
 
156960
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-B7nufamW.es.js
157045
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DCeIAH_W.es.js
156961
157046
  function parseSizeUnit(val = "0") {
156962
157047
  const length3 = val.toString() || "0";
156963
157048
  const value = Number.parseFloat(length3);
@@ -159624,8 +159709,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
159624
159709
  }
159625
159710
  };
159626
159711
  };
159627
- var init_create_headless_toolbar_B7nufamW_es = __esm(() => {
159628
- init_SuperConverter_C9I74vtg_es();
159712
+ var init_create_headless_toolbar_DCeIAH_W_es = __esm(() => {
159713
+ init_SuperConverter_BecdrRIX_es();
159629
159714
  init_constants_DrU4EASo_es();
159630
159715
  init_dist_B8HfvhaK_es();
159631
159716
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
@@ -208322,7 +208407,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
208322
208407
  init_remark_gfm_BhnWr3yf_es();
208323
208408
  });
208324
208409
 
208325
- // ../../packages/superdoc/dist/chunks/src-BE-DiVIy.es.js
208410
+ // ../../packages/superdoc/dist/chunks/src-AOxYjda5.es.js
208326
208411
  function deleteProps(obj, propOrProps) {
208327
208412
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
208328
208413
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -211625,6 +211710,24 @@ function calcTabHeight(blockParent2) {
211625
211710
  const parentTextStyleMark = blockParent2.firstChild?.marks?.find((mark2) => mark2.type.name === "textStyle");
211626
211711
  return `${(parseInt(parentTextStyleMark?.attrs.fontSize) * ptToPxRatio || defaultFontSize) * defaultLineHeight}px`;
211627
211712
  }
211713
+ function inferParagraphRtlFromRuns(node3) {
211714
+ const fragment2 = node3?.content;
211715
+ if (!fragment2 || !fragment2.childCount)
211716
+ return false;
211717
+ let hasExplicitRtl = false;
211718
+ for (let i4 = 0;i4 < fragment2.childCount; i4++) {
211719
+ const child = fragment2.child(i4);
211720
+ if (child.type.name !== "run")
211721
+ continue;
211722
+ const runProperties = child.attrs?.runProperties || {};
211723
+ const isRtl = runProperties.rightToLeft === true || runProperties.rtl === true;
211724
+ if (runProperties.rightToLeft === false || runProperties.rtl === false)
211725
+ return false;
211726
+ if (isRtl)
211727
+ hasExplicitRtl = true;
211728
+ }
211729
+ return hasExplicitRtl;
211730
+ }
211628
211731
  function createNumberingManager() {
211629
211732
  let countersMap = {};
211630
211733
  let abstractCountersMap = {};
@@ -212247,6 +212350,7 @@ function parseCssLength(value) {
212247
212350
  function parseAttrs(node3) {
212248
212351
  const numberingProperties = {};
212249
212352
  let indent2, spacing, justification;
212353
+ let rightToLeft;
212250
212354
  let sectionProperties = null;
212251
212355
  let pageBreakSource = null;
212252
212356
  const { styleid: styleId, ...extraAttrs } = Array.from(node3.attributes).reduce((acc, attr) => {
@@ -212279,7 +212383,12 @@ function parseAttrs(node3) {
212279
212383
  } catch {}
212280
212384
  else if (attr.name === "data-sd-page-break-source")
212281
212385
  pageBreakSource = attr.value || null;
212282
- else
212386
+ else if (attr.name === "dir") {
212387
+ if (attr.value === "rtl")
212388
+ rightToLeft = true;
212389
+ else if (attr.value === "ltr")
212390
+ rightToLeft = false;
212391
+ } else
212283
212392
  acc[attr.name] = attr.value;
212284
212393
  return acc;
212285
212394
  }, {});
@@ -212309,6 +212418,12 @@ function parseAttrs(node3) {
212309
212418
  const ml = parseCssLength(node3.style.marginLeft);
212310
212419
  if (ml && ml.unit !== "%" && ml.points >= 0)
212311
212420
  cssIndent.left = Math.round(ml.points * 20);
212421
+ const mis = parseCssLength(node3.style.marginInlineStart);
212422
+ if (mis && mis.unit !== "%" && mis.points >= 0)
212423
+ cssIndent.start = Math.round(mis.points * 20);
212424
+ const mie = parseCssLength(node3.style.marginInlineEnd);
212425
+ if (mie && mie.unit !== "%" && mie.points >= 0)
212426
+ cssIndent.end = Math.round(mie.points * 20);
212312
212427
  const ti = parseCssLength(node3.style.textIndent);
212313
212428
  if (ti && ti.unit !== "%")
212314
212429
  if (ti.points >= 0)
@@ -212323,6 +212438,12 @@ function parseAttrs(node3) {
212323
212438
  if (textAlign && CSS_ALIGN_TO_OOXML[textAlign])
212324
212439
  justification = CSS_ALIGN_TO_OOXML[textAlign];
212325
212440
  }
212441
+ if (rightToLeft == null && node3.style) {
212442
+ if (node3.style.direction === "rtl")
212443
+ rightToLeft = true;
212444
+ else if (node3.style.direction === "ltr")
212445
+ rightToLeft = false;
212446
+ }
212326
212447
  let attrs = {
212327
212448
  paragraphProperties: { styleId: styleId || null },
212328
212449
  extraAttrs
@@ -212333,6 +212454,8 @@ function parseAttrs(node3) {
212333
212454
  attrs.paragraphProperties.spacing = spacing;
212334
212455
  if (justification)
212335
212456
  attrs.paragraphProperties.justification = justification;
212457
+ if (rightToLeft != null)
212458
+ attrs.paragraphProperties.rightToLeft = rightToLeft;
212336
212459
  if (Object.keys(numberingProperties).length > 0)
212337
212460
  attrs.paragraphProperties.numberingProperties = numberingProperties;
212338
212461
  if (sectionProperties)
@@ -217237,6 +217360,21 @@ function getCurrentCoords(editor, selection) {
217237
217360
  y: layoutSpaceCoords.y
217238
217361
  };
217239
217362
  }
217363
+ function resolveLineBoundaryPosition(editor, selection, key2) {
217364
+ const coords = getCurrentCoords(editor, selection);
217365
+ if (!coords)
217366
+ return null;
217367
+ const doc$12 = editor.presentationEditor?.visibleHost?.ownerDocument ?? document;
217368
+ const caretX = coords.clientX;
217369
+ const lineEl = findLineElementAtPoint(doc$12, caretX, coords.clientY + coords.height / 2);
217370
+ if (!lineEl)
217371
+ return null;
217372
+ const pmStart = Number(lineEl.dataset?.pmStart);
217373
+ const pmEnd = Number(lineEl.dataset?.pmEnd);
217374
+ if (!Number.isFinite(pmStart) || !Number.isFinite(pmEnd))
217375
+ return null;
217376
+ return key2 === "Home" ? pmStart : pmEnd;
217377
+ }
217240
217378
  function getAdjacentLineClientTarget(editor, coords, direction) {
217241
217379
  const doc$12 = editor.presentationEditor.visibleHost?.ownerDocument ?? document;
217242
217380
  const caretX = coords.clientX;
@@ -251538,6 +251676,15 @@ function isMinimalWordLayout(value) {
251538
251676
  }
251539
251677
  return true;
251540
251678
  }
251679
+ function resolveMarkerIndent(indent2, isRtl) {
251680
+ const left$1 = indent2?.left ?? 0;
251681
+ const right$1 = indent2?.right ?? 0;
251682
+ return {
251683
+ anchorIndentPx: isRtl ? right$1 : left$1,
251684
+ firstLinePx: isRtl ? -(indent2?.firstLine ?? 0) : indent2?.firstLine ?? 0,
251685
+ hangingPx: isRtl ? -(indent2?.hanging ?? 0) : indent2?.hanging ?? 0
251686
+ };
251687
+ }
251541
251688
  function computeTabWidth(currentPos, justification, tabs, hangingIndent, firstLineIndent, leftIndent) {
251542
251689
  const nextDefaultTabStop = currentPos + 48 - currentPos % 48;
251543
251690
  let tabWidth;
@@ -252586,17 +252733,18 @@ function resolveParagraphContent(fragment2, block, measure) {
252586
252733
  const paraIndent = block.attrs?.indent;
252587
252734
  const paraIndentLeft = paraIndent?.left ?? 0;
252588
252735
  const paraIndentRight = paraIndent?.right ?? 0;
252736
+ const { anchorIndentPx: paraMarkerAnchorIndent, firstLinePx: markerFirstLine, hangingPx: markerHanging } = resolveMarkerIndent(paraIndent, block.attrs?.direction === "rtl");
252589
252737
  const firstLineOffset = block.attrs?.suppressFirstLineIndent === true ? 0 : (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
252590
252738
  const paragraphEndsWithLineBreak = (block.runs.length > 0 ? block.runs[block.runs.length - 1] : null)?.kind === "lineBreak";
252591
252739
  const lines = fragment2.lines ?? measure.lines.slice(fragment2.fromLine, fragment2.toLine);
252592
252740
  const hasMarker = !fragment2.continuesFromPrev && fragment2.markerWidth && wordLayout?.marker;
252593
- const listFirstLineTextStartPx = hasMarker ? resolverListTextStartPx(wordLayout, paraIndentLeft, paraIndent?.hanging ?? 0, paraIndent?.firstLine ?? 0, fragment2.markerTextWidth) : undefined;
252594
- const listFirstLineMarkerGeometry = !fragment2.continuesFromPrev && fragment2.markerWidth && wordLayout?.marker?.justification === "left" && wordLayout.firstLineIndentMode !== true && typeof fragment2.markerTextWidth === "number" && Number.isFinite(fragment2.markerTextWidth) && fragment2.markerTextWidth >= 0 ? resolverListMarkerGeometry(wordLayout, paraIndentLeft, paraIndent?.hanging ?? 0, paraIndent?.firstLine ?? 0, fragment2.markerTextWidth) : undefined;
252741
+ const listFirstLineTextStartPx = hasMarker ? resolverListTextStartPx(wordLayout, paraMarkerAnchorIndent, markerHanging, markerFirstLine, fragment2.markerTextWidth) : undefined;
252742
+ const listFirstLineMarkerGeometry = !fragment2.continuesFromPrev && fragment2.markerWidth && wordLayout?.marker?.justification === "left" && wordLayout.firstLineIndentMode !== true && typeof fragment2.markerTextWidth === "number" && Number.isFinite(fragment2.markerTextWidth) && fragment2.markerTextWidth >= 0 ? resolverListMarkerGeometry(wordLayout, paraMarkerAnchorIndent, markerHanging, markerFirstLine, fragment2.markerTextWidth) : undefined;
252595
252743
  let listTabWidth = 0;
252596
252744
  let markerStartPos = 0;
252597
252745
  if (hasMarker) {
252598
252746
  const markerTextWidth = fragment2.markerTextWidth;
252599
- const anchorPoint = paraIndentLeft - (paraIndent?.hanging ?? 0) + (paraIndent?.firstLine ?? 0);
252747
+ const anchorPoint = paraMarkerAnchorIndent - markerHanging + markerFirstLine;
252600
252748
  const markerJustification = wordLayout.marker.justification ?? "left";
252601
252749
  let currentPos;
252602
252750
  if (markerJustification === "left") {
@@ -252613,7 +252761,7 @@ function resolveParagraphContent(fragment2, block, measure) {
252613
252761
  if (listFirstLineMarkerGeometry && (suffix === "tab" || suffix === "space"))
252614
252762
  listTabWidth = listFirstLineMarkerGeometry.suffixWidthPx;
252615
252763
  else if (suffix === "tab")
252616
- listTabWidth = computeTabWidth(currentPos, markerJustification, wordLayout.tabsPx, paraIndent?.hanging, paraIndent?.firstLine, paraIndentLeft);
252764
+ listTabWidth = computeTabWidth(currentPos, markerJustification, wordLayout.tabsPx, markerHanging, markerFirstLine, paraMarkerAnchorIndent);
252617
252765
  else if (suffix === "space")
252618
252766
  listTabWidth = 4;
252619
252767
  }
@@ -252621,7 +252769,7 @@ function resolveParagraphContent(fragment2, block, measure) {
252621
252769
  if (hasMarker) {
252622
252770
  const m$1 = wordLayout.marker;
252623
252771
  const justification = m$1.justification ?? "left";
252624
- const firstLinePaddingLeftPx = paraIndentLeft + (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
252772
+ const firstLinePaddingLeftPx = paraMarkerAnchorIndent - markerHanging + markerFirstLine;
252625
252773
  let centerPaddingAdjustPx;
252626
252774
  if (justification === "center")
252627
252775
  centerPaddingAdjustPx = fragment2.markerTextWidth / 2;
@@ -255983,26 +256131,26 @@ function resolvePageNumberTokens(layout, blocks2, measures, numberingCtx) {
255983
256131
  continue;
255984
256132
  }
255985
256133
  const displayPageText = displayPageInfo.displayText;
255986
- for (const fragment2 of page.fragments) {
255987
- if (fragment2.kind !== "para")
255988
- continue;
255989
- const blockId = fragment2.blockId;
255990
- if (processedBlocks.has(blockId))
255991
- continue;
255992
- if (blockHasTokensFlags.get(blockId) === false)
255993
- continue;
255994
- const block = blockMap.get(blockId);
255995
- if (!block || block.kind !== "paragraph")
255996
- continue;
255997
- if (!hasPageTokens$1(block)) {
256134
+ for (const fragment2 of page.fragments)
256135
+ if (fragment2.kind === "para") {
256136
+ const blockId = fragment2.blockId;
256137
+ if (processedBlocks.has(blockId))
256138
+ continue;
256139
+ if (blockHasTokensFlags.get(blockId) === false)
256140
+ continue;
256141
+ const block = blockMap.get(blockId);
256142
+ if (!block || block.kind !== "paragraph")
256143
+ continue;
256144
+ if (!hasPageTokens$1(block)) {
256145
+ processedBlocks.add(blockId);
256146
+ continue;
256147
+ }
256148
+ const clonedBlock = cloneBlockWithResolvedTokens(block, displayPageText, totalPagesStr);
256149
+ updatedBlocks.set(blockId, clonedBlock);
256150
+ affectedBlockIds.add(blockId);
255998
256151
  processedBlocks.add(blockId);
255999
256152
  continue;
256000
256153
  }
256001
- const clonedBlock = cloneBlockWithResolvedTokens(block, displayPageText, totalPagesStr);
256002
- updatedBlocks.set(blockId, clonedBlock);
256003
- affectedBlockIds.add(blockId);
256004
- processedBlocks.add(blockId);
256005
- }
256006
256154
  }
256007
256155
  return {
256008
256156
  affectedBlockIds,
@@ -258099,6 +258247,20 @@ function isBorderSpec(value) {
258099
258247
  function hasComments$1(run2) {
258100
258248
  return "comments" in run2 && Array.isArray(run2.comments) && run2.comments.length > 0;
258101
258249
  }
258250
+ function forEachParagraphBlock(blocks2, visit2) {
258251
+ for (const block of blocks2)
258252
+ if (block.kind === "paragraph")
258253
+ visit2(block);
258254
+ else if (block.kind === "table") {
258255
+ const table2 = block;
258256
+ for (const row2 of table2.rows ?? [])
258257
+ for (const cell2 of row2.cells ?? [])
258258
+ if (cell2.blocks && cell2.blocks.length > 0)
258259
+ forEachParagraphBlock(cell2.blocks, visit2);
258260
+ else if (cell2.paragraph)
258261
+ forEachParagraphBlock([cell2.paragraph], visit2);
258262
+ }
258263
+ }
258102
258264
  function resolveHeaderFooterTokens(blocks2, pageNumber, totalPages, pageNumberText) {
258103
258265
  if (!blocks2 || blocks2.length === 0)
258104
258266
  return;
@@ -258112,10 +258274,7 @@ function resolveHeaderFooterTokens(blocks2, pageNumber, totalPages, pageNumberTe
258112
258274
  }
258113
258275
  const pageNumberStr = pageNumberText ?? String(pageNumber);
258114
258276
  const totalPagesStr = String(totalPages);
258115
- for (const block of blocks2) {
258116
- if (block.kind !== "paragraph")
258117
- continue;
258118
- const paraBlock = block;
258277
+ forEachParagraphBlock(blocks2, (paraBlock) => {
258119
258278
  for (const run2 of paraBlock.runs)
258120
258279
  if ("token" in run2 && run2.token) {
258121
258280
  if (run2.token === "pageNumber")
@@ -258123,22 +258282,37 @@ function resolveHeaderFooterTokens(blocks2, pageNumber, totalPages, pageNumberTe
258123
258282
  else if (run2.token === "totalPageCount")
258124
258283
  run2.text = totalPagesStr;
258125
258284
  }
258126
- }
258285
+ });
258127
258286
  }
258128
258287
  function cloneHeaderFooterBlocks(blocks2) {
258129
258288
  if (!blocks2 || blocks2.length === 0)
258130
258289
  return [];
258131
- return blocks2.map((block) => {
258132
- if (block.kind === "paragraph") {
258133
- const paraBlock = block;
258134
- return {
258135
- ...paraBlock,
258136
- runs: paraBlock.runs.map((run2) => ({ ...run2 })),
258137
- attrs: paraBlock.attrs ? { ...paraBlock.attrs } : undefined
258138
- };
258139
- }
258140
- return { ...block };
258141
- });
258290
+ return blocks2.map(cloneHeaderFooterBlock);
258291
+ }
258292
+ function cloneHeaderFooterBlock(block) {
258293
+ if (block.kind === "paragraph") {
258294
+ const paraBlock = block;
258295
+ return {
258296
+ ...paraBlock,
258297
+ runs: paraBlock.runs.map((run2) => ({ ...run2 })),
258298
+ attrs: paraBlock.attrs ? { ...paraBlock.attrs } : undefined
258299
+ };
258300
+ }
258301
+ if (block.kind === "table") {
258302
+ const table2 = block;
258303
+ return {
258304
+ ...table2,
258305
+ rows: (table2.rows ?? []).map((row2) => ({
258306
+ ...row2,
258307
+ cells: (row2.cells ?? []).map((cell2) => ({
258308
+ ...cell2,
258309
+ paragraph: cell2.paragraph ? cloneHeaderFooterBlock(cell2.paragraph) : cell2.paragraph,
258310
+ blocks: cell2.blocks ? cell2.blocks.map(cloneHeaderFooterBlock) : cell2.blocks
258311
+ }))
258312
+ }))
258313
+ };
258314
+ }
258315
+ return { ...block };
258142
258316
  }
258143
258317
  function isEnabled(envVar, defaultValue) {
258144
258318
  if (typeof process$1 === "undefined" || typeof process$1.env === "undefined")
@@ -258171,14 +258345,24 @@ function getBucketRepresentative(bucket) {
258171
258345
  return 5000;
258172
258346
  }
258173
258347
  }
258348
+ function paragraphHasPageToken(para) {
258349
+ for (const run2 of para.runs)
258350
+ if ("token" in run2 && (run2.token === "pageNumber" || run2.token === "totalPageCount"))
258351
+ return true;
258352
+ return false;
258353
+ }
258174
258354
  function hasPageTokens(blocks2) {
258175
- for (const block of blocks2) {
258176
- if (block.kind !== "paragraph")
258177
- continue;
258178
- for (const run2 of block.runs)
258179
- if ("token" in run2 && (run2.token === "pageNumber" || run2.token === "totalPageCount"))
258355
+ for (const block of blocks2)
258356
+ if (block.kind === "paragraph") {
258357
+ if (paragraphHasPageToken(block))
258180
258358
  return true;
258181
- }
258359
+ } else if (block.kind === "table") {
258360
+ const table2 = block;
258361
+ for (const row2 of table2.rows ?? [])
258362
+ for (const cell2 of row2.cells ?? [])
258363
+ if (hasPageTokens(cell2.blocks ? cell2.blocks : cell2.paragraph ? [cell2.paragraph] : []))
258364
+ return true;
258365
+ }
258182
258366
  return false;
258183
258367
  }
258184
258368
  async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1, cache$2 = sharedHeaderFooterCache, totalPages, pageResolver, kind) {
@@ -263256,7 +263440,7 @@ function handleStructuredContentBlockNode(node3, context) {
263256
263440
  const { blocks: blocks2, recordBlockKind, nextBlockId, positions, trackedChangesConfig, bookmarks, hyperlinkConfig, converters: converters$1, converterContext, enableComments, themeColors } = context;
263257
263441
  const structuredContentMetadata = resolveNodeSdtMetadata(node3, "structuredContentBlock");
263258
263442
  const paragraphToFlowBlocks$1 = converters$1.paragraphToFlowBlocks;
263259
- node3.content.forEach((child) => {
263443
+ const visitChild = (child) => {
263260
263444
  if (child.type === "paragraph") {
263261
263445
  const paragraphBlocks = paragraphToFlowBlocks$1({
263262
263446
  para: child,
@@ -263275,7 +263459,9 @@ function handleStructuredContentBlockNode(node3, context) {
263275
263459
  blocks2.push(block);
263276
263460
  recordBlockKind?.(block.kind);
263277
263461
  });
263278
- } else if (child.type === "table") {
263462
+ return;
263463
+ }
263464
+ if (child.type === "table") {
263279
263465
  const tableNodeToBlock$1 = converters$1?.tableNodeToBlock;
263280
263466
  if (tableNodeToBlock$1) {
263281
263467
  const tableBlock = tableNodeToBlock$1(child, {
@@ -263295,8 +263481,12 @@ function handleStructuredContentBlockNode(node3, context) {
263295
263481
  recordBlockKind?.(tableBlock.kind);
263296
263482
  }
263297
263483
  }
263484
+ return;
263298
263485
  }
263299
- });
263486
+ if (child.type === "documentPartObject" && Array.isArray(child.content))
263487
+ child.content.forEach(visitChild);
263488
+ };
263489
+ node3.content.forEach(visitChild);
263300
263490
  }
263301
263491
  function processParagraphChild(child, sectionMetadata, context, output, converters$1) {
263302
263492
  const paragraphBlocks = converters$1.paragraphToFlowBlocks({
@@ -264720,6 +264910,20 @@ function handleTableNode(node3, context) {
264720
264910
  recordBlockKind?.(tableBlock.kind);
264721
264911
  }
264722
264912
  }
264913
+ function resolveSectionDirectionFromSectPr$1(sectPr) {
264914
+ if (!sectPr || typeof sectPr !== "object")
264915
+ return;
264916
+ const elements = sectPr.elements;
264917
+ if (!Array.isArray(elements))
264918
+ return;
264919
+ const bidi = elements.find((element3) => element3?.name === "w:bidi");
264920
+ if (!bidi)
264921
+ return;
264922
+ const val = bidi.attributes?.["w:val"] ?? bidi.attributes?.val;
264923
+ if (val === "0" || val === 0 || val === false || val === "false" || val === "off")
264924
+ return "ltr";
264925
+ return "rtl";
264926
+ }
264723
264927
  function sourceAnchorFromNode(node3) {
264724
264928
  const sourceAnchor = node3.attrs?.sourceAnchor;
264725
264929
  return sourceAnchor && typeof sourceAnchor === "object" && !Array.isArray(sourceAnchor) ? sourceAnchor : undefined;
@@ -265045,6 +265249,7 @@ function handleParagraphNode2(node3, context) {
265045
265249
  blocks2.push(sectionBreak);
265046
265250
  recordBlockKind?.(sectionBreak.kind);
265047
265251
  sectionState.currentSectionIndex++;
265252
+ converterContext.sectionDirection = resolveSectionDirectionFromSectPr$1(nextSection.sectPr);
265048
265253
  }
265049
265254
  }
265050
265255
  const paragraphToFlowBlocks$1 = converters$1.paragraphToFlowBlocks;
@@ -265141,6 +265346,20 @@ function handleMathBlockNode(node3, context) {
265141
265346
  blocks2.push(block);
265142
265347
  recordBlockKind?.(block.kind);
265143
265348
  }
265349
+ function resolveSectionDirectionFromSectPr(sectPr) {
265350
+ if (!sectPr || typeof sectPr !== "object")
265351
+ return;
265352
+ const elements = sectPr.elements;
265353
+ if (!Array.isArray(elements))
265354
+ return;
265355
+ const bidi = elements.find((element3) => element3?.name === "w:bidi");
265356
+ if (!bidi)
265357
+ return;
265358
+ const val = bidi.attributes?.["w:val"] ?? bidi.attributes?.val;
265359
+ if (val === "0" || val === 0 || val === false || val === "false" || val === "off")
265360
+ return "ltr";
265361
+ return "rtl";
265362
+ }
265144
265363
  function toFlowBlocks(pmDoc, options) {
265145
265364
  const defaultFont = options?.defaultFont ?? DEFAULT_FONT;
265146
265365
  const defaultSize = options?.defaultSize ?? DEFAULT_SIZE2;
@@ -265178,6 +265397,7 @@ function toFlowBlocks(pmDoc, options) {
265178
265397
  };
265179
265398
  const bodySectionProps = doc$12.attrs?.bodySectPr ?? doc$12.attrs?.sectPr;
265180
265399
  const sectionRanges = options?.emitSectionBreaks ? analyzeSectionRanges(doc$12, bodySectionProps) : [];
265400
+ converterContext.sectionDirection = converterContext.sectionDirection ?? resolveSectionDirectionFromSectPr(sectionRanges[0]?.sectPr ?? bodySectionProps);
265181
265401
  publishSectionMetadata(sectionRanges, options);
265182
265402
  if (sectionRanges.length > 0 && sectionRanges[0]) {
265183
265403
  const sectionBreak = createSectionBreakBlock(sectionRanges[0], nextBlockId, { isFirstSection: true });
@@ -266622,8 +266842,10 @@ function computeCaretLayoutRectGeometry({ layout, blocks: blocks2, measures, pai
266622
266842
  hangingIndent: indent2.hanging,
266623
266843
  wordLayout
266624
266844
  });
266625
- const charX = measureCharacterX(block, line, pmOffset, Math.max(0, fragment2.width - (indentAdjust + indent2.right)));
266626
- const localX = fragment2.x + indentAdjust + charX;
266845
+ const availableWidth = Math.max(0, fragment2.width - (indentAdjust + indent2.right));
266846
+ const charX = measureCharacterX(block, line, pmOffset, availableWidth);
266847
+ const resolvedCharX = block.attrs?.direction === "rtl" ? Math.max(0, availableWidth - charX) : charX;
266848
+ const localX = fragment2.x + indentAdjust + resolvedCharX;
266627
266849
  const lineOffset = lineHeightBeforeIndex(measure.lines, fragment2.fromLine, index2);
266628
266850
  const localY = fragment2.y + lineOffset;
266629
266851
  const result = {
@@ -276065,7 +276287,7 @@ var Node$13 = class Node$14 {
276065
276287
  this.dom.classList.remove("sd-editor-dropcap");
276066
276288
  if (paragraphProperties.styleId)
276067
276289
  this.dom.setAttribute("styleid", paragraphProperties.styleId);
276068
- if (paragraphProperties.rightToLeft)
276290
+ if (paragraphProperties.rightToLeft === true || paragraphProperties.rightToLeft !== false && inferParagraphRtlFromRuns(this.node))
276069
276291
  this.dom.setAttribute("dir", "rtl");
276070
276292
  else
276071
276293
  this.dom.removeAttribute("dir");
@@ -289389,7 +289611,7 @@ menclose::after {
289389
289611
  y$1 += actualRowHeight + cellSpacingPx;
289390
289612
  }
289391
289613
  return container;
289392
- }, isRtlParagraph = (attrs) => attrs?.direction === "rtl" || attrs?.rtl === true, resolveTextAlign = (alignment$1, isRtl) => {
289614
+ }, isRtlParagraph = (attrs) => attrs?.direction === "rtl", resolveTextAlign = (alignment$1, isRtl) => {
289393
289615
  switch (alignment$1) {
289394
289616
  case "center":
289395
289617
  case "right":
@@ -289404,6 +289626,9 @@ menclose::after {
289404
289626
  if (rtl) {
289405
289627
  element3.setAttribute("dir", "rtl");
289406
289628
  element3.style.direction = "rtl";
289629
+ } else {
289630
+ element3.removeAttribute("dir");
289631
+ element3.style.direction = "";
289407
289632
  }
289408
289633
  element3.style.textAlign = resolveTextAlign(attrs?.alignment, rtl);
289409
289634
  return rtl;
@@ -290706,7 +290931,6 @@ menclose::after {
290706
290931
  attrs.shading?.fill ?? "",
290707
290932
  attrs.shading?.color ?? "",
290708
290933
  attrs.direction ?? "",
290709
- attrs.rtl ? "1" : "",
290710
290934
  attrs.tabs?.length ? JSON.stringify(attrs.tabs) : ""
290711
290935
  ].join(":") : "";
290712
290936
  const sdtAttrs = block.attrs?.sdt;
@@ -290835,7 +291059,6 @@ menclose::after {
290835
291059
  hash$3 = hashString(hash$3, attrs.shading?.fill ?? "");
290836
291060
  hash$3 = hashString(hash$3, attrs.shading?.color ?? "");
290837
291061
  hash$3 = hashString(hash$3, attrs.direction ?? "");
290838
- hash$3 = hashString(hash$3, attrs.rtl ? "1" : "");
290839
291062
  if (attrs.borders)
290840
291063
  hash$3 = hashString(hash$3, hashParagraphBorders$1(attrs.borders));
290841
291064
  }
@@ -291549,8 +291772,6 @@ menclose::after {
291549
291772
  }
291550
291773
  if (attrs.direction)
291551
291774
  parts.push(`dir:${attrs.direction}`);
291552
- if (attrs.rtl)
291553
- parts.push("rtl");
291554
291775
  if (parts.length > 0)
291555
291776
  cellHashes.push(`pa:${parts.join(":")}`);
291556
291777
  }
@@ -291658,8 +291879,6 @@ menclose::after {
291658
291879
  }
291659
291880
  if (attrs.direction)
291660
291881
  parts.push(`dir:${attrs.direction}`);
291661
- if (attrs.rtl)
291662
- parts.push("rtl");
291663
291882
  if (attrs.keepNext)
291664
291883
  parts.push("kn");
291665
291884
  if (attrs.keepLines)
@@ -292391,7 +292610,7 @@ menclose::after {
292391
292610
  return true;
292392
292611
  if (!a2 || !b$1)
292393
292612
  return !a2 && !b$1;
292394
- if (a2.alignment !== b$1.alignment || a2.contextualSpacing !== b$1.contextualSpacing || a2.suppressFirstLineIndent !== b$1.suppressFirstLineIndent || a2.dropCap !== b$1.dropCap || a2.decimalSeparator !== b$1.decimalSeparator || a2.tabIntervalTwips !== b$1.tabIntervalTwips || a2.keepNext !== b$1.keepNext || a2.keepLines !== b$1.keepLines || a2.direction !== b$1.direction || a2.rtl !== b$1.rtl || a2.floatAlignment !== b$1.floatAlignment)
292613
+ if (a2.alignment !== b$1.alignment || a2.contextualSpacing !== b$1.contextualSpacing || a2.suppressFirstLineIndent !== b$1.suppressFirstLineIndent || a2.dropCap !== b$1.dropCap || a2.decimalSeparator !== b$1.decimalSeparator || a2.tabIntervalTwips !== b$1.tabIntervalTwips || a2.keepNext !== b$1.keepNext || a2.keepLines !== b$1.keepLines || a2.direction !== b$1.direction || a2.floatAlignment !== b$1.floatAlignment)
292395
292614
  return false;
292396
292615
  if (!paragraphSpacingEqual(a2.spacing, b$1.spacing))
292397
292616
  return false;
@@ -293322,8 +293541,6 @@ menclose::after {
293322
293541
  const directionAttr = attrs.direction ?? attrs.dir ?? attrs.textDirection;
293323
293542
  if (typeof directionAttr === "string" && directionAttr.toLowerCase() === "rtl")
293324
293543
  return true;
293325
- if (typeof attrs.rtl === "boolean")
293326
- return attrs.rtl;
293327
293544
  return false;
293328
293545
  }, determineColumn = (layout, fragmentX) => {
293329
293546
  const columns = layout.columns;
@@ -294555,6 +294772,26 @@ menclose::after {
294555
294772
  default:
294556
294773
  return;
294557
294774
  }
294775
+ }, mirrorIndentForRtl = (indent2) => {
294776
+ const mirrored = {};
294777
+ let mutated = false;
294778
+ if (indent2.right != null) {
294779
+ mirrored.left = indent2.right;
294780
+ mutated = true;
294781
+ }
294782
+ if (indent2.left != null) {
294783
+ mirrored.right = indent2.left;
294784
+ mutated = true;
294785
+ }
294786
+ if (indent2.firstLine != null) {
294787
+ mirrored.firstLine = -indent2.firstLine;
294788
+ mutated = true;
294789
+ }
294790
+ if (indent2.hanging != null) {
294791
+ mirrored.hanging = -indent2.hanging;
294792
+ mutated = true;
294793
+ }
294794
+ return mutated ? mirrored : indent2;
294558
294795
  }, DEFAULT_DECIMAL_SEPARATOR$1 = ".", DEFAULT_TAB_INTERVAL_TWIPS$1 = 720, normalizeColor$1 = (value) => {
294559
294796
  if (typeof value !== "string")
294560
294797
  return;
@@ -294572,6 +294809,37 @@ menclose::after {
294572
294809
  if (Object.prototype.hasOwnProperty.call(obj, key2))
294573
294810
  clone[key2] = deepClone3(obj[key2]);
294574
294811
  return clone;
294812
+ }, inferDirectionFromRuns = (para) => {
294813
+ const content3 = Array.isArray(para.content) ? para.content : [];
294814
+ let hasExplicitRtl = false;
294815
+ let hasExplicitLtr = false;
294816
+ for (const node3 of content3) {
294817
+ if (node3?.type !== "run")
294818
+ continue;
294819
+ const runProps = node3.attrs?.runProperties ?? {};
294820
+ const runDirection = runProps.rightToLeft ?? runProps.rtl;
294821
+ if (runDirection === true) {
294822
+ hasExplicitRtl = true;
294823
+ continue;
294824
+ }
294825
+ if (runDirection === false)
294826
+ hasExplicitLtr = true;
294827
+ }
294828
+ if (!hasExplicitRtl && !hasExplicitLtr)
294829
+ return;
294830
+ if (hasExplicitLtr)
294831
+ return;
294832
+ return "rtl";
294833
+ }, resolveEffectiveParagraphDirection = (para, resolvedParagraphProperties, _sectionDirection, docDefaultsDirection) => {
294834
+ if (resolvedParagraphProperties.rightToLeft === true)
294835
+ return "rtl";
294836
+ if (resolvedParagraphProperties.rightToLeft === false)
294837
+ return "ltr";
294838
+ const inferredFromRuns = inferDirectionFromRuns(para);
294839
+ if (inferredFromRuns)
294840
+ return inferredFromRuns;
294841
+ if (docDefaultsDirection)
294842
+ return docDefaultsDirection;
294575
294843
  }, normalizeIndentTwipsToPx = (indent2) => {
294576
294844
  if (!indent2)
294577
294845
  return;
@@ -294595,6 +294863,18 @@ menclose::after {
294595
294863
  if (hanging != null)
294596
294864
  result.hanging = twipsToPx$1(hanging);
294597
294865
  return Object.keys(result).length > 0 ? result : undefined;
294866
+ }, resolveLogicalIndentToPhysical = (indent2, _direction) => {
294867
+ if (!indent2)
294868
+ return;
294869
+ const resolved = { ...indent2 };
294870
+ const source = indent2;
294871
+ if (source.start != null)
294872
+ resolved.left = source.start;
294873
+ if (source.end != null)
294874
+ resolved.right = source.end;
294875
+ delete resolved.start;
294876
+ delete resolved.end;
294877
+ return resolved;
294598
294878
  }, normalizeFramePr = (value) => {
294599
294879
  if (!value)
294600
294880
  return;
@@ -294682,9 +294962,11 @@ menclose::after {
294682
294962
  resolvedParagraphProperties = paragraphProperties;
294683
294963
  else
294684
294964
  resolvedParagraphProperties = resolveParagraphProperties(converterContext, paragraphProperties, converterContext.tableInfo);
294685
- const isRtl = resolvedParagraphProperties.rightToLeft === true;
294965
+ const normalizedDirection = resolveEffectiveParagraphDirection(para, resolvedParagraphProperties, converterContext?.sectionDirection, converterContext?.translatedLinkedStyles?.docDefaults?.paragraphProperties?.rightToLeft === true ? "rtl" : converterContext?.translatedLinkedStyles?.docDefaults?.paragraphProperties?.rightToLeft === false ? "ltr" : undefined);
294966
+ const isRtl = normalizedDirection === "rtl";
294686
294967
  const normalizedSpacing = normalizeParagraphSpacing(resolvedParagraphProperties.spacing, Boolean(resolvedParagraphProperties.numberingProperties));
294687
- const normalizedIndent = normalizeIndentTwipsToPx(resolvedParagraphProperties.indent);
294968
+ const normalizedIndentBase = normalizeIndentTwipsToPx(resolveLogicalIndentToPhysical(resolvedParagraphProperties.indent, normalizedDirection));
294969
+ const normalizedIndent = isRtl && normalizedIndentBase ? mirrorIndentForRtl(normalizedIndentBase) : normalizedIndentBase;
294688
294970
  const normalizedTabStops = normalizeOoxmlTabs(resolvedParagraphProperties.tabStops);
294689
294971
  const normalizedAlignment = normalizeAlignment(resolvedParagraphProperties.justification, isRtl);
294690
294972
  const normalizedBorders = normalizeParagraphBorders(resolvedParagraphProperties.borders);
@@ -294692,7 +294974,6 @@ menclose::after {
294692
294974
  const paragraphDecimalSeparator = DEFAULT_DECIMAL_SEPARATOR$1;
294693
294975
  const tabIntervalTwips = DEFAULT_TAB_INTERVAL_TWIPS$1;
294694
294976
  const normalizedFramePr = normalizeFramePr(resolvedParagraphProperties.framePr);
294695
- const normalizedDirection = resolvedParagraphProperties.rightToLeft === true ? "rtl" : resolvedParagraphProperties.rightToLeft === false ? "ltr" : undefined;
294696
294977
  const floatAlignment = normalizedFramePr?.xAlign;
294697
294978
  const normalizedNumberingProperties = normalizeNumberingProperties(resolvedParagraphProperties.numberingProperties);
294698
294979
  const dropCapDescriptor = normalizeDropCap(resolvedParagraphProperties.framePr, para, converterContext);
@@ -294715,10 +294996,7 @@ menclose::after {
294715
294996
  keepLines: resolvedParagraphProperties.keepLines,
294716
294997
  floatAlignment,
294717
294998
  pageBreakBefore: resolvedParagraphProperties.pageBreakBefore,
294718
- ...normalizedDirection ? {
294719
- direction: normalizedDirection,
294720
- rtl: isRtl
294721
- } : {}
294999
+ ...normalizedDirection ? { direction: normalizedDirection } : {}
294722
295000
  };
294723
295001
  if (normalizedNumberingProperties && normalizedListRendering) {
294724
295002
  const markerRunAttrs = computeRunAttrs(resolveRunProperties(converterContext, resolvedParagraphProperties.runProperties, resolvedParagraphProperties, converterContext.tableInfo, true, Boolean(paragraphProperties.numberingProperties)), converterContext);
@@ -296061,6 +296339,58 @@ menclose::after {
296061
296339
  blocks2.push(block);
296062
296340
  });
296063
296341
  };
296342
+ const flattenSdtWrappersIntoCell = (wrapperNode, inheritedSdtMetadata) => {
296343
+ if (!Array.isArray(wrapperNode.content))
296344
+ return;
296345
+ for (const nestedNode of wrapperNode.content) {
296346
+ if (nestedNode.type === "paragraph") {
296347
+ if (!paragraphToFlowBlocks$1)
296348
+ continue;
296349
+ appendParagraphBlocks(paragraphToFlowBlocks$1({
296350
+ para: nestedNode,
296351
+ nextBlockId: context.nextBlockId,
296352
+ positions: context.positions,
296353
+ storyKey: context.storyKey,
296354
+ trackedChangesConfig: context.trackedChangesConfig,
296355
+ bookmarks: context.bookmarks,
296356
+ hyperlinkConfig: context.hyperlinkConfig,
296357
+ themeColors: context.themeColors,
296358
+ converterContext: cellConverterContext,
296359
+ converters: context.converters,
296360
+ enableComments: context.enableComments
296361
+ }), inheritedSdtMetadata);
296362
+ continue;
296363
+ }
296364
+ if (nestedNode.type === "table" && tableNodeToBlock$1) {
296365
+ const tableBlock = tableNodeToBlock$1(nestedNode, {
296366
+ nextBlockId: context.nextBlockId,
296367
+ positions: context.positions,
296368
+ storyKey: context.storyKey,
296369
+ trackedChangesConfig: context.trackedChangesConfig,
296370
+ bookmarks: context.bookmarks,
296371
+ hyperlinkConfig: context.hyperlinkConfig,
296372
+ themeColors: context.themeColors,
296373
+ converterContext: context.converterContext,
296374
+ converters: context.converters,
296375
+ enableComments: context.enableComments
296376
+ });
296377
+ if (tableBlock && tableBlock.kind === "table") {
296378
+ if (inheritedSdtMetadata)
296379
+ applySdtMetadataToTableBlock(tableBlock, inheritedSdtMetadata);
296380
+ blocks2.push(tableBlock);
296381
+ }
296382
+ continue;
296383
+ }
296384
+ if (nestedNode.type === "documentPartObject") {
296385
+ flattenSdtWrappersIntoCell(nestedNode, inheritedSdtMetadata);
296386
+ continue;
296387
+ }
296388
+ if (nestedNode.type === "structuredContentBlock") {
296389
+ flattenSdtWrappersIntoCell(nestedNode, inheritedSdtMetadata ?? resolveNodeSdtMetadata(nestedNode, "structuredContentBlock"));
296390
+ continue;
296391
+ }
296392
+ }
296393
+ };
296064
296394
  for (const childNode of cellNode.content) {
296065
296395
  if (childNode.type === "paragraph") {
296066
296396
  if (!paragraphToFlowBlocks$1)
@@ -296081,46 +296411,7 @@ menclose::after {
296081
296411
  continue;
296082
296412
  }
296083
296413
  if (childNode.type === "structuredContentBlock" && Array.isArray(childNode.content)) {
296084
- const structuredContentMetadata = resolveNodeSdtMetadata(childNode, "structuredContentBlock");
296085
- for (const nestedNode of childNode.content) {
296086
- if (nestedNode.type === "paragraph") {
296087
- if (!paragraphToFlowBlocks$1)
296088
- continue;
296089
- appendParagraphBlocks(paragraphToFlowBlocks$1({
296090
- para: nestedNode,
296091
- nextBlockId: context.nextBlockId,
296092
- positions: context.positions,
296093
- storyKey: context.storyKey,
296094
- trackedChangesConfig: context.trackedChangesConfig,
296095
- bookmarks: context.bookmarks,
296096
- hyperlinkConfig: context.hyperlinkConfig,
296097
- themeColors: context.themeColors,
296098
- converterContext: cellConverterContext,
296099
- converters: context.converters,
296100
- enableComments: context.enableComments
296101
- }), structuredContentMetadata);
296102
- continue;
296103
- }
296104
- if (nestedNode.type === "table" && tableNodeToBlock$1) {
296105
- const tableBlock = tableNodeToBlock$1(nestedNode, {
296106
- nextBlockId: context.nextBlockId,
296107
- positions: context.positions,
296108
- storyKey: context.storyKey,
296109
- trackedChangesConfig: context.trackedChangesConfig,
296110
- bookmarks: context.bookmarks,
296111
- hyperlinkConfig: context.hyperlinkConfig,
296112
- themeColors: context.themeColors,
296113
- converterContext: context.converterContext,
296114
- converters: context.converters,
296115
- enableComments: context.enableComments
296116
- });
296117
- if (tableBlock && tableBlock.kind === "table") {
296118
- applySdtMetadataToTableBlock(tableBlock, structuredContentMetadata);
296119
- blocks2.push(tableBlock);
296120
- }
296121
- continue;
296122
- }
296123
- }
296414
+ flattenSdtWrappersIntoCell(childNode, resolveNodeSdtMetadata(childNode, "structuredContentBlock"));
296124
296415
  continue;
296125
296416
  }
296126
296417
  if (childNode.type === "table" && tableNodeToBlock$1) {
@@ -296140,6 +296431,10 @@ menclose::after {
296140
296431
  blocks2.push(tableBlock);
296141
296432
  continue;
296142
296433
  }
296434
+ if (childNode.type === "documentPartObject" && Array.isArray(childNode.content)) {
296435
+ flattenSdtWrappersIntoCell(childNode, undefined);
296436
+ continue;
296437
+ }
296143
296438
  if (childNode.type === "image" && context.converters?.imageNodeToBlock) {
296144
296439
  const mergedMarks = [...childNode.marks ?? []];
296145
296440
  const trackedMeta = context.trackedChangesConfig ? collectTrackedChangeFromMarks(mergedMarks, context.storyKey) : undefined;
@@ -301355,12 +301650,12 @@ menclose::after {
301355
301650
  return;
301356
301651
  console.log(...args$1);
301357
301652
  }, 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;
301358
- var init_src_BE_DiVIy_es = __esm(() => {
301653
+ var init_src_AOxYjda5_es = __esm(() => {
301359
301654
  init_rolldown_runtime_Bg48TavK_es();
301360
- init_SuperConverter_C9I74vtg_es();
301655
+ init_SuperConverter_BecdrRIX_es();
301361
301656
  init_jszip_C49i9kUs_es();
301362
301657
  init_uuid_qzgm05fK_es();
301363
- init_create_headless_toolbar_B7nufamW_es();
301658
+ init_create_headless_toolbar_DCeIAH_W_es();
301364
301659
  init_constants_DrU4EASo_es();
301365
301660
  init_dist_B8HfvhaK_es();
301366
301661
  init_unified_Dsuw2be5_es();
@@ -319655,10 +319950,25 @@ function print() { __p += __j.call(arguments, '') }
319655
319950
  handleKeyDown(view, event) {
319656
319951
  if (view.composing || !editor.isEditable)
319657
319952
  return false;
319658
- if (event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") {
319953
+ if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
319659
319954
  view.dispatch(view.state.tr.setMeta(VerticalNavigationPluginKey, { type: "reset-goal-x" }));
319660
319955
  return false;
319661
319956
  }
319957
+ if (event.key === "Home" || event.key === "End") {
319958
+ view.dispatch(view.state.tr.setMeta(VerticalNavigationPluginKey, { type: "reset-goal-x" }));
319959
+ if (!isPresenting(editor))
319960
+ return false;
319961
+ if (event.ctrlKey || event.metaKey || event.altKey)
319962
+ return false;
319963
+ const targetPos = resolveLineBoundaryPosition(editor, view.state.selection, event.key);
319964
+ if (!Number.isFinite(targetPos))
319965
+ return false;
319966
+ const selection$1 = buildSelection(view.state, targetPos, event.shiftKey);
319967
+ if (!selection$1)
319968
+ return false;
319969
+ view.dispatch(view.state.tr.setSelection(selection$1));
319970
+ return true;
319971
+ }
319662
319972
  if (event.key === "PageUp" || event.key === "PageDown") {
319663
319973
  view.dispatch(view.state.tr.setMeta(VerticalNavigationPluginKey, { type: "reset-goal-x" }));
319664
319974
  return false;
@@ -329256,6 +329566,7 @@ function print() { __p += __j.call(arguments, '') }
329256
329566
  const expandedRunsForBlock = expandRunsForInlineNewlines(block.runs);
329257
329567
  content3.lines.forEach((resolvedLine) => {
329258
329568
  const paragraphMarkLeftOffset = this.resolveResolvedListParagraphMarkOffset(resolvedLine.isListFirstLine ? resolvedMarker : undefined, fragment2.markerTextWidth, resolvedLine.indentOffset);
329569
+ const isRtl = block.attrs?.direction === "rtl";
329259
329570
  const lineEl = this.renderLine(block, resolvedLine.line, context, resolvedLine.availableWidth, resolvedLine.lineIndex, resolvedLine.skipJustify, expandedRunsForBlock, resolvedLine.resolvedListTextStartPx, resolvedLine.indentOffset, paragraphMarkLeftOffset);
329260
329571
  if (!resolvedLine.isListFirstLine) {
329261
329572
  if (resolvedLine.paddingLeftPx > 0)
@@ -329271,17 +329582,28 @@ function print() { __p += __j.call(arguments, '') }
329271
329582
  if (resolvedLine.paddingRightPx > 0)
329272
329583
  lineEl.style.paddingRight = `${resolvedLine.paddingRightPx}px`;
329273
329584
  if (resolvedLine.isListFirstLine && resolvedMarker) {
329274
- lineEl.style.paddingLeft = `${resolvedMarker.firstLinePaddingLeftPx}px`;
329585
+ if (isRtl)
329586
+ lineEl.style.paddingRight = `${resolvedMarker.firstLinePaddingLeftPx}px`;
329587
+ else
329588
+ lineEl.style.paddingLeft = `${resolvedMarker.firstLinePaddingLeftPx}px`;
329275
329589
  if (!resolvedMarker.vanish) {
329276
329590
  const markerContainer = createListMarkerElement(this.doc, resolvedMarker.text, resolvedMarker.run, resolvedMarker.sourceAnchor ?? resolvedItem?.sourceAnchor);
329277
329591
  markerContainer.style.position = "relative";
329278
329592
  if (resolvedMarker.justification === "right") {
329279
329593
  markerContainer.style.position = "absolute";
329280
- markerContainer.style.left = `${resolvedMarker.markerStartPx}px`;
329594
+ if (isRtl)
329595
+ markerContainer.style.right = `${resolvedMarker.markerStartPx}px`;
329596
+ else
329597
+ markerContainer.style.left = `${resolvedMarker.markerStartPx}px`;
329281
329598
  } else if (resolvedMarker.justification === "center") {
329282
329599
  markerContainer.style.position = "absolute";
329283
- markerContainer.style.left = `${resolvedMarker.markerStartPx - (resolvedMarker.centerPaddingAdjustPx ?? 0)}px`;
329284
- lineEl.style.paddingLeft = parseFloat(lineEl.style.paddingLeft) + (resolvedMarker.centerPaddingAdjustPx ?? 0) + "px";
329600
+ if (isRtl) {
329601
+ markerContainer.style.right = `${resolvedMarker.markerStartPx - (resolvedMarker.centerPaddingAdjustPx ?? 0)}px`;
329602
+ lineEl.style.paddingRight = (parseFloat(lineEl.style.paddingRight || "0") + (resolvedMarker.centerPaddingAdjustPx ?? 0)).toString() + "px";
329603
+ } else {
329604
+ markerContainer.style.left = `${resolvedMarker.markerStartPx - (resolvedMarker.centerPaddingAdjustPx ?? 0)}px`;
329605
+ lineEl.style.paddingLeft = parseFloat(lineEl.style.paddingLeft) + (resolvedMarker.centerPaddingAdjustPx ?? 0) + "px";
329606
+ }
329285
329607
  }
329286
329608
  if (resolvedMarker.suffix === "tab") {
329287
329609
  const tabEl = this.doc.createElement("span");
@@ -329314,28 +329636,30 @@ function print() { __p += __j.call(arguments, '') }
329314
329636
  const paraIndent = block.attrs?.indent;
329315
329637
  const paraIndentLeft = paraIndent?.left ?? 0;
329316
329638
  const paraIndentRight = paraIndent?.right ?? 0;
329639
+ const isRtl = block.attrs?.direction === "rtl";
329640
+ const { anchorIndentPx: paraMarkerAnchorIndent, firstLinePx: markerFirstLine, hangingPx: markerHanging } = resolveMarkerIndent(paraIndent, isRtl);
329317
329641
  const firstLineOffset = block.attrs?.suppressFirstLineIndent === true ? 0 : (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
329318
329642
  const expandedRunsForBlock = expandRunsForInlineNewlines(block.runs);
329319
329643
  const paragraphEndsWithLineBreak = (block.runs.length > 0 ? block.runs[block.runs.length - 1] : null)?.kind === "lineBreak";
329320
329644
  const listFirstLineTextStartPx = !paraContinuesFromPrev && paraMarkerWidth && wordLayout?.marker ? resolvePainterListTextStartPx({
329321
329645
  wordLayout,
329322
- indentLeftPx: paraIndentLeft,
329323
- hangingIndentPx: paraIndent?.hanging ?? 0,
329324
- firstLineIndentPx: paraIndent?.firstLine ?? 0,
329646
+ indentLeftPx: paraMarkerAnchorIndent,
329647
+ hangingIndentPx: markerHanging,
329648
+ firstLineIndentPx: markerFirstLine,
329325
329649
  markerTextWidthPx: fragment2.markerTextWidth
329326
329650
  }) : undefined;
329327
329651
  const listFirstLineMarkerGeometry = !paraContinuesFromPrev && paraMarkerWidth && wordLayout?.marker?.justification === "left" && wordLayout.firstLineIndentMode !== true && typeof fragment2.markerTextWidth === "number" && Number.isFinite(fragment2.markerTextWidth) && fragment2.markerTextWidth >= 0 ? resolvePainterListMarkerGeometry({
329328
329652
  wordLayout,
329329
- indentLeftPx: paraIndentLeft,
329330
- hangingIndentPx: paraIndent?.hanging ?? 0,
329331
- firstLineIndentPx: paraIndent?.firstLine ?? 0,
329653
+ indentLeftPx: paraMarkerAnchorIndent,
329654
+ hangingIndentPx: markerHanging,
329655
+ firstLineIndentPx: markerFirstLine,
329332
329656
  markerTextWidthPx: fragment2.markerTextWidth
329333
329657
  }) : undefined;
329334
329658
  let listTabWidth = 0;
329335
329659
  let markerStartPos = 0;
329336
329660
  if (!paraContinuesFromPrev && paraMarkerWidth && wordLayout?.marker) {
329337
329661
  const markerTextWidth = fragment2.markerTextWidth;
329338
- const anchorPoint = paraIndentLeft - (paraIndent?.hanging ?? 0) + (paraIndent?.firstLine ?? 0);
329662
+ const anchorPoint = paraMarkerAnchorIndent - markerHanging + markerFirstLine;
329339
329663
  const markerJustification = wordLayout.marker.justification ?? "left";
329340
329664
  let currentPos;
329341
329665
  if (markerJustification === "left") {
@@ -329352,7 +329676,7 @@ function print() { __p += __j.call(arguments, '') }
329352
329676
  if (listFirstLineMarkerGeometry && (suffix === "tab" || suffix === "space"))
329353
329677
  listTabWidth = listFirstLineMarkerGeometry.suffixWidthPx;
329354
329678
  else if (suffix === "tab")
329355
- listTabWidth = computeTabWidth(currentPos, markerJustification, wordLayout.tabsPx, paraIndent?.hanging, paraIndent?.firstLine, paraIndentLeft);
329679
+ listTabWidth = computeTabWidth(currentPos, markerJustification, wordLayout.tabsPx, markerHanging, markerFirstLine, paraMarkerAnchorIndent);
329356
329680
  else if (suffix === "space")
329357
329681
  listTabWidth = 4;
329358
329682
  }
@@ -329394,18 +329718,30 @@ function print() { __p += __j.call(arguments, '') }
329394
329718
  const marker = wordLayout?.marker;
329395
329719
  if (!marker)
329396
329720
  return;
329397
- lineEl.style.paddingLeft = `${paraIndentLeft + (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0)}px`;
329721
+ const firstLineIndent = paraMarkerAnchorIndent - markerHanging + markerFirstLine;
329722
+ if (isRtl)
329723
+ lineEl.style.paddingRight = `${firstLineIndent}px`;
329724
+ else
329725
+ lineEl.style.paddingLeft = `${firstLineIndent}px`;
329398
329726
  if (!marker.run.vanish) {
329399
329727
  const markerContainer = createListMarkerElement(this.doc, marker.markerText ?? "", marker.run, block.sourceAnchor ?? resolvedItem?.sourceAnchor);
329400
329728
  const markerJustification = marker.justification ?? "left";
329401
329729
  markerContainer.style.position = "relative";
329402
329730
  if (markerJustification === "right") {
329403
329731
  markerContainer.style.position = "absolute";
329404
- markerContainer.style.left = `${markerStartPos}px`;
329732
+ if (isRtl)
329733
+ markerContainer.style.right = `${markerStartPos}px`;
329734
+ else
329735
+ markerContainer.style.left = `${markerStartPos}px`;
329405
329736
  } else if (markerJustification === "center") {
329406
329737
  markerContainer.style.position = "absolute";
329407
- markerContainer.style.left = `${markerStartPos - fragment2.markerTextWidth / 2}px`;
329408
- lineEl.style.paddingLeft = parseFloat(lineEl.style.paddingLeft) + fragment2.markerTextWidth / 2 + "px";
329738
+ if (isRtl) {
329739
+ markerContainer.style.right = `${markerStartPos - fragment2.markerTextWidth / 2}px`;
329740
+ lineEl.style.paddingRight = (parseFloat(lineEl.style.paddingRight || "0") + fragment2.markerTextWidth / 2).toString() + "px";
329741
+ } else {
329742
+ markerContainer.style.left = `${markerStartPos - fragment2.markerTextWidth / 2}px`;
329743
+ lineEl.style.paddingLeft = parseFloat(lineEl.style.paddingLeft) + fragment2.markerTextWidth / 2 + "px";
329744
+ }
329409
329745
  }
329410
329746
  const suffix = marker.suffix ?? "tab";
329411
329747
  if (suffix === "tab") {
@@ -334506,7 +334842,8 @@ function print() { __p += __j.call(arguments, '') }
334506
334842
  x: localX,
334507
334843
  y: localY
334508
334844
  };
334509
- const hit = clickToPositionGeometry(context.layout, context.blocks, context.measures, headerPoint) ?? null;
334845
+ const geometryHit = clickToPositionGeometry(context.layout, context.blocks, context.measures, headerPoint) ?? null;
334846
+ const hit = this.#resolveHeaderFooterDomHit(context, clientX, clientY) ?? geometryHit;
334510
334847
  if (!hit)
334511
334848
  return null;
334512
334849
  const doc$2 = this.getActiveEditor().state?.doc;
@@ -337585,6 +337922,63 @@ function print() { __p += __j.call(arguments, '') }
337585
337922
  lineIndex: -1
337586
337923
  };
337587
337924
  }
337925
+ #resolveHeaderFooterDomHit(context, clientX, clientY) {
337926
+ const layout = this.#layoutState.layout;
337927
+ if (!layout)
337928
+ return null;
337929
+ const blockIds = new Set(context.blocks.map((block) => block.id).filter((id2) => typeof id2 === "string" && id2.length > 0));
337930
+ if (blockIds.size === 0)
337931
+ return null;
337932
+ const doc$12 = this.#viewportHost.ownerDocument ?? document;
337933
+ const elementsFromPoint = typeof doc$12.elementsFromPoint === "function" ? doc$12.elementsFromPoint.bind(doc$12) : null;
337934
+ const tryResolve = (element3, enforceKnownBlockIds = true) => {
337935
+ const fragmentElement = element3 instanceof HTMLElement ? element3.closest("[data-block-id]") : null;
337936
+ const blockId = fragmentElement?.getAttribute("data-block-id") ?? "";
337937
+ if (!fragmentElement)
337938
+ return null;
337939
+ if (enforceKnownBlockIds && !blockIds.has(blockId))
337940
+ return null;
337941
+ const pos = resolvePositionWithinFragmentDom(fragmentElement, clientX, clientY);
337942
+ if (pos == null)
337943
+ return null;
337944
+ return {
337945
+ pos,
337946
+ layoutEpoch: readLayoutEpochFromDom(fragmentElement, clientX, clientY) ?? layout.layoutEpoch ?? 0,
337947
+ blockId,
337948
+ pageIndex: this.#resolveRenderedPageIndexForElement(fragmentElement),
337949
+ column: 0,
337950
+ lineIndex: -1
337951
+ };
337952
+ };
337953
+ if (elementsFromPoint) {
337954
+ for (const element3 of elementsFromPoint(clientX, clientY)) {
337955
+ const hit = tryResolve(element3, true);
337956
+ if (hit)
337957
+ return hit;
337958
+ }
337959
+ for (const element3 of elementsFromPoint(clientX, clientY)) {
337960
+ if (!element3.closest(".superdoc-page-header, .superdoc-page-footer"))
337961
+ continue;
337962
+ const hit = tryResolve(element3, false);
337963
+ if (hit)
337964
+ return hit;
337965
+ }
337966
+ }
337967
+ const surfaceSelector = context.region.kind === "footer" ? ".superdoc-page-footer" : ".superdoc-page-header";
337968
+ const surface = getPageElementByIndex(this.#viewportHost, context.region.pageIndex)?.querySelector(surfaceSelector) ?? null;
337969
+ if (surface instanceof HTMLElement) {
337970
+ const fragments = Array.from(surface.querySelectorAll(".superdoc-fragment"));
337971
+ for (const fragment2 of fragments) {
337972
+ const rect = fragment2.getBoundingClientRect();
337973
+ if (clientX < rect.left || clientX > rect.right || clientY < rect.top || clientY > rect.bottom)
337974
+ continue;
337975
+ const hit = tryResolve(fragment2, false);
337976
+ if (hit)
337977
+ return hit;
337978
+ }
337979
+ }
337980
+ return null;
337981
+ }
337588
337982
  #createCollapsedSelectionNearInlineContent(doc$12, pos) {
337589
337983
  const clampedPos = Math.max(0, Math.min(pos, doc$12.content.size));
337590
337984
  const directSelection = TextSelection.create(doc$12, clampedPos);
@@ -339104,11 +339498,11 @@ function print() { __p += __j.call(arguments, '') }
339104
339498
  ];
339105
339499
  });
339106
339500
 
339107
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-CmG_8rWP.es.js
339501
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-fxrCn5X_.es.js
339108
339502
  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;
339109
- var init_create_super_doc_ui_CmG_8rWP_es = __esm(() => {
339110
- init_SuperConverter_C9I74vtg_es();
339111
- init_create_headless_toolbar_B7nufamW_es();
339503
+ var init_create_super_doc_ui_fxrCn5X__es = __esm(() => {
339504
+ init_SuperConverter_BecdrRIX_es();
339505
+ init_create_headless_toolbar_DCeIAH_W_es();
339112
339506
  MOD_ALIASES = new Set([
339113
339507
  "Mod",
339114
339508
  "Meta",
@@ -339150,16 +339544,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
339150
339544
 
339151
339545
  // ../../packages/superdoc/dist/super-editor.es.js
339152
339546
  var init_super_editor_es = __esm(() => {
339153
- init_src_BE_DiVIy_es();
339154
- init_SuperConverter_C9I74vtg_es();
339547
+ init_src_AOxYjda5_es();
339548
+ init_SuperConverter_BecdrRIX_es();
339155
339549
  init_jszip_C49i9kUs_es();
339156
339550
  init_xml_js_CqGKpaft_es();
339157
- init_create_headless_toolbar_B7nufamW_es();
339551
+ init_create_headless_toolbar_DCeIAH_W_es();
339158
339552
  init_constants_DrU4EASo_es();
339159
339553
  init_dist_B8HfvhaK_es();
339160
339554
  init_unified_Dsuw2be5_es();
339161
339555
  init_DocxZipper_Dh4RtvcE_es();
339162
- init_create_super_doc_ui_CmG_8rWP_es();
339556
+ init_create_super_doc_ui_fxrCn5X__es();
339163
339557
  init_ui_CGB3qmy3_es();
339164
339558
  init_eventemitter3_UwU_CLPU_es();
339165
339559
  init_errors_C_DoKMoN_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.8.0-next.85",
3
+ "version": "0.8.0-next.87",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -34,11 +34,11 @@
34
34
  "access": "public"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@superdoc-dev/cli-darwin-arm64": "0.8.0-next.85",
38
- "@superdoc-dev/cli-darwin-x64": "0.8.0-next.85",
39
- "@superdoc-dev/cli-linux-x64": "0.8.0-next.85",
40
- "@superdoc-dev/cli-linux-arm64": "0.8.0-next.85",
41
- "@superdoc-dev/cli-windows-x64": "0.8.0-next.85"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.8.0-next.87",
38
+ "@superdoc-dev/cli-darwin-x64": "0.8.0-next.87",
39
+ "@superdoc-dev/cli-linux-x64": "0.8.0-next.87",
40
+ "@superdoc-dev/cli-linux-arm64": "0.8.0-next.87",
41
+ "@superdoc-dev/cli-windows-x64": "0.8.0-next.87"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",