@bigbluebutton/tldraw 2.0.0-alpha.23 → 2.0.0-alpha.25
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 +9 -1
- package/dist-cjs/lib/defaultShapeUtils.js +3 -1
- package/dist-cjs/lib/defaultShapeUtils.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/poll/PollShapeTool.js +30 -0
- package/dist-cjs/lib/shapes/poll/PollShapeTool.js.map +7 -0
- package/dist-cjs/lib/shapes/poll/PollShapeUtil.js +121 -0
- package/dist-cjs/lib/shapes/poll/PollShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/poll/components/poll-content.js +101 -0
- package/dist-cjs/lib/shapes/poll/components/poll-content.js.map +7 -0
- package/dist-cjs/lib/shapes/poll/components/styles.js +53 -0
- package/dist-cjs/lib/shapes/poll/components/styles.js.map +7 -0
- package/dist-cjs/lib/shapes/poll/poll-shape-migrations.js +45 -0
- package/dist-cjs/lib/shapes/poll/poll-shape-migrations.js.map +7 -0
- package/dist-cjs/lib/shapes/poll/poll-shape-props.js +39 -0
- package/dist-cjs/lib/shapes/poll/poll-shape-props.js.map +7 -0
- package/dist-cjs/lib/shapes/poll/poll-shape-types.js +17 -0
- package/dist-cjs/lib/shapes/poll/poll-shape-types.js.map +7 -0
- package/dist-cjs/lib/tools/HandTool/HandTool.js +3 -3
- package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu.js +0 -1
- package/dist-cjs/lib/ui/components/ContextMenu.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 +6 -1
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTranslation/translations.js +1 -1
- package/dist-cjs/lib/ui/hooks/useTranslation/translations.js.map +2 -2
- package/dist-esm/index.d.mts +9 -1
- package/dist-esm/lib/defaultShapeUtils.mjs +3 -1
- package/dist-esm/lib/defaultShapeUtils.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/poll/PollShapeTool.mjs +10 -0
- package/dist-esm/lib/shapes/poll/PollShapeTool.mjs.map +7 -0
- package/dist-esm/lib/shapes/poll/PollShapeUtil.mjs +97 -0
- package/dist-esm/lib/shapes/poll/PollShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/poll/components/poll-content.mjs +71 -0
- package/dist-esm/lib/shapes/poll/components/poll-content.mjs.map +7 -0
- package/dist-esm/lib/shapes/poll/components/styles.mjs +23 -0
- package/dist-esm/lib/shapes/poll/components/styles.mjs.map +7 -0
- package/dist-esm/lib/shapes/poll/poll-shape-migrations.mjs +25 -0
- package/dist-esm/lib/shapes/poll/poll-shape-migrations.mjs.map +7 -0
- package/dist-esm/lib/shapes/poll/poll-shape-props.mjs +19 -0
- package/dist-esm/lib/shapes/poll/poll-shape-props.mjs.map +7 -0
- package/dist-esm/lib/shapes/poll/poll-shape-types.mjs +1 -0
- package/dist-esm/lib/shapes/poll/poll-shape-types.mjs.map +7 -0
- package/dist-esm/lib/tools/HandTool/HandTool.mjs +3 -3
- package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu.mjs +0 -1
- package/dist-esm/lib/ui/components/ContextMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +6 -1
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/translations.mjs +1 -1
- package/dist-esm/lib/ui/hooks/useTranslation/translations.mjs.map +2 -2
- package/package.json +4 -3
- package/src/lib/Tldraw.test.tsx +9 -13
- package/src/lib/defaultShapeUtils.ts +2 -0
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +1 -1
- package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.ts.snap +6 -6
- package/src/lib/shapes/poll/PollShapeTool.tsx +7 -0
- package/src/lib/shapes/poll/PollShapeUtil.tsx +108 -0
- package/src/lib/shapes/poll/components/poll-content.tsx +100 -0
- package/src/lib/shapes/poll/components/styles.ts +21 -0
- package/src/lib/shapes/poll/poll-shape-migrations.ts +23 -0
- package/src/lib/shapes/poll/poll-shape-props.ts +17 -0
- package/src/lib/shapes/poll/poll-shape-types.ts +21 -0
- package/src/lib/tools/HandTool/HandTool.ts +4 -5
- package/src/lib/ui/components/ContextMenu.tsx +1 -1
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +5 -0
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +5 -0
- package/src/lib/ui/hooks/useTranslation/translations.ts +1 -1
- package/src/test/Editor.test.tsx +2 -2
- package/src/test/HandTool.test.ts +55 -56
- package/src/test/TLSessionStateSnapshot.test.ts +5 -5
- package/src/test/TestEditor.ts +4 -1
- package/src/test/TldrawEditor.test.tsx +28 -30
- package/src/test/__snapshots__/resizing.test.ts.snap +8 -8
- package/src/test/commands/__snapshots__/packShapes.test.ts.snap +20 -20
- package/src/test/commands/__snapshots__/zoomToFit.test.ts.snap +2 -2
- package/src/test/commands/createShapes.test.ts +1 -1
- package/src/test/commands/putContent.test.ts +4 -4
- package/src/test/commands/updateShapes.test.ts +1 -1
- package/src/test/resizing.test.ts +203 -203
- package/src/test/selection-omnibus.test.ts +41 -41
- package/src/test/test-jsx.tsx +7 -3
- package/src/test/translating.test.ts +42 -42
|
@@ -1709,47 +1709,47 @@ describe('right clicking', () => {
|
|
|
1709
1709
|
})
|
|
1710
1710
|
})
|
|
1711
1711
|
|
|
1712
|
-
describe('When brushing close to the edges of the screen', () => {
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
})
|
|
1712
|
+
// describe('When brushing close to the edges of the screen', () => {
|
|
1713
|
+
// it('selects shapes that are outside of the viewport', () => {
|
|
1714
|
+
// editor.user.updateUserPreferences({ edgeScrollSpeed: 1 })
|
|
1715
|
+
// editor.createShapes([{ id: ids.box1, type: 'geo', x: 100, y: 100, props: { w: 100, h: 100 } }])
|
|
1716
|
+
// editor.createShapes([
|
|
1717
|
+
// { id: ids.box2, type: 'geo', x: -150, y: -150, props: { w: 100, h: 100 } },
|
|
1718
|
+
// ])
|
|
1719
|
+
|
|
1720
|
+
// editor.pointerMove(300, 300)
|
|
1721
|
+
// editor.pointerDown()
|
|
1722
|
+
// editor.pointerMove(50, 50)
|
|
1723
|
+
// editor.expectToBeIn('select.brushing')
|
|
1724
|
+
// expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1725
|
+
// editor.pointerMove(0, 0)
|
|
1726
|
+
// // still only box 1...
|
|
1727
|
+
// expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1728
|
+
// jest.advanceTimersByTime(100)
|
|
1729
|
+
// // ...but now viewport will have moved to select box2 as well
|
|
1730
|
+
// expect(editor.getSelectedShapeIds()).toEqual([ids.box1, ids.box2])
|
|
1731
|
+
// editor.pointerUp()
|
|
1732
|
+
// })
|
|
1733
|
+
|
|
1734
|
+
// it('doesnt edge scroll to the other shape', () => {
|
|
1735
|
+
// editor.user.updateUserPreferences({ edgeScrollSpeed: 0 }) // <-- no edge scrolling
|
|
1736
|
+
// editor.createShapes([{ id: ids.box1, type: 'geo', x: 100, y: 100, props: { w: 100, h: 100 } }])
|
|
1737
|
+
// editor.createShapes([
|
|
1738
|
+
// { id: ids.box2, type: 'geo', x: -150, y: -150, props: { w: 100, h: 100 } },
|
|
1739
|
+
// ])
|
|
1740
|
+
|
|
1741
|
+
// editor.pointerMove(300, 300)
|
|
1742
|
+
// editor.pointerDown()
|
|
1743
|
+
// editor.pointerMove(50, 50)
|
|
1744
|
+
// editor.expectToBeIn('select.brushing')
|
|
1745
|
+
// expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1746
|
+
// editor.pointerMove(0, 0)
|
|
1747
|
+
// expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1748
|
+
// jest.advanceTimersByTime(100)
|
|
1749
|
+
// expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1750
|
+
// editor.pointerUp()
|
|
1751
|
+
// })
|
|
1752
|
+
// })
|
|
1753
1753
|
|
|
1754
1754
|
describe('When a shape is locked', () => {
|
|
1755
1755
|
beforeEach(() => {
|
package/src/test/test-jsx.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
getIndexAbove,
|
|
9
9
|
omitFromStackTrace,
|
|
10
10
|
} from '@bigbluebutton/editor'
|
|
11
|
+
import React from 'react'
|
|
11
12
|
|
|
12
13
|
const shapeTypeSymbol = Symbol('shapeJsx')
|
|
13
14
|
|
|
@@ -26,7 +27,7 @@ type CommonProps = {
|
|
|
26
27
|
rotation?: number
|
|
27
28
|
isLocked?: number
|
|
28
29
|
ref?: string
|
|
29
|
-
children?: JSX.Element | JSX.Element[]
|
|
30
|
+
children?: React.JSX.Element | React.JSX.Element[]
|
|
30
31
|
opacity?: number
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -47,11 +48,14 @@ export const TL = new Proxy(
|
|
|
47
48
|
}
|
|
48
49
|
) as { [K in TLDefaultShape['type']]: (props: PropsForShape<K>) => null }
|
|
49
50
|
|
|
50
|
-
export function shapesFromJsx(shapes: JSX.Element | Array<JSX.Element>) {
|
|
51
|
+
export function shapesFromJsx(shapes: React.JSX.Element | Array<React.JSX.Element>) {
|
|
51
52
|
const ids = {} as Record<string, TLShapeId>
|
|
52
53
|
const currentPageShapes: Array<TLShapePartial> = []
|
|
53
54
|
|
|
54
|
-
function addChildren(
|
|
55
|
+
function addChildren(
|
|
56
|
+
children: React.JSX.Element | Array<React.JSX.Element>,
|
|
57
|
+
parentId?: TLShapeId
|
|
58
|
+
) {
|
|
55
59
|
let nextIndex = 'a0'
|
|
56
60
|
|
|
57
61
|
for (const el of Array.isArray(children) ? children : [children]) {
|
|
@@ -127,39 +127,39 @@ describe('When translating...', () => {
|
|
|
127
127
|
.expectShapeToMatch({ id: ids.box1, x: 60, y: 60 })
|
|
128
128
|
})
|
|
129
129
|
|
|
130
|
-
it('translates a single shape near the top left edge', () => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
it('translates a single shape near the bottom right edge', () => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
})
|
|
130
|
+
// it('translates a single shape near the top left edge', () => {
|
|
131
|
+
// editor.user.updateUserPreferences({ edgeScrollSpeed: 1 })
|
|
132
|
+
// editor.pointerDown(50, 50, ids.box1).pointerMove(0, 50) // [-50, 0]
|
|
133
|
+
|
|
134
|
+
// jest.advanceTimersByTime(100)
|
|
135
|
+
// editor
|
|
136
|
+
// // The change is bigger than expected because the camera moves
|
|
137
|
+
// .expectShapeToMatch({ id: ids.box1, x: -160, y: 10 })
|
|
138
|
+
// // We'll continue moving in the x postion, but now we'll also move in the y position.
|
|
139
|
+
// // The speed in the y position is smaller since we are further away from the edge.
|
|
140
|
+
// .pointerMove(0, 25)
|
|
141
|
+
// jest.advanceTimersByTime(100)
|
|
142
|
+
// editor
|
|
143
|
+
// .expectShapeToMatch({ id: ids.box1, x: -280, y: -42.54 })
|
|
144
|
+
// .pointerUp()
|
|
145
|
+
// .expectShapeToMatch({ id: ids.box1, x: -280, y: -42.54 })
|
|
146
|
+
// })
|
|
147
|
+
|
|
148
|
+
// it('translates a single shape near the bottom right edge', () => {
|
|
149
|
+
// editor.user.updateUserPreferences({ edgeScrollSpeed: 1 })
|
|
150
|
+
// editor.pointerDown(50, 50, ids.box1).pointerMove(1080, 50)
|
|
151
|
+
|
|
152
|
+
// jest.advanceTimersByTime(100)
|
|
153
|
+
// editor
|
|
154
|
+
// // The change is bigger than expected because the camera moves
|
|
155
|
+
// .expectShapeToMatch({ id: ids.box1, x: 1140, y: 10 })
|
|
156
|
+
// .pointerMove(1080, 800)
|
|
157
|
+
// jest.advanceTimersByTime(100)
|
|
158
|
+
// editor
|
|
159
|
+
// .expectShapeToMatch({ id: ids.box1, x: 1280, y: 845.68 })
|
|
160
|
+
// .pointerUp()
|
|
161
|
+
// .expectShapeToMatch({ id: ids.box1, x: 1280, y: 845.68 })
|
|
162
|
+
// })
|
|
163
163
|
|
|
164
164
|
it('translates multiple shapes', () => {
|
|
165
165
|
editor
|
|
@@ -1539,15 +1539,15 @@ describe('snap lines', () => {
|
|
|
1539
1539
|
})
|
|
1540
1540
|
|
|
1541
1541
|
expect(getSnapLines(editor)).toMatchInlineSnapshot(`
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1542
|
+
[
|
|
1543
|
+
"0,0 0,100 0,200 0,300",
|
|
1544
|
+
"0,0 100,0 200,0 300,0",
|
|
1545
|
+
"0,100 100,100 200,100 300,100",
|
|
1546
|
+
"100,0 100,100 100,200 100,300",
|
|
1547
|
+
"50,50 250,50",
|
|
1548
|
+
"50,50 50,250",
|
|
1549
|
+
]
|
|
1550
|
+
`)
|
|
1551
1551
|
})
|
|
1552
1552
|
})
|
|
1553
1553
|
|