@tldraw/editor 5.3.0-canary.821283682ad4 → 5.3.0-canary.bd7224e87f5d

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.
@@ -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.821283682ad4",
382
+ "5.3.0-canary.bd7224e87f5d",
383
383
  "cjs"
384
384
  );
385
385
  //# sourceMappingURL=index.js.map
@@ -273,12 +273,16 @@ 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(() => {
279
280
  deletedShapeIds.clear();
281
+ const justCreatedShapeIds = new Set(createdShapes);
282
+ createdShapes.clear();
280
283
  for (const parentId of invalidParents) {
281
284
  invalidParents.delete(parentId);
285
+ if (justCreatedShapeIds.has(parentId)) continue;
282
286
  const parent = this.getShape(parentId);
283
287
  if (!parent) continue;
284
288
  const util = this.getShapeUtil(parent);
@@ -308,6 +312,12 @@ class Editor extends import_eventemitter3.default {
308
312
  this.disposables.add(
309
313
  this.sideEffects.register({
310
314
  shape: {
315
+ afterCreate: (shape) => {
316
+ createdShapes.add(shape.id);
317
+ if (shape.parentId && (0, import_tlschema.isShapeId)(shape.parentId)) {
318
+ invalidParents.add(shape.parentId);
319
+ }
320
+ },
311
321
  afterChange: (shapeBefore, shapeAfter) => {
312
322
  for (const binding of this.getBindingsInvolvingShape(shapeAfter)) {
313
323
  invalidBindingTypes.add(binding.type);
@@ -482,6 +492,9 @@ class Editor extends import_eventemitter3.default {
482
492
  },
483
493
  instance_page_state: {
484
494
  afterChange: (prev, next) => {
495
+ if (prev?.focusedGroupId !== next?.focusedGroupId) {
496
+ this.cancelDoubleClick();
497
+ }
485
498
  if (prev?.selectedShapeIds !== next?.selectedShapeIds) {
486
499
  const filtered = next.selectedShapeIds.filter((id) => {
487
500
  let parentId = this.getShape(id)?.parentId;
@@ -554,6 +567,9 @@ class Editor extends import_eventemitter3.default {
554
567
  this.stopFollowingUser();
555
568
  }
556
569
  this.on("tick", this._flushEventsForTick);
570
+ this.once("mount", () => {
571
+ this.isMounted = true;
572
+ });
557
573
  this.timers.requestAnimationFrame(() => {
558
574
  this._tickManager.start();
559
575
  });
@@ -648,6 +664,12 @@ class Editor extends import_eventemitter3.default {
648
664
  * @public
649
665
  */
650
666
  isDisposed = false;
667
+ /**
668
+ * Whether the editor is mounted.
669
+ *
670
+ * @public
671
+ */
672
+ isMounted = false;
651
673
  /**
652
674
  * A manager for the editor's tick events.
653
675
  *
@@ -4224,7 +4246,21 @@ class Editor extends import_eventemitter3.default {
4224
4246
  */
4225
4247
  getSelectedShapeAtPoint(point) {
4226
4248
  const selectedShapeIds = this.getSelectedShapeIds();
4227
- return this.getCurrentPageShapesSorted().filter((shape) => shape.type !== "group" && selectedShapeIds.includes(shape.id)).reverse().find((shape) => this.isPointInShape(shape, point, { hitInside: true, margin: 0 }));
4249
+ const margin = this.options.hitTestMargin / this.getZoomLevel();
4250
+ const sortedShapes = this.getCurrentPageShapesSorted();
4251
+ for (let i = sortedShapes.length - 1; i >= 0; i--) {
4252
+ const shape = sortedShapes[i];
4253
+ if (shape.type === "group") continue;
4254
+ if (!selectedShapeIds.includes(shape.id)) continue;
4255
+ if (this.getShapeGeometry(shape).hitTestPoint(
4256
+ this.getPointInShapeSpace(shape, point),
4257
+ margin,
4258
+ true
4259
+ )) {
4260
+ return shape;
4261
+ }
4262
+ }
4263
+ return void 0;
4228
4264
  }
4229
4265
  /**
4230
4266
  * Get the shape at the current point.