@tldraw/editor 5.6.0 → 5.7.0-canary.04258659f7da

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 (31) hide show
  1. package/dist-cjs/index.d.ts +19 -1
  2. package/dist-cjs/index.js +1 -1
  3. package/dist-cjs/lib/editor/Editor.js +11 -4
  4. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  5. package/dist-cjs/lib/editor/shapes/ShapeUtil.js +11 -0
  6. package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
  7. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +11 -0
  8. package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
  9. package/dist-cjs/lib/license/LicenseManager.js +6 -1
  10. package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
  11. package/dist-cjs/version.js +3 -3
  12. package/dist-cjs/version.js.map +1 -1
  13. package/dist-esm/index.d.mts +19 -1
  14. package/dist-esm/index.mjs +1 -1
  15. package/dist-esm/lib/editor/Editor.mjs +11 -4
  16. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  17. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +11 -0
  18. package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
  19. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +11 -0
  20. package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
  21. package/dist-esm/lib/license/LicenseManager.mjs +6 -1
  22. package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
  23. package/dist-esm/version.mjs +3 -3
  24. package/dist-esm/version.mjs.map +1 -1
  25. package/package.json +7 -7
  26. package/src/lib/editor/Editor.ts +11 -4
  27. package/src/lib/editor/shapes/ShapeUtil.ts +12 -0
  28. package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +14 -0
  29. package/src/lib/license/LicenseManager.test.ts +31 -0
  30. package/src/lib/license/LicenseManager.ts +8 -1
  31. package/src/version.ts +3 -3
