@tldraw/editor 3.13.0-canary.be59c37b047e → 3.13.0-canary.c0afd1f5aa1e
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 +14 -1
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +45 -9
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +0 -3
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.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 +14 -1
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +45 -9
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +0 -3
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +5 -0
- package/package.json +7 -7
- package/src/lib/components/default-components/DefaultCanvas.tsx +2 -1
- package/src/lib/editor/Editor.ts +56 -9
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +0 -4
- package/src/version.ts +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/editor/shapes/group/GroupShapeUtil.tsx"],
|
|
4
|
-
"sourcesContent": ["import { TLGroupShape, groupShapeMigrations, groupShapeProps } from '@tldraw/tlschema'\nimport { SVGContainer } from '../../../components/SVGContainer'\nimport { Geometry2d } from '../../../primitives/geometry/Geometry2d'\nimport { Group2d } from '../../../primitives/geometry/Group2d'\nimport { Rectangle2d } from '../../../primitives/geometry/Rectangle2d'\nimport { ShapeUtil } from '../ShapeUtil'\nimport { DashedOutlineBox } from './DashedOutlineBox'\n\n/** @public */\nexport class GroupShapeUtil extends ShapeUtil<TLGroupShape> {\n\tstatic override type = 'group' as const\n\tstatic override props = groupShapeProps\n\tstatic override migrations = groupShapeMigrations\n\n\toverride
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { TLGroupShape, groupShapeMigrations, groupShapeProps } from '@tldraw/tlschema'\nimport { SVGContainer } from '../../../components/SVGContainer'\nimport { Geometry2d } from '../../../primitives/geometry/Geometry2d'\nimport { Group2d } from '../../../primitives/geometry/Group2d'\nimport { Rectangle2d } from '../../../primitives/geometry/Rectangle2d'\nimport { ShapeUtil } from '../ShapeUtil'\nimport { DashedOutlineBox } from './DashedOutlineBox'\n\n/** @public */\nexport class GroupShapeUtil extends ShapeUtil<TLGroupShape> {\n\tstatic override type = 'group' as const\n\tstatic override props = groupShapeProps\n\tstatic override migrations = groupShapeMigrations\n\n\toverride hideSelectionBoundsFg() {\n\t\treturn true\n\t}\n\n\toverride canBind() {\n\t\treturn false\n\t}\n\n\tgetDefaultProps(): TLGroupShape['props'] {\n\t\treturn {}\n\t}\n\n\tgetGeometry(shape: TLGroupShape): Geometry2d {\n\t\tconst children = this.editor.getSortedChildIdsForParent(shape.id)\n\t\tif (children.length === 0) {\n\t\t\treturn new Rectangle2d({ width: 1, height: 1, isFilled: false })\n\t\t}\n\n\t\treturn new Group2d({\n\t\t\tchildren: children.map((childId) => {\n\t\t\t\tconst shape = this.editor.getShape(childId)!\n\t\t\t\treturn this.editor\n\t\t\t\t\t.getShapeGeometry(childId)\n\t\t\t\t\t.transform(this.editor.getShapeLocalTransform(shape)!, { isLabel: false })\n\t\t\t}),\n\t\t})\n\t}\n\n\tcomponent(shape: TLGroupShape) {\n\t\tconst isErasing = this.editor.getErasingShapeIds().includes(shape.id)\n\n\t\tconst { hintingShapeIds } = this.editor.getCurrentPageState()\n\t\tconst isHintingOtherGroup =\n\t\t\thintingShapeIds.length > 0 &&\n\t\t\thintingShapeIds.some(\n\t\t\t\t(id) =>\n\t\t\t\t\tid !== shape.id &&\n\t\t\t\t\tthis.editor.isShapeOfType<TLGroupShape>(this.editor.getShape(id)!, 'group')\n\t\t\t)\n\n\t\tconst isFocused = this.editor.getCurrentPageState().focusedGroupId !== shape.id\n\n\t\tif (\n\t\t\t!isErasing && // always show the outline while we're erasing the group\n\t\t\t// show the outline while the group is focused unless something outside of the group is being hinted\n\t\t\t// this happens dropping shapes from a group onto some outside group\n\t\t\t(isFocused || isHintingOtherGroup)\n\t\t) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst bounds = this.editor.getShapeGeometry(shape).bounds\n\n\t\treturn (\n\t\t\t<SVGContainer>\n\t\t\t\t<DashedOutlineBox className=\"tl-group\" bounds={bounds} />\n\t\t\t</SVGContainer>\n\t\t)\n\t}\n\n\tindicator(shape: TLGroupShape) {\n\t\t// Not a class component, but eslint can't tell that :(\n\t\tconst bounds = this.editor.getShapeGeometry(shape).bounds\n\t\treturn <DashedOutlineBox className=\"\" bounds={bounds} />\n\t}\n\n\toverride onChildrenChange(group: TLGroupShape) {\n\t\tconst children = this.editor.getSortedChildIdsForParent(group.id)\n\t\tif (children.length === 0) {\n\t\t\tif (this.editor.getCurrentPageState().focusedGroupId === group.id) {\n\t\t\t\tthis.editor.popFocusedGroupId()\n\t\t\t}\n\t\t\tthis.editor.deleteShapes([group.id])\n\t\t\treturn\n\t\t} else if (children.length === 1) {\n\t\t\tif (this.editor.getCurrentPageState().focusedGroupId === group.id) {\n\t\t\t\tthis.editor.popFocusedGroupId()\n\t\t\t}\n\t\t\tthis.editor.reparentShapes(children, group.parentId)\n\t\t\tthis.editor.deleteShapes([group.id])\n\t\t\treturn\n\t\t}\n\t}\n}\n"],
|
|
5
|
+
"m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A;AAAA,KAGA,aAAa,sBACb;AACD,aAAO;AAAA,IACR;AAEA,UAAM,SAAS,KAAK,OAAO,iBAAiB,KAAK,EAAE;AAEnD,WACC,oBAAC,gBACA,8BAAC,oBAAiB,WAAU,YAAW,QAAgB,GACxD;AAAA,EAEF;AAAA,EAEA,UAAU,OAAqB;AAE9B,UAAM,SAAS,KAAK,OAAO,iBAAiB,KAAK,EAAE;AACnD,WAAO,oBAAC,oBAAiB,WAAU,IAAG,QAAgB;AAAA,EACvD;AAAA,EAES,iBAAiB,OAAqB;AAC9C,UAAM,WAAW,KAAK,OAAO,2BAA2B,MAAM,EAAE;AAChE,QAAI,SAAS,WAAW,GAAG;AAC1B,UAAI,KAAK,OAAO,oBAAoB,EAAE,mBAAmB,MAAM,IAAI;AAClE,aAAK,OAAO,kBAAkB;AAAA,MAC/B;AACA,WAAK,OAAO,aAAa,CAAC,MAAM,EAAE,CAAC;AACnC;AAAA,IACD,WAAW,SAAS,WAAW,GAAG;AACjC,UAAI,KAAK,OAAO,oBAAoB,EAAE,mBAAmB,MAAM,IAAI;AAClE,aAAK,OAAO,kBAAkB;AAAA,MAC/B;AACA,WAAK,OAAO,eAAe,UAAU,MAAM,QAAQ;AACnD,WAAK,OAAO,aAAa,CAAC,MAAM,EAAE,CAAC;AACnC;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["shape"]
|
|
7
7
|
}
|
package/dist-esm/version.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const version = "3.13.0-canary.
|
|
1
|
+
const version = "3.13.0-canary.c0afd1f5aa1e";
|
|
2
2
|
const publishDates = {
|
|
3
3
|
major: "2024-09-13T14:36:29.063Z",
|
|
4
|
-
minor: "2025-05-
|
|
5
|
-
patch: "2025-05-
|
|
4
|
+
minor: "2025-05-13T10:34:53.973Z",
|
|
5
|
+
patch: "2025-05-13T10:34:53.973Z"
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
8
|
publishDates,
|
package/dist-esm/version.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.13.0-canary.
|
|
4
|
+
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.13.0-canary.c0afd1f5aa1e'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-05-13T10:34:53.973Z',\n\tpatch: '2025-05-13T10:34:53.973Z',\n}\n"],
|
|
5
5
|
"mappings": "AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/editor.css
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tldraw/editor",
|
|
3
3
|
"description": "A tiny little drawing app (editor).",
|
|
4
|
-
"version": "3.13.0-canary.
|
|
4
|
+
"version": "3.13.0-canary.c0afd1f5aa1e",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"@tiptap/core": "^2.9.1",
|
|
49
49
|
"@tiptap/pm": "^2.9.1",
|
|
50
50
|
"@tiptap/react": "^2.9.1",
|
|
51
|
-
"@tldraw/state": "3.13.0-canary.
|
|
52
|
-
"@tldraw/state-react": "3.13.0-canary.
|
|
53
|
-
"@tldraw/store": "3.13.0-canary.
|
|
54
|
-
"@tldraw/tlschema": "3.13.0-canary.
|
|
55
|
-
"@tldraw/utils": "3.13.0-canary.
|
|
56
|
-
"@tldraw/validate": "3.13.0-canary.
|
|
51
|
+
"@tldraw/state": "3.13.0-canary.c0afd1f5aa1e",
|
|
52
|
+
"@tldraw/state-react": "3.13.0-canary.c0afd1f5aa1e",
|
|
53
|
+
"@tldraw/store": "3.13.0-canary.c0afd1f5aa1e",
|
|
54
|
+
"@tldraw/tlschema": "3.13.0-canary.c0afd1f5aa1e",
|
|
55
|
+
"@tldraw/utils": "3.13.0-canary.c0afd1f5aa1e",
|
|
56
|
+
"@tldraw/validate": "3.13.0-canary.c0afd1f5aa1e",
|
|
57
57
|
"@types/core-js": "^2.5.8",
|
|
58
58
|
"@use-gesture/react": "^10.3.1",
|
|
59
59
|
"classnames": "^2.5.1",
|
|
@@ -365,7 +365,8 @@ function HandleWrapper({
|
|
|
365
365
|
return (
|
|
366
366
|
<g
|
|
367
367
|
role="button"
|
|
368
|
-
|
|
368
|
+
// TODO(mime): handle.label needs to be required in the future.
|
|
369
|
+
aria-label={handle.label || 'handle'}
|
|
369
370
|
transform={`translate(${handle.x}, ${handle.y})`}
|
|
370
371
|
{...events}
|
|
371
372
|
>
|
package/src/lib/editor/Editor.ts
CHANGED
|
@@ -1815,9 +1815,28 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
1815
1815
|
return this
|
|
1816
1816
|
}
|
|
1817
1817
|
|
|
1818
|
+
/**
|
|
1819
|
+
* Select the next shape in the reading order or in cardinal order.
|
|
1820
|
+
*
|
|
1821
|
+
* @example
|
|
1822
|
+
* ```ts
|
|
1823
|
+
* editor.selectAdjacentShape('next')
|
|
1824
|
+
* ```
|
|
1825
|
+
*
|
|
1826
|
+
* @public
|
|
1827
|
+
*/
|
|
1818
1828
|
selectAdjacentShape(direction: TLAdjacentDirection) {
|
|
1819
|
-
const readingOrderShapes = this.getCurrentPageShapesInReadingOrder()
|
|
1820
1829
|
const selectedShapeIds = this.getSelectedShapeIds()
|
|
1830
|
+
const firstParentId = selectedShapeIds[0] ? this.getShape(selectedShapeIds[0])?.parentId : null
|
|
1831
|
+
const isSelectedWithinContainer =
|
|
1832
|
+
firstParentId &&
|
|
1833
|
+
selectedShapeIds.every((shapeId) => this.getShape(shapeId)?.parentId === firstParentId) &&
|
|
1834
|
+
!isPageId(firstParentId)
|
|
1835
|
+
const readingOrderShapes = isSelectedWithinContainer
|
|
1836
|
+
? this._getShapesInReadingOrder(
|
|
1837
|
+
this.getCurrentPageShapes().filter((shape) => shape.parentId === firstParentId)
|
|
1838
|
+
)
|
|
1839
|
+
: this.getCurrentPageShapesInReadingOrder()
|
|
1821
1840
|
const currentShapeId: TLShapeId | undefined =
|
|
1822
1841
|
selectedShapeIds.length === 1
|
|
1823
1842
|
? selectedShapeIds[0]
|
|
@@ -1839,13 +1858,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
1839
1858
|
const shape = this.getShape(adjacentShapeId)
|
|
1840
1859
|
if (!shape) return
|
|
1841
1860
|
|
|
1842
|
-
this.
|
|
1843
|
-
this.zoomToSelectionIfOffscreen(256, {
|
|
1844
|
-
animation: {
|
|
1845
|
-
duration: this.options.animationMediumMs,
|
|
1846
|
-
},
|
|
1847
|
-
inset: 0,
|
|
1848
|
-
})
|
|
1861
|
+
this._selectShapesAndZoom([shape.id])
|
|
1849
1862
|
}
|
|
1850
1863
|
|
|
1851
1864
|
/**
|
|
@@ -1855,10 +1868,14 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
1855
1868
|
* @public
|
|
1856
1869
|
*/
|
|
1857
1870
|
@computed getCurrentPageShapesInReadingOrder(): TLShape[] {
|
|
1871
|
+
const shapes = this.getCurrentPageShapes().filter((shape) => isPageId(shape.parentId))
|
|
1872
|
+
return this._getShapesInReadingOrder(shapes)
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
private _getShapesInReadingOrder(shapes: TLShape[]): TLShape[] {
|
|
1858
1876
|
const SHALLOW_ANGLE = 20
|
|
1859
1877
|
const ROW_THRESHOLD = 100
|
|
1860
1878
|
|
|
1861
|
-
const shapes = this.getCurrentPageShapes()
|
|
1862
1879
|
const tabbableShapes = shapes.filter((shape) => this.getShapeUtil(shape).canTabTo(shape))
|
|
1863
1880
|
|
|
1864
1881
|
if (tabbableShapes.length <= 1) return tabbableShapes
|
|
@@ -2004,6 +2021,36 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
2004
2021
|
return lowestScoringShape!.shape.id
|
|
2005
2022
|
}
|
|
2006
2023
|
|
|
2024
|
+
selectParentShape() {
|
|
2025
|
+
const selectedShape = this.getOnlySelectedShape()
|
|
2026
|
+
if (!selectedShape) return
|
|
2027
|
+
const parentShape = this.getShape(selectedShape.parentId)
|
|
2028
|
+
if (!parentShape) return
|
|
2029
|
+
this._selectShapesAndZoom([parentShape.id])
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
selectFirstChildShape() {
|
|
2033
|
+
const selectedShapes = this.getSelectedShapes()
|
|
2034
|
+
if (!selectedShapes.length) return
|
|
2035
|
+
const selectedShape = selectedShapes[0]
|
|
2036
|
+
const children = this.getSortedChildIdsForParent(selectedShape.id)
|
|
2037
|
+
.map((id) => this.getShape(id))
|
|
2038
|
+
.filter((i) => i) as TLShape[]
|
|
2039
|
+
const sortedChildren = this._getShapesInReadingOrder(children)
|
|
2040
|
+
if (sortedChildren.length === 0) return
|
|
2041
|
+
this._selectShapesAndZoom([sortedChildren[0].id])
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
private _selectShapesAndZoom(ids: TLShapeId[]) {
|
|
2045
|
+
this.setSelectedShapes(ids)
|
|
2046
|
+
this.zoomToSelectionIfOffscreen(256, {
|
|
2047
|
+
animation: {
|
|
2048
|
+
duration: this.options.animationMediumMs,
|
|
2049
|
+
},
|
|
2050
|
+
inset: 0,
|
|
2051
|
+
})
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2007
2054
|
/**
|
|
2008
2055
|
* Clear the selection.
|
|
2009
2056
|
*
|
|
@@ -12,10 +12,6 @@ export class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
|
|
|
12
12
|
static override props = groupShapeProps
|
|
13
13
|
static override migrations = groupShapeMigrations
|
|
14
14
|
|
|
15
|
-
override canTabTo() {
|
|
16
|
-
return false
|
|
17
|
-
}
|
|
18
|
-
|
|
19
15
|
override hideSelectionBoundsFg() {
|
|
20
16
|
return true
|
|
21
17
|
}
|
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 = '3.13.0-canary.
|
|
4
|
+
export const version = '3.13.0-canary.c0afd1f5aa1e'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-05-
|
|
8
|
-
patch: '2025-05-
|
|
7
|
+
minor: '2025-05-13T10:34:53.973Z',
|
|
8
|
+
patch: '2025-05-13T10:34:53.973Z',
|
|
9
9
|
}
|