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