tldraw 4.2.0-next.f100cedfc45b → 4.3.0-canary.03ae87dcc44b
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 +17 -7
- 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 +5 -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/frame/components/FrameLabelInput.js +63 -36
- package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js.map +2 -2
- 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/NoteShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.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/ShapeFill.js +3 -0
- package/dist-cjs/lib/shapes/shared/ShapeFill.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 +15 -7
- 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 +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/Dialogs.js +2 -14
- package/dist-cjs/lib/ui/components/Dialogs.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/PageMenu/DefaultPageMenu.js +5 -4
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbarContent.js +2 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbarContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/Button/TldrawUiButton.js +2 -2
- package/dist-cjs/lib/ui/components/primitives/Button/TldrawUiButton.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +2 -1
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +17 -2
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/events.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +18 -16
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +3 -3
- 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/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +1 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTranslation/useTranslation.js +1 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/useTranslation.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 +17 -7
- 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 +6 -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/frame/components/FrameLabelInput.mjs +65 -38
- package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs.map +2 -2
- 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/NoteShapeUtil.mjs +5 -5
- package/dist-esm/lib/shapes/note/NoteShapeUtil.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/ShapeFill.mjs +3 -0
- package/dist-esm/lib/shapes/shared/ShapeFill.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 +15 -7
- 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 +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/Dialogs.mjs +2 -14
- package/dist-esm/lib/ui/components/Dialogs.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/PageMenu/DefaultPageMenu.mjs +5 -5
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbarContent.mjs +2 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbarContent.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/components/primitives/Button/TldrawUiButton.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/Button/TldrawUiButton.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -1
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +17 -2
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/events.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/useClipboardEvents.mjs +18 -16
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +3 -3
- 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/hooks/useTranslation/defaultTranslation.mjs +1 -0
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/useTranslation.mjs +1 -0
- package/dist-esm/lib/ui/hooks/useTranslation/useTranslation.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 +18 -7
- 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/frame/components/FrameLabelInput.tsx +48 -24
- 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/NoteShapeUtil.tsx +6 -5
- 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/ShapeFill.tsx +3 -0
- 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 +23 -15
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/Idle.ts +8 -12
- 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/Dialogs.tsx +2 -14
- package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
- package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +6 -5
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
- package/src/lib/ui/components/Toolbar/DefaultRichTextToolbarContent.tsx +4 -1
- package/src/lib/ui/components/menu-items.tsx +6 -14
- package/src/lib/ui/components/primitives/Button/TldrawUiButton.tsx +3 -2
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +1 -0
- package/src/lib/ui/context/actions.tsx +25 -13
- package/src/lib/ui/context/events.tsx +1 -0
- package/src/lib/ui/hooks/menu-hooks.ts +9 -19
- package/src/lib/ui/hooks/useClipboardEvents.ts +12 -9
- package/src/lib/ui/hooks/useFlatten.ts +1 -2
- package/src/lib/ui/hooks/useTools.tsx +1 -2
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +1 -0
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +1 -0
- package/src/lib/ui/hooks/useTranslation/useTranslation.tsx +2 -1
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +4 -6
- 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 +87 -40
- 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 +254 -54
- 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
- package/tldraw.css +4 -6
|
@@ -2,11 +2,12 @@ import {
|
|
|
2
2
|
BaseBoxShapeUtil,
|
|
3
3
|
IndexKey,
|
|
4
4
|
Polyline2d,
|
|
5
|
+
ShapeUtil,
|
|
5
6
|
TLAnyShapeUtilConstructor,
|
|
6
|
-
TLBaseShape,
|
|
7
7
|
TLHandle,
|
|
8
8
|
TLHandleDragInfo,
|
|
9
9
|
TLLineShape,
|
|
10
|
+
TLShape,
|
|
10
11
|
TLShapeId,
|
|
11
12
|
Vec,
|
|
12
13
|
VecModel,
|
|
@@ -15,13 +16,19 @@ import {
|
|
|
15
16
|
import { TestEditor } from './TestEditor'
|
|
16
17
|
import { TL } from './test-jsx'
|
|
17
18
|
|
|
19
|
+
const TEST1_TYPE = 'test1'
|
|
20
|
+
|
|
21
|
+
declare module '@tldraw/tlschema' {
|
|
22
|
+
export interface TLGlobalShapePropsMap {
|
|
23
|
+
[TEST1_TYPE]: { w: number; h: number; boundsSnapPoints: VecModel[] | null }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type Test1Shape = TLShape<typeof TEST1_TYPE>
|
|
28
|
+
|
|
18
29
|
describe('custom shape bounds snapping - translate', () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{ w: number; h: number; boundsSnapPoints: VecModel[] | null }
|
|
22
|
-
>
|
|
23
|
-
class TestShapeUtil extends BaseBoxShapeUtil<TestShape> {
|
|
24
|
-
static override type = 'test'
|
|
30
|
+
class TestShapeUtil extends BaseBoxShapeUtil<Test1Shape> {
|
|
31
|
+
static override type = TEST1_TYPE
|
|
25
32
|
override getDefaultProps() {
|
|
26
33
|
return { w: 100, h: 100, boundsSnapPoints: null }
|
|
27
34
|
}
|
|
@@ -31,7 +38,7 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
31
38
|
override indicator() {
|
|
32
39
|
throw new Error('Method not implemented.')
|
|
33
40
|
}
|
|
34
|
-
override getBoundsSnapGeometry(shape:
|
|
41
|
+
override getBoundsSnapGeometry(shape: Test1Shape) {
|
|
35
42
|
return {
|
|
36
43
|
points: shape.props.boundsSnapPoints ?? undefined,
|
|
37
44
|
}
|
|
@@ -45,14 +52,14 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
45
52
|
editor = new TestEditor({ shapeUtils })
|
|
46
53
|
ids = editor.createShapesFromJsx([
|
|
47
54
|
<TL.geo ref="box" x={0} y={0} w={100} h={100} />,
|
|
48
|
-
<TL.
|
|
55
|
+
<TL.test1 ref="test1" x={200} y={200} w={100} h={100} boundsSnapPoints={null} />,
|
|
49
56
|
])
|
|
50
57
|
})
|
|
51
58
|
|
|
52
59
|
describe('with default boundSnapPoints', () => {
|
|
53
60
|
test('normal snapping works with default boundSnapPoints when moving test shape', () => {
|
|
54
61
|
// start translating the test shape
|
|
55
|
-
editor.setSelectedShapes([ids.
|
|
62
|
+
editor.setSelectedShapes([ids.test1]).pointerDown(250, 250)
|
|
56
63
|
|
|
57
64
|
// move the left edge of the test shape to the right edge of the box shape - it should snap
|
|
58
65
|
editor.pointerMove(155, 250, undefined, { ctrlKey: true })
|
|
@@ -83,15 +90,15 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
83
90
|
|
|
84
91
|
describe('with only the center in boundSnapPoints', () => {
|
|
85
92
|
beforeEach(() => {
|
|
86
|
-
editor.updateShape
|
|
87
|
-
id: ids.
|
|
88
|
-
type:
|
|
93
|
+
editor.updateShape({
|
|
94
|
+
id: ids.test1,
|
|
95
|
+
type: TEST1_TYPE,
|
|
89
96
|
props: { boundsSnapPoints: [{ x: 50, y: 50 }] },
|
|
90
97
|
})
|
|
91
98
|
})
|
|
92
99
|
|
|
93
100
|
describe('when moving the test shape', () => {
|
|
94
|
-
beforeEach(() => editor.select(ids.
|
|
101
|
+
beforeEach(() => editor.select(ids.test1).pointerDown(250, 250))
|
|
95
102
|
|
|
96
103
|
test('does not snap its edges to the box edges', () => {
|
|
97
104
|
editor.pointerMove(155, 250, undefined, { ctrlKey: true })
|
|
@@ -125,15 +132,15 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
125
132
|
|
|
126
133
|
describe('with empty boundSnapPoints', () => {
|
|
127
134
|
beforeEach(() => {
|
|
128
|
-
editor.updateShape
|
|
129
|
-
id: ids.
|
|
130
|
-
type:
|
|
135
|
+
editor.updateShape({
|
|
136
|
+
id: ids.test1,
|
|
137
|
+
type: TEST1_TYPE,
|
|
131
138
|
props: { boundsSnapPoints: [] },
|
|
132
139
|
})
|
|
133
140
|
})
|
|
134
141
|
|
|
135
142
|
test('test shape does not snap to anything', () => {
|
|
136
|
-
editor.select(ids.
|
|
143
|
+
editor.select(ids.test1).pointerDown(250, 250)
|
|
137
144
|
|
|
138
145
|
// try to snap our left edge to the right edge of the box shape - it should not snap
|
|
139
146
|
editor.pointerMove(155, 250, undefined, { ctrlKey: true })
|
|
@@ -162,10 +169,11 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
162
169
|
})
|
|
163
170
|
})
|
|
164
171
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
const TEST2_TYPE = 'test2'
|
|
173
|
+
|
|
174
|
+
declare module '@tldraw/tlschema' {
|
|
175
|
+
export interface TLGlobalShapePropsMap {
|
|
176
|
+
[TEST2_TYPE]: {
|
|
169
177
|
w: number
|
|
170
178
|
h: number
|
|
171
179
|
ownHandle: VecModel
|
|
@@ -175,10 +183,15 @@ describe('custom handle snapping', () => {
|
|
|
175
183
|
selfSnapPoints: VecModel[] | 'default'
|
|
176
184
|
handleSnapType?: 'point' | 'align'
|
|
177
185
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
type Test2Shape = TLShape<typeof TEST2_TYPE>
|
|
190
|
+
|
|
191
|
+
describe('custom handle snapping', () => {
|
|
192
|
+
class TestShapeUtil extends BaseBoxShapeUtil<Test2Shape> {
|
|
193
|
+
static override type = TEST2_TYPE
|
|
194
|
+
override getDefaultProps(): Test2Shape['props'] {
|
|
182
195
|
return {
|
|
183
196
|
w: 100,
|
|
184
197
|
h: 100,
|
|
@@ -195,7 +208,7 @@ describe('custom handle snapping', () => {
|
|
|
195
208
|
override indicator() {
|
|
196
209
|
throw new Error('Method not implemented.')
|
|
197
210
|
}
|
|
198
|
-
override getHandleSnapGeometry(shape:
|
|
211
|
+
override getHandleSnapGeometry(shape: Test2Shape) {
|
|
199
212
|
const { handleOutline, handlePoints, selfSnapOutline, selfSnapPoints } = shape.props
|
|
200
213
|
return {
|
|
201
214
|
outline:
|
|
@@ -213,7 +226,7 @@ describe('custom handle snapping', () => {
|
|
|
213
226
|
getSelfSnapPoints: selfSnapPoints === 'default' ? undefined : () => selfSnapPoints,
|
|
214
227
|
}
|
|
215
228
|
}
|
|
216
|
-
override getHandles(shape:
|
|
229
|
+
override getHandles(shape: Test2Shape): TLHandle[] {
|
|
217
230
|
const handle: TLHandle = {
|
|
218
231
|
id: 'handle',
|
|
219
232
|
label: 'handle',
|
|
@@ -232,7 +245,7 @@ describe('custom handle snapping', () => {
|
|
|
232
245
|
|
|
233
246
|
return [handle]
|
|
234
247
|
}
|
|
235
|
-
override onHandleDrag(shape:
|
|
248
|
+
override onHandleDrag(shape: Test2Shape, { handle }: TLHandleDragInfo<Test2Shape>) {
|
|
236
249
|
return { ...shape, props: { ...shape.props, ownHandle: { x: handle.x, y: handle.y } } }
|
|
237
250
|
}
|
|
238
251
|
}
|
|
@@ -252,7 +265,7 @@ describe('custom handle snapping', () => {
|
|
|
252
265
|
a2: { id: 'a2', index: 'a2' as IndexKey, x: 100, y: 100 },
|
|
253
266
|
}}
|
|
254
267
|
/>,
|
|
255
|
-
<TL.
|
|
268
|
+
<TL.test2 ref="test2" x={200} y={200} w={100} h={100} />,
|
|
256
269
|
])
|
|
257
270
|
})
|
|
258
271
|
|
|
@@ -295,9 +308,9 @@ describe('custom handle snapping', () => {
|
|
|
295
308
|
|
|
296
309
|
describe('with empty handleSnapGeometry.outline', () => {
|
|
297
310
|
beforeEach(() => {
|
|
298
|
-
editor.updateShape
|
|
299
|
-
id: ids.
|
|
300
|
-
type:
|
|
311
|
+
editor.updateShape({
|
|
312
|
+
id: ids.test2,
|
|
313
|
+
type: TEST2_TYPE,
|
|
301
314
|
props: { handleOutline: null },
|
|
302
315
|
})
|
|
303
316
|
})
|
|
@@ -312,9 +325,9 @@ describe('custom handle snapping', () => {
|
|
|
312
325
|
|
|
313
326
|
describe('with custom handleSnapGeometry.outline', () => {
|
|
314
327
|
beforeEach(() => {
|
|
315
|
-
editor.updateShape
|
|
316
|
-
id: ids.
|
|
317
|
-
type:
|
|
328
|
+
editor.updateShape({
|
|
329
|
+
id: ids.test2,
|
|
330
|
+
type: TEST2_TYPE,
|
|
318
331
|
props: {
|
|
319
332
|
// a diagonal line from the top left to the bottom right
|
|
320
333
|
handleOutline: [
|
|
@@ -359,9 +372,9 @@ describe('custom handle snapping', () => {
|
|
|
359
372
|
|
|
360
373
|
describe('with custom handleSnapGeometry.points', () => {
|
|
361
374
|
beforeEach(() => {
|
|
362
|
-
editor.updateShape
|
|
363
|
-
id: ids.
|
|
364
|
-
type:
|
|
375
|
+
editor.updateShape({
|
|
376
|
+
id: ids.test2,
|
|
377
|
+
type: TEST2_TYPE,
|
|
365
378
|
props: {
|
|
366
379
|
handlePoints: [
|
|
367
380
|
{ x: 30, y: 30 },
|
|
@@ -386,12 +399,12 @@ describe('custom handle snapping', () => {
|
|
|
386
399
|
|
|
387
400
|
describe('with custom handleSnapGeometry.points along the outline', () => {
|
|
388
401
|
beforeEach(() => {
|
|
389
|
-
editor.updateShape
|
|
390
|
-
id: ids.
|
|
391
|
-
type:
|
|
402
|
+
editor.updateShape({
|
|
403
|
+
id: ids.test2,
|
|
404
|
+
type: TEST2_TYPE,
|
|
392
405
|
props: {
|
|
393
406
|
handlePoints: editor
|
|
394
|
-
.getShapeGeometry(ids.
|
|
407
|
+
.getShapeGeometry(ids.test2)
|
|
395
408
|
.bounds.cornersAndCenter.map(({ x, y }) => ({ x, y })),
|
|
396
409
|
},
|
|
397
410
|
})
|
|
@@ -425,9 +438,9 @@ describe('custom handle snapping', () => {
|
|
|
425
438
|
describe('self snapping', () => {
|
|
426
439
|
beforeEach(() => {
|
|
427
440
|
editor.deleteShape(ids.line)
|
|
428
|
-
editor.updateShape
|
|
429
|
-
id: ids.
|
|
430
|
-
type:
|
|
441
|
+
editor.updateShape({
|
|
442
|
+
id: ids.test2,
|
|
443
|
+
type: TEST2_TYPE,
|
|
431
444
|
x: 0,
|
|
432
445
|
y: 0,
|
|
433
446
|
props: {
|
|
@@ -436,12 +449,12 @@ describe('custom handle snapping', () => {
|
|
|
436
449
|
})
|
|
437
450
|
})
|
|
438
451
|
function startDraggingOwnHandle() {
|
|
439
|
-
const shape = editor.select(ids.
|
|
452
|
+
const shape = editor.select(ids.test2).getOnlySelectedShape()!
|
|
440
453
|
const handles = editor.getShapeHandles(shape)!
|
|
441
454
|
editor.pointerDown(0, 0, { target: 'handle', shape, handle: handles[0] })
|
|
442
455
|
}
|
|
443
456
|
function ownHandlePosition() {
|
|
444
|
-
const shape = editor.select(ids.
|
|
457
|
+
const shape = editor.select(ids.test2).getOnlySelectedShape()!
|
|
445
458
|
const handle = editor.getShapeHandles(shape)![0]
|
|
446
459
|
return { x: handle.x, y: handle.y }
|
|
447
460
|
}
|
|
@@ -461,9 +474,9 @@ describe('custom handle snapping', () => {
|
|
|
461
474
|
})
|
|
462
475
|
describe('with custom self snap outline & points', () => {
|
|
463
476
|
beforeEach(() => {
|
|
464
|
-
editor.updateShape
|
|
465
|
-
id: ids.
|
|
466
|
-
type:
|
|
477
|
+
editor.updateShape({
|
|
478
|
+
id: ids.test2,
|
|
479
|
+
type: TEST2_TYPE,
|
|
467
480
|
props: {
|
|
468
481
|
selfSnapOutline: [
|
|
469
482
|
{ x: 20, y: 50 },
|
|
@@ -505,9 +518,9 @@ describe('custom handle snapping', () => {
|
|
|
505
518
|
|
|
506
519
|
describe('with snapType set to align', () => {
|
|
507
520
|
beforeEach(() => {
|
|
508
|
-
editor.updateShape
|
|
509
|
-
id: ids.
|
|
510
|
-
type:
|
|
521
|
+
editor.updateShape({
|
|
522
|
+
id: ids.test2,
|
|
523
|
+
type: TEST2_TYPE,
|
|
511
524
|
props: {
|
|
512
525
|
selfSnapPoints: [
|
|
513
526
|
{ x: 20, y: 50 },
|
|
@@ -541,3 +554,190 @@ describe('custom handle snapping', () => {
|
|
|
541
554
|
})
|
|
542
555
|
})
|
|
543
556
|
})
|
|
557
|
+
|
|
558
|
+
const BEZIER_TYPE = 'bezier'
|
|
559
|
+
|
|
560
|
+
declare module '@tldraw/tlschema' {
|
|
561
|
+
export interface TLGlobalShapePropsMap {
|
|
562
|
+
[BEZIER_TYPE]: {
|
|
563
|
+
start: VecModel
|
|
564
|
+
cp1: VecModel
|
|
565
|
+
cp2: VecModel
|
|
566
|
+
end: VecModel
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
type BezierShape = TLShape<typeof BEZIER_TYPE>
|
|
572
|
+
|
|
573
|
+
describe('custom adjacent handle for shift snapping', () => {
|
|
574
|
+
class BezierShapeUtil extends ShapeUtil<BezierShape> {
|
|
575
|
+
static override type = BEZIER_TYPE
|
|
576
|
+
override getDefaultProps() {
|
|
577
|
+
return {
|
|
578
|
+
start: { x: 0, y: 0 },
|
|
579
|
+
cp1: { x: 50, y: 0 },
|
|
580
|
+
cp2: { x: 50, y: 100 },
|
|
581
|
+
end: { x: 100, y: 100 },
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
override component() {
|
|
585
|
+
throw new Error('Method not implemented.')
|
|
586
|
+
}
|
|
587
|
+
override indicator() {
|
|
588
|
+
throw new Error('Method not implemented.')
|
|
589
|
+
}
|
|
590
|
+
override getGeometry() {
|
|
591
|
+
return new Polyline2d({ points: [] })
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
override getHandles(shape: BezierShape): TLHandle[] {
|
|
595
|
+
return [
|
|
596
|
+
{
|
|
597
|
+
id: 'start',
|
|
598
|
+
type: 'vertex',
|
|
599
|
+
index: 'a0' as IndexKey,
|
|
600
|
+
x: shape.props.start.x,
|
|
601
|
+
y: shape.props.start.y,
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
id: 'cp1',
|
|
605
|
+
type: 'vertex',
|
|
606
|
+
index: 'a1' as IndexKey,
|
|
607
|
+
x: shape.props.cp1.x,
|
|
608
|
+
y: shape.props.cp1.y,
|
|
609
|
+
snapReferenceHandleId: 'start', // cp1 snaps relative to start
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
id: 'cp2',
|
|
613
|
+
type: 'vertex',
|
|
614
|
+
index: 'a2' as IndexKey,
|
|
615
|
+
x: shape.props.cp2.x,
|
|
616
|
+
y: shape.props.cp2.y,
|
|
617
|
+
snapReferenceHandleId: 'end', // cp2 snaps relative to end
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
id: 'end',
|
|
621
|
+
type: 'vertex',
|
|
622
|
+
index: 'a3' as IndexKey,
|
|
623
|
+
x: shape.props.end.x,
|
|
624
|
+
y: shape.props.end.y,
|
|
625
|
+
},
|
|
626
|
+
]
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
override onHandleDrag(shape: BezierShape, { handle }: TLHandleDragInfo<BezierShape>) {
|
|
630
|
+
return {
|
|
631
|
+
...shape,
|
|
632
|
+
props: {
|
|
633
|
+
...shape.props,
|
|
634
|
+
[handle.id]: { x: handle.x, y: handle.y },
|
|
635
|
+
},
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
const shapeUtils = [BezierShapeUtil] as TLAnyShapeUtilConstructor[]
|
|
641
|
+
|
|
642
|
+
let editor: TestEditor
|
|
643
|
+
let ids: Record<string, TLShapeId>
|
|
644
|
+
|
|
645
|
+
beforeEach(() => {
|
|
646
|
+
editor = new TestEditor({ shapeUtils })
|
|
647
|
+
ids = editor.createShapesFromJsx([
|
|
648
|
+
<TL.bezier
|
|
649
|
+
ref="bezier"
|
|
650
|
+
x={0}
|
|
651
|
+
y={0}
|
|
652
|
+
start={{ x: 0, y: 0 }}
|
|
653
|
+
cp1={{ x: 50, y: 0 }}
|
|
654
|
+
cp2={{ x: 50, y: 100 }}
|
|
655
|
+
end={{ x: 100, y: 100 }}
|
|
656
|
+
/>,
|
|
657
|
+
])
|
|
658
|
+
})
|
|
659
|
+
|
|
660
|
+
test('cp1 snaps angle relative to start point when using custom adjacent handle', () => {
|
|
661
|
+
editor.select(ids.bezier)
|
|
662
|
+
const bezier = editor.getShape<BezierShape>(ids.bezier)!
|
|
663
|
+
const cp1Handle = editor.getShapeHandles(bezier)!.find((h) => h.id === 'cp1')!
|
|
664
|
+
|
|
665
|
+
// Start dragging cp1 handle
|
|
666
|
+
editor.pointerDown(cp1Handle.x, cp1Handle.y, {
|
|
667
|
+
target: 'handle',
|
|
668
|
+
shape: bezier,
|
|
669
|
+
handle: cp1Handle,
|
|
670
|
+
})
|
|
671
|
+
|
|
672
|
+
// Move with shift key - should snap angle relative to start (0, 0) not cp2
|
|
673
|
+
editor.pointerMove(60, 20, { shiftKey: true })
|
|
674
|
+
|
|
675
|
+
const updatedBezier = editor.getShape<BezierShape>(ids.bezier)!
|
|
676
|
+
const cp1Pos = updatedBezier.props.cp1
|
|
677
|
+
const startPos = updatedBezier.props.start
|
|
678
|
+
|
|
679
|
+
// The angle from start to cp1 should be snapped to nearest 15 degrees
|
|
680
|
+
const angle = Math.atan2(cp1Pos.y - startPos.y, cp1Pos.x - startPos.x)
|
|
681
|
+
const degrees = (angle * 180) / Math.PI
|
|
682
|
+
|
|
683
|
+
// Should snap to a multiple of 15 degrees (snapAngle uses 24 divisions = 15 degrees)
|
|
684
|
+
const remainder = ((degrees % 15) + 15) % 15
|
|
685
|
+
expect(Math.min(remainder, 15 - remainder)).toBeLessThan(1)
|
|
686
|
+
})
|
|
687
|
+
|
|
688
|
+
test('cp2 snaps angle relative to end point when using custom adjacent handle', () => {
|
|
689
|
+
editor.select(ids.bezier)
|
|
690
|
+
const bezier = editor.getShape<BezierShape>(ids.bezier)!
|
|
691
|
+
const cp2Handle = editor.getShapeHandles(bezier)!.find((h) => h.id === 'cp2')!
|
|
692
|
+
|
|
693
|
+
// Start dragging cp2 handle
|
|
694
|
+
editor.pointerDown(cp2Handle.x, cp2Handle.y, {
|
|
695
|
+
target: 'handle',
|
|
696
|
+
shape: bezier,
|
|
697
|
+
handle: cp2Handle,
|
|
698
|
+
})
|
|
699
|
+
|
|
700
|
+
// Move with shift key - should snap angle relative to end (100, 100)
|
|
701
|
+
editor.pointerMove(80, 80, { shiftKey: true })
|
|
702
|
+
|
|
703
|
+
const updatedBezier = editor.getShape<BezierShape>(ids.bezier)!
|
|
704
|
+
const cp2Pos = updatedBezier.props.cp2
|
|
705
|
+
const endPos = updatedBezier.props.end
|
|
706
|
+
|
|
707
|
+
// The angle from end to cp2 should be snapped to nearest 15 degrees
|
|
708
|
+
const angle = Math.atan2(cp2Pos.y - endPos.y, cp2Pos.x - endPos.x)
|
|
709
|
+
const degrees = (angle * 180) / Math.PI
|
|
710
|
+
|
|
711
|
+
// Should snap to a multiple of 15 degrees
|
|
712
|
+
const remainder = ((degrees % 15) + 15) % 15
|
|
713
|
+
expect(Math.min(remainder, 15 - remainder)).toBeLessThan(1)
|
|
714
|
+
})
|
|
715
|
+
|
|
716
|
+
test('default handles use default adjacent handle logic', () => {
|
|
717
|
+
editor.select(ids.bezier)
|
|
718
|
+
const bezier = editor.getShape<BezierShape>(ids.bezier)!
|
|
719
|
+
const startHandle = editor.getShapeHandles(bezier)!.find((h) => h.id === 'start')!
|
|
720
|
+
|
|
721
|
+
// Start dragging start handle
|
|
722
|
+
editor.pointerDown(startHandle.x, startHandle.y, {
|
|
723
|
+
target: 'handle',
|
|
724
|
+
shape: bezier,
|
|
725
|
+
handle: startHandle,
|
|
726
|
+
})
|
|
727
|
+
|
|
728
|
+
// Move with shift key - should use default logic (next vertex handle = cp1)
|
|
729
|
+
editor.pointerMove(10, 10, { shiftKey: true })
|
|
730
|
+
|
|
731
|
+
const updatedBezier = editor.getShape<BezierShape>(ids.bezier)!
|
|
732
|
+
const startPos = updatedBezier.props.start
|
|
733
|
+
const cp1Pos = updatedBezier.props.cp1
|
|
734
|
+
|
|
735
|
+
// The angle from cp1 to start should be snapped to nearest 15 degrees
|
|
736
|
+
const angle = Math.atan2(startPos.y - cp1Pos.y, startPos.x - cp1Pos.x)
|
|
737
|
+
const degrees = (angle * 180) / Math.PI
|
|
738
|
+
|
|
739
|
+
// Should snap to a multiple of 15 degrees
|
|
740
|
+
const remainder = ((degrees % 15) + 15) % 15
|
|
741
|
+
expect(Math.min(remainder, 15 - remainder)).toBeLessThan(1)
|
|
742
|
+
})
|
|
743
|
+
})
|
|
@@ -295,7 +295,7 @@ describe('When duplicating shapes that include arrows', () => {
|
|
|
295
295
|
.select(
|
|
296
296
|
...editor
|
|
297
297
|
.getCurrentPageShapes()
|
|
298
|
-
.filter((s) => editor.isShapeOfType
|
|
298
|
+
.filter((s) => editor.isShapeOfType(s, 'arrow'))
|
|
299
299
|
.map((s) => s.id)
|
|
300
300
|
)
|
|
301
301
|
|
package/src/test/frames.test.ts
CHANGED
|
@@ -1363,13 +1363,13 @@ describe('Unparenting behavior', () => {
|
|
|
1363
1363
|
|
|
1364
1364
|
// When the shape has a fill, it should not fall out of the frame
|
|
1365
1365
|
editor.undo()
|
|
1366
|
-
editor.updateShape
|
|
1366
|
+
editor.updateShape({ ...largeRect, props: { fill: 'solid' } })
|
|
1367
1367
|
dragOntoFrame()
|
|
1368
1368
|
expect(editor.getShape(largeRect.id)!.parentId).toBe(frameId)
|
|
1369
1369
|
|
|
1370
1370
|
// When the shape has a label and that label is on top of the frame, it should not fall out of the frame
|
|
1371
1371
|
editor.undo()
|
|
1372
|
-
editor.updateShape
|
|
1372
|
+
editor.updateShape({
|
|
1373
1373
|
...largeRect,
|
|
1374
1374
|
props: { fill: 'none', richText: toRichText('hello') },
|
|
1375
1375
|
})
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Box,
|
|
4
4
|
RecordProps,
|
|
5
5
|
T,
|
|
6
|
-
|
|
6
|
+
TLShape,
|
|
7
7
|
TLShapeId,
|
|
8
8
|
createShapeId,
|
|
9
9
|
} from '@tldraw/editor'
|
|
@@ -11,11 +11,19 @@ import { vi } from 'vitest'
|
|
|
11
11
|
import { TestEditor } from './TestEditor'
|
|
12
12
|
import { TL } from './test-jsx'
|
|
13
13
|
|
|
14
|
+
const UNCULLABLE_TYPE = 'uncullable'
|
|
15
|
+
|
|
16
|
+
declare module '@tldraw/tlschema' {
|
|
17
|
+
export interface TLGlobalShapePropsMap {
|
|
18
|
+
[UNCULLABLE_TYPE]: { w: number; h: number }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
// Custom uncullable shape type for testing canCull override
|
|
15
|
-
type UncullableShape =
|
|
23
|
+
type UncullableShape = TLShape<typeof UNCULLABLE_TYPE>
|
|
16
24
|
|
|
17
25
|
class UncullableShapeUtil extends BaseBoxShapeUtil<UncullableShape> {
|
|
18
|
-
static override type =
|
|
26
|
+
static override type = UNCULLABLE_TYPE
|
|
19
27
|
static override props: RecordProps<UncullableShape> = {
|
|
20
28
|
w: T.number,
|
|
21
29
|
h: T.number,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TLShape, createShapeId, toRichText } from '@tldraw/editor'
|
|
2
2
|
import { TestEditor } from './TestEditor'
|
|
3
3
|
|
|
4
4
|
let editor: TestEditor
|
|
@@ -146,7 +146,7 @@ describe('with hitLabels=true', () => {
|
|
|
146
146
|
it('hits geo shape label behind overlapping hollow shape', () => {
|
|
147
147
|
// label is empty
|
|
148
148
|
expect(editor.getShapeAtPoint({ x: 350, y: 350 }, opts)?.id).toBe(ids.box3)
|
|
149
|
-
editor.updateShape
|
|
149
|
+
editor.updateShape({
|
|
150
150
|
id: ids.box2,
|
|
151
151
|
type: 'geo',
|
|
152
152
|
props: { richText: toRichText('hello') },
|
package/src/test/groups.test.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Box,
|
|
3
|
+
ExtractShapeByProps,
|
|
3
4
|
GroupShapeUtil,
|
|
4
5
|
TLArrowShape,
|
|
5
6
|
TLGroupShape,
|
|
@@ -35,14 +36,16 @@ const ids = {
|
|
|
35
36
|
groupA: createShapeId('groupA'),
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
type BoxShape = ExtractShapeByProps<{ fill: string }>
|
|
40
|
+
|
|
38
41
|
const box = (
|
|
39
42
|
id: TLShapeId,
|
|
40
43
|
x: number,
|
|
41
44
|
y: number,
|
|
42
45
|
w = 10,
|
|
43
46
|
h = 10,
|
|
44
|
-
fill = 'solid'
|
|
45
|
-
): TLShapePartial => ({
|
|
47
|
+
fill: BoxShape['props']['fill'] = 'solid'
|
|
48
|
+
): TLShapePartial<BoxShape> => ({
|
|
46
49
|
type: 'geo',
|
|
47
50
|
id,
|
|
48
51
|
x,
|
|
@@ -1980,7 +1983,7 @@ describe('Group opacity', () => {
|
|
|
1980
1983
|
editor.setOpacityForNextShapes(0.5)
|
|
1981
1984
|
editor.groupShapes(editor.getSelectedShapeIds())
|
|
1982
1985
|
const group = editor.getShape(onlySelectedId())!
|
|
1983
|
-
assert(editor.isShapeOfType
|
|
1986
|
+
assert(editor.isShapeOfType(group, 'group'))
|
|
1984
1987
|
expect(group.opacity).toBe(1)
|
|
1985
1988
|
})
|
|
1986
1989
|
})
|
|
@@ -3876,10 +3876,8 @@ it('uses the cross cursor when create resizing', () => {
|
|
|
3876
3876
|
describe('Resizing text from the right edge', () => {
|
|
3877
3877
|
it('Resizes text from the right edge', () => {
|
|
3878
3878
|
const id = createShapeId()
|
|
3879
|
-
editor.createShapes
|
|
3880
|
-
editor.updateShapes
|
|
3881
|
-
{ id, type: 'text', props: { richText: toRichText('Hello World') } },
|
|
3882
|
-
]) // auto size
|
|
3879
|
+
editor.createShapes([{ id, type: 'text', props: { richText: toRichText('H') } }])
|
|
3880
|
+
editor.updateShapes([{ id, type: 'text', props: { richText: toRichText('Hello World') } }]) // auto size
|
|
3883
3881
|
|
|
3884
3882
|
editor.select(id)
|
|
3885
3883
|
|
|
@@ -3905,10 +3903,8 @@ describe('Resizing text from the right edge', () => {
|
|
|
3905
3903
|
editor.updateInstanceState({ isCoarsePointer: true })
|
|
3906
3904
|
|
|
3907
3905
|
const id = createShapeId()
|
|
3908
|
-
editor.createShapes
|
|
3909
|
-
editor.updateShapes
|
|
3910
|
-
{ id, type: 'text', props: { richText: toRichText('Hello World') } },
|
|
3911
|
-
]) // auto size
|
|
3906
|
+
editor.createShapes([{ id, type: 'text', props: { richText: toRichText('H') } }])
|
|
3907
|
+
editor.updateShapes([{ id, type: 'text', props: { richText: toRichText('Hello World') } }]) // auto size
|
|
3912
3908
|
|
|
3913
3909
|
editor.select(id)
|
|
3914
3910
|
|
|
@@ -3954,7 +3950,7 @@ describe('When resizing near the edges of the screen', () => {
|
|
|
3954
3950
|
|
|
3955
3951
|
describe('resizing text with autosize true', () => {
|
|
3956
3952
|
it('resizes text from the right side', () => {
|
|
3957
|
-
editor.createShape
|
|
3953
|
+
editor.createShape({
|
|
3958
3954
|
type: 'text',
|
|
3959
3955
|
x: 0,
|
|
3960
3956
|
y: 0,
|
|
@@ -3980,7 +3976,7 @@ describe('resizing text with autosize true', () => {
|
|
|
3980
3976
|
})
|
|
3981
3977
|
|
|
3982
3978
|
it('resizes text from the right side when alt key is pressed', () => {
|
|
3983
|
-
editor.createShape
|
|
3979
|
+
editor.createShape({
|
|
3984
3980
|
type: 'text',
|
|
3985
3981
|
x: 0,
|
|
3986
3982
|
y: 0,
|
|
@@ -4007,7 +4003,7 @@ describe('resizing text with autosize true', () => {
|
|
|
4007
4003
|
})
|
|
4008
4004
|
|
|
4009
4005
|
it('resizes text from the left side', () => {
|
|
4010
|
-
editor.createShape
|
|
4006
|
+
editor.createShape({
|
|
4011
4007
|
type: 'text',
|
|
4012
4008
|
x: 0,
|
|
4013
4009
|
y: 0,
|
|
@@ -4033,7 +4029,7 @@ describe('resizing text with autosize true', () => {
|
|
|
4033
4029
|
})
|
|
4034
4030
|
|
|
4035
4031
|
it('resizes text from the left side when alt is pressed', () => {
|
|
4036
|
-
editor.createShape
|
|
4032
|
+
editor.createShape({
|
|
4037
4033
|
type: 'text',
|
|
4038
4034
|
x: 0,
|
|
4039
4035
|
y: 0,
|
|
@@ -4062,7 +4058,7 @@ describe('resizing text with autosize true', () => {
|
|
|
4062
4058
|
|
|
4063
4059
|
describe('cancelling a resize operation', () => {
|
|
4064
4060
|
it('undoes any changes since the start of the resize operation', () => {
|
|
4065
|
-
editor.createShape
|
|
4061
|
+
editor.createShape({
|
|
4066
4062
|
type: 'geo',
|
|
4067
4063
|
x: 0,
|
|
4068
4064
|
y: 0,
|