@superdoc-dev/cli 0.7.0-next.18 → 0.7.0-next.19

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 +173 -5
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -205496,7 +205496,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
205496
205496
  init_remark_gfm_BhnWr3yf_es();
205497
205497
  });
205498
205498
 
205499
- // ../../packages/superdoc/dist/chunks/src-yUVuhLM1.es.js
205499
+ // ../../packages/superdoc/dist/chunks/src-DlMaB1h-.es.js
205500
205500
  function deleteProps(obj, propOrProps) {
205501
205501
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
205502
205502
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -223215,6 +223215,124 @@ function normalizeReplacementText(text5, stepId) {
223215
223215
  throw planError("INVALID_INPUT", "replacement text normalized to zero blocks", stepId);
223216
223216
  return chunks;
223217
223217
  }
223218
+ function tokenizeWords(text5) {
223219
+ const tokens = [];
223220
+ const regex = /(\s+|\S+)/g;
223221
+ let match$1;
223222
+ while ((match$1 = regex.exec(text5)) !== null)
223223
+ tokens.push({
223224
+ text: match$1[0],
223225
+ offset: match$1.index
223226
+ });
223227
+ return tokens;
223228
+ }
223229
+ function getWordChanges(oldText, newText) {
223230
+ if (oldText === newText)
223231
+ return [];
223232
+ const oldTokens = tokenizeWords(oldText);
223233
+ const newTokens = tokenizeWords(newText);
223234
+ if (oldTokens.length === 0 && newTokens.length === 0)
223235
+ return [];
223236
+ if (oldTokens.length === 0)
223237
+ return [{
223238
+ type: "insert",
223239
+ insertAt: 0,
223240
+ newText
223241
+ }];
223242
+ if (newTokens.length === 0)
223243
+ return [{
223244
+ type: "delete",
223245
+ oldFrom: 0,
223246
+ oldTo: oldText.length
223247
+ }];
223248
+ const ops = myersDiff(oldTokens, newTokens, (a2, b$1) => a2.text === b$1.text);
223249
+ const steps = [];
223250
+ let oldIdx = 0;
223251
+ let newIdx = 0;
223252
+ for (const op of ops) {
223253
+ steps.push({
223254
+ type: op,
223255
+ oldIdx,
223256
+ newIdx
223257
+ });
223258
+ if (op === "equal") {
223259
+ oldIdx++;
223260
+ newIdx++;
223261
+ } else if (op === "delete")
223262
+ oldIdx++;
223263
+ else
223264
+ newIdx++;
223265
+ }
223266
+ const result = [];
223267
+ let i4 = 0;
223268
+ while (i4 < steps.length) {
223269
+ if (steps[i4].type === "equal") {
223270
+ i4++;
223271
+ continue;
223272
+ }
223273
+ let deleteStart = -1;
223274
+ let deleteEnd = -1;
223275
+ let insertText2 = "";
223276
+ while (i4 < steps.length && (steps[i4].type === "delete" || steps[i4].type === "insert")) {
223277
+ const s2 = steps[i4];
223278
+ if (s2.type === "delete") {
223279
+ const token$1 = oldTokens[s2.oldIdx];
223280
+ if (deleteStart === -1)
223281
+ deleteStart = token$1.offset;
223282
+ deleteEnd = token$1.offset + token$1.text.length;
223283
+ } else
223284
+ insertText2 += newTokens[s2.newIdx].text;
223285
+ i4++;
223286
+ }
223287
+ if (deleteStart !== -1 && insertText2.length > 0)
223288
+ result.push({
223289
+ type: "replace",
223290
+ oldFrom: deleteStart,
223291
+ oldTo: deleteEnd,
223292
+ newText: insertText2
223293
+ });
223294
+ else if (deleteStart !== -1)
223295
+ result.push({
223296
+ type: "delete",
223297
+ oldFrom: deleteStart,
223298
+ oldTo: deleteEnd
223299
+ });
223300
+ else if (insertText2.length > 0) {
223301
+ const prevStep = i4 > 0 ? steps[i4 - 1] : null;
223302
+ let insertAt = 0;
223303
+ if (prevStep && prevStep.type === "equal") {
223304
+ const prevToken = oldTokens[prevStep.oldIdx];
223305
+ insertAt = prevToken.offset + prevToken.text.length;
223306
+ } else if (result.length > 0) {
223307
+ const lastOp = result[result.length - 1];
223308
+ insertAt = "oldTo" in lastOp ? lastOp.oldTo : ("insertAt" in lastOp) ? lastOp.insertAt : 0;
223309
+ }
223310
+ result.push({
223311
+ type: "insert",
223312
+ insertAt,
223313
+ newText: insertText2
223314
+ });
223315
+ }
223316
+ }
223317
+ return result;
223318
+ }
223319
+ function charOffsetToDocPos(doc$12, rangeFrom, rangeTo, charOffset) {
223320
+ let count2 = 0;
223321
+ let foundPos = -1;
223322
+ doc$12.nodesBetween(rangeFrom, rangeTo, (node3, pos) => {
223323
+ if (foundPos >= 0)
223324
+ return false;
223325
+ if (!node3.isText)
223326
+ return true;
223327
+ const textStart = Math.max(pos, rangeFrom);
223328
+ const textLen = Math.min(pos + node3.nodeSize, rangeTo) - textStart;
223329
+ if (count2 + textLen >= charOffset)
223330
+ foundPos = textStart + (charOffset - count2);
223331
+ count2 += textLen;
223332
+ return false;
223333
+ });
223334
+ return foundPos >= 0 ? foundPos : rangeTo;
223335
+ }
223218
223336
  function debugTextRewrite(message, details) {
223219
223337
  if (!DEBUG_TEXT_REWRITE)
223220
223338
  return;
@@ -223703,8 +223821,58 @@ function executeTextRewrite(editor, tr, target, step3, mapping) {
223703
223821
  });
223704
223822
  }
