@superdoc-dev/cli 0.8.0-next.86 → 0.8.0-next.88

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 +438 -71
  2. package/package.json +9 -9
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-DOdRGHiA.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,119 @@ 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;
294795
+ }, DEFAULT_PAGE_DIRECTION = "ltr", DEFAULT_WRITING_MODE = "horizontal-tb", isToggleOn = (val) => {
294796
+ if (val === undefined || val === null)
294797
+ return true;
294798
+ if (val === "0" || val === 0 || val === false)
294799
+ return false;
294800
+ if (val === "false" || val === "off")
294801
+ return false;
294802
+ return true;
294803
+ }, writingModeFromTextDirection$1 = (val) => {
294804
+ if (typeof val !== "string")
294805
+ return;
294806
+ switch (val) {
294807
+ case "lrTb":
294808
+ case "lrTbV":
294809
+ case "tb":
294810
+ case "tbV":
294811
+ return "horizontal-tb";
294812
+ case "tbRl":
294813
+ case "tbRlV":
294814
+ case "rl":
294815
+ case "rlV":
294816
+ return "vertical-rl";
294817
+ case "btLr":
294818
+ case "lr":
294819
+ case "lrV":
294820
+ case "tbLrV":
294821
+ return "vertical-lr";
294822
+ default:
294823
+ return;
294824
+ }
294825
+ }, resolveSectionDirection = (sectPr) => {
294826
+ let pageDirection = DEFAULT_PAGE_DIRECTION;
294827
+ let writingMode = DEFAULT_WRITING_MODE;
294828
+ let rtlGutter = false;
294829
+ if (sectPr && typeof sectPr === "object") {
294830
+ const elements = sectPr.elements;
294831
+ if (Array.isArray(elements))
294832
+ for (const el of elements) {
294833
+ if (!el?.name)
294834
+ continue;
294835
+ const val = el.attributes?.["w:val"] ?? el.attributes?.val;
294836
+ if (el.name === "w:bidi" && isToggleOn(val)) {
294837
+ pageDirection = "rtl";
294838
+ continue;
294839
+ }
294840
+ if (el.name === "w:textDirection") {
294841
+ const mode = writingModeFromTextDirection$1(val);
294842
+ if (mode)
294843
+ writingMode = mode;
294844
+ continue;
294845
+ }
294846
+ if (el.name === "w:rtlGutter" && isToggleOn(val)) {
294847
+ rtlGutter = true;
294848
+ continue;
294849
+ }
294850
+ }
294851
+ }
294852
+ return {
294853
+ pageDirection,
294854
+ writingMode,
294855
+ rtlGutter
294856
+ };
294857
+ }, writingModeFromTextDirection = (val) => {
294858
+ switch (val) {
294859
+ case "lrTb":
294860
+ case "lrTbV":
294861
+ case "tb":
294862
+ case "tbV":
294863
+ return "horizontal-tb";
294864
+ case "tbRl":
294865
+ case "tbRlV":
294866
+ case "rl":
294867
+ case "rlV":
294868
+ return "vertical-rl";
294869
+ case "btLr":
294870
+ case "lr":
294871
+ case "lrV":
294872
+ case "tbLrV":
294873
+ return "vertical-lr";
294874
+ default:
294875
+ return;
294876
+ }
294877
+ }, resolveParagraphDirection = (paragraphProperties, parentSection, parentCell) => {
294878
+ let inlineDirection;
294879
+ if (paragraphProperties?.rightToLeft === true)
294880
+ inlineDirection = "rtl";
294881
+ else if (paragraphProperties?.rightToLeft === false)
294882
+ inlineDirection = "ltr";
294883
+ const writingMode = writingModeFromTextDirection(paragraphProperties?.textDirection) ?? parentCell?.writingMode ?? parentSection.writingMode;
294884
+ return {
294885
+ inlineDirection,
294886
+ writingMode
294887
+ };
294633
294888
  }, DEFAULT_DECIMAL_SEPARATOR$1 = ".", DEFAULT_TAB_INTERVAL_TWIPS$1 = 720, normalizeColor$1 = (value) => {
294634
294889
  if (typeof value !== "string")
294635
294890
  return;
@@ -294670,6 +294925,18 @@ menclose::after {
294670
294925
  if (hanging != null)
294671
294926
  result.hanging = twipsToPx$1(hanging);
294672
294927
  return Object.keys(result).length > 0 ? result : undefined;
294928
+ }, resolveLogicalIndentToPhysical = (indent2, _direction) => {
294929
+ if (!indent2)
294930
+ return;
294931
+ const resolved = { ...indent2 };
294932
+ const source = indent2;
294933
+ if (source.start != null)
294934
+ resolved.left = source.start;
294935
+ if (source.end != null)
294936
+ resolved.right = source.end;
294937
+ delete resolved.start;
294938
+ delete resolved.end;
294939
+ return resolved;
294673
294940
  }, normalizeFramePr = (value) => {
294674
294941
  if (!value)
294675
294942
  return;
@@ -294757,9 +295024,13 @@ menclose::after {
294757
295024
  resolvedParagraphProperties = paragraphProperties;
294758
295025
  else
294759
295026
  resolvedParagraphProperties = resolveParagraphProperties(converterContext, paragraphProperties, converterContext.tableInfo);
294760
- const isRtl = resolvedParagraphProperties.rightToLeft === true;
295027
+ const sectionContext = resolveSectionDirection(undefined);
295028
+ const directionContext = resolveParagraphDirection(resolvedParagraphProperties, sectionContext);
295029
+ const normalizedDirection = directionContext.inlineDirection;
295030
+ const isRtl = normalizedDirection === "rtl";
294761
295031
  const normalizedSpacing = normalizeParagraphSpacing(resolvedParagraphProperties.spacing, Boolean(resolvedParagraphProperties.numberingProperties));
294762
- const normalizedIndent = normalizeIndentTwipsToPx(resolvedParagraphProperties.indent);
295032
+ const normalizedIndentBase = normalizeIndentTwipsToPx(resolveLogicalIndentToPhysical(resolvedParagraphProperties.indent, normalizedDirection));
295033
+ const normalizedIndent = isRtl && normalizedIndentBase ? mirrorIndentForRtl(normalizedIndentBase) : normalizedIndentBase;
294763
295034
  const normalizedTabStops = normalizeOoxmlTabs(resolvedParagraphProperties.tabStops);
294764
295035
  const normalizedAlignment = normalizeAlignment(resolvedParagraphProperties.justification, isRtl);
294765
295036
  const normalizedBorders = normalizeParagraphBorders(resolvedParagraphProperties.borders);
@@ -294767,7 +295038,6 @@ menclose::after {
294767
295038
  const paragraphDecimalSeparator = DEFAULT_DECIMAL_SEPARATOR$1;
294768
295039
  const tabIntervalTwips = DEFAULT_TAB_INTERVAL_TWIPS$1;
294769
295040
  const normalizedFramePr = normalizeFramePr(resolvedParagraphProperties.framePr);
294770
- const normalizedDirection = resolvedParagraphProperties.rightToLeft === true ? "rtl" : resolvedParagraphProperties.rightToLeft === false ? "ltr" : undefined;
294771
295041
  const floatAlignment = normalizedFramePr?.xAlign;
294772
295042
  const normalizedNumberingProperties = normalizeNumberingProperties(resolvedParagraphProperties.numberingProperties);
294773
295043
  const dropCapDescriptor = normalizeDropCap(resolvedParagraphProperties.framePr, para, converterContext);
@@ -294790,10 +295060,8 @@ menclose::after {
294790
295060
  keepLines: resolvedParagraphProperties.keepLines,
294791
295061
  floatAlignment,
294792
295062
  pageBreakBefore: resolvedParagraphProperties.pageBreakBefore,
294793
- ...normalizedDirection ? {
294794
- direction: normalizedDirection,
294795
- rtl: isRtl
294796
- } : {}
295063
+ ...normalizedDirection ? { direction: normalizedDirection } : {},
295064
+ directionContext
294797
295065
  };
294798
295066
  if (normalizedNumberingProperties && normalizedListRendering) {
294799
295067
  const markerRunAttrs = computeRunAttrs(resolveRunProperties(converterContext, resolvedParagraphProperties.runProperties, resolvedParagraphProperties, converterContext.tableInfo, true, Boolean(paragraphProperties.numberingProperties)), converterContext);
@@ -301447,12 +301715,12 @@ menclose::after {
301447
301715
  return;
301448
301716
  console.log(...args$1);
301449
301717
  }, 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(() => {
301718
+ var init_src_DOdRGHiA_es = __esm(() => {
301451
301719
  init_rolldown_runtime_Bg48TavK_es();
301452
- init_SuperConverter_CjDkqrj8_es();
301720
+ init_SuperConverter_BecdrRIX_es();
301453
301721
  init_jszip_C49i9kUs_es();
301454
301722
  init_uuid_qzgm05fK_es();
301455
- init_create_headless_toolbar_pGestihw_es();
301723
+ init_create_headless_toolbar_DCeIAH_W_es();
301456
301724
  init_constants_DrU4EASo_es();
301457
301725
  init_dist_B8HfvhaK_es();
301458
301726
  init_unified_Dsuw2be5_es();
@@ -319747,10 +320015,25 @@ function print() { __p += __j.call(arguments, '') }
319747
320015
  handleKeyDown(view, event) {
319748
320016
  if (view.composing || !editor.isEditable)
319749
320017
  return false;
319750
- if (event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End") {
320018
+ if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
319751
320019
  view.dispatch(view.state.tr.setMeta(VerticalNavigationPluginKey, { type: "reset-goal-x" }));
319752
320020
  return false;
319753
320021
  }
320022
+ if (event.key === "Home" || event.key === "End") {
320023
+ view.dispatch(view.state.tr.setMeta(VerticalNavigationPluginKey, { type: "reset-goal-x" }));
320024
+ if (!isPresenting(editor))
320025
+ return false;
320026
+ if (event.ctrlKey || event.metaKey || event.altKey)
320027
+ return false;
320028
+ const targetPos = resolveLineBoundaryPosition(editor, view.state.selection, event.key);
320029
+ if (!Number.isFinite(targetPos))
320030
+ return false;
320031
+ const selection$1 = buildSelection(view.state, targetPos, event.shiftKey);
320032
+ if (!selection$1)
320033
+ return false;
320034
+ view.dispatch(view.state.tr.setSelection(selection$1));
320035
+ return true;
320036
+ }
319754
320037
  if (event.key === "PageUp" || event.key === "PageDown") {
319755
320038
  view.dispatch(view.state.tr.setMeta(VerticalNavigationPluginKey, { type: "reset-goal-x" }));
319756
320039
  return false;
@@ -329348,6 +329631,7 @@ function print() { __p += __j.call(arguments, '') }
329348
329631
  const expandedRunsForBlock = expandRunsForInlineNewlines(block.runs);
329349
329632
  content3.lines.forEach((resolvedLine) => {
329350
329633
  const paragraphMarkLeftOffset = this.resolveResolvedListParagraphMarkOffset(resolvedLine.isListFirstLine ? resolvedMarker : undefined, fragment2.markerTextWidth, resolvedLine.indentOffset);
329634
+ const isRtl = block.attrs?.direction === "rtl";
329351
329635
  const lineEl = this.renderLine(block, resolvedLine.line, context, resolvedLine.availableWidth, resolvedLine.lineIndex, resolvedLine.skipJustify, expandedRunsForBlock, resolvedLine.resolvedListTextStartPx, resolvedLine.indentOffset, paragraphMarkLeftOffset);
329352
329636
  if (!resolvedLine.isListFirstLine) {
329353
329637
  if (resolvedLine.paddingLeftPx > 0)
@@ -329363,17 +329647,28 @@ function print() { __p += __j.call(arguments, '') }
329363
329647
  if (resolvedLine.paddingRightPx > 0)
329364
329648
  lineEl.style.paddingRight = `${resolvedLine.paddingRightPx}px`;
329365
329649
  if (resolvedLine.isListFirstLine && resolvedMarker) {
329366
- lineEl.style.paddingLeft = `${resolvedMarker.firstLinePaddingLeftPx}px`;
329650
+ if (isRtl)
329651
+ lineEl.style.paddingRight = `${resolvedMarker.firstLinePaddingLeftPx}px`;
329652
+ else
329653
+ lineEl.style.paddingLeft = `${resolvedMarker.firstLinePaddingLeftPx}px`;
329367
329654
  if (!resolvedMarker.vanish) {
329368
329655
  const markerContainer = createListMarkerElement(this.doc, resolvedMarker.text, resolvedMarker.run, resolvedMarker.sourceAnchor ?? resolvedItem?.sourceAnchor);
329369
329656
  markerContainer.style.position = "relative";
329370
329657
  if (resolvedMarker.justification === "right") {
329371
329658
  markerContainer.style.position = "absolute";
329372
- markerContainer.style.left = `${resolvedMarker.markerStartPx}px`;
329659
+ if (isRtl)
329660
+ markerContainer.style.right = `${resolvedMarker.markerStartPx}px`;
329661
+ else
329662
+ markerContainer.style.left = `${resolvedMarker.markerStartPx}px`;
329373
329663
  } else if (resolvedMarker.justification === "center") {
329374
329664
  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";
329665
+ if (isRtl) {
329666
+ markerContainer.style.right = `${resolvedMarker.markerStartPx - (resolvedMarker.centerPaddingAdjustPx ?? 0)}px`;
329667
+ lineEl.style.paddingRight = (parseFloat(lineEl.style.paddingRight || "0") + (resolvedMarker.centerPaddingAdjustPx ?? 0)).toString() + "px";
329668
+ } else {
329669
+ markerContainer.style.left = `${resolvedMarker.markerStartPx - (resolvedMarker.centerPaddingAdjustPx ?? 0)}px`;
329670
+ lineEl.style.paddingLeft = parseFloat(lineEl.style.paddingLeft) + (resolvedMarker.centerPaddingAdjustPx ?? 0) + "px";
329671
+ }
329377
329672
  }
329378
329673
  if (resolvedMarker.suffix === "tab") {
329379
329674
  const tabEl = this.doc.createElement("span");
@@ -329406,28 +329701,30 @@ function print() { __p += __j.call(arguments, '') }
329406
329701
  const paraIndent = block.attrs?.indent;
329407
329702
  const paraIndentLeft = paraIndent?.left ?? 0;
329408
329703
  const paraIndentRight = paraIndent?.right ?? 0;
329704
+ const isRtl = block.attrs?.direction === "rtl";
329705
+ const { anchorIndentPx: paraMarkerAnchorIndent, firstLinePx: markerFirstLine, hangingPx: markerHanging } = resolveMarkerIndent(paraIndent, isRtl);
329409
329706
  const firstLineOffset = block.attrs?.suppressFirstLineIndent === true ? 0 : (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
329410
329707
  const expandedRunsForBlock = expandRunsForInlineNewlines(block.runs);
329411
329708
  const paragraphEndsWithLineBreak = (block.runs.length > 0 ? block.runs[block.runs.length - 1] : null)?.kind === "lineBreak";
329412
329709
  const listFirstLineTextStartPx = !paraContinuesFromPrev && paraMarkerWidth && wordLayout?.marker ? resolvePainterListTextStartPx({
329413
329710
  wordLayout,
329414
- indentLeftPx: paraIndentLeft,
329415
- hangingIndentPx: paraIndent?.hanging ?? 0,
329416
- firstLineIndentPx: paraIndent?.firstLine ?? 0,
329711
+ indentLeftPx: paraMarkerAnchorIndent,
329712
+ hangingIndentPx: markerHanging,
329713
+ firstLineIndentPx: markerFirstLine,
329417
329714
  markerTextWidthPx: fragment2.markerTextWidth
329418
329715
  }) : undefined;
329419
329716
  const listFirstLineMarkerGeometry = !paraContinuesFromPrev && paraMarkerWidth && wordLayout?.marker?.justification === "left" && wordLayout.firstLineIndentMode !== true && typeof fragment2.markerTextWidth === "number" && Number.isFinite(fragment2.markerTextWidth) && fragment2.markerTextWidth >= 0 ? resolvePainterListMarkerGeometry({
329420
329717
  wordLayout,
329421
- indentLeftPx: paraIndentLeft,
329422
- hangingIndentPx: paraIndent?.hanging ?? 0,
329423
- firstLineIndentPx: paraIndent?.firstLine ?? 0,
329718
+ indentLeftPx: paraMarkerAnchorIndent,
329719
+ hangingIndentPx: markerHanging,
329720
+ firstLineIndentPx: markerFirstLine,
329424
329721
  markerTextWidthPx: fragment2.markerTextWidth
329425
329722
  }) : undefined;
329426
329723
  let listTabWidth = 0;
329427
329724
  let markerStartPos = 0;
329428
329725
  if (!paraContinuesFromPrev && paraMarkerWidth && wordLayout?.marker) {
329429
329726
  const markerTextWidth = fragment2.markerTextWidth;
329430
- const anchorPoint = paraIndentLeft - (paraIndent?.hanging ?? 0) + (paraIndent?.firstLine ?? 0);
329727
+ const anchorPoint = paraMarkerAnchorIndent - markerHanging + markerFirstLine;
329431
329728
  const markerJustification = wordLayout.marker.justification ?? "left";
329432
329729
  let currentPos;
329433
329730
  if (markerJustification === "left") {
@@ -329444,7 +329741,7 @@ function print() { __p += __j.call(arguments, '') }
329444
329741
  if (listFirstLineMarkerGeometry && (suffix === "tab" || suffix === "space"))
329445
329742
  listTabWidth = listFirstLineMarkerGeometry.suffixWidthPx;
329446
329743
  else if (suffix === "tab")
329447
- listTabWidth = computeTabWidth(currentPos, markerJustification, wordLayout.tabsPx, paraIndent?.hanging, paraIndent?.firstLine, paraIndentLeft);
329744
+ listTabWidth = computeTabWidth(currentPos, markerJustification, wordLayout.tabsPx, markerHanging, markerFirstLine, paraMarkerAnchorIndent);
329448
329745
  else if (suffix === "space")
329449
329746
  listTabWidth = 4;
329450
329747
  }
@@ -329486,18 +329783,30 @@ function print() { __p += __j.call(arguments, '') }
329486
329783
  const marker = wordLayout?.marker;
329487
329784
  if (!marker)
329488
329785
  return;
329489
- lineEl.style.paddingLeft = `${paraIndentLeft + (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0)}px`;
329786
+ const firstLineIndent = paraMarkerAnchorIndent - markerHanging + markerFirstLine;
329787
+ if (isRtl)
329788
+ lineEl.style.paddingRight = `${firstLineIndent}px`;
329789
+ else
329790
+ lineEl.style.paddingLeft = `${firstLineIndent}px`;
329490
329791
  if (!marker.run.vanish) {
329491
329792
  const markerContainer = createListMarkerElement(this.doc, marker.markerText ?? "", marker.run, block.sourceAnchor ?? resolvedItem?.sourceAnchor);
329492
329793
  const markerJustification = marker.justification ?? "left";
329493
329794
  markerContainer.style.position = "relative";
329494
329795
  if (markerJustification === "right") {
329495
329796
  markerContainer.style.position = "absolute";
329496
- markerContainer.style.left = `${markerStartPos}px`;
329797
+ if (isRtl)
329798
+ markerContainer.style.right = `${markerStartPos}px`;
329799
+ else
329800
+ markerContainer.style.left = `${markerStartPos}px`;
329497
329801
  } else if (markerJustification === "center") {
329498
329802
  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";
329803
+ if (isRtl) {
329804
+ markerContainer.style.right = `${markerStartPos - fragment2.markerTextWidth / 2}px`;
329805
+ lineEl.style.paddingRight = (parseFloat(lineEl.style.paddingRight || "0") + fragment2.markerTextWidth / 2).toString() + "px";
329806
+ } else {
329807
+ markerContainer.style.left = `${markerStartPos - fragment2.markerTextWidth / 2}px`;
329808
+ lineEl.style.paddingLeft = parseFloat(lineEl.style.paddingLeft) + fragment2.markerTextWidth / 2 + "px";
329809
+ }
329501
329810
  }
329502
329811
  const suffix = marker.suffix ?? "tab";
329503
329812
  if (suffix === "tab") {
@@ -334598,7 +334907,8 @@ function print() { __p += __j.call(arguments, '') }
334598
334907
  x: localX,
334599
334908
  y: localY
334600
334909
  };
334601
- const hit = clickToPositionGeometry(context.layout, context.blocks, context.measures, headerPoint) ?? null;
334910
+ const geometryHit = clickToPositionGeometry(context.layout, context.blocks, context.measures, headerPoint) ?? null;
334911
+ const hit = this.#resolveHeaderFooterDomHit(context, clientX, clientY) ?? geometryHit;
334602
334912
  if (!hit)
334603
334913
  return null;
334604
334914
  const doc$2 = this.getActiveEditor().state?.doc;
@@ -337677,6 +337987,63 @@ function print() { __p += __j.call(arguments, '') }
337677
337987
  lineIndex: -1
337678
337988
  };
337679
337989
  }
337990
+ #resolveHeaderFooterDomHit(context, clientX, clientY) {
337991
+ const layout = this.#layoutState.layout;
337992
+ if (!layout)
337993
+ return null;
337994
+ const blockIds = new Set(context.blocks.map((block) => block.id).filter((id2) => typeof id2 === "string" && id2.length > 0));
337995
+ if (blockIds.size === 0)
337996
+ return null;
337997
+ const doc$12 = this.#viewportHost.ownerDocument ?? document;
337998
+ const elementsFromPoint = typeof doc$12.elementsFromPoint === "function" ? doc$12.elementsFromPoint.bind(doc$12) : null;
337999
+ const tryResolve = (element3, enforceKnownBlockIds = true) => {
338000
+ const fragmentElement = element3 instanceof HTMLElement ? element3.closest("[data-block-id]") : null;
338001
+ const blockId = fragmentElement?.getAttribute("data-block-id") ?? "";
338002
+ if (!fragmentElement)
338003
+ return null;
338004
+ if (enforceKnownBlockIds && !blockIds.has(blockId))
338005
+ return null;
338006
+ const pos = resolvePositionWithinFragmentDom(fragmentElement, clientX, clientY);
338007
+ if (pos == null)
338008
+ return null;
338009
+ return {
338010
+ pos,
338011
+ layoutEpoch: readLayoutEpochFromDom(fragmentElement, clientX, clientY) ?? layout.layoutEpoch ?? 0,
338012
+ blockId,
338013
+ pageIndex: this.#resolveRenderedPageIndexForElement(fragmentElement),
338014
+ column: 0,
338015
+ lineIndex: -1
338016
+ };
338017
+ };
338018
+ if (elementsFromPoint) {
338019
+ for (const element3 of elementsFromPoint(clientX, clientY)) {
338020
+ const hit = tryResolve(element3, true);
338021
+ if (hit)
338022
+ return hit;
338023
+ }
338024
+ for (const element3 of elementsFromPoint(clientX, clientY)) {
338025
+ if (!element3.closest(".superdoc-page-header, .superdoc-page-footer"))
338026
+ continue;
338027
+ const hit = tryResolve(element3, false);
338028
+ if (hit)
338029
+ return hit;
338030
+ }
338031
+ }
338032
+ const surfaceSelector = context.region.kind === "footer" ? ".superdoc-page-footer" : ".superdoc-page-header";
338033
+ const surface = getPageElementByIndex(this.#viewportHost, context.region.pageIndex)?.querySelector(surfaceSelector) ?? null;
338034
+ if (surface instanceof HTMLElement) {
338035
+ const fragments = Array.from(surface.querySelectorAll(".superdoc-fragment"));
338036
+ for (const fragment2 of fragments) {
338037
+ const rect = fragment2.getBoundingClientRect();
338038
+ if (clientX < rect.left || clientX > rect.right || clientY < rect.top || clientY > rect.bottom)
338039
+ continue;
338040
+ const hit = tryResolve(fragment2, false);
338041
+ if (hit)
338042
+ return hit;
338043
+ }
338044
+ }
338045
+ return null;
338046
+ }
337680
338047
  #createCollapsedSelectionNearInlineContent(doc$12, pos) {
337681
338048
  const clampedPos = Math.max(0, Math.min(pos, doc$12.content.size));
337682
338049
  const directSelection = TextSelection.create(doc$12, clampedPos);
@@ -339196,11 +339563,11 @@ function print() { __p += __j.call(arguments, '') }
339196
339563
  ];
339197
339564
  });
339198
339565
 
339199
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-Cj3mqS9_.es.js
339566
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-fxrCn5X_.es.js
339200
339567
  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();
339568
+ var init_create_super_doc_ui_fxrCn5X__es = __esm(() => {
339569
+ init_SuperConverter_BecdrRIX_es();
339570
+ init_create_headless_toolbar_DCeIAH_W_es();
339204
339571
  MOD_ALIASES = new Set([
339205
339572
  "Mod",
339206
339573
  "Meta",
@@ -339242,16 +339609,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
339242
339609
 
339243
339610
  // ../../packages/superdoc/dist/super-editor.es.js
339244
339611
  var init_super_editor_es = __esm(() => {
339245
- init_src_tOywM1hR_es();
339246
- init_SuperConverter_CjDkqrj8_es();
339612
+ init_src_DOdRGHiA_es();
339613
+ init_SuperConverter_BecdrRIX_es();
339247
339614
  init_jszip_C49i9kUs_es();
339248
339615
  init_xml_js_CqGKpaft_es();
339249
- init_create_headless_toolbar_pGestihw_es();
339616
+ init_create_headless_toolbar_DCeIAH_W_es();
339250
339617
  init_constants_DrU4EASo_es();
339251
339618
  init_dist_B8HfvhaK_es();
339252
339619
  init_unified_Dsuw2be5_es();
339253
339620
  init_DocxZipper_Dh4RtvcE_es();
339254
- init_create_super_doc_ui_Cj3mqS9__es();
339621
+ init_create_super_doc_ui_fxrCn5X__es();
339255
339622
  init_ui_CGB3qmy3_es();
339256
339623
  init_eventemitter3_UwU_CLPU_es();
339257
339624
  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.88",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -24,21 +24,21 @@
24
24
  "@types/node": "22.19.2",
25
25
  "@types/ws": "^8.5.13",
26
26
  "typescript": "^5.9.2",
27
- "@superdoc/pm-adapter": "0.0.0",
28
- "@superdoc/super-editor": "0.0.1",
29
27
  "@superdoc/document-api": "0.0.1",
30
- "superdoc": "1.31.0"
28
+ "superdoc": "1.31.0",
29
+ "@superdoc/pm-adapter": "0.0.0",
30
+ "@superdoc/super-editor": "0.0.1"
31
31
  },
32
32
  "module": "src/index.ts",
33
33
  "publishConfig": {
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.88",
38
+ "@superdoc-dev/cli-darwin-x64": "0.8.0-next.88",
39
+ "@superdoc-dev/cli-linux-arm64": "0.8.0-next.88",
40
+ "@superdoc-dev/cli-linux-x64": "0.8.0-next.88",
41
+ "@superdoc-dev/cli-windows-x64": "0.8.0-next.88"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",