@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
package/dist-cjs/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { Editor as Editor_2 } from '@tiptap/core';
|
|
|
7
7
|
import { EditorProviderProps as EditorProviderProps_2 } from '@tiptap/react';
|
|
8
8
|
import EventEmitter from 'eventemitter3';
|
|
9
9
|
import { ExoticComponent } from 'react';
|
|
10
|
+
import { ExtractShapeByProps } from '@tldraw/tlschema';
|
|
10
11
|
import { ForwardRefExoticComponent } from 'react';
|
|
11
12
|
import { HistoryEntry } from '@tldraw/store';
|
|
12
13
|
import { IndexKey } from '@tldraw/utils';
|
|
@@ -48,6 +49,7 @@ import { TLBindingId } from '@tldraw/tlschema';
|
|
|
48
49
|
import { TLBindingUpdate } from '@tldraw/tlschema';
|
|
49
50
|
import { TLBookmarkAsset } from '@tldraw/tlschema';
|
|
50
51
|
import { TLCamera } from '@tldraw/tlschema';
|
|
52
|
+
import { TLCreateShapePartial } from '@tldraw/tlschema';
|
|
51
53
|
import { TLCursor } from '@tldraw/tlschema';
|
|
52
54
|
import { TLCursorType } from '@tldraw/tlschema';
|
|
53
55
|
import { TLDefaultDashStyle } from '@tldraw/tlschema';
|
|
@@ -147,7 +149,7 @@ export declare abstract class BaseBoxShapeTool extends StateNode {
|
|
|
147
149
|
static id: string;
|
|
148
150
|
static initial: string;
|
|
149
151
|
static children(): TLStateNodeConstructor[];
|
|
150
|
-
abstract shapeType:
|
|
152
|
+
abstract shapeType: TLBaseBoxShape['type'];
|
|
151
153
|
onCreate?(_shape: null | TLShape): null | void;
|
|
152
154
|
}
|
|
153
155
|
|
|
@@ -165,7 +167,7 @@ export declare abstract class BaseBoxShapeUtil<Shape extends TLBaseBoxShape> ext
|
|
|
165
167
|
*
|
|
166
168
|
* @public
|
|
167
169
|
*/
|
|
168
|
-
export declare interface BindingOnChangeOptions<Binding extends
|
|
170
|
+
export declare interface BindingOnChangeOptions<Binding extends TLBinding = TLBinding> {
|
|
169
171
|
/** The binding record before the change is made. */
|
|
170
172
|
bindingBefore: Binding;
|
|
171
173
|
/** The binding record after the change is made. */
|
|
@@ -178,7 +180,7 @@ export declare interface BindingOnChangeOptions<Binding extends TLUnknownBinding
|
|
|
178
180
|
*
|
|
179
181
|
* @public
|
|
180
182
|
*/
|
|
181
|
-
export declare interface BindingOnCreateOptions<Binding extends
|
|
183
|
+
export declare interface BindingOnCreateOptions<Binding extends TLBinding = TLBinding> {
|
|
182
184
|
/** The binding being created. */
|
|
183
185
|
binding: Binding;
|
|
184
186
|
}
|
|
@@ -189,7 +191,7 @@ export declare interface BindingOnCreateOptions<Binding extends TLUnknownBinding
|
|
|
189
191
|
*
|
|
190
192
|
* @public
|
|
191
193
|
*/
|
|
192
|
-
export declare interface BindingOnDeleteOptions<Binding extends
|
|
194
|
+
export declare interface BindingOnDeleteOptions<Binding extends TLBinding = TLBinding> {
|
|
193
195
|
/** The binding being deleted. */
|
|
194
196
|
binding: Binding;
|
|
195
197
|
}
|
|
@@ -200,7 +202,7 @@ export declare interface BindingOnDeleteOptions<Binding extends TLUnknownBinding
|
|
|
200
202
|
*
|
|
201
203
|
* @public
|
|
202
204
|
*/
|
|
203
|
-
export declare interface BindingOnShapeChangeOptions<Binding extends
|
|
205
|
+
export declare interface BindingOnShapeChangeOptions<Binding extends TLBinding = TLBinding> {
|
|
204
206
|
/** The binding record linking these two shapes. */
|
|
205
207
|
binding: Binding;
|
|
206
208
|
/** The shape record before the change is made. */
|
|
@@ -224,7 +226,7 @@ export declare interface BindingOnShapeChangeOptions<Binding extends TLUnknownBi
|
|
|
224
226
|
*
|
|
225
227
|
* @public
|
|
226
228
|
*/
|
|
227
|
-
export declare interface BindingOnShapeDeleteOptions<Binding extends
|
|
229
|
+
export declare interface BindingOnShapeDeleteOptions<Binding extends TLBinding = TLBinding> {
|
|
228
230
|
/** The binding record that refers to the shape in question. */
|
|
229
231
|
binding: Binding;
|
|
230
232
|
/** The shape that is about to be deleted. */
|
|
@@ -256,7 +258,7 @@ export declare interface BindingOnShapeDeleteOptions<Binding extends TLUnknownBi
|
|
|
256
258
|
*
|
|
257
259
|
* @public
|
|
258
260
|
*/
|
|
259
|
-
export declare interface BindingOnShapeIsolateOptions<Binding extends
|
|
261
|
+
export declare interface BindingOnShapeIsolateOptions<Binding extends TLBinding = TLBinding> {
|
|
260
262
|
/** The binding record that refers to the shape in question. */
|
|
261
263
|
binding: Binding;
|
|
262
264
|
/**
|
|
@@ -267,7 +269,7 @@ export declare interface BindingOnShapeIsolateOptions<Binding extends TLUnknownB
|
|
|
267
269
|
}
|
|
268
270
|
|
|
269
271
|
/** @public */
|
|
270
|
-
export declare abstract class BindingUtil<Binding extends
|
|
272
|
+
export declare abstract class BindingUtil<Binding extends TLBinding = TLBinding> {
|
|
271
273
|
editor: Editor;
|
|
272
274
|
constructor(editor: Editor);
|
|
273
275
|
static props?: RecordProps<TLUnknownBinding>;
|
|
@@ -1023,19 +1025,21 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1023
1025
|
* after the editor has already been initialized.
|
|
1024
1026
|
*
|
|
1025
1027
|
* @param Tool - The tool to set.
|
|
1028
|
+
* @param parent - The parent state node to set the tool on.
|
|
1026
1029
|
*
|
|
1027
1030
|
* @public
|
|
1028
1031
|
*/
|
|
1029
|
-
setTool(Tool: TLStateNodeConstructor): void;
|
|
1032
|
+
setTool(Tool: TLStateNodeConstructor, parent?: StateNode): void;
|
|
1030
1033
|
/**
|
|
1031
1034
|
* Remove a tool. Useful if you need to remove a tool from the state chart on demand,
|
|
1032
1035
|
* after the editor has already been initialized.
|
|
1033
1036
|
*
|
|
1034
1037
|
* @param Tool - The tool to delete.
|
|
1038
|
+
* @param parent - The parent state node to remove the tool from.
|
|
1035
1039
|
*
|
|
1036
1040
|
* @public
|
|
1037
1041
|
*/
|
|
1038
|
-
removeTool(Tool: TLStateNodeConstructor): void;
|
|
1042
|
+
removeTool(Tool: TLStateNodeConstructor, parent?: StateNode): void;
|
|
1039
1043
|
/**
|
|
1040
1044
|
* A set of functions to call when the app is disposed.
|
|
1041
1045
|
*
|
|
@@ -1127,7 +1131,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1127
1131
|
* @public
|
|
1128
1132
|
*/
|
|
1129
1133
|
shapeUtils: {
|
|
1130
|
-
readonly [K in string]?: ShapeUtil<
|
|
1134
|
+
readonly [K in string]?: ShapeUtil<TLShape>;
|
|
1131
1135
|
};
|
|
1132
1136
|
styleProps: {
|
|
1133
1137
|
[key: string]: Map<StyleProp<any>, string>;
|
|
@@ -1147,16 +1151,18 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1147
1151
|
*
|
|
1148
1152
|
* @public
|
|
1149
1153
|
*/
|
|
1150
|
-
getShapeUtil<
|
|
1151
|
-
|
|
1154
|
+
getShapeUtil<K extends TLShape['type']>(type: K): ShapeUtil<Extract<TLShape, {
|
|
1155
|
+
type: K;
|
|
1156
|
+
}>>;
|
|
1157
|
+
getShapeUtil<S extends TLShape>(shape: S | S['type'] | TLShapePartial<S>): ShapeUtil<S>;
|
|
1152
1158
|
getShapeUtil<T extends ShapeUtil>(type: T extends ShapeUtil<infer R> ? R['type'] : string): T;
|
|
1153
1159
|
/**
|
|
1154
1160
|
* Returns true if the editor has a shape util for the given shape / shape type.
|
|
1155
1161
|
*
|
|
1156
1162
|
* @param shape - A shape, shape partial, or shape type.
|
|
1157
1163
|
*/
|
|
1158
|
-
hasShapeUtil
|
|
1159
|
-
hasShapeUtil
|
|
1164
|
+
hasShapeUtil(shape: TLShape | TLShapePartial<TLShape>): boolean;
|
|
1165
|
+
hasShapeUtil(type: TLShape['type']): boolean;
|
|
1160
1166
|
hasShapeUtil<T extends ShapeUtil>(type: T extends ShapeUtil<infer R> ? R['type'] : string): boolean;
|
|
1161
1167
|
/**
|
|
1162
1168
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
@@ -1164,7 +1170,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1164
1170
|
* @public
|
|
1165
1171
|
*/
|
|
1166
1172
|
bindingUtils: {
|
|
1167
|
-
readonly [K in string]?: BindingUtil<
|
|
1173
|
+
readonly [K in string]?: BindingUtil<TLBinding>;
|
|
1168
1174
|
};
|
|
1169
1175
|
/**
|
|
1170
1176
|
* Get a binding util from a binding itself.
|
|
@@ -1181,10 +1187,12 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1181
1187
|
*
|
|
1182
1188
|
* @public
|
|
1183
1189
|
*/
|
|
1184
|
-
getBindingUtil<
|
|
1190
|
+
getBindingUtil<K extends TLBinding['type']>(type: K): BindingUtil<Extract<TLBinding, {
|
|
1191
|
+
type: K;
|
|
1192
|
+
}>>;
|
|
1193
|
+
getBindingUtil<S extends TLBinding>(binding: {
|
|
1185
1194
|
type: S['type'];
|
|
1186
1195
|
} | S): BindingUtil<S>;
|
|
1187
|
-
getBindingUtil<S extends TLUnknownBinding>(type: S['type']): BindingUtil<S>;
|
|
1188
1196
|
getBindingUtil<T extends BindingUtil>(type: T extends BindingUtil<infer R> ? R['type'] : string): T;
|
|
1189
1197
|
/**
|
|
1190
1198
|
* A manager for the app's history.
|
|
@@ -2763,7 +2771,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2763
2771
|
*
|
|
2764
2772
|
* @example
|
|
2765
2773
|
* ```ts
|
|
2766
|
-
* const isArrowShape = isShapeOfType
|
|
2774
|
+
* const isArrowShape = isShapeOfType(someShape, 'arrow')
|
|
2767
2775
|
* ```
|
|
2768
2776
|
*
|
|
2769
2777
|
* @param util - the TLShapeUtil constructor to test against
|
|
@@ -2771,8 +2779,13 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2771
2779
|
*
|
|
2772
2780
|
* @public
|
|
2773
2781
|
*/
|
|
2774
|
-
isShapeOfType<
|
|
2775
|
-
|
|
2782
|
+
isShapeOfType<K extends TLShape['type']>(shape: TLShape, type: K): shape is Extract<TLShape, {
|
|
2783
|
+
type: K;
|
|
2784
|
+
}>;
|
|
2785
|
+
isShapeOfType<T extends TLShape>(shape: TLShape, type: T['type']): shape is Extract<TLShape, {
|
|
2786
|
+
type: T['type'];
|
|
2787
|
+
}>;
|
|
2788
|
+
isShapeOfType<T extends TLShape = TLShape>(shapeId: TLShapeId, type: T['type']): boolean;
|
|
2776
2789
|
/**
|
|
2777
2790
|
* Get a shape by its id.
|
|
2778
2791
|
*
|
|
@@ -2923,17 +2936,26 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2923
2936
|
* Get all bindings of a certain type _from_ a particular shape. These are the bindings whose
|
|
2924
2937
|
* `fromId` matched the shape's ID.
|
|
2925
2938
|
*/
|
|
2926
|
-
getBindingsFromShape<
|
|
2939
|
+
getBindingsFromShape<K extends TLBinding['type']>(shape: TLShape | TLShapeId, type: K): Extract<TLBinding, {
|
|
2940
|
+
type: K;
|
|
2941
|
+
}>[];
|
|
2942
|
+
getBindingsFromShape<Binding extends TLBinding = TLBinding>(shape: TLShape | TLShapeId, type: Binding['type']): Binding[];
|
|
2927
2943
|
/**
|
|
2928
2944
|
* Get all bindings of a certain type _to_ a particular shape. These are the bindings whose
|
|
2929
2945
|
* `toId` matches the shape's ID.
|
|
2930
2946
|
*/
|
|
2931
|
-
getBindingsToShape<
|
|
2947
|
+
getBindingsToShape<K extends TLBinding['type']>(shape: TLShape | TLShapeId, type: K): Extract<TLBinding, {
|
|
2948
|
+
type: K;
|
|
2949
|
+
}>[];
|
|
2950
|
+
getBindingsToShape<Binding extends TLBinding = TLBinding>(shape: TLShape | TLShapeId, type: Binding['type']): Binding[];
|
|
2932
2951
|
/**
|
|
2933
2952
|
* Get all bindings involving a particular shape. This includes bindings where the shape is the
|
|
2934
2953
|
* `fromId` or `toId`. If a type is provided, only bindings of that type are returned.
|
|
2935
2954
|
*/
|
|
2936
|
-
getBindingsInvolvingShape<
|
|
2955
|
+
getBindingsInvolvingShape<K extends TLBinding['type']>(shape: TLShape | TLShapeId, type: K): Extract<TLBinding, {
|
|
2956
|
+
type: K;
|
|
2957
|
+
}>[];
|
|
2958
|
+
getBindingsInvolvingShape<Binding extends TLBinding = TLBinding>(shape: TLShape | TLShapeId, type?: Binding['type']): Binding[];
|
|
2937
2959
|
/**
|
|
2938
2960
|
* Create bindings from a list of partial bindings. You can omit the ID and most props of a
|
|
2939
2961
|
* binding, but the `type`, `toId`, and `fromId` must all be provided.
|
|
@@ -3248,7 +3270,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3248
3270
|
*
|
|
3249
3271
|
* @public
|
|
3250
3272
|
*/
|
|
3251
|
-
canCreateShape
|
|
3273
|
+
canCreateShape(shape: OptionalKeys<TLShapePartial<TLShape>, 'id'> | TLShape['id']): boolean;
|
|
3252
3274
|
/**
|
|
3253
3275
|
* Get whether the provided shapes can be created.
|
|
3254
3276
|
*
|
|
@@ -3256,7 +3278,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3256
3278
|
*
|
|
3257
3279
|
* @public
|
|
3258
3280
|
*/
|
|
3259
|
-
canCreateShapes
|
|
3281
|
+
canCreateShapes(shapes: (OptionalKeys<TLShapePartial<TLShape>, 'id'> | TLShape['id'])[]): boolean;
|
|
3260
3282
|
/**
|
|
3261
3283
|
* Create a single shape.
|
|
3262
3284
|
*
|
|
@@ -3270,7 +3292,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3270
3292
|
*
|
|
3271
3293
|
* @public
|
|
3272
3294
|
*/
|
|
3273
|
-
createShape<
|
|
3295
|
+
createShape<TShape extends TLShape>(shape: TLCreateShapePartial<TShape>): this;
|
|
3274
3296
|
/**
|
|
3275
3297
|
* Create shapes.
|
|
3276
3298
|
*
|
|
@@ -3284,7 +3306,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3284
3306
|
*
|
|
3285
3307
|
* @public
|
|
3286
3308
|
*/
|
|
3287
|
-
createShapes<
|
|
3309
|
+
createShapes<TShape extends TLShape = TLShape>(shapes: TLCreateShapePartial<TShape>[]): this;
|
|
3288
3310
|
private animatingShapes;
|
|
3289
3311
|
/**
|
|
3290
3312
|
* Animate a shape.
|
|
@@ -3370,7 +3392,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3370
3392
|
*
|
|
3371
3393
|
* @public
|
|
3372
3394
|
*/
|
|
3373
|
-
updateShape<T extends
|
|
3395
|
+
updateShape<T extends TLShape = TLShape>(partial: null | TLShapePartial<T> | undefined): this;
|
|
3374
3396
|
/**
|
|
3375
3397
|
* Update shapes using partials of each shape.
|
|
3376
3398
|
*
|
|
@@ -3383,7 +3405,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3383
3405
|
*
|
|
3384
3406
|
* @public
|
|
3385
3407
|
*/
|
|
3386
|
-
updateShapes<T extends
|
|
3408
|
+
updateShapes<T extends TLShape>(partials: (null | TLShapePartial<T> | undefined)[]): this;
|
|
3387
3409
|
/* Excluded from this release type: _updateShapes */
|
|
3388
3410
|
/* Excluded from this release type: _getUnlockedShapeIds */
|
|
3389
3411
|
/**
|
|
@@ -5114,7 +5136,7 @@ export declare function setRuntimeOverrides(input: Partial<typeof runtime>): voi
|
|
|
5114
5136
|
export declare function setUserPreferences(user: TLUserPreferences): void;
|
|
5115
5137
|
|
|
5116
5138
|
/** @public */
|
|
5117
|
-
export declare abstract class ShapeUtil<Shape extends
|
|
5139
|
+
export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
5118
5140
|
editor: Editor;
|
|
5119
5141
|
/** Configure this shape utils {@link ShapeUtil.options | `options`}. */
|
|
5120
5142
|
static configure<T extends TLShapeUtilConstructor<any, any>>(this: T, options: T extends new (...args: any[]) => {
|
|
@@ -6039,7 +6061,7 @@ export declare type TLAnyBindingUtilConstructor = TLBindingUtilConstructor<any>;
|
|
|
6039
6061
|
export declare type TLAnyShapeUtilConstructor = TLShapeUtilConstructor<any>;
|
|
6040
6062
|
|
|
6041
6063
|
/** @public */
|
|
6042
|
-
export declare type TLBaseBoxShape =
|
|
6064
|
+
export declare type TLBaseBoxShape = ExtractShapeByProps<{
|
|
6043
6065
|
h: number;
|
|
6044
6066
|
w: number;
|
|
6045
6067
|
}>;
|
|
@@ -6061,7 +6083,7 @@ export declare interface TLBaseExternalContent {
|
|
|
6061
6083
|
}
|
|
6062
6084
|
|
|
6063
6085
|
/** @public */
|
|
6064
|
-
export declare interface TLBindingUtilConstructor<T extends
|
|
6086
|
+
export declare interface TLBindingUtilConstructor<T extends TLBinding, U extends BindingUtil<T> = BindingUtil<T>> {
|
|
6065
6087
|
new (editor: Editor): U;
|
|
6066
6088
|
type: T['type'];
|
|
6067
6089
|
/** Validations for this binding's props. */
|
|
@@ -7495,11 +7517,11 @@ export declare interface TLShapeUtilCanBeLaidOutOpts {
|
|
|
7495
7517
|
*
|
|
7496
7518
|
* @public
|
|
7497
7519
|
*/
|
|
7498
|
-
export declare interface TLShapeUtilCanBindOpts<Shape extends
|
|
7520
|
+
export declare interface TLShapeUtilCanBindOpts<Shape extends TLShape = TLShape> {
|
|
7499
7521
|
/** The type of shape referenced by the `fromId` of the binding. */
|
|
7500
|
-
fromShapeType:
|
|
7522
|
+
fromShapeType: TLShape['type'];
|
|
7501
7523
|
/** The type of shape referenced by the `toId` of the binding. */
|
|
7502
|
-
toShapeType:
|
|
7524
|
+
toShapeType: TLShape['type'];
|
|
7503
7525
|
/** The type of binding. */
|
|
7504
7526
|
bindingType: string;
|
|
7505
7527
|
}
|
|
@@ -7511,7 +7533,7 @@ export declare interface TLShapeUtilCanvasSvgDef {
|
|
|
7511
7533
|
}
|
|
7512
7534
|
|
|
7513
7535
|
/** @public */
|
|
7514
|
-
export declare interface TLShapeUtilConstructor<T extends
|
|
7536
|
+
export declare interface TLShapeUtilConstructor<T extends TLShape, U extends ShapeUtil<T> = ShapeUtil<T>> {
|
|
7515
7537
|
new (editor: Editor): U;
|
|
7516
7538
|
type: T['type'];
|
|
7517
7539
|
props?: RecordProps<T>;
|
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.03ae87dcc44b",
|
|
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
|
/**
|
|
@@ -4396,30 +4400,18 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4396
4400
|
getBinding(id) {
|
|
4397
4401
|
return this.store.get(id);
|
|
4398
4402
|
}
|
|
4399
|
-
/**
|
|
4400
|
-
* Get all bindings of a certain type _from_ a particular shape. These are the bindings whose
|
|
4401
|
-
* `fromId` matched the shape's ID.
|
|
4402
|
-
*/
|
|
4403
4403
|
getBindingsFromShape(shape, type) {
|
|
4404
4404
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4405
4405
|
return this.getBindingsInvolvingShape(id).filter(
|
|
4406
4406
|
(b) => b.fromId === id && b.type === type
|
|
4407
4407
|
);
|
|
4408
4408
|
}
|
|
4409
|
-
/**
|
|
4410
|
-
* Get all bindings of a certain type _to_ a particular shape. These are the bindings whose
|
|
4411
|
-
* `toId` matches the shape's ID.
|
|
4412
|
-
*/
|
|
4413
4409
|
getBindingsToShape(shape, type) {
|
|
4414
4410
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4415
4411
|
return this.getBindingsInvolvingShape(id).filter(
|
|
4416
4412
|
(b) => b.toId === id && b.type === type
|
|
4417
4413
|
);
|
|
4418
4414
|
}
|
|
4419
|
-
/**
|
|
4420
|
-
* Get all bindings involving a particular shape. This includes bindings where the shape is the
|
|
4421
|
-
* `fromId` or `toId`. If a type is provided, only bindings of that type are returned.
|
|
4422
|
-
*/
|
|
4423
4415
|
getBindingsInvolvingShape(shape, type) {
|
|
4424
4416
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4425
4417
|
const result = this._getBindingsIndexCache().get(id) ?? import_state.EMPTY_ARRAY;
|
|
@@ -7477,6 +7469,7 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7477
7469
|
this.setCursor({ type: this._prevCursor, rotation: 0 });
|
|
7478
7470
|
}
|
|
7479
7471
|
}
|
|
7472
|
+
this.emit("event", info);
|
|
7480
7473
|
this.root.handleEvent(info);
|
|
7481
7474
|
return;
|
|
7482
7475
|
}
|