@ai-matrx/office 0.8.9 → 0.8.11

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.
package/CHANGELOG.md CHANGED
@@ -1,13 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.11
4
+
5
+ - Docs co-editing (C3): a collaborator's edit now moves this seat's caret with the characters (§6.8). The view port gains an optional `selection { get, set }`; `DocumentModel` moves body ranges through each applied remote edit (`moveRangesThroughBodyEdit`). Found in the live two-browser run: with the caret left at its old offset, the next keystrokes landed scattered. Consumer action: pass `selection` from Univer's `DocSelectionManagerService` in the view port.
6
+
3
7
  ### Unreleased
4
8
 
5
9
  - **`Workbook` and `DocumentRow` carry `test_expires_at` / `test_run_id`** — the `workbench.udt_workbooks` / `udt_documents` rows gained these test-fixture columns; the hand-written types now match the generated row again (matrx-frontend `features/data-tables/office-types-agree.ts`). Consumer action: none (a literal building one of these rows must add the two fields, `null` for real records).
6
10
 
7
11
  ## 0.8.9
8
12
 
9
- UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
10
- Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/office/src`.
13
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
14
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
15
+ Diff: `git diff 14c15decf1 1c52fd1b8c -- apps/shared/office/src`
16
+
17
+ Changed shipped source files (14):
18
+ - `apps/shared/office/src/collab/sheets/transform/fuzz/seats.ts`
19
+ - `apps/shared/office/src/collab/sheets/transform/transform.ts`
20
+ - `apps/shared/office/src/core/document-page-style.ts`
21
+ - `apps/shared/office/src/core/page-setup-apply.ts`
22
+ - `apps/shared/office/src/docs/doc-edit-ops.ts`
23
+ - `apps/shared/office/src/docs/doc-tools-core.ts`
24
+ - `apps/shared/office/src/docs/document-write-validation.ts`
25
+ - `apps/shared/office/src/sheets/import-workbook-file.ts`
26
+ - `apps/shared/office/src/sheets/snapshot-grid.ts`
27
+ - `apps/shared/office/src/sheets/xlsx-shared.ts`
28
+ - `apps/shared/office/src/univer/collab/docs-ot/state-hash.ts`
29
+ - `apps/shared/office/src/univer/collab/docs-ot/transform.ts`
30
+ - ...and 2 more
11
31
 
12
32
  ## 0.8.8
13
33
 
package/dist/docs.cjs CHANGED
@@ -22,6 +22,9 @@ var _chunkHX5TXQIXcjs = require('./chunk-HX5TXQIX.cjs');
22
22
  var _chunkNSU6EVJKcjs = require('./chunk-NSU6EVJK.cjs');
23
23
  require('./chunk-XAIKXHHJ.cjs');
24
24
 
25
+ // src/docs/document-model.ts
26
+ var _core = require('@univerjs/core');
27
+
25
28
  // src/univer/isSnapshotMutation.ts
26
29
  var MUTATION = 2;
27
30
  var NON_CONTENT_ID_PATTERN = /(scroll|selection|set-selections|viewport|zoom|hover|cursor|focus|activate)/i;
@@ -188,13 +191,13 @@ var DocumentModel = (_class = class {
188
191
  return editor;
189
192
  }
190
193
  onViewMutation(viewId, info, options) {
191
- if (this.relaying || _optionalChain([options, 'optionalAccess', _7 => _7.fromCollab]) || _optionalChain([options, 'optionalAccess', _8 => _8.fromChangeset])) return;
194
+ if (this.relaying || _optionalChain([options, 'optionalAccess', _15 => _15.fromCollab]) || _optionalChain([options, 'optionalAccess', _16 => _16.fromChangeset])) return;
192
195
  const view = this.views.get(viewId);
193
196
  if (!view || !view.port.editable()) return;
194
197
  this.lastEditedView = viewId;
195
198
  this.relay(info, viewId);
196
199
  for (const listener of this.collabListeners) listener(info, options);
197
- if (this.otListeners.size && !_optionalChain([options, 'optionalAccess', _9 => _9.onlyLocal])) {
200
+ if (this.otListeners.size && !_optionalChain([options, 'optionalAccess', _17 => _17.onlyLocal])) {
198
201
  const m = {
199
202
  id: info.id,
200
203
  params: info.params,
@@ -223,7 +226,7 @@ var DocumentModel = (_class = class {
223
226
  try {
224
227
  const snap = view.port.snapshot();
225
228
  view.pre = snap ? structuredClone(snap) : null;
226
- } catch (e3) {
229
+ } catch (e4) {
227
230
  view.pre = null;
228
231
  }
229
232
  }
@@ -254,8 +257,8 @@ var DocumentModel = (_class = class {
254
257
  /** The unit id a view's document has (what a replayed mutation must be addressed to). */
255
258
  unitIdOf(view) {
256
259
  try {
257
- return _nullishCoalesce(_nullishCoalesce(_optionalChain([view, 'access', _10 => _10.port, 'access', _11 => _11.unitId, 'optionalCall', _12 => _12()]), () => ( _optionalChain([view, 'access', _13 => _13.port, 'access', _14 => _14.snapshot, 'call', _15 => _15(), 'optionalAccess', _16 => _16.id]))), () => ( null));
258
- } catch (e4) {
260
+ return _nullishCoalesce(_nullishCoalesce(_optionalChain([view, 'access', _18 => _18.port, 'access', _19 => _19.unitId, 'optionalCall', _20 => _20()]), () => ( _optionalChain([view, 'access', _21 => _21.port, 'access', _22 => _22.snapshot, 'call', _23 => _23(), 'optionalAccess', _24 => _24.id]))), () => ( null));
261
+ } catch (e5) {
259
262
  return null;
260
263
  }
261
264
  }
@@ -288,7 +291,7 @@ var DocumentModel = (_class = class {
288
291
  /** A view could not follow an edit: say so, then show the saved version (unless this tab has unsaved edits of its own). */
289
292
  applyFailed(mutationId, error) {
290
293
  try {
291
- _optionalChain([this, 'access', _17 => _17.deps, 'access', _18 => _18.onApplyFailed, 'optionalCall', _19 => _19(this.documentId, mutationId, error)]);
294
+ _optionalChain([this, 'access', _25 => _25.deps, 'access', _26 => _26.onApplyFailed, 'optionalCall', _27 => _27(this.documentId, mutationId, error)]);
292
295
  } catch (notifyError) {
293
296
  console.warn(`[document-model] the notice for ${this.documentId}'s failed apply also failed`, notifyError);
