@tldraw/editor 3.15.0-canary.e3f6387b7e04 → 3.15.0-canary.f6f94b895c02

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 (84) hide show
  1. package/dist-cjs/index.d.ts +60 -3
  2. package/dist-cjs/index.js +1 -1
  3. package/dist-cjs/lib/components/SVGContainer.js +1 -1
  4. package/dist-cjs/lib/components/SVGContainer.js.map +2 -2
  5. package/dist-cjs/lib/components/default-components/DefaultBrush.js +1 -1
  6. package/dist-cjs/lib/components/default-components/DefaultBrush.js.map +2 -2
  7. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +1 -1
  8. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
  9. package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +1 -1
  10. package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +2 -2
  11. package/dist-cjs/lib/components/default-components/DefaultCursor.js +1 -1
  12. package/dist-cjs/lib/components/default-components/DefaultCursor.js.map +2 -2
  13. package/dist-cjs/lib/components/default-components/DefaultGrid.js +1 -1
  14. package/dist-cjs/lib/components/default-components/DefaultGrid.js.map +2 -2
  15. package/dist-cjs/lib/components/default-components/DefaultHandles.js +1 -1
  16. package/dist-cjs/lib/components/default-components/DefaultHandles.js.map +2 -2
  17. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +1 -1
  18. package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
  19. package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js +1 -1
  20. package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js.map +2 -2
  21. package/dist-cjs/lib/components/default-components/DefaultSpinner.js +27 -15
  22. package/dist-cjs/lib/components/default-components/DefaultSpinner.js.map +3 -3
  23. package/dist-cjs/lib/editor/Editor.js +4 -6
  24. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  25. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  26. package/dist-cjs/lib/editor/tools/StateNode.js +20 -1
  27. package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
  28. package/dist-cjs/lib/hooks/useEditorComponents.js.map +1 -1
  29. package/dist-cjs/lib/license/Watermark.js +2 -2
  30. package/dist-cjs/lib/license/Watermark.js.map +2 -2
  31. package/dist-cjs/version.js +3 -3
  32. package/dist-cjs/version.js.map +1 -1
  33. package/dist-esm/index.d.mts +60 -3
  34. package/dist-esm/index.mjs +1 -1
  35. package/dist-esm/lib/components/SVGContainer.mjs +1 -1
  36. package/dist-esm/lib/components/SVGContainer.mjs.map +2 -2
  37. package/dist-esm/lib/components/default-components/DefaultBrush.mjs +1 -1
  38. package/dist-esm/lib/components/default-components/DefaultBrush.mjs.map +2 -2
  39. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -1
  40. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  41. package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +1 -1
  42. package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +2 -2
  43. package/dist-esm/lib/components/default-components/DefaultCursor.mjs +1 -1
  44. package/dist-esm/lib/components/default-components/DefaultCursor.mjs.map +2 -2
  45. package/dist-esm/lib/components/default-components/DefaultGrid.mjs +1 -1
  46. package/dist-esm/lib/components/default-components/DefaultGrid.mjs.map +2 -2
  47. package/dist-esm/lib/components/default-components/DefaultHandles.mjs +1 -1
  48. package/dist-esm/lib/components/default-components/DefaultHandles.mjs.map +2 -2
  49. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +1 -1
  50. package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
  51. package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs +1 -1
  52. package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs.map +2 -2
  53. package/dist-esm/lib/components/default-components/DefaultSpinner.mjs +17 -15
  54. package/dist-esm/lib/components/default-components/DefaultSpinner.mjs.map +2 -2
  55. package/dist-esm/lib/editor/Editor.mjs +4 -6
  56. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  57. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  58. package/dist-esm/lib/editor/tools/StateNode.mjs +20 -1
  59. package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
  60. package/dist-esm/lib/hooks/useEditorComponents.mjs.map +1 -1
  61. package/dist-esm/lib/license/Watermark.mjs +2 -2
  62. package/dist-esm/lib/license/Watermark.mjs.map +2 -2
  63. package/dist-esm/version.mjs +3 -3
  64. package/dist-esm/version.mjs.map +1 -1
  65. package/editor.css +17 -4
  66. package/package.json +9 -8
  67. package/src/lib/components/SVGContainer.tsx +1 -1
  68. package/src/lib/components/default-components/DefaultBrush.tsx +1 -1
  69. package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
  70. package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +1 -1
  71. package/src/lib/components/default-components/DefaultCursor.tsx +1 -1
  72. package/src/lib/components/default-components/DefaultGrid.tsx +1 -1
  73. package/src/lib/components/default-components/DefaultHandles.tsx +5 -1
  74. package/src/lib/components/default-components/DefaultShapeIndicator.tsx +1 -1
  75. package/src/lib/components/default-components/DefaultSnapIndictor.tsx +1 -1
  76. package/src/lib/components/default-components/DefaultSpinner.tsx +12 -12
  77. package/src/lib/editor/Editor.ts +6 -5
  78. package/src/lib/editor/shapes/ShapeUtil.ts +57 -0
  79. package/src/lib/editor/tools/StateNode.test.ts +285 -0
  80. package/src/lib/editor/tools/StateNode.ts +27 -1
  81. package/src/lib/hooks/useEditorComponents.tsx +1 -1
  82. package/src/lib/license/Watermark.tsx +2 -2
  83. package/src/version.ts +3 -3
  84. package/src/lib/test/currentToolIdMask.test.ts +0 -49
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var DefaultSpinner_exports = {};
20
30
  __export(DefaultSpinner_exports, {
@@ -22,20 +32,22 @@ __export(DefaultSpinner_exports, {
22
32
  });
23
33
  module.exports = __toCommonJS(DefaultSpinner_exports);
24
34
  var import_jsx_runtime = require("react/jsx-runtime");
25
- function DefaultSpinner() {
26
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: 16, height: 16, viewBox: "0 0 16 16", "aria-hidden": "false", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { strokeWidth: 2, fill: "none", fillRule: "evenodd", children: [
27
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { strokeOpacity: 0.25, cx: 8, cy: 8, r: 7, stroke: "currentColor" }),
28
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", d: "M15 8c0-4.5-4.5-7-7-7", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
29
- "animateTransform",
30
- {
31
- attributeName: "transform",
32
- type: "rotate",
33
- from: "0 8 8",
34
- to: "360 8 8",
35
- dur: "1s",
36
- repeatCount: "indefinite"
37
- }
38
- ) })
39
- ] }) });
35
+ var import_classnames = __toESM(require("classnames"));
36
+ function DefaultSpinner(props) {
37
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
38
+ "svg",
39
+ {
40
+ width: 16,
41
+ height: 16,
42
+ viewBox: "0 0 16 16",
43
+ "aria-hidden": "false",
44
+ ...props,
45
+ className: (0, import_classnames.default)("tl-spinner", props.className),
46
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { strokeWidth: 2, fill: "none", fillRule: "evenodd", children: [
47
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { strokeOpacity: 0.25, cx: 8, cy: 8, r: 7, stroke: "currentColor" }),
48
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", d: "M15 8c0-4.5-4.5-7-7-7", stroke: "currentColor" })
49
+ ] })
50
+ }
51
+ );
40
52
  }
