@tldraw/editor 5.5.0-canary.277b26aa4b0a → 5.5.0-canary.2a22fdfebf61

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.
Files changed (36) hide show
  1. package/dist-cjs/index.d.ts +0 -1
  2. package/dist-cjs/index.js +1 -1
  3. package/dist-cjs/lib/editor/Editor.js +10 -24
  4. package/dist-cjs/lib/editor/Editor.js.map +3 -3
  5. package/dist-cjs/lib/editor/derivations/bindingsIndex.js +0 -2
  6. package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +2 -2
  7. package/dist-cjs/lib/exports/ExportDelay.js +2 -10
  8. package/dist-cjs/lib/exports/ExportDelay.js.map +2 -2
  9. package/dist-cjs/lib/exports/getSvgAsImage.js +4 -10
  10. package/dist-cjs/lib/exports/getSvgAsImage.js.map +2 -2
  11. package/dist-cjs/lib/exports/getSvgJsx.js +9 -18
  12. package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
  13. package/dist-cjs/version.js +3 -3
  14. package/dist-cjs/version.js.map +1 -1
  15. package/dist-esm/index.d.mts +0 -1
  16. package/dist-esm/index.mjs +1 -1
  17. package/dist-esm/lib/editor/Editor.mjs +10 -24
  18. package/dist-esm/lib/editor/Editor.mjs.map +3 -3
  19. package/dist-esm/lib/editor/derivations/bindingsIndex.mjs +0 -2
  20. package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +2 -2
  21. package/dist-esm/lib/exports/ExportDelay.mjs +3 -11
  22. package/dist-esm/lib/exports/ExportDelay.mjs.map +2 -2
  23. package/dist-esm/lib/exports/getSvgAsImage.mjs +4 -10
  24. package/dist-esm/lib/exports/getSvgAsImage.mjs.map +2 -2
  25. package/dist-esm/lib/exports/getSvgJsx.mjs +9 -18
  26. package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
  27. package/dist-esm/version.mjs +3 -3
  28. package/dist-esm/version.mjs.map +1 -1
  29. package/package.json +7 -7
  30. package/src/lib/editor/Editor.ts +14 -35
  31. package/src/lib/editor/derivations/bindingsIndex.ts +0 -3
  32. package/src/lib/exports/ExportDelay.tsx +4 -16
  33. package/src/lib/exports/getSvgAsImage.ts +5 -13
  34. package/src/lib/exports/getSvgJsx.test.ts +1 -43
  35. package/src/lib/exports/getSvgJsx.tsx +16 -28
  36. package/src/version.ts +3 -3
@@ -3483,7 +3483,6 @@ export declare class Editor extends EventEmitter<TLEventMap> {
3483
3483
  deleteBindings(bindings: (TLBinding | TLBindingId)[], { isolateShapes }?: {
3484
3484
  isolateShapes?: boolean | undefined;
3485
3485
  }): this;
3486
- /* Excluded from this release type: _deleteBindings */
3487
3486
  /**
3488
3487
  * Delete a binding by its ID. If the binding doesn't exist, it's ignored.
3489
3488
  */
package/dist-cjs/index.js CHANGED
@@ -392,7 +392,7 @@ var import_uniq = require("./lib/utils/uniq");
392
392
  var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
393
393
  (0, import_utils.registerTldrawLibraryVersion)(
394
394
  "@tldraw/editor",
395
- "5.5.0-canary.277b26aa4b0a",
395
+ "5.5.0-canary.2a22fdfebf61",
396
396
  "cjs"
397
397
  );
398
398
  //# sourceMappingURL=index.js.map
@@ -421,7 +421,7 @@ class Editor extends import_eventemitter3.default {
421
421
  }
422
422
  }
423
423
  if (deleteBindingIds.length) {
424
- this.store.remove(deleteBindingIds);
424
+ this.deleteBindings(deleteBindingIds);
425
425
  }
426
426
  }
427
427
  },
