@ai-matrx/office 0.8.44 → 0.8.45
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 +17 -2
- package/dist/collab-sheets-transform.cjs +12 -0
- package/dist/collab-sheets-transform.cjs.map +1 -1
- package/dist/collab-sheets-transform.js +12 -0
- package/dist/collab-sheets-transform.js.map +1 -1
- package/dist/docs.cjs +85 -24
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.d.cts +15 -1
- package/dist/docs.d.ts +15 -1
- package/dist/docs.js +65 -4
- package/dist/docs.js.map +1 -1
- package/dist/univer-collab.cjs +196 -15
- package/dist/univer-collab.cjs.map +1 -1
- package/dist/univer-collab.d.cts +68 -7
- package/dist/univer-collab.d.ts +68 -7
- package/dist/univer-collab.js +196 -15
- package/dist/univer-collab.js.map +1 -1
- package/package.json +6 -5
package/dist/docs.cjs
CHANGED
|
@@ -322,9 +322,12 @@ var DocumentModel = (_class = class {
|
|
|
322
322
|
const cs = view.port.commandService;
|
|
323
323
|
if (typeof cs.beforeCommandExecuted !== "function" || typeof cs.onCommandExecuted !== "function") return () => {
|
|
324
324
|
};
|
|
325
|
-
const before = cs.beforeCommandExecuted((info) => {
|
|
325
|
+
const before = cs.beforeCommandExecuted((info, options) => {
|
|
326
326
|
if (info.type === COMMAND_TYPE) view.commands.push(info.id);
|
|
327
|
-
else if (info.id === RICH_TEXT_EDITING_ID && this.
|
|
327
|
+
else if (info.id === RICH_TEXT_EDITING_ID && !this.relaying && !_optionalChain([options, 'optionalAccess', _29 => _29.fromCollab]) && !_optionalChain([options, 'optionalAccess', _30 => _30.onlyLocal])) {
|
|
328
|
+
keepInsideTheBody(info.params, () => view.port.snapshot());
|
|
329
|
+
}
|
|
330
|
+
if (info.id === RICH_TEXT_EDITING_ID && this.otListeners.size && !this.relaying) {
|
|
328
331
|
try {
|
|
329
332
|
const snap = view.port.snapshot();
|
|
330
333
|
view.pre = snap ? structuredClone(snap) : null;
|
|
@@ -359,7 +362,7 @@ var DocumentModel = (_class = class {
|
|
|
359
362
|
/** The unit id a view's document has (what a replayed mutation must be addressed to). */
|
|
360
363
|
unitIdOf(view) {
|
|
361
364
|
try {
|
|
362
|
-
return _nullishCoalesce(_nullishCoalesce(_optionalChain([view, 'access',
|
|
365
|
+
return _nullishCoalesce(_nullishCoalesce(_optionalChain([view, 'access', _31 => _31.port, 'access', _32 => _32.unitId, 'optionalCall', _33 => _33()]), () => ( _optionalChain([view, 'access', _34 => _34.port, 'access', _35 => _35.snapshot, 'call', _36 => _36(), 'optionalAccess', _37 => _37.id]))), () => ( null));
|
|
363
366
|
} catch (e6) {
|
|
364
367
|
return null;
|
|
365
368
|
}
|
|
@@ -393,7 +396,7 @@ var DocumentModel = (_class = class {
|
|
|
393
396
|
/** A view could not follow an edit: say so, then show the saved version (unless this tab has unsaved edits of its own). */
|
|
394
397
|
applyFailed(mutationId, error) {
|
|
395
398
|
try {
|
|
396
|
-
_optionalChain([this, 'access',
|
|
399
|
+
_optionalChain([this, 'access', _38 => _38.deps, 'access', _39 => _39.onApplyFailed, 'optionalCall', _40 => _40(this.documentId, mutationId, error)]);
|
|
397
400
|
} catch (notifyError) {
|
|
398
401
|
console.warn(`[document-model] the notice for ${this.documentId}'s failed apply also failed`, notifyError);
|
|
399
402
|
}
|
|
@@ -421,7 +424,7 @@ var DocumentModel = (_class = class {
|
|
|
421
424
|
async write(reason) {
|
|
422
425
|
if (this.ot) {
|
|
423
426
|
const wrote = await this.ot.write(reason);
|
|
424
|
-
if (wrote) _optionalChain([this, 'access',
|
|
427
|
+
if (wrote) _optionalChain([this, 'access', _41 => _41.deps, 'access', _42 => _42.onSaved, 'optionalCall', _43 => _43(this.documentId, reason === "manual" ? "manual" : "autosave")]);
|
|
425
428
|
return wrote;
|
|
426
429
|
}
|
|
427
430
|
const snapshot = this.latest();
|
|
@@ -446,7 +449,7 @@ var DocumentModel = (_class = class {
|
|
|
446
449
|
this.saving = false;
|
|
447
450
|
}
|
|
448
451
|
if (this.views.size === 0) this.stored = snapshot;
|
|
449
|
-
_optionalChain([this, 'access',
|
|
452
|
+
_optionalChain([this, 'access', _44 => _44.deps, 'access', _45 => _45.onSaved, 'optionalCall', _46 => _46(this.documentId, origin)]);
|
|
450
453
|
return true;
|
|
451
454
|
}
|
|
452
455
|
hasUnsaved() {
|
|
@@ -489,7 +492,7 @@ var DocumentModel = (_class = class {
|
|
|
489
492
|
replaceContent(row) {
|
|
490
493
|
if (this.ot) return this.ot.replace(row.snapshot);
|
|
491
494
|
this.show(row);
|
|
492
|
-
_optionalChain([this, 'access',
|
|
495
|
+
_optionalChain([this, 'access', _47 => _47.collab, 'optionalAccess', _48 => _48.announceReplaced, 'call', _49 => _49(row.id)]);
|
|
493
496
|
}
|
|
494
497
|
/** A peer replaced the document: show the newest save (once). */
|
|
495
498
|
async onPeerReplaced() {
|
|
@@ -511,8 +514,8 @@ var DocumentModel = (_class = class {
|
|
|
511
514
|
this.stored = snapshot;
|
|
512
515
|
this.relaying = true;
|
|
513
516
|
try {
|
|
514
|
-
for (const view of this.views.values()) view.port
|
|
515
|
-
_optionalChain([this, 'access',
|
|
517
|
+
for (const view of this.views.values()) remountKeepingCaret(view.port, snapshot);
|
|
518
|
+
_optionalChain([this, 'access', _50 => _50.parked, 'optionalAccess', _51 => _51.remount, 'call', _52 => _52(snapshot)]);
|
|
516
519
|
} finally {
|
|
517
520
|
this.relaying = false;
|
|
518
521
|
}
|
|
@@ -586,7 +589,7 @@ var DocumentModel = (_class = class {
|
|
|
586
589
|
const input = Array.isArray(params.actions) ? params.actions.length : 0;
|
|
587
590
|
let sel = null;
|
|
588
591
|
try {
|
|
589
|
-
sel = _nullishCoalesce(_optionalChain([view, 'access',
|
|
592
|
+
sel = _nullishCoalesce(_optionalChain([view, 'access', _53 => _53.port, 'access', _54 => _54.selection, 'optionalAccess', _55 => _55.get, 'call', _56 => _56()]), () => ( null));
|
|
590
593
|
} catch (e7) {
|
|
591
594
|
sel = null;
|
|
592
595
|
}
|
|
@@ -597,7 +600,7 @@ var DocumentModel = (_class = class {
|
|
|
597
600
|
const moved = sel && sel.length && sel.every((r) => !r.segmentId) ? moveRangesThroughBodyEdit(sel, params.actions) : null;
|
|
598
601
|
if (moved) {
|
|
599
602
|
try {
|
|
600
|
-
_optionalChain([view, 'access',
|
|
603
|
+
_optionalChain([view, 'access', _57 => _57.port, 'access', _58 => _58.selection, 'optionalAccess', _59 => _59.set, 'call', _60 => _60(moved)]);
|
|
601
604
|
} catch (error) {
|
|
602
605
|
console.warn(`[document-model] could not move this view's caret past a collaborator's edit`, error);
|
|
603
606
|
}
|
|
@@ -615,8 +618,8 @@ var DocumentModel = (_class = class {
|
|
|
615
618
|
this.savedFingerprint = contentFingerprint(s2);
|
|
616
619
|
this.relaying = true;
|
|
617
620
|
try {
|
|
618
|
-
for (const view of this.views.values()) view.port
|
|
619
|
-
_optionalChain([this, 'access',
|
|
621
|
+
for (const view of this.views.values()) remountKeepingCaret(view.port, s2);
|
|
622
|
+
_optionalChain([this, 'access', _61 => _61.parked, 'optionalAccess', _62 => _62.remount, 'call', _63 => _63(s2)]);
|
|
620
623
|
} finally {
|
|
621
624
|
this.relaying = false;
|
|
622
625
|
}
|
|
@@ -625,7 +628,7 @@ var DocumentModel = (_class = class {
|
|
|
625
628
|
const out = [];
|
|
626
629
|
for (const view of this.views.values()) {
|
|
627
630
|
const unitId = this.unitIdOf(view);
|
|
628
|
-
const service = _optionalChain([view, 'access',
|
|
631
|
+
const service = _optionalChain([view, 'access', _64 => _64.port, 'access', _65 => _65.undoRedo, 'optionalCall', _66 => _66()]);
|
|
629
632
|
if (!unitId || !service) continue;
|
|
630
633
|
const port = view.port;
|
|
631
634
|
out.push({
|
|
@@ -633,7 +636,7 @@ var DocumentModel = (_class = class {
|
|
|
633
636
|
unitId,
|
|
634
637
|
flushHistory: () => {
|
|
635
638
|
try {
|
|
636
|
-
_optionalChain([port, 'access',
|
|
639
|
+
_optionalChain([port, 'access', _67 => _67.docHistory, 'optionalCall', _68 => _68(), 'optionalAccess', _69 => _69.flushPendingChanges, 'call', _70 => _70(unitId)]);
|
|
637
640
|
} catch (error) {
|
|
638
641
|
console.warn(`[document-model] could not close this view's typing burst before a collaborator's edit`, error);
|
|
639
642
|
}
|
|
@@ -646,7 +649,7 @@ var DocumentModel = (_class = class {
|
|
|
646
649
|
selection: () => {
|
|
647
650
|
for (const view of this.views.values()) {
|
|
648
651
|
try {
|
|
649
|
-
const sel = _optionalChain([view, 'access',
|
|
652
|
+
const sel = _optionalChain([view, 'access', _71 => _71.port, 'access', _72 => _72.selection, 'optionalAccess', _73 => _73.get, 'call', _74 => _74()]);
|
|
650
653
|
if (sel) return sel;
|
|
651
654
|
} catch (e8) {
|
|
652
655
|
}
|
|
@@ -705,9 +708,9 @@ var DocumentModel = (_class = class {
|
|
|
705
708
|
* so a collaborator's save still reaches the body a returning view boots from.
|
|
706
709
|
*/
|
|
707
710
|
rest() {
|
|
708
|
-
_optionalChain([this, 'access',
|
|
711
|
+
_optionalChain([this, 'access', _75 => _75.collab, 'optionalAccess', _76 => _76.stop, 'call', _77 => _77()]);
|
|
709
712
|
this.collab = null;
|
|
710
|
-
_optionalChain([this, 'access',
|
|
713
|
+
_optionalChain([this, 'access', _78 => _78.ot, 'optionalAccess', _79 => _79.stop, 'call', _80 => _80()]);
|
|
711
714
|
this.ot = null;
|
|
712
715
|
this.awareness = null;
|
|
713
716
|
}
|
|
@@ -723,12 +726,68 @@ var DocumentModel = (_class = class {
|
|
|
723
726
|
console.warn(`[document-model] could not dispose ${this.documentId}'s kept editor`, error);
|
|
724
727
|
}
|
|
725
728
|
}
|
|
726
|
-
_optionalChain([this, 'access',
|
|
729
|
+
_optionalChain([this, 'access', _81 => _81.realtimeClose, 'optionalCall', _82 => _82()]);
|
|
727
730
|
this.realtimeClose = null;
|
|
728
|
-
_optionalChain([this, 'access',
|
|
731
|
+
_optionalChain([this, 'access', _83 => _83.pageClose, 'optionalCall', _84 => _84()]);
|
|
729
732
|
this.pageClose = null;
|
|
730
733
|
}
|
|
731
734
|
}, _class);
|
|
735
|
+
var lastTextOffset = (dataStream) => Math.max(0, dataStream.length - 2);
|
|
736
|
+
function mapOffsetThroughReplace(before, after, offset) {
|
|
737
|
+
const max = Math.min(before.length, after.length);
|
|
738
|
+
let pre = 0;
|
|
739
|
+
while (pre < max && before[pre] === after[pre]) pre++;
|
|
740
|
+
let suf = 0;
|
|
741
|
+
while (suf < max - pre && before[before.length - 1 - suf] === after[after.length - 1 - suf]) suf++;
|
|
742
|
+
const at = offset <= pre ? offset : offset >= before.length - suf ? after.length - (before.length - offset) : after.length - suf;
|
|
743
|
+
return Math.max(0, Math.min(at, lastTextOffset(after)));
|
|
744
|
+
}
|
|
745
|
+
function remountKeepingCaret(port, snapshot) {
|
|
746
|
+
let sel = null;
|
|
747
|
+
let before = null;
|
|
748
|
+
try {
|
|
749
|
+
sel = _nullishCoalesce(_optionalChain([port, 'access', _85 => _85.selection, 'optionalAccess', _86 => _86.get, 'call', _87 => _87()]), () => ( null));
|
|
750
|
+
before = _nullishCoalesce(_optionalChain([port, 'access', _88 => _88.snapshot, 'call', _89 => _89(), 'optionalAccess', _90 => _90.body, 'optionalAccess', _91 => _91.dataStream]), () => ( null));
|
|
751
|
+
} catch (e9) {
|
|
752
|
+
sel = null;
|
|
753
|
+
}
|
|
754
|
+
port.remount(snapshot);
|
|
755
|
+
const after = _optionalChain([snapshot, 'access', _92 => _92.body, 'optionalAccess', _93 => _93.dataStream]);
|
|
756
|
+
if (!_optionalChain([sel, 'optionalAccess', _94 => _94.length]) || before == null || typeof after !== "string" || sel.some((r) => r.segmentId)) return;
|
|
757
|
+
try {
|
|
758
|
+
_optionalChain([port, 'access', _95 => _95.selection, 'optionalAccess', _96 => _96.set, 'call', _97 => _97(
|
|
759
|
+
sel.map((r) => ({ startOffset: mapOffsetThroughReplace(before, after, r.startOffset), endOffset: mapOffsetThroughReplace(before, after, r.endOffset) }))
|
|
760
|
+
)]);
|
|
761
|
+
} catch (error) {
|
|
762
|
+
console.warn("[document-model] could not carry this view's caret into the replaced document", error);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
function keepInsideTheBody(params, current) {
|
|
766
|
+
const p = params;
|
|
767
|
+
if (!p || p.segmentId || !Array.isArray(p.actions) || p.actions[0] !== "body") return;
|
|
768
|
+
const sub = p.actions[1];
|
|
769
|
+
if (!sub || sub.et !== "text-x" || !Array.isArray(sub.e)) return;
|
|
770
|
+
let doc = null;
|
|
771
|
+
try {
|
|
772
|
+
doc = current();
|
|
773
|
+
} catch (e10) {
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
const ds = _optionalChain([doc, 'optionalAccess', _98 => _98.body, 'optionalAccess', _99 => _99.dataStream]);
|
|
777
|
+
if (typeof ds !== "string" || !ds.endsWith("\r\n")) return;
|
|
778
|
+
const last = lastTextOffset(ds);
|
|
779
|
+
let pos = 0;
|
|
780
|
+
let past = false;
|
|
781
|
+
for (const a of sub.e) {
|
|
782
|
+
if (a.t === "i" && pos > last) past = true;
|
|
783
|
+
if (a.t !== "i") pos += a.len;
|
|
784
|
+
}
|
|
785
|
+
if (!past) return;
|
|
786
|
+
const inserts = sub.e.filter((a) => a.t === "i");
|
|
787
|
+
const plain = sub.e.every((a) => a.t === "i" || a.t === "r" && a.body == null);
|
|
788
|
+
console.warn("[document-model] an edit aimed past the end of the document was kept inside it", { at: pos, length: ds.length });
|
|
789
|
+
p.actions = inserts.length === 1 && plain ? ["body", { ...sub, e: [...last ? [{ t: "r", len: last }] : [], inserts[0]] }] : [];
|
|
790
|
+
}
|
|
732
791
|
function moveRangesThroughBodyEdit(ranges, actions) {
|
|
733
792
|
const a = actions;
|
|
734
793
|
if (!Array.isArray(a) || a[0] !== "body") return null;
|
|
@@ -1003,12 +1062,12 @@ function movePeerRangesThroughBodyEdit(ranges, actions) {
|
|
|
1003
1062
|
}
|
|
1004
1063
|
var sameRanges = (a, b) => a.length === b.length && a.every((r, i) => r.start === b[i].start && r.end === b[i].end);
|
|
1005
1064
|
function readCaret(raw) {
|
|
1006
|
-
const c = _optionalChain([raw, 'optionalAccess',
|
|
1065
|
+
const c = _optionalChain([raw, 'optionalAccess', _100 => _100.caret]);
|
|
1007
1066
|
if (!c || !Array.isArray(c.ranges) || typeof c.at !== "number") return null;
|
|
1008
1067
|
const ranges = [];
|
|
1009
1068
|
for (const r of c.ranges.slice(0, CARET_MAX_RANGES)) {
|
|
1010
|
-
const s2 = _optionalChain([r, 'optionalAccess',
|
|
1011
|
-
const e2 = _optionalChain([r, 'optionalAccess',
|
|
1069
|
+
const s2 = _optionalChain([r, 'optionalAccess', _101 => _101.start]);
|
|
1070
|
+
const e2 = _optionalChain([r, 'optionalAccess', _102 => _102.end]);
|
|
1012
1071
|
if (typeof s2 !== "number" || typeof e2 !== "number" || !Number.isFinite(s2) || !Number.isFinite(e2) || s2 < 0 || e2 < 0) return null;
|
|
1013
1072
|
ranges.push({ start: s2, end: e2 });
|
|
1014
1073
|
}
|
|
@@ -1128,5 +1187,7 @@ var RemoteCaretBook = (_class2 = class {
|
|
|
1128
1187
|
|
|
1129
1188
|
|
|
1130
1189
|
|
|
1131
|
-
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
exports.CARET_HEARTBEAT_MS = CARET_HEARTBEAT_MS; exports.CARET_MAX_RANGES = CARET_MAX_RANGES; exports.CARET_STALE_MS = CARET_STALE_MS; exports.COMMENT_ANCHOR_LABEL_MAX = COMMENT_ANCHOR_LABEL_MAX; exports.COMMENT_ANCHOR_PART_PREFIX = COMMENT_ANCHOR_PART_PREFIX; exports.COMMENT_ANCHOR_RANGE_TYPE = COMMENT_ANCHOR_RANGE_TYPE; 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.RemoteCaretBook = RemoteCaretBook; exports.SPECIAL_GROUPS = SPECIAL_GROUPS; exports.addCommentAnchorActions = addCommentAnchorActions; exports.anchorIdOfPartAnchor = anchorIdOfPartAnchor; exports.bodyTextOf = bodyTextOf; exports.commentAnchorPartKey = commentAnchorPartKey; exports.commentAnchorsOf = commentAnchorsOf; exports.commentPartAnchor = commentPartAnchor; exports.configureDocsHost = _chunkXJBJKOUHcjs.configureDocsHost; exports.copyDocument = _chunkXJBJKOUHcjs.copyDocument; exports.createDocument = _chunkXJBJKOUHcjs.createDocument; exports.deleteDocument = _chunkXJBJKOUHcjs.deleteDocument; exports.discardFailedDocument = _chunkXJBJKOUHcjs.discardFailedDocument; exports.documentBodyWriteHandler = documentBodyWriteHandler; exports.documentSourceLabel = documentSourceLabel; exports.fitZoomRatio = fitZoomRatio; exports.getDocsHost = _chunkXJBJKOUHcjs.getDocsHost; exports.getDocument = _chunkXJBJKOUHcjs.getDocument; exports.getLatestDocumentSnapshot = _chunkXJBJKOUHcjs.getLatestDocumentSnapshot; exports.isDocsAnchorOnlyOp = isDocsAnchorOnlyOp; exports.keepInsideTheBody = keepInsideTheBody; exports.listAccessibleDocuments = _chunkXJBJKOUHcjs.listAccessibleDocuments; exports.listDocumentSnapshots = _chunkXJBJKOUHcjs.listDocumentSnapshots; exports.listTrashedDocuments = _chunkXJBJKOUHcjs.listTrashedDocuments; exports.mapOffsetThroughReplace = mapOffsetThroughReplace; exports.moveDocument = _chunkXJBJKOUHcjs.moveDocument; exports.movePeerRangesThroughBodyEdit = movePeerRangesThroughBodyEdit; exports.moveRangesThroughBodyEdit = moveRangesThroughBodyEdit; exports.newCommentAnchorId = newCommentAnchorId; exports.planBodyEdit = planBodyEdit; exports.publishedCaretFromSelection = publishedCaretFromSelection; exports.quoteOfCommentAnchor = quoteOfCommentAnchor; exports.removeCommentAnchorActions = removeCommentAnchorActions; exports.renameDocument = _chunkXJBJKOUHcjs.renameDocument; exports.restoreDocument = _chunkXJBJKOUHcjs.restoreDocument; exports.sanitizeUniverDocSnapshot = _chunkXJBJKOUHcjs.sanitizeUniverDocSnapshot; exports.saveDocumentSnapshot = _chunkXJBJKOUHcjs.saveDocumentSnapshot; exports.searchSymbols = searchSymbols; exports.updateDocumentDescription = _chunkXJBJKOUHcjs.updateDocumentDescription; exports.validateDocumentBody = validateDocumentBody; exports.validateDocumentDescription = validateDocumentDescription; exports.validateDocumentName = validateDocumentName; exports.writeBodyText = writeBodyText;
|
|
1132
1193
|
//# sourceMappingURL=docs.cjs.map
|