@bigbluebutton/tldraw 2.0.0-alpha.24 → 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-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/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/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
|
@@ -23,16 +23,16 @@ function checkAllShapes(editor: Editor, shapes: string[]) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
describe('<TldrawEditor />', () => {
|
|
26
|
-
it('Renders without crashing',
|
|
26
|
+
it('Renders without crashing', () => {
|
|
27
27
|
render(
|
|
28
28
|
<TldrawEditor tools={defaultTools} autoFocus initialState="select">
|
|
29
29
|
<div data-testid="canvas-1" />
|
|
30
30
|
</TldrawEditor>
|
|
31
31
|
)
|
|
32
|
-
|
|
32
|
+
screen.findByTestId('canvas-1')
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
it('Creates its own store with core shapes',
|
|
35
|
+
it('Creates its own store with core shapes', () => {
|
|
36
36
|
let editor: Editor
|
|
37
37
|
render(
|
|
38
38
|
<TldrawEditor
|
|
@@ -46,11 +46,11 @@ describe('<TldrawEditor />', () => {
|
|
|
46
46
|
<div data-testid="canvas-1" />
|
|
47
47
|
</TldrawEditor>
|
|
48
48
|
)
|
|
49
|
-
|
|
49
|
+
screen.findByTestId('canvas-1')
|
|
50
50
|
checkAllShapes(editor!, ['group'])
|
|
51
51
|
})
|
|
52
52
|
|
|
53
|
-
it('Can be created with default shapes',
|
|
53
|
+
it('Can be created with default shapes', () => {
|
|
54
54
|
let editor: Editor
|
|
55
55
|
render(
|
|
56
56
|
<TldrawEditor
|
|
@@ -65,13 +65,13 @@ describe('<TldrawEditor />', () => {
|
|
|
65
65
|
<div data-testid="canvas-1" />
|
|
66
66
|
</TldrawEditor>
|
|
67
67
|
)
|
|
68
|
-
|
|
68
|
+
screen.findByTestId('canvas-1')
|
|
69
69
|
expect(editor!).toBeTruthy()
|
|
70
70
|
|
|
71
71
|
checkAllShapes(editor!, ['group'])
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
-
it('Renders with an external store',
|
|
74
|
+
it('Renders with an external store', () => {
|
|
75
75
|
const store = createTLStore({ shapeUtils: [] })
|
|
76
76
|
render(
|
|
77
77
|
<TldrawEditor
|
|
@@ -86,10 +86,10 @@ describe('<TldrawEditor />', () => {
|
|
|
86
86
|
<div data-testid="canvas-1" />
|
|
87
87
|
</TldrawEditor>
|
|
88
88
|
)
|
|
89
|
-
|
|
89
|
+
screen.findByTestId('canvas-1')
|
|
90
90
|
})
|
|
91
91
|
|
|
92
|
-
it('throws if the store has different shapes to the ones passed in',
|
|
92
|
+
it('throws if the store has different shapes to the ones passed in', () => {
|
|
93
93
|
const spy = jest.spyOn(console, 'error').mockImplementation(noop)
|
|
94
94
|
// expect(() =>
|
|
95
95
|
// render(
|
|
@@ -130,7 +130,7 @@ describe('<TldrawEditor />', () => {
|
|
|
130
130
|
spy.mockRestore()
|
|
131
131
|
})
|
|
132
132
|
|
|
133
|
-
it('Accepts fresh versions of store and calls `onMount` for each one',
|
|
133
|
+
it('Accepts fresh versions of store and calls `onMount` for each one', () => {
|
|
134
134
|
const initialStore = createTLStore({ shapeUtils: [] })
|
|
135
135
|
const onMount = jest.fn()
|
|
136
136
|
const rendered = render(
|
|
@@ -144,7 +144,7 @@ describe('<TldrawEditor />', () => {
|
|
|
144
144
|
<div data-testid="canvas-1" />
|
|
145
145
|
</TldrawEditor>
|
|
146
146
|
)
|
|
147
|
-
|
|
147
|
+
screen.findByTestId('canvas-1')
|
|
148
148
|
const initialEditor = onMount.mock.lastCall[0]
|
|
149
149
|
jest.spyOn(initialEditor, 'dispose')
|
|
150
150
|
expect(initialEditor.store).toBe(initialStore)
|
|
@@ -160,7 +160,7 @@ describe('<TldrawEditor />', () => {
|
|
|
160
160
|
<div data-testid="canvas-2" />
|
|
161
161
|
</TldrawEditor>
|
|
162
162
|
)
|
|
163
|
-
|
|
163
|
+
screen.findByTestId('canvas-2')
|
|
164
164
|
// not called again:
|
|
165
165
|
expect(onMount).toHaveBeenCalledTimes(1)
|
|
166
166
|
// re-render with a new store:
|
|
@@ -176,7 +176,7 @@ describe('<TldrawEditor />', () => {
|
|
|
176
176
|
<div data-testid="canvas-3" />
|
|
177
177
|
</TldrawEditor>
|
|
178
178
|
)
|
|
179
|
-
|
|
179
|
+
screen.findByTestId('canvas-3')
|
|
180
180
|
expect(initialEditor.dispose).toHaveBeenCalledTimes(1)
|
|
181
181
|
expect(onMount).toHaveBeenCalledTimes(2)
|
|
182
182
|
expect(onMount.mock.lastCall[0].store).toBe(newStore)
|
|
@@ -184,23 +184,21 @@ describe('<TldrawEditor />', () => {
|
|
|
184
184
|
|
|
185
185
|
it('Renders the canvas and shapes', async () => {
|
|
186
186
|
let editor = {} as Editor
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
</TldrawEditor>
|
|
201
|
-
)
|
|
187
|
+
render(
|
|
188
|
+
<TldrawEditor
|
|
189
|
+
shapeUtils={[GeoShapeUtil]}
|
|
190
|
+
initialState="select"
|
|
191
|
+
tools={defaultTools}
|
|
192
|
+
autoFocus
|
|
193
|
+
onMount={(editorApp) => {
|
|
194
|
+
editor = editorApp
|
|
195
|
+
}}
|
|
196
|
+
>
|
|
197
|
+
<Canvas />
|
|
198
|
+
<div data-testid="canvas-1" />
|
|
199
|
+
</TldrawEditor>
|
|
202
200
|
)
|
|
203
|
-
|
|
201
|
+
screen.findByTestId('canvas-1')
|
|
204
202
|
|
|
205
203
|
expect(editor).toBeTruthy()
|
|
206
204
|
await act(async () => {
|
|
@@ -324,7 +322,7 @@ describe('Custom shapes', () => {
|
|
|
324
322
|
<div data-testid="canvas-1" />
|
|
325
323
|
</TldrawEditor>
|
|
326
324
|
)
|
|
327
|
-
|
|
325
|
+
screen.findByTestId('canvas-1')
|
|
328
326
|
|
|
329
327
|
expect(editor).toBeTruthy()
|
|
330
328
|
await act(async () => {
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`When resizing a shape with children Resizes a rotated draw shape: draw shape after rotating 1`] = `
|
|
4
|
-
|
|
4
|
+
{
|
|
5
5
|
"id": "shape:lineA",
|
|
6
6
|
"index": "a3",
|
|
7
7
|
"isLocked": false,
|
|
8
|
-
"meta":
|
|
8
|
+
"meta": {},
|
|
9
9
|
"opacity": 1,
|
|
10
10
|
"parentId": "shape:boxA",
|
|
11
|
-
"props":
|
|
11
|
+
"props": {
|
|
12
12
|
"color": "black",
|
|
13
13
|
"dash": "draw",
|
|
14
14
|
"fill": "none",
|
|
15
15
|
"isClosed": false,
|
|
16
16
|
"isComplete": false,
|
|
17
17
|
"isPen": false,
|
|
18
|
-
"segments":
|
|
19
|
-
|
|
20
|
-
"points":
|
|
21
|
-
|
|
18
|
+
"segments": [
|
|
19
|
+
{
|
|
20
|
+
"points": [
|
|
21
|
+
{
|
|
22
22
|
"x": 0,
|
|
23
23
|
"y": 0,
|
|
24
24
|
"z": 0.5,
|
|
25
25
|
},
|
|
26
|
-
|
|
26
|
+
{
|
|
27
27
|
"x": 110,
|
|
28
28
|
"y": 110,
|
|
29
29
|
"z": 0.5,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`editor.packShapes packs rotated shapes: packed shapes 1`] = `
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
6
|
"id": "shape:boxA",
|
|
7
7
|
"index": "a1",
|
|
8
8
|
"isLocked": false,
|
|
9
|
-
"meta":
|
|
9
|
+
"meta": {},
|
|
10
10
|
"opacity": 1,
|
|
11
11
|
"parentId": "wahtever",
|
|
12
|
-
"props":
|
|
12
|
+
"props": {
|
|
13
13
|
"align": "middle",
|
|
14
14
|
"color": "black",
|
|
15
15
|
"dash": "draw",
|
|
@@ -31,14 +31,14 @@ Array [
|
|
|
31
31
|
"x": 134,
|
|
32
32
|
"y": 250,
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
{
|
|
35
35
|
"id": "shape:boxB",
|
|
36
36
|
"index": "a2",
|
|
37
37
|
"isLocked": false,
|
|
38
|
-
"meta":
|
|
38
|
+
"meta": {},
|
|
39
39
|
"opacity": 1,
|
|
40
40
|
"parentId": "wahtever",
|
|
41
|
-
"props":
|
|
41
|
+
"props": {
|
|
42
42
|
"align": "middle",
|
|
43
43
|
"color": "black",
|
|
44
44
|
"dash": "draw",
|
|
@@ -60,14 +60,14 @@ Array [
|
|
|
60
60
|
"x": 150,
|
|
61
61
|
"y": 150,
|
|
62
62
|
},
|
|
63
|
-
|
|
63
|
+
{
|
|
64
64
|
"id": "shape:boxC",
|
|
65
65
|
"index": "a3",
|
|
66
66
|
"isLocked": false,
|
|
67
|
-
"meta":
|
|
67
|
+
"meta": {},
|
|
68
68
|
"opacity": 1,
|
|
69
69
|
"parentId": "wahtever",
|
|
70
|
-
"props":
|
|
70
|
+
"props": {
|
|
71
71
|
"align": "middle",
|
|
72
72
|
"color": "black",
|
|
73
73
|
"dash": "draw",
|
|
@@ -93,15 +93,15 @@ Array [
|
|
|
93
93
|
`;
|
|
94
94
|
|
|
95
95
|
exports[`editor.packShapes packs shapes: packed shapes 1`] = `
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
[
|
|
97
|
+
{
|
|
98
98
|
"id": "shape:boxA",
|
|
99
99
|
"index": "a1",
|
|
100
100
|
"isLocked": false,
|
|
101
|
-
"meta":
|
|
101
|
+
"meta": {},
|
|
102
102
|
"opacity": 1,
|
|
103
103
|
"parentId": "wahtever",
|
|
104
|
-
"props":
|
|
104
|
+
"props": {
|
|
105
105
|
"align": "middle",
|
|
106
106
|
"color": "black",
|
|
107
107
|
"dash": "draw",
|
|
@@ -123,14 +123,14 @@ Array [
|
|
|
123
123
|
"x": 84,
|
|
124
124
|
"y": 200,
|
|
125
125
|
},
|
|
126
|
-
|
|
126
|
+
{
|
|
127
127
|
"id": "shape:boxB",
|
|
128
128
|
"index": "a2",
|
|
129
129
|
"isLocked": false,
|
|
130
|
-
"meta":
|
|
130
|
+
"meta": {},
|
|
131
131
|
"opacity": 1,
|
|
132
132
|
"parentId": "wahtever",
|
|
133
|
-
"props":
|
|
133
|
+
"props": {
|
|
134
134
|
"align": "middle",
|
|
135
135
|
"color": "black",
|
|
136
136
|
"dash": "draw",
|
|
@@ -152,14 +152,14 @@ Array [
|
|
|
152
152
|
"x": 200,
|
|
153
153
|
"y": 200,
|
|
154
154
|
},
|
|
155
|
-
|
|
155
|
+
{
|
|
156
156
|
"id": "shape:boxC",
|
|
157
157
|
"index": "a3",
|
|
158
158
|
"isLocked": false,
|
|
159
|
-
"meta":
|
|
159
|
+
"meta": {},
|
|
160
160
|
"opacity": 1,
|
|
161
161
|
"parentId": "wahtever",
|
|
162
|
-
"props":
|
|
162
|
+
"props": {
|
|
163
163
|
"align": "middle",
|
|
164
164
|
"color": "black",
|
|
165
165
|
"dash": "draw",
|
|
@@ -16,17 +16,17 @@ describe('Migrations', () => {
|
|
|
16
16
|
const withoutSchema = structuredClone(clipboardContent)
|
|
17
17
|
// @ts-expect-error
|
|
18
18
|
delete withoutSchema.schema
|
|
19
|
-
expect(() => editor.putContentOntoCurrentPage(withoutSchema)).
|
|
19
|
+
expect(() => editor.putContentOntoCurrentPage(withoutSchema)).toThrow()
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
it('Does not throw error if content has a schema', () => {
|
|
23
|
-
expect(() => editor.putContentOntoCurrentPage(clipboardContent)).not.
|
|
23
|
+
expect(() => editor.putContentOntoCurrentPage(clipboardContent)).not.toThrow()
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
it('Throws error if any shape is invalid due to wrong type', () => {
|
|
27
27
|
const withInvalidShapeType = structuredClone(clipboardContent)
|
|
28
28
|
withInvalidShapeType.shapes[0].type = 'invalid'
|
|
29
|
-
expect(() => editor.putContentOntoCurrentPage(withInvalidShapeType)).
|
|
29
|
+
expect(() => editor.putContentOntoCurrentPage(withInvalidShapeType)).toThrow()
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
// we temporarily disabled validations
|
|
@@ -34,6 +34,6 @@ describe('Migrations', () => {
|
|
|
34
34
|
const withInvalidShapeModel = structuredClone(clipboardContent)
|
|
35
35
|
// @ts-expect-error
|
|
36
36
|
withInvalidShapeModel.shapes[0].x = 'invalid'
|
|
37
|
-
expect(() => editor.putContentOntoCurrentPage(withInvalidShapeModel)).
|
|
37
|
+
expect(() => editor.putContentOntoCurrentPage(withInvalidShapeModel)).toThrow()
|
|
38
38
|
})
|
|
39
39
|
})
|