@superdoc-dev/cli 0.5.0-next.68 → 0.5.0-next.69

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 +120 -23
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -65886,7 +65886,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
65886
65886
  emptyOptions2 = {};
65887
65887
  });
65888
65888
 
65889
- // ../../packages/superdoc/dist/chunks/SuperConverter-CJYLTlzF.es.js
65889
+ // ../../packages/superdoc/dist/chunks/SuperConverter-DKPcCGTm.es.js
65890
65890
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
65891
65891
  const fieldValue = extension$1.config[field];
65892
65892
  if (typeof fieldValue === "function")
@@ -116191,6 +116191,7 @@ var isRegExp = (value) => {
116191
116191
  else
116192
116192
  pageBreakAfterVal = Number(pageBreakAfter?.attributes?.["w:val"]);
116193
116193
  const basedOn = elementsWithId.find((el) => el.elements.some((inner) => inner.name === "w:basedOn"))?.elements.find((inner) => inner.name === "w:basedOn")?.attributes["w:val"];
116194
+ const linkToCharacterStyle = firstMatch.elements.find((el) => el.name === "w:link")?.attributes?.["w:val"] ?? null;
116194
116195
  const parsedAttrs = {
116195
116196
  name,
116196
116197
  qFormat: qFormat ? true : false,
@@ -116199,7 +116200,8 @@ var isRegExp = (value) => {
116199
116200
  outlineLevel: outlineLevel ? parseInt(outlineLvlValue) : null,
116200
116201
  pageBreakBefore: pageBreakBeforeVal ? true : false,
116201
116202
  pageBreakAfter: pageBreakAfterVal ? true : false,
116202
- basedOn: basedOn ?? null
116203
+ basedOn: basedOn ?? null,
116204
+ link: linkToCharacterStyle
116203
116205
  };
116204
116206
  const parsedMarks = parseMarks(firstMatch.elements.find((el) => el.name === "w:rPr"), [], docx) || [];
116205
116207
  const parsedStyles = {
@@ -117501,7 +117503,7 @@ var isRegExp = (value) => {
117501
117503
  state.kern = kernNode.attributes["w:val"];
117502
117504
  }
117503
117505
  }, SuperConverter;
117504
- var init_SuperConverter_CJYLTlzF_es = __esm(() => {
117506
+ var init_SuperConverter_DKPcCGTm_es = __esm(() => {
117505
117507
  init_rolldown_runtime_Bg48TavK_es();
117506
117508
  init_jszip_C49i9kUs_es();
117507
117509
  init_xml_js_CqGKpaft_es();
@@ -154593,7 +154595,7 @@ var init_SuperConverter_CJYLTlzF_es = __esm(() => {
154593
154595
  };
154594
154596
  });
154595
154597
 
154596
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BvILQhp3.es.js
154598
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BTSQjUTS.es.js
154597
154599
  function parseSizeUnit(val = "0") {
154598
154600
  const length3 = val.toString() || "0";
154599
154601
  const value = Number.parseFloat(length3);
@@ -155786,11 +155788,34 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
155786
155788
  }
155787
155789
  });
155788
155790
  return Object.entries(markValue).map(([key$1, value]) => `${key$1}: ${value}`).join(";");
155791
+ }, getParagraphTextBounds = (doc2, paragraphPos, paragraphNode) => {
155792
+ let minPos = null;
155793
+ let maxPos = null;
155794
+ const innerStart = paragraphPos + 1;
155795
+ const innerEnd = paragraphPos + paragraphNode.nodeSize - 1;
155796
+ doc2.nodesBetween(innerStart, innerEnd, (node3, pos) => {
155797
+ if (node3.isText) {
155798
+ if (minPos === null || pos < minPos)
155799
+ minPos = pos;
155800
+ maxPos = pos + node3.nodeSize;
155801
+ }
155802
+ return true;
155803
+ });
155804
+ if (minPos === null || maxPos === null)
155805
+ return null;
155806
+ return {
155807
+ from: minPos,
155808
+ to: maxPos
155809
+ };
155810
+ }, applyCharacterStyleMarkToRange = (tr, textStyleType, from5, to, styleId) => {
155811
+ tr.removeMark(from5, to, textStyleType);
155812
+ tr.addMark(from5, to, textStyleType.create({ styleId }));
155789
155813
  }, applyLinkedStyleToTransaction = (tr, editor, style) => {
155790
155814
  if (!style)
155791
155815
  return false;
155792
155816
  let selection = tr.selection;
155793
155817
  const state = editor.state;
155818
+ const textStyleType = editor.schema.marks.textStyle;
155794
155819
  const focusState = CustomSelectionPluginKey.getState(state);
155795
155820
  if (selection.empty && focusState?.preservedSelection && !focusState?.preservedSelection.empty) {
155796
155821
  selection = focusState.preservedSelection;
@@ -155809,13 +155834,19 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
155809
155834
  }
155810
155835
  };
155811
155836
  };
155812
- const clearFormattingMarks = (startPos, endPos) => {
155813
- tr.doc.nodesBetween(startPos, endPos, (node3, pos) => {
155814
- if (node3.isText && node3.marks.length > 0)
155815
- node3.marks.forEach((mark) => {
155816
- if (FORMATTING_MARK_NAMES.has(mark.type.name))
155817
- tr.removeMark(pos, pos + node3.nodeSize, mark);
155818
- });
155837
+ const clearFormattingMarks = (rangeFrom, rangeTo) => {
155838
+ tr.doc.nodesBetween(rangeFrom, rangeTo, (node3, pos) => {
155839
+ if (!node3.isText || node3.marks.length === 0)
155840
+ return true;
155841
+ const nodeEnd = pos + node3.nodeSize;
155842
+ const clearFrom = Math.max(pos, rangeFrom);
155843
+ const clearTo = Math.min(nodeEnd, rangeTo);
155844
+ if (clearFrom >= clearTo)
155845
+ return true;
155846
+ node3.marks.forEach((mark) => {
155847
+ if (FORMATTING_MARK_NAMES.has(mark.type.name))
155848
+ tr.removeMark(clearFrom, clearTo, mark);
155849
+ });
155819
155850
  return true;
155820
155851
  });
155821
155852
  };
@@ -155827,6 +155858,19 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
155827
155858
  if (nextStoredMarks.length !== sourceMarks.length)
155828
155859
  tr.setStoredMarks(nextStoredMarks);
155829
155860
  };
155861
+ if (style.type === "character") {
155862
+ if (!textStyleType)
155863
+ return false;
155864
+ if (from5 === to) {
155865
+ const filtered = (tr.storedMarks ?? state.storedMarks ?? selection.$from.marks()).filter((mark) => mark.type !== textStyleType);
155866
+ tr.setStoredMarks([...filtered, textStyleType.create({ styleId: style.id })]);
155867
+ return true;
155868
+ }
155869
+ clearFormattingMarks(from5, to);
155870
+ applyCharacterStyleMarkToRange(tr, textStyleType, from5, to, style.id);
155871
+ clearStoredFormattingMarks();
155872
+ return true;
155873
+ }
155830
155874
  if (from5 === to) {
155831
155875
  let pos = from5;
155832
155876
  let paragraphNode = tr.doc.nodeAt(from5);
@@ -155842,6 +155886,25 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
155842
155886
  tr.setNodeMarkup(pos, undefined, getUpdatedParagraphAttrs(paragraphNode));
155843
155887
  return true;
155844
155888
  }
155889
+ if (style.type === "paragraph" && textStyleType) {
155890
+ const linkedCharStyleId = style.definition?.attrs?.link;
155891
+ if (linkedCharStyleId) {
155892
+ const $fromPos = tr.doc.resolve(from5);
155893
+ const $toPos = tr.doc.resolve(to);
155894
+ const startPara = findParentNodeClosestToPos($fromPos, (n) => n.type.name === "paragraph");
155895
+ const endPara = findParentNodeClosestToPos($toPos, (n) => n.type.name === "paragraph");
155896
+ if (startPara && endPara && startPara.pos === endPara.pos) {
155897
+ const bounds = getParagraphTextBounds(tr.doc, startPara.pos, startPara.node);
155898
+ const coversFullParagraphText = bounds && from5 <= bounds.from && to >= bounds.to;
155899
+ if (bounds && !coversFullParagraphText) {
155900
+ clearFormattingMarks(from5, to);
155901
+ applyCharacterStyleMarkToRange(tr, textStyleType, from5, to, linkedCharStyleId);
155902
+ clearStoredFormattingMarks();
155903
+ return true;
155904
+ }
155905
+ }
155906
+ }
155907
+ }
155845
155908
  const paragraphPositions = [];
155846
155909
  tr.doc.nodesBetween(from5, to, (node3, pos) => {
155847
155910
  if (node3.type.name === "paragraph")
@@ -155851,6 +155914,20 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
155851
155914
  });
155852
155915
  return true;
155853
155916
  });
155917
+ if (paragraphPositions.length === 0 && from5 !== to) {
155918
+ const seen = /* @__PURE__ */ new Set;
155919
+ const pushParagraph = (info) => {
155920
+ if (!info || seen.has(info.pos))
155921
+ return;
155922
+ seen.add(info.pos);
155923
+ paragraphPositions.push({
155924
+ node: info.node,
155925
+ pos: info.pos
155926
+ });
155927
+ };
155928
+ pushParagraph(findParentNodeClosestToPos(tr.doc.resolve(from5), (n) => n.type.name === "paragraph"));
155929
+ pushParagraph(findParentNodeClosestToPos(tr.doc.resolve(to), (n) => n.type.name === "paragraph"));
155930
+ }
155854
155931
  paragraphPositions.forEach(({ node: node3, pos }) => {
155855
155932
  clearFormattingMarks(pos + 1, pos + node3.nodeSize - 1);
155856
155933
  tr.setNodeMarkup(pos, undefined, getUpdatedParagraphAttrs(node3));
@@ -156129,8 +156206,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
156129
156206
  return false;
156130
156207
  return Boolean(checker(attrs));
156131
156208
  };
156132
- var init_create_headless_toolbar_BvILQhp3_es = __esm(() => {
156133
- init_SuperConverter_CJYLTlzF_es();
156209
+ var init_create_headless_toolbar_BTSQjUTS_es = __esm(() => {
156210
+ init_SuperConverter_DKPcCGTm_es();
156134
156211
  init_constants_CGhJRd87_es();
156135
156212
  init_dist_B8HfvhaK_es();
156136
156213
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
@@ -204568,7 +204645,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
204568
204645
  init_remark_gfm_BhnWr3yf_es();
204569
204646
  });
204570
204647
 
204571
- // ../../packages/superdoc/dist/chunks/src-d1wQbdUW.es.js
204648
+ // ../../packages/superdoc/dist/chunks/src-CX93tpZZ.es.js
204572
204649
  function deleteProps(obj, propOrProps) {
204573
204650
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
204574
204651
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -206497,6 +206574,7 @@ function splitBlockPatch(state, dispatch, editor) {
206497
206574
  atEnd = $from.end(d) == $from.pos + ($from.depth - d);
206498
206575
  atStart = $from.start(d) == $from.pos - ($from.depth - d);
206499
206576
  deflt = defaultBlockAt($from.node(d - 1).contentMatchAt($from.indexAfter(d - 1)));
206577
+ const sourceParagraphStyleId = node3.attrs?.paragraphProperties?.styleId;
206500
206578
  paragraphAttrs = {
206501
206579
  ...node3.attrs,
206502
206580
  sdBlockId: null,
@@ -206505,8 +206583,20 @@ function splitBlockPatch(state, dispatch, editor) {
206505
206583
  textId: null
206506
206584
  };
206507
206585
  paragraphAttrs = clearInheritedLinkedStyleId(paragraphAttrs, editor, { emptyParagraph: atEnd });
206508
- if (atEnd && $from.parent.type.name === "run")
206509
- paragraphAttrs = syncSplitParagraphRunProperties(paragraphAttrs, getSplitRunProperties(state, $from));
206586
+ if (atEnd && $from.parent.type.name === "run") {
206587
+ if (!isLinkedParagraphStyleId(editor, sourceParagraphStyleId))
206588
+ paragraphAttrs = syncSplitParagraphRunProperties(paragraphAttrs, getSplitRunProperties(state, $from));
206589
+ const pp = paragraphAttrs?.paragraphProperties;
206590
+ const runStyleIsLinkedCharacter = isLinkedCharacterStyleId(editor, pp?.runProperties?.styleId);
206591
+ if (pp && (isLinkedParagraphStyleId(editor, sourceParagraphStyleId) || runStyleIsLinkedCharacter)) {
206592
+ const nextPp = { ...pp };
206593
+ delete nextPp.runProperties;
206594
+ paragraphAttrs = {
206595
+ ...paragraphAttrs,
206596
+ paragraphProperties: nextPp
206597
+ };
206598
+ }
206599
+ }
206510
206600
  types3.unshift({
206511
206601
  type: deflt || node3.type,
206512
206602
  attrs: paragraphAttrs
@@ -206580,7 +206670,7 @@ function applyStyleMarks(state, tr, editor, paragraphAttrs, tableInfo) {
206580
206670
  };
206581
206671
  const runProperties = styleId ? resolveRunProperties(params$1, {}, styleId ? { styleId } : {}, tableInfo, false, Boolean(paragraphAttrs.paragraphProperties?.numberingProperties)) : {};
206582
206672
  const markDefsFromStyle = styleId ? encodeMarksFromRPr(runProperties, editor?.converter?.convertedXml ?? {}) : [];
206583
- const selectionMarks = state.selection?.$from?.marks ? state.selection.$from.marks() : [];
206673
+ const selectionMarks = tr.selection?.$from?.marks ? tr.selection.$from.marks() : [];
206584
206674
  const selectionMarkDefs = selectionMarks.map((mark2) => ({
206585
206675
  type: mark2.type.name,
206586
206676
  attrs: mark2.attrs
@@ -263353,6 +263443,13 @@ var Node$13 = class Node$14 {
263353
263443
  return false;
263354
263444
  const styleDefinition = readTranslatedLinkedStyles(editor)?.styles?.[styleId];
263355
263445
  return Boolean(styleDefinition?.type === "paragraph" && styleDefinition?.link);
263446
+ }, isLinkedCharacterStyleId = (editor, styleId) => {
263447
+ if (!styleId)
263448
+ return false;
263449
+ const translatedStyles = readTranslatedLinkedStyles(editor)?.styles;
263450
+ if (!translatedStyles)
263451
+ return false;
263452
+ return Object.values(translatedStyles).some((def) => def?.type === "paragraph" && def?.link === styleId);
263356
263453
  }, clearInheritedLinkedStyleId = (attrs, editor, { emptyParagraph = false } = {}) => {
263357
263454
  if (!emptyParagraph)
263358
263455
  return attrs;
@@ -287211,12 +287308,12 @@ var Node$13 = class Node$14 {
287211
287308
  return;
287212
287309
  console.log(...args$1);
287213
287310
  }, 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;
287214
- var init_src_d1wQbdUW_es = __esm(() => {
287311
+ var init_src_CX93tpZZ_es = __esm(() => {
287215
287312
  init_rolldown_runtime_Bg48TavK_es();
287216
- init_SuperConverter_CJYLTlzF_es();
287313
+ init_SuperConverter_DKPcCGTm_es();
287217
287314
  init_jszip_C49i9kUs_es();
287218
287315
  init_uuid_qzgm05fK_es();
287219
- init_create_headless_toolbar_BvILQhp3_es();
287316
+ init_create_headless_toolbar_BTSQjUTS_es();
287220
287317
  init_constants_CGhJRd87_es();
287221
287318
  init_dist_B8HfvhaK_es();
287222
287319
  init_unified_Dsuw2be5_es();
@@ -321785,11 +321882,11 @@ var init_zipper_DbkgrypV_es = __esm(() => {
321785
321882
 
321786
321883
  // ../../packages/superdoc/dist/super-editor.es.js
321787
321884
  var init_super_editor_es = __esm(() => {
321788
- init_src_d1wQbdUW_es();
321789
- init_SuperConverter_CJYLTlzF_es();
321885
+ init_src_CX93tpZZ_es();
321886
+ init_SuperConverter_DKPcCGTm_es();
321790
321887
  init_jszip_C49i9kUs_es();
321791
321888
  init_xml_js_CqGKpaft_es();
321792
- init_create_headless_toolbar_BvILQhp3_es();
321889
+ init_create_headless_toolbar_BTSQjUTS_es();
321793
321890
  init_constants_CGhJRd87_es();
321794
321891
  init_dist_B8HfvhaK_es();
321795
321892
  init_unified_Dsuw2be5_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.5.0-next.68",
3
+ "version": "0.5.0-next.69",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -34,11 +34,11 @@
34
34
  "access": "public"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@superdoc-dev/cli-darwin-arm64": "0.5.0-next.68",
38
- "@superdoc-dev/cli-darwin-x64": "0.5.0-next.68",
39
- "@superdoc-dev/cli-linux-arm64": "0.5.0-next.68",
40
- "@superdoc-dev/cli-linux-x64": "0.5.0-next.68",
41
- "@superdoc-dev/cli-windows-x64": "0.5.0-next.68"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.5.0-next.69",
38
+ "@superdoc-dev/cli-darwin-x64": "0.5.0-next.69",
39
+ "@superdoc-dev/cli-linux-x64": "0.5.0-next.69",
40
+ "@superdoc-dev/cli-linux-arm64": "0.5.0-next.69",
41
+ "@superdoc-dev/cli-windows-x64": "0.5.0-next.69"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",