41
53
  //# sourceMappingURL=DefaultSpinner.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/components/default-components/DefaultSpinner.tsx"],
4
- "sourcesContent": ["/** @public @react */\nexport function DefaultSpinner() {\n\treturn (\n\t\t<svg width={16} height={16} viewBox=\"0 0 16 16\" aria-hidden=\"false\">\n\t\t\t<g strokeWidth={2} fill=\"none\" fillRule=\"evenodd\">\n\t\t\t\t<circle strokeOpacity={0.25} cx={8} cy={8} r={7} stroke=\"currentColor\" />\n\t\t\t\t<path strokeLinecap=\"round\" d=\"M15 8c0-4.5-4.5-7-7-7\" stroke=\"currentColor\">\n\t\t\t\t\t<animateTransform\n\t\t\t\t\t\tattributeName=\"transform\"\n\t\t\t\t\t\ttype=\"rotate\"\n\t\t\t\t\t\tfrom=\"0 8 8\"\n\t\t\t\t\t\tto=\"360 8 8\"\n\t\t\t\t\t\tdur=\"1s\"\n\t\t\t\t\t\trepeatCount=\"indefinite\"\n\t\t\t\t\t/>\n\t\t\t\t</path>\n\t\t\t</g>\n\t\t</svg>\n\t)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIG;AAHI,SAAS,iBAAiB;AAChC,SACC,4CAAC,SAAI,OAAO,IAAI,QAAQ,IAAI,SAAQ,aAAY,eAAY,SAC3D,uDAAC,OAAE,aAAa,GAAG,MAAK,QAAO,UAAS,WACvC;AAAA,gDAAC,YAAO,eAAe,MAAM,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,QAAO,gBAAe;AAAA,IACvE,4CAAC,UAAK,eAAc,SAAQ,GAAE,yBAAwB,QAAO,gBAC5D;AAAA,MAAC;AAAA;AAAA,QACA,eAAc;AAAA,QACd,MAAK;AAAA,QACL,MAAK;AAAA,QACL,IAAG;AAAA,QACH,KAAI;AAAA,QACJ,aAAY;AAAA;AAAA,IACb,GACD;AAAA,KACD,GACD;AAEF;",
6
- "names": []
4
+ "sourcesContent": ["import classNames from 'classnames'\n\n/** @public @react */\nexport function DefaultSpinner(props: React.SVGProps<SVGSVGElement>) {\n\treturn (\n\t\t<svg\n\t\t\twidth={16}\n\t\t\theight={16}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\taria-hidden=\"false\"\n\t\t\t{...props}\n\t\t\tclassName={classNames('tl-spinner', props.className)}\n\t\t>\n\t\t\t<g strokeWidth={2} fill=\"none\" fillRule=\"evenodd\">\n\t\t\t\t<circle strokeOpacity={0.25} cx={8} cy={8} r={7} stroke=\"currentColor\" />\n\t\t\t\t<path strokeLinecap=\"round\" d=\"M15 8c0-4.5-4.5-7-7-7\" stroke=\"currentColor\" />\n\t\t\t</g>\n\t\t</svg>\n\t)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaG;AAbH,wBAAuB;AAGhB,SAAS,eAAe,OAAsC;AACpE,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,SAAQ;AAAA,MACR,eAAY;AAAA,MACX,GAAG;AAAA,MACJ,eAAW,kBAAAA,SAAW,cAAc,MAAM,SAAS;AAAA,MAEnD,uDAAC,OAAE,aAAa,GAAG,MAAK,QAAO,UAAS,WACvC;AAAA,oDAAC,YAAO,eAAe,MAAM,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,QAAO,gBAAe;AAAA,QACvE,4CAAC,UAAK,eAAc,SAAQ,GAAE,yBAAwB,QAAO,gBAAe;AAAA,SAC7E;AAAA;AAAA,EACD;AAEF;",
6
+ "names": ["classNames"]
7
7
  }
@@ -1479,9 +1479,8 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
1479
1479
  const selectedShapeIds = this.getSelectedShapeIds();
1480
1480
  const firstParentId = selectedShapeIds[0] ? this.getShape(selectedShapeIds[0])?.parentId : null;
1481
1481
  const isSelectedWithinContainer = firstParentId && selectedShapeIds.every((shapeId) => this.getShape(shapeId)?.parentId === firstParentId) && !(0, import_tlschema.isPageId)(firstParentId);
1482
- const readingOrderShapes = isSelectedWithinContainer ? this._getShapesInReadingOrder(
1483
- this.getCurrentPageShapes().filter((shape2) => shape2.parentId === firstParentId)
1484
- ) : this.getCurrentPageShapesInReadingOrder();
1482
+ const filteredShapes = isSelectedWithinContainer ? this.getCurrentPageShapes().filter((shape2) => shape2.parentId === firstParentId) : this.getCurrentPageShapes().filter((shape2) => (0, import_tlschema.isPageId)(shape2.parentId));
1483
+ const readingOrderShapes = isSelectedWithinContainer ? this._getShapesInReadingOrder(filteredShapes) : this.getCurrentPageShapesInReadingOrder();
1485
1484
  const currentShapeId = selectedShapeIds.length === 1 ? selectedShapeIds[0] : readingOrderShapes.find((shape2) => selectedShapeIds.includes(shape2.id))?.id;
1486
1485
  let adjacentShapeId;
1487
1486
  if (direction === "next" || direction === "prev") {
@@ -1491,7 +1490,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
1491
1490
  adjacentShapeId = shapeIds[adjacentIndex];
1492
1491
  } else {
1493
1492
  if (!currentShapeId) return;
1494
- adjacentShapeId = this.getNearestAdjacentShape(currentShapeId, direction);
1493
+ adjacentShapeId = this.getNearestAdjacentShape(filteredShapes, currentShapeId, direction);
1495
1494
  }
1496
1495
  const shape = this.getShape(adjacentShapeId);
1497
1496
  if (!shape) return;
@@ -1557,11 +1556,10 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
1557
1556
  *
1558
1557
  * @public
1559
1558
  */
1560
- getNearestAdjacentShape(currentShapeId, direction) {
1559
+ getNearestAdjacentShape(shapes, currentShapeId, direction) {
1561
1560
  const directionToAngle = { right: 0, left: 180, down: 90, up: 270 };
1562
1561
  const currentShape = this.getShape(currentShapeId);
1563
1562
  if (!currentShape) return currentShapeId;
1564
- const shapes = this.getCurrentPageShapes();
1565
1563
  const tabbableShapes = shapes.filter(
1566
1564
  (shape) => this.getShapeUtil(shape).canTabTo(shape) && shape.id !== currentShapeId
1567
1565
  );