@tldraw/editor 5.4.0-canary.2466fb759d0e → 5.4.0-canary.263c43164873
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 +20 -30
- 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/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 +20 -30
- 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/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/lib/editor/Editor.ts +35 -44
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +4 -1
- package/src/lib/hooks/useCanvasEvents.ts +2 -0
- package/src/lib/test/useCanvasEvents.test.tsx +74 -0
- 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.263c43164873",
|
|
396
396
|
"cjs"
|
|
397
397
|
);
|
|
398
398
|
//# sourceMappingURL=index.js.map
|
|
@@ -257,6 +257,10 @@ class Editor extends import_eventemitter3.default {
|
|
|
257
257
|
if (!nextPageState) nextPageState = { ...prevPageState };
|
|
258
258
|
nextPageState.editingShapeId = null;
|
|
259
259
|
}
|
|
260
|
+
if (prevPageState.croppingShapeId && shapesNoLongerInPage.has(prevPageState.croppingShapeId)) {
|
|
261
|
+
if (!nextPageState) nextPageState = { ...prevPageState };
|
|
262
|
+
nextPageState.croppingShapeId = null;
|
|
263
|
+
}
|
|
260
264
|
const hintingShapeIds = prevPageState.hintingShapeIds.filter(
|
|
261
265
|
(id) => !shapesNoLongerInPage.has(id)
|
|
262
266
|
);
|
|
@@ -1959,42 +1963,28 @@ class Editor extends import_eventemitter3.default {
|
|
|
1959
1963
|
*/
|
|
1960
1964
|
setEditingShape(shape) {
|
|
1961
1965
|
const id = typeof shape === "string" ? shape : shape?.id ?? null;
|
|
1962
|
-
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
|
+
}
|
|
1963
1975
|
this.run(
|
|
1964
1976
|
() => {
|
|
1965
|
-
const prevEditingShapeId = this.getEditingShapeId();
|
|
1966
|
-
if (prevEditingShapeId) {
|
|
1967
|
-
const prevEditingShape = this.getShape(prevEditingShapeId);
|
|
1968
|
-
if (prevEditingShape) {
|
|
1969
|
-
this.getShapeUtil(prevEditingShape).onEditEnd?.(prevEditingShape);
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
1977
|
this._updateCurrentPageState({ editingShapeId: null });
|
|
1973
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);
|
|
1974
1984
|
},
|
|
1975
1985
|
{ history: "ignore" }
|
|
1976
1986
|
);
|
|
1977
|
-
|
|
1978
|
-
}
|
|
1979
|
-
if (!this.canEditShape(id)) return this;
|
|
1980
|
-
this.run(
|
|
1981
|
-
() => {
|
|
1982
|
-
const prevEditingShapeId = this.getEditingShapeId();
|
|
1983
|
-
if (prevEditingShapeId) {
|
|
1984
|
-
const prevEditingShape = this.getShape(prevEditingShapeId);
|
|
1985
|
-
if (prevEditingShape) {
|
|
1986
|
-
this.getShapeUtil(prevEditingShape).onEditEnd?.(prevEditingShape);
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
this._updateCurrentPageState({ editingShapeId: null });
|
|
1990
|
-
this._currentRichTextEditor.set(null);
|
|
1991
|
-
this.select(id);
|
|
1992
|
-
this._updateCurrentPageState({ editingShapeId: id });
|
|
1993
|
-
const nextEditingShape = this.getShape(id);
|
|
1994
|
-
this.getShapeUtil(nextEditingShape).onEditStart?.(nextEditingShape);
|
|
1995
|
-
},
|
|
1996
|
-
{ history: "ignore" }
|
|
1997
|
-
);
|
|
1987
|
+
});
|
|
1998
1988
|
return this;
|
|
1999
1989
|
}
|
|
2000
1990
|
// Rich text editor
|
|
@@ -2347,7 +2337,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
2347
2337
|
...this._cameraOptions.__unsafe__getWithoutCapture(),
|
|
2348
2338
|
...opts
|
|
2349
2339
|
});
|
|
2350
|
-
if (next.zoomSteps
|
|
2340
|
+
if (!next.zoomSteps || next.zoomSteps.length < 1) next.zoomSteps = [1];
|
|
2351
2341
|
this._cameraOptions.set(next);
|
|
2352
2342
|
this.setCamera(this.getCamera());
|
|
2353
2343
|
return this;
|