223705
223823
  }
223706
- const textNode = editor.state.schema.text(replacementText, asProseMirrorMarks(marks));
223707
- tr.replaceWith(absFrom, absTo, textNode);
223824
+ const originalText = tr.doc.textBetween(absFrom, absTo, "", "");
223825
+ const origLen = originalText.length;
223826
+ const replLen = replacementText.length;
223827
+ let prefix2 = 0;
223828
+ while (prefix2 < origLen && prefix2 < replLen && originalText[prefix2] === replacementText[prefix2])
223829
+ prefix2++;
223830
+ if (prefix2 === origLen && prefix2 === replLen)
223831
+ return { changed: false };
223832
+ let suffix = 0;
223833
+ while (suffix < origLen - prefix2 && suffix < replLen - prefix2 && originalText[origLen - 1 - suffix] === replacementText[replLen - 1 - suffix])
223834
+ suffix++;
223835
+ const trimmedFrom = charOffsetToDocPos(tr.doc, absFrom, absTo, prefix2);
223836
+ const trimmedTo = charOffsetToDocPos(tr.doc, absFrom, absTo, origLen - suffix);
223837
+ const trimmedOld = originalText.slice(prefix2, origLen - suffix);
223838
+ const trimmedNew = replacementText.slice(prefix2, replLen - suffix);
223839
+ const wordChanges = getWordChanges(trimmedOld, trimmedNew);
223840
+ if (wordChanges.length > 1) {
223841
+ const doc$12 = tr.doc;
223842
+ const baseSteps = tr.steps.length;
223843
+ const mapped = wordChanges.map((change) => {
223844
+ if (change.type === "insert")
223845
+ return {
223846
+ ...change,
223847
+ docPos: charOffsetToDocPos(doc$12, trimmedFrom, trimmedTo, change.insertAt)
223848
+ };
223849
+ return {
223850
+ ...change,
223851
+ docFrom: charOffsetToDocPos(doc$12, trimmedFrom, trimmedTo, change.oldFrom),
223852
+ docTo: charOffsetToDocPos(doc$12, trimmedFrom, trimmedTo, change.oldTo)
223853
+ };
223854
+ });
223855
+ for (let i4 = 0;i4 < mapped.length; i4++) {
223856
+ const change = mapped[i4];
223857
+ const remap = (pos) => {
223858
+ for (let s2 = baseSteps;s2 < tr.steps.length; s2++)
223859
+ pos = tr.steps[s2].getMap().map(pos);
223860
+ return pos;
223861
+ };
223862
+ if (change.type === "delete")
223863
+ tr.delete(remap(change.docFrom), remap(change.docTo));
223864
+ else if (change.type === "insert") {
223865
+ const node3 = editor.state.schema.text(change.newText, asProseMirrorMarks(marks));
223866
+ tr.insert(remap(change.docPos), node3);
223867
+ } else {
223868
+ const node3 = editor.state.schema.text(change.newText, asProseMirrorMarks(marks));
223869
+ tr.replaceWith(remap(change.docFrom), remap(change.docTo), node3);
223870
+ }
223871
+ }
223872
+ } else {
223873
+ const textNode = editor.state.schema.text(trimmedNew, asProseMirrorMarks(marks));
223874
+ tr.replaceWith(trimmedFrom, trimmedTo, textNode);
223875
+ }
223708
223876
  return { changed: replacementText !== target.text };
