@tldraw/editor 3.13.0-canary.d403fcffd1eb → 3.13.0-canary.dc099cf30823
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 +25 -20
- 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 +25 -20
- 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 +22 -19
- 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.dc099cf30823";
|
|
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-17T14:42:12.602Z",
|
|
29
|
+
patch: "2025-04-17T14:42:12.602Z"
|
|
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.dc099cf30823'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-04-17T14:42:12.602Z',\n\tpatch: '2025-04-17T14:42:12.602Z',\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
|
@@ -1381,8 +1381,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1381
1381
|
return this.getCurrentPageState().selectedShapeIds;
|
|
1382
1382
|
}
|
|
1383
1383
|
getSelectedShapes() {
|
|
1384
|
-
|
|
1385
|
-
return compact(selectedShapeIds.map((id) => this.store.get(id)));
|
|
1384
|
+
return compact(this.getSelectedShapeIds().map((id) => this.store.get(id)));
|
|
1386
1385
|
}
|
|
1387
1386
|
/**
|
|
1388
1387
|
* Select one or more shapes.
|
|
@@ -1984,12 +1983,22 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1984
1983
|
}
|
|
1985
1984
|
return baseCamera;
|
|
1986
1985
|
}
|
|
1986
|
+
_getFollowingPresence(targetUserId) {
|
|
1987
|
+
const visited = [this.user.getId()];
|
|
1988
|
+
const collaborators = this.getCollaborators();
|
|
1989
|
+
let leaderPresence = null;
|
|
1990
|
+
while (targetUserId && !visited.includes(targetUserId)) {
|
|
1991
|
+
leaderPresence = collaborators.find((c) => c.userId === targetUserId) ?? null;
|
|
1992
|
+
targetUserId = leaderPresence?.followingUserId ?? null;
|
|
1993
|
+
if (leaderPresence) {
|
|
1994
|
+
visited.push(leaderPresence.userId);
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
return leaderPresence;
|
|
1998
|
+
}
|
|
1987
1999
|
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;
|
|
2000
|
+
const leaderPresence = this._getFollowingPresence(this.getInstanceState().followingUserId);
|
|
2001
|
+
if (!leaderPresence?.camera || !leaderPresence?.screenBounds) return null;
|
|
1993
2002
|
const { w: lw, h: lh } = leaderPresence.screenBounds;
|
|
1994
2003
|
const { x: lx, y: ly, z: lz } = leaderPresence.camera;
|
|
1995
2004
|
const theirViewport = new Box(-lx, -ly, lw / lz, lh / lz);
|
|
@@ -2896,34 +2905,30 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
2896
2905
|
*/
|
|
2897
2906
|
startFollowingUser(userId) {
|
|
2898
2907
|
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
2908
|
const thisUserId = this.user.getId();
|
|
2905
2909
|
if (!thisUserId) {
|
|
2906
2910
|
console.warn("You should set the userId for the current instance before following a user");
|
|
2907
2911
|
}
|
|
2908
|
-
|
|
2912
|
+
const leaderPresence = this._getFollowingPresence(userId);
|
|
2913
|
+
if (!leaderPresence) {
|
|
2909
2914
|
return this;
|
|
2910
2915
|
}
|
|
2911
2916
|
const latestLeaderPresence = computed("latestLeaderPresence", () => {
|
|
2912
|
-
return this.
|
|
2917
|
+
return this._getFollowingPresence(userId);
|
|
2913
2918
|
});
|
|
2914
2919
|
transact(() => {
|
|
2915
2920
|
this.updateInstanceState({ followingUserId: userId }, { history: "ignore" });
|
|
2916
2921
|
const dispose = react("update current page", () => {
|
|
2917
|
-
const
|
|
2918
|
-
if (!
|
|
2922
|
+
const leaderPresence2 = latestLeaderPresence.get();
|
|
2923
|
+
if (!leaderPresence2) {
|
|
2919
2924
|
this.stopFollowingUser();
|
|
2920
2925
|
return;
|
|
2921
2926
|
}
|
|
2922
|
-
if (
|
|
2927
|
+
if (leaderPresence2.currentPageId !== this.getCurrentPageId() && this.getPage(leaderPresence2.currentPageId)) {
|
|
2923
2928
|
this.run(
|
|
2924
2929
|
() => {
|
|
2925
2930
|
this.store.put([
|
|
2926
|
-
{ ...this.getInstanceState(), currentPageId:
|
|
2931
|
+
{ ...this.getInstanceState(), currentPageId: leaderPresence2.currentPageId }
|
|
2927
2932
|
]);
|
|
2928
2933
|
this._isLockedOnFollowingUser.set(true);
|
|
2929
2934
|
},
|
|
@@ -2938,8 +2943,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
2938
2943
|
this.off("stop-following", cancel);
|
|
2939
2944
|
};
|
|
2940
2945
|
const moveTowardsUser = () => {
|
|
2941
|
-
const
|
|
2942
|
-
if (!
|
|
2946
|
+
const leaderPresence2 = latestLeaderPresence.get();
|
|
2947
|
+
if (!leaderPresence2) {
|
|
2943
2948
|
this.stopFollowingUser();
|
|
2944
2949
|
return;
|
|
2945
2950
|
}
|