@tldraw/editor 3.15.0-canary.ee0606e7631e → 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.
- package/dist-cjs/index.d.ts +60 -3
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js +27 -15
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js.map +3 -3
- package/dist-cjs/lib/editor/Editor.js +4 -6
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js +20 -1
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +1 -1
- package/dist-cjs/lib/license/Watermark.js +2 -2
- 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 +60 -3
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs +17 -15
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +4 -6
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs +20 -1
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +1 -1
- package/dist-esm/lib/license/Watermark.mjs +2 -2
- 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/editor.css +15 -2
- package/package.json +9 -8
- package/src/lib/components/default-components/DefaultSpinner.tsx +12 -12
- package/src/lib/editor/Editor.ts +6 -5
- package/src/lib/editor/shapes/ShapeUtil.ts +57 -0
- package/src/lib/editor/tools/StateNode.test.ts +285 -0
- package/src/lib/editor/tools/StateNode.ts +27 -1
- package/src/lib/hooks/useEditorComponents.tsx +1 -1
- package/src/lib/license/Watermark.tsx +2 -2
- package/src/version.ts +3 -3
- package/src/lib/test/currentToolIdMask.test.ts +0 -49
package/dist-cjs/index.d.ts
CHANGED
|
@@ -821,7 +821,7 @@ export declare const DefaultShapeIndicators: NamedExoticComponent<TLShapeIndicat
|
|
|
821
821
|
export declare function DefaultSnapIndicator({ className, line, zoom }: TLSnapIndicatorProps): JSX_2.Element;
|
|
822
822
|
|
|
823
823
|
/** @public @react */
|
|
824
|
-
export declare function DefaultSpinner(): JSX_2.Element;
|
|
824
|
+
export declare function DefaultSpinner(props: React.SVGProps<SVGSVGElement>): JSX_2.Element;
|
|
825
825
|
|
|
826
826
|
/** @public @react */
|
|
827
827
|
export declare const DefaultSvgDefs: () => null;
|
|
@@ -1591,7 +1591,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1591
1591
|
*
|
|
1592
1592
|
* @public
|
|
1593
1593
|
*/
|
|
1594
|
-
getNearestAdjacentShape(currentShapeId: TLShapeId, direction: 'down' | 'left' | 'right' | 'up'): TLShapeId;
|
|
1594
|
+
getNearestAdjacentShape(shapes: TLShape[], currentShapeId: TLShapeId, direction: 'down' | 'left' | 'right' | 'up'): TLShapeId;
|
|
1595
1595
|
selectParentShape(): void;
|
|
1596
1596
|
selectFirstChildShape(): void;
|
|
1597
1597
|
private _selectShapesAndZoom;
|
|
@@ -5418,6 +5418,14 @@ export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknown
|
|
|
5418
5418
|
* @public
|
|
5419
5419
|
*/
|
|
5420
5420
|
onResizeEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | void;
|
|
5421
|
+
/**
|
|
5422
|
+
* A callback called when a shape resize is cancelled.
|
|
5423
|
+
*
|
|
5424
|
+
* @param initial - The shape at the start of the resize.
|
|
5425
|
+
* @param current - The current shape.
|
|
5426
|
+
* @public
|
|
5427
|
+
*/
|
|
5428
|
+
onResizeCancel?(initial: Shape, current: Shape): void;
|
|
5421
5429
|
/**
|
|
5422
5430
|
* A callback called when a shape starts being translated.
|
|
5423
5431
|
*
|
|
@@ -5444,6 +5452,23 @@ export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknown
|
|
|
5444
5452
|
* @public
|
|
5445
5453
|
*/
|
|
5446
5454
|
onTranslateEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | void;
|
|
5455
|
+
/**
|
|
5456
|
+
* A callback called when a shape translation is cancelled.
|
|
5457
|
+
*
|
|
5458
|
+
* @param initial - The shape at the start of the translation.
|
|
5459
|
+
* @param current - The current shape.
|
|
5460
|
+
* @public
|
|
5461
|
+
*/
|
|
5462
|
+
onTranslateCancel?(initial: Shape, current: Shape): void;
|
|
5463
|
+
/**
|
|
5464
|
+
* A callback called when a shape's handle starts being dragged.
|
|
5465
|
+
*
|
|
5466
|
+
* @param shape - The shape.
|
|
5467
|
+
* @param info - An object containing the handle and whether the handle is 'precise' or not.
|
|
5468
|
+
* @returns A change to apply to the shape, or void.
|
|
5469
|
+
* @public
|
|
5470
|
+
*/
|
|
5471
|
+
onHandleDragStart?(shape: Shape, info: TLHandleDragInfo<Shape>): TLShapePartial<Shape> | void;
|
|
5447
5472
|
/**
|
|
5448
5473
|
* A callback called when a shape's handle changes.
|
|
5449
5474
|
*
|
|
@@ -5453,6 +5478,23 @@ export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknown
|
|
|
5453
5478
|
* @public
|
|
5454
5479
|
*/
|
|
5455
5480
|
onHandleDrag?(shape: Shape, info: TLHandleDragInfo<Shape>): TLShapePartial<Shape> | void;
|
|
5481
|
+
/**
|
|
5482
|
+
* A callback called when a shape's handle finishes being dragged.
|
|
5483
|
+
*
|
|
5484
|
+
* @param current - The current shape.
|
|
5485
|
+
* @param info - An object containing the handle and whether the handle is 'precise' or not.
|
|
5486
|
+
* @returns A change to apply to the shape, or void.
|
|
5487
|
+
* @public
|
|
5488
|
+
*/
|
|
5489
|
+
onHandleDragEnd?(current: Shape, info: TLHandleDragInfo<Shape>): TLShapePartial<Shape> | void;
|
|
5490
|
+
/**
|
|
5491
|
+
* A callback called when a shape's handle drag is cancelled.
|
|
5492
|
+
*
|
|
5493
|
+
* @param current - The current shape.
|
|
5494
|
+
* @param info - An object containing the handle and whether the handle is 'precise' or not.
|
|
5495
|
+
* @public
|
|
5496
|
+
*/
|
|
5497
|
+
onHandleDragCancel?(current: Shape, info: TLHandleDragInfo<Shape>): void;
|
|
5456
5498
|
/**
|
|
5457
5499
|
* A callback called when a shape starts being rotated.
|
|
5458
5500
|
*
|
|
@@ -5479,6 +5521,14 @@ export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknown
|
|
|
5479
5521
|
* @public
|
|
5480
5522
|
*/
|
|
5481
5523
|
onRotateEnd?(initial: Shape, current: Shape): TLShapePartial<Shape> | void;
|
|
5524
|
+
/**
|
|
5525
|
+
* A callback called when a shape rotation is cancelled.
|
|
5526
|
+
*
|
|
5527
|
+
* @param initial - The shape at the start of the rotation.
|
|
5528
|
+
* @param current - The current shape.
|
|
5529
|
+
* @public
|
|
5530
|
+
*/
|
|
5531
|
+
onRotateCancel?(initial: Shape, current: Shape): void;
|
|
5482
5532
|
/* Excluded from this release type: onBindingChange */
|
|
5483
5533
|
/**
|
|
5484
5534
|
* A callback called when a shape's children change.
|
|
@@ -5707,6 +5757,12 @@ export declare abstract class StateNode implements Partial<TLEventHandlers> {
|
|
|
5707
5757
|
_currentToolIdMask: Atom<string | undefined, unknown>;
|
|
5708
5758
|
getCurrentToolIdMask(): string | undefined;
|
|
5709
5759
|
setCurrentToolIdMask(id: string | undefined): void;
|
|
5760
|
+
/**
|
|
5761
|
+
* Add a child node to this state node.
|
|
5762
|
+
*
|
|
5763
|
+
* @public
|
|
5764
|
+
*/
|
|
5765
|
+
addChild(childConstructor: TLStateNodeConstructor): this;
|
|
5710
5766
|
onWheel?(info: TLWheelEventInfo): void;
|
|
5711
5767
|
onPointerDown?(info: TLPointerEventInfo): void;
|
|
5712
5768
|
onPointerMove?(info: TLPointerEventInfo): void;
|
|
@@ -6424,7 +6480,7 @@ export declare interface TLEditorComponents {
|
|
|
6424
6480
|
ShapeIndicator?: ComponentType<TLShapeIndicatorProps> | null;
|
|
6425
6481
|
ShapeIndicators?: ComponentType | null;
|
|
6426
6482
|
SnapIndicator?: ComponentType<TLSnapIndicatorProps> | null;
|
|
6427
|
-
Spinner?: ComponentType | null;
|
|
6483
|
+
Spinner?: ComponentType<React.SVGProps<SVGSVGElement>> | null;
|
|
6428
6484
|
SvgDefs?: ComponentType | null;
|
|
6429
6485
|
ZoomBrush?: ComponentType<TLBrushProps> | null;
|
|
6430
6486
|
ErrorFallback?: TLErrorFallbackComponent;
|
|
@@ -6770,6 +6826,7 @@ export declare interface TLGridProps {
|
|
|
6770
6826
|
export declare interface TLHandleDragInfo<T extends TLShape> {
|
|
6771
6827
|
handle: TLHandle;
|
|
6772
6828
|
isPrecise: boolean;
|
|
6829
|
+
isCreatingShape: boolean;
|
|
6773
6830
|
initial?: T | undefined;
|
|
6774
6831
|
}
|
|
6775
6832
|
|
package/dist-cjs/index.js
CHANGED
|
@@ -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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
5
|
-
"mappings": "
|
|
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
|
|
1483
|
-
|
|
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
|
);
|