@@ -1381,7 +1381,6 @@ class Editor extends import_eventemitter3.default {
1381
1381
  * @public
1382
1382
  **/
1383
1383
  updateDocumentSettings(settings) {
1384
- if (this.getIsReadonly()) return this;
1385
1384
  this.run(
1386
1385
  () => {
1387
1386
  this.store.put([{ ...this.getDocumentSettings(), ...settings }]);
@@ -4872,7 +4871,6 @@ class Editor extends import_eventemitter3.default {
4872
4871
  * binding, but the `type`, `toId`, and `fromId` must all be provided.
4873
4872
  */
4874
4873
  createBindings(partials) {
4875
- if (this.getIsReadonly()) return this;
4876
4874
  const bindings = [];
4877
4875
  for (const partial of partials) {
4878
4876
  const fromShape = this.getShape(partial.fromId);
@@ -4907,7 +4905,6 @@ class Editor extends import_eventemitter3.default {
4907
4905
  * binding is skipped. The changes from the partial are merged into the existing record.
4908
4906
  */
4909
4907
  updateBindings(partials) {
4910
- if (this.getIsReadonly()) return this;
4911
4908
  const updated = [];
4912
4909
  for (const partial of partials) {
4913
4910
  if (!partial) continue;
@@ -4936,16 +4933,6 @@ class Editor extends import_eventemitter3.default {
4936
4933
  * Delete several bindings by their IDs. If a binding ID doesn't exist, it's ignored.
4937
4934
  */
4938
4935
  deleteBindings(bindings, { isolateShapes = false } = {}) {
4939
- if (this.getIsReadonly()) return this;
4940
- return this._deleteBindings(bindings, { isolateShapes });
4941
- }
4942
- /**
4943
- * Unguarded so that withIsolatedShapes can transiently isolate shapes for copy and export in
4944
- * readonly mode; the public deleteBindings is what readonly blocks.
4945
- *
4946
- * @internal
4947
- */
4948
- _deleteBindings(bindings, { isolateShapes = false } = {}) {
4949
4936
  const ids = bindings.map((binding) => typeof binding === "string" ? binding : binding.id);
4950
4937
  if (isolateShapes) {
4951
4938
  this.store.atomic(() => {
@@ -6384,6 +6371,7 @@ class Editor extends import_eventemitter3.default {
6384
6371
  }
6385
6372
  if (this.getIsReadonly()) return this;
6386
6373
  const ids = typeof shapes[0] === "string" ? shapes : shapes.map((s) => s.id);
6374
+ if (ids.length <= 1) return this;
6387
6375
  const shapesToGroup = (0, import_utils.compact)(
6388
6376
  (this._shouldIgnoreShapeLock ? ids : this._getUnlockedShapeIds(ids)).map(
6389
6377
  (id) => this.getShape(id)
@@ -6398,11 +6386,8 @@ class Editor extends import_eventemitter3.default {
6398
6386
  }
6399
6387
  const { x, y } = pageBounds.point;
6400
6388
  const parentId = this.findCommonAncestor(shapesToGroup) ?? this.getCurrentPageId();
6401
- if (!this.canCreateShapes([groupId])) {
6402
- alertMaxShapes(this);
6403
- return this;
6404
- }
6405
- if (this.isIn("select") && !this.isIn("select.idle")) {
6389
+ if (this.getCurrentToolId() !== "select") return this;
6390
+ if (!this.isIn("select.idle")) {
6406
6391
  this.cancel();
6407
6392
  }
6408
6393
  const shapesWithRootParent = shapesToGroup.filter((shape) => shape.parentId === parentId).sort(import_utils.sortByIndex);
@@ -6437,7 +6422,8 @@ class Editor extends import_eventemitter3.default {
6437
6422
  )
6438
6423
  );
6439
6424
  if (shapesToUngroup.length === 0) return this;
6440
- if (this.isIn("select") && !this.isIn("select.idle")) {
6425
+ if (this.getCurrentToolId() !== "select") return this;
6426
+ if (!this.isIn("select.idle")) {
6441
6427
  this.cancel();
6442
6428
  }
6443
6429
  const idsToSelect = /* @__PURE__ */ new Set();
@@ -6451,16 +6437,16 @@ class Editor extends import_eventemitter3.default {
6451
6437
  });
6452
6438
  if (groups.length === 0) return this;
6453
6439
  this.run(() => {
6440
+ let group;
6454
6441
  for (let i = 0, n = groups.length; i < n; i++) {
6455
- const group = this.getShape(groups[i].id);
6456
- if (!group) continue;
6442
+ group = groups[i];
6457
6443
  const childIds = this.getSortedChildIdsForParent(group.id);
6458
6444
  for (let j = 0, n2 = childIds.length; j < n2; j++) {
6459
6445
  idsToSelect.add(childIds[j]);
6460
6446
  }
6461
6447
  this.reparentShapes(childIds, group.parentId, group.index);
6462
6448
  }
6463
- this.deleteShapes(groups.map((group) => group.id));
6449
+ this.deleteShapes(groups.map((group2) => group2.id));
6464
6450
  if (select) {
6465
6451
  this.select(...idsToSelect);
6466
6452
  }
@@ -8724,7 +8710,7 @@ function withIsolatedShapes(editor, shapeIds, callback) {
8724
8710
  }
8725
8711
  }
8726
8712
  }
8727
- editor._deleteBindings([...bindingsToRemove], { isolateShapes: true });
8713
+ editor.deleteBindings([...bindingsToRemove], { isolateShapes: true });
8728
8714
  try {
8729
8715
  result = import_utils.Result.ok(callback(bindingsWithBoth));
8730
8716
  } catch (error) {