@tldraw/editor 3.13.0-canary.a2884bb1bab2 → 3.13.0-canary.bec6f90d283a
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/dist-cjs/index.d.ts +1 -0
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +24 -18
- package/dist-cjs/lib/editor/Editor.js.map +3 -3
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +1 -0
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +24 -18
- package/dist-esm/lib/editor/Editor.mjs.map +3 -3
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/lib/editor/Editor.ts +21 -17
- package/src/version.ts +3 -3
package/dist-cjs/version.js
CHANGED
|
@@ -22,10 +22,10 @@ __export(version_exports, {
|
|
|
22
22
|
version: () => version
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(version_exports);
|
|
25
|
-
const version = "3.13.0-canary.
|
|
25
|
+
const version = "3.13.0-canary.bec6f90d283a";
|
|
26
26
|
const publishDates = {
|
|
27
27
|
major: "2024-09-13T14:36:29.063Z",
|
|
28
|
-
minor: "2025-04-
|
|
29
|
-
patch: "2025-04-
|
|
28
|
+
minor: "2025-04-17T13:31:58.284Z",
|
|
29
|
+
patch: "2025-04-17T13:31:58.284Z"
|
|
30
30
|
};
|
|
31
31
|
//# sourceMappingURL=version.js.map
|
package/dist-cjs/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.13.0-canary.
|
|
4
|
+
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.13.0-canary.bec6f90d283a'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-04-17T13:31:58.284Z',\n\tpatch: '2025-04-17T13:31:58.284Z',\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist-esm/index.d.mts
CHANGED
package/dist-esm/index.mjs
CHANGED
|
@@ -1984,12 +1984,22 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1984
1984
|
}
|
|
1985
1985
|
return baseCamera;
|
|
1986
1986
|
}
|
|
1987
|
+
_getFollowingPresence(targetUserId) {
|
|
1988
|
+
const visited = [this.user.getId()];
|
|
1989
|
+
const collaborators = this.getCollaborators();
|
|
1990
|
+
let leaderPresence = null;
|
|
1991
|
+
while (targetUserId && !visited.includes(targetUserId)) {
|
|
1992
|
+
leaderPresence = collaborators.find((c) => c.userId === targetUserId) ?? null;
|
|
1993
|
+
targetUserId = leaderPresence?.followingUserId ?? null;
|
|
1994
|
+
if (leaderPresence) {
|
|
1995
|
+
visited.push(leaderPresence.userId);
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
return leaderPresence;
|
|
1999
|
+
}
|
|
1987
2000
|
getViewportPageBoundsForFollowing() {
|
|
1988
|
-
const
|
|
1989
|
-
if (!
|
|
1990
|
-
const leaderPresence = this.getCollaborators().find((c) => c.userId === followingUserId);
|
|
1991
|
-
if (!leaderPresence) return null;
|
|
1992
|
-
if (!leaderPresence.camera || !leaderPresence.screenBounds) return null;
|
|
2001
|
+
const leaderPresence = this._getFollowingPresence(this.getInstanceState().followingUserId);
|
|
2002
|
+
if (!leaderPresence?.camera || !leaderPresence?.screenBounds) return null;
|
|
1993
2003
|
const { w: lw, h: lh } = leaderPresence.screenBounds;
|
|
1994
2004
|
const { x: lx, y: ly, z: lz } = leaderPresence.camera;
|
|
1995
2005
|
const theirViewport = new Box(-lx, -ly, lw / lz, lh / lz);
|
|
@@ -2896,34 +2906,30 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
2896
2906
|
*/
|
|
2897
2907
|
startFollowingUser(userId) {
|
|
2898
2908
|
this.stopFollowingUser();
|
|
2899
|
-
const leaderPresences = this._getCollaboratorsQuery().get().filter((p) => p.userId === userId);
|
|
2900
|
-
if (!leaderPresences.length) {
|
|
2901
|
-
console.warn("User not found");
|
|
2902
|
-
return this;
|
|
2903
|
-
}
|
|
2904
2909
|
const thisUserId = this.user.getId();
|
|
2905
2910
|
if (!thisUserId) {
|
|
2906
2911
|
console.warn("You should set the userId for the current instance before following a user");
|
|
2907
2912
|
}
|
|
2908
|
-
|
|
2913
|
+
const leaderPresence = this._getFollowingPresence(userId);
|
|
2914
|
+
if (!leaderPresence) {
|
|
2909
2915
|
return this;
|
|
2910
2916
|
}
|
|
2911
2917
|
const latestLeaderPresence = computed("latestLeaderPresence", () => {
|
|
2912
|
-
return this.
|
|
2918
|
+
return this._getFollowingPresence(userId);
|
|
2913
2919
|
});
|
|
2914
2920
|
transact(() => {
|
|
2915
2921
|
this.updateInstanceState({ followingUserId: userId }, { history: "ignore" });
|
|
2916
2922
|
const dispose = react("update current page", () => {
|
|
2917
|
-
const
|
|
2918
|
-
if (!
|
|
2923
|
+
const leaderPresence2 = latestLeaderPresence.get();
|
|
2924
|
+
if (!leaderPresence2) {
|
|
2919
2925
|
this.stopFollowingUser();
|
|
2920
2926
|
return;
|
|
2921
2927
|
}
|
|
2922
|
-
if (
|
|
2928
|
+
if (leaderPresence2.currentPageId !== this.getCurrentPageId() && this.getPage(leaderPresence2.currentPageId)) {
|
|
2923
2929
|
this.run(
|
|
2924
2930
|
() => {
|
|
2925
2931
|
this.store.put([
|
|
2926
|
-
{ ...this.getInstanceState(), currentPageId:
|
|
2932
|
+
{ ...this.getInstanceState(), currentPageId: leaderPresence2.currentPageId }
|
|
2927
2933
|
]);
|
|
2928
2934
|
this._isLockedOnFollowingUser.set(true);
|
|
2929
2935
|
},
|
|
@@ -2938,8 +2944,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
2938
2944
|
this.off("stop-following", cancel);
|
|
2939
2945
|
};
|
|
2940
2946
|
const moveTowardsUser = () => {
|
|
2941
|
-
const
|
|
2942
|
-
if (!
|
|
2947
|
+
const leaderPresence2 = latestLeaderPresence.get();
|
|
2948
|
+
if (!leaderPresence2) {
|
|
2943
2949
|
this.stopFollowingUser();
|
|
2944
2950
|
return;
|
|
2945
2951
|
}
|