@tldraw/editor 4.2.0-canary.5887eb336025 → 4.2.0-canary.7329b1541236

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.
Files changed (43) hide show
  1. package/dist-cjs/index.d.ts +54 -6
  2. package/dist-cjs/index.js +2 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/editor/Editor.js +27 -0
  5. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  6. package/dist-cjs/lib/license/LicenseManager.js +1 -0
  7. package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
  8. package/dist-cjs/lib/license/Watermark.js +1 -1
  9. package/dist-cjs/lib/license/Watermark.js.map +2 -2
  10. package/dist-cjs/lib/utils/debug-flags.js +1 -0
  11. package/dist-cjs/lib/utils/debug-flags.js.map +2 -2
  12. package/dist-cjs/lib/utils/runtime.js +2 -2
  13. package/dist-cjs/lib/utils/runtime.js.map +2 -2
  14. package/dist-cjs/lib/utils/window-open.js +2 -2
  15. package/dist-cjs/lib/utils/window-open.js.map +2 -2
  16. package/dist-cjs/version.js +3 -3
  17. package/dist-cjs/version.js.map +1 -1
  18. package/dist-esm/index.d.mts +54 -6
  19. package/dist-esm/index.mjs +3 -1
  20. package/dist-esm/index.mjs.map +2 -2
  21. package/dist-esm/lib/editor/Editor.mjs +27 -0
  22. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  23. package/dist-esm/lib/license/LicenseManager.mjs +1 -0
  24. package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
  25. package/dist-esm/lib/license/Watermark.mjs +1 -1
  26. package/dist-esm/lib/license/Watermark.mjs.map +2 -2
  27. package/dist-esm/lib/utils/debug-flags.mjs +1 -0
  28. package/dist-esm/lib/utils/debug-flags.mjs.map +2 -2
  29. package/dist-esm/lib/utils/runtime.mjs +2 -2
  30. package/dist-esm/lib/utils/runtime.mjs.map +2 -2
  31. package/dist-esm/lib/utils/window-open.mjs +2 -2
  32. package/dist-esm/lib/utils/window-open.mjs.map +2 -2
  33. package/dist-esm/version.mjs +3 -3
  34. package/dist-esm/version.mjs.map +1 -1
  35. package/package.json +7 -7
  36. package/src/index.ts +1 -0
  37. package/src/lib/editor/Editor.ts +29 -0
  38. package/src/lib/license/LicenseManager.ts +1 -0
  39. package/src/lib/license/Watermark.tsx +1 -1
  40. package/src/lib/utils/debug-flags.ts +5 -4
  41. package/src/lib/utils/runtime.ts +3 -3
  42. package/src/lib/utils/window-open.ts +13 -3
  43. package/src/version.ts +3 -3
@@ -854,6 +854,33 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
854
854
  typeof shapeOrId === "string" ? shapeOrId : shapeOrId.id
855
855
  );
856
856
  }
857
+ /**
858
+ * Set a tool. Useful if you need to add a tool to the state chart on demand,
859
+ * after the editor has already been initialized.
860
+ *
861
+ * @param Tool - The tool to set.
862
+ *
863
+ * @public
864
+ */
865
+ setTool(Tool) {
866
+ if (hasOwnProperty(this.root.children, Tool.id)) {
867
+ throw Error(`Can't override tool with id "${Tool.id}"`);
868
+ }
869
+ this.root.children[Tool.id] = new Tool(this, this.root);
870
+ }
871
+ /**
872
+ * Remove a tool. Useful if you need to remove a tool from the state chart on demand,
873
+ * after the editor has already been initialized.
874
+ *
875
+ * @param Tool - The tool to delete.
876
+ *
877
+ * @public
878
+ */
879
+ removeTool(Tool) {
880
+ if (hasOwnProperty(this.root.children, Tool.id)) {
881
+ delete this.root.children[Tool.id];
882
+ }
883
+ }
857
884
  /**
858
885
  * Dispose the editor.
859
886
  *