@superdoc-dev/cli 0.5.0-next.7 → 0.5.0-next.9

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 +266 -125
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -62964,7 +62964,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
62964
62964
  emptyOptions2 = {};
62965
62965
  });
62966
62966
 
62967
- // ../../packages/superdoc/dist/chunks/SuperConverter-CXcZg9Os.es.js
62967
+ // ../../packages/superdoc/dist/chunks/SuperConverter-CTUnwu05.es.js
62968
62968
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
62969
62969
  const fieldValue = extension$1.config[field];
62970
62970
  if (typeof fieldValue === "function")
@@ -72691,6 +72691,17 @@ function generateParagraphProperties(params3) {
72691
72691
  const { node: node3 } = params3;
72692
72692
  const { attrs = {} } = node3;
72693
72693
  const paragraphProperties = carbonCopy(attrs.paragraphProperties || {});
72694
+ const inlineKeys = paragraphProperties.runPropertiesInlineKeys;
72695
+ delete paragraphProperties.runPropertiesInlineKeys;
72696
+ if (Array.isArray(inlineKeys) && inlineKeys.length === 0)
72697
+ delete paragraphProperties.runProperties;
72698
+ else if (Array.isArray(inlineKeys) && paragraphProperties.runProperties) {
72699
+ const filtered = Object.fromEntries(inlineKeys.filter((k) => (k in paragraphProperties.runProperties)).map((k) => [k, paragraphProperties.runProperties[k]]));
72700
+ if (Object.keys(filtered).length > 0)
72701
+ paragraphProperties.runProperties = filtered;
72702
+ else
72703
+ delete paragraphProperties.runProperties;
72704
+ }
72694
72705
  let pPr = translator$126.decode({ node: {
72695
72706
  ...node3,
72696
72707
  attrs: { paragraphProperties }
@@ -72754,7 +72765,13 @@ function mergeConsecutiveTrackedChanges(elements) {
72754
72765
  return result;
72755
72766
  }
72756
72767
  function translateParagraphNode(params3) {
72757
- let elements = translateChildNodes(params3);
72768
+ let elements = translateChildNodes({
72769
+ ...params3,
72770
+ extraParams: {
72771
+ ...params3.extraParams,
72772
+ paragraphProperties: params3.node?.attrs?.paragraphProperties
72773
+ }
72774
+ });
72758
72775
  elements = mergeConsecutiveTrackedChanges(elements);
72759
72776
  const htmlAnnotationChild = elements.find((element) => element.name === "htmlAnnotation");
72760
72777
  if (htmlAnnotationChild)
@@ -72841,6 +72858,45 @@ function _addNewLinkRelationship(params3, link2) {
72841
72858
  });
72842
72859
  return `rId${id2}`;
72843
72860
  }
72861
+ function getParagraphStyleRunPropertiesFromStylesXml(docx, styleId, params3) {
72862
+ const stylesPart = docx?.[STYLES_KEY];
72863
+ if (!stylesPart?.elements?.[0]?.elements)
72864
+ return {};
72865
+ const styleElements = stylesPart.elements[0].elements.filter((el) => el.name === "w:style");
72866
+ const styleById = new Map(styleElements.map((el) => [el.attributes?.["w:styleId"], el]));
72867
+ const chain = [];
72868
+ let currentId = styleId;
72869
+ const seen = /* @__PURE__ */ new Set;
72870
+ while (currentId && !seen.has(currentId)) {
72871
+ seen.add(currentId);
72872
+ const styleTag = styleById.get(currentId);
72873
+ if (!styleTag)
72874
+ break;
72875
+ const rPr = styleTag.elements?.find((el) => el.name === "w:rPr");
72876
+ if (rPr?.elements?.length)
72877
+ chain.push(rPr);
72878
+ currentId = styleTag.elements?.find((el) => el.name === "w:basedOn")?.attributes?.["w:val"];
72879
+ }
72880
+ if (chain.length === 0)
72881
+ return {};
72882
+ const byName = {};
72883
+ chain.reverse().forEach((rPr) => {
72884
+ (rPr.elements || []).forEach((el) => {
72885
+ if (el?.name)
72886
+ byName[el.name] = el;
72887
+ });
72888
+ });
72889
+ const mergedRPr = {
72890
+ name: "w:rPr",
72891
+ elements: Object.values(byName)
72892
+ };
72893
+ const encodeParams = {
72894
+ ...params3,
72895
+ docx: params3.docx ?? docx,
72896
+ nodes: [mergedRPr]
72897
+ };
72898
+ return translator$129.encode(encodeParams) ?? {};
72899
+ }
72844
72900
  function handleTableCellNode({ params: params3, node: node3, table, row, tableProperties, columnIndex, columnWidth = null, allColumnWidths = [], preferTableGridWidths = false, _referencedStyles }) {
72845
72901
  const { nodeListHandler } = params3;
72846
72902
  const attributes = {};
@@ -72855,6 +72911,7 @@ function handleTableCellNode({ params: params3, node: node3, table, row, tablePr
72855
72911
  nodes: [tcPr]
72856
72912
  }) ?? {} : {};
72857
72913
  attributes["tableCellProperties"] = tableCellProperties;
72914
+ attributes["tableCellPropertiesInlineKeys"] = Object.keys(tableCellProperties);
72858
72915
  const colspan = parseInt(tableCellProperties.gridSpan || 1, 10);
72859
72916
  if (colspan > 1)
72860
72917
  attributes["colspan"] = colspan;
@@ -73037,6 +73094,7 @@ function translateTableCell(params3) {
73037
73094
  }
73038
73095
  function generateTableCellProperties(node3) {
73039
73096
  let tableCellProperties = { ...node3.attrs?.tableCellProperties || {} };
73097
+ const inlineKeys = node3.attrs?.tableCellPropertiesInlineKeys;
73040
73098
  const { attrs } = node3;
73041
73099
  const { colwidth: rawColwidth, widthUnit = "px" } = attrs;
73042
73100
  const resolvedWidthType = attrs.cellWidthType ?? (attrs.widthType !== "auto" ? attrs.widthType : undefined) ?? tableCellProperties.cellWidth?.type ?? "dxa";
@@ -73060,7 +73118,7 @@ function generateTableCellProperties(node3) {
73060
73118
  else if (!background?.color && tableCellProperties?.shading?.fill)
73061
73119
  delete tableCellProperties.shading;
73062
73120
  const { cellMargins } = attrs;
73063
- if (cellMargins)
73121
+ if (cellMargins && (!Array.isArray(inlineKeys) || inlineKeys.includes("cellMargins")))
73064
73122
  [
73065
73123
  "left",
73066
73124
  "right",
@@ -89276,11 +89334,14 @@ function _getReferencedTableStyles(tableStyleReference, params3) {
89276
89334
  }
89277
89335
  const tblPr = styleTag.elements.find((el) => el.name === "w:tblPr");
89278
89336
  if (tblPr && tblPr.elements) {
89279
- if (baseTblPr && baseTblPr.elements)
89280
- tblPr.elements = [...baseTblPr.elements, ...tblPr.elements];
89337
+ const mergedTblPr = baseTblPr?.elements?.length > 0 ? {
89338
+ name: tblPr.name,
89339
+ attributes: tblPr.attributes,
89340
+ elements: [...baseTblPr.elements, ...tblPr.elements]
89341
+ } : tblPr;
89281
89342
  const tableProperties = translator$163.encode({
89282
89343
  ...params3,
89283
- nodes: [tblPr]
89344
+ nodes: [mergedTblPr]
89284
89345
  });
89285
89346
  if (tableProperties) {
89286
89347
  const borders = _processTableBorders(tableProperties.borders || {});
@@ -99251,11 +99312,14 @@ var isRegExp = (value) => {
99251
99312
  let schemaNode;
99252
99313
  const pPr = node3.elements?.find((el) => el.name === "w:pPr");
99253
99314
  let inlineParagraphProperties = {};
99254
- if (pPr)
99315
+ if (pPr) {
99255
99316
  inlineParagraphProperties = translator$126.encode({
99256
99317
  ...params3,
99257
99318
  nodes: [pPr]
99258
99319
  }) || {};
99320
+ if (inlineParagraphProperties.runProperties && typeof inlineParagraphProperties.runProperties === "object")
99321
+ inlineParagraphProperties.runPropertiesInlineKeys = Object.keys(inlineParagraphProperties.runProperties);
99322
+ }
99259
99323
  const tableStyleId = getTableStyleId(params3.path || []);
99260
99324
  const resolvedParagraphProperties = resolveParagraphProperties(params3, inlineParagraphProperties, { tableStyleId });
99261
99325
  const { elements = [], attributes = {}, marks = [] } = parseProperties(node3, params3.docx);
@@ -99634,7 +99698,7 @@ var isRegExp = (value) => {
99634
99698
  return attributes["w:rsidDel"];
99635
99699
  }, decode$53 = (attrs) => {
99636
99700
  return attrs.rsidDel;
99637
- }, attributes_default$4, XML_NODE_NAME$33 = "w:r", SD_KEY_NAME = "run", REFERENCE_RUN_STYLE_BY_XML_NAME, hasXmlNodeNamed = (node3, targetName) => {
99701
+ }, attributes_default$4, STYLES_KEY = "word/styles.xml", XML_NODE_NAME$33 = "w:r", SD_KEY_NAME = "run", REFERENCE_RUN_STYLE_BY_XML_NAME, hasXmlNodeNamed = (node3, targetName) => {
99638
99702
  if (!node3 || typeof node3 !== "object")
99639
99703
  return false;
99640
99704
  if (node3.name === targetName)
@@ -99701,13 +99765,16 @@ var isRegExp = (value) => {
99701
99765
  name: "w:vertAlign",
99702
99766
  attributes: { "w:val": "superscript" }
99703
99767
  });
99704
- }, createRunNodeWithContent = (content$2, encodedAttrs, runLevelMarks, runProperties) => {
99768
+ }, createRunNodeWithContent = (content$2, encodedAttrs, runLevelMarks, resolvedRunProperties, inlineKeysFromCombine, runPropertiesStyleKeys = null, runPropertiesOverrideKeys = null) => {
99705
99769
  const node3 = {
99706
99770
  type: SD_KEY_NAME,
99707
99771
  content: content$2,
99708
99772
  attrs: {
99709
99773
  ...encodedAttrs,
99710
- runProperties
99774
+ runProperties: resolvedRunProperties,
99775
+ runPropertiesInlineKeys: inlineKeysFromCombine,
99776
+ runPropertiesStyleKeys: runPropertiesStyleKeys?.length ? runPropertiesStyleKeys : null,
99777
+ runPropertiesOverrideKeys: runPropertiesOverrideKeys?.length ? runPropertiesOverrideKeys : null
99711
99778
  }
99712
99779
  };
99713
99780
  if (runLevelMarks.length)
@@ -99720,10 +99787,11 @@ var isRegExp = (value) => {
99720
99787
  return;
99721
99788
  const elements = Array.isArray(runNode.elements) ? runNode.elements : [];
99722
99789
  const rPrNode = elements.find((child) => child?.name === "w:rPr");
99723
- const runProperties = rPrNode ? translator$129.encode({
99790
+ const encodedRunProperties = (rPrNode ? translator$129.encode({
99724
99791
  ...params3,
99725
99792
  nodes: [rPrNode]
99726
- }) : {};
99793
+ }) : undefined) ?? {};
99794
+ const runPropertiesInlineKeysFromCombine = Object.keys(encodedRunProperties);
99727
99795
  const paragraphProperties = params3?.extraParams?.paragraphProperties || {};
99728
99796
  let tableInfo = null;
99729
99797
  if (params3?.extraParams?.rowIndex != null && params3?.extraParams?.columnIndex != null && params3?.extraParams?.tableProperties != null && params3?.extraParams?.totalColumns != null && params3?.extraParams?.totalRows != null)
@@ -99734,7 +99802,8 @@ var isRegExp = (value) => {
99734
99802
  numCells: params3.extraParams.totalColumns,
99735
99803
  numRows: params3.extraParams.totalRows
99736
99804
  };
99737
- const marksResult = encodeMarksFromRPr(resolveRunProperties(params3, runProperties ?? {}, paragraphProperties, tableInfo, false, params3?.extraParams?.numberingDefinedInline), params3?.docx);
99805
+ const resolvedRunProperties = resolveRunProperties(params3, encodedRunProperties, paragraphProperties, tableInfo, false, params3?.extraParams?.numberingDefinedInline);
99806
+ const marksResult = encodeMarksFromRPr(resolvedRunProperties, params3?.docx);
99738
99807
  const marks = Array.isArray(marksResult) ? marksResult : [];
99739
99808
  const rPrChange = rPrNode?.elements?.find((el) => el.name === "w:rPrChange");
99740
99809
  const styleChangeMarks = handleStyleChangeMarksV2(rPrChange, marks, params3) || [];
@@ -99786,14 +99855,21 @@ var isRegExp = (value) => {
99786
99855
  marks: childMarks
99787
99856
  };
99788
99857
  }).filter(Boolean);
99858
+ let runPropertiesStyleKeys = null;
99859
+ if (encodedRunProperties?.styleId && params3?.docx) {
99860
+ const styleRPr = getParagraphStyleRunPropertiesFromStylesXml(params3.docx, encodedRunProperties.styleId, params3);
99861
+ if (styleRPr && Object.keys(styleRPr).length > 0)
99862
+ runPropertiesStyleKeys = Object.keys(styleRPr);
99863
+ }
99864
+ const runPropertiesOverrideKeys = runPropertiesStyleKeys?.length && runPropertiesInlineKeysFromCombine?.length ? runPropertiesInlineKeysFromCombine.filter((k) => runPropertiesStyleKeys.includes(k)) : null;
99789
99865
  if (!filtered.some((child) => child?.type === "lineBreak"))
99790
- return createRunNodeWithContent(filtered, encodedAttrs, runLevelMarks, runProperties);
99866
+ return createRunNodeWithContent(filtered, encodedAttrs, runLevelMarks, resolvedRunProperties, runPropertiesInlineKeysFromCombine, runPropertiesStyleKeys, runPropertiesOverrideKeys);
99791
99867
  const splitRuns = [];
99792
99868
  let currentChunk = [];
99793
99869
  const finalizeTextChunk = () => {
99794
99870
  if (!currentChunk.length)
99795
99871
  return;
99796
- const chunkNode = createRunNodeWithContent(currentChunk, encodedAttrs, runLevelMarks, runProperties);
99872
+ const chunkNode = createRunNodeWithContent(currentChunk, encodedAttrs, runLevelMarks, resolvedRunProperties, runPropertiesInlineKeysFromCombine, runPropertiesStyleKeys, runPropertiesOverrideKeys);
99797
99873
  if (chunkNode)
99798
99874
  splitRuns.push(chunkNode);
99799
99875
  currentChunk = [];
@@ -99801,7 +99877,7 @@ var isRegExp = (value) => {
99801
99877
  filtered.forEach((child) => {
99802
99878
  if (child?.type === "lineBreak") {
99803
99879
  finalizeTextChunk();
99804
- const breakNode = createRunNodeWithContent([child], encodedAttrs, runLevelMarks, runProperties);
99880
+ const breakNode = createRunNodeWithContent([child], encodedAttrs, runLevelMarks, resolvedRunProperties, runPropertiesInlineKeysFromCombine, runPropertiesStyleKeys, runPropertiesOverrideKeys);
99805
99881
  if (breakNode)
99806
99882
  splitRuns.push(breakNode);
99807
99883
  } else
@@ -99825,7 +99901,15 @@ var isRegExp = (value) => {
99825
99901
  }
99826
99902
  const { runNode: runNodeForExport, trackingMarksByType } = prepareRunTrackingContext(node3);
99827
99903
  const runTrackFormatMark = findTrackFormatMark(runNodeForExport.marks);
99828
- const runProperties = (runNodeForExport.attrs || {}).runProperties || {};
99904
+ const runAttrs = runNodeForExport.attrs || {};
99905
+ const runProperties = runAttrs.runProperties || {};
99906
+ const inlineKeys = runAttrs.runPropertiesInlineKeys;
99907
+ const styleKeys = runAttrs.runPropertiesStyleKeys;
99908
+ const overrideKeys = runAttrs.runPropertiesOverrideKeys;
99909
+ const candidateKeys = inlineKeys != null ? [...new Set([...inlineKeys || [], ...overrideKeys || []])] : Object.keys(runProperties);
99910
+ const shouldExport = (key) => (key in (runProperties || {})) && (!(Array.isArray(styleKeys) && styleKeys.includes(key)) || Array.isArray(overrideKeys) && overrideKeys.includes(key));
99911
+ const exportKeys = candidateKeys.filter(shouldExport);
99912
+ const runPropertiesToExport = exportKeys.length > 0 ? Object.fromEntries(exportKeys.map((k) => [k, runProperties[k]])) : {};
99829
99913
  const exportParams = {
99830
99914
  ...params3,
99831
99915
  node: runNodeForExport,
@@ -99837,10 +99921,10 @@ var isRegExp = (value) => {
99837
99921
  if (!exportParams.editor)
99838
99922
  exportParams.editor = { extensionService: { extensions: [] } };
99839
99923
  const childElements = translateChildNodes(exportParams) || [];
99840
- let runPropertiesElement = translator$129.decode({
99924
+ let runPropertiesElement = Object.keys(runPropertiesToExport).length > 0 ? translator$129.decode({
99841
99925
  ...params3,
99842
- node: { attrs: { runProperties } }
99843
- });
99926
+ node: { attrs: { runProperties: runPropertiesToExport } }
99927
+ }) : null;
99844
99928
  const runPropsTemplate = runPropertiesElement ? cloneXmlNode(runPropertiesElement) : null;
99845
99929
  const applyBaseRunProps = (runNode) => applyRunPropertiesTemplate(runNode, runPropsTemplate);
99846
99930
  const replaceRunProps = (runNode) => {
@@ -107347,19 +107431,35 @@ var isRegExp = (value) => {
107347
107431
  return;
107348
107432
  const { segments, firstInlineProps } = segmentRunByInlineProps(runNode, paragraphNode, tableInfo, $pos, editor, preservedDerivedKeys, preferExistingKeys);
107349
107433
  const runProperties = firstInlineProps ?? null;
107434
+ const existingInlineKeys = runNode.attrs?.runPropertiesInlineKeys || [];
107435
+ const styleKeys = runNode.attrs?.runPropertiesStyleKeys || [];
107436
+ const keysFromMarks = (segment) => {
107437
+ const textNode = segment.content?.find((n) => n.isText);
107438
+ return Object.keys(decodeRPrFromMarks(textNode?.marks || []));
107439
+ };
107440
+ const overrideKeysFromInlineProps = (inlineProps) => styleKeys.filter((k) => inlineProps && (k in inlineProps));
107350
107441
  if (segments.length === 1) {
107351
- if (JSON.stringify(runProperties) === JSON.stringify(runNode.attrs.runProperties))
107442
+ const hadInlineKeys = Array.isArray(runNode.attrs?.runPropertiesInlineKeys) && runNode.attrs.runPropertiesInlineKeys.length > 0;
107443
+ if (JSON.stringify(runProperties) === JSON.stringify(runNode.attrs.runProperties) && hadInlineKeys)
107352
107444
  return;
107445
+ const newInlineKeys = [...new Set([...existingInlineKeys, ...keysFromMarks(segments[0])])];
107446
+ const newOverrideKeys = overrideKeysFromInlineProps(runProperties);
107353
107447
  tr.setNodeMarkup(mappedPos, runNode.type, {
107354
107448
  ...runNode.attrs,
107355
- runProperties
107449
+ runProperties,
107450
+ runPropertiesInlineKeys: newInlineKeys.length ? newInlineKeys : null,
107451
+ runPropertiesOverrideKeys: newOverrideKeys.length ? newOverrideKeys : null
107356
107452
  }, runNode.marks);
107357
107453
  } else {
107358
107454
  const newRuns = segments.map((segment) => {
107359
107455
  const props = segment.inlineProps ?? null;
107456
+ const segmentInlineKeys = [...new Set([...existingInlineKeys, ...keysFromMarks(segment)])];
107457
+ const segmentOverrideKeys = overrideKeysFromInlineProps(props);
107360
107458
  return runType.create({
107361
107459
  ...runNode.attrs ?? {},
107362
- runProperties: props
107460
+ runProperties: props,
107461
+ runPropertiesInlineKeys: segmentInlineKeys.length ? segmentInlineKeys : null,
107462
+ runPropertiesOverrideKeys: segmentOverrideKeys.length ? segmentOverrideKeys : null
107363
107463
  }, Fragment.fromArray(segment.content), runNode.marks);
107364
107464
  });
107365
107465
  const replacement = Fragment.fromArray(newRuns);
@@ -113235,7 +113335,7 @@ var isRegExp = (value) => {
113235
113335
  state.kern = kernNode.attributes["w:val"];
113236
113336
  }
113237
113337
  }, SuperConverter;
113238
- var init_SuperConverter_CXcZg9Os_es = __esm(() => {
113338
+ var init_SuperConverter_CTUnwu05_es = __esm(() => {
113239
113339
  init_rolldown_runtime_B2q5OVn9_es();
113240
113340
  init_jszip_ChlR43oI_es();
113241
113341
  init_xml_js_40FWvL78_es();
@@ -171536,7 +171636,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
171536
171636
  init_remark_gfm_z_sDF4ss_es();
171537
171637
  });
171538
171638
 
171539
- // ../../packages/superdoc/dist/chunks/src-D9hI0nIy.es.js
171639
+ // ../../packages/superdoc/dist/chunks/src-2Droteg9.es.js
171540
171640
  function deleteProps(obj, propOrProps) {
171541
171641
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
171542
171642
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -196876,8 +196976,20 @@ function applyRunAttributePatch(tr, runType, absFrom, absTo, updates) {
196876
196976
  const patchTo = Math.min(mappedTo, runContentTo);
196877
196977
  if (patchFrom >= patchTo)
196878
196978
  continue;
196879
- const nextRunProperties = { ...isRecord$12(runNode.attrs?.runProperties) ? { ...runNode.attrs.runProperties } : {} };
196979
+ const currentRunProperties = isRecord$12(runNode.attrs?.runProperties) ? { ...runNode.attrs.runProperties } : {};
196980
+ const currentStyleKeys = Array.isArray(runNode.attrs?.runPropertiesStyleKeys) ? runNode.attrs.runPropertiesStyleKeys : [];
196981
+ const currentOverrideKeys = Array.isArray(runNode.attrs?.runPropertiesOverrideKeys) ? runNode.attrs.runPropertiesOverrideKeys : [];
196982
+ const hasInlineOwnershipMetadata = Array.isArray(runNode.attrs?.runPropertiesInlineKeys);
196983
+ let currentInlineKeys;
196984
+ if (hasInlineOwnershipMetadata)
196985
+ currentInlineKeys = runNode.attrs.runPropertiesInlineKeys;
196986
+ else if (currentStyleKeys.length > 0)
196987
+ currentInlineKeys = [...new Set([...Object.keys(currentRunProperties).filter((key$1) => !currentStyleKeys.includes(key$1)), ...currentOverrideKeys])];
196988
+ else
196989
+ currentInlineKeys = Object.keys(currentRunProperties);
196990
+ const nextRunProperties = { ...currentRunProperties };
196880
196991
  let runChanged = false;
196992
+ const changedRunPropertyKeys = /* @__PURE__ */ new Set;
196881
196993
  for (const [runPropertyKey, patchValue] of Object.entries(updates)) {
196882
196994
  const existingValue = nextRunProperties[runPropertyKey];
196883
196995
  const mergeResult = mergeRunAttributeValue(existingValue, patchValue);
@@ -196888,14 +197000,19 @@ function applyRunAttributePatch(tr, runType, absFrom, absTo, updates) {
196888
197000
  else
196889
197001
  nextRunProperties[runPropertyKey] = mergeResult.nextValue;
196890
197002
  runChanged = true;
197003
+ changedRunPropertyKeys.add(runPropertyKey);
196891
197004
  }
196892
197005
  if (!runChanged)
196893
197006
  continue;
196894
197007
  const normalizedNextRunProperties = Object.keys(nextRunProperties).length > 0 ? nextRunProperties : null;
197008
+ const nextInlineKeys = [...new Set([...currentInlineKeys.filter((key$1) => normalizedNextRunProperties && (key$1 in normalizedNextRunProperties)), ...[...changedRunPropertyKeys].filter((key$1) => normalizedNextRunProperties && (key$1 in normalizedNextRunProperties))])];
197009
+ const nextOverrideKeys = [...new Set([...currentOverrideKeys.filter((key$1) => normalizedNextRunProperties && (key$1 in normalizedNextRunProperties) && currentStyleKeys.includes(key$1)), ...[...changedRunPropertyKeys].filter((key$1) => normalizedNextRunProperties && (key$1 in normalizedNextRunProperties) && currentStyleKeys.includes(key$1))])];
196895
197010
  if (patchFrom === runContentFrom && patchTo === runContentTo) {
196896
197011
  tr.setNodeMarkup(runPos, runNode.type, {
196897
197012
  ...runNode.attrs,
196898
- runProperties: normalizedNextRunProperties
197013
+ runProperties: normalizedNextRunProperties,
197014
+ runPropertiesInlineKeys: nextInlineKeys.length ? nextInlineKeys : null,
197015
+ runPropertiesOverrideKeys: nextOverrideKeys.length ? nextOverrideKeys : null
196899
197016
  }, runNode.marks);
196900
197017
  changed = true;
196901
197018
  continue;
@@ -196912,7 +197029,9 @@ function applyRunAttributePatch(tr, runType, absFrom, absTo, updates) {
196912
197029
  const middleContent = runNode.content.cut(relativeFrom, relativeTo);
196913
197030
  replacementRuns.push(runType.create({
196914
197031
  ...runNode.attrs,
196915
- runProperties: normalizedNextRunProperties
197032
+ runProperties: normalizedNextRunProperties,
197033
+ runPropertiesInlineKeys: nextInlineKeys.length ? nextInlineKeys : null,
197034
+ runPropertiesOverrideKeys: nextOverrideKeys.length ? nextOverrideKeys : null
196916
197035
  }, middleContent, runNode.marks));
196917
197036
  if (relativeTo < runNode.content.size) {
196918
197037
  const rightContent = runNode.content.cut(relativeTo, runNode.content.size);
@@ -217329,6 +217448,12 @@ function findCharacterAtX(block, line, x, pmStart, availableWidthOverride, align
217329
217448
  pmPosition
217330
217449
  };
217331
217450
  }
217451
+ function isRtlLine(lineEl) {
217452
+ return getComputedStyle(lineEl).direction === "rtl";
217453
+ }
217454
+ function isVisibleRect(rect) {
217455
+ return rect.width > 0 && rect.height > 0;
217456
+ }
217332
217457
  function clickToPositionDom(domContainer, clientX, clientY) {
217333
217458
  log2("=== clickToPositionDom START ===");
217334
217459
  log2("Input coords:", {
@@ -217533,64 +217658,7 @@ function processFragment(fragmentEl, viewX, viewY) {
217533
217658
  }
217534
217659
  };
217535
217660
  }));
217536
- if (spanEls.length === 0) {
217537
- log2("No spans in line, returning lineStart:", lineStart);
217538
- return lineStart;
217539
- }
217540
- if (viewX <= spanEls[0].getBoundingClientRect().left) {
217541
- log2("Click before first span, returning lineStart:", lineStart);
217542
- return lineStart;
217543
- }
217544
- if (viewX >= spanEls[spanEls.length - 1].getBoundingClientRect().right) {
217545
- log2("Click after last span, returning lineEnd:", lineEnd);
217546
- return lineEnd;
217547
- }
217548
- const targetEl = findSpanAtX(spanEls, viewX);
217549
- if (!targetEl) {
217550
- log2("No target element found, returning lineStart:", lineStart);
217551
- return lineStart;
217552
- }
217553
- const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
217554
- const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
217555
- const targetRect = targetEl.getBoundingClientRect();
217556
- log2("Target element:", {
217557
- tag: targetEl.tagName,
217558
- pmStart: spanStart,
217559
- pmEnd: spanEnd,
217560
- text: targetEl.textContent?.substring(0, 30),
217561
- visibility: targetEl.style.visibility,
217562
- rect: {
217563
- left: targetRect.left,
217564
- right: targetRect.right,
217565
- width: targetRect.width
217566
- },
217567
- pageX: viewX,
217568
- pageY: viewY
217569
- });
217570
- if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
217571
- log2("Element has invalid PM positions");
217572
- return null;
217573
- }
217574
- const firstChild = targetEl.firstChild;
217575
- if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
217576
- const elRect = targetEl.getBoundingClientRect();
217577
- const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
217578
- const snapPos = closerToLeft ? spanStart : spanEnd;
217579
- log2("Empty/non-text element, snapping to:", {
217580
- closerToLeft,
217581
- snapPos
217582
- });
217583
- return snapPos;
217584
- }
217585
- const textNode = firstChild;
217586
- const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
217587
- const pos = mapCharIndexToPm(spanStart, spanEnd, textNode.length, charIndex);
217588
- log2("Character position:", {
217589
- charIndex,
217590
- spanStart,
217591
- finalPos: pos
217592
- });
217593
- return pos;
217661
+ return resolveLinePosition(lineEl, lineStart, lineEnd, spanEls, viewX);
217594
217662
  }
217595
217663
  function mapCharIndexToPm(spanStart, spanEnd, textLength, charIndex) {
217596
217664
  if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd))
@@ -217641,17 +217709,28 @@ function processLineElement(lineEl, viewX) {
217641
217709
  }
217642
217710
  };
217643
217711
  }));
217712
+ return resolveLinePosition(lineEl, lineStart, lineEnd, spanEls, viewX);
217713
+ }
217714
+ function resolveLinePosition(lineEl, lineStart, lineEnd, spanEls, viewX) {
217644
217715
  if (spanEls.length === 0) {
217645
217716
  log2("No spans in line, returning lineStart:", lineStart);
217646
217717
  return lineStart;
217647
217718
  }
217648
- if (viewX <= spanEls[0].getBoundingClientRect().left) {
217649
- log2("Click before first span, returning lineStart:", lineStart);
217650
- return lineStart;
217651
- }
217652
- if (viewX >= spanEls[spanEls.length - 1].getBoundingClientRect().right) {
217653
- log2("Click after last span, returning lineEnd:", lineEnd);
217654
- return lineEnd;
217719
+ const rtl = isRtlLine(lineEl);
217720
+ const allRects = spanEls.map((el) => el.getBoundingClientRect());
217721
+ const visibleRects = allRects.filter(isVisibleRect);
217722
+ const boundsRects = visibleRects.length > 0 ? visibleRects : allRects;
217723
+ const visualLeft = Math.min(...boundsRects.map((r$1) => r$1.left));
217724
+ const visualRight = Math.max(...boundsRects.map((r$1) => r$1.right));
217725
+ if (viewX <= visualLeft) {
217726
+ const pos$1 = rtl ? lineEnd : lineStart;
217727
+ log2("Click to visual left of all spans, returning:", pos$1);
217728
+ return pos$1;
217729
+ }
217730
+ if (viewX >= visualRight) {
217731
+ const pos$1 = rtl ? lineStart : lineEnd;
217732
+ log2("Click to visual right of all spans, returning:", pos$1);
217733
+ return pos$1;
217655
217734
  }
217656
217735
  const targetEl = findSpanAtX(spanEls, viewX);
217657
217736
  if (!targetEl) {
@@ -217679,20 +217758,22 @@ function processLineElement(lineEl, viewX) {
217679
217758
  }
217680
217759
  const firstChild = targetEl.firstChild;
217681
217760
  if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
217682
- const elRect = targetEl.getBoundingClientRect();
217683
- const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
217684
- const snapPos = closerToLeft ? spanStart : spanEnd;
217761
+ const closerToLeft = Math.abs(viewX - targetRect.left) <= Math.abs(viewX - targetRect.right);
217762
+ const snapPos = rtl ? closerToLeft ? spanEnd : spanStart : closerToLeft ? spanStart : spanEnd;
217685
217763
  log2("Empty/non-text element, snapping to:", {
217686
217764
  closerToLeft,
217765
+ rtl,
217687
217766
  snapPos
217688
217767
  });
217689
217768
  return snapPos;
217690
217769
  }
217691
- const charIndex = findCharIndexAtX(firstChild, targetEl, viewX);
217692
- const pos = spanStart + charIndex;
217770
+ const textNode = firstChild;
217771
+ const charIndex = findCharIndexAtX(textNode, viewX, rtl);
217772
+ const pos = mapCharIndexToPm(spanStart, spanEnd, textNode.length, charIndex);
217693
217773
  log2("Character position:", {
217694
217774
  charIndex,
217695
217775
  spanStart,
217776
+ rtl,
217696
217777
  finalPos: pos
217697
217778
  });
217698
217779
  return pos;
@@ -217728,9 +217809,12 @@ function findSpanAtX(spanEls, viewX) {
217728
217809
  if (spanEls.length === 0)
217729
217810
  return null;
217730
217811
  let targetSpan = spanEls[0];
217812
+ let minDist = Infinity;
217731
217813
  for (let i4 = 0;i4 < spanEls.length; i4++) {
217732
217814
  const span = spanEls[i4];
217733
217815
  const rect = span.getBoundingClientRect();
217816
+ if (!isVisibleRect(rect))
217817
+ continue;
217734
217818
  if (viewX >= rect.left && viewX <= rect.right) {
217735
217819
  log2("findSpanAtX: Found containing element at index", i4, {
217736
217820
  tag: span.tagName,
@@ -217744,8 +217828,11 @@ function findSpanAtX(spanEls, viewX) {
217744
217828
  });
217745
217829
  return span;
217746
217830
  }
217747
- if (viewX > rect.right)
217831
+ const dist = Math.min(Math.abs(viewX - rect.left), Math.abs(viewX - rect.right));
217832
+ if (dist < minDist) {
217833
+ minDist = dist;
217748
217834
  targetSpan = span;
217835
+ }
217749
217836
  }
217750
217837
  log2("findSpanAtX: No containing element, using nearest:", {
217751
217838
  tag: targetSpan.tagName,
@@ -217755,36 +217842,63 @@ function findSpanAtX(spanEls, viewX) {
217755
217842
  });
217756
217843
  return targetSpan;
217757
217844
  }
217758
- function findCharIndexAtX(textNode, container, targetX) {
217845
+ function findCharIndexAtX(textNode, targetX, rtl) {
217759
217846
  const text5 = textNode.textContent ?? "";
217760
- const baseLeft = container.getBoundingClientRect().left;
217847
+ if (text5.length === 0)
217848
+ return 0;
217849
+ const container = textNode.parentElement;
217850
+ if (!container)
217851
+ return 0;
217852
+ const containerRect = container.getBoundingClientRect();
217853
+ const caretIndex = caretOffsetFromPoint(targetX, containerRect.top + containerRect.height / 2, textNode);
217854
+ if (caretIndex != null) {
217855
+ log2("findCharIndexAtX: caret API returned", caretIndex);
217856
+ return caretIndex;
217857
+ }
217858
+ log2("findCharIndexAtX: falling back to range binary search, rtl =", rtl);
217761
217859
  const range = document.createRange();
217860
+ const measureX = (i4) => {
217861
+ if (i4 <= 0)
217862
+ return rtl ? containerRect.right : containerRect.left;
217863
+ range.setStart(textNode, 0);
217864
+ range.setEnd(textNode, i4);
217865
+ const r$1 = range.getBoundingClientRect();
217866
+ return rtl ? r$1.left : r$1.right;
217867
+ };
217762
217868
  let lo = 0;
217763
217869
  let hi = text5.length;
217764
217870
  while (lo < hi) {
217765
217871
  const mid = Math.floor((lo + hi) / 2);
217766
- range.setStart(textNode, 0);
217767
- range.setEnd(textNode, mid);
217768
- if (baseLeft + range.getBoundingClientRect().width < targetX)
217872
+ const x = measureX(mid);
217873
+ if (rtl ? x > targetX : x < targetX)
217769
217874
  lo = mid + 1;
217770
217875
  else
217771
217876
  hi = mid;
217772
217877
  }
217773
217878
  const index2 = Math.max(0, Math.min(text5.length, lo));
217774
- const measureAt = (i4) => {
217775
- range.setStart(textNode, 0);
217776
- range.setEnd(textNode, i4);
217777
- return baseLeft + range.getBoundingClientRect().width;
217778
- };
217779
- const xAt = measureAt(index2);
217879
+ const xAt = measureX(index2);
217780
217880
  const distAt = Math.abs(xAt - targetX);
217781
217881
  if (index2 > 0) {
217782
- const xPrev = measureAt(index2 - 1);
217882
+ const xPrev = measureX(index2 - 1);
217783
217883
  if (Math.abs(xPrev - targetX) < distAt)
217784
217884
  return index2 - 1;
217785
217885
  }
217786
217886
  return index2;
217787
217887
  }
217888
+ function caretOffsetFromPoint(x, y$1, expectedNode) {
217889
+ const doc$12 = document;
217890
+ if (typeof doc$12.caretPositionFromPoint === "function") {
217891
+ const cp = doc$12.caretPositionFromPoint(x, y$1);
217892
+ if (cp && cp.offsetNode === expectedNode)
217893
+ return cp.offset;
217894
+ }
217895
+ if (typeof doc$12.caretRangeFromPoint === "function") {
217896
+ const r$1 = doc$12.caretRangeFromPoint(x, y$1);
217897
+ if (r$1 && r$1.startContainer === expectedNode)
217898
+ return r$1.startOffset;
217899
+ }
217900
+ return null;
217901
+ }
217788
217902
  function getWordLayoutConfig(block) {
217789
217903
  if (!block || block.kind !== "paragraph")
217790
217904
  return;
@@ -252330,9 +252444,9 @@ var Node$13 = class Node$14 {
252330
252444
  return;
252331
252445
  console.log(...args$1);
252332
252446
  }, 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;
252333
- var init_src_D9hI0nIy_es = __esm(() => {
252447
+ var init_src_2Droteg9_es = __esm(() => {
252334
252448
  init_rolldown_runtime_B2q5OVn9_es();
252335
- init_SuperConverter_CXcZg9Os_es();
252449
+ init_SuperConverter_CTUnwu05_es();
252336
252450
  init_jszip_ChlR43oI_es();
252337
252451
  init_uuid_qzgm05fK_es();
252338
252452
  init_constants_Qqwopz80_es();
@@ -254984,6 +255098,21 @@ ${err.toString()}`);
254984
255098
  rendered: false,
254985
255099
  keepOnSplit: true
254986
255100
  },
255101
+ runPropertiesInlineKeys: {
255102
+ default: null,
255103
+ rendered: false,
255104
+ keepOnSplit: true
255105
+ },
255106
+ runPropertiesStyleKeys: {
255107
+ default: null,
255108
+ rendered: false,
255109
+ keepOnSplit: true
255110
+ },
255111
+ runPropertiesOverrideKeys: {
255112
+ default: null,
255113
+ rendered: false,
255114
+ keepOnSplit: true
255115
+ },
254987
255116
  rsidR: {
254988
255117
  default: null,
254989
255118
  rendered: false,
@@ -256794,20 +256923,24 @@ ${err.toString()}`);
256794
256923
  color: "auto"
256795
256924
  };
256796
256925
  state.doc.nodesBetween(from$1, to, (node3, pos) => {
256797
- if (["tableCell", "tableHeader"].includes(node3.type.name))
256926
+ if (["tableCell", "tableHeader"].includes(node3.type.name)) {
256927
+ const nextTableCellProperties = {
256928
+ ...node3.attrs.tableCellProperties ?? {},
256929
+ borders: {
256930
+ top: { ...nilBorder },
256931
+ bottom: { ...nilBorder },
256932
+ left: { ...nilBorder },
256933
+ right: { ...nilBorder }
256934
+ }
256935
+ };
256936
+ const nextInlineKeys = [...new Set([...node3.attrs.tableCellPropertiesInlineKeys || [], "borders"])];
256798
256937
  tr.setNodeMarkup(pos, undefined, {
256799
256938
  ...node3.attrs,
256800
256939
  borders: null,
256801
- tableCellProperties: {
256802
- ...node3.attrs.tableCellProperties ?? {},
256803
- borders: {
256804
- top: { ...nilBorder },
256805
- bottom: { ...nilBorder },
256806
- left: { ...nilBorder },
256807
- right: { ...nilBorder }
256808
- }
256809
- }
256940
+ tableCellProperties: nextTableCellProperties,
256941
+ tableCellPropertiesInlineKeys: nextInlineKeys
256810
256942
  });
256943
+ }
256811
256944
  });
256812
256945
  tr.setNodeMarkup(table2.pos, undefined, {
256813
256946
  ...table2.node.attrs,
@@ -257026,6 +257159,10 @@ ${err.toString()}`);
257026
257159
  default: null,
257027
257160
  rendered: false
257028
257161
  },
257162
+ tableCellPropertiesInlineKeys: {
257163
+ default: null,
257164
+ rendered: false
257165
+ },
257029
257166
  __placeholder: {
257030
257167
  default: null,
257031
257168
  parseDOM: (element3) => {
@@ -257205,6 +257342,10 @@ ${err.toString()}`);
257205
257342
  tableCellProperties: {
257206
257343
  default: null,
257207
257344
  rendered: false
257345
+ },
257346
+ tableCellPropertiesInlineKeys: {
257347
+ default: null,
257348
+ rendered: false
257208
257349
  }
257209
257350
  };
257210
257351
  },
@@ -285845,8 +285986,8 @@ var init_zipper_YmNpPIyc_es = __esm(() => {
285845
285986
 
285846
285987
  // ../../packages/superdoc/dist/super-editor.es.js
285847
285988
  var init_super_editor_es = __esm(() => {
285848
- init_src_D9hI0nIy_es();
285849
- init_SuperConverter_CXcZg9Os_es();
285989
+ init_src_2Droteg9_es();
285990
+ init_SuperConverter_CTUnwu05_es();
285850
285991
  init_jszip_ChlR43oI_es();
285851
285992
  init_xml_js_40FWvL78_es();
285852
285993
  init_constants_Qqwopz80_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.5.0-next.7",
3
+ "version": "0.5.0-next.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -25,20 +25,20 @@
25
25
  "@types/ws": "^8.5.13",
26
26
  "typescript": "^5.9.2",
27
27
  "@superdoc/document-api": "0.0.1",
28
- "@superdoc/pm-adapter": "0.0.0",
29
28
  "@superdoc/super-editor": "0.0.1",
30
- "superdoc": "1.23.0"
29
+ "superdoc": "1.23.0",
30
+ "@superdoc/pm-adapter": "0.0.0"
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.5.0-next.7",
38
- "@superdoc-dev/cli-darwin-x64": "0.5.0-next.7",
39
- "@superdoc-dev/cli-linux-x64": "0.5.0-next.7",
40
- "@superdoc-dev/cli-windows-x64": "0.5.0-next.7",
41
- "@superdoc-dev/cli-linux-arm64": "0.5.0-next.7"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.5.0-next.9",
38
+ "@superdoc-dev/cli-darwin-x64": "0.5.0-next.9",
39
+ "@superdoc-dev/cli-windows-x64": "0.5.0-next.9",
40
+ "@superdoc-dev/cli-linux-x64": "0.5.0-next.9",
41
+ "@superdoc-dev/cli-linux-arm64": "0.5.0-next.9"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",