tldraw 4.3.0-canary.fd6b7f2a8adc → 4.3.0-next.2b3bfbba757b
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 +5 -14
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +0 -1
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +4 -1
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +1 -11
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +2 -1
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +0 -8
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
- package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +5 -14
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +0 -1
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +4 -1
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +4 -1
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +4 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +1 -11
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +4 -1
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +2 -1
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs +4 -1
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +0 -8
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/export/exportAs.mjs +3 -1
- package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
- package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +10 -10
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +9 -4
- package/src/lib/defaultExternalContentHandlers.ts +4 -3
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +1 -1
- package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
- package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
- package/src/lib/shapes/arrow/shared.ts +4 -4
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +1 -1
- package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
- package/src/lib/shapes/draw/toolStates/Drawing.ts +4 -4
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +2 -10
- package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
- package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
- package/src/lib/shapes/line/toolStates/Pointing.ts +1 -1
- package/src/lib/shapes/note/NoteShapeTool.test.ts +1 -2
- package/src/lib/shapes/note/noteHelpers.ts +2 -2
- package/src/lib/shapes/shared/PlainTextLabel.tsx +1 -2
- package/src/lib/shapes/shared/RichTextLabel.tsx +1 -2
- package/src/lib/shapes/shared/crop.ts +0 -1
- package/src/lib/shapes/shared/useEditablePlainText.ts +3 -7
- package/src/lib/shapes/shared/useEditableRichText.ts +3 -7
- package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
- package/src/lib/shapes/text/toolStates/Pointing.ts +1 -1
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +5 -3
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +16 -3
- package/src/lib/tools/SelectTool/DragAndDropManager.ts +4 -2
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +6 -2
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +3 -2
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +7 -4
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +4 -2
- package/src/lib/tools/SelectTool/childStates/Idle.ts +10 -6
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +12 -4
- package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +2 -2
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +4 -2
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +4 -2
- package/src/lib/tools/SelectTool/childStates/Translating.ts +3 -1
- package/src/lib/ui/components/EditLinkDialog.tsx +6 -16
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
- package/src/lib/ui/components/menu-items.tsx +14 -6
- package/src/lib/ui/context/actions.tsx +13 -9
- package/src/lib/ui/hooks/menu-hooks.ts +19 -9
- package/src/lib/ui/hooks/useFlatten.ts +2 -1
- package/src/lib/ui/hooks/useTools.tsx +2 -1
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +0 -8
- package/src/lib/utils/export/exportAs.ts +9 -2
- package/src/lib/utils/frames/frames.ts +1 -1
- package/src/lib/utils/tldr/buildFromV1Document.ts +17 -12
- package/src/test/Editor.test.tsx +12 -38
- package/src/test/SelectTool.test.ts +19 -11
- package/src/test/TestEditor.ts +4 -1
- package/src/test/TldrawEditor.test.tsx +16 -18
- package/src/test/bindings.test.tsx +25 -29
- package/src/test/bindingsIndex.test.tsx +4 -4
- package/src/test/commands/createShapes.test.ts +1 -15
- package/src/test/commands/getSvgString.test.ts +2 -2
- package/src/test/commands/putContent.test.ts +0 -1
- package/src/test/commands/updateShapes.test.ts +5 -21
- package/src/test/custom-clipping.test.ts +35 -36
- package/src/test/customSnapping.test.tsx +62 -77
- package/src/test/duplicate.test.ts +1 -1
- package/src/test/frames.test.ts +2 -2
- package/src/test/getCulledShapes.test.tsx +3 -11
- package/src/test/getShapeAtPoint.test.ts +2 -2
- package/src/test/groups.test.tsx +3 -6
- package/src/test/resizing.test.ts +13 -9
- package/src/test/selection-omnibus.test.ts +11 -11
- package/src/test/shapeutils.test.ts +1 -1
- package/src/test/styles2.test.tsx +1 -1
- package/src/test/styles3.test.ts +5 -5
- package/src/test/test-jsx.tsx +57 -69
- package/src/test/text.test.ts +17 -15
- package/src/test/translating.test.ts +8 -6
- package/src/test/commands/createShape.test.ts +0 -64
- package/src/test/commands/isShapeOfType.test.ts +0 -44
- package/src/test/commands/updateShape.test.ts +0 -67
|
@@ -24,7 +24,7 @@ export class Pointing extends StateNode {
|
|
|
24
24
|
const creatingMarkId = this.editor.markHistoryStoppingPoint(`creating_geo:${id}`)
|
|
25
25
|
const newPoint = maybeSnapToGrid(originPagePoint, this.editor)
|
|
26
26
|
this.editor
|
|
27
|
-
.createShapes([
|
|
27
|
+
.createShapes<TLGeoShape>([
|
|
28
28
|
{
|
|
29
29
|
id,
|
|
30
30
|
type: 'geo',
|
|
@@ -88,7 +88,7 @@ export class Pointing extends StateNode {
|
|
|
88
88
|
? { w: 300, h: 180 }
|
|
89
89
|
: { w: 200, h: 200 }
|
|
90
90
|
|
|
91
|
-
this.editor.createShapes([
|
|
91
|
+
this.editor.createShapes<TLGeoShape>([
|
|
92
92
|
{
|
|
93
93
|
id,
|
|
94
94
|
type: 'geo',
|
|
@@ -115,7 +115,7 @@ export class Pointing extends StateNode {
|
|
|
115
115
|
if (parentTransform) delta.rot(-parentTransform.rotation())
|
|
116
116
|
const newPoint = maybeSnapToGrid(new Vec(shape.x - delta.x, shape.y - delta.y), this.editor)
|
|
117
117
|
this.editor.select(id)
|
|
118
|
-
this.editor.updateShape({
|
|
118
|
+
this.editor.updateShape<TLGeoShape>({
|
|
119
119
|
id: shape.id,
|
|
120
120
|
type: 'geo',
|
|
121
121
|
x: newPoint.x,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assert } from '@tldraw/editor'
|
|
1
|
+
import { TLLineShape, assert } from '@tldraw/editor'
|
|
2
2
|
import { TestEditor } from '../../../test/TestEditor'
|
|
3
3
|
|
|
4
4
|
let editor: TestEditor
|
|
@@ -127,7 +127,7 @@ describe('When extending the line with the shift-key in tool-lock mode', () => {
|
|
|
127
127
|
.pointerUp(20, 10)
|
|
128
128
|
|
|
129
129
|
const line = editor.getCurrentPageShapes()[editor.getCurrentPageShapes().length - 1]
|
|
130
|
-
assert(editor.isShapeOfType(line, 'line'))
|
|
130
|
+
assert(editor.isShapeOfType<TLLineShape>(line, 'line'))
|
|
131
131
|
expect(Object.keys(line.props.points).length).toBe(3)
|
|
132
132
|
})
|
|
133
133
|
|
|
@@ -143,7 +143,7 @@ describe('When extending the line with the shift-key in tool-lock mode', () => {
|
|
|
143
143
|
.pointerUp(30, 10)
|
|
144
144
|
|
|
145
145
|
const line = editor.getCurrentPageShapes()[editor.getCurrentPageShapes().length - 1]
|
|
146
|
-
assert(editor.isShapeOfType(line, 'line'))
|
|
146
|
+
assert(editor.isShapeOfType<TLLineShape>(line, 'line'))
|
|
147
147
|
expect(Object.keys(line.props.points).length).toBe(2)
|
|
148
148
|
})
|
|
149
149
|
|
|
@@ -160,7 +160,7 @@ describe('When extending the line with the shift-key in tool-lock mode', () => {
|
|
|
160
160
|
.pointerUp(30, 10)
|
|
161
161
|
|
|
162
162
|
const line = editor.getCurrentPageShapes()[editor.getCurrentPageShapes().length - 1]
|
|
163
|
-
assert(editor.isShapeOfType(line, 'line'))
|
|
163
|
+
assert(editor.isShapeOfType<TLLineShape>(line, 'line'))
|
|
164
164
|
expect(Object.keys(line.props.points).length).toBe(3)
|
|
165
165
|
})
|
|
166
166
|
|
|
@@ -179,7 +179,7 @@ describe('When extending the line with the shift-key in tool-lock mode', () => {
|
|
|
179
179
|
.pointerUp(30, 10)
|
|
180
180
|
|
|
181
181
|
const line = editor.getCurrentPageShapes()[editor.getCurrentPageShapes().length - 1]
|
|
182
|
-
assert(editor.isShapeOfType(line, 'line'))
|
|
182
|
+
assert(editor.isShapeOfType<TLLineShape>(line, 'line'))
|
|
183
183
|
expect(Object.keys(line.props.points).length).toBe(3)
|
|
184
184
|
})
|
|
185
185
|
|
|
@@ -200,7 +200,7 @@ describe('When extending the line with the shift-key in tool-lock mode', () => {
|
|
|
200
200
|
.pointerUp(40, 10)
|
|
201
201
|
|
|
202
202
|
const line = editor.getCurrentPageShapes()[editor.getCurrentPageShapes().length - 1]
|
|
203
|
-
assert(editor.isShapeOfType(line, 'line'))
|
|
203
|
+
assert(editor.isShapeOfType<TLLineShape>(line, 'line'))
|
|
204
204
|
expect(Object.keys(line.props.points).length).toBe(3)
|
|
205
205
|
})
|
|
206
206
|
})
|
|
@@ -24,7 +24,7 @@ beforeEach(() => {
|
|
|
24
24
|
editor
|
|
25
25
|
.selectAll()
|
|
26
26
|
.deleteShapes(editor.getSelectedShapeIds())
|
|
27
|
-
.createShapes([
|
|
27
|
+
.createShapes<TLLineShape>([
|
|
28
28
|
{
|
|
29
29
|
id: id,
|
|
30
30
|
type: 'line',
|
|
@@ -168,10 +168,10 @@ describe('Snapping', () => {
|
|
|
168
168
|
type: 'line',
|
|
169
169
|
props: {
|
|
170
170
|
points: {
|
|
171
|
-
a1: { id: 'a1', index: 'a1'
|
|
172
|
-
a2: { id: 'a2', index: 'a2'
|
|
173
|
-
a3: { id: 'a3', index: 'a3'
|
|
174
|
-
a4: { id: 'a4', index: 'a4'
|
|
171
|
+
a1: { id: 'a1', index: 'a1', x: 0, y: 0 },
|
|
172
|
+
a2: { id: 'a2', index: 'a2', x: 100, y: 0 },
|
|
173
|
+
a3: { id: 'a3', index: 'a3', x: 100, y: 100 },
|
|
174
|
+
a4: { id: 'a4', index: 'a4', x: 0, y: 100 },
|
|
175
175
|
},
|
|
176
176
|
},
|
|
177
177
|
})
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TLNoteShape } from '@tldraw/editor'
|
|
2
1
|
import { TestEditor } from '../../../test/TestEditor'
|
|
3
2
|
import { NoteShapeTool } from './NoteShapeTool'
|
|
4
3
|
|
|
@@ -243,7 +242,7 @@ describe('Adjacent note position helpers (sticky pits)', () => {
|
|
|
243
242
|
|
|
244
243
|
it('Falls into correct pit below notes with growY', () => {
|
|
245
244
|
editor.createShape({ type: 'note', x: 0, y: 0 }).updateShape({
|
|
246
|
-
...editor.getLastCreatedShape
|
|
245
|
+
...editor.getLastCreatedShape(),
|
|
247
246
|
props: { growY: 100 },
|
|
248
247
|
})
|
|
249
248
|
|
|
@@ -104,7 +104,7 @@ export function getAvailableNoteAdjacentPositions(
|
|
|
104
104
|
// Get all the positions that are adjacent to the selected note shapes
|
|
105
105
|
for (const shape of editor.getCurrentPageShapes()) {
|
|
106
106
|
if (
|
|
107
|
-
!editor.isShapeOfType(shape, 'note') ||
|
|
107
|
+
!editor.isShapeOfType<TLNoteShape>(shape, 'note') ||
|
|
108
108
|
scale !== shape.props.scale ||
|
|
109
109
|
selectedShapeIds.has(shape.id)
|
|
110
110
|
) {
|
|
@@ -204,7 +204,7 @@ export function getNoteShapeForAdjacentPosition(
|
|
|
204
204
|
|
|
205
205
|
// We create it at the center first, so that it becomes
|
|
206
206
|
// the child of whatever parent was at that center
|
|
207
|
-
editor.createShape({
|
|
207
|
+
editor.createShape<TLNoteShape>({
|
|
208
208
|
id,
|
|
209
209
|
type: 'note',
|
|
210
210
|
x: center.x,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Box,
|
|
3
|
-
ExtractShapeByProps,
|
|
4
3
|
TLDefaultFillStyle,
|
|
5
4
|
TLDefaultFontStyle,
|
|
6
5
|
TLDefaultHorizontalAlignStyle,
|
|
@@ -16,7 +15,7 @@ import { useEditablePlainText } from './useEditablePlainText'
|
|
|
16
15
|
/** @public */
|
|
17
16
|
export interface PlainTextLabelProps {
|
|
18
17
|
shapeId: TLShapeId
|
|
19
|
-
type:
|
|
18
|
+
type: string
|
|
20
19
|
font: TLDefaultFontStyle
|
|
21
20
|
fontSize: number
|
|
22
21
|
lineHeight: number
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Box,
|
|
3
3
|
DefaultFontFamilies,
|
|
4
|
-
ExtractShapeByProps,
|
|
5
4
|
TLDefaultFillStyle,
|
|
6
5
|
TLDefaultFontStyle,
|
|
7
6
|
TLDefaultHorizontalAlignStyle,
|
|
@@ -25,7 +24,7 @@ import { useEditableRichText } from './useEditableRichText'
|
|
|
25
24
|
/** @public */
|
|
26
25
|
export interface RichTextLabelProps {
|
|
27
26
|
shapeId: TLShapeId
|
|
28
|
-
type:
|
|
27
|
+
type: string
|
|
29
28
|
font: TLDefaultFontStyle
|
|
30
29
|
fontSize: number
|
|
31
30
|
lineHeight: number
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Editor,
|
|
3
|
-
ExtractShapeByProps,
|
|
4
3
|
TLShapeId,
|
|
4
|
+
TLUnknownShape,
|
|
5
5
|
getPointerInfo,
|
|
6
6
|
noop,
|
|
7
7
|
preventDefault,
|
|
@@ -13,11 +13,7 @@ import React, { useCallback, useEffect, useRef } from 'react'
|
|
|
13
13
|
import { TextHelpers } from './TextHelpers'
|
|
14
14
|
|
|
15
15
|
/** @public */
|
|
16
|
-
export function useEditablePlainText(
|
|
17
|
-
shapeId: TLShapeId,
|
|
18
|
-
type: ExtractShapeByProps<{ text: string }>['type'],
|
|
19
|
-
text?: string
|
|
20
|
-
) {
|
|
16
|
+
export function useEditablePlainText(shapeId: TLShapeId, type: string, text?: string) {
|
|
21
17
|
const commonUseEditableTextHandlers = useEditableTextCommon(shapeId)
|
|
22
18
|
const isEditing = commonUseEditableTextHandlers.isEditing
|
|
23
19
|
const editor = useEditor()
|
|
@@ -79,7 +75,7 @@ export function useEditablePlainText(
|
|
|
79
75
|
if (editor.getEditingShapeId() !== shapeId) return
|
|
80
76
|
|
|
81
77
|
const normalizedPlaintext = TextHelpers.normalizeText(plaintext || '')
|
|
82
|
-
editor.updateShape({
|
|
78
|
+
editor.updateShape<TLUnknownShape & { props: { text: string } }>({
|
|
83
79
|
id: shapeId,
|
|
84
80
|
type,
|
|
85
81
|
props: { text: normalizedPlaintext },
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TLRichText, TLShapeId, TLUnknownShape, isAccelKey, useEditor } from '@tldraw/editor'
|
|
2
2
|
import { useCallback, useEffect, useRef } from 'react'
|
|
3
3
|
import { isEmptyRichText } from '../../utils/text/richText'
|
|
4
4
|
import { useEditableTextCommon } from './useEditablePlainText'
|
|
5
5
|
|
|
6
6
|
/** @public */
|
|
7
|
-
export function useEditableRichText(
|
|
8
|
-
shapeId: TLShapeId,
|
|
9
|
-
type: ExtractShapeByProps<{ richText: TLRichText }>['type'],
|
|
10
|
-
richText?: TLRichText
|
|
11
|
-
) {
|
|
7
|
+
export function useEditableRichText(shapeId: TLShapeId, type: string, richText?: TLRichText) {
|
|
12
8
|
const commonUseEditableTextHandlers = useEditableTextCommon(shapeId)
|
|
13
9
|
const isEditing = commonUseEditableTextHandlers.isEditing
|
|
14
10
|
const editor = useEditor()
|
|
@@ -43,7 +39,7 @@ export function useEditableRichText(
|
|
|
43
39
|
({ richText }: { richText: TLRichText }) => {
|
|
44
40
|
if (editor.getEditingShapeId() !== shapeId) return
|
|
45
41
|
|
|
46
|
-
editor.updateShape({
|
|
42
|
+
editor.updateShape<TLUnknownShape & { props: { richText: TLRichText } }>({
|
|
47
43
|
id: shapeId,
|
|
48
44
|
type,
|
|
49
45
|
props: { richText },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DefaultTextAlignStyle, toRichText } from '@tldraw/editor'
|
|
1
|
+
import { DefaultTextAlignStyle, TLTextShape, toRichText } from '@tldraw/editor'
|
|
2
2
|
import { vi } from 'vitest'
|
|
3
3
|
import { TestEditor } from '../../../test/TestEditor'
|
|
4
4
|
import { TextShapeTool } from './TextShapeTool'
|
|
@@ -24,7 +24,7 @@ describe(TextShapeTool, () => {
|
|
|
24
24
|
editor.pointerUp()
|
|
25
25
|
editor.expectToBeIn('select.editing_shape')
|
|
26
26
|
// This comes from the component, not the state chart
|
|
27
|
-
editor.updateShapes([
|
|
27
|
+
editor.updateShapes<TLTextShape>([
|
|
28
28
|
{
|
|
29
29
|
...editor.getCurrentPageShapes()[0]!,
|
|
30
30
|
type: 'text',
|
|
@@ -96,7 +96,7 @@ describe('When in idle state', () => {
|
|
|
96
96
|
editor.expectToBeIn('select.editing_shape')
|
|
97
97
|
|
|
98
98
|
// Update the text shape with some content
|
|
99
|
-
editor.updateShapes([
|
|
99
|
+
editor.updateShapes<TLTextShape>([
|
|
100
100
|
{
|
|
101
101
|
...editor.getCurrentPageShapes()[0]!,
|
|
102
102
|
type: 'text',
|
|
@@ -133,7 +133,7 @@ describe('When in idle state', () => {
|
|
|
133
133
|
editor.expectToBeIn('select.editing_shape')
|
|
134
134
|
|
|
135
135
|
// Update the text shape with some content
|
|
136
|
-
editor.updateShapes([
|
|
136
|
+
editor.updateShapes<TLTextShape>([
|
|
137
137
|
{
|
|
138
138
|
...editor.getCurrentPageShapes()[0]!,
|
|
139
139
|
type: 'text',
|
|
@@ -124,7 +124,7 @@ export class Pointing extends StateNode {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
private createTextShape(id: TLShapeId, point: Vec, autoSize: boolean, width: number) {
|
|
127
|
-
this.editor.createShape({
|
|
127
|
+
this.editor.createShape<TLTextShape>({
|
|
128
128
|
id,
|
|
129
129
|
type: 'text',
|
|
130
130
|
x: point.x,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StateNode,
|
|
3
|
+
TLFrameShape,
|
|
4
|
+
TLGroupShape,
|
|
3
5
|
TLPointerEventInfo,
|
|
4
6
|
TLShapeId,
|
|
5
7
|
isAccelKey,
|
|
@@ -35,8 +37,8 @@ export class Erasing extends StateNode {
|
|
|
35
37
|
if (this.editor.isShapeOrAncestorLocked(shape)) return true
|
|
36
38
|
//If the shape is a group or frame, check we're inside it when we start erasing
|
|
37
39
|
if (
|
|
38
|
-
this.editor.isShapeOfType(shape, 'group') ||
|
|
39
|
-
this.editor.isShapeOfType(shape, 'frame')
|
|
40
|
+
this.editor.isShapeOfType<TLGroupShape>(shape, 'group') ||
|
|
41
|
+
this.editor.isShapeOfType<TLFrameShape>(shape, 'frame')
|
|
40
42
|
) {
|
|
41
43
|
const pointInShapeShape = this.editor.getPointInShapeSpace(shape, originPagePoint)
|
|
42
44
|
const geometry = this.editor.getShapeGeometry(shape)
|
|
@@ -109,7 +111,7 @@ export class Erasing extends StateNode {
|
|
|
109
111
|
const minDist = this.editor.options.hitTestMargin / zoomLevel
|
|
110
112
|
|
|
111
113
|
for (const shape of currentPageShapes) {
|
|
112
|
-
if (editor.isShapeOfType(shape, 'group')) continue
|
|
114
|
+
if (editor.isShapeOfType<TLGroupShape>(shape, 'group')) continue
|
|
113
115
|
|
|
114
116
|
// Avoid testing masked shapes, unless the pointer is inside the mask
|
|
115
117
|
const pageMask = editor.getShapeMask(shape.id)
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
isAccelKey,
|
|
3
|
+
StateNode,
|
|
4
|
+
TLFrameShape,
|
|
5
|
+
TLGroupShape,
|
|
6
|
+
TLPointerEventInfo,
|
|
7
|
+
TLShapeId,
|
|
8
|
+
} from '@tldraw/editor'
|
|
2
9
|
|
|
3
10
|
export class Pointing extends StateNode {
|
|
4
11
|
static override id = 'pointing'
|
|
@@ -20,7 +27,10 @@ export class Pointing extends StateNode {
|
|
|
20
27
|
|
|
21
28
|
for (let n = currentPageShapesSorted.length, i = n - 1; i >= 0; i--) {
|
|
22
29
|
const shape = currentPageShapesSorted[i]
|
|
23
|
-
if (
|
|
30
|
+
if (
|
|
31
|
+
this.editor.isShapeOrAncestorLocked(shape) ||
|
|
32
|
+
this.editor.isShapeOfType<TLGroupShape>(shape, 'group')
|
|
33
|
+
) {
|
|
24
34
|
continue
|
|
25
35
|
}
|
|
26
36
|
|
|
@@ -32,7 +42,10 @@ export class Pointing extends StateNode {
|
|
|
32
42
|
) {
|
|
33
43
|
const hitShape = this.editor.getOutermostSelectableShape(shape)
|
|
34
44
|
// If we've hit a frame after hitting any other shape, stop here
|
|
35
|
-
if (
|
|
45
|
+
if (
|
|
46
|
+
this.editor.isShapeOfType<TLFrameShape>(hitShape, 'frame') &&
|
|
47
|
+
erasing.size > initialSize
|
|
48
|
+
) {
|
|
36
49
|
break
|
|
37
50
|
}
|
|
38
51
|
|
|
@@ -44,7 +44,7 @@ export class DragAndDropManager {
|
|
|
44
44
|
|
|
45
45
|
for (const shape of shapesToActuallyMove) {
|
|
46
46
|
const parent = editor.getShapeParent(shape)
|
|
47
|
-
if (parent && editor.isShapeOfType(parent, 'group')) {
|
|
47
|
+
if (parent && editor.isShapeOfType<TLGroupShape>(parent, 'group')) {
|
|
48
48
|
if (!movingGroups.has(parent)) {
|
|
49
49
|
movingGroups.add(parent)
|
|
50
50
|
}
|
|
@@ -70,7 +70,9 @@ export class DragAndDropManager {
|
|
|
70
70
|
}
|
|
71
71
|
this.initialIndices.set(shape.id, shape.index)
|
|
72
72
|
|
|
73
|
-
const group = editor.findShapeAncestor(shape, (s) =>
|
|
73
|
+
const group = editor.findShapeAncestor(shape, (s) =>
|
|
74
|
+
editor.isShapeOfType<TLGroupShape>(s, 'group')
|
|
75
|
+
)
|
|
74
76
|
if (group) {
|
|
75
77
|
this.initialGroupIds.set(shape.id, group.id)
|
|
76
78
|
}
|
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
Mat,
|
|
4
4
|
StateNode,
|
|
5
5
|
TLCancelEventInfo,
|
|
6
|
+
TLFrameShape,
|
|
7
|
+
TLGroupShape,
|
|
6
8
|
TLKeyboardEventInfo,
|
|
7
9
|
TLPageId,
|
|
8
10
|
TLPointerEventInfo,
|
|
@@ -55,7 +57,9 @@ export class Brushing extends StateNode {
|
|
|
55
57
|
editor
|
|
56
58
|
.getCurrentPageShapes()
|
|
57
59
|
.filter(
|
|
58
|
-
(shape) =>
|
|
60
|
+
(shape) =>
|
|
61
|
+
editor.isShapeOfType<TLGroupShape>(shape, 'group') ||
|
|
62
|
+
editor.isShapeOrAncestorLocked(shape)
|
|
59
63
|
)
|
|
60
64
|
.map((shape) => shape.id)
|
|
61
65
|
)
|
|
@@ -173,7 +177,7 @@ export class Brushing extends StateNode {
|
|
|
173
177
|
|
|
174
178
|
// If we're in wrap mode and the brush did not fully encloses the shape, it's a miss
|
|
175
179
|
// We also skip frames unless we've completely selected the frame.
|
|
176
|
-
if (isWrapping || editor.isShapeOfType(shape, 'frame')) {
|
|
180
|
+
if (isWrapping || editor.isShapeOfType<TLFrameShape>(shape, 'frame')) {
|
|
177
181
|
continue testAllShapes
|
|
178
182
|
}
|
|
179
183
|
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
ShapeWithCrop,
|
|
3
3
|
StateNode,
|
|
4
4
|
TLClickEventInfo,
|
|
5
|
+
TLGroupShape,
|
|
5
6
|
TLKeyboardEventInfo,
|
|
6
7
|
TLPointerEventInfo,
|
|
7
8
|
Vec,
|
|
@@ -42,7 +43,7 @@ export class Idle extends StateNode {
|
|
|
42
43
|
switch (info.target) {
|
|
43
44
|
case 'canvas': {
|
|
44
45
|
const hitShape = getHitShapeOnCanvasPointerDown(this.editor)
|
|
45
|
-
if (hitShape && !this.editor.isShapeOfType(hitShape, 'group')) {
|
|
46
|
+
if (hitShape && !this.editor.isShapeOfType<TLGroupShape>(hitShape, 'group')) {
|
|
46
47
|
this.onPointerDown({
|
|
47
48
|
...info,
|
|
48
49
|
shape: hitShape,
|
|
@@ -190,7 +191,7 @@ export class Idle extends StateNode {
|
|
|
190
191
|
this.editor.markHistoryStoppingPoint('translate crop')
|
|
191
192
|
}
|
|
192
193
|
|
|
193
|
-
this.editor.updateShapes([partial])
|
|
194
|
+
this.editor.updateShapes<ShapeWithCrop>([partial])
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
197
|
}
|
|
@@ -115,7 +115,7 @@ export class DraggingHandle extends StateNode {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// <!-- Only relevant to arrows
|
|
118
|
-
if (this.editor.isShapeOfType(shape, 'arrow')) {
|
|
118
|
+
if (this.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) {
|
|
119
119
|
const initialBinding = getArrowBindings(this.editor, shape)[info.handle.id as 'start' | 'end']
|
|
120
120
|
|
|
121
121
|
this.isPrecise = false
|
|
@@ -228,7 +228,7 @@ export class DraggingHandle extends StateNode {
|
|
|
228
228
|
}
|
|
229
229
|
const endChanges = util.onHandleDragEnd?.(shape, handleDragInfo)
|
|
230
230
|
if (endChanges) {
|
|
231
|
-
this.editor.updateShapes([{ ...endChanges, id: shape.id }])
|
|
231
|
+
this.editor.updateShapes([{ ...endChanges, id: shape.id, type: shape.type }])
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
|
|
@@ -295,7 +295,7 @@ export class DraggingHandle extends StateNode {
|
|
|
295
295
|
if (!shape) return
|
|
296
296
|
const util = editor.getShapeUtil(shape)
|
|
297
297
|
|
|
298
|
-
const initialBinding = editor.isShapeOfType(shape, 'arrow')
|
|
298
|
+
const initialBinding = editor.isShapeOfType<TLArrowShape>(shape, 'arrow')
|
|
299
299
|
? getArrowBindings(editor, shape)[initialHandle.id as 'start' | 'end']
|
|
300
300
|
: undefined
|
|
301
301
|
|
|
@@ -352,7 +352,10 @@ export class DraggingHandle extends StateNode {
|
|
|
352
352
|
const next: TLShapePartial<any> = { id: shape.id, type: shape.type, ...changes }
|
|
353
353
|
|
|
354
354
|
// Arrows
|
|
355
|
-
if (
|
|
355
|
+
if (
|
|
356
|
+
initialHandle.type === 'vertex' &&
|
|
357
|
+
this.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')
|
|
358
|
+
) {
|
|
356
359
|
const bindingAfter = getArrowBindings(editor, shape)[initialHandle.id as 'start' | 'end']
|
|
357
360
|
|
|
358
361
|
if (bindingAfter) {
|
|
@@ -3,8 +3,10 @@ import {
|
|
|
3
3
|
TLCancelEventInfo,
|
|
4
4
|
TLCompleteEventInfo,
|
|
5
5
|
tlenv,
|
|
6
|
+
TLFrameShape,
|
|
6
7
|
TLPointerEventInfo,
|
|
7
8
|
TLShape,
|
|
9
|
+
TLTextShape,
|
|
8
10
|
} from '@tldraw/editor'
|
|
9
11
|
import { getTextLabels } from '../../../utils/shapes/shapes'
|
|
10
12
|
import { renderPlaintextFromRichText } from '../../../utils/text/richText'
|
|
@@ -107,7 +109,7 @@ export class EditingShape extends StateNode {
|
|
|
107
109
|
const textLabel = textLabels.length === 1 ? textLabels[0] : undefined
|
|
108
110
|
// N.B. One nuance here is that we want empty text fields to be removed from the canvas when the user clicks away from them.
|
|
109
111
|
const isEmptyTextShape =
|
|
110
|
-
this.editor.isShapeOfType(editingShape, 'text') &&
|
|
112
|
+
this.editor.isShapeOfType<TLTextShape>(editingShape, 'text') &&
|
|
111
113
|
renderPlaintextFromRichText(this.editor, editingShape.props.richText).trim() === ''
|
|
112
114
|
if (textLabel && !isEmptyTextShape) {
|
|
113
115
|
const pointInShapeSpace = this.editor.getPointInShapeSpace(
|
|
@@ -133,7 +135,7 @@ export class EditingShape extends StateNode {
|
|
|
133
135
|
} else {
|
|
134
136
|
if (selectingShape.id === editingShape.id) {
|
|
135
137
|
// If we clicked on a frame, while editing its heading, cancel editing
|
|
136
|
-
if (this.editor.isShapeOfType(selectingShape, 'frame')) {
|
|
138
|
+
if (this.editor.isShapeOfType<TLFrameShape>(selectingShape, 'frame')) {
|
|
137
139
|
this.editor.setEditingShape(null)
|
|
138
140
|
this.parent.transition('idle', info)
|
|
139
141
|
}
|
|
@@ -3,9 +3,11 @@ import {
|
|
|
3
3
|
StateNode,
|
|
4
4
|
TLAdjacentDirection,
|
|
5
5
|
TLClickEventInfo,
|
|
6
|
+
TLGroupShape,
|
|
6
7
|
TLKeyboardEventInfo,
|
|
7
8
|
TLPointerEventInfo,
|
|
8
9
|
TLShape,
|
|
10
|
+
TLTextShape,
|
|
9
11
|
Vec,
|
|
10
12
|
VecLike,
|
|
11
13
|
createShapeId,
|
|
@@ -188,7 +190,7 @@ export class Idle extends StateNode {
|
|
|
188
190
|
// unexpected results when working "inside of" a hollow shape.
|
|
189
191
|
|
|
190
192
|
const hitShape =
|
|
191
|
-
hoveredShape && !this.editor.isShapeOfType(hoveredShape, 'group')
|
|
193
|
+
hoveredShape && !this.editor.isShapeOfType<TLGroupShape>(hoveredShape, 'group')
|
|
192
194
|
? hoveredShape
|
|
193
195
|
: (this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint) ??
|
|
194
196
|
this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
|
|
@@ -199,13 +201,13 @@ export class Idle extends StateNode {
|
|
|
199
201
|
const focusedGroupId = this.editor.getFocusedGroupId()
|
|
200
202
|
|
|
201
203
|
if (hitShape) {
|
|
202
|
-
if (this.editor.isShapeOfType(hitShape, 'group')) {
|
|
204
|
+
if (this.editor.isShapeOfType<TLGroupShape>(hitShape, 'group')) {
|
|
203
205
|
// Probably select the shape
|
|
204
206
|
selectOnCanvasPointerUp(this.editor, info)
|
|
205
207
|
return
|
|
206
208
|
} else {
|
|
207
209
|
const parent = this.editor.getShape(hitShape.parentId)
|
|
208
|
-
if (parent && this.editor.isShapeOfType(parent, 'group')) {
|
|
210
|
+
if (parent && this.editor.isShapeOfType<TLGroupShape>(parent, 'group')) {
|
|
209
211
|
// The shape is the direct child of a group. If the group is
|
|
210
212
|
// selected, then we can select the shape. If the group is the
|
|
211
213
|
// focus layer id, then we can double click into it as usual.
|
|
@@ -354,7 +356,7 @@ export class Idle extends StateNode {
|
|
|
354
356
|
case 'canvas': {
|
|
355
357
|
const hoveredShape = this.editor.getHoveredShape()
|
|
356
358
|
const hitShape =
|
|
357
|
-
hoveredShape && !this.editor.isShapeOfType(hoveredShape, 'group')
|
|
359
|
+
hoveredShape && !this.editor.isShapeOfType<TLGroupShape>(hoveredShape, 'group')
|
|
358
360
|
? hoveredShape
|
|
359
361
|
: this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
|
|
360
362
|
margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),
|
|
@@ -523,7 +525,9 @@ export class Idle extends StateNode {
|
|
|
523
525
|
const selectedShapes = this.editor.getSelectedShapes()
|
|
524
526
|
|
|
525
527
|
// On enter, if every selected shape is a group, then select all of the children of the groups
|
|
526
|
-
if (
|
|
528
|
+
if (
|
|
529
|
+
selectedShapes.every((shape) => this.editor.isShapeOfType<TLGroupShape>(shape, 'group'))
|
|
530
|
+
) {
|
|
527
531
|
this.editor.setSelectedShapes(
|
|
528
532
|
selectedShapes.flatMap((shape) => this.editor.getSortedChildIdsForParent(shape.id))
|
|
529
533
|
)
|
|
@@ -600,7 +604,7 @@ export class Idle extends StateNode {
|
|
|
600
604
|
const { x, y } = this.editor.inputs.currentPagePoint
|
|
601
605
|
|
|
602
606
|
// Allow this to trigger the max shapes reached alert
|
|
603
|
-
this.editor.createShapes([
|
|
607
|
+
this.editor.createShapes<TLTextShape>([
|
|
604
608
|
{
|
|
605
609
|
id,
|
|
606
610
|
type: 'text',
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Editor,
|
|
3
|
+
StateNode,
|
|
4
|
+
TLArrowShape,
|
|
5
|
+
TLHandle,
|
|
6
|
+
TLNoteShape,
|
|
7
|
+
TLPointerEventInfo,
|
|
8
|
+
Vec,
|
|
9
|
+
} from '@tldraw/editor'
|
|
2
10
|
import { updateArrowTargetState } from '../../../shapes/arrow/arrowTargetState'
|
|
3
11
|
import { getArrowBindings } from '../../../shapes/arrow/shared'
|
|
4
12
|
import {
|
|
@@ -21,7 +29,7 @@ export class PointingHandle extends StateNode {
|
|
|
21
29
|
this.didCtrlOnEnter = info.accelKey
|
|
22
30
|
|
|
23
31
|
const { shape } = info
|
|
24
|
-
if (this.editor.isShapeOfType(shape, 'arrow')) {
|
|
32
|
+
if (this.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) {
|
|
25
33
|
const initialBindings = getArrowBindings(this.editor, shape)
|
|
26
34
|
const currentBinding = initialBindings[info.handle.id as 'start' | 'end']
|
|
27
35
|
const oppositeBinding = initialBindings[info.handle.id === 'start' ? 'end' : 'start']
|
|
@@ -50,7 +58,7 @@ export class PointingHandle extends StateNode {
|
|
|
50
58
|
override onPointerUp() {
|
|
51
59
|
const { shape, handle } = this.info
|
|
52
60
|
|
|
53
|
-
if (this.editor.isShapeOfType(shape, 'note')) {
|
|
61
|
+
if (this.editor.isShapeOfType<TLNoteShape>(shape, 'note')) {
|
|
54
62
|
const { editor } = this
|
|
55
63
|
const nextNote = getNoteForAdjacentPosition(editor, shape, handle, false)
|
|
56
64
|
if (nextNote) {
|
|
@@ -82,7 +90,7 @@ export class PointingHandle extends StateNode {
|
|
|
82
90
|
if (editor.getIsReadonly()) return
|
|
83
91
|
const { shape, handle } = this.info
|
|
84
92
|
|
|
85
|
-
if (editor.isShapeOfType(shape, 'note')) {
|
|
93
|
+
if (editor.isShapeOfType<TLNoteShape>(shape, 'note')) {
|
|
86
94
|
const nextNote = getNoteForAdjacentPosition(editor, shape, handle, true)
|
|
87
95
|
if (nextNote) {
|
|
88
96
|
// Center the shape on the current pointer
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StateNode, TLClickEventInfo, TLPointerEventInfo } from '@tldraw/editor'
|
|
1
|
+
import { StateNode, TLClickEventInfo, TLGroupShape, TLPointerEventInfo } from '@tldraw/editor'
|
|
2
2
|
import { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'
|
|
3
3
|
|
|
4
4
|
export class PointingSelection extends StateNode {
|
|
@@ -35,7 +35,7 @@ export class PointingSelection extends StateNode {
|
|
|
35
35
|
override onDoubleClick?(info: TLClickEventInfo) {
|
|
36
36
|
const hoveredShape = this.editor.getHoveredShape()
|
|
37
37
|
const hitShape =
|
|
38
|
-
hoveredShape && !this.editor.isShapeOfType(hoveredShape, 'group')
|
|
38
|
+
hoveredShape && !this.editor.isShapeOfType<TLGroupShape>(hoveredShape, 'group')
|
|
39
39
|
? hoveredShape
|
|
40
40
|
: this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
|
|
41
41
|
hitInside: true,
|
|
@@ -7,10 +7,12 @@ import {
|
|
|
7
7
|
SelectionCorner,
|
|
8
8
|
SelectionEdge,
|
|
9
9
|
StateNode,
|
|
10
|
+
TLFrameShape,
|
|
10
11
|
TLPointerEventInfo,
|
|
11
12
|
TLShape,
|
|
12
13
|
TLShapeId,
|
|
13
14
|
TLShapePartial,
|
|
15
|
+
TLTextShape,
|
|
14
16
|
TLTickEventInfo,
|
|
15
17
|
Vec,
|
|
16
18
|
VecLike,
|
|
@@ -226,7 +228,7 @@ export class Resizing extends StateNode {
|
|
|
226
228
|
|
|
227
229
|
if (shapeSnapshots.size === 1) {
|
|
228
230
|
const onlySnapshot = [...shapeSnapshots.values()][0]!
|
|
229
|
-
if (this.editor.isShapeOfType(onlySnapshot.shape, 'text')) {
|
|
231
|
+
if (this.editor.isShapeOfType<TLTextShape>(onlySnapshot.shape, 'text')) {
|
|
230
232
|
isAspectRatioLocked = !(this.info.handle === 'left' || this.info.handle === 'right')
|
|
231
233
|
}
|
|
232
234
|
}
|
|
@@ -526,7 +528,7 @@ export class Resizing extends StateNode {
|
|
|
526
528
|
// descendants (easy) but also flagging with behavior like "resize" or "keep absolute position" or "reposition only with accel key",
|
|
527
529
|
// though I'm not sure where that would be defined; perhaps better handled with onResizeStart / onResize callbacks on the util, and
|
|
528
530
|
// pass `accelKeyIsPressed` as well as `accelKeyWasPressed`?
|
|
529
|
-
if (editor.isShapeOfType(shape, 'frame')) {
|
|
531
|
+
if (editor.isShapeOfType<TLFrameShape>(shape, 'frame')) {
|
|
530
532
|
frames.push({
|
|
531
533
|
id: shape.id,
|
|
532
534
|
children: compact(
|