@superdoc-dev/cli 0.8.0-next.86 → 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 +373 -71
  2. package/package.json +7 -7
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-CjDkqrj8.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": {
@@ -105400,11 +105407,17 @@ var isRegExp = (value) => {
105400
105407
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node3);
105401
105408
  const runTrackFormatMark = findTrackFormatMark(runNodeForExport.marks);
105402
105409
  const runAttrs = runNodeForExport.attrs || {};
105403
- 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;
105404
105415
  const inlineKeys = runAttrs.runPropertiesInlineKeys;
105405
105416
  const styleKeys = runAttrs.runPropertiesStyleKeys;
105406
105417
  const overrideKeys = runAttrs.runPropertiesOverrideKeys;
105407
105418
  const candidateKeys = inlineKeys != null ? [...new Set([...inlineKeys || [], ...overrideKeys || []])] : Object.keys(runProperties);
105419
+ if (candidateKeys.includes("iCs") && !candidateKeys.includes("italicCs"))
105420
+ candidateKeys.push("italicCs");
105408
105421
  const shouldExport = (key) => (key in (runProperties || {})) && (!(Array.isArray(styleKeys) && styleKeys.includes(key)) || Array.isArray(overrideKeys) && overrideKeys.includes(key));
105409
105422
  const exportKeys = candidateKeys.filter(shouldExport);
105410
105423
  const runPropertiesToExport = exportKeys.length > 0 ? Object.fromEntries(exportKeys.map((k) => [k, runProperties[k]])) : {};
@@ -112952,7 +112965,7 @@ var isRegExp = (value) => {
112952
112965
  start: safeStart,
112953
112966
  end: safeEnd
112954
112967
  };
112955
- }, 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) {
112956
112969
  const tr = newState.tr;
112957
112970
  if (!transactions.some((t) => t.docChanged))
112958
112971
  return null;
@@ -113015,15 +113028,46 @@ var isRegExp = (value) => {
113015
113028
  const existingInlineKeys = runNode.attrs?.runPropertiesInlineKeys || [];
113016
113029
  const hadInlineKeysMetadata = Array.isArray(runNode.attrs?.runPropertiesInlineKeys);
113017
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));
113018
113035
  const keysFromMarks = (segment) => {
113019
113036
  const textNode = segment.content?.find((n) => n.isText);
113020
113037
  return Object.keys(decodeRPrFromMarks(textNode?.marks || []));
113021
113038
  };
113022
- 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
+ });
113023
113046
  const existingRunPropsKeys = new Set(runNode.attrs?.runProperties ? Object.keys(runNode.attrs.runProperties) : []);
113024
113047
  const computeSegmentKeys = (segmentInlineProps, segment) => {
113025
- const hasNewInlineProps = segmentInlineProps != null && Object.keys(segmentInlineProps).some((k) => !existingRunPropsKeys.has(k));
113026
- 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) : [];
113027
113071
  const keys$1 = [...new Set([...existingInlineKeys, ...markKeysToAdd])];
113028
113072
  const ok3 = overrideKeysFromInlineProps(segmentInlineProps);
113029
113073
  return {
@@ -119130,7 +119174,7 @@ var isRegExp = (value) => {
119130
119174
  state.kern = kernNode.attributes["w:val"];
119131
119175
  }
119132
119176
  }, SuperConverter;
