@tldraw/editor 4.3.0-canary.fd6b7f2a8adc → 4.3.0-next.2b3bfbba757b
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 +35 -55
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +12 -1
- 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/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 +35 -55
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +12 -1
- 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/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 +10 -10
- package/src/lib/editor/Editor.ts +59 -82
- package/src/lib/editor/bindings/BindingUtil.ts +9 -15
- package/src/lib/editor/derivations/bindingsIndex.ts +2 -2
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +4 -14
- 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 +8 -5
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +3 -1
- package/src/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.ts +1 -2
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +3 -3
- package/src/lib/exports/getSvgJsx.test.ts +19 -10
- package/src/lib/exports/getSvgJsx.tsx +5 -2
- package/src/lib/utils/reparenting.ts +5 -5
- package/src/version.ts +3 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ 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';
|
|
11
10
|
import { ForwardRefExoticComponent } from 'react';
|
|
12
11
|
import { HistoryEntry } from '@tldraw/store';
|
|
13
12
|
import { IndexKey } from '@tldraw/utils';
|
|
@@ -49,7 +48,6 @@ import { TLBindingId } from '@tldraw/tlschema';
|
|
|
49
48
|
import { TLBindingUpdate } from '@tldraw/tlschema';
|
|
50
49
|
import { TLBookmarkAsset } from '@tldraw/tlschema';
|
|
51
50
|
import { TLCamera } from '@tldraw/tlschema';
|
|
52
|
-
import { TLCreateShapePartial } from '@tldraw/tlschema';
|
|
53
51
|
import { TLCursor } from '@tldraw/tlschema';
|
|
54
52
|
import { TLCursorType } from '@tldraw/tlschema';
|
|
55
53
|
import { TLDefaultDashStyle } from '@tldraw/tlschema';
|
|
@@ -149,7 +147,7 @@ export declare abstract class BaseBoxShapeTool extends StateNode {
|
|
|
149
147
|
static id: string;
|
|
150
148
|
static initial: string;
|
|
151
149
|
static children(): TLStateNodeConstructor[];
|
|
152
|
-
abstract shapeType:
|
|
150
|
+
abstract shapeType: string;
|
|
153
151
|
onCreate?(_shape: null | TLShape): null | void;
|
|
154
152
|
}
|
|
155
153
|
|
|
@@ -167,7 +165,7 @@ export declare abstract class BaseBoxShapeUtil<Shape extends TLBaseBoxShape> ext
|
|
|
167
165
|
*
|
|
168
166
|
* @public
|
|
169
167
|
*/
|
|
170
|
-
export declare interface BindingOnChangeOptions<Binding extends
|
|
168
|
+
export declare interface BindingOnChangeOptions<Binding extends TLUnknownBinding> {
|
|
171
169
|
/** The binding record before the change is made. */
|
|
172
170
|
bindingBefore: Binding;
|
|
173
171
|
/** The binding record after the change is made. */
|
|
@@ -180,7 +178,7 @@ export declare interface BindingOnChangeOptions<Binding extends TLBinding = TLBi
|
|
|
180
178
|
*
|
|
181
179
|
* @public
|
|
182
180
|
*/
|
|
183
|
-
export declare interface BindingOnCreateOptions<Binding extends
|
|
181
|
+
export declare interface BindingOnCreateOptions<Binding extends TLUnknownBinding> {
|
|
184
182
|
/** The binding being created. */
|
|
185
183
|
binding: Binding;
|
|
186
184
|
}
|
|
@@ -191,7 +189,7 @@ export declare interface BindingOnCreateOptions<Binding extends TLBinding = TLBi
|
|
|
191
189
|
*
|
|
192
190
|
* @public
|
|
193
191
|
*/
|
|
194
|
-
export declare interface BindingOnDeleteOptions<Binding extends
|
|
192
|
+
export declare interface BindingOnDeleteOptions<Binding extends TLUnknownBinding> {
|
|
195
193
|
/** The binding being deleted. */
|
|
196
194
|
binding: Binding;
|
|
197
195
|
}
|
|
@@ -202,7 +200,7 @@ export declare interface BindingOnDeleteOptions<Binding extends TLBinding = TLBi
|
|
|
202
200
|
*
|
|
203
201
|
* @public
|
|
204
202
|
*/
|
|
205
|
-
export declare interface BindingOnShapeChangeOptions<Binding extends
|
|
203
|
+
export declare interface BindingOnShapeChangeOptions<Binding extends TLUnknownBinding> {
|
|
206
204
|
/** The binding record linking these two shapes. */
|
|
207
205
|
binding: Binding;
|
|
208
206
|
/** The shape record before the change is made. */
|
|
@@ -226,7 +224,7 @@ export declare interface BindingOnShapeChangeOptions<Binding extends TLBinding =
|
|
|
226
224
|
*
|
|
227
225
|
* @public
|
|
228
226
|
*/
|
|
229
|
-
export declare interface BindingOnShapeDeleteOptions<Binding extends
|
|
227
|
+
export declare interface BindingOnShapeDeleteOptions<Binding extends TLUnknownBinding> {
|
|
230
228
|
/** The binding record that refers to the shape in question. */
|
|
231
229
|
binding: Binding;
|
|
232
230
|
/** The shape that is about to be deleted. */
|
|
@@ -258,7 +256,7 @@ export declare interface BindingOnShapeDeleteOptions<Binding extends TLBinding =
|
|
|
258
256
|
*
|
|
259
257
|
* @public
|
|
260
258
|
*/
|
|
261
|
-
export declare interface BindingOnShapeIsolateOptions<Binding extends
|
|
259
|
+
export declare interface BindingOnShapeIsolateOptions<Binding extends TLUnknownBinding> {
|
|
262
260
|
/** The binding record that refers to the shape in question. */
|
|
263
261
|
binding: Binding;
|
|
264
262
|
/**
|
|
@@ -269,7 +267,7 @@ export declare interface BindingOnShapeIsolateOptions<Binding extends TLBinding
|
|
|
269
267
|
}
|
|
270
268
|
|
|
271
269
|
/** @public */
|
|
272
|
-
export declare abstract class BindingUtil<Binding extends
|
|
270
|
+
export declare abstract class BindingUtil<Binding extends TLUnknownBinding = TLUnknownBinding> {
|
|
273
271
|
editor: Editor;
|
|
274
272
|
constructor(editor: Editor);
|
|
275
273
|
static props?: RecordProps<TLUnknownBinding>;
|
|
@@ -1131,7 +1129,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1131
1129
|
* @public
|
|
1132
1130
|
*/
|
|
1133
1131
|
shapeUtils: {
|
|
1134
|
-
readonly [K in string]?: ShapeUtil<
|
|
1132
|
+
readonly [K in string]?: ShapeUtil<TLUnknownShape>;
|
|
1135
1133
|
};
|
|
1136
1134
|
styleProps: {
|
|
1137
1135
|
[key: string]: Map<StyleProp<any>, string>;
|
|
@@ -1151,18 +1149,16 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1151
1149
|
*
|
|
1152
1150
|
* @public
|
|
1153
1151
|
*/
|
|
1154
|
-
getShapeUtil<
|
|
1155
|
-
|
|
1156
|
-
}>>;
|
|
1157
|
-
getShapeUtil<S extends TLShape>(shape: S | S['type'] | TLShapePartial<S>): ShapeUtil<S>;
|
|
1152
|
+
getShapeUtil<S extends TLUnknownShape>(shape: S | TLShapePartial<S>): ShapeUtil<S>;
|
|
1153
|
+
getShapeUtil<S extends TLUnknownShape>(type: S['type']): ShapeUtil<S>;
|
|
1158
1154
|
getShapeUtil<T extends ShapeUtil>(type: T extends ShapeUtil<infer R> ? R['type'] : string): T;
|
|
1159
1155
|
/**
|
|
1160
1156
|
* Returns true if the editor has a shape util for the given shape / shape type.
|
|
1161
1157
|
*
|
|
1162
1158
|
* @param shape - A shape, shape partial, or shape type.
|
|
1163
1159
|
*/
|
|
1164
|
-
hasShapeUtil(shape:
|
|
1165
|
-
hasShapeUtil(type:
|
|
1160
|
+
hasShapeUtil<S extends TLUnknownShape>(shape: S | TLShapePartial<S>): boolean;
|
|
1161
|
+
hasShapeUtil<S extends TLUnknownShape>(type: S['type']): boolean;
|
|
1166
1162
|
hasShapeUtil<T extends ShapeUtil>(type: T extends ShapeUtil<infer R> ? R['type'] : string): boolean;
|
|
1167
1163
|
/**
|
|
1168
1164
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
@@ -1170,7 +1166,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1170
1166
|
* @public
|
|
1171
1167
|
*/
|
|
1172
1168
|
bindingUtils: {
|
|
1173
|
-
readonly [K in string]?: BindingUtil<
|
|
1169
|
+
readonly [K in string]?: BindingUtil<TLUnknownBinding>;
|
|
1174
1170
|
};
|
|
1175
1171
|
/**
|
|
1176
1172
|
* Get a binding util from a binding itself.
|
|
@@ -1187,12 +1183,10 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1187
1183
|
*
|
|
1188
1184
|
* @public
|
|
1189
1185
|
*/
|
|
1190
|
-
getBindingUtil<
|
|
1191
|
-
type: K;
|
|
1192
|
-
}>>;
|
|
1193
|
-
getBindingUtil<S extends TLBinding>(binding: {
|
|
1186
|
+
getBindingUtil<S extends TLUnknownBinding>(binding: {
|
|
1194
1187
|
type: S['type'];
|
|
1195
1188
|
} | S): BindingUtil<S>;
|
|
1189
|
+
getBindingUtil<S extends TLUnknownBinding>(type: S['type']): BindingUtil<S>;
|
|
1196
1190
|
getBindingUtil<T extends BindingUtil>(type: T extends BindingUtil<infer R> ? R['type'] : string): T;
|
|
1197
1191
|
/**
|
|
1198
1192
|
* A manager for the app's history.
|
|
@@ -2771,7 +2765,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2771
2765
|
*
|
|
2772
2766
|
* @example
|
|
2773
2767
|
* ```ts
|
|
2774
|
-
* const isArrowShape = isShapeOfType(someShape, 'arrow')
|
|
2768
|
+
* const isArrowShape = isShapeOfType<TLArrowShape>(someShape, 'arrow')
|
|
2775
2769
|
* ```
|
|
2776
2770
|
*
|
|
2777
2771
|
* @param util - the TLShapeUtil constructor to test against
|
|
@@ -2779,13 +2773,8 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2779
2773
|
*
|
|
2780
2774
|
* @public
|
|
2781
2775
|
*/
|
|
2782
|
-
isShapeOfType<
|
|
2783
|
-
|
|
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
|
+
isShapeOfType<T extends TLUnknownShape>(shape: TLUnknownShape, type: T['type']): shape is T;
|
|
2777
|
+
isShapeOfType<T extends TLUnknownShape>(shapeId: TLUnknownShape['id'], type: T['type']): shapeId is T['id'];
|
|
2789
2778
|
/**
|
|
2790
2779
|
* Get a shape by its id.
|
|
2791
2780
|
*
|
|
@@ -2936,26 +2925,17 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2936
2925
|
* Get all bindings of a certain type _from_ a particular shape. These are the bindings whose
|
|
2937
2926
|
* `fromId` matched the shape's ID.
|
|
2938
2927
|
*/
|
|
2939
|
-
getBindingsFromShape<
|
|
2940
|
-
type: K;
|
|
2941
|
-
}>[];
|
|
2942
|
-
getBindingsFromShape<Binding extends TLBinding = TLBinding>(shape: TLShape | TLShapeId, type: Binding['type']): Binding[];
|
|
2928
|
+
getBindingsFromShape<Binding extends TLUnknownBinding = TLBinding>(shape: TLShape | TLShapeId, type: Binding['type']): Binding[];
|
|
2943
2929
|
/**
|
|
2944
2930
|
* Get all bindings of a certain type _to_ a particular shape. These are the bindings whose
|
|
2945
2931
|
* `toId` matches the shape's ID.
|
|
2946
2932
|
*/
|
|
2947
|
-
getBindingsToShape<
|
|
2948
|
-
type: K;
|
|
2949
|
-
}>[];
|
|
2950
|
-
getBindingsToShape<Binding extends TLBinding = TLBinding>(shape: TLShape | TLShapeId, type: Binding['type']): Binding[];
|
|
2933
|
+
getBindingsToShape<Binding extends TLUnknownBinding = TLBinding>(shape: TLShape | TLShapeId, type: Binding['type']): Binding[];
|
|
2951
2934
|
/**
|
|
2952
2935
|
* Get all bindings involving a particular shape. This includes bindings where the shape is the
|
|
2953
2936
|
* `fromId` or `toId`. If a type is provided, only bindings of that type are returned.
|
|
2954
2937
|
*/
|
|
2955
|
-
getBindingsInvolvingShape<
|
|
2956
|
-
type: K;
|
|
2957
|
-
}>[];
|
|
2958
|
-
getBindingsInvolvingShape<Binding extends TLBinding = TLBinding>(shape: TLShape | TLShapeId, type?: Binding['type']): Binding[];
|
|
2938
|
+
getBindingsInvolvingShape<Binding extends TLUnknownBinding = TLBinding>(shape: TLShape | TLShapeId, type?: Binding['type']): Binding[];
|
|
2959
2939
|
/**
|
|
2960
2940
|
* Create bindings from a list of partial bindings. You can omit the ID and most props of a
|
|
2961
2941
|
* binding, but the `type`, `toId`, and `fromId` must all be provided.
|
|
@@ -3270,7 +3250,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3270
3250
|
*
|
|
3271
3251
|
* @public
|
|
3272
3252
|
*/
|
|
3273
|
-
canCreateShape(shape: OptionalKeys<TLShapePartial<
|
|
3253
|
+
canCreateShape<T extends TLUnknownShape>(shape: OptionalKeys<TLShapePartial<T>, 'id'> | T['id']): boolean;
|
|
3274
3254
|
/**
|
|
3275
3255
|
* Get whether the provided shapes can be created.
|
|
3276
3256
|
*
|
|
@@ -3278,7 +3258,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3278
3258
|
*
|
|
3279
3259
|
* @public
|
|
3280
3260
|
*/
|
|
3281
|
-
canCreateShapes(shapes: (OptionalKeys<TLShapePartial<
|
|
3261
|
+
canCreateShapes<T extends TLUnknownShape>(shapes: (OptionalKeys<TLShapePartial<T>, 'id'> | T['id'])[]): boolean;
|
|
3282
3262
|
/**
|
|
3283
3263
|
* Create a single shape.
|
|
3284
3264
|
*
|
|
@@ -3292,7 +3272,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3292
3272
|
*
|
|
3293
3273
|
* @public
|
|
3294
3274
|
*/
|
|
3295
|
-
createShape<
|
|
3275
|
+
createShape<T extends TLUnknownShape>(shape: OptionalKeys<TLShapePartial<T>, 'id'>): this;
|
|
3296
3276
|
/**
|
|
3297
3277
|
* Create shapes.
|
|
3298
3278
|
*
|
|
@@ -3306,7 +3286,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3306
3286
|
*
|
|
3307
3287
|
* @public
|
|
3308
3288
|
*/
|
|
3309
|
-
createShapes<
|
|
3289
|
+
createShapes<T extends TLUnknownShape>(shapes: OptionalKeys<TLShapePartial<T>, 'id'>[]): this;
|
|
3310
3290
|
private animatingShapes;
|
|
3311
3291
|
/**
|
|
3312
3292
|
* Animate a shape.
|
|
@@ -3392,7 +3372,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3392
3372
|
*
|
|
3393
3373
|
* @public
|
|
3394
3374
|
*/
|
|
3395
|
-
updateShape<T extends
|
|
3375
|
+
updateShape<T extends TLUnknownShape>(partial: null | TLShapePartial<T> | undefined): this;
|
|
3396
3376
|
/**
|
|
3397
3377
|
* Update shapes using partials of each shape.
|
|
3398
3378
|
*
|
|
@@ -3405,7 +3385,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3405
3385
|
*
|
|
3406
3386
|
* @public
|
|
3407
3387
|
*/
|
|
3408
|
-
updateShapes<T extends
|
|
3388
|
+
updateShapes<T extends TLUnknownShape>(partials: (null | TLShapePartial<T> | undefined)[]): this;
|
|
3409
3389
|
/* Excluded from this release type: _updateShapes */
|
|
3410
3390
|
/* Excluded from this release type: _getUnlockedShapeIds */
|
|
3411
3391
|
/**
|
|
@@ -5136,7 +5116,7 @@ export declare function setRuntimeOverrides(input: Partial<typeof runtime>): voi
|
|
|
5136
5116
|
export declare function setUserPreferences(user: TLUserPreferences): void;
|
|
5137
5117
|
|
|
5138
5118
|
/** @public */
|
|
5139
|
-
export declare abstract class ShapeUtil<Shape extends
|
|
5119
|
+
export declare abstract class ShapeUtil<Shape extends TLUnknownShape = TLUnknownShape> {
|
|
5140
5120
|
editor: Editor;
|
|
5141
5121
|
/** Configure this shape utils {@link ShapeUtil.options | `options`}. */
|
|
5142
5122
|
static configure<T extends TLShapeUtilConstructor<any, any>>(this: T, options: T extends new (...args: any[]) => {
|
|
@@ -6061,7 +6041,7 @@ export declare type TLAnyBindingUtilConstructor = TLBindingUtilConstructor<any>;
|
|
|
6061
6041
|
export declare type TLAnyShapeUtilConstructor = TLShapeUtilConstructor<any>;
|
|
6062
6042
|
|
|
6063
6043
|
/** @public */
|
|
6064
|
-
export declare type TLBaseBoxShape =
|
|
6044
|
+
export declare type TLBaseBoxShape = TLBaseShape<string, {
|
|
6065
6045
|
h: number;
|
|
6066
6046
|
w: number;
|
|
6067
6047
|
}>;
|
|
@@ -6083,7 +6063,7 @@ export declare interface TLBaseExternalContent {
|
|
|
6083
6063
|
}
|
|
6084
6064
|
|
|
6085
6065
|
/** @public */
|
|
6086
|
-
export declare interface TLBindingUtilConstructor<T extends
|
|
6066
|
+
export declare interface TLBindingUtilConstructor<T extends TLUnknownBinding, U extends BindingUtil<T> = BindingUtil<T>> {
|
|
6087
6067
|
new (editor: Editor): U;
|
|
6088
6068
|
type: T['type'];
|
|
6089
6069
|
/** Validations for this binding's props. */
|
|
@@ -7517,11 +7497,11 @@ export declare interface TLShapeUtilCanBeLaidOutOpts {
|
|
|
7517
7497
|
*
|
|
7518
7498
|
* @public
|
|
7519
7499
|
*/
|
|
7520
|
-
export declare interface TLShapeUtilCanBindOpts<Shape extends
|
|
7500
|
+
export declare interface TLShapeUtilCanBindOpts<Shape extends TLUnknownShape = TLUnknownShape> {
|
|
7521
7501
|
/** The type of shape referenced by the `fromId` of the binding. */
|
|
7522
|
-
fromShapeType:
|
|
7502
|
+
fromShapeType: string;
|
|
7523
7503
|
/** The type of shape referenced by the `toId` of the binding. */
|
|
7524
|
-
toShapeType:
|
|
7504
|
+
toShapeType: string;
|
|
7525
7505
|
/** The type of binding. */
|
|
7526
7506
|
bindingType: string;
|
|
7527
7507
|
}
|
|
@@ -7533,7 +7513,7 @@ export declare interface TLShapeUtilCanvasSvgDef {
|
|
|
7533
7513
|
}
|
|
7534
7514
|
|
|
7535
7515
|
/** @public */
|
|
7536
|
-
export declare interface TLShapeUtilConstructor<T extends
|
|
7516
|
+
export declare interface TLShapeUtilConstructor<T extends TLUnknownShape, U extends ShapeUtil<T> = ShapeUtil<T>> {
|
|
7537
7517
|
new (editor: Editor): U;
|
|
7538
7518
|
type: T['type'];
|
|
7539
7519
|
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.3.0-
|
|
373
|
+
"4.3.0-next.2b3bfbba757b",
|
|
374
374
|
"cjs"
|
|
375
375
|
);
|
|
376
376
|
//# sourceMappingURL=index.js.map
|
|
@@ -4400,18 +4400,30 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
4400
4400
|
getBinding(id) {
|
|
4401
4401
|
return this.store.get(id);
|
|
4402
4402
|
}
|
|
4403
|
+
/**
|
|
4404
|
+
* Get all bindings of a certain type _from_ a particular shape. These are the bindings whose
|
|
4405
|
+
* `fromId` matched the shape's ID.
|
|
4406
|
+
*/
|
|
4403
4407
|
getBindingsFromShape(shape, type) {
|
|
4404
4408
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4405
4409
|
return this.getBindingsInvolvingShape(id).filter(
|
|
4406
4410
|
(b) => b.fromId === id && b.type === type
|
|
4407
4411
|
);
|
|
4408
4412
|
}
|
|
4413
|
+
/**
|
|
4414
|
+
* Get all bindings of a certain type _to_ a particular shape. These are the bindings whose
|
|
4415
|
+
* `toId` matches the shape's ID.
|
|
4416
|
+
*/
|
|
4409
4417
|
getBindingsToShape(shape, type) {
|
|
4410
4418
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4411
4419
|
return this.getBindingsInvolvingShape(id).filter(
|
|
4412
4420
|
(b) => b.toId === id && b.type === type
|
|
4413
4421
|
);
|
|
4414
4422
|
}
|
|
4423
|
+
/**
|
|
4424
|
+
* Get all bindings involving a particular shape. This includes bindings where the shape is the
|
|
4425
|
+
* `fromId` or `toId`. If a type is provided, only bindings of that type are returned.
|
|
4426
|
+
*/
|
|
4415
4427
|
getBindingsInvolvingShape(shape, type) {
|
|
4416
4428
|
const id = typeof shape === "string" ? shape : shape.id;
|
|
4417
4429
|
const result = this._getBindingsIndexCache().get(id) ?? import_state.EMPTY_ARRAY;
|
|
@@ -7469,7 +7481,6 @@ class Editor extends (_a = import_eventemitter3.default, _getIsShapeHiddenCache_
|
|
|
7469
7481
|
this.setCursor({ type: this._prevCursor, rotation: 0 });
|
|
7470
7482
|
}
|
|
7471
7483
|
}
|
|
7472
|
-
this.emit("event", info);
|
|
7473
7484
|
this.root.handleEvent(info);
|
|
7474
7485
|
return;
|
|
7475
7486
|
}
|