@tldraw/editor 4.2.0-next.f100cedfc45b → 4.3.0-canary.d8da2a99f394
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 +4 -2
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +10 -6
- package/dist-cjs/lib/editor/Editor.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/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +4 -2
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +10 -6
- package/dist-esm/lib/editor/Editor.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/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/lib/editor/Editor.test.ts +268 -0
- package/src/lib/editor/Editor.ts +10 -6
- package/src/lib/hooks/useCanvasEvents.ts +4 -3
- package/src/lib/license/Watermark.tsx +8 -5
- package/src/version.ts +3 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -1023,19 +1023,21 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1023
1023
|
* after the editor has already been initialized.
|
|
1024
1024
|
*
|
|
1025
1025
|
* @param Tool - The tool to set.
|
|
1026
|
+
* @param parent - The parent state node to set the tool on.
|
|
1026
1027
|
*
|
|
1027
1028
|
* @public
|
|
1028
1029
|
*/
|
|
1029
|
-
setTool(Tool: TLStateNodeConstructor): void;
|
|
1030
|
+
setTool(Tool: TLStateNodeConstructor, parent?: StateNode): void;
|
|
1030
1031
|
/**
|
|
1031
1032
|
* Remove a tool. Useful if you need to remove a tool from the state chart on demand,
|
|
1032
1033
|
* after the editor has already been initialized.
|
|
1033
1034
|
*
|
|
1034
1035
|
* @param Tool - The tool to delete.
|
|
1036
|
+
* @param parent - The parent state node to remove the tool from.
|
|
1035
1037
|
*
|
|
1036
1038
|
* @public
|
|
1037
1039
|
*/
|
|
1038
|
-
removeTool(Tool: TLStateNodeConstructor): void;
|
|
1040
|
+
removeTool(Tool: TLStateNodeConstructor, parent?: StateNode): void;
|
|
1039
1041
|
/**
|
|
1040
1042
|
* A set of functions to call when the app is disposed.
|
|
1041
1043
|
*
|
package/dist-cjs/index.js
CHANGED
|
@@ -370,7 +370,7 @@ var import_uniq = require("./lib/utils/uniq");
|
|
|
370
370
|
var import_window_open = require("./lib/utils/window-open");
|
|
371
371
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
372
372
|
"@tldraw/editor",
|
|
373
|
-
"4.
|
|
373
|
+
"4.3.0-canary.d8da2a99f394",
|
|
374
374
|
"cjs"
|
|
375
375
|
);
|
|
376
376
|
//# sourceMappingURL=index.js.map
|
|
@@ -824,26 +824,30 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
824
824
|
* after the editor has already been initialized.
|
|
825
825
|
*
|
|
826
826
|
* @param Tool - The tool to set.
|
|
827
|
+
* @param parent - The parent state node to set the tool on.
|
|
827
828
|
*
|
|
828
829
|
* @public
|
|
829
830
|
*/
|
|
830
|
-
setTool(Tool) {
|
|
831
|
-
|
|
831
|
+
setTool(Tool, parent) {
|
|
832
|
+
parent ??= this.root;
|
|
833
|
+
if ((0, import_utils.hasOwnProperty)(parent.children, Tool.id)) {
|
|
832
834
|
throw Error(`Can't override tool with id "${Tool.id}"`);
|
|
833
835
|
}
|
|
834
|
-
|
|
836
|
+
parent.children[Tool.id] = new Tool(this, parent);
|
|
835
837
|
}
|
|
836
838
|
/**
|
|
837
839
|
* Remove a tool. Useful if you need to remove a tool from the state chart on demand,
|
|
838
840
|
* after the editor has already been initialized.
|
|
839
841
|
*
|
|
840
842
|
* @param Tool - The tool to delete.
|
|
843
|
+
* @param parent - The parent state node to remove the tool from.
|
|
841
844
|
*
|
|
842
845
|
* @public
|
|
843
846
|
*/
|
|
844
|
-
removeTool(Tool) {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
+
removeTool(Tool, parent) {
|
|
848
|
+
parent ??= this.root;
|
|
849
|
+
if ((0, import_utils.hasOwnProperty)(parent.children, Tool.id)) {
|
|
850
|
+
delete parent.children[Tool.id];
|
|
847
851
|
}
|
|
848
852
|
}
|
|
849
853
|
/**
|