@tldraw/editor 5.2.0-next.335655a13f00 → 5.2.0-next.5d769d321393
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 +5 -7
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +34 -12
- package/dist-cjs/lib/editor/Editor.js.map +3 -3
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +8 -58
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js +1 -2
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/editor/types/event-types.js +0 -2
- package/dist-cjs/lib/editor/types/event-types.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +5 -7
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +34 -12
- package/dist-esm/lib/editor/Editor.mjs.map +3 -3
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +8 -58
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs +1 -2
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/editor/types/event-types.mjs +0 -2
- package/dist-esm/lib/editor/types/event-types.mjs.map +2 -2
- 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 +59 -20
- package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +54 -74
- package/src/lib/editor/managers/ClickManager/ClickManager.ts +15 -65
- package/src/lib/editor/managers/FocusManager/FocusManager.test.ts +4 -4
- package/src/lib/editor/managers/FocusManager/FocusManager.ts +1 -2
- package/src/lib/editor/tools/StateNode.ts +0 -2
- package/src/lib/editor/types/event-types.ts +2 -6
- package/src/version.ts +3 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -746,6 +746,7 @@ export declare class ClickManager {
|
|
|
746
746
|
private _clickTimeout?;
|
|
747
747
|
private _clickScreenPoint?;
|
|
748
748
|
private _previousScreenPoint?;
|
|
749
|
+
private _isPressingWhilePending;
|
|
749
750
|
_getClickTimeout(state: TLClickState, id?: string): void;
|
|
750
751
|
/* Excluded from this release type: _clickState */
|
|
751
752
|
/**
|
|
@@ -4444,6 +4445,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
4444
4445
|
/* Excluded from this release type: _restoreToolId */
|
|
4445
4446
|
/* Excluded from this release type: _didPinch */
|
|
4446
4447
|
/* Excluded from this release type: _selectedShapeIdsAtPointerDown */
|
|
4448
|
+
/* Excluded from this release type: _didCaptureSelectionAtPointerDown */
|
|
4447
4449
|
/* Excluded from this release type: _longPressTimeout */
|
|
4448
4450
|
/* Excluded from this release type: capturedPointerId */
|
|
4449
4451
|
/* Excluded from this release type: performanceTracker */
|
|
@@ -7165,8 +7167,6 @@ export declare abstract class StateNode implements Partial<TLEventHandlers> {
|
|
|
7165
7167
|
onLongPress?(info: TLPointerEventInfo): void;
|
|
7166
7168
|
onPointerUp?(info: TLPointerEventInfo): void;
|
|
7167
7169
|
onDoubleClick?(info: TLClickEventInfo): void;
|
|
7168
|
-
onTripleClick?(info: TLClickEventInfo): void;
|
|
7169
|
-
onQuadrupleClick?(info: TLClickEventInfo): void;
|
|
7170
7170
|
onRightClick?(info: TLPointerEventInfo): void;
|
|
7171
7171
|
onMiddleClick?(info: TLPointerEventInfo): void;
|
|
7172
7172
|
onKeyDown?(info: TLKeyboardEventInfo): void;
|
|
@@ -7566,17 +7566,17 @@ export declare type TLClickEvent = (info: TLClickEventInfo) => void;
|
|
|
7566
7566
|
export declare type TLClickEventInfo = TLBaseEventInfo & {
|
|
7567
7567
|
button: number;
|
|
7568
7568
|
name: TLCLickEventName;
|
|
7569
|
-
phase: 'down' | 'settle' | 'up';
|
|
7569
|
+
phase: 'down' | 'settle-down' | 'settle-up' | 'up';
|
|
7570
7570
|
point: VecLike;
|
|
7571
7571
|
pointerId: number;
|
|
7572
7572
|
type: 'click';
|
|
7573
7573
|
} & TLPointerEventTarget;
|
|
7574
7574
|
|
|
7575
7575
|
/** @public */
|
|
7576
|
-
export declare type TLCLickEventName = 'double_click'
|
|
7576
|
+
export declare type TLCLickEventName = 'double_click';
|
|
7577
7577
|
|
|
7578
7578
|
/** @public */
|
|
7579
|
-
export declare type TLClickState = 'idle' | 'overflow' | 'pendingDouble' | 'pendingOverflow'
|
|
7579
|
+
export declare type TLClickState = 'idle' | 'overflow' | 'pendingDouble' | 'pendingOverflow';
|
|
7580
7580
|
|
|
7581
7581
|
/**
|
|
7582
7582
|
* Raw clipboard paste payload, before tldraw parses clipboard contents into {@link TLExternalContent}.
|
|
@@ -8356,8 +8356,6 @@ export declare interface TLEventHandlers {
|
|
|
8356
8356
|
onLongPress: TLPointerEvent;
|
|
8357
8357
|
onRightClick: TLPointerEvent;
|
|
8358
8358
|
onDoubleClick: TLClickEvent;
|
|
8359
|
-
onTripleClick: TLClickEvent;
|
|
8360
|
-
onQuadrupleClick: TLClickEvent;
|
|
8361
8359
|
onMiddleClick: TLPointerEvent;
|
|
8362
8360
|
onPointerUp: TLPointerEvent;
|
|
8363
8361
|
onKeyDown: TLKeyboardEvent;
|
package/dist-cjs/index.js
CHANGED
|
@@ -380,7 +380,7 @@ var import_uniq = require("./lib/utils/uniq");
|
|
|
380
380
|
var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
|
|
381
381
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
382
382
|
"@tldraw/editor",
|
|
383
|
-
"5.2.0-next.
|
|
383
|
+
"5.2.0-next.5d769d321393",
|
|
384
384
|
"cjs"
|
|
385
385
|
);
|
|
386
386
|
//# sourceMappingURL=index.js.map
|
|
@@ -2340,6 +2340,11 @@ class Editor extends import_eventemitter3.default {
|
|
|
2340
2340
|
getConstrainedCamera(point, opts) {
|
|
2341
2341
|
const currentCamera = this.getCamera();
|
|
2342
2342
|
let { x, y, z = currentCamera.z } = point;
|
|
2343
|
+
const preserveFocalPoint = (current, requested, rz, z2) => {
|
|
2344
|
+
const cz = currentCamera.z;
|
|
2345
|
+
if (rz === cz) return current;
|
|
2346
|
+
return current + (requested - current) * (1 / z2 - 1 / cz) / (1 / rz - 1 / cz);
|
|
2347
|
+
};
|
|
2343
2348
|
if (!opts?.force) {
|
|
2344
2349
|
const cameraOptions = this.getCameraOptions();
|
|
2345
2350
|
const zoomMin = cameraOptions.zoomSteps[0];
|
|
@@ -2359,14 +2364,10 @@ class Editor extends import_eventemitter3.default {
|
|
|
2359
2364
|
z = this.getInitialZoom();
|
|
2360
2365
|
}
|
|
2361
2366
|
if (z < minZ || z > maxZ) {
|
|
2362
|
-
const
|
|
2363
|
-
const cxA = -cx + vsb.w / cz / 2;
|
|
2364
|
-
const cyA = -cy + vsb.h / cz / 2;
|
|
2367
|
+
const rz = z;
|
|
2365
2368
|
z = (0, import_utils2.clamp)(z, minZ, maxZ);
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
x = cx + cxB - cxA;
|
|
2369
|
-
y = cy + cyB - cyA;
|
|
2369
|
+
x = preserveFocalPoint(currentCamera.x, x, rz, z);
|
|
2370
|
+
y = preserveFocalPoint(currentCamera.y, y, rz, z);
|
|
2370
2371
|
}
|
|
2371
2372
|
const minX = px / z - bounds.x;
|
|
2372
2373
|
const minY = py / z - bounds.y;
|
|
@@ -2435,10 +2436,10 @@ class Editor extends import_eventemitter3.default {
|
|
|
2435
2436
|
}
|
|
2436
2437
|
} else {
|
|
2437
2438
|
if (z > zoomMax || z < zoomMin) {
|
|
2438
|
-
const
|
|
2439
|
+
const rz = z;
|
|
2439
2440
|
z = (0, import_utils2.clamp)(z, zoomMin, zoomMax);
|
|
2440
|
-
x =
|
|
2441
|
-
y =
|
|
2441
|
+
x = preserveFocalPoint(currentCamera.x, x, rz, z);
|
|
2442
|
+
y = preserveFocalPoint(currentCamera.y, y, rz, z);
|
|
2442
2443
|
}
|
|
2443
2444
|
}
|
|
2444
2445
|
}
|
|
@@ -7834,6 +7835,15 @@ class Editor extends import_eventemitter3.default {
|
|
|
7834
7835
|
_didPinch = false;
|
|
7835
7836
|
/** @internal */
|
|
7836
7837
|
_selectedShapeIdsAtPointerDown = [];
|
|
7838
|
+
/**
|
|
7839
|
+
* Whether `_selectedShapeIdsAtPointerDown` holds a pre-gesture selection
|
|
7840
|
+
* captured by a `pointer_down` (the touch path) that a following pinch
|
|
7841
|
+
* should restore. False when no pointer_down preceded the pinch (the
|
|
7842
|
+
* Safari trackpad path uses gesture events), in which case `pinch_start`
|
|
7843
|
+
* captures the live selection instead.
|
|
7844
|
+
* @internal
|
|
7845
|
+
*/
|
|
7846
|
+
_didCaptureSelectionAtPointerDown = false;
|
|
7837
7847
|
/** @internal */
|
|
7838
7848
|
_longPressTimeout = -1;
|
|
7839
7849
|
/** @internal */
|
|
@@ -7966,10 +7976,15 @@ class Editor extends import_eventemitter3.default {
|
|
|
7966
7976
|
case "pinch_start": {
|
|
7967
7977
|
if (inputs.getIsPinching()) return;
|
|
7968
7978
|
if (!inputs.getIsEditing()) {
|
|
7969
|
-
this.
|
|
7979
|
+
if (!this._didCaptureSelectionAtPointerDown) {
|
|
7980
|
+
this._selectedShapeIdsAtPointerDown = [...pageState.selectedShapeIds];
|
|
7981
|
+
}
|
|
7970
7982
|
this._didPinch = true;
|
|
7971
7983
|
inputs.setIsPinching(true);
|
|
7972
7984
|
this.interrupt();
|
|
7985
|
+
if (this._didCaptureSelectionAtPointerDown) {
|
|
7986
|
+
this.setSelectedShapes(this._selectedShapeIdsAtPointerDown);
|
|
7987
|
+
}
|
|
7973
7988
|
}
|
|
7974
7989
|
this.emit("event", info);
|
|
7975
7990
|
return;
|
|
@@ -8009,6 +8024,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8009
8024
|
const { _selectedShapeIdsAtPointerDown: shapesToReselect } = this;
|
|
8010
8025
|
this.setSelectedShapes(this._selectedShapeIdsAtPointerDown);
|
|
8011
8026
|
this._selectedShapeIdsAtPointerDown = [];
|
|
8027
|
+
this._didCaptureSelectionAtPointerDown = false;
|
|
8012
8028
|
if (this._didPinch) {
|
|
8013
8029
|
this._didPinch = false;
|
|
8014
8030
|
if (shapesToReselect.length > 0) {
|
|
@@ -8102,7 +8118,10 @@ class Editor extends import_eventemitter3.default {
|
|
|
8102
8118
|
});
|
|
8103
8119
|
}, this.options.longPressDurationMs);
|
|
8104
8120
|
}
|
|
8105
|
-
|
|
8121
|
+
if (!this._didCaptureSelectionAtPointerDown) {
|
|
8122
|
+
this._selectedShapeIdsAtPointerDown = this.getSelectedShapeIds();
|
|
8123
|
+
this._didCaptureSelectionAtPointerDown = true;
|
|
8124
|
+
}
|
|
8106
8125
|
if (info.button === import_constants.LEFT_MOUSE_BUTTON) this.capturedPointerId = info.pointerId;
|
|
8107
8126
|
inputs.buttons.add(info.button);
|
|
8108
8127
|
inputs.setIsPointing(true);
|
|
@@ -8175,6 +8194,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8175
8194
|
if (this.inputs.getIsRightPointing() && !this.inputs.getIsPanning()) {
|
|
8176
8195
|
this.inputs.setIsRightPointing(false);
|
|
8177
8196
|
this._selectedShapeIdsAtPointerDown = [];
|
|
8197
|
+
this._didCaptureSelectionAtPointerDown = false;
|
|
8178
8198
|
break;
|
|
8179
8199
|
}
|
|
8180
8200
|
this.inputs.setIsRightPointing(false);
|
|
@@ -8212,6 +8232,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8212
8232
|
this.slideCamera({ speed: slideSpeed, direction: slideDirection });
|
|
8213
8233
|
}
|
|
8214
8234
|
this._selectedShapeIdsAtPointerDown = [];
|
|
8235
|
+
this._didCaptureSelectionAtPointerDown = false;
|
|
8215
8236
|
return this;
|
|
8216
8237
|
}
|
|
8217
8238
|
}
|
|
@@ -8225,6 +8246,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8225
8246
|
}
|
|
8226
8247
|
}
|
|
8227
8248
|
this._selectedShapeIdsAtPointerDown = [];
|
|
8249
|
+
this._didCaptureSelectionAtPointerDown = false;
|
|
8228
8250
|
break;
|
|
8229
8251
|
}
|
|
8230
8252
|
}
|