@tldraw/editor 4.4.0-canary.4e4f05b278df → 4.4.0-canary.52ddccb88729
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 +52 -9
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +17 -8
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js +2 -3
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/license/LicenseManager.js +6 -6
- package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
- package/dist-cjs/lib/options.js +2 -1
- package/dist-cjs/lib/options.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 +52 -9
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +17 -8
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs +2 -3
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/license/LicenseManager.mjs +6 -6
- package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +2 -1
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +17 -2
- package/package.json +8 -9
- package/src/lib/editor/Editor.ts +24 -8
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +0 -35
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +4 -8
- package/src/lib/editor/shapes/ShapeUtil.ts +19 -5
- package/src/lib/license/LicenseManager.ts +6 -6
- package/src/lib/options.ts +10 -2
- package/src/version.ts +3 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -909,6 +909,7 @@ export declare const defaultTldrawOptions: {
|
|
|
909
909
|
readonly maxShapesPerPage: 4000;
|
|
910
910
|
readonly multiClickDurationMs: 200;
|
|
911
911
|
readonly nonce: undefined;
|
|
912
|
+
readonly quickZoomPreservesScreenBounds: true;
|
|
912
913
|
readonly snapThreshold: 8;
|
|
913
914
|
readonly spacebarPanning: true;
|
|
914
915
|
readonly temporaryAssetPreviewLifetimeMs: 180000;
|
|
@@ -2259,10 +2260,10 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2259
2260
|
*/
|
|
2260
2261
|
stopFollowingUser(): this;
|
|
2261
2262
|
/* Excluded from this release type: getUnorderedRenderingShapes */
|
|
2262
|
-
private _cameraState;
|
|
2263
2263
|
private _cameraStateTimeoutRemaining;
|
|
2264
2264
|
private _decayCameraStateTimeout;
|
|
2265
2265
|
private _tickCameraState;
|
|
2266
|
+
private _setCameraState;
|
|
2266
2267
|
/**
|
|
2267
2268
|
* Whether the camera is moving or idle.
|
|
2268
2269
|
*
|
|
@@ -2761,7 +2762,24 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2761
2762
|
hitInside?: boolean;
|
|
2762
2763
|
margin?: number;
|
|
2763
2764
|
}): TLShape[];
|
|
2764
|
-
|
|
2765
|
+
/**
|
|
2766
|
+
* Get shape IDs within the given bounds.
|
|
2767
|
+
*
|
|
2768
|
+
* Note: Uses shape page bounds only. Frames with labels outside their bounds
|
|
2769
|
+
* may not be included even if the label is within the search bounds.
|
|
2770
|
+
*
|
|
2771
|
+
* Note: Results are unordered. If you need z-order, combine with sorted shapes:
|
|
2772
|
+
* ```ts
|
|
2773
|
+
* const candidates = editor.getShapeIdsInsideBounds(bounds)
|
|
2774
|
+
* const sorted = editor.getCurrentPageShapesSorted().filter(s => candidates.has(s.id))
|
|
2775
|
+
* ```
|
|
2776
|
+
*
|
|
2777
|
+
* @param bounds - The bounds to search within.
|
|
2778
|
+
* @returns Unordered set of shape IDs within the given bounds.
|
|
2779
|
+
*
|
|
2780
|
+
* @public
|
|
2781
|
+
*/
|
|
2782
|
+
getShapeIdsInsideBounds(bounds: Box): Set<TLShapeId>;
|
|
2765
2783
|
/**
|
|
2766
2784
|
* Test whether a point (in the current page space) will will a shape. This method takes into account masks,
|
|
2767
2785
|
* such as when a shape is the child of a frame and is partially clipped by the frame.
|
|
@@ -7022,13 +7040,13 @@ export declare interface TldrawOptions {
|
|
|
7022
7040
|
readonly branding?: string;
|
|
7023
7041
|
/**
|
|
7024
7042
|
* Whether to use debounced zoom level for certain rendering optimizations. When true,
|
|
7025
|
-
* `editor.
|
|
7043
|
+
* `editor.getEfficientZoomLevel()` returns a cached zoom value while the camera is moving,
|
|
7026
7044
|
* reducing re-renders. When false, it always returns the current zoom level.
|
|
7027
7045
|
*/
|
|
7028
7046
|
readonly debouncedZoom: boolean;
|
|
7029
7047
|
/**
|
|
7030
7048
|
* The number of shapes that must be on the page for the debounced zoom level to be used.
|
|
7031
|
-
* Defaults to
|
|
7049
|
+
* Defaults to 500 shapes.
|
|
7032
7050
|
*/
|
|
7033
7051
|
readonly debouncedZoomThreshold: number;
|
|
7034
7052
|
/**
|
|
@@ -7047,6 +7065,13 @@ export declare interface TldrawOptions {
|
|
|
7047
7065
|
* The distance (in screen pixels) at which shapes snap to guides and other shapes.
|
|
7048
7066
|
*/
|
|
7049
7067
|
readonly snapThreshold: number;
|
|
7068
|
+
/**
|
|
7069
|
+
* Whether the quick-zoom brush preserves its screen-pixel size when the user
|
|
7070
|
+
* zooms the overview. When true, zooming in shrinks the target viewport (higher
|
|
7071
|
+
* return zoom); zooming out expands it. When false, the brush keeps the original
|
|
7072
|
+
* viewport's page dimensions regardless of overview zoom changes.
|
|
7073
|
+
*/
|
|
7074
|
+
readonly quickZoomPreservesScreenBounds: boolean;
|
|
7050
7075
|
}
|
|
7051
7076
|
|
|
7052
7077
|
/** @public */
|
|
@@ -8002,17 +8027,35 @@ export declare interface TLShapeUtilCanBeLaidOutOpts {
|
|
|
8002
8027
|
|
|
8003
8028
|
/**
|
|
8004
8029
|
* Options passed to {@link ShapeUtil.canBind}. A binding that could be made. At least one of
|
|
8005
|
-
* `
|
|
8030
|
+
* `fromShape` or `toShape` will belong to this shape util.
|
|
8031
|
+
*
|
|
8032
|
+
* The shapes may be full {@link @tldraw/tlschema#TLShape} objects when available, or just
|
|
8033
|
+
* `{ type }` stubs when the shape hasn't been created yet (e.g. during arrow creation). Use
|
|
8034
|
+
* `'id' in shape` to check whether the full shape is available.
|
|
8006
8035
|
*
|
|
8007
8036
|
* @public
|
|
8008
8037
|
*/
|
|
8009
8038
|
export declare interface TLShapeUtilCanBindOpts<Shape extends TLShape = TLShape> {
|
|
8010
|
-
/** The
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8039
|
+
/** The shape referenced by the `fromId` of the binding, or a `{ type }` stub if unavailable. */
|
|
8040
|
+
fromShape: {
|
|
8041
|
+
type: TLShape['type'];
|
|
8042
|
+
} | TLShape;
|
|
8043
|
+
/** The shape referenced by the `toId` of the binding, or a `{ type }` stub if unavailable. */
|
|
8044
|
+
toShape: {
|
|
8045
|
+
type: TLShape['type'];
|
|
8046
|
+
} | TLShape;
|
|
8014
8047
|
/** The type of binding. */
|
|
8015
8048
|
bindingType: string;
|
|
8049
|
+
/**
|
|
8050
|
+
* The type of shape referenced by the `fromId` of the binding.
|
|
8051
|
+
* @deprecated Use `fromShape.type` instead.
|
|
8052
|
+
*/
|
|
8053
|
+
fromShapeType: TLShape['type'];
|
|
8054
|
+
/**
|
|
8055
|
+
* The type of shape referenced by the `toId` of the binding.
|
|
8056
|
+
* @deprecated Use `toShape.type` instead.
|
|
8057
|
+
*/
|
|
8058
|
+
toShapeType: TLShape['type'];
|
|
8016
8059
|
}
|
|
8017
8060
|
|
|
8018
8061
|
/** @public */
|
package/dist-cjs/index.js
CHANGED
|
@@ -372,7 +372,7 @@ var import_uniq = require("./lib/utils/uniq");
|
|
|
372
372
|
var import_window_open = require("./lib/utils/window-open");
|
|
373
373
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
374
374
|
"@tldraw/editor",
|
|
375
|
-
"4.4.0-canary.
|
|
375
|
+
"4.4.0-canary.52ddccb88729",
|
|
376
376
|
"cjs"
|
|
377
377
|
);
|
|
378
378
|
//# sourceMappingURL=index.js.map
|
|
@@ -298,7 +298,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
298
298
|
// unmount / remount in the DOM, which is expensive; and computing visibility is
|
|
299
299
|
// also expensive in large projects. For this reason, we use a second bounding
|
|
300
300
|
// box just for rendering, and we only update after the camera stops moving.
|
|
301
|
-
__publicField(this, "_cameraState", (0, import_state.atom)("camera state", "idle"));
|
|
302
301
|
__publicField(this, "_cameraStateTimeoutRemaining", 0);
|
|
303
302
|
/* @internal */
|
|
304
303
|
__publicField(this, "_currentPageShapeIds");
|
|
@@ -3088,15 +3087,18 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
3088
3087
|
this._cameraStateTimeoutRemaining -= elapsed;
|
|
3089
3088
|
if (this._cameraStateTimeoutRemaining > 0) return;
|
|
3090
3089
|
this.off("tick", this._decayCameraStateTimeout);
|
|
3091
|
-
this.
|
|
3090
|
+
this._setCameraState("idle");
|
|
3092
3091
|
}
|
|
3093
3092
|
_tickCameraState() {
|
|
3094
3093
|
this._cameraStateTimeoutRemaining = this.options.cameraMovingTimeoutMs;
|
|
3095
|
-
if (this.
|
|
3096
|
-
this.
|
|
3094
|
+
if (this.getInstanceState().cameraState !== "idle") return;
|
|
3095
|
+
this._setCameraState("moving");
|
|
3097
3096
|
this._debouncedZoomLevel.set((0, import_state.unsafe__withoutCapture)(() => this.getCamera().z));
|
|
3098
3097
|
this.on("tick", this._decayCameraStateTimeout);
|
|
3099
3098
|
}
|
|
3099
|
+
_setCameraState(cameraState) {
|
|
3100
|
+
this.updateInstanceState({ cameraState }, { history: "ignore" });
|
|
3101
|
+
}
|
|
3100
3102
|
/**
|
|
3101
3103
|
* Whether the camera is moving or idle.
|
|
3102
3104
|
*
|
|
@@ -3108,7 +3110,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
3108
3110
|
* @public
|
|
3109
3111
|
*/
|
|
3110
3112
|
getCameraState() {
|
|
3111
|
-
return this.
|
|
3113
|
+
return this.getInstanceState().cameraState;
|
|
3112
3114
|
}
|
|
3113
3115
|
getRenderingShapes() {
|
|
3114
3116
|
const renderingShapes = this.getUnorderedRenderingShapes(true);
|
|
@@ -4053,7 +4055,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4053
4055
|
* @param bounds - The bounds to search within.
|
|
4054
4056
|
* @returns Unordered set of shape IDs within the given bounds.
|
|
4055
4057
|
*
|
|
4056
|
-
* @
|
|
4058
|
+
* @public
|
|
4057
4059
|
*/
|
|
4058
4060
|
getShapeIdsInsideBounds(bounds) {
|
|
4059
4061
|
return this._spatialIndex.getShapeIdsInsideBounds(bounds);
|
|
@@ -4596,7 +4598,13 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4596
4598
|
const fromShapeType = typeof fromShape === "string" ? fromShape : fromShape.type;
|
|
4597
4599
|
const toShapeType = typeof toShape === "string" ? toShape : toShape.type;
|
|
4598
4600
|
const bindingType = typeof binding === "string" ? binding : binding.type;
|
|
4599
|
-
const canBindOpts = {
|
|
4601
|
+
const canBindOpts = {
|
|
4602
|
+
fromShape: typeof fromShape === "string" ? { type: fromShape } : fromShape,
|
|
4603
|
+
toShape: typeof toShape === "string" ? { type: toShape } : toShape,
|
|
4604
|
+
bindingType,
|
|
4605
|
+
fromShapeType,
|
|
4606
|
+
toShapeType
|
|
4607
|
+
};
|
|
4600
4608
|
if (fromShapeType === toShapeType) {
|
|
4601
4609
|
return this.getShapeUtil(fromShapeType).canBind(canBindOpts);
|
|
4602
4610
|
}
|
|
@@ -5736,7 +5744,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
5736
5744
|
this.resizeShape(id, shapeScale, {
|
|
5737
5745
|
initialShape: options.initialShape,
|
|
5738
5746
|
initialBounds: options.initialBounds,
|
|
5739
|
-
isAspectRatioLocked: options.isAspectRatioLocked
|
|
5747
|
+
isAspectRatioLocked: options.isAspectRatioLocked,
|
|
5748
|
+
initialPageTransform: options.initialPageTransform
|
|
5740
5749
|
});
|
|
5741
5750
|
if (Math.sign(scale.x) * Math.sign(scale.y) < 0) {
|
|
5742
5751
|
const parentRotation = this.getShapeParentTransform(id).rotation();
|