@ai-matrx/office 0.8.26 → 0.8.28
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 +29 -0
- package/dist/collab-sheets-transform.cjs +215 -14
- package/dist/collab-sheets-transform.cjs.map +1 -1
- package/dist/collab-sheets-transform.d.cts +7 -2
- package/dist/collab-sheets-transform.d.ts +7 -2
- package/dist/collab-sheets-transform.js +215 -14
- package/dist/collab-sheets-transform.js.map +1 -1
- package/dist/docs.cjs +35 -1
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.d.cts +16 -2
- package/dist/docs.d.ts +16 -2
- package/dist/docs.js +34 -0
- package/dist/docs.js.map +1 -1
- package/dist/sheets-comment-anchors.cjs +44 -3
- package/dist/sheets-comment-anchors.cjs.map +1 -1
- package/dist/sheets-comment-anchors.js +42 -1
- package/dist/sheets-comment-anchors.js.map +1 -1
- package/dist/univer-collab.cjs +315 -37
- package/dist/univer-collab.cjs.map +1 -1
- package/dist/univer-collab.d.cts +9 -5
- package/dist/univer-collab.d.ts +9 -5
- package/dist/univer-collab.js +300 -18
- package/dist/univer-collab.js.map +1 -1
- package/package.json +6 -5
package/dist/docs.d.cts
CHANGED
|
@@ -816,8 +816,15 @@ declare const COMMENT_ANCHOR_LABEL_MAX = 200;
|
|
|
816
816
|
/** A fresh anchor id: 16 random base-36 characters (custom-range ids are plain strings). */
|
|
817
817
|
declare function newCommentAnchorId(): string;
|
|
818
818
|
declare function commentAnchorPartKey(anchorId: string): string;
|
|
819
|
-
/**
|
|
819
|
+
/**
|
|
820
|
+
* The anchor id a thread's `anchor` names, or null when it is not one of ours. A new thread is a `part_anchor` keyed
|
|
821
|
+
* `anchor:<id>`. At each save the door projects the live anchor onto the thread (COLLAB-DESIGN §8): a sheet thread's key
|
|
822
|
+
* becomes `cell:<sheetId>!R<r>C<c>` and a docs thread becomes a `text_anchor` holding the quoted text; both keep the id in
|
|
823
|
+
* `anchor_id`, so the thread stays joined to its anchor after the rewrite.
|
|
824
|
+
*/
|
|
820
825
|
declare function anchorIdOfPartAnchor(anchor: unknown): string | null;
|
|
826
|
+
/** The quoted text a thread carries: a new thread's label, or the frozen `exact` of a projected docs thread. */
|
|
827
|
+
declare function quoteOfCommentAnchor(anchor: unknown): string;
|
|
821
828
|
/** The `part_anchor` a new thread on this anchor carries. */
|
|
822
829
|
declare function commentPartAnchor(anchorId: string, quote: string): {
|
|
823
830
|
__kind: "part_anchor";
|
|
@@ -843,5 +850,12 @@ declare function addCommentAnchorActions(body: unknown, start: number, end: numb
|
|
|
843
850
|
* its text. Null when the anchor is not there.
|
|
844
851
|
*/
|
|
845
852
|
declare function removeCommentAnchorActions(documentDataModel: unknown, anchorId: string): unknown[] | null;
|
|
853
|
+
/**
|
|
854
|
+
* A Docs op that only ADDS comment anchors: `["body", { et: "text-x", e: [...] }]` whose every component is a plain
|
|
855
|
+
* retain, carrying (when it carries a body) nothing but COMMENT custom ranges. No insert, no delete, no text, no style,
|
|
856
|
+
* no other range type. A seat that may comment but not edit sends exactly these; the door `content.collab_append`
|
|
857
|
+
* checks the same rule. Taking a range out is NOT included: it reads the same as removing a link, so it is an edit.
|
|
858
|
+
*/
|
|
859
|
+
declare function isDocsAnchorOnlyOp(op: unknown): boolean;
|
|
846
860
|
|
|
847
|
-
export { type BodyEdit, type BodyText, CARET_HEARTBEAT_MS, CARET_MAX_RANGES, CARET_STALE_MS, COMMENT_ANCHOR_LABEL_MAX, COMMENT_ANCHOR_PART_PREFIX, COMMENT_ANCHOR_RANGE_TYPE, type CaretRange, type CommentAnchorSpan, type CreateDocumentArgs, DOCUMENT_BODY_MAX_LENGTH, DOCUMENT_DESCRIPTION_MAX_LENGTH, DOCUMENT_NAME_MAX_LENGTH, DOCUMENT_SAVE_DELAY_MS, type DocsHostPorts, type DocsSupabase, type DocumentAwareness, type DocumentBodyPort, type DocumentBodyWriteHandler, type DocumentCollabBase, type DocumentCollabFactory, type DocumentCollabHandle, DocumentModel, type DocumentModelDeps, type DocumentOtFactory, type DocumentOtHandle, type DocumentSnapshotData, type DocumentViewPort, EMOJI_GROUPS, type Glyph, MIN_FIT_ZOOM, type ParkedDocumentEditor, type PublishedCaret, type RemoteCaret, RemoteCaretBook, SPECIAL_GROUPS, type SaveDocumentSnapshotArgs, addCommentAnchorActions, anchorIdOfPartAnchor, bodyTextOf, commentAnchorPartKey, commentAnchorsOf, commentPartAnchor, configureDocsHost, copyDocument, createDocument, deleteDocument, discardFailedDocument, documentBodyWriteHandler, documentSourceLabel, fitZoomRatio, getDocsHost, getDocument, getLatestDocumentSnapshot, listAccessibleDocuments, listDocumentSnapshots, listTrashedDocuments, moveDocument, movePeerRangesThroughBodyEdit, moveRangesThroughBodyEdit, newCommentAnchorId, planBodyEdit, publishedCaretFromSelection, removeCommentAnchorActions, renameDocument, restoreDocument, sanitizeUniverDocSnapshot, saveDocumentSnapshot, searchSymbols, updateDocumentDescription, validateDocumentBody, validateDocumentDescription, validateDocumentName, writeBodyText };
|
|
861
|
+
export { type BodyEdit, type BodyText, CARET_HEARTBEAT_MS, CARET_MAX_RANGES, CARET_STALE_MS, COMMENT_ANCHOR_LABEL_MAX, COMMENT_ANCHOR_PART_PREFIX, COMMENT_ANCHOR_RANGE_TYPE, type CaretRange, type CommentAnchorSpan, type CreateDocumentArgs, DOCUMENT_BODY_MAX_LENGTH, DOCUMENT_DESCRIPTION_MAX_LENGTH, DOCUMENT_NAME_MAX_LENGTH, DOCUMENT_SAVE_DELAY_MS, type DocsHostPorts, type DocsSupabase, type DocumentAwareness, type DocumentBodyPort, type DocumentBodyWriteHandler, type DocumentCollabBase, type DocumentCollabFactory, type DocumentCollabHandle, DocumentModel, type DocumentModelDeps, type DocumentOtFactory, type DocumentOtHandle, type DocumentSnapshotData, type DocumentViewPort, EMOJI_GROUPS, type Glyph, MIN_FIT_ZOOM, type ParkedDocumentEditor, type PublishedCaret, type RemoteCaret, RemoteCaretBook, SPECIAL_GROUPS, type SaveDocumentSnapshotArgs, addCommentAnchorActions, anchorIdOfPartAnchor, bodyTextOf, commentAnchorPartKey, commentAnchorsOf, commentPartAnchor, configureDocsHost, copyDocument, createDocument, deleteDocument, discardFailedDocument, documentBodyWriteHandler, documentSourceLabel, fitZoomRatio, getDocsHost, getDocument, getLatestDocumentSnapshot, isDocsAnchorOnlyOp, listAccessibleDocuments, listDocumentSnapshots, listTrashedDocuments, moveDocument, movePeerRangesThroughBodyEdit, moveRangesThroughBodyEdit, newCommentAnchorId, planBodyEdit, publishedCaretFromSelection, quoteOfCommentAnchor, removeCommentAnchorActions, renameDocument, restoreDocument, sanitizeUniverDocSnapshot, saveDocumentSnapshot, searchSymbols, updateDocumentDescription, validateDocumentBody, validateDocumentDescription, validateDocumentName, writeBodyText };
|
package/dist/docs.d.ts
CHANGED
|
@@ -816,8 +816,15 @@ declare const COMMENT_ANCHOR_LABEL_MAX = 200;
|
|
|
816
816
|
/** A fresh anchor id: 16 random base-36 characters (custom-range ids are plain strings). */
|
|
817
817
|
declare function newCommentAnchorId(): string;
|
|
818
818
|
declare function commentAnchorPartKey(anchorId: string): string;
|
|
819
|
-
/**
|
|
819
|
+
/**
|
|
820
|
+
* The anchor id a thread's `anchor` names, or null when it is not one of ours. A new thread is a `part_anchor` keyed
|
|
821
|
+
* `anchor:<id>`. At each save the door projects the live anchor onto the thread (COLLAB-DESIGN §8): a sheet thread's key
|
|
822
|
+
* becomes `cell:<sheetId>!R<r>C<c>` and a docs thread becomes a `text_anchor` holding the quoted text; both keep the id in
|
|
823
|
+
* `anchor_id`, so the thread stays joined to its anchor after the rewrite.
|
|
824
|
+
*/
|
|
820
825
|
declare function anchorIdOfPartAnchor(anchor: unknown): string | null;
|
|
826
|
+
/** The quoted text a thread carries: a new thread's label, or the frozen `exact` of a projected docs thread. */
|
|
827
|
+
declare function quoteOfCommentAnchor(anchor: unknown): string;
|
|
821
828
|
/** The `part_anchor` a new thread on this anchor carries. */
|
|
822
829
|
declare function commentPartAnchor(anchorId: string, quote: string): {
|
|
823
830
|
__kind: "part_anchor";
|
|
@@ -843,5 +850,12 @@ declare function addCommentAnchorActions(body: unknown, start: number, end: numb
|
|
|
843
850
|
* its text. Null when the anchor is not there.
|
|
844
851
|
*/
|
|
845
852
|
declare function removeCommentAnchorActions(documentDataModel: unknown, anchorId: string): unknown[] | null;
|
|
853
|
+
/**
|
|
854
|
+
* A Docs op that only ADDS comment anchors: `["body", { et: "text-x", e: [...] }]` whose every component is a plain
|
|
855
|
+
* retain, carrying (when it carries a body) nothing but COMMENT custom ranges. No insert, no delete, no text, no style,
|
|
856
|
+
* no other range type. A seat that may comment but not edit sends exactly these; the door `content.collab_append`
|
|
857
|
+
* checks the same rule. Taking a range out is NOT included: it reads the same as removing a link, so it is an edit.
|
|
858
|
+
*/
|
|
859
|
+
declare function isDocsAnchorOnlyOp(op: unknown): boolean;
|
|
846
860
|
|
|
847
|
-
export { type BodyEdit, type BodyText, CARET_HEARTBEAT_MS, CARET_MAX_RANGES, CARET_STALE_MS, COMMENT_ANCHOR_LABEL_MAX, COMMENT_ANCHOR_PART_PREFIX, COMMENT_ANCHOR_RANGE_TYPE, type CaretRange, type CommentAnchorSpan, type CreateDocumentArgs, DOCUMENT_BODY_MAX_LENGTH, DOCUMENT_DESCRIPTION_MAX_LENGTH, DOCUMENT_NAME_MAX_LENGTH, DOCUMENT_SAVE_DELAY_MS, type DocsHostPorts, type DocsSupabase, type DocumentAwareness, type DocumentBodyPort, type DocumentBodyWriteHandler, type DocumentCollabBase, type DocumentCollabFactory, type DocumentCollabHandle, DocumentModel, type DocumentModelDeps, type DocumentOtFactory, type DocumentOtHandle, type DocumentSnapshotData, type DocumentViewPort, EMOJI_GROUPS, type Glyph, MIN_FIT_ZOOM, type ParkedDocumentEditor, type PublishedCaret, type RemoteCaret, RemoteCaretBook, SPECIAL_GROUPS, type SaveDocumentSnapshotArgs, addCommentAnchorActions, anchorIdOfPartAnchor, bodyTextOf, commentAnchorPartKey, commentAnchorsOf, commentPartAnchor, configureDocsHost, copyDocument, createDocument, deleteDocument, discardFailedDocument, documentBodyWriteHandler, documentSourceLabel, fitZoomRatio, getDocsHost, getDocument, getLatestDocumentSnapshot, listAccessibleDocuments, listDocumentSnapshots, listTrashedDocuments, moveDocument, movePeerRangesThroughBodyEdit, moveRangesThroughBodyEdit, newCommentAnchorId, planBodyEdit, publishedCaretFromSelection, removeCommentAnchorActions, renameDocument, restoreDocument, sanitizeUniverDocSnapshot, saveDocumentSnapshot, searchSymbols, updateDocumentDescription, validateDocumentBody, validateDocumentDescription, validateDocumentName, writeBodyText };
|
|
861
|
+
export { type BodyEdit, type BodyText, CARET_HEARTBEAT_MS, CARET_MAX_RANGES, CARET_STALE_MS, COMMENT_ANCHOR_LABEL_MAX, COMMENT_ANCHOR_PART_PREFIX, COMMENT_ANCHOR_RANGE_TYPE, type CaretRange, type CommentAnchorSpan, type CreateDocumentArgs, DOCUMENT_BODY_MAX_LENGTH, DOCUMENT_DESCRIPTION_MAX_LENGTH, DOCUMENT_NAME_MAX_LENGTH, DOCUMENT_SAVE_DELAY_MS, type DocsHostPorts, type DocsSupabase, type DocumentAwareness, type DocumentBodyPort, type DocumentBodyWriteHandler, type DocumentCollabBase, type DocumentCollabFactory, type DocumentCollabHandle, DocumentModel, type DocumentModelDeps, type DocumentOtFactory, type DocumentOtHandle, type DocumentSnapshotData, type DocumentViewPort, EMOJI_GROUPS, type Glyph, MIN_FIT_ZOOM, type ParkedDocumentEditor, type PublishedCaret, type RemoteCaret, RemoteCaretBook, SPECIAL_GROUPS, type SaveDocumentSnapshotArgs, addCommentAnchorActions, anchorIdOfPartAnchor, bodyTextOf, commentAnchorPartKey, commentAnchorsOf, commentPartAnchor, configureDocsHost, copyDocument, createDocument, deleteDocument, discardFailedDocument, documentBodyWriteHandler, documentSourceLabel, fitZoomRatio, getDocsHost, getDocument, getLatestDocumentSnapshot, isDocsAnchorOnlyOp, listAccessibleDocuments, listDocumentSnapshots, listTrashedDocuments, moveDocument, movePeerRangesThroughBodyEdit, moveRangesThroughBodyEdit, newCommentAnchorId, planBodyEdit, publishedCaretFromSelection, quoteOfCommentAnchor, removeCommentAnchorActions, renameDocument, restoreDocument, sanitizeUniverDocSnapshot, saveDocumentSnapshot, searchSymbols, updateDocumentDescription, validateDocumentBody, validateDocumentDescription, validateDocumentName, writeBodyText };
|
package/dist/docs.js
CHANGED
|
@@ -979,11 +979,17 @@ function commentAnchorPartKey(anchorId) {
|
|
|
979
979
|
function anchorIdOfPartAnchor(anchor) {
|
|
980
980
|
if (!anchor || typeof anchor !== "object") return null;
|
|
981
981
|
const a = anchor;
|
|
982
|
+
if ((a.__kind === "part_anchor" || a.__kind === "text_anchor") && typeof a.anchor_id === "string" && a.anchor_id.length > 0) return a.anchor_id;
|
|
982
983
|
if (a.__kind !== "part_anchor" || typeof a.part_key !== "string") return null;
|
|
983
984
|
if (!a.part_key.startsWith(COMMENT_ANCHOR_PART_PREFIX)) return null;
|
|
984
985
|
const id = a.part_key.slice(COMMENT_ANCHOR_PART_PREFIX.length);
|
|
985
986
|
return id.length > 0 ? id : null;
|
|
986
987
|
}
|
|
988
|
+
function quoteOfCommentAnchor(anchor) {
|
|
989
|
+
if (!anchor || typeof anchor !== "object") return "";
|
|
990
|
+
const a = anchor;
|
|
991
|
+
return typeof a.label === "string" ? a.label : typeof a.exact === "string" ? a.exact : "";
|
|
992
|
+
}
|
|
987
993
|
function commentPartAnchor(anchorId, quote) {
|
|
988
994
|
const label = quote.replace(/\s+/g, " ").trim().slice(0, COMMENT_ANCHOR_LABEL_MAX);
|
|
989
995
|
return { __kind: "part_anchor", part_key: commentAnchorPartKey(anchorId), ...label ? { label } : {} };
|
|
@@ -1022,6 +1028,32 @@ function removeCommentAnchorActions(documentDataModel, anchorId) {
|
|
|
1022
1028
|
if (!textX) return null;
|
|
1023
1029
|
return JSONX.getInstance().editOp(textX.serialize(), ["body"]);
|
|
1024
1030
|
}
|
|
1031
|
+
var RETAIN_KEYS = /* @__PURE__ */ new Set(["t", "len", "body", "coverType"]);
|
|
1032
|
+
var RANGE_KEYS = /* @__PURE__ */ new Set(["rangeId", "rangeType", "startIndex", "endIndex", "properties"]);
|
|
1033
|
+
var isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
1034
|
+
var keysOf = (o) => Object.keys(o).filter((k) => o[k] !== void 0);
|
|
1035
|
+
function isDocsAnchorOnlyOp(op) {
|
|
1036
|
+
if (!Array.isArray(op) || op.length !== 2 || op[0] !== "body") return false;
|
|
1037
|
+
const x = op[1];
|
|
1038
|
+
if (!isObj(x) || x.et !== "text-x" || !Array.isArray(x.e) || x.e.length === 0) return false;
|
|
1039
|
+
if (keysOf(x).some((k) => k !== "et" && k !== "e")) return false;
|
|
1040
|
+
for (const c of x.e) {
|
|
1041
|
+
if (!isObj(c) || c.t !== "r" || typeof c.len !== "number") return false;
|
|
1042
|
+
if (keysOf(c).some((k) => !RETAIN_KEYS.has(k))) return false;
|
|
1043
|
+
if ("coverType" in c && typeof c.coverType !== "number") return false;
|
|
1044
|
+
if ("body" in c) {
|
|
1045
|
+
const b = c.body;
|
|
1046
|
+
if (!isObj(b) || keysOf(b).some((k) => k !== "dataStream" && k !== "customRanges")) return false;
|
|
1047
|
+
if (b.dataStream !== void 0 && b.dataStream !== "") return false;
|
|
1048
|
+
if (!Array.isArray(b.customRanges) || b.customRanges.length === 0) return false;
|
|
1049
|
+
for (const r of b.customRanges) {
|
|
1050
|
+
if (!isObj(r) || r.rangeType !== COMMENT_ANCHOR_RANGE_TYPE) return false;
|
|
1051
|
+
if (keysOf(r).some((k) => !RANGE_KEYS.has(k))) return false;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
return true;
|
|
1056
|
+
}
|
|
1025
1057
|
export {
|
|
1026
1058
|
CARET_HEARTBEAT_MS,
|
|
1027
1059
|
CARET_MAX_RANGES,
|
|
@@ -1055,6 +1087,7 @@ export {
|
|
|
1055
1087
|
getDocsHost,
|
|
1056
1088
|
getDocument,
|
|
1057
1089
|
getLatestDocumentSnapshot,
|
|
1090
|
+
isDocsAnchorOnlyOp,
|
|
1058
1091
|
listAccessibleDocuments,
|
|
1059
1092
|
listDocumentSnapshots,
|
|
1060
1093
|
listTrashedDocuments,
|
|
@@ -1064,6 +1097,7 @@ export {
|
|
|
1064
1097
|
newCommentAnchorId,
|
|
1065
1098
|
planBodyEdit,
|
|
1066
1099
|
publishedCaretFromSelection,
|
|
1100
|
+
quoteOfCommentAnchor,
|
|
1067
1101
|
removeCommentAnchorActions,
|
|
1068
1102
|
renameDocument,
|
|
1069
1103
|
restoreDocument,
|