@tldraw/editor 4.2.0-next.f100cedfc45b → 4.3.0-canary.03ae87dcc44b
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 +59 -37
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +11 -18
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/bindings/BindingUtil.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/BaseBoxShapeUtil.js.map +1 -1
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +4 -3
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/license/Watermark.js +8 -4
- package/dist-cjs/lib/license/Watermark.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.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 +59 -37
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +11 -18
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/bindings/BindingUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/BaseBoxShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +4 -3
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/license/Watermark.mjs +8 -4
- package/dist-esm/lib/license/Watermark.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +10 -10
- package/src/lib/editor/Editor.test.ts +278 -10
- package/src/lib/editor/Editor.ts +92 -65
- package/src/lib/editor/bindings/BindingUtil.ts +15 -9
- package/src/lib/editor/derivations/bindingsIndex.ts +2 -2
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +14 -4
- package/src/lib/editor/managers/SnapManager/SnapManager.ts +3 -3
- package/src/lib/editor/shapes/BaseBoxShapeUtil.tsx +2 -2
- package/src/lib/editor/shapes/ShapeUtil.ts +5 -8
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +1 -3
- package/src/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.ts +2 -1
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +3 -3
- package/src/lib/exports/getSvgJsx.test.ts +10 -19
- package/src/lib/exports/getSvgJsx.tsx +2 -5
- package/src/lib/hooks/useCanvasEvents.ts +4 -3
- package/src/lib/license/Watermark.tsx +8 -5
- package/src/lib/utils/reparenting.ts +5 -5
- package/src/version.ts +3 -3
|
@@ -859,26 +859,30 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
859
859
|
* after the editor has already been initialized.
|
|
860
860
|
*
|
|
861
861
|
* @param Tool - The tool to set.
|
|
862
|
+
* @param parent - The parent state node to set the tool on.
|
|
862
863
|
*
|
|
863
864
|
* @public
|
|
864
865
|
*/
|
|
865
|
-
setTool(Tool) {
|
|
866
|
-
|
|
866
|
+
setTool(Tool, parent) {
|
|
867
|
+
parent ??= this.root;
|
|
868
|
+
if (hasOwnProperty(parent.children, Tool.id)) {
|
|
867
869
|
throw Error(`Can't override tool with id "${Tool.id}"`);
|
|
868
870
|
}
|
|
869
|
-
|
|
871
|
+
parent.children[Tool.id] = new Tool(this, parent);
|
|
870
872
|
}
|
|
871
873
|
/**
|
|
872
874
|
* Remove a tool. Useful if you need to remove a tool from the state chart on demand,
|
|
873
875
|
* after the editor has already been initialized.
|
|
874
876
|
*
|
|
875
877
|
* @param Tool - The tool to delete.
|
|
878
|
+
* @param parent - The parent state node to remove the tool from.
|
|
876
879
|
*
|
|
877
880
|
* @public
|
|
878
881
|
*/
|
|
879
|
-
removeTool(Tool) {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
+
removeTool(Tool, parent) {
|
|
883
|
+
parent ??= this.root;
|
|
884
|
+
if (hasOwnProperty(parent.children, Tool.id)) {
|
|
885
|
+
delete parent.children[Tool.id];
|
|
882
886
|
}
|
|
883
887
|
}
|
|
884
888
|
/**
|
|
@@ -4431,30 +4435,18 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
4431
4435
|
getBinding(id) {
|
|
4432
4436
|
return this.store.get(id);
|
|
4433
4437
|
}
|
|
4434
|
-
/**
|
|
4435
|
-
* Get all bindings of a certain type _from_ a particular shape. These are the bindings whose
|
|
4436
|
-
* `fromId` matched the shape's ID.
|
|
4437
|
-
*/
|
|
4438
4438
|
getBindingsFromShape(shape, type) {
|
|
4439
4439
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4440
4440
|
return this.getBindingsInvolvingShape(id).filter(
|
|
4441
4441
|
(b) => b.fromId === id && b.type === type
|
|
4442
4442
|
);
|
|
4443
4443
|
}
|
|
4444
|
-
/**
|
|
4445
|
-
* Get all bindings of a certain type _to_ a particular shape. These are the bindings whose
|
|
4446
|
-
* `toId` matches the shape's ID.
|
|
4447
|
-
*/
|
|
4448
4444
|
getBindingsToShape(shape, type) {
|
|
4449
4445
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4450
4446
|
return this.getBindingsInvolvingShape(id).filter(
|
|
4451
4447
|
(b) => b.toId === id && b.type === type
|
|
4452
4448
|
);
|
|
4453
4449
|
}
|
|
4454
|
-
/**
|
|
4455
|
-
* Get all bindings involving a particular shape. This includes bindings where the shape is the
|
|
4456
|
-
* `fromId` or `toId`. If a type is provided, only bindings of that type are returned.
|
|
4457
|
-
*/
|
|
4458
4450
|
getBindingsInvolvingShape(shape, type) {
|
|
4459
4451
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4460
4452
|
const result = this._getBindingsIndexCache().get(id) ?? EMPTY_ARRAY;
|
|
@@ -7512,6 +7504,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
7512
7504
|
this.setCursor({ type: this._prevCursor, rotation: 0 });
|
|
7513
7505
|
}
|
|
7514
7506
|
}
|
|
7507
|
+
this.emit("event", info);
|
|
7515
7508
|
this.root.handleEvent(info);
|
|
7516
7509
|
return;
|
|
7517
7510
|
}
|