@tldraw/editor 3.13.0-canary.2c1fb1ac1f1a → 3.13.0-canary.3000265147be
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.d.ts +8 -1
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +19 -7
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +8 -1
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +19 -7
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +0 -4
- package/package.json +7 -7
- package/src/lib/editor/Editor.ts +19 -7
- package/src/lib/editor/shapes/ShapeUtil.ts +9 -1
- package/src/version.ts +3 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -5438,7 +5438,14 @@ export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknown
|
|
|
5438
5438
|
*/
|
|
5439
5439
|
onClick?(shape: Shape): TLShapePartial<Shape> | void;
|
|
5440
5440
|
/**
|
|
5441
|
-
* A callback called when a shape
|
|
5441
|
+
* A callback called when a shape starts being edited.
|
|
5442
|
+
*
|
|
5443
|
+
* @param shape - The shape.
|
|
5444
|
+
* @public
|
|
5445
|
+
*/
|
|
5446
|
+
onEditStart?(shape: Shape): void;
|
|
5447
|
+
/**
|
|
5448
|
+
* A callback called when a shape finishes being edited.
|
|
5442
5449
|
*
|
|
5443
5450
|
* @param shape - The shape.
|
|
5444
5451
|
* @public
|
package/dist-cjs/index.js
CHANGED
|
@@ -424,7 +424,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
424
424
|
) : getShapeVisibility;
|
|
425
425
|
this.options = { ...import_options.defaultTldrawOptions, ...options };
|
|
426
426
|
this.store = store;
|
|
427
|
-
this.disposables.add(this.store.dispose.bind(this.store));
|
|
428
427
|
this.history = new import_HistoryManager.HistoryManager({
|
|
429
428
|
store,
|
|
430
429
|
annotateError: (error) => {
|
|
@@ -836,6 +835,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
836
835
|
dispose() {
|
|
837
836
|
this.disposables.forEach((dispose) => dispose());
|
|
838
837
|
this.disposables.clear();
|
|
838
|
+
this.store.dispose();
|
|
839
839
|
this.isDisposed = true;
|
|
840
840
|
}
|
|
841
841
|
getShapeUtil(arg) {
|
|
@@ -1738,13 +1738,21 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1738
1738
|
setEditingShape(shape) {
|
|
1739
1739
|
const id = typeof shape === "string" ? shape : shape?.id ?? null;
|
|
1740
1740
|
this.setRichTextEditor(null);
|
|
1741
|
-
|
|
1741
|
+
const prevEditingShapeId = this.getEditingShapeId();
|
|
1742
|
+
if (id !== prevEditingShapeId) {
|
|
1742
1743
|
if (id) {
|
|
1743
1744
|
const shape2 = this.getShape(id);
|
|
1744
1745
|
if (shape2 && this.getShapeUtil(shape2).canEdit(shape2)) {
|
|
1745
1746
|
this.run(
|
|
1746
1747
|
() => {
|
|
1747
1748
|
this._updateCurrentPageState({ editingShapeId: id });
|
|
1749
|
+
if (prevEditingShapeId) {
|
|
1750
|
+
const prevEditingShape = this.getShape(prevEditingShapeId);
|
|
1751
|
+
if (prevEditingShape) {
|
|
1752
|
+
this.getShapeUtil(prevEditingShape).onEditEnd?.(prevEditingShape);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
this.getShapeUtil(shape2).onEditStart?.(shape2);
|
|
1748
1756
|
},
|
|
1749
1757
|
{ history: "ignore" }
|
|
1750
1758
|
);
|
|
@@ -1755,6 +1763,12 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
1755
1763
|
() => {
|
|
1756
1764
|
this._updateCurrentPageState({ editingShapeId: null });
|
|
1757
1765
|
this._currentRichTextEditor.set(null);
|
|
1766
|
+
if (prevEditingShapeId) {
|
|
1767
|
+
const prevEditingShape = this.getShape(prevEditingShapeId);
|
|
1768
|
+
if (prevEditingShape) {
|
|
1769
|
+
this.getShapeUtil(prevEditingShape).onEditEnd?.(prevEditingShape);
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1758
1772
|
},
|
|
1759
1773
|
{ history: "ignore" }
|
|
1760
1774
|
);
|
|
@@ -7539,12 +7553,10 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7539
7553
|
const { x: cx, y: cy, z: cz } = (0, import_state.unsafe__withoutCapture)(() => this.getCamera());
|
|
7540
7554
|
if (this.inputs.isPanning && this.inputs.isPointing) {
|
|
7541
7555
|
const { currentScreenPoint, previousScreenPoint } = this.inputs;
|
|
7542
|
-
const { panSpeed } = cameraOptions;
|
|
7543
7556
|
const offset = import_Vec.Vec.Sub(currentScreenPoint, previousScreenPoint);
|
|
7544
|
-
this.setCamera(
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
);
|
|
7557
|
+
this.setCamera(new import_Vec.Vec(cx + offset.x / cz, cy + offset.y / cz, cz), {
|
|
7558
|
+
immediate: true
|
|
7559
|
+
});
|
|
7548
7560
|
this.maybeTrackPerformance("Panning");
|
|
7549
7561
|
return;
|
|
7550
7562
|
}
|