223709
223877
  }
223710
223878
  function executeTextInsert(editor, tr, target, step3, mapping) {
@@ -289115,7 +289283,7 @@ var Node$13 = class Node$14 {
289115
289283
  return;
289116
289284
  console.log(...args$1);
289117
289285
  }, 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;
289118
- var init_src_yUVuhLM1_es = __esm(() => {
289286
+ var init_src_DlMaB1h_es = __esm(() => {
289119
289287
  init_rolldown_runtime_Bg48TavK_es();
289120
289288
  init_SuperConverter_BgwP1GeS_es();
289121
289289
  init_jszip_C49i9kUs_es();
@@ -323733,7 +323901,7 @@ var init_zipper_DbkgrypV_es = __esm(() => {
323733
323901
 
323734
323902
  // ../../packages/superdoc/dist/super-editor.es.js
323735
323903
  var init_super_editor_es = __esm(() => {
323736
- init_src_yUVuhLM1_es();
323904
+ init_src_DlMaB1h_es();
323737
323905
  init_SuperConverter_BgwP1GeS_es();
323738
323906
  init_jszip_C49i9kUs_es();
323739
323907
  init_xml_js_CqGKpaft_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.7.0-next.18",
3
+ "version": "0.7.0-next.19",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -26,19 +26,19 @@
26
26
  "typescript": "^5.9.2",
27
27
  "@superdoc/document-api": "0.0.1",
28
28
  "@superdoc/super-editor": "0.0.1",
29
- "superdoc": "1.26.0",
30
- "@superdoc/pm-adapter": "0.0.0"
29
+ "@superdoc/pm-adapter": "0.0.0",
30
+ "superdoc": "1.26.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.7.0-next.18",
38
- "@superdoc-dev/cli-darwin-x64": "0.7.0-next.18",
39
- "@superdoc-dev/cli-linux-x64": "0.7.0-next.18",
40
- "@superdoc-dev/cli-windows-x64": "0.7.0-next.18",
41
- "@superdoc-dev/cli-linux-arm64": "0.7.0-next.18"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.7.0-next.19",
38
+ "@superdoc-dev/cli-darwin-x64": "0.7.0-next.19",
39
+ "@superdoc-dev/cli-linux-arm64": "0.7.0-next.19",
40
+ "@superdoc-dev/cli-linux-x64": "0.7.0-next.19",
41
+ "@superdoc-dev/cli-windows-x64": "0.7.0-next.19"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",