@tldraw/editor 5.3.0-canary.bf61a40bac61 → 5.3.0-canary.c2916d0f252d
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 +9 -1
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +48 -10
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/BaseFrameLikeShapeUtil.js +3 -0
- package/dist-cjs/lib/editor/shapes/BaseFrameLikeShapeUtil.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 +9 -1
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +48 -10
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/BaseFrameLikeShapeUtil.mjs +3 -0
- package/dist-esm/lib/editor/shapes/BaseFrameLikeShapeUtil.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/lib/editor/Editor.ts +58 -15
- package/src/lib/editor/shapes/BaseFrameLikeShapeUtil.tsx +6 -1
- package/src/version.ts +3 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -219,7 +219,7 @@ export declare abstract class BaseBoxShapeUtil<Shape extends TLBaseBoxShape> ext
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
/**
|
|
222
|
-
* A base class for frame-like shapes — containers that clip their children,
|
|
222
|
+
* A base class for frame-like shapes — containers that clip their children except arrows,
|
|
223
223
|
* require full-brush selection, block erasure from inside, and support
|
|
224
224
|
* drag-and-drop reparenting.
|
|
225
225
|
*
|
|
@@ -231,6 +231,7 @@ export declare abstract class BaseBoxShapeUtil<Shape extends TLBaseBoxShape> ext
|
|
|
231
231
|
* - `canReceiveNewChildrenOfType()` returns `true` unless the container is locked
|
|
232
232
|
* - `canRemoveChildrenOfType()` returns `true` unless the container is locked
|
|
233
233
|
* - `getClipPath()` returns the shape geometry's vertices
|
|
234
|
+
* - `shouldClipChild()` clips all children except arrows
|
|
234
235
|
* - `onDragShapesIn()` reparents shapes into the frame (with index restoration)
|
|
235
236
|
* - `onDragShapesOut()` reparents shapes back to the page
|
|
236
237
|
*
|
|
@@ -266,6 +267,7 @@ export declare abstract class BaseFrameLikeShapeUtil<Shape extends TLBaseBoxShap
|
|
|
266
267
|
canReceiveNewChildrenOfType(shape: Shape, _type: TLShape['type']): boolean;
|
|
267
268
|
canRemoveChildrenOfType(shape: Shape, _type: TLShape['type']): boolean;
|
|
268
269
|
getClipPath(shape: Shape): undefined | Vec[];
|
|
270
|
+
shouldClipChild(child: TLShape): boolean;
|
|
269
271
|
onDragShapesIn(shape: Shape, draggingShapes: TLShape[], { initialParentIds, initialIndices }: TLDragShapesInInfo): void;
|
|
270
272
|
onDragShapesOut(shape: Shape, draggingShapes: TLShape[], info: TLDragShapesOutInfo): void;
|
|
271
273
|
}
|
|
@@ -1218,6 +1220,12 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1218
1220
|
* @public
|
|
1219
1221
|
*/
|
|
1220
1222
|
isDisposed: boolean;
|
|
1223
|
+
/**
|
|
1224
|
+
* Whether the editor is mounted.
|
|
1225
|
+
*
|
|
1226
|
+
* @public
|
|
1227
|
+
*/
|
|
1228
|
+
isMounted: boolean;
|
|
1221
1229
|
/* Excluded from this release type: _tickManager */
|
|
1222
1230
|
/**
|
|
1223
1231
|
* A manager for the editor's input state.
|
package/dist-cjs/index.js
CHANGED
|
@@ -379,7 +379,7 @@ var import_uniq = require("./lib/utils/uniq");
|
|
|
379
379
|
var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
|
|
380
380
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
381
381
|
"@tldraw/editor",
|
|
382
|
-
"5.3.0-canary.
|
|
382
|
+
"5.3.0-canary.c2916d0f252d",
|
|
383
383
|
"cjs"
|
|
384
384
|
);
|
|
385
385
|
//# sourceMappingURL=index.js.map
|
|
@@ -273,12 +273,27 @@ class Editor extends import_eventemitter3.default {
|
|
|
273
273
|
let deletedBindings = /* @__PURE__ */ new Map();
|
|
274
274
|
const deletedShapeIds = /* @__PURE__ */ new Set();
|
|
275
275
|
const invalidParents = /* @__PURE__ */ new Set();
|
|
276
|
+
const createdShapes = /* @__PURE__ */ new Set();
|
|
276
277
|
let invalidBindingTypes = /* @__PURE__ */ new Set();
|
|
277
278
|
this.disposables.add(
|
|
278
279
|
this.sideEffects.registerOperationCompleteHandler(() => {
|
|
280
|
+
const deletedIds = deletedShapeIds.size ? new Set(deletedShapeIds) : null;
|
|
279
281
|
deletedShapeIds.clear();
|
|
282
|
+
if (deletedIds) {
|
|
283
|
+
const updates = (0, import_utils.compact)(
|
|
284
|
+
this.getPageStates().map((pageState) => {
|
|
285
|
+
return cleanupInstancePageState(pageState, deletedIds);
|
|
286
|
+
})
|
|
287
|
+
);
|
|
288
|
+
if (updates.length) {
|
|
289
|
+
this.store.put(updates);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const justCreatedShapeIds = new Set(createdShapes);
|
|
293
|
+
createdShapes.clear();
|
|
280
294
|
for (const parentId of invalidParents) {
|
|
281
295
|
invalidParents.delete(parentId);
|
|
296
|
+
if (justCreatedShapeIds.has(parentId)) continue;
|
|
282
297
|
const parent = this.getShape(parentId);
|
|
283
298
|
if (!parent) continue;
|
|
284
299
|
const util = this.getShapeUtil(parent);
|
|
@@ -308,6 +323,12 @@ class Editor extends import_eventemitter3.default {
|
|
|
308
323
|
this.disposables.add(
|
|
309
324
|
this.sideEffects.register({
|
|
310
325
|
shape: {
|
|
326
|
+
afterCreate: (shape) => {
|
|
327
|
+
createdShapes.add(shape.id);
|
|
328
|
+
if (shape.parentId && (0, import_tlschema.isShapeId)(shape.parentId)) {
|
|
329
|
+
invalidParents.add(shape.parentId);
|
|
330
|
+
}
|
|
331
|
+
},
|
|
311
332
|
afterChange: (shapeBefore, shapeAfter) => {
|
|
312
333
|
for (const binding of this.getBindingsInvolvingShape(shapeAfter)) {
|
|
313
334
|
invalidBindingTypes.add(binding.type);
|
|
@@ -397,15 +418,6 @@ class Editor extends import_eventemitter3.default {
|
|
|
397
418
|
if (deleteBindingIds.length) {
|
|
398
419
|
this.deleteBindings(deleteBindingIds);
|
|
399
420
|
}
|
|
400
|
-
const deletedIds = /* @__PURE__ */ new Set([shape.id]);
|
|
401
|
-
const updates = (0, import_utils.compact)(
|
|
402
|
-
this.getPageStates().map((pageState) => {
|
|
403
|
-
return cleanupInstancePageState(pageState, deletedIds);
|
|
404
|
-
})
|
|
405
|
-
);
|
|
406
|
-
if (updates.length) {
|
|
407
|
-
this.store.put(updates);
|
|
408
|
-
}
|
|
409
421
|
}
|
|
410
422
|
},
|
|
411
423
|
binding: {
|
|
@@ -482,6 +494,9 @@ class Editor extends import_eventemitter3.default {
|
|
|
482
494
|
},
|
|
483
495
|
instance_page_state: {
|
|
484
496
|
afterChange: (prev, next) => {
|
|
497
|
+
if (prev?.focusedGroupId !== next?.focusedGroupId) {
|
|
498
|
+
this.cancelDoubleClick();
|
|
499
|
+
}
|
|
485
500
|
if (prev?.selectedShapeIds !== next?.selectedShapeIds) {
|
|
486
501
|
const filtered = next.selectedShapeIds.filter((id) => {
|
|
487
502
|
let parentId = this.getShape(id)?.parentId;
|
|
@@ -554,6 +569,9 @@ class Editor extends import_eventemitter3.default {
|
|
|
554
569
|
this.stopFollowingUser();
|
|
555
570
|
}
|
|
556
571
|
this.on("tick", this._flushEventsForTick);
|
|
572
|
+
this.once("mount", () => {
|
|
573
|
+
this.isMounted = true;
|
|
574
|
+
});
|
|
557
575
|
this.timers.requestAnimationFrame(() => {
|
|
558
576
|
this._tickManager.start();
|
|
559
577
|
});
|
|
@@ -648,6 +666,12 @@ class Editor extends import_eventemitter3.default {
|
|
|
648
666
|
* @public
|
|
649
667
|
*/
|
|
650
668
|
isDisposed = false;
|
|
669
|
+
/**
|
|
670
|
+
* Whether the editor is mounted.
|
|
671
|
+
*
|
|
672
|
+
* @public
|
|
673
|
+
*/
|
|
674
|
+
isMounted = false;
|
|
651
675
|
/**
|
|
652
676
|
* A manager for the editor's tick events.
|
|
653
677
|
*
|
|
@@ -4224,7 +4248,21 @@ class Editor extends import_eventemitter3.default {
|
|
|
4224
4248
|
*/
|
|
4225
4249
|
getSelectedShapeAtPoint(point) {
|
|
4226
4250
|
const selectedShapeIds = this.getSelectedShapeIds();
|
|
4227
|
-
|
|
4251
|
+
const margin = this.options.hitTestMargin / this.getZoomLevel();
|
|
4252
|
+
const sortedShapes = this.getCurrentPageShapesSorted();
|
|
4253
|
+
for (let i = sortedShapes.length - 1; i >= 0; i--) {
|
|
4254
|
+
const shape = sortedShapes[i];
|
|
4255
|
+
if (shape.type === "group") continue;
|
|
4256
|
+
if (!selectedShapeIds.includes(shape.id)) continue;
|
|
4257
|
+
if (this.getShapeGeometry(shape).hitTestPoint(
|
|
4258
|
+
this.getPointInShapeSpace(shape, point),
|
|
4259
|
+
margin,
|
|
4260
|
+
true
|
|
4261
|
+
)) {
|
|
4262
|
+
return shape;
|
|
4263
|
+
}
|
|
4264
|
+
}
|
|
4265
|
+
return void 0;
|
|
4228
4266
|
}
|
|
4229
4267
|
/**
|
|
4230
4268
|
* Get the shape at the current point.
|