@@ -2310,7 +2310,7 @@ export class Editor extends EventEmitter<TLEventMap> {
2310
2310
  const filteredShapes = this.getCurrentPageShapes().filter((shape) =>
2311
2311
  isSelectedWithinContainer ? shape.parentId === firstParentId : isPageId(shape.parentId)
2312
2312
  )
2313
- const readingOrderShapes = this._getShapesInReadingOrder(filteredShapes)
2313
+ const readingOrderShapes = this.getShapesInReadingOrder(filteredShapes)
2314
2314
  const currentShapeId: TLShapeId | undefined =
2315
2315
  selectedShapeIds.length === 1
2316
2316
  ? selectedShapeIds[0]
@@ -2351,10 +2351,17 @@ export class Editor extends EventEmitter<TLEventMap> {
2351
2351
  */
2352
2352
  @computed getCurrentPageShapesInReadingOrder(): TLShape[] {
2353
2353
  const shapes = this.getCurrentPageShapes().filter((shape) => isPageId(shape.parentId))
2354
- return this._getShapesInReadingOrder(shapes)
2354
+ return this.getShapesInReadingOrder(shapes)
2355
2355
  }
2356
2356
 
2357
- private _getShapesInReadingOrder(shapes: TLShape[]): TLShape[] {
2357
+ /**
2358
+ * Sort the given shapes into reading order (left-to-right, top-to-bottom), dropping any that
2359
+ * can't be tabbed to. Use this for the children of a frame or group, which
2360
+ * {@link Editor.getCurrentPageShapesInReadingOrder} leaves out.
2361
+ *
2362
+ * @public
2363
+ */
2364
+ getShapesInReadingOrder(shapes: TLShape[]): TLShape[] {
2358
2365
  const SHALLOW_ANGLE = 20
2359
2366
  const ROW_THRESHOLD = 100
2360
2367
 
@@ -2521,7 +2528,7 @@ export class Editor extends EventEmitter<TLEventMap> {
2521
2528
  const children = compact(
2522
2529
  this.getSortedChildIdsForParent(selectedShape.id).map((id) => this.getShape(id))
2523
2530
  )
2524
- const sortedChildren = this._getShapesInReadingOrder(children)
2531
+ const sortedChildren = this.getShapesInReadingOrder(children)
2525
2532
  if (sortedChildren.length === 0) return
2526
2533
  this._selectShapesAndZoom([sortedChildren[0].id])
2527
2534
  }
@@ -367,6 +367,18 @@ export abstract class ShapeUtil<Shape extends TLShape = TLShape> {
367
367
  return false
368
368
  }
369
369
 
370
+ /**
371
+ * Whether flipping changes the shape itself, by mirroring it or toggling its stored flip. The
372
+ * default UI only offers flip for a lone selected shape when this is true; {@link Editor.flipShapes}
373
+ * doesn't check it, so shapes that return false still move when flipped as part of a larger
374
+ * selection. Use {@link ShapeUtil.canBeLaidOut} to opt out of that.
375
+ *
376
+ * @public
377
+ */
378
+ canFlip(shape: Shape): boolean {
379
+ return false
380
+ }
381
+
370
382
  /**
371
383
  * Whether the shape can participate in layout functions such as alignment or distribution.
372
384
  *
@@ -1,5 +1,6 @@
1
1
  import { TLGroupShape, groupShapeMigrations, groupShapeProps } from '@tldraw/tlschema'
2
2
  import { SVGContainer } from '../../../components/SVGContainer'
3
+ import { defineMessages, translateMessage } from '../../../config/TLI18n'
3
4
  import { Geometry2d } from '../../../primitives/geometry/Geometry2d'
4
5
  import { Group2d } from '../../../primitives/geometry/Group2d'
5
6
  import { Rectangle2d } from '../../../primitives/geometry/Rectangle2d'
@@ -7,16 +8,29 @@ import { ShapeUtil } from '../ShapeUtil'
7
8
  import { getPerfectDashProps } from '../shared/getPerfectDashProps'
8
9
  import { DashedOutlineBox } from './DashedOutlineBox'
9
10
 
11
+ const messages = defineMessages({
12
+ name: { id: 'a11y.shape-group', defaultMessage: 'Group' },
13
+ })
14
+
10
15
  /** @public */
11
16
  export class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
12
17
  static override type = 'group' as const
13
18
  static override props = groupShapeProps
14
19
  static override migrations = groupShapeMigrations
15
20
 
21
+ // Groups have no tool of their own, so there's no `tool.group` label to fall back on.
22
+ override getShapeName() {
23
+ return translateMessage(this.editor.i18n(), messages.name)
24
+ }
25
+
16
26
  override hideSelectionBoundsFg(shape: TLGroupShape) {
17
27
  return true
18
28
  }
19
29
 
30
+ override canFlip() {
31
+ return true
32
+ }
33
+
20
34
  override canBind() {
21
35
  return false
22
36
  }
@@ -760,6 +760,37 @@ describe('LicenseManager', () => {
760
760
  }
761
761
  })
762
762
 
763
+ it('Licenses our VS Code extension webview when no key is provided', async () => {
764
+ const manager = await createManagerOnHost(
765
+ 'vscode-webview://1ipd8pun8ud7nd7hv9d112g7evi7m10vak9vviuvia66ou6aibp3/index.html?id=6ec2dc7a-afe9-45d9-bd71-1749f9568d28&swVersion=4&extensionId=tldraw-org.tldraw-vscode&platform=electron'
766
+ )
767
+
768
+ expect(await manager.getLicenseFromKey('')).toMatchObject({
769
+ isLicenseParseable: true,
770
+ isDomainValid: true,
771
+ isLicensedWithWatermark: true,
772
+ })
773
+ expect(manager.state.get()).toBe('licensed-with-watermark')
774
+ manager.dispose()
775
+ })
776
+
777
+ it('Does not license other VS Code extension webviews', async () => {
778
+ const urls = [
779
+ 'vscode-webview://abc/index.html?extensionId=evil-org.evil-vscode&x=tldraw-org.tldraw-vscode',
780
+ 'vscode-webview://tldraw-org.tldraw-vscode/index.html?extensionId=evil-org.evil-vscode',
781
+ ]
782
+
783
+ for (const url of urls) {
784
+ const manager = await createManagerOnHost(url)
785
+
786
+ expect(await manager.getLicenseFromKey('')).toMatchObject({
787
+ isLicenseParseable: false,
788
+ reason: 'no-key-provided',
789
+ })
790
+ manager.dispose()
791
+ }
792
+ })
793
+
763
794
  it('Never sends a watermark tracking ping for our own domains', async () => {
764
795
  const manager = await createManagerOnHost('https://makereal.tldraw.com')
765
796
 
@@ -59,6 +59,9 @@ const CANONICAL_TLDRAW_HOSTS = [
59
59
  'tldraw.xyz',
60
60
  ]
61
61
 
62
+ /** Our VS Code extension, whose webviews are served from `vscode-webview:` with a random hostname. */
63
+ const CANONICAL_VSCODE_EXTENSION_ID = 'tldraw-org.tldraw-vscode'
64
+
62
65
  /** Marks a license as the keyless canonical-host grant, which is never tracked. */
63
66
  const CANONICAL_HOST_LICENSE_ID = 'tldraw-canonical-host'
64
67
 
@@ -237,8 +240,12 @@ export class LicenseManager {
237
240
  return host === 'localhost' || host === '::1' || /^127(?:\.\d{1,3}){3}$/.test(host)
238
241
  }
239
242
 
240
- /** Whether the page is served from one of tldraw's own domains, or a subdomain of one. */
243
+ /** Whether the page is served from one of tldraw's own domains, a subdomain of one, or our VS Code extension. */
241
244
  private isCanonicalTldrawHost() {
245
+ if (window.location.protocol === 'vscode-webview:') {
246
+ const extensionId = new URL(window.location.href).searchParams.get('extensionId')
247
+ return extensionId === CANONICAL_VSCODE_EXTENSION_ID
248
+ }
242
249
  const hostname = window.location.hostname.toLowerCase()
243
250
  return CANONICAL_TLDRAW_HOSTS.some((host) => hostname === host || hostname.endsWith(`.${host}`))
244
251
  }
package/src/version.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  // This file is automatically generated by internal/scripts/refresh-assets.ts.
2
2
  // Do not edit manually. Or do, I'm a comment, not a cop.
3
3
 
4
- export const version = '5.6.0'
4
+ export const version = '5.7.0-canary.04258659f7da'
5
5
  export const publishDates = {
6
6
  major: '2026-05-06T16:28:18.473Z',
7
- minor: '2026-10-28T14:20:57.238Z',
8
- patch: '2026-10-28T14:20:57.238Z',
7
+ minor: '2026-11-10T11:55:47.956Z',
8
+ patch: '2026-11-10T11:55:47.956Z',
9
9
  }