119133
- var init_SuperConverter_CjDkqrj8_es = __esm(() => {
119177
+ var init_SuperConverter_BecdrRIX_es = __esm(() => {
119134
119178
  init_rolldown_runtime_Bg48TavK_es();
119135
119179
  init_jszip_C49i9kUs_es();
119136
119180
  init_xml_js_CqGKpaft_es();
@@ -121800,7 +121844,7 @@ var init_SuperConverter_CjDkqrj8_es = __esm(() => {
121800
121844
  runAttribute2("rtl", "boolean", "w:rtl", schemaBooleanOrNull2()),
121801
121845
  runAttribute2("cs", "boolean", "w:cs", schemaBooleanOrNull2()),
121802
121846
  runAttribute2("bCs", "boolean", "w:bCs", schemaBooleanOrNull2(), "boldCs"),
121803
- runAttribute2("iCs", "boolean", "w:iCs", schemaBooleanOrNull2()),
121847
+ runAttribute2("iCs", "boolean", "w:iCs", schemaBooleanOrNull2(), "italicCs"),
121804
121848
  runAttribute2("eastAsianLayout", "object", "w:eastAsianLayout", schemaObjectOrNull2({
121805
121849
  id: { oneOf: [{
121806
121850
  type: "string",
@@ -134578,7 +134622,7 @@ var init_SuperConverter_CjDkqrj8_es = __esm(() => {
134578
134622
  });
134579
134623
  translator$134 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:rtl"));
134580
134624
  translator$56 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:cs"));
134581
- translator$78 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:iCs"));
134625
+ translator$78 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:iCs", "italicCs"));
134582
134626
  translator$196 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:webHidden"));
134583
134627
  translator$213 = NodeTranslator.from({
134584
134628
  xmlName: XML_NAME$4,
@@ -148397,18 +148441,26 @@ var init_SuperConverter_CjDkqrj8_es = __esm(() => {
148397
148441
  RUN_PROPERTIES_DERIVED_FROM_MARKS = new Set([
148398
148442
  "strike",
148399
148443
  "italic",
148444
+ "italicCs",
148400
148445
  "bold",
148446
+ "boldCs",
148401
148447
  "underline",
148402
148448
  "highlight",
148403
148449
  "textTransform",
148404
148450
  "color",
148405
148451
  "fontSize",
148452
+ "fontSizeCs",
148406
148453
  "letterSpacing",
148407
148454
  "fontFamily",
148408
148455
  "vertAlign",
148409
148456
  "position"
148410
148457
  ]);
148411
148458
  TRANSIENT_HYPERLINK_STYLE_IDS = new Set(["Hyperlink", "FollowedHyperlink"]);
148459
+ COMPANION_INLINE_KEYS = {
148460
+ fontSizeCs: "fontSize",
148461
+ boldCs: "bold",
148462
+ italicCs: "italic"
148463
+ };
148412
148464
  init_dist4();
148413
148465
  DEFAULT_ALLOWED_PROTOCOLS = [
148414
148466
  "http",
@@ -156990,7 +157042,7 @@ var init_SuperConverter_CjDkqrj8_es = __esm(() => {
156990
157042
  };
156991
157043
  });
156992
157044
 
156993
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-pGestihw.es.js
157045
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DCeIAH_W.es.js
156994
157046
  function parseSizeUnit(val = "0") {
156995
157047
  const length3 = val.toString() || "0";
156996
157048
  const value = Number.parseFloat(length3);
@@ -159657,8 +159709,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
159657
159709
  }
159658
159710
  };
159659
159711
  };
159660
- var init_create_headless_toolbar_pGestihw_es = __esm(() => {
159661
- init_SuperConverter_CjDkqrj8_es();
159712
+ var init_create_headless_toolbar_DCeIAH_W_es = __esm(() => {
159713
+ init_SuperConverter_BecdrRIX_es();
159662
159714
  init_constants_DrU4EASo_es();
159663
159715
  init_dist_B8HfvhaK_es();
159664
159716
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
@@ -208355,7 +208407,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
208355
208407
  init_remark_gfm_BhnWr3yf_es();
208356
208408
  });
208357
208409
 
208358
- // ../../packages/superdoc/dist/chunks/src-tOywM1hR.es.js
208410
+ // ../../packages/superdoc/dist/chunks/src-AOxYjda5.es.js
208359
208411
  function deleteProps(obj, propOrProps) {
208360
208412
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
208361
208413
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -211658,6 +211710,24 @@ function calcTabHeight(blockParent2) {
211658
211710
  const parentTextStyleMark = blockParent2.firstChild?.marks?.find((mark2) => mark2.type.name === "textStyle");
211659
211711
  return `${(parseInt(parentTextStyleMark?.attrs.fontSize) * ptToPxRatio || defaultFontSize) * defaultLineHeight}px`;
211660
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
+ }
211661
211731
  function createNumberingManager() {
211662
211732
  let countersMap = {};
211663
211733
  let abstractCountersMap = {};
@@ -212280,6 +212350,7 @@ function parseCssLength(value) {
212280
212350
  function parseAttrs(node3) {
212281
212351
  const numberingProperties = {};
212282
212352
  let indent2, spacing, justification;
212353
+ let rightToLeft;
212283
212354
  let sectionProperties = null;
212284
212355
  let pageBreakSource = null;
212285
212356
  const { styleid: styleId, ...extraAttrs } = Array.from(node3.attributes).reduce((acc, attr) => {
@@ -212312,7 +212383,12 @@ function parseAttrs(node3) {
212312
212383
  } catch {}
212313
212384
  else if (attr.name === "data-sd-page-break-source")
212314
212385
  pageBreakSource = attr.value || null;
212315
- 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
212316
212392
  acc[attr.name] = attr.value;
212317
212393
  return acc;
212318
212394
  }, {});
@@ -212342,6 +212418,12 @@ function parseAttrs(node3) {
212342
212418
  const ml = parseCssLength(node3.style.marginLeft);
212343
212419
  if (ml && ml.unit !== "%" && ml.points >= 0)
212344
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);
212345
212427
  const ti = parseCssLength(node3.style.textIndent);
212346
212428
  if (ti && ti.unit !== "%")
212347
212429
  if (ti.points >= 0)
@@ -212356,6 +212438,12 @@ function parseAttrs(node3) {
212356
212438
  if (textAlign && CSS_ALIGN_TO_OOXML[textAlign])
212357
212439
  justification = CSS_ALIGN_TO_OOXML[textAlign];
212358
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
+ }
212359
212447
  let attrs = {
212360
212448
  paragraphProperties: { styleId: styleId || null },
212361
212449
  extraAttrs
@@ -212366,6 +212454,8 @@ function parseAttrs(node3) {
212366
212454
  attrs.paragraphProperties.spacing = spacing;
212367
212455
  if (justification)
212368
212456
  attrs.paragraphProperties.justification = justification;
212457
+ if (rightToLeft != null)
212458
+ attrs.paragraphProperties.rightToLeft = rightToLeft;
212369
212459
  if (Object.keys(numberingProperties).length > 0)
212370
212460
  attrs.paragraphProperties.numberingProperties = numberingProperties;
212371
212461
  if (sectionProperties)
@@ -217270,6 +217360,21 @@ function getCurrentCoords(editor, selection) {
217270
217360
  y: layoutSpaceCoords.y
217271
217361
  };
217272
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
+ }
217273
217378
  function getAdjacentLineClientTarget(editor, coords, direction) {
217274
217379
  const doc$12 = editor.presentationEditor.visibleHost?.ownerDocument ?? document;
217275
217380
  const caretX = coords.clientX;
@@ -251571,6 +251676,15 @@ function isMinimalWordLayout(value) {
251571
251676
  }
251572
251677
  return true;
251573
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
+ }
251574
251688
  function computeTabWidth(currentPos, justification, tabs, hangingIndent, firstLineIndent, leftIndent) {
251575
251689
  const nextDefaultTabStop = currentPos + 48 - currentPos % 48;
251576
251690
  let tabWidth;
@@ -252619,17 +252733,18 @@ function resolveParagraphContent(fragment2, block, measure) {
252619
252733
  const paraIndent = block.attrs?.indent;
252620
252734
  const paraIndentLeft = paraIndent?.left ?? 0;
252621
252735
  const paraIndentRight = paraIndent?.right ?? 0;
252736
+ const { anchorIndentPx: paraMarkerAnchorIndent, firstLinePx: markerFirstLine, hangingPx: markerHanging } = resolveMarkerIndent(paraIndent, block.attrs?.direction === "rtl");
252622
252737
  const firstLineOffset = block.attrs?.suppressFirstLineIndent === true ? 0 : (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
252623
252738
  const paragraphEndsWithLineBreak = (block.runs.length > 0 ? block.runs[block.runs.length - 1] : null)?.kind === "lineBreak";
252624
252739
  const lines = fragment2.lines ?? measure.lines.slice(fragment2.fromLine, fragment2.toLine);
252625
252740
  const hasMarker = !fragment2.continuesFromPrev && fragment2.markerWidth && wordLayout?.marker;
252626
- const listFirstLineTextStartPx = hasMarker ? resolverListTextStartPx(wordLayout, paraIndentLeft, paraIndent?.hanging ?? 0, paraIndent?.firstLine ?? 0, fragment2.markerTextWidth) : undefined;
252627
- 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;
252628
252743
  let listTabWidth = 0;
252629
252744
  let markerStartPos = 0;
252630
252745
  if (hasMarker) {
252631
252746
  const markerTextWidth = fragment2.markerTextWidth;
252632
- const anchorPoint = paraIndentLeft - (paraIndent?.hanging ?? 0) + (paraIndent?.firstLine ?? 0);
252747
+ const anchorPoint = paraMarkerAnchorIndent - markerHanging + markerFirstLine;
252633
252748
  const markerJustification = wordLayout.marker.justification ?? "left";
252634
252749
  let currentPos;
252635
252750
  if (markerJustification === "left") {
@@ -252646,7 +252761,7 @@ function resolveParagraphContent(fragment2, block, measure) {
252646
252761
  if (listFirstLineMarkerGeometry && (suffix === "tab" || suffix === "space"))
252647
252762
  listTabWidth = listFirstLineMarkerGeometry.suffixWidthPx;
252648
252763
  else if (suffix === "tab")
252649
- listTabWidth = computeTabWidth(currentPos, markerJustification, wordLayout.tabsPx, paraIndent?.hanging, paraIndent?.firstLine, paraIndentLeft);
252764
+ listTabWidth = computeTabWidth(currentPos, markerJustification, wordLayout.tabsPx, markerHanging, markerFirstLine, paraMarkerAnchorIndent);
252650
252765
  else if (suffix === "space")
252651
252766
  listTabWidth = 4;
252652
252767
  }
@@ -252654,7 +252769,7 @@ function resolveParagraphContent(fragment2, block, measure) {
252654
252769
  if (hasMarker) {
252655
252770
  const m$1 = wordLayout.marker;
252656
252771
  const justification = m$1.justification ?? "left";
252657
- const firstLinePaddingLeftPx = paraIndentLeft + (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
252772
+ const firstLinePaddingLeftPx = paraMarkerAnchorIndent - markerHanging + markerFirstLine;
252658
252773
  let centerPaddingAdjustPx;
252659
252774
  if (justification === "center")
252660
252775
  centerPaddingAdjustPx = fragment2.markerTextWidth / 2;
@@ -264795,6 +264910,20 @@ function handleTableNode(node3, context) {
264795
264910
  recordBlockKind?.(tableBlock.kind);
264796
264911
  }
264797
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
+ }
264798
264927
  function sourceAnchorFromNode(node3) {
264799
264928
  const sourceAnchor = node3.attrs?.sourceAnchor;
264800
264929
  return sourceAnchor && typeof sourceAnchor === "object" && !Array.isArray(sourceAnchor) ? sourceAnchor : undefined;
@@ -265120,6 +265249,7 @@ function handleParagraphNode2(node3, context) {
265120
265249
  blocks2.push(sectionBreak);
265121
265250
  recordBlockKind?.(sectionBreak.kind);
265122
265251
  sectionState.currentSectionIndex++;
265252
+ converterContext.sectionDirection = resolveSectionDirectionFromSectPr$1(nextSection.sectPr);
265123
265253
  }
265124
265254
  }
265125
265255
  const paragraphToFlowBlocks$1 = converters$1.paragraphToFlowBlocks;
@@ -265216,6 +265346,20 @@ function handleMathBlockNode(node3, context) {
265216
265346
  blocks2.push(block);
265217
265347
  recordBlockKind?.(block.kind);
265218
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
+ }
265219
265363
  function toFlowBlocks(pmDoc, options) {
265220
265364
  const defaultFont = options?.defaultFont ?? DEFAULT_FONT;
265221
265365
  const defaultSize = options?.defaultSize ?? DEFAULT_SIZE2;
@@ -265253,6 +265397,7 @@ function toFlowBlocks(pmDoc, options) {
265253
265397
  };
265254
265398
  const bodySectionProps = doc$12.attrs?.bodySectPr ?? doc$12.attrs?.sectPr;
265255
265399
  const sectionRanges = options?.emitSectionBreaks ? analyzeSectionRanges(doc$12, bodySectionProps) : [];
265400
+ converterContext.sectionDirection = converterContext.sectionDirection ?? resolveSectionDirectionFromSectPr(sectionRanges[0]?.sectPr ?? bodySectionProps);
265256
265401
  publishSectionMetadata(sectionRanges, options);
265257
265402
  if (sectionRanges.length > 0 && sectionRanges[0]) {
265258
265403
  const sectionBreak = createSectionBreakBlock(sectionRanges[0], nextBlockId, { isFirstSection: true });
@@ -266697,8 +266842,10 @@ function computeCaretLayoutRectGeometry({ layout, blocks: blocks2, measures, pai
266697
266842
  hangingIndent: indent2.hanging,
266698
266843
  wordLayout
266699
266844
  });
266700
- const charX = measureCharacterX(block, line, pmOffset, Math.max(0, fragment2.width - (indentAdjust + indent2.right)));
266701
- 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;
266702
266849
  const lineOffset = lineHeightBeforeIndex(measure.lines, fragment2.fromLine, index2);
266703
266850
  const localY = fragment2.y + lineOffset;
266704
266851
  const result = {
@@ -276140,7 +276287,7 @@ var Node$13 = class Node$14 {
276140
276287
  this.dom.classList.remove("sd-editor-dropcap");
276141
276288
  if (paragraphProperties.styleId)
276142
276289
  this.dom.setAttribute("styleid", paragraphProperties.styleId);
276143
- if (paragraphProperties.rightToLeft)
276290
+ if (paragraphProperties.rightToLeft === true || paragraphProperties.rightToLeft !== false && inferParagraphRtlFromRuns(this.node))
276144
276291
  this.dom.setAttribute("dir", "rtl");
276145
276292
  else
276146
276293
  this.dom.removeAttribute("dir");
@@ -289464,7 +289611,7 @@ menclose::after {
289464
289611
  y$1 += actualRowHeight + cellSpacingPx;
289465
289612
  }
289466
289613
  return container;
289467
- }, isRtlParagraph = (attrs) => attrs?.direction === "rtl" || attrs?.rtl === true, resolveTextAlign = (alignment$1, isRtl) => {
289614
+ }, isRtlParagraph = (attrs) => attrs?.direction === "rtl", resolveTextAlign = (alignment$1, isRtl) => {
289468
289615
  switch (alignment$1) {
289469
289616
  case "center":
289470
289617
  case "right":
@@ -289479,6 +289626,9 @@ menclose::after {
289479
289626
  if (rtl) {
289480
289627
  element3.setAttribute("dir", "rtl");
289481
289628
  element3.style.direction = "rtl";
289629
+ } else {
289630
+ element3.removeAttribute("dir");
289631
+ element3.style.direction = "";
289482
289632
  }
289483
289633
  element3.style.textAlign = resolveTextAlign(attrs?.alignment, rtl);
289484
289634
  return rtl;
@@ -290781,7 +290931,6 @@ menclose::after {
290781
290931
  attrs.shading?.fill ?? "",
290782
290932
  attrs.shading?.color ?? "",
290783
290933
  attrs.direction ?? "",
290784
- attrs.rtl ? "1" : "",
290785
290934
  attrs.tabs?.length ? JSON.stringify(attrs.tabs) : ""
290786
290935
  ].join(":") : "";
290787
290936
  const sdtAttrs = block.attrs?.sdt;
@@ -290910,7 +291059,6 @@ menclose::after {
290910
291059
  hash$3 = hashString(hash$3, attrs.shading?.fill ?? "");
290911
291060
  hash$3 = hashString(hash$3, attrs.shading?.color ?? "");
290912
291061
  hash$3 = hashString(hash$3, attrs.direction ?? "");
290913
- hash$3 = hashString(hash$3, attrs.rtl ? "1" : "");
290914
291062
  if (attrs.borders)
290915
291063
  hash$3 = hashString(hash$3, hashParagraphBorders$1(attrs.borders));
290916
291064
  }
@@ -291624,8 +291772,6 @@ menclose::after {
291624
291772
  }
291625
291773
  if (attrs.direction)
291626
291774
  parts.push(`dir:${attrs.direction}`);
291627
- if (attrs.rtl)
291628
- parts.push("rtl");
291629
291775
  if (parts.length > 0)
291630
291776
  cellHashes.push(`pa:${parts.join(":")}`);
291631
291777
  }
@@ -291733,8 +291879,6 @@ menclose::after {
291733
291879
  }
291734
291880
  if (attrs.direction)
291735
291881
  parts.push(`dir:${attrs.direction}`);
291736
- if (attrs.rtl)
291737
- parts.push("rtl");
291738
291882
  if (attrs.keepNext)
291739
291883
  parts.push("kn");
291740
291884
  if (attrs.keepLines)
@@ -292466,7 +292610,7 @@ menclose::after {
292466
292610
  return true;
292467
292611
  if (!a2 || !b$1)
292468
292612
  return !a2 && !b$1;
292469
- 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)
292470
292614
  return false;
292471
292615
  if (!paragraphSpacingEqual(a2.spacing, b$1.spacing))
292472
292616
  return false;
@@ -293397,8 +293541,6 @@ menclose::after {
293397
293541
  const directionAttr = attrs.direction ?? attrs.dir ?? attrs.textDirection;
293398
293542
  if (typeof directionAttr === "string" && directionAttr.toLowerCase() === "rtl")
293399
293543
  return true;
293400
- if (typeof attrs.rtl === "boolean")
293401
- return attrs.rtl;
293402
293544
  return false;
293403
293545
  }, determineColumn = (layout, fragmentX) => {
293404
293546
  const columns = layout.columns;
@@ -294630,6 +294772,26 @@ menclose::after {
294630
294772
  default:
294631
294773
  return;
294632
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;
294633
294795
  }, DEFAULT_DECIMAL_SEPARATOR$1 = ".", DEFAULT_TAB_INTERVAL_TWIPS$1 = 720, normalizeColor$1 = (value) => {
294634
294796
  if (typeof value !== "string")
294635
294797
  return;
@@ -294647,6 +294809,37 @@ menclose::after {
294647
294809
  if (Object.prototype.hasOwnProperty.call(obj, key2))
294648
294810
  clone[key2] = deepClone3(obj[key2]);
294649
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;
294650
294843
  }, normalizeIndentTwipsToPx = (indent2) => {
294651
294844
  if (!indent2)
294652
294845
  return;
@@ -294670,6 +294863,18 @@ menclose::after {
294670
294863
  if (hanging != null)
294671
294864
  result.hanging = twipsToPx$1(hanging);
294672
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;
294673
294878
  }, normalizeFramePr = (value) => {
294674
294879
  if (!value)
294675
294880
  return;
@@ -294757,9 +294962,11 @@ menclose::after {
294757
294962
  resolvedParagraphProperties = paragraphProperties;
294758
294963
  else
294759
294964
  resolvedParagraphProperties = resolveParagraphProperties(converterContext, paragraphProperties, converterContext.tableInfo);
294760
- 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";
294761
294967
  const normalizedSpacing = normalizeParagraphSpacing(resolvedParagraphProperties.spacing, Boolean(resolvedParagraphProperties.numberingProperties));
294762
- const normalizedIndent = normalizeIndentTwipsToPx(resolvedParagraphProperties.indent);
294968
+ const normalizedIndentBase = normalizeIndentTwipsToPx(resolveLogicalIndentToPhysical(resolvedParagraphProperties.indent, normalizedDirection));
294969
+ const normalizedIndent = isRtl && normalizedIndentBase ? mirrorIndentForRtl(normalizedIndentBase) : normalizedIndentBase;
294763
294970
  const normalizedTabStops = normalizeOoxmlTabs(resolvedParagraphProperties.tabStops);
294764
294971
  const normalizedAlignment = normalizeAlignment(resolvedParagraphProperties.justification, isRtl);
294765
294972
  const normalizedBorders = normalizeParagraphBorders(resolvedParagraphProperties.borders);
@@ -294767,7 +294974,6 @@ menclose::after {
294767
294974
  const paragraphDecimalSeparator = DEFAULT_DECIMAL_SEPARATOR$1;
294768
294975
  const tabIntervalTwips = DEFAULT_TAB_INTERVAL_TWIPS$1;
294769
294976
  const normalizedFramePr = normalizeFramePr(resolvedParagraphProperties.framePr);
294770
- const normalizedDirection = resolvedParagraphProperties.rightToLeft === true ? "rtl" : resolvedParagraphProperties.rightToLeft === false ? "ltr" : undefined;
294771
294977
  const floatAlignment = normalizedFramePr?.xAlign;
294772
294978
  const normalizedNumberingProperties = normalizeNumberingProperties(resolvedParagraphProperties.numberingProperties);
294773
294979
  const dropCapDescriptor = normalizeDropCap(resolvedParagraphProperties.framePr, para, converterContext);
@@ -294790,10 +294996,7 @@ menclose::after {
294790
294996
  keepLines: resolvedParagraphProperties.keepLines,
294791
294997
  floatAlignment,
294792
294998
  pageBreakBefore: resolvedParagraphProperties.pageBreakBefore,
294793
- ...normalizedDirection ? {
294794
- direction: normalizedDirection,
294795
- rtl: isRtl
294796
- } : {}
294999
+ ...normalizedDirection ? { direction: normalizedDirection } : {}
294797
295000
  };
294798
295001
  if (normalizedNumberingProperties && normalizedListRendering) {
294799
295002
  const markerRunAttrs = computeRunAttrs(resolveRunProperties(converterContext, resolvedParagraphProperties.runProperties, resolvedParagraphProperties, converterContext.tableInfo, true, Boolean(paragraphProperties.numberingProperties)), converterContext);
@@ -301447,12 +301650,12 @@ menclose::after {
301447
301650
  return;
301448
301651
  console.log(...args$1);
301449
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;
301450
- var init_src_tOywM1hR_es = __esm(() => {
301653
+ var init_src_AOxYjda5_es = __esm(() => {
301451
301654
  init_rolldown_runtime_Bg48TavK_es();
301452
- init_SuperConverter_CjDkqrj8_es();
301655
+ init_SuperConverter_BecdrRIX_es();
301453
301656
  init_jszip_C49i9kUs_es();
301454
301657
  init_uuid_qzgm05fK_es();
301455
- init_create_headless_toolbar_pGestihw_es();
301658
+ init_create_headless_toolbar_DCeIAH_W_es();
301456
301659
  init_constants_DrU4EASo_es();
301457
301660
  init_dist_B8HfvhaK_es();
301458
301661
  init_unified_Dsuw2be5_es();
@@ -319747,10 +319950,25 @@ function print() { __p += __j.call(arguments, '') }
319747
319950
  handleKeyDown(view, event) {
319748
319951
  if (view.composing || !editor.isEditable)
319749
319952
  return false;
319750
- if (event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") {
319953
+ if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
319751
319954
  view.dispatch(view.state.tr.setMeta(VerticalNavigationPluginKey, { type: "reset-goal-x" }));
319752
319955
  return false;
319753
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
+ }
319754
319972
  if (event.key === "PageUp" || event.key === "PageDown") {
319755
319973
  view.dispatch(view.state.tr.setMeta(VerticalNavigationPluginKey, { type: "reset-goal-x" }));
319756
319974
  return false;
@@ -329348,6 +329566,7 @@ function print() { __p += __j.call(arguments, '') }
329348
329566
  const expandedRunsForBlock = expandRunsForInlineNewlines(block.runs);
329349
329567
  content3.lines.forEach((resolvedLine) => {
329350
329568
  const paragraphMarkLeftOffset = this.resolveResolvedListParagraphMarkOffset(resolvedLine.isListFirstLine ? resolvedMarker : undefined, fragment2.markerTextWidth, resolvedLine.indentOffset);
329569
+ const isRtl = block.attrs?.direction === "rtl";
329351
329570
  const lineEl = this.renderLine(block, resolvedLine.line, context, resolvedLine.availableWidth, resolvedLine.lineIndex, resolvedLine.skipJustify, expandedRunsForBlock, resolvedLine.resolvedListTextStartPx, resolvedLine.indentOffset, paragraphMarkLeftOffset);
329352
329571
  if (!resolvedLine.isListFirstLine) {
329353
329572
  if (resolvedLine.paddingLeftPx > 0)
@@ -329363,17 +329582,28 @@ function print() { __p += __j.call(arguments, '') }
329363
329582
  if (resolvedLine.paddingRightPx > 0)
329364
329583
  lineEl.style.paddingRight = `${resolvedLine.paddingRightPx}px`;
329365
329584
  if (resolvedLine.isListFirstLine && resolvedMarker) {
329366
- 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`;
329367
329589
  if (!resolvedMarker.vanish) {
329368
329590
  const markerContainer = createListMarkerElement(this.doc, resolvedMarker.text, resolvedMarker.run, resolvedMarker.sourceAnchor ?? resolvedItem?.sourceAnchor);
329369
329591
  markerContainer.style.position = "relative";
329370
329592
  if (resolvedMarker.justification === "right") {
329371
329593
  markerContainer.style.position = "absolute";
329372
- 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`;
329373
329598
  } else if (resolvedMarker.justification === "center") {
329374
329599
  markerContainer.style.position = "absolute";
329375
- markerContainer.style.left = `${resolvedMarker.markerStartPx - (resolvedMarker.centerPaddingAdjustPx ?? 0)}px`;
329376
- 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
+ }
329377
329607
  }
329378
329608
  if (resolvedMarker.suffix === "tab") {
329379
329609
  const tabEl = this.doc.createElement("span");
@@ -329406,28 +329636,30 @@ function print() { __p += __j.call(arguments, '') }
329406
329636
  const paraIndent = block.attrs?.indent;
329407
329637
  const paraIndentLeft = paraIndent?.left ?? 0;
329408
329638
  const paraIndentRight = paraIndent?.right ?? 0;
329639
+ const isRtl = block.attrs?.direction === "rtl";
329640
+ const { anchorIndentPx: paraMarkerAnchorIndent, firstLinePx: markerFirstLine, hangingPx: markerHanging } = resolveMarkerIndent(paraIndent, isRtl);
329409
329641
  const firstLineOffset = block.attrs?.suppressFirstLineIndent === true ? 0 : (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
329410
329642
  const expandedRunsForBlock = expandRunsForInlineNewlines(block.runs);
329411
329643
  const paragraphEndsWithLineBreak = (block.runs.length > 0 ? block.runs[block.runs.length - 1] : null)?.kind === "lineBreak";
329412
329644
  const listFirstLineTextStartPx = !paraContinuesFromPrev && paraMarkerWidth && wordLayout?.marker ? resolvePainterListTextStartPx({
329413
329645
  wordLayout,
329414
- indentLeftPx: paraIndentLeft,
329415
- hangingIndentPx: paraIndent?.hanging ?? 0,
329416
- firstLineIndentPx: paraIndent?.firstLine ?? 0,
329646
+ indentLeftPx: paraMarkerAnchorIndent,
329647
+ hangingIndentPx: markerHanging,
329648
+ firstLineIndentPx: markerFirstLine,
329417
329649
  markerTextWidthPx: fragment2.markerTextWidth
329418
329650
  }) : undefined;
329419
329651
  const listFirstLineMarkerGeometry = !paraContinuesFromPrev && paraMarkerWidth && wordLayout?.marker?.justification === "left" && wordLayout.firstLineIndentMode !== true && typeof fragment2.markerTextWidth === "number" && Number.isFinite(fragment2.markerTextWidth) && fragment2.markerTextWidth >= 0 ? resolvePainterListMarkerGeometry({
329420
329652
  wordLayout,
329421
- indentLeftPx: paraIndentLeft,
329422
- hangingIndentPx: paraIndent?.hanging ?? 0,
329423
- firstLineIndentPx: paraIndent?.firstLine ?? 0,
329653
+ indentLeftPx: paraMarkerAnchorIndent,
329654
+ hangingIndentPx: markerHanging,
329655
+ firstLineIndentPx: markerFirstLine,
329424
329656
  markerTextWidthPx: fragment2.markerTextWidth
329425
329657
  }) : undefined;
329426
329658
  let listTabWidth = 0;
329427
329659
  let markerStartPos = 0;
329428
329660
  if (!paraContinuesFromPrev && paraMarkerWidth && wordLayout?.marker) {
329429
329661
  const markerTextWidth = fragment2.markerTextWidth;
329430
- const anchorPoint = paraIndentLeft - (paraIndent?.hanging ?? 0) + (paraIndent?.firstLine ?? 0);
329662
+ const anchorPoint = paraMarkerAnchorIndent - markerHanging + markerFirstLine;
329431
329663
  const markerJustification = wordLayout.marker.justification ?? "left";
329432
329664
  let currentPos;
329433
329665
  if (markerJustification === "left") {
@@ -329444,7 +329676,7 @@ function print() { __p += __j.call(arguments, '') }
329444
329676
  if (listFirstLineMarkerGeometry && (suffix === "tab" || suffix === "space"))
329445
329677
  listTabWidth = listFirstLineMarkerGeometry.suffixWidthPx;
329446
329678
  else if (suffix === "tab")
329447
- listTabWidth = computeTabWidth(currentPos, markerJustification, wordLayout.tabsPx, paraIndent?.hanging, paraIndent?.firstLine, paraIndentLeft);
329679
+ listTabWidth = computeTabWidth(currentPos, markerJustification, wordLayout.tabsPx, markerHanging, markerFirstLine, paraMarkerAnchorIndent);
329448
329680
  else if (suffix === "space")
329449
329681
  listTabWidth = 4;
329450
329682
  }
@@ -329486,18 +329718,30 @@ function print() { __p += __j.call(arguments, '') }
329486
329718
  const marker = wordLayout?.marker;
329487
329719
  if (!marker)
329488
329720
  return;
329489
- 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`;
329490
329726
  if (!marker.run.vanish) {
329491
329727
  const markerContainer = createListMarkerElement(this.doc, marker.markerText ?? "", marker.run, block.sourceAnchor ?? resolvedItem?.sourceAnchor);
329492
329728
  const markerJustification = marker.justification ?? "left";
329493
329729
  markerContainer.style.position = "relative";
329494
329730
  if (markerJustification === "right") {
329495
329731
  markerContainer.style.position = "absolute";
329496
- markerContainer.style.left = `${markerStartPos}px`;
329732
+ if (isRtl)
329733
+ markerContainer.style.right = `${markerStartPos}px`;
329734
+ else
329735
+ markerContainer.style.left = `${markerStartPos}px`;
329497
329736
  } else if (markerJustification === "center") {
329498
329737
  markerContainer.style.position = "absolute";
329499
- markerContainer.style.left = `${markerStartPos - fragment2.markerTextWidth / 2}px`;
329500
- 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
+ }
329501
329745
  }
329502
329746
  const suffix = marker.suffix ?? "tab";
329503
329747
  if (suffix === "tab") {
@@ -334598,7 +334842,8 @@ function print() { __p += __j.call(arguments, '') }
334598
334842
  x: localX,
334599
334843
  y: localY
334600
334844
  };
334601
- 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;
334602
334847
  if (!hit)
334603
334848
  return null;
334604
334849
  const doc$2 = this.getActiveEditor().state?.doc;
@@ -337677,6 +337922,63 @@ function print() { __p += __j.call(arguments, '') }
337677
337922
  lineIndex: -1
337678
337923
  };
337679
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
+ }
337680
337982
  #createCollapsedSelectionNearInlineContent(doc$12, pos) {
337681
337983
  const clampedPos = Math.max(0, Math.min(pos, doc$12.content.size));
337682
337984
  const directSelection = TextSelection.create(doc$12, clampedPos);
@@ -339196,11 +339498,11 @@ function print() { __p += __j.call(arguments, '') }
339196
339498
  ];
339197
339499
  });
339198
339500
 
339199
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-Cj3mqS9_.es.js
339501
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-fxrCn5X_.es.js
339200
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;
339201
- var init_create_super_doc_ui_Cj3mqS9__es = __esm(() => {
339202
- init_SuperConverter_CjDkqrj8_es();
339203
- init_create_headless_toolbar_pGestihw_es();
339503
+ var init_create_super_doc_ui_fxrCn5X__es = __esm(() => {
339504
+ init_SuperConverter_BecdrRIX_es();
339505
+ init_create_headless_toolbar_DCeIAH_W_es();
339204
339506
  MOD_ALIASES = new Set([
339205
339507
  "Mod",
339206
339508
  "Meta",
@@ -339242,16 +339544,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
339242
339544
 
339243
339545
  // ../../packages/superdoc/dist/super-editor.es.js
339244
339546
  var init_super_editor_es = __esm(() => {
339245
- init_src_tOywM1hR_es();
339246
- init_SuperConverter_CjDkqrj8_es();
339547
+ init_src_AOxYjda5_es();
339548
+ init_SuperConverter_BecdrRIX_es();
339247
339549
  init_jszip_C49i9kUs_es();
339248
339550
  init_xml_js_CqGKpaft_es();
339249
- init_create_headless_toolbar_pGestihw_es();
339551
+ init_create_headless_toolbar_DCeIAH_W_es();
339250
339552
  init_constants_DrU4EASo_es();
339251
339553
  init_dist_B8HfvhaK_es();
339252
339554
  init_unified_Dsuw2be5_es();
339253
339555
  init_DocxZipper_Dh4RtvcE_es();
339254
- init_create_super_doc_ui_Cj3mqS9__es();
339556
+ init_create_super_doc_ui_fxrCn5X__es();
339255
339557
  init_ui_CGB3qmy3_es();
339256
339558
  init_eventemitter3_UwU_CLPU_es();
339257
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.86",
3
+ "version": "0.8.0-next.87",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -24,9 +24,9 @@
24
24
  "@types/node": "22.19.2",
25
25
  "@types/ws": "^8.5.13",
26
26
  "typescript": "^5.9.2",
27
+ "@superdoc/document-api": "0.0.1",
27
28
  "@superdoc/pm-adapter": "0.0.0",
28
29
  "@superdoc/super-editor": "0.0.1",
29
- "@superdoc/document-api": "0.0.1",
30
30
  "superdoc": "1.31.0"
31
31
  },
32
32
  "module": "src/index.ts",
@@ -34,11 +34,11 @@
34
34
  "access": "public"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@superdoc-dev/cli-darwin-arm64": "0.8.0-next.86",
38
- "@superdoc-dev/cli-darwin-x64": "0.8.0-next.86",
39
- "@superdoc-dev/cli-windows-x64": "0.8.0-next.86",
40
- "@superdoc-dev/cli-linux-x64": "0.8.0-next.86",
41
- "@superdoc-dev/cli-linux-arm64": "0.8.0-next.86"
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",