294
297
  }
@@ -316,7 +319,7 @@ var DocumentModel = (_class = class {
316
319
  async write(reason) {
317
320
  if (this.ot) {
318
321
  const wrote = await this.ot.write(reason);
319
- if (wrote) _optionalChain([this, 'access', _20 => _20.deps, 'access', _21 => _21.onSaved, 'optionalCall', _22 => _22(this.documentId, reason === "manual" ? "manual" : "autosave")]);
322
+ if (wrote) _optionalChain([this, 'access', _28 => _28.deps, 'access', _29 => _29.onSaved, 'optionalCall', _30 => _30(this.documentId, reason === "manual" ? "manual" : "autosave")]);
320
323
  return wrote;
321
324
  }
322
325
  const snapshot = this.latest();
@@ -341,7 +344,7 @@ var DocumentModel = (_class = class {
341
344
  this.saving = false;
342
345
  }
343
346
  if (this.views.size === 0) this.stored = snapshot;
344
- _optionalChain([this, 'access', _23 => _23.deps, 'access', _24 => _24.onSaved, 'optionalCall', _25 => _25(this.documentId, origin)]);
347
+ _optionalChain([this, 'access', _31 => _31.deps, 'access', _32 => _32.onSaved, 'optionalCall', _33 => _33(this.documentId, origin)]);
345
348
  return true;
346
349
  }
347
350
  hasUnsaved() {
@@ -384,7 +387,7 @@ var DocumentModel = (_class = class {
384
387
  replaceContent(row) {
385
388
  if (this.ot) return this.ot.replace(row.snapshot);
386
389
  this.show(row);
387
- _optionalChain([this, 'access', _26 => _26.collab, 'optionalAccess', _27 => _27.announceReplaced, 'call', _28 => _28(row.id)]);
390
+ _optionalChain([this, 'access', _34 => _34.collab, 'optionalAccess', _35 => _35.announceReplaced, 'call', _36 => _36(row.id)]);
388
391
  }
389
392
  /** A peer replaced the document: show the newest save (once). */
390
393
  async onPeerReplaced() {
@@ -407,7 +410,7 @@ var DocumentModel = (_class = class {
407
410
  this.relaying = true;
408
411
  try {
409
412
  for (const view of this.views.values()) view.port.remount(snapshot);
410
- _optionalChain([this, 'access', _29 => _29.parked, 'optionalAccess', _30 => _30.remount, 'call', _31 => _31(snapshot)]);
413
+ _optionalChain([this, 'access', _37 => _37.parked, 'optionalAccess', _38 => _38.remount, 'call', _39 => _39(snapshot)]);
411
414
  } finally {
412
415
  this.relaying = false;
413
416
  }
@@ -479,10 +482,24 @@ var DocumentModel = (_class = class {
479
482
  for (const view of this.views.values()) {
480
483
  const unitId = this.unitIdOf(view);
481
484
  const input = Array.isArray(params.actions) ? params.actions.length : 0;
485
+ let sel = null;
486
+ try {
487
+ sel = _nullishCoalesce(_optionalChain([view, 'access', _40 => _40.port, 'access', _41 => _41.selection, 'optionalAccess', _42 => _42.get, 'call', _43 => _43()]), () => ( null));
488
+ } catch (e6) {
489
+ sel = null;
490
+ }
482
491
  const p = { ...params, ...unitId ? { unitId } : {}, textRanges: null, noNeedSetTextRange: true };
483
492
  const ok = view.port.commandService.syncExecuteCommand(id, p, { onlyLocal: true, fromCollab: true });
484
493
  if (ok === false) throw new Error(`"${id}" was refused by the editor`);
485
494
  if (input > 0 && Array.isArray(p.actions) && p.actions.length === 0) throw new Error(`"${id}" was emptied by the editor`);
495
+ const moved = sel && sel.length && sel.every((r) => !r.segmentId) ? moveRangesThroughBodyEdit(sel, params.actions) : null;
496
+ if (moved) {
497
+ try {
498
+ _optionalChain([view, 'access', _44 => _44.port, 'access', _45 => _45.selection, 'optionalAccess', _46 => _46.set, 'call', _47 => _47(moved)]);
499
+ } catch (error) {
500
+ console.warn(`[document-model] could not move this view's caret past a collaborator's edit`, error);
501
+ }
502
+ }
486
503
  }
487
504
  } finally {
488
505
  this.relaying = false;
@@ -497,7 +514,7 @@ var DocumentModel = (_class = class {
497
514
  this.relaying = true;
498
515
  try {
499
516
  for (const view of this.views.values()) view.port.remount(s2);
500
- _optionalChain([this, 'access', _32 => _32.parked, 'optionalAccess', _33 => _33.remount, 'call', _34 => _34(s2)]);
517
+ _optionalChain([this, 'access', _48 => _48.parked, 'optionalAccess', _49 => _49.remount, 'call', _50 => _50(s2)]);
501
518
  } finally {
502
519
  this.relaying = false;
503
520
  }
@@ -506,7 +523,7 @@ var DocumentModel = (_class = class {
506
523
  const out = [];
507
524
  for (const view of this.views.values()) {
508
525
  const unitId = this.unitIdOf(view);
509
- const service = _optionalChain([view, 'access', _35 => _35.port, 'access', _36 => _36.undoRedo, 'optionalCall', _37 => _37()]);
526
+ const service = _optionalChain([view, 'access', _51 => _51.port, 'access', _52 => _52.undoRedo, 'optionalCall', _53 => _53()]);
510
527
  if (unitId && service) out.push({ service, unitId });
511
528
  }
512
529
  return out;
@@ -564,9 +581,9 @@ var DocumentModel = (_class = class {
564
581
  * so a collaborator's save still reaches the body a returning view boots from.
565
582
  */
566
583
  rest() {
567
- _optionalChain([this, 'access', _38 => _38.collab, 'optionalAccess', _39 => _39.stop, 'call', _40 => _40()]);
584
+ _optionalChain([this, 'access', _54 => _54.collab, 'optionalAccess', _55 => _55.stop, 'call', _56 => _56()]);
568
585
  this.collab = null;
569
- _optionalChain([this, 'access', _41 => _41.ot, 'optionalAccess', _42 => _42.stop, 'call', _43 => _43()]);
586
+ _optionalChain([this, 'access', _57 => _57.ot, 'optionalAccess', _58 => _58.stop, 'call', _59 => _59()]);
570
587
  this.ot = null;
571
588
  this.awareness = null;
572
589
  }
@@ -582,12 +599,20 @@ var DocumentModel = (_class = class {
582
599
  console.warn(`[document-model] could not dispose ${this.documentId}'s kept editor`, error);
583
600
  }
584
601
  }
585
- _optionalChain([this, 'access', _44 => _44.realtimeClose, 'optionalCall', _45 => _45()]);
602
+ _optionalChain([this, 'access', _60 => _60.realtimeClose, 'optionalCall', _61 => _61()]);
586
603
  this.realtimeClose = null;
587
- _optionalChain([this, 'access', _46 => _46.pageClose, 'optionalCall', _47 => _47()]);
604
+ _optionalChain([this, 'access', _62 => _62.pageClose, 'optionalCall', _63 => _63()]);
588
605
  this.pageClose = null;
589
606
  }
590
607
  }, _class);
608
+ function moveRangesThroughBodyEdit(ranges, actions) {
609
+ const a = actions;
610
+ if (!Array.isArray(a) || a[0] !== "body") return null;
611
+ const sub = a[1];
612
+ if (!sub || sub.et !== "text-x" || !Array.isArray(sub.e)) return null;
613
+ const e2 = sub.e;
614
+ return ranges.map((r) => ({ startOffset: _core.TextX.transformPosition(e2, r.startOffset, false), endOffset: _core.TextX.transformPosition(e2, r.endOffset, false) }));
615
+ }
591
616
  function contentFingerprint(snapshot) {
592
617
  const { id: _id, rev: _rev, ...content } = snapshot;
593
618
  return JSON.stringify(content);
@@ -860,5 +885,6 @@ function documentBodyWriteHandler(deps) {
860
885
 
861
886
 
862
887
 
863
- exports.DOCUMENT_BODY_MAX_LENGTH = DOCUMENT_BODY_MAX_LENGTH; exports.DOCUMENT_DESCRIPTION_MAX_LENGTH = DOCUMENT_DESCRIPTION_MAX_LENGTH; exports.DOCUMENT_NAME_MAX_LENGTH = DOCUMENT_NAME_MAX_LENGTH; exports.DOCUMENT_SAVE_DELAY_MS = DOCUMENT_SAVE_DELAY_MS; exports.DocumentModel = DocumentModel; exports.EMOJI_GROUPS = EMOJI_GROUPS; exports.MIN_FIT_ZOOM = MIN_FIT_ZOOM; exports.SPECIAL_GROUPS = SPECIAL_GROUPS; exports.bodyTextOf = bodyTextOf; exports.configureDocsHost = _chunkHX5TXQIXcjs.configureDocsHost; exports.copyDocument = _chunkHX5TXQIXcjs.copyDocument; exports.createDocument = _chunkHX5TXQIXcjs.createDocument; exports.deleteDocument = _chunkHX5TXQIXcjs.deleteDocument; exports.discardFailedDocument = _chunkHX5TXQIXcjs.discardFailedDocument; exports.documentBodyWriteHandler = documentBodyWriteHandler; exports.documentSourceLabel = documentSourceLabel; exports.fitZoomRatio = fitZoomRatio; exports.getDocsHost = _chunkHX5TXQIXcjs.getDocsHost; exports.getDocument = _chunkHX5TXQIXcjs.getDocument; exports.getLatestDocumentSnapshot = _chunkHX5TXQIXcjs.getLatestDocumentSnapshot; exports.listAccessibleDocuments = _chunkHX5TXQIXcjs.listAccessibleDocuments; exports.listDocumentSnapshots = _chunkHX5TXQIXcjs.listDocumentSnapshots; exports.listTrashedDocuments = _chunkHX5TXQIXcjs.listTrashedDocuments; exports.moveDocument = _chunkHX5TXQIXcjs.moveDocument; exports.planBodyEdit = planBodyEdit; exports.renameDocument = _chunkHX5TXQIXcjs.renameDocument; exports.restoreDocument = _chunkHX5TXQIXcjs.restoreDocument; exports.sanitizeUniverDocSnapshot = _chunkHX5TXQIXcjs.sanitizeUniverDocSnapshot; exports.saveDocumentSnapshot = _chunkHX5TXQIXcjs.saveDocumentSnapshot; exports.searchSymbols = searchSymbols; exports.updateDocumentDescription = _chunkHX5TXQIXcjs.updateDocumentDescription; exports.validateDocumentBody = validateDocumentBody; exports.validateDocumentDescription = validateDocumentDescription; exports.validateDocumentName = validateDocumentName; exports.writeBodyText = writeBodyText;
888
+
889
+ exports.DOCUMENT_BODY_MAX_LENGTH = DOCUMENT_BODY_MAX_LENGTH; exports.DOCUMENT_DESCRIPTION_MAX_LENGTH = DOCUMENT_DESCRIPTION_MAX_LENGTH; exports.DOCUMENT_NAME_MAX_LENGTH = DOCUMENT_NAME_MAX_LENGTH; exports.DOCUMENT_SAVE_DELAY_MS = DOCUMENT_SAVE_DELAY_MS; exports.DocumentModel = DocumentModel; exports.EMOJI_GROUPS = EMOJI_GROUPS; exports.MIN_FIT_ZOOM = MIN_FIT_ZOOM; exports.SPECIAL_GROUPS = SPECIAL_GROUPS; exports.bodyTextOf = bodyTextOf; exports.configureDocsHost = _chunkHX5TXQIXcjs.configureDocsHost; exports.copyDocument = _chunkHX5TXQIXcjs.copyDocument; exports.createDocument = _chunkHX5TXQIXcjs.createDocument; exports.deleteDocument = _chunkHX5TXQIXcjs.deleteDocument; exports.discardFailedDocument = _chunkHX5TXQIXcjs.discardFailedDocument; exports.documentBodyWriteHandler = documentBodyWriteHandler; exports.documentSourceLabel = documentSourceLabel; exports.fitZoomRatio = fitZoomRatio; exports.getDocsHost = _chunkHX5TXQIXcjs.getDocsHost; exports.getDocument = _chunkHX5TXQIXcjs.getDocument; exports.getLatestDocumentSnapshot = _chunkHX5TXQIXcjs.getLatestDocumentSnapshot; exports.listAccessibleDocuments = _chunkHX5TXQIXcjs.listAccessibleDocuments; exports.listDocumentSnapshots = _chunkHX5TXQIXcjs.listDocumentSnapshots; exports.listTrashedDocuments = _chunkHX5TXQIXcjs.listTrashedDocuments; exports.moveDocument = _chunkHX5TXQIXcjs.moveDocument; exports.moveRangesThroughBodyEdit = moveRangesThroughBodyEdit; exports.planBodyEdit = planBodyEdit; exports.renameDocument = _chunkHX5TXQIXcjs.renameDocument; exports.restoreDocument = _chunkHX5TXQIXcjs.restoreDocument; exports.sanitizeUniverDocSnapshot = _chunkHX5TXQIXcjs.sanitizeUniverDocSnapshot; exports.saveDocumentSnapshot = _chunkHX5TXQIXcjs.saveDocumentSnapshot; exports.searchSymbols = searchSymbols; exports.updateDocumentDescription = _chunkHX5TXQIXcjs.updateDocumentDescription; exports.validateDocumentBody = validateDocumentBody; exports.validateDocumentDescription = validateDocumentDescription; exports.validateDocumentName = validateDocumentName; exports.writeBodyText = writeBodyText;
864
890
  //# sourceMappingURL=docs.cjs.map