@tldraw/editor 4.4.0-canary.2f051ecbee73 → 4.4.0-canary.3d13b40b6c39

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.
@@ -2259,10 +2259,10 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2259
2259
  */
2260
2260
  stopFollowingUser(): this;
2261
2261
  /* Excluded from this release type: getUnorderedRenderingShapes */
2262
- private _cameraState;
2263
2262
  private _cameraStateTimeoutRemaining;
2264
2263
  private _decayCameraStateTimeout;
2265
2264
  private _tickCameraState;
2265
+ private _setCameraState;
2266
2266
  /**
2267
2267
  * Whether the camera is moving or idle.
2268
2268
  *
@@ -2761,7 +2761,24 @@ export declare class Editor extends EventEmitter<TLEventMap> {
2761
2761
  hitInside?: boolean;
2762
2762
  margin?: number;
2763
2763
  }): TLShape[];
2764
- /* Excluded from this release type: getShapeIdsInsideBounds */
2764
+ /**
2765
+ * Get shape IDs within the given bounds.
2766
+ *
2767
+ * Note: Uses shape page bounds only. Frames with labels outside their bounds
2768
+ * may not be included even if the label is within the search bounds.
2769
+ *
2770
+ * Note: Results are unordered. If you need z-order, combine with sorted shapes:
2771
+ * ```ts
2772
+ * const candidates = editor.getShapeIdsInsideBounds(bounds)
2773
+ * const sorted = editor.getCurrentPageShapesSorted().filter(s => candidates.has(s.id))
2774
+ * ```
2775
+ *
2776
+ * @param bounds - The bounds to search within.
2777
+ * @returns Unordered set of shape IDs within the given bounds.
2778
+ *
2779
+ * @public
2780
+ */
2781
+ getShapeIdsInsideBounds(bounds: Box): Set<TLShapeId>;
2765
2782
  /**
2766
2783
  * Test whether a point (in the current page space) will will a shape. This method takes into account masks,
2767
2784
  * such as when a shape is the child of a frame and is partially clipped by the frame.
@@ -7022,13 +7039,13 @@ export declare interface TldrawOptions {
7022
7039
  readonly branding?: string;
7023
7040
  /**
7024
7041
  * Whether to use debounced zoom level for certain rendering optimizations. When true,
7025
- * `editor.getDebouncedZoomLevel()` returns a cached zoom value while the camera is moving,
7042
+ * `editor.getEfficientZoomLevel()` returns a cached zoom value while the camera is moving,
7026
7043
  * reducing re-renders. When false, it always returns the current zoom level.
7027
7044
  */
7028
7045
  readonly debouncedZoom: boolean;
7029
7046
  /**
7030
7047
  * The number of shapes that must be on the page for the debounced zoom level to be used.
7031
- * Defaults to 300 shapes.
7048
+ * Defaults to 500 shapes.
7032
7049
  */
7033
7050
  readonly debouncedZoomThreshold: number;
7034
7051
  /**
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.2f051ecbee73",
375
+ "4.4.0-canary.3d13b40b6c39",
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._cameraState.set("idle");
3090
+ this._setCameraState("idle");
3092
3091
  }
3093
3092
  _tickCameraState() {
3094
3093
  this._cameraStateTimeoutRemaining = this.options.cameraMovingTimeoutMs;
3095
- if (this._cameraState.__unsafe__getWithoutCapture() !== "idle") return;
3096
- this._cameraState.set("moving");
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._cameraState.get();
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
- * @internal
4058
+ * @public
4057
4059
  */
4058
4060
  getShapeIdsInsideBounds(bounds) {
4059
4061
  return this._spatialIndex.getShapeIdsInsideBounds(bounds);
@@ -7567,9 +7569,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7567
7569
  case "pinch_start": {
7568
7570
  if (inputs.getIsPinching()) return;
7569
7571
  if (!inputs.getIsEditing()) {
7570
- if (!this._selectedShapeIdsAtPointerDown.length) {
7571
- this._selectedShapeIdsAtPointerDown = [...pageState.selectedShapeIds];
7572
- }
7572
+ this._selectedShapeIdsAtPointerDown = [...pageState.selectedShapeIds];
7573
7573
  this._didPinch = true;
7574
7574
  inputs.setIsPinching(true);
7575
7575
  this.interrupt();
@@ -7784,6 +7784,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
7784
7784
  this.setCurrentTool(this._restoreToolId);
7785
7785
  }
7786
7786
  }
7787
+ this._selectedShapeIdsAtPointerDown = [];
7787
7788
  break;
7788
7789
  }
7789
7790
  }