@tldraw/editor 5.4.0-canary.ccab4e96c56e → 5.4.0-canary.ce2194838da7
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.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +21 -42
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js +1 -1
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +2 -0
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +1 -0
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +21 -42
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs +1 -1
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +2 -0
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +1 -0
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.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 +32 -57
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +4 -1
- package/src/lib/hooks/useCanvasEvents.ts +2 -0
- package/src/lib/hooks/usePassThroughWheelEvents.ts +3 -0
- package/src/lib/test/useCanvasEvents.test.tsx +74 -0
- package/src/lib/test/usePassThroughWheelEvents.test.tsx +25 -2
- 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.
|
|
395
|
+
"5.4.0-canary.ce2194838da7",
|
|
396
396
|
"cjs"
|
|
397
397
|
);
|
|
398
398
|
//# sourceMappingURL=index.js.map
|
|
@@ -1963,42 +1963,28 @@ class Editor extends import_eventemitter3.default {
|
|
|
1963
1963
|
*/
|
|
1964
1964
|
setEditingShape(shape) {
|
|
1965
1965
|
const id = typeof shape === "string" ? shape : shape?.id ?? null;
|
|
1966
|
-
if (!id)
|
|
1966
|
+
if (id && !this.canEditShape(id)) return this;
|
|
1967
|
+
this.run(() => {
|
|
1968
|
+
const prevEditingShapeId = this.getEditingShapeId();
|
|
1969
|
+
if (prevEditingShapeId) {
|
|
1970
|
+
const prevEditingShape = this.getShape(prevEditingShapeId);
|
|
1971
|
+
if (prevEditingShape) {
|
|
1972
|
+
this.getShapeUtil(prevEditingShape).onEditEnd?.(prevEditingShape);
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1967
1975
|
this.run(
|
|
1968
1976
|
() => {
|
|
1969
|
-
const prevEditingShapeId = this.getEditingShapeId();
|
|
1970
|
-
if (prevEditingShapeId) {
|
|
1971
|
-
const prevEditingShape = this.getShape(prevEditingShapeId);
|
|
1972
|
-
if (prevEditingShape) {
|
|
1973
|
-
this.getShapeUtil(prevEditingShape).onEditEnd?.(prevEditingShape);
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
1977
|
this._updateCurrentPageState({ editingShapeId: null });
|
|
1977
1978
|
this._currentRichTextEditor.set(null);
|
|
1979
|
+
if (!id) return;
|
|
1980
|
+
this.select(id);
|
|
1981
|
+
this._updateCurrentPageState({ editingShapeId: id });
|
|
1982
|
+
const nextEditingShape = this.getShape(id);
|
|
1983
|
+
this.getShapeUtil(nextEditingShape).onEditStart?.(nextEditingShape);
|
|
1978
1984
|
},
|
|
1979
1985
|
{ history: "ignore" }
|
|
1980
1986
|
);
|
|
1981
|
-
|
|
1982
|
-
}
|
|
1983
|
-
if (!this.canEditShape(id)) return this;
|
|
1984
|
-
this.run(
|
|
1985
|
-
() => {
|
|
1986
|
-
const prevEditingShapeId = this.getEditingShapeId();
|
|
1987
|
-
if (prevEditingShapeId) {
|
|
1988
|
-
const prevEditingShape = this.getShape(prevEditingShapeId);
|
|
1989
|
-
if (prevEditingShape) {
|
|
1990
|
-
this.getShapeUtil(prevEditingShape).onEditEnd?.(prevEditingShape);
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
this._updateCurrentPageState({ editingShapeId: null });
|
|
1994
|
-
this._currentRichTextEditor.set(null);
|
|
1995
|
-
this.select(id);
|
|
1996
|
-
this._updateCurrentPageState({ editingShapeId: id });
|
|
1997
|
-
const nextEditingShape = this.getShape(id);
|
|
1998
|
-
this.getShapeUtil(nextEditingShape).onEditStart?.(nextEditingShape);
|
|
1999
|
-
},
|
|
2000
|
-
{ history: "ignore" }
|
|
2001
|
-
);
|
|
1987
|
+
});
|
|
2002
1988
|
return this;
|
|
2003
1989
|
}
|
|
2004
1990
|
// Rich text editor
|
|
@@ -2142,6 +2128,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
2142
2128
|
if (!_shape) return false;
|
|
2143
2129
|
const util = this.getShapeUtil(_shape);
|
|
2144
2130
|
if (!util.canCrop(_shape)) return false;
|
|
2131
|
+
if (this.getIsReadonly()) return false;
|
|
2145
2132
|
if (this.isShapeOrAncestorLocked(_shape)) return false;
|
|
2146
2133
|
return true;
|
|
2147
2134
|
}
|
|
@@ -2351,7 +2338,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
2351
2338
|
...this._cameraOptions.__unsafe__getWithoutCapture(),
|
|
2352
2339
|
...opts
|
|
2353
2340
|
});
|
|
2354
|
-
if (next.zoomSteps
|
|
2341
|
+
if (!next.zoomSteps || next.zoomSteps.length < 1) next.zoomSteps = [1];
|
|
2355
2342
|
this._cameraOptions.set(next);
|
|
2356
2343
|
this.setCamera(this.getCamera());
|
|
2357
2344
|
return this;
|
|
@@ -5217,26 +5204,17 @@ class Editor extends import_eventemitter3.default {
|
|
|
5217
5204
|
toggleLock(shapes) {
|
|
5218
5205
|
const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
|
|
5219
5206
|
if (this.getIsReadonly() || ids.length === 0) return this;
|
|
5220
|
-
let allLocked = true
|
|
5207
|
+
let allLocked = true;
|
|
5221
5208
|
const shapesToToggle = [];
|
|
5222
5209
|
for (const id of ids) {
|
|
5223
5210
|
const shape = this.getShape(id);
|
|
5224
5211
|
if (shape) {
|
|
5225
5212
|
shapesToToggle.push(shape);
|
|
5226
|
-
if (shape.isLocked)
|
|
5227
|
-
allUnlocked = false;
|
|
5228
|
-
} else {
|
|
5229
|
-
allLocked = false;
|
|
5230
|
-
}
|
|
5213
|
+
if (!shape.isLocked) allLocked = false;
|
|
5231
5214
|
}
|
|
5232
5215
|
}
|
|
5233
5216
|
this.run(() => {
|
|
5234
|
-
if (
|
|
5235
|
-
this.updateShapes(
|
|
5236
|
-
shapesToToggle.map((shape) => ({ id: shape.id, type: shape.type, isLocked: true }))
|
|
5237
|
-
);
|
|
5238
|
-
this.setSelectedShapes([]);
|
|
5239
|
-
} else if (allLocked) {
|
|
5217
|
+
if (allLocked) {
|
|
5240
5218
|
this.updateShapes(
|
|
5241
5219
|
shapesToToggle.map((shape) => ({ id: shape.id, type: shape.type, isLocked: false }))
|
|
5242
5220
|
);
|
|
@@ -5244,6 +5222,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
5244
5222
|
this.updateShapes(
|
|
5245
5223
|
shapesToToggle.map((shape) => ({ id: shape.id, type: shape.type, isLocked: true }))
|
|
5246
5224
|
);
|
|
5225
|
+
this.setSelectedShapes([]);
|
|
5247
5226
|
}
|
|
5248
5227
|
});
|
|
5249
5228
|
return this;
|