@superdoc-dev/cli 0.2.0-next.131 → 0.2.0-next.132

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 +87 -41
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -135187,7 +135187,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
135187
135187
  init_remark_gfm_z_sDF4ss_es();
135188
135188
  });
135189
135189
 
135190
- // ../../packages/superdoc/dist/chunks/src-BTrBP-Dc.es.js
135190
+ // ../../packages/superdoc/dist/chunks/src-BVOVss6W.es.js
135191
135191
  function deleteProps(obj, propOrProps) {
135192
135192
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
135193
135193
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -138035,6 +138035,12 @@ function createPositionTrackerPlugin() {
138035
138035
  } }
138036
138036
  });
138037
138037
  }
138038
+ function getConverter$12(editor) {
138039
+ return editor.converter;
138040
+ }
138041
+ function readTranslatedLinkedStyles(editor) {
138042
+ return getConverter$12(editor)?.translatedLinkedStyles ?? null;
138043
+ }
138038
138044
  function keyName(event) {
138039
138045
  var name = !(mac$1 && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey || ie && event.shiftKey && event.key && event.key.length == 1 || event.key == "Unidentified") && event.key || (event.shiftKey ? shift : base4)[event.keyCode] || event.key || "Unidentified";
138040
138046
  if (name == "Esc")
@@ -139914,6 +139920,7 @@ function splitBlockPatch(state, dispatch, editor) {
139914
139920
  paraId: null,
139915
139921
  textId: null
139916
139922
  };
139923
+ paragraphAttrs = clearInheritedLinkedStyleId(paragraphAttrs, editor, { emptyParagraph: atEnd });
139917
139924
  types3.unshift({
139918
139925
  type: deflt || node3.type,
139919
139926
  attrs: paragraphAttrs
@@ -139964,6 +139971,11 @@ function splitBlockPatch(state, dispatch, editor) {
139964
139971
  }
139965
139972
  function applyStyleMarks(state, tr, editor, paragraphAttrs, tableInfo) {
139966
139973
  const styleId = paragraphAttrs?.paragraphProperties?.styleId;
139974
+ if (paragraphAttrs?.paragraphProperties && Object.prototype.hasOwnProperty.call(paragraphAttrs.paragraphProperties, "styleId") && paragraphAttrs.paragraphProperties.styleId == null) {
139975
+ tr.setStoredMarks([]);
139976
+ tr.setMeta("sdStyleMarks", []);
139977
+ return;
139978
+ }
139967
139979
  if (!editor?.converter && !styleId)
139968
139980
  return;
139969
139981
  try {
@@ -141044,7 +141056,7 @@ function createPartPublisher(editor, ydoc, options = {}) {
141044
141056
  destroy
141045
141057
  };
141046
141058
  }
141047
- function getConverter$12(editor) {
141059
+ function getConverter$11(editor) {
141048
141060
  return editor.converter;
141049
141061
  }
141050
141062
  function isHeaderPartId(partId) {
@@ -141079,7 +141091,7 @@ function ensureHeaderFooterDescriptor(partId, sectionId) {
141079
141091
  };
141080
141092
  },
141081
141093
  afterCommit(ctx$1) {
141082
- const converter = getConverter$12(ctx$1.editor);
141094
+ const converter = getConverter$11(ctx$1.editor);
141083
141095
  if (!converter)
141084
141096
  return;
141085
141097
  const resolvedSectionId = ctx$1.sectionId ?? sectionId;
@@ -141099,7 +141111,7 @@ function ensureHeaderFooterDescriptor(partId, sectionId) {
141099
141111
  refreshActiveSubEditors(converter, type, resolvedSectionId);
141100
141112
  },
141101
141113
  onDelete(ctx$1) {
141102
- const converter = getConverter$12(ctx$1.editor);
141114
+ const converter = getConverter$11(ctx$1.editor);
141103
141115
  if (!converter)
141104
141116
  return;
141105
141117
  const resolvedSectionId = ctx$1.sectionId ?? sectionId;
@@ -141146,11 +141158,11 @@ function registerHeaderFooterInvalidationHandler(partId) {
141146
141158
  } catch {}
141147
141159
  });
141148
141160
  }
141149
- function getConverter$11(editor) {
141161
+ function getConverter$10(editor) {
141150
141162
  return editor.converter;
141151
141163
  }
141152
141164
  function resolvePartIdFromSectionId(editor, sectionId) {
141153
- const relsRoot = getConverter$11(editor)?.convertedXml?.["word/_rels/document.xml.rels"]?.elements?.find((el) => el.name === "Relationships");
141165
+ const relsRoot = getConverter$10(editor)?.convertedXml?.["word/_rels/document.xml.rels"]?.elements?.find((el) => el.name === "Relationships");
141154
141166
  if (!relsRoot?.elements)
141155
141167
  return null;
141156
141168
  for (const el of relsRoot.elements) {
@@ -141192,14 +141204,14 @@ function resolveHeaderFooterRId(partId, relsData, editor) {
141192
141204
  return rId;
141193
141205
  }
141194
141206
  if (editor) {
141195
- const localRels = getConverter$11(editor)?.convertedXml?.["word/_rels/document.xml.rels"];
141207
+ const localRels = getConverter$10(editor)?.convertedXml?.["word/_rels/document.xml.rels"];
141196
141208
  if (localRels)
141197
141209
  return resolveRIdFromRelsData(localRels, partId);
141198
141210
  }
141199
141211
  return null;
141200
141212
  }
141201
141213
  function exportSubEditorToPart(mainEditor, subEditor, sectionId, type) {
141202
- const converter = getConverter$11(mainEditor);
141214
+ const converter = getConverter$10(mainEditor);
141203
141215
  if (!converter?.exportToXmlJson)
141204
141216
  return false;
141205
141217
  const partId = resolvePartIdFromSectionId(mainEditor, sectionId);
@@ -141262,7 +141274,7 @@ function exportSubEditorToPart(mainEditor, subEditor, sectionId, type) {
141262
141274
  }
141263
141275
  }
141264
141276
  function registerExistingHeaderFooterDescriptors(editor) {
141265
- const converter = getConverter$11(editor);
141277
+ const converter = getConverter$10(editor);
141266
141278
  if (!converter?.convertedXml)
141267
141279
  return;
141268
141280
  const relsRoot = converter.convertedXml["word/_rels/document.xml.rels"]?.elements?.find((el) => el.name === "Relationships");
@@ -144414,11 +144426,11 @@ function pxToInches$1(value) {
144414
144426
  function buildSectionId(index2) {
144415
144427
  return `section-${index2}`;
144416
144428
  }
144417
- function getConverter$10(editor) {
144429
+ function getConverter$9(editor) {
144418
144430
  return editor.converter;
144419
144431
  }
144420
144432
  function getBodySectPrFromEditor(editor) {
144421
- const converter = getConverter$10(editor);
144433
+ const converter = getConverter$9(editor);
144422
144434
  if (isSectPrElement$1(converter?.bodySectPr))
144423
144435
  return cloneXmlElement(converter.bodySectPr);
144424
144436
  const docAttrs = editor.state.doc.attrs ?? {};
@@ -144467,7 +144479,7 @@ function resolveAnalysisDoc(editor, paragraphs) {
144467
144479
  return buildAnalysisDocFromParagraphs(paragraphs);
144468
144480
  }
144469
144481
  function getSettingsRoot(editor) {
144470
- const settingsPart = getConverter$10(editor)?.convertedXml?.["word/settings.xml"];
144482
+ const settingsPart = getConverter$9(editor)?.convertedXml?.["word/settings.xml"];
144471
144483
  if (!settingsPart)
144472
144484
  return null;
144473
144485
  if (settingsPart.name === "w:settings")
@@ -144477,7 +144489,7 @@ function getSettingsRoot(editor) {
144477
144489
  return settingsPart.elements.find((entry) => entry.name === "w:settings") ?? null;
144478
144490
  }
144479
144491
  function readOddEvenHeadersFlag(editor) {
144480
- const converter = getConverter$10(editor);
144492
+ const converter = getConverter$9(editor);
144481
144493
  if (converter?.pageStyles?.alternateHeaders != null)
144482
144494
  return converter.pageStyles.alternateHeaders === true;
144483
144495
  const settingsRoot = getSettingsRoot(editor);
@@ -149546,11 +149558,11 @@ function executePlan(editor, input2) {
149546
149558
  expectedRevision: input2.expectedRevision
149547
149559
  });
149548
149560
  }
149549
- function getConverter$9(editor) {
149561
+ function getConverter$8(editor) {
149550
149562
  return editor.converter;
149551
149563
  }
149552
149564
  function takeSnapshot(editor, partIds) {
149553
- const converter = getConverter$9(editor);
149565
+ const converter = getConverter$8(editor);
149554
149566
  const partEntries = /* @__PURE__ */ new Map;
149555
149567
  if (converter?.convertedXml)
149556
149568
  for (const partId of partIds) {
@@ -149574,7 +149586,7 @@ function takeSnapshot(editor, partIds) {
149574
149586
  };
149575
149587
  }
149576
149588
  function restoreFromSnapshot(editor, snapshot2) {
149577
- const converter = getConverter$9(editor);
149589
+ const converter = getConverter$8(editor);
149578
149590
  if (!converter)
149579
149591
  return;
149580
149592
  if (converter.convertedXml)
@@ -155428,12 +155440,6 @@ function assertRunTilingInvariant(runs2, blockRange, blockId) {
155428
155440
  if (runs2[i$1].range.end !== runs2[i$1 + 1].range.start)
155429
155441
  throw planError("INTERNAL_ERROR", `run-tiling: gap or overlap between runs[${i$1}] and runs[${i$1 + 1}] in block ${blockId}`);
155430
155442
  }
155431
- function getConverter$8(editor) {
155432
- return editor.converter;
155433
- }
155434
- function readTranslatedLinkedStyles(editor) {
155435
- return getConverter$8(editor)?.translatedLinkedStyles ?? null;
155436
- }
155437
155443
  function encodeV3Ref(payload) {
155438
155444
  return `text:${btoa(JSON.stringify(payload))}`;
155439
155445
  }
@@ -194142,6 +194148,27 @@ var Node$13 = class Node$14 {
194142
194148
  }, command = (fn) => (props) => fn(props), insertTabChar = () => ({ tr }) => {
194143
194149
  tr.insertText("\t", tr.selection.from, tr.selection.to);
194144
194150
  return true;
194151
+ }, isLinkedParagraphStyleId = (editor, styleId) => {
194152
+ if (!styleId)
194153
+ return false;
194154
+ const styleDefinition = readTranslatedLinkedStyles(editor)?.styles?.[styleId];
194155
+ return Boolean(styleDefinition?.type === "paragraph" && styleDefinition?.link);
194156
+ }, clearInheritedLinkedStyleId = (attrs, editor, { emptyParagraph = false } = {}) => {
194157
+ if (!emptyParagraph)
194158
+ return attrs;
194159
+ if (!attrs || typeof attrs !== "object")
194160
+ return attrs;
194161
+ const paragraphProperties = attrs.paragraphProperties;
194162
+ const styleId = paragraphProperties?.styleId;
194163
+ if (!isLinkedParagraphStyleId(editor, styleId))
194164
+ return attrs;
194165
+ return {
194166
+ ...attrs,
194167
+ paragraphProperties: {
194168
+ ...paragraphProperties,
194169
+ styleId: null
194170
+ }
194171
+ };
194145
194172
  }, base4, shift, mac$1, ie, i3, i3, i3, code6, mac, windows, readFromCache, addToCache, TableMap = class {
194146
194173
  constructor(width, height, map$12, problems) {
194147
194174
  this.width = width;
@@ -194471,6 +194498,7 @@ var Node$13 = class Node$14 {
194471
194498
  return false;
194472
194499
  if (dispatch) {
194473
194500
  const atEnd = $to.parentOffset === $to.parent.content.size;
194501
+ newAttrs = clearInheritedLinkedStyleId(newAttrs, editor, { emptyParagraph: atEnd });
194474
194502
  if (selection instanceof TextSelection2)
194475
194503
  tr.deleteSelection();
194476
194504
  const deflt = $from.depth === 0 ? null : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
@@ -200157,7 +200185,7 @@ var Node$13 = class Node$14 {
200157
200185
  return !!target?.closest(".button-text-input") || target?.classList?.contains("button-text-input");
200158
200186
  }, isToolbarButton = (target) => {
200159
200187
  return !!target?.closest(".toolbar-button") || target?.classList?.contains("toolbar-button");
200160
- }, CustomSelection, LinkedStyles, getLinkedStyle = (styleId, styles = []) => {
200188
+ }, CustomSelection, LinkedStyles, FORMATTING_MARK_NAMES, getLinkedStyle = (styleId, styles = []) => {
200161
200189
  const linkedStyle = styles.find((style2) => style2.id === styleId);
200162
200190
  const basedOn = linkedStyle?.definition?.attrs?.basedOn;
200163
200191
  return {
@@ -200277,6 +200305,7 @@ var Node$13 = class Node$14 {
200277
200305
  }, applyLinkedStyleToTransaction = (tr, editor, style2) => {
200278
200306
  if (!style2)
200279
200307
  return false;
200308
+ tr.setMeta("sdStyleMarks", []);
200280
200309
  let selection = tr.selection;
200281
200310
  const state = editor.state;
200282
200311
  const focusState = CustomSelectionPluginKey.getState(state);
@@ -200299,25 +200328,22 @@ var Node$13 = class Node$14 {
200299
200328
  };
200300
200329
  const clearFormattingMarks = (startPos, endPos) => {
200301
200330
  tr.doc.nodesBetween(startPos, endPos, (node3, pos) => {
200302
- if (node3.isText && node3.marks.length > 0) {
200303
- const marksToRemove = [
200304
- "textStyle",
200305
- "bold",
200306
- "italic",
200307
- "underline",
200308
- "strike",
200309
- "subscript",
200310
- "superscript",
200311
- "highlight"
200312
- ];
200331
+ if (node3.isText && node3.marks.length > 0)
200313
200332
  node3.marks.forEach((mark2) => {
200314
- if (marksToRemove.includes(mark2.type.name))
200333
+ if (FORMATTING_MARK_NAMES.has(mark2.type.name))
200315
200334
  tr.removeMark(pos, pos + node3.nodeSize, mark2);
200316
200335
  });
200317
- }
200318
200336
  return true;
200319
200337
  });
200320
200338
  };
200339
+ const clearStoredFormattingMarks = () => {
200340
+ const sourceMarks = tr.storedMarks ?? state.storedMarks ?? (selection.empty ? selection.$from.marks() : []);
200341
+ if (!sourceMarks?.length)
200342
+ return;
200343
+ const nextStoredMarks = sourceMarks.filter((mark2) => !FORMATTING_MARK_NAMES.has(mark2.type.name));
200344
+ if (nextStoredMarks.length !== sourceMarks.length)
200345
+ tr.setStoredMarks(nextStoredMarks);
200346
+ };
200321
200347
  if (from$1 === to) {
200322
200348
  let pos = from$1;
200323
200349
  let paragraphNode = tr.doc.nodeAt(from$1);
@@ -200329,6 +200355,7 @@ var Node$13 = class Node$14 {
200329
200355
  paragraphNode = parentNode$1.node;
200330
200356
  }
200331
200357
  clearFormattingMarks(pos + 1, pos + paragraphNode.nodeSize - 1);
200358
+ clearStoredFormattingMarks();
200332
200359
  tr.setNodeMarkup(pos, undefined, getUpdatedParagraphAttrs(paragraphNode));
200333
200360
  return true;
200334
200361
  }
@@ -200345,6 +200372,7 @@ var Node$13 = class Node$14 {
200345
200372
  clearFormattingMarks(pos + 1, pos + node3.nodeSize - 1);
200346
200373
  tr.setNodeMarkup(pos, undefined, getUpdatedParagraphAttrs(node3));
200347
200374
  });
200375
+ clearStoredFormattingMarks();
200348
200376
  return true;
200349
200377
  }, stepInsertsTextIntoStyledParagraph = (tr, oldEditorState, step3, stepIndex) => {
200350
200378
  if (!step3.slice || step3.slice.size === 0 || typeof step3.from !== "number")
@@ -213406,6 +213434,9 @@ var Node$13 = class Node$14 {
213406
213434
  }
213407
213435
  } catch (_e) {}
213408
213436
  return null;
213437
+ }, hasParagraphStyleOverride = (paragraphNode) => {
213438
+ const paragraphProperties = paragraphNode?.attrs?.paragraphProperties;
213439
+ return Boolean(paragraphProperties && typeof paragraphProperties === "object" && Object.prototype.hasOwnProperty.call(paragraphProperties, "styleId"));
213409
213440
  }, createMarksFromDefs = (schema, markDefs = []) => markDefs.map((def2) => {
213410
213441
  const markType = schema.marks[def2.type];
213411
213442
  return markType ? markType.create(def2.attrs) : null;
@@ -213434,6 +213465,11 @@ var Node$13 = class Node$14 {
213434
213465
  }, copyRunPropertiesFromPreviousParagraph = (state, pos, textNode, runType, editor) => {
213435
213466
  let runProperties;
213436
213467
  let updatedTextNode = textNode;
213468
+ if (hasParagraphStyleOverride(getParagraphAtPos(state.doc, pos)))
213469
+ return {
213470
+ runProperties,
213471
+ textNode: updatedTextNode
213472
+ };
213437
213473
  const paragraphNode = getParagraphAtPos(state.doc, pos - 2);
213438
213474
  if (paragraphNode && paragraphNode.content.size > 0) {
213439
213475
  const lastChild = paragraphNode.child(paragraphNode.childCount - 1);
@@ -213535,9 +213571,9 @@ var Node$13 = class Node$14 {
213535
213571
  pendingRanges = collectChangedRangesThroughTransactions(transactions, docSize, { extraRanges: pendingRanges });
213536
213572
  if (view?.composing)
213537
213573
  return null;
213538
- const metaFromTxn = [...transactions].reverse().map((txn) => txn.getMeta("sdStyleMarks")).find(Boolean);
213539
- if (metaFromTxn?.length)
213540
- lastStyleMarksMeta = metaFromTxn;
213574
+ const metaFromTxn = [...transactions].reverse().map((txn) => txn.getMeta("sdStyleMarks")).find((meta2) => meta2 !== undefined);
213575
+ if (metaFromTxn !== undefined)
213576
+ lastStyleMarksMeta = Array.isArray(metaFromTxn) ? metaFromTxn : [];
213541
213577
  const tr = buildWrapTransaction(newState, pendingRanges, runType, editor, lastStyleMarksMeta);
213542
213578
  pendingRanges = [];
213543
213579
  return tr;
@@ -217922,7 +217958,7 @@ var Node$13 = class Node$14 {
217922
217958
  return false;
217923
217959
  return Boolean(checker(attrs));
217924
217960
  }, SuperToolbar, ICONS, TEXTS, tableActionsOptions;
217925
- var init_src_BTrBP_Dc_es = __esm(() => {
217961
+ var init_src_BVOVss6W_es = __esm(() => {
217926
217962
  init_rolldown_runtime_B2q5OVn9_es();
217927
217963
  init_SuperConverter_C9IFvZwR_es();
217928
217964
  init_jszip_ChlR43oI_es();
@@ -229506,6 +229542,16 @@ function print() { __p += __j.call(arguments, '') }
229506
229542
  };
229507
229543
  }
229508
229544
  });
229545
+ FORMATTING_MARK_NAMES = new Set([
229546
+ "textStyle",
229547
+ "bold",
229548
+ "italic",
229549
+ "underline",
229550
+ "strike",
229551
+ "subscript",
229552
+ "superscript",
229553
+ "highlight"
229554
+ ]);
229509
229555
  LinkedStylesPluginKey = new PluginKey("linkedStyles");
229510
229556
  NodeResizerKey = new PluginKey("node-resizer");
229511
229557
  NodeResizer = Extension.create({
@@ -251533,7 +251579,7 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
251533
251579
 
251534
251580
  // ../../packages/superdoc/dist/super-editor.es.js
251535
251581
  var init_super_editor_es = __esm(() => {
251536
- init_src_BTrBP_Dc_es();
251582
+ init_src_BVOVss6W_es();
251537
251583
  init_SuperConverter_C9IFvZwR_es();
251538
251584
  init_jszip_ChlR43oI_es();
251539
251585
  init_xml_js_DLE8mr0n_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.2.0-next.131",
3
+ "version": "0.2.0-next.132",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -20,21 +20,21 @@
20
20
  "@types/bun": "^1.3.8",
21
21
  "@types/node": "22.19.2",
22
22
  "typescript": "^5.9.2",
23
- "@superdoc/pm-adapter": "0.0.0",
24
- "@superdoc/super-editor": "0.0.1",
25
23
  "@superdoc/document-api": "0.0.1",
26
- "superdoc": "1.18.0"
24
+ "@superdoc/super-editor": "0.0.1",
25
+ "superdoc": "1.18.0",
26
+ "@superdoc/pm-adapter": "0.0.0"
27
27
  },
28
28
  "module": "src/index.ts",
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
32
  "optionalDependencies": {
33
- "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.131",
34
- "@superdoc-dev/cli-darwin-x64": "0.2.0-next.131",
35
- "@superdoc-dev/cli-linux-x64": "0.2.0-next.131",
36
- "@superdoc-dev/cli-linux-arm64": "0.2.0-next.131",
37
- "@superdoc-dev/cli-windows-x64": "0.2.0-next.131"
33
+ "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.132",
34
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.132",
35
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.132",
36
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.132",
37
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.132"
38
38
  },
39
39
  "scripts": {
40
40
  "dev": "bun run src/index.ts",