@tldraw/editor 5.4.0-canary.c2c2eba669bd → 5.4.0-canary.c3a6ec8c6238

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 (30) hide show
  1. package/dist-cjs/index.js +1 -1
  2. package/dist-cjs/lib/editor/Editor.js +5 -12
  3. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  4. package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js +1 -1
  5. package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +2 -2
  6. package/dist-cjs/lib/hooks/useCanvasEvents.js +2 -0
  7. package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
  8. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +1 -0
  9. package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
  10. package/dist-cjs/version.js +3 -3
  11. package/dist-cjs/version.js.map +1 -1
  12. package/dist-esm/index.mjs +1 -1
  13. package/dist-esm/lib/editor/Editor.mjs +5 -12
  14. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  15. package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs +1 -1
  16. package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +2 -2
  17. package/dist-esm/lib/hooks/useCanvasEvents.mjs +2 -0
  18. package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
  19. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +1 -0
  20. package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +2 -2
  21. package/dist-esm/version.mjs +3 -3
  22. package/dist-esm/version.mjs.map +1 -1
  23. package/package.json +7 -7
  24. package/src/lib/editor/Editor.ts +5 -13
  25. package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +4 -1
  26. package/src/lib/hooks/useCanvasEvents.ts +2 -0
  27. package/src/lib/hooks/usePassThroughWheelEvents.ts +3 -0
  28. package/src/lib/test/useCanvasEvents.test.tsx +74 -0
  29. package/src/lib/test/usePassThroughWheelEvents.test.tsx +25 -2
  30. package/src/version.ts +3 -3
package/dist-cjs/index.js CHANGED
@@ -392,7 +392,7 @@ var import_uniq = require("./lib/utils/uniq");
392
392
  var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
393
393
  (0, import_utils.registerTldrawLibraryVersion)(
394
394
  "@tldraw/editor",
395
- "5.4.0-canary.c2c2eba669bd",
395
+ "5.4.0-canary.c3a6ec8c6238",
396
396
  "cjs"
397
397
  );
398
398
  //# sourceMappingURL=index.js.map
@@ -2128,6 +2128,7 @@ class Editor extends import_eventemitter3.default {
2128
2128
  if (!_shape) return false;
2129
2129
  const util = this.getShapeUtil(_shape);
2130
2130
  if (!util.canCrop(_shape)) return false;
2131
+ if (this.getIsReadonly()) return false;
2131
2132
  if (this.isShapeOrAncestorLocked(_shape)) return false;
2132
2133
  return true;
2133
2134
  }
@@ -5203,26 +5204,17 @@ class Editor extends import_eventemitter3.default {
5203
5204
  toggleLock(shapes) {
5204
5205
  const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
5205
5206
  if (this.getIsReadonly() || ids.length === 0) return this;
5206
- let allLocked = true, allUnlocked = true;
5207
+ let allLocked = true;
5207
5208
  const shapesToToggle = [];
5208
5209
  for (const id of ids) {
5209
5210
  const shape = this.getShape(id);
5210
5211
  if (shape) {
5211
5212
  shapesToToggle.push(shape);
5212
- if (shape.isLocked) {
5213
- allUnlocked = false;
5214
- } else {
5215
- allLocked = false;
5216
- }
5213
+ if (!shape.isLocked) allLocked = false;
5217
5214
  }
5218
5215
  }
5219
5216
  this.run(() => {
5220
- if (allUnlocked) {
5221
- this.updateShapes(
5222
- shapesToToggle.map((shape) => ({ id: shape.id, type: shape.type, isLocked: true }))
5223
- );
5224
- this.setSelectedShapes([]);
5225
- } else if (allLocked) {
5217
+ if (allLocked) {
5226
5218
  this.updateShapes(
5227
5219
  shapesToToggle.map((shape) => ({ id: shape.id, type: shape.type, isLocked: false }))
5228
5220
  );
@@ -5230,6 +5222,7 @@ class Editor extends import_eventemitter3.default {
5230
5222
  this.updateShapes(
5231
5223
  shapesToToggle.map((shape) => ({ id: shape.id, type: shape.type, isLocked: true }))
5232
5224
  );
5225
+ this.setSelectedShapes([]);
5233
5226
  }
5234
5227
  });
5235
5228
  return this;