@tldraw/editor 3.13.0-canary.d403fcffd1eb → 3.13.0-canary.da15a0065ba5
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/index.d.ts
CHANGED
package/dist-cjs/index.js
CHANGED
|
@@ -1950,12 +1950,22 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1950
1950
|
}
|
|
1951
1951
|
return baseCamera;
|
|
1952
1952
|
}
|
|
1953
|
+
_getFollowingPresence(targetUserId) {
|
|
1954
|
+
const visited = [this.user.getId()];
|
|
1955
|
+
const collaborators = this.getCollaborators();
|
|
1956
|
+
let leaderPresence = null;
|
|
1957
|
+
while (targetUserId && !visited.includes(targetUserId)) {
|
|
1958
|
+
leaderPresence = collaborators.find((c) => c.userId === targetUserId) ?? null;
|
|
1959
|
+
targetUserId = leaderPresence?.followingUserId ?? null;
|
|
1960
|
+
if (leaderPresence) {
|
|
1961
|
+
visited.push(leaderPresence.userId);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
return leaderPresence;
|
|
1965
|
+
}
|
|
1953
1966
|
getViewportPageBoundsForFollowing() {
|
|
1954
|
-
const
|
|
1955
|
-
if (!
|
|
1956
|
-
const leaderPresence = this.getCollaborators().find((c) => c.userId === followingUserId);
|
|
1957
|
-
if (!leaderPresence) return null;
|
|
1958
|
-
if (!leaderPresence.camera || !leaderPresence.screenBounds) return null;
|
|
1967
|
+
const leaderPresence = this._getFollowingPresence(this.getInstanceState().followingUserId);
|
|
1968
|
+
if (!leaderPresence?.camera || !leaderPresence?.screenBounds) return null;
|
|
1959
1969
|
const { w: lw, h: lh } = leaderPresence.screenBounds;
|
|
1960
1970
|
const { x: lx, y: ly, z: lz } = leaderPresence.camera;
|
|
1961
1971
|
const theirViewport = new import_Box.Box(-lx, -ly, lw / lz, lh / lz);
|
|
@@ -2862,34 +2872,30 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2862
2872
|
*/
|
|
2863
2873
|
startFollowingUser(userId) {
|
|
2864
2874
|
this.stopFollowingUser();
|
|
2865
|
-
const leaderPresences = this._getCollaboratorsQuery().get().filter((p) => p.userId === userId);
|
|
2866
|
-
if (!leaderPresences.length) {
|
|
2867
|
-
console.warn("User not found");
|
|
2868
|
-
return this;
|
|
2869
|
-
}
|
|
2870
2875
|
const thisUserId = this.user.getId();
|
|
2871
2876
|
if (!thisUserId) {
|
|
2872
2877
|
console.warn("You should set the userId for the current instance before following a user");
|
|
2873
2878
|
}
|
|
2874
|
-
|
|
2879
|
+
const leaderPresence = this._getFollowingPresence(userId);
|
|
2880
|
+
if (!leaderPresence) {
|
|
2875
2881
|
return this;
|
|
2876
2882
|
}
|
|
2877
2883
|
const latestLeaderPresence = (0, import_state.computed)("latestLeaderPresence", () => {
|
|
2878
|
-
return this.
|
|
2884
|
+
return this._getFollowingPresence(userId);
|
|
2879
2885
|
});
|
|
2880
2886
|
(0, import_state.transact)(() => {
|
|
2881
2887
|
this.updateInstanceState({ followingUserId: userId }, { history: "ignore" });
|
|
2882
2888
|
const dispose = (0, import_state.react)("update current page", () => {
|
|
2883
|
-
const
|
|
2884
|
-
if (!
|
|
2889
|
+
const leaderPresence2 = latestLeaderPresence.get();
|
|
2890
|
+
if (!leaderPresence2) {
|
|
2885
2891
|
this.stopFollowingUser();
|
|
2886
2892
|
return;
|
|
2887
2893
|
}
|
|
2888
|
-
if (
|
|
2894
|
+
if (leaderPresence2.currentPageId !== this.getCurrentPageId() && this.getPage(leaderPresence2.currentPageId)) {
|
|
2889
2895
|
this.run(
|
|
2890
2896
|
() => {
|
|
2891
2897
|
this.store.put([
|
|
2892
|
-
{ ...this.getInstanceState(), currentPageId:
|
|
2898
|
+
{ ...this.getInstanceState(), currentPageId: leaderPresence2.currentPageId }
|
|
2893
2899
|
]);
|
|
2894
2900
|
this._isLockedOnFollowingUser.set(true);
|
|
2895
2901
|
},
|
|
@@ -2904,8 +2910,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
2904
2910
|
this.off("stop-following", cancel);
|
|
2905
2911
|
};
|
|
2906
2912
|
const moveTowardsUser = () => {
|
|
2907
|
-
const
|
|
2908
|
-
if (!
|
|
2913
|
+
const leaderPresence2 = latestLeaderPresence.get();
|
|
2914
|
+
if (!leaderPresence2) {
|
|
2909
2915
|
this.stopFollowingUser();
|
|
2910
2916
|
return;
|
|
2911
2917
|
}
|