tldraw 3.15.0-next.f1dfcef63951 → 3.16.0-next.c30b1b5e551a
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 +161 -95
- package/dist-cjs/index.js +42 -31
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawImage.js +5 -2
- package/dist-cjs/lib/TldrawImage.js.map +3 -3
- package/dist-cjs/lib/canvas/TldrawCropHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawCropHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawOverlays.js +1 -1
- package/dist-cjs/lib/canvas/TldrawOverlays.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +279 -271
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +1 -0
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +22 -36
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +16 -4
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +3 -0
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +5 -5
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js +15 -1
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PathBuilder.js +21 -3
- package/dist-cjs/lib/shapes/shared/PathBuilder.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +1 -0
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +1 -0
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -11
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/styles.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +43 -22
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +2 -15
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +5 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +8 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +8 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +8 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +51 -1
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +1 -0
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +3 -4
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/Spinner.js +2 -25
- package/dist-cjs/lib/ui/components/Spinner.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +2 -1
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js +16 -0
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/Button/TldrawUiButtonIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js +35 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +6 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +1 -0
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +0 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +42 -8
- 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 +24 -7
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.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 +8 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/kbd-utils.js +2 -1
- package/dist-cjs/lib/ui/kbd-utils.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 +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +3 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +161 -95
- package/dist-esm/index.mjs +154 -135
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawImage.mjs +5 -2
- package/dist-esm/lib/TldrawImage.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawOverlays.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawOverlays.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +279 -271
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +1 -0
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +24 -36
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +19 -5
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +3 -0
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +5 -5
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +15 -1
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs +22 -3
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +1 -0
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +1 -0
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -11
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/styles.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +43 -22
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +2 -15
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +5 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +8 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +8 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +8 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +51 -1
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +2 -0
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +3 -4
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Spinner.mjs +3 -26
- package/dist-esm/lib/ui/components/Spinner.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +2 -1
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +16 -0
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/Button/TldrawUiButtonIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs +36 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +6 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +1 -0
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +0 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +42 -8
- 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.map +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +24 -7
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +8 -0
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/kbd-utils.mjs +2 -1
- package/dist-esm/lib/ui/kbd-utils.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 +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +3 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +4 -3
- package/src/index.ts +174 -160
- package/src/lib/TldrawImage.tsx +6 -2
- package/src/lib/canvas/TldrawCropHandles.tsx +3 -1
- package/src/lib/canvas/TldrawHandles.tsx +5 -1
- package/src/lib/canvas/TldrawOverlays.tsx +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +5 -1
- package/src/lib/defaultExternalContentHandlers.ts +2 -1
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +5 -5
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +25 -39
- package/src/lib/shapes/arrow/arrowLabel.ts +23 -3
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +3 -0
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +5 -7
- package/src/lib/shapes/line/LineShapeUtil.tsx +19 -2
- package/src/lib/shapes/shared/PathBuilder.test.tsx +1 -1
- package/src/lib/shapes/shared/PathBuilder.tsx +35 -1
- package/src/lib/shapes/shared/PlainTextLabel.tsx +1 -0
- package/src/lib/shapes/shared/RichTextLabel.tsx +1 -0
- package/src/lib/shapes/text/TextShapeUtil.tsx +5 -12
- package/src/lib/styles.tsx +3 -1
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +54 -30
- package/src/lib/tools/SelectTool/childStates/Idle.ts +2 -24
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +7 -0
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +12 -1
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +11 -0
- package/src/lib/tools/SelectTool/childStates/Translating.ts +11 -0
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -0
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +40 -0
- package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +2 -0
- package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +3 -4
- package/src/lib/ui/components/Spinner.tsx +2 -24
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +1 -0
- package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +3 -1
- package/src/lib/ui/components/menu-items.tsx +17 -0
- package/src/lib/ui/components/primitives/Button/TldrawUiButtonIcon.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiIcon.tsx +41 -3
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +6 -1
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +4 -0
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +2 -2
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +3 -4
- package/src/lib/ui/context/actions.tsx +44 -9
- package/src/lib/ui/context/events.tsx +4 -2
- package/src/lib/ui/hooks/menu-hooks.ts +1 -0
- package/src/lib/ui/hooks/useClipboardEvents.ts +31 -10
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +3 -2
- package/src/lib/ui/hooks/useTools.tsx +2 -1
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +8 -0
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +8 -0
- package/src/lib/ui/kbd-utils.ts +2 -1
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +8 -22
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +16 -2
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +1 -1
- package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +24 -3
- package/src/lib/utils/tldr/buildFromV1Document.ts +2 -1
- package/src/test/Editor.test.tsx +68 -1
- package/src/test/SelectTool.test.ts +37 -11
- package/src/test/commands/clipboard.test.ts +1 -1
- package/src/test/commands/deletePage.test.ts +84 -1
- package/src/test/navigation.test.ts +254 -0
- package/src/test/shapeutils.test.ts +394 -45
- package/tldraw.css +29 -49
- package/src/test/editor.test.ts +0 -77
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PageRecordType } from '@tldraw/editor'
|
|
1
|
+
import { PageRecordType, createShapeId } from '@tldraw/editor'
|
|
2
2
|
import { TestEditor } from '../TestEditor'
|
|
3
3
|
|
|
4
4
|
let editor: TestEditor
|
|
@@ -76,4 +76,87 @@ describe('deletePage', () => {
|
|
|
76
76
|
expect(editor.getCurrentPageId()).not.toBe(currentPageId)
|
|
77
77
|
expect(editor.getCurrentPageId()).toBe(editor.getPages()[0].id)
|
|
78
78
|
})
|
|
79
|
+
|
|
80
|
+
it('deletes all shapes that belong to the deleted page', () => {
|
|
81
|
+
// Create a second page
|
|
82
|
+
const page2Id = PageRecordType.createId('page2')
|
|
83
|
+
editor.createPage({ name: 'Page 2', id: page2Id })
|
|
84
|
+
|
|
85
|
+
// Switch to the second page
|
|
86
|
+
editor.setCurrentPage(page2Id)
|
|
87
|
+
|
|
88
|
+
// Add some shapes to the second page
|
|
89
|
+
const shape1Id = createShapeId('shape1')
|
|
90
|
+
const shape2Id = createShapeId('shape2')
|
|
91
|
+
const shape3Id = createShapeId('shape3')
|
|
92
|
+
|
|
93
|
+
editor.createShape({ id: shape1Id, type: 'text', x: 100, y: 100 })
|
|
94
|
+
editor.createShape({ id: shape2Id, type: 'geo', x: 200, y: 200, props: { geo: 'rectangle' } })
|
|
95
|
+
editor.createShape({ id: shape3Id, type: 'geo', x: 300, y: 300, props: { geo: 'ellipse' } })
|
|
96
|
+
|
|
97
|
+
// Verify shapes were created and belong to the second page
|
|
98
|
+
expect(editor.getShape(shape1Id)).toBeDefined()
|
|
99
|
+
expect(editor.getShape(shape2Id)).toBeDefined()
|
|
100
|
+
expect(editor.getShape(shape3Id)).toBeDefined()
|
|
101
|
+
expect(editor.getShape(shape1Id)?.parentId).toBe(page2Id)
|
|
102
|
+
expect(editor.getShape(shape2Id)?.parentId).toBe(page2Id)
|
|
103
|
+
expect(editor.getShape(shape3Id)?.parentId).toBe(page2Id)
|
|
104
|
+
|
|
105
|
+
// Delete the second page
|
|
106
|
+
editor.deletePage(page2Id)
|
|
107
|
+
|
|
108
|
+
// Verify the page was deleted
|
|
109
|
+
expect(editor.getPages().length).toBe(1)
|
|
110
|
+
expect(editor.getPages()[0].id).not.toBe(page2Id)
|
|
111
|
+
|
|
112
|
+
// Verify all shapes that belonged to the deleted page were also deleted
|
|
113
|
+
expect(editor.getShape(shape1Id)).toBeUndefined()
|
|
114
|
+
expect(editor.getShape(shape2Id)).toBeUndefined()
|
|
115
|
+
expect(editor.getShape(shape3Id)).toBeUndefined()
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
it('deletes locked shapes that belong to the deleted page', () => {
|
|
119
|
+
// Create a second page
|
|
120
|
+
const page2Id = PageRecordType.createId('page2')
|
|
121
|
+
editor.createPage({ name: 'Page 2', id: page2Id })
|
|
122
|
+
|
|
123
|
+
// Switch to the second page
|
|
124
|
+
editor.setCurrentPage(page2Id)
|
|
125
|
+
|
|
126
|
+
// Add some shapes to the second page
|
|
127
|
+
const shape1Id = createShapeId('shape1')
|
|
128
|
+
const shape2Id = createShapeId('shape2')
|
|
129
|
+
const shape3Id = createShapeId('shape3')
|
|
130
|
+
|
|
131
|
+
editor.createShape({ id: shape1Id, type: 'text', x: 100, y: 100 })
|
|
132
|
+
editor.createShape({ id: shape2Id, type: 'geo', x: 200, y: 200, props: { geo: 'rectangle' } })
|
|
133
|
+
editor.createShape({ id: shape3Id, type: 'geo', x: 300, y: 300, props: { geo: 'ellipse' } })
|
|
134
|
+
|
|
135
|
+
// Lock some of the shapes
|
|
136
|
+
editor.updateShape({ id: shape1Id, type: 'text', isLocked: true })
|
|
137
|
+
editor.updateShape({ id: shape2Id, type: 'geo', isLocked: true })
|
|
138
|
+
|
|
139
|
+
// Verify shapes were created and belong to the second page
|
|
140
|
+
expect(editor.getShape(shape1Id)).toBeDefined()
|
|
141
|
+
expect(editor.getShape(shape2Id)).toBeDefined()
|
|
142
|
+
expect(editor.getShape(shape3Id)).toBeDefined()
|
|
143
|
+
expect(editor.getShape(shape1Id)?.parentId).toBe(page2Id)
|
|
144
|
+
expect(editor.getShape(shape2Id)?.parentId).toBe(page2Id)
|
|
145
|
+
expect(editor.getShape(shape3Id)?.parentId).toBe(page2Id)
|
|
146
|
+
expect(editor.getShape(shape1Id)?.isLocked).toBe(true)
|
|
147
|
+
expect(editor.getShape(shape2Id)?.isLocked).toBe(true)
|
|
148
|
+
expect(editor.getShape(shape3Id)?.isLocked).toBe(false)
|
|
149
|
+
|
|
150
|
+
// Delete the second page
|
|
151
|
+
editor.deletePage(page2Id)
|
|
152
|
+
|
|
153
|
+
// Verify the page was deleted
|
|
154
|
+
expect(editor.getPages().length).toBe(1)
|
|
155
|
+
expect(editor.getPages()[0].id).not.toBe(page2Id)
|
|
156
|
+
|
|
157
|
+
// Verify all shapes that belonged to the deleted page were also deleted, including locked ones
|
|
158
|
+
expect(editor.getShape(shape1Id)).toBeUndefined()
|
|
159
|
+
expect(editor.getShape(shape2Id)).toBeUndefined()
|
|
160
|
+
expect(editor.getShape(shape3Id)).toBeUndefined()
|
|
161
|
+
})
|
|
79
162
|
})
|
|
@@ -414,6 +414,260 @@ describe('Shape navigation', () => {
|
|
|
414
414
|
expect(editor.getSelectedShapeIds()).toEqual([])
|
|
415
415
|
})
|
|
416
416
|
|
|
417
|
+
it('respects container boundaries when navigating with left/right', () => {
|
|
418
|
+
// Create a frame with shapes inside and shapes outside
|
|
419
|
+
editor.createShapes([
|
|
420
|
+
{
|
|
421
|
+
id: ids.frame1,
|
|
422
|
+
type: 'frame',
|
|
423
|
+
x: 0,
|
|
424
|
+
y: 0,
|
|
425
|
+
props: {
|
|
426
|
+
w: 200,
|
|
427
|
+
h: 200,
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
// Shapes inside frame
|
|
431
|
+
{
|
|
432
|
+
id: ids.box1,
|
|
433
|
+
type: 'geo',
|
|
434
|
+
x: 10,
|
|
435
|
+
y: 100,
|
|
436
|
+
parentId: ids.frame1,
|
|
437
|
+
props: {
|
|
438
|
+
w: 30,
|
|
439
|
+
h: 30,
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
id: ids.box2,
|
|
444
|
+
type: 'geo',
|
|
445
|
+
x: 50,
|
|
446
|
+
y: 100,
|
|
447
|
+
parentId: ids.frame1,
|
|
448
|
+
props: {
|
|
449
|
+
w: 30,
|
|
450
|
+
h: 30,
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
id: ids.box3,
|
|
455
|
+
type: 'geo',
|
|
456
|
+
x: 90,
|
|
457
|
+
y: 100,
|
|
458
|
+
parentId: ids.frame1,
|
|
459
|
+
props: {
|
|
460
|
+
w: 30,
|
|
461
|
+
h: 30,
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
// Shapes outside frame
|
|
465
|
+
{
|
|
466
|
+
id: ids.box4,
|
|
467
|
+
type: 'geo',
|
|
468
|
+
x: 300,
|
|
469
|
+
y: 100,
|
|
470
|
+
props: {
|
|
471
|
+
w: 30,
|
|
472
|
+
h: 30,
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
id: ids.box5,
|
|
477
|
+
type: 'geo',
|
|
478
|
+
x: 350,
|
|
479
|
+
y: 100,
|
|
480
|
+
props: {
|
|
481
|
+
w: 30,
|
|
482
|
+
h: 30,
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
])
|
|
486
|
+
|
|
487
|
+
// Setup shape centers for consistent testing
|
|
488
|
+
jest.spyOn(editor, 'getShapePageBounds').mockImplementation((shape: any) => {
|
|
489
|
+
const positions = {
|
|
490
|
+
[ids.box1]: { x: 25, y: 115 },
|
|
491
|
+
[ids.box2]: { x: 65, y: 115 },
|
|
492
|
+
[ids.box3]: { x: 105, y: 115 },
|
|
493
|
+
[ids.box4]: { x: 315, y: 115 },
|
|
494
|
+
[ids.box5]: { x: 365, y: 115 },
|
|
495
|
+
}
|
|
496
|
+
const pos = positions[shape?.id as keyof typeof positions]
|
|
497
|
+
return pos ? ({ center: pos } as any) : ({ center: { x: 0, y: 0 } } as any)
|
|
498
|
+
})
|
|
499
|
+
|
|
500
|
+
// Select a shape inside the frame
|
|
501
|
+
editor.select(ids.box1)
|
|
502
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
503
|
+
|
|
504
|
+
// Navigate right - should stay within the frame
|
|
505
|
+
editor.selectAdjacentShape('right')
|
|
506
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box2])
|
|
507
|
+
|
|
508
|
+
// Continue navigating right - should still stay within the frame
|
|
509
|
+
editor.selectAdjacentShape('right')
|
|
510
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box3])
|
|
511
|
+
|
|
512
|
+
// Navigate right again - should not leave the frame to go to box4
|
|
513
|
+
editor.selectAdjacentShape('right')
|
|
514
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box3]) // Should stay at box3
|
|
515
|
+
|
|
516
|
+
// Now navigate left to test the other direction
|
|
517
|
+
editor.selectAdjacentShape('left')
|
|
518
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box2])
|
|
519
|
+
|
|
520
|
+
editor.selectAdjacentShape('left')
|
|
521
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
522
|
+
|
|
523
|
+
// Navigate left again - should not leave the frame
|
|
524
|
+
editor.selectAdjacentShape('left')
|
|
525
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box1]) // Should stay at box1
|
|
526
|
+
|
|
527
|
+
// Now test navigation outside the frame
|
|
528
|
+
editor.select(ids.box4)
|
|
529
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box4])
|
|
530
|
+
|
|
531
|
+
// Navigate right - should move to box5
|
|
532
|
+
editor.selectAdjacentShape('right')
|
|
533
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box5])
|
|
534
|
+
|
|
535
|
+
// Navigate left - should move back to box4
|
|
536
|
+
editor.selectAdjacentShape('left')
|
|
537
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box4])
|
|
538
|
+
|
|
539
|
+
// Navigate left again - should select the frame (nearest shape to the left)
|
|
540
|
+
editor.selectAdjacentShape('left')
|
|
541
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.frame1]) // Should select frame1
|
|
542
|
+
})
|
|
543
|
+
|
|
544
|
+
it('respects container boundaries when navigating with up/down', () => {
|
|
545
|
+
// Create a frame with shapes inside and shapes outside
|
|
546
|
+
editor.createShapes([
|
|
547
|
+
{
|
|
548
|
+
id: ids.frame1,
|
|
549
|
+
type: 'frame',
|
|
550
|
+
x: 0,
|
|
551
|
+
y: 0,
|
|
552
|
+
props: {
|
|
553
|
+
w: 200,
|
|
554
|
+
h: 200,
|
|
555
|
+
},
|
|
556
|
+
},
|
|
557
|
+
// Shapes inside frame - vertically arranged
|
|
558
|
+
{
|
|
559
|
+
id: ids.box1,
|
|
560
|
+
type: 'geo',
|
|
561
|
+
x: 100,
|
|
562
|
+
y: 10,
|
|
563
|
+
parentId: ids.frame1,
|
|
564
|
+
props: {
|
|
565
|
+
w: 30,
|
|
566
|
+
h: 30,
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
id: ids.box2,
|
|
571
|
+
type: 'geo',
|
|
572
|
+
x: 100,
|
|
573
|
+
y: 50,
|
|
574
|
+
parentId: ids.frame1,
|
|
575
|
+
props: {
|
|
576
|
+
w: 30,
|
|
577
|
+
h: 30,
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
id: ids.box3,
|
|
582
|
+
type: 'geo',
|
|
583
|
+
x: 100,
|
|
584
|
+
y: 90,
|
|
585
|
+
parentId: ids.frame1,
|
|
586
|
+
props: {
|
|
587
|
+
w: 30,
|
|
588
|
+
h: 30,
|
|
589
|
+
},
|
|
590
|
+
},
|
|
591
|
+
// Shapes outside frame - vertically arranged
|
|
592
|
+
{
|
|
593
|
+
id: ids.box4,
|
|
594
|
+
type: 'geo',
|
|
595
|
+
x: 300,
|
|
596
|
+
y: 10,
|
|
597
|
+
props: {
|
|
598
|
+
w: 30,
|
|
599
|
+
h: 30,
|
|
600
|
+
},
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
id: ids.box5,
|
|
604
|
+
type: 'geo',
|
|
605
|
+
x: 300,
|
|
606
|
+
y: 50,
|
|
607
|
+
props: {
|
|
608
|
+
w: 30,
|
|
609
|
+
h: 30,
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
])
|
|
613
|
+
|
|
614
|
+
// Setup shape centers for consistent testing
|
|
615
|
+
jest.spyOn(editor, 'getShapePageBounds').mockImplementation((shape: any) => {
|
|
616
|
+
const positions = {
|
|
617
|
+
[ids.box1]: { x: 115, y: 25 },
|
|
618
|
+
[ids.box2]: { x: 115, y: 65 },
|
|
619
|
+
[ids.box3]: { x: 115, y: 105 },
|
|
620
|
+
[ids.box4]: { x: 315, y: 25 },
|
|
621
|
+
[ids.box5]: { x: 315, y: 65 },
|
|
622
|
+
}
|
|
623
|
+
const pos = positions[shape?.id as keyof typeof positions]
|
|
624
|
+
return pos ? ({ center: pos } as any) : ({ center: { x: 0, y: 0 } } as any)
|
|
625
|
+
})
|
|
626
|
+
|
|
627
|
+
// Select a shape inside the frame
|
|
628
|
+
editor.select(ids.box1)
|
|
629
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
630
|
+
|
|
631
|
+
// Navigate down - should stay within the frame
|
|
632
|
+
editor.selectAdjacentShape('down')
|
|
633
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box2])
|
|
634
|
+
|
|
635
|
+
// Continue navigating down - should still stay within the frame
|
|
636
|
+
editor.selectAdjacentShape('down')
|
|
637
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box3])
|
|
638
|
+
|
|
639
|
+
// Navigate down again - should not leave the frame
|
|
640
|
+
editor.selectAdjacentShape('down')
|
|
641
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box3]) // Should stay at box3
|
|
642
|
+
|
|
643
|
+
// Now navigate up to test the other direction
|
|
644
|
+
editor.selectAdjacentShape('up')
|
|
645
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box2])
|
|
646
|
+
|
|
647
|
+
editor.selectAdjacentShape('up')
|
|
648
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
649
|
+
|
|
650
|
+
// Navigate up again - should not leave the frame
|
|
651
|
+
editor.selectAdjacentShape('up')
|
|
652
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box1]) // Should stay at box1
|
|
653
|
+
|
|
654
|
+
// Now test navigation outside the frame
|
|
655
|
+
editor.select(ids.box4)
|
|
656
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box4])
|
|
657
|
+
|
|
658
|
+
// Navigate down - should move to box5
|
|
659
|
+
editor.selectAdjacentShape('down')
|
|
660
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box5])
|
|
661
|
+
|
|
662
|
+
// Navigate up - should move back to box4
|
|
663
|
+
editor.selectAdjacentShape('up')
|
|
664
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box4])
|
|
665
|
+
|
|
666
|
+
// Navigate up again - should not enter the frame
|
|
667
|
+
editor.selectAdjacentShape('up')
|
|
668
|
+
expect(editor.getSelectedShapeIds()).toEqual([ids.box4]) // Should stay at box4
|
|
669
|
+
})
|
|
670
|
+
|
|
417
671
|
it('respects container boundaries when navigating with Tab', () => {
|
|
418
672
|
// Create a frame with shapes inside and shapes outside
|
|
419
673
|
editor.createShapes([
|