@tldraw/editor 4.4.0-canary.2cc304fbec3f → 4.4.0-canary.2d6554e2c18e

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.
Files changed (35) hide show
  1. package/dist-cjs/index.d.ts +5 -5
  2. package/dist-cjs/index.js +1 -6
  3. package/dist-cjs/index.js.map +3 -3
  4. package/dist-cjs/lib/TldrawEditor.js.map +1 -1
  5. package/dist-cjs/lib/config/createTLStore.js.map +1 -1
  6. package/dist-cjs/lib/editor/Editor.js +12 -10
  7. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  8. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +13 -38
  9. package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +3 -3
  10. package/dist-cjs/lib/editor/tools/RootState.js +0 -13
  11. package/dist-cjs/lib/editor/tools/RootState.js.map +2 -2
  12. package/dist-cjs/version.js +3 -3
  13. package/dist-cjs/version.js.map +1 -1
  14. package/dist-esm/index.d.mts +5 -5
  15. package/dist-esm/index.mjs +1 -6
  16. package/dist-esm/index.mjs.map +2 -2
  17. package/dist-esm/lib/TldrawEditor.mjs.map +1 -1
  18. package/dist-esm/lib/config/createTLStore.mjs.map +1 -1
  19. package/dist-esm/lib/editor/Editor.mjs +12 -10
  20. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  21. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +14 -39
  22. package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +2 -2
  23. package/dist-esm/lib/editor/tools/RootState.mjs +0 -13
  24. package/dist-esm/lib/editor/tools/RootState.mjs.map +2 -2
  25. package/dist-esm/version.mjs +3 -3
  26. package/dist-esm/version.mjs.map +1 -1
  27. package/editor.css +5 -0
  28. package/package.json +7 -9
  29. package/src/index.ts +0 -5
  30. package/src/lib/TldrawEditor.tsx +1 -1
  31. package/src/lib/config/createTLStore.ts +1 -1
  32. package/src/lib/editor/Editor.ts +21 -11
  33. package/src/lib/editor/managers/HistoryManager/HistoryManager.ts +19 -47
  34. package/src/lib/editor/tools/RootState.ts +0 -16
  35. package/src/version.ts +3 -3
@@ -331,7 +331,6 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
331
331
  // unmount / remount in the DOM, which is expensive; and computing visibility is
332
332
  // also expensive in large projects. For this reason, we use a second bounding
333
333
  // box just for rendering, and we only update after the camera stops moving.
334
- __publicField(this, "_cameraState", atom("camera state", "idle"));
335
334
  __publicField(this, "_cameraStateTimeoutRemaining", 0);
336
335
  /* @internal */
337
336
  __publicField(this, "_currentPageShapeIds");
@@ -2422,7 +2421,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2422
2421
  * @public
2423
2422
  */
2424
2423
  zoomToFit(opts) {
2425
- const ids = [...this.getCurrentPageShapeIds()];
2424
+ const ids = [...this.getCurrentPageShapeIds()].filter((id) => !this.isShapeHidden(id));
2426
2425
  if (ids.length <= 0) return this;
2427
2426
  const pageBounds = Box.Common(compact(ids.map((id) => this.getShapePageBounds(id))));
2428
2427
  this.zoomToBounds(pageBounds, opts);
@@ -3121,15 +3120,18 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3121
3120
  this._cameraStateTimeoutRemaining -= elapsed;
3122
3121
  if (this._cameraStateTimeoutRemaining > 0) return;
3123
3122
  this.off("tick", this._decayCameraStateTimeout);
3124
- this._cameraState.set("idle");
3123
+ this._setCameraState("idle");
3125
3124
  }
3126
3125
  _tickCameraState() {
3127
3126
  this._cameraStateTimeoutRemaining = this.options.cameraMovingTimeoutMs;
3128
- if (this._cameraState.__unsafe__getWithoutCapture() !== "idle") return;
3129
- this._cameraState.set("moving");
3127
+ if (this.getInstanceState().cameraState !== "idle") return;
3128
+ this._setCameraState("moving");
3130
3129
  this._debouncedZoomLevel.set(unsafe__withoutCapture(() => this.getCamera().z));
3131
3130
  this.on("tick", this._decayCameraStateTimeout);
3132
3131
  }
3132
+ _setCameraState(cameraState) {
3133
+ this.updateInstanceState({ cameraState }, { history: "ignore" });
3134
+ }
3133
3135
  /**
3134
3136
  * Whether the camera is moving or idle.
3135
3137
  *
@@ -3141,7 +3143,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3141
3143
  * @public
3142
3144
  */
3143
3145
  getCameraState() {
3144
- return this._cameraState.get();
3146
+ return this.getInstanceState().cameraState;
3145
3147
  }
3146
3148
  getRenderingShapes() {
3147
3149
  const renderingShapes = this.getUnorderedRenderingShapes(true);
@@ -3907,6 +3909,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
3907
3909
  getCurrentPageBounds() {
3908
3910
  let commonBounds;
3909
3911
  this.getCurrentPageShapeIdsSorted().forEach((shapeId) => {
3912
+ if (this.isShapeHidden(shapeId)) return;
3910
3913
  const bounds = this.getShapeMaskedPageBounds(shapeId);
3911
3914
  if (!bounds) return;
3912
3915
  if (!commonBounds) {
@@ -7248,7 +7251,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7248
7251
  /**
7249
7252
  * Handles navigating to the content specified by the query param in the given URL.
7250
7253
  *
7251
- * Use {@link Editor#createDeepLink} to create a URL with a deep link query param.
7254
+ * Use {@link Editor.createDeepLink} to create a URL with a deep link query param.
7252
7255
  *
7253
7256
  * If no URL is provided, it will look for the param in the current `window.location.href`.
7254
7257
  *
@@ -7599,9 +7602,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7599
7602
  case "pinch_start": {
7600
7603
  if (inputs.getIsPinching()) return;
7601
7604
  if (!inputs.getIsEditing()) {
7602
- if (!this._selectedShapeIdsAtPointerDown.length) {
7603
- this._selectedShapeIdsAtPointerDown = [...pageState.selectedShapeIds];
7604
- }
7605
+ this._selectedShapeIdsAtPointerDown = [...pageState.selectedShapeIds];
7605
7606
  this._didPinch = true;
7606
7607
  inputs.setIsPinching(true);
7607
7608
  this.interrupt();
@@ -7816,6 +7817,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
7816
7817
  this.setCurrentTool(this._restoreToolId);
7817
7818
  }
7818
7819
  }
7820
+ this._selectedShapeIdsAtPointerDown = [];
7819
7821
  break;
7820
7822
  }
7821
7823
  }