@tldraw/editor 4.2.0 → 4.3.0-canary.3811ec6b3dcd
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 +55 -35
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +0 -12
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/bindings/BindingUtil.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/BaseBoxShapeUtil.js.map +1 -1
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +4 -3
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.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 +55 -35
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +0 -12
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/bindings/BindingUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/BaseBoxShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +4 -3
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +10 -10
- package/src/lib/editor/Editor.test.ts +10 -10
- package/src/lib/editor/Editor.ts +81 -59
- package/src/lib/editor/bindings/BindingUtil.ts +15 -9
- package/src/lib/editor/derivations/bindingsIndex.ts +2 -2
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +14 -4
- package/src/lib/editor/managers/SnapManager/SnapManager.ts +3 -3
- package/src/lib/editor/shapes/BaseBoxShapeUtil.tsx +2 -2
- package/src/lib/editor/shapes/ShapeUtil.ts +5 -8
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +1 -3
- package/src/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.ts +2 -1
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +3 -3
- package/src/lib/exports/getSvgJsx.test.ts +10 -19
- package/src/lib/exports/getSvgJsx.tsx +2 -5
- package/src/lib/hooks/useCanvasEvents.ts +4 -3
- package/src/lib/utils/reparenting.ts +5 -5
- package/src/version.ts +3 -3
|
@@ -23,7 +23,7 @@ export class Pointing extends StateNode {
|
|
|
23
23
|
const newPoint = maybeSnapToGrid(originPagePoint, editor)
|
|
24
24
|
|
|
25
25
|
// Allow this to trigger the max shapes reached alert
|
|
26
|
-
this.editor.createShapes
|
|
26
|
+
this.editor.createShapes([
|
|
27
27
|
{
|
|
28
28
|
id,
|
|
29
29
|
type: shapeType,
|
|
@@ -88,7 +88,7 @@ export class Pointing extends StateNode {
|
|
|
88
88
|
|
|
89
89
|
// Allow this to trigger the max shapes reached alert
|
|
90
90
|
// todo: add scale here when dynamic size is enabled (is this still needed?)
|
|
91
|
-
this.editor.createShapes
|
|
91
|
+
this.editor.createShapes([
|
|
92
92
|
{
|
|
93
93
|
id,
|
|
94
94
|
type: shapeType,
|
|
@@ -127,7 +127,7 @@ export class Pointing extends StateNode {
|
|
|
127
127
|
;(next as TLBaseBoxShape & { props: { scale: number } }).props.scale = scale
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
this.editor.updateShape
|
|
130
|
+
this.editor.updateShape(next)
|
|
131
131
|
|
|
132
132
|
this.editor.setSelectedShapes([id])
|
|
133
133
|
|
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Geometry2d,
|
|
3
|
-
RecordProps,
|
|
4
|
-
Rectangle2d,
|
|
5
|
-
ShapeUtil,
|
|
6
|
-
T,
|
|
7
|
-
TLBaseShape,
|
|
8
|
-
createShapeId,
|
|
9
|
-
} from '../..'
|
|
1
|
+
import { Geometry2d, RecordProps, Rectangle2d, ShapeUtil, T, TLShape, createShapeId } from '../..'
|
|
10
2
|
import { createTLStore } from '../config/createTLStore'
|
|
11
3
|
import { Editor } from '../editor/Editor'
|
|
12
4
|
import { Box } from '../primitives/Box'
|
|
13
5
|
import { getExportDefaultBounds } from './getSvgJsx'
|
|
14
6
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
h: number
|
|
20
|
-
x: number
|
|
21
|
-
y: number
|
|
22
|
-
isContainer?: boolean
|
|
7
|
+
const TEST_SHAPE_TYPE = 'test-shape'
|
|
8
|
+
|
|
9
|
+
declare module '@tldraw/tlschema' {
|
|
10
|
+
export interface TLGlobalShapePropsMap {
|
|
11
|
+
[TEST_SHAPE_TYPE]: { w: number; h: number; x: number; y: number; isContainer?: boolean }
|
|
23
12
|
}
|
|
24
|
-
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type ITestShape = TLShape<typeof TEST_SHAPE_TYPE>
|
|
25
16
|
|
|
26
17
|
class TestShape extends ShapeUtil<ITestShape> {
|
|
27
|
-
static override type =
|
|
18
|
+
static override type = TEST_SHAPE_TYPE
|
|
28
19
|
static override props: RecordProps<ITestShape> = {
|
|
29
20
|
w: T.number,
|
|
30
21
|
h: T.number,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useAtom, useValue } from '@tldraw/state-react'
|
|
2
2
|
import {
|
|
3
3
|
TLFrameShape,
|
|
4
|
-
TLGroupShape,
|
|
5
4
|
TLShape,
|
|
6
5
|
TLShapeId,
|
|
7
6
|
getColorValue,
|
|
@@ -58,9 +57,7 @@ export function getSvgJsx(editor: Editor, ids: TLShapeId[], opts: TLImageExportO
|
|
|
58
57
|
|
|
59
58
|
// --- Common bounding box of all shapes
|
|
60
59
|
const singleFrameShapeId =
|
|
61
|
-
ids.length === 1 && editor.isShapeOfType
|
|
62
|
-
? ids[0]
|
|
63
|
-
: null
|
|
60
|
+
ids.length === 1 && editor.isShapeOfType(editor.getShape(ids[0])!, 'frame') ? ids[0] : null
|
|
64
61
|
|
|
65
62
|
let bbox: null | Box = null
|
|
66
63
|
if (opts.bounds) {
|
|
@@ -272,7 +269,7 @@ function SvgExport({
|
|
|
272
269
|
|
|
273
270
|
const shape = editor.getShape(id)!
|
|
274
271
|
|
|
275
|
-
if (editor.isShapeOfType
|
|
272
|
+
if (editor.isShapeOfType(shape, 'group')) return []
|
|
276
273
|
|
|
277
274
|
const elements = []
|
|
278
275
|
const util = editor.getShapeUtil(shape)
|
|
@@ -8,6 +8,7 @@ import { useEditor } from './useEditor'
|
|
|
8
8
|
|
|
9
9
|
export function useCanvasEvents() {
|
|
10
10
|
const editor = useEditor()
|
|
11
|
+
const ownerDocument = editor.getContainer().ownerDocument
|
|
11
12
|
const currentTool = useValue('current tool', () => editor.getCurrentTool(), [editor])
|
|
12
13
|
|
|
13
14
|
const events = useMemo(
|
|
@@ -180,11 +181,11 @@ export function useCanvasEvents() {
|
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
|
|
183
|
-
|
|
184
|
+
ownerDocument.body.addEventListener('pointermove', onPointerMove)
|
|
184
185
|
return () => {
|
|
185
|
-
|
|
186
|
+
ownerDocument.body.removeEventListener('pointermove', onPointerMove)
|
|
186
187
|
}
|
|
187
|
-
}, [editor, currentTool])
|
|
188
|
+
}, [editor, currentTool, ownerDocument])
|
|
188
189
|
|
|
189
190
|
return events
|
|
190
191
|
}
|
|
@@ -95,8 +95,8 @@ export function kickoutOccludedShapes(
|
|
|
95
95
|
if (remainingShapesToReparent.size > 0) {
|
|
96
96
|
// The remaining shapes are going to be reparented to the old parent's containing group, if there was one, or else to the page
|
|
97
97
|
const newParentId =
|
|
98
|
-
editor.findShapeAncestor(prevParent, (s) => editor.isShapeOfType
|
|
99
|
-
|
|
98
|
+
editor.findShapeAncestor(prevParent, (s) => editor.isShapeOfType(s, 'group'))?.id ??
|
|
99
|
+
editor.getCurrentPageId()
|
|
100
100
|
|
|
101
101
|
remainingShapesToReparent.forEach((shape) => {
|
|
102
102
|
if (!parentsToNewChildren[newParentId]) {
|
|
@@ -211,7 +211,7 @@ export function getDroppedShapesToNewParents(
|
|
|
211
211
|
|
|
212
212
|
for (const shape of shapes) {
|
|
213
213
|
const parent = editor.getShapeParent(shape)
|
|
214
|
-
if (parent && editor.isShapeOfType
|
|
214
|
+
if (parent && editor.isShapeOfType(parent, 'group')) {
|
|
215
215
|
if (!movingGroups.has(parent)) {
|
|
216
216
|
movingGroups.add(parent)
|
|
217
217
|
}
|
|
@@ -248,7 +248,7 @@ export function getDroppedShapesToNewParents(
|
|
|
248
248
|
parentCheck: for (let i = potentialParentShapes.length - 1; i >= 0; i--) {
|
|
249
249
|
const parentShape = potentialParentShapes[i]
|
|
250
250
|
const parentShapeContainingGroupId = editor.findShapeAncestor(parentShape, (s) =>
|
|
251
|
-
editor.isShapeOfType
|
|
251
|
+
editor.isShapeOfType(s, 'group')
|
|
252
252
|
)?.id
|
|
253
253
|
|
|
254
254
|
const parentGeometry = editor.getShapeGeometry(parentShape)
|
|
@@ -274,7 +274,7 @@ export function getDroppedShapesToNewParents(
|
|
|
274
274
|
if (!shapeGroupIds.has(shape.id)) {
|
|
275
275
|
shapeGroupIds.set(
|
|
276
276
|
shape.id,
|
|
277
|
-
editor.findShapeAncestor(shape, (s) => editor.isShapeOfType
|
|
277
|
+
editor.findShapeAncestor(shape, (s) => editor.isShapeOfType(s, 'group'))?.id
|
|
278
278
|
)
|
|
279
279
|
}
|
|
280
280
|
|
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 = '4.
|
|
4
|
+
export const version = '4.3.0-canary.3811ec6b3dcd'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2025-09-18T14:39:22.803Z',
|
|
7
|
-
minor: '2025-11-
|
|
8
|
-
patch: '2025-11-
|
|
7
|
+
minor: '2025-11-21T11:43:18.907Z',
|
|
8
|
+
patch: '2025-11-21T11:43:18.907Z',
|
|
9
9
|
}
|