@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.
Files changed (85) hide show
  1. package/dist-cjs/index.d.ts +9 -1
  2. package/dist-cjs/lib/defaultShapeUtils.js +3 -1
  3. package/dist-cjs/lib/defaultShapeUtils.js.map +2 -2
  4. package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
  5. package/dist-cjs/lib/shapes/poll/PollShapeTool.js +30 -0
  6. package/dist-cjs/lib/shapes/poll/PollShapeTool.js.map +7 -0
  7. package/dist-cjs/lib/shapes/poll/PollShapeUtil.js +121 -0
  8. package/dist-cjs/lib/shapes/poll/PollShapeUtil.js.map +7 -0
  9. package/dist-cjs/lib/shapes/poll/components/poll-content.js +101 -0
  10. package/dist-cjs/lib/shapes/poll/components/poll-content.js.map +7 -0
  11. package/dist-cjs/lib/shapes/poll/components/styles.js +53 -0
  12. package/dist-cjs/lib/shapes/poll/components/styles.js.map +7 -0
  13. package/dist-cjs/lib/shapes/poll/poll-shape-migrations.js +45 -0
  14. package/dist-cjs/lib/shapes/poll/poll-shape-migrations.js.map +7 -0
  15. package/dist-cjs/lib/shapes/poll/poll-shape-props.js +39 -0
  16. package/dist-cjs/lib/shapes/poll/poll-shape-props.js.map +7 -0
  17. package/dist-cjs/lib/shapes/poll/poll-shape-types.js +17 -0
  18. package/dist-cjs/lib/shapes/poll/poll-shape-types.js.map +7 -0
  19. package/dist-cjs/lib/tools/HandTool/HandTool.js +3 -3
  20. package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
  21. package/dist-cjs/lib/ui/components/ContextMenu.js +0 -1
  22. package/dist-cjs/lib/ui/components/ContextMenu.js.map +2 -2
  23. package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
  24. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +6 -1
  25. package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
  26. package/dist-cjs/lib/ui/hooks/useTranslation/translations.js +1 -1
  27. package/dist-cjs/lib/ui/hooks/useTranslation/translations.js.map +2 -2
  28. package/dist-esm/index.d.mts +9 -1
  29. package/dist-esm/lib/defaultShapeUtils.mjs +3 -1
  30. package/dist-esm/lib/defaultShapeUtils.mjs.map +2 -2
  31. package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
  32. package/dist-esm/lib/shapes/poll/PollShapeTool.mjs +10 -0
  33. package/dist-esm/lib/shapes/poll/PollShapeTool.mjs.map +7 -0
  34. package/dist-esm/lib/shapes/poll/PollShapeUtil.mjs +97 -0
  35. package/dist-esm/lib/shapes/poll/PollShapeUtil.mjs.map +7 -0
  36. package/dist-esm/lib/shapes/poll/components/poll-content.mjs +71 -0
  37. package/dist-esm/lib/shapes/poll/components/poll-content.mjs.map +7 -0
  38. package/dist-esm/lib/shapes/poll/components/styles.mjs +23 -0
  39. package/dist-esm/lib/shapes/poll/components/styles.mjs.map +7 -0
  40. package/dist-esm/lib/shapes/poll/poll-shape-migrations.mjs +25 -0
  41. package/dist-esm/lib/shapes/poll/poll-shape-migrations.mjs.map +7 -0
  42. package/dist-esm/lib/shapes/poll/poll-shape-props.mjs +19 -0
  43. package/dist-esm/lib/shapes/poll/poll-shape-props.mjs.map +7 -0
  44. package/dist-esm/lib/shapes/poll/poll-shape-types.mjs +1 -0
  45. package/dist-esm/lib/shapes/poll/poll-shape-types.mjs.map +7 -0
  46. package/dist-esm/lib/tools/HandTool/HandTool.mjs +3 -3
  47. package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
  48. package/dist-esm/lib/ui/components/ContextMenu.mjs +0 -1
  49. package/dist-esm/lib/ui/components/ContextMenu.mjs.map +2 -2
  50. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +6 -1
  51. package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
  52. package/dist-esm/lib/ui/hooks/useTranslation/translations.mjs +1 -1
  53. package/dist-esm/lib/ui/hooks/useTranslation/translations.mjs.map +2 -2
  54. package/package.json +4 -3
  55. package/src/lib/Tldraw.test.tsx +9 -13
  56. package/src/lib/defaultShapeUtils.ts +2 -0
  57. package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +1 -1
  58. package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.ts.snap +6 -6
  59. package/src/lib/shapes/poll/PollShapeTool.tsx +7 -0
  60. package/src/lib/shapes/poll/PollShapeUtil.tsx +108 -0
  61. package/src/lib/shapes/poll/components/poll-content.tsx +100 -0
  62. package/src/lib/shapes/poll/components/styles.ts +21 -0
  63. package/src/lib/shapes/poll/poll-shape-migrations.ts +23 -0
  64. package/src/lib/shapes/poll/poll-shape-props.ts +17 -0
  65. package/src/lib/shapes/poll/poll-shape-types.ts +21 -0
  66. package/src/lib/tools/HandTool/HandTool.ts +4 -5
  67. package/src/lib/ui/components/ContextMenu.tsx +1 -1
  68. package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +5 -0
  69. package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +5 -0
  70. package/src/lib/ui/hooks/useTranslation/translations.ts +1 -1
  71. package/src/test/Editor.test.tsx +2 -2
  72. package/src/test/HandTool.test.ts +55 -56
  73. package/src/test/TLSessionStateSnapshot.test.ts +5 -5
  74. package/src/test/TestEditor.ts +4 -1
  75. package/src/test/TldrawEditor.test.tsx +28 -30
  76. package/src/test/__snapshots__/resizing.test.ts.snap +8 -8
  77. package/src/test/commands/__snapshots__/packShapes.test.ts.snap +20 -20
  78. package/src/test/commands/__snapshots__/zoomToFit.test.ts.snap +2 -2
  79. package/src/test/commands/createShapes.test.ts +1 -1
  80. package/src/test/commands/putContent.test.ts +4 -4
  81. package/src/test/commands/updateShapes.test.ts +1 -1
  82. package/src/test/resizing.test.ts +203 -203
  83. package/src/test/selection-omnibus.test.ts +41 -41
  84. package/src/test/test-jsx.tsx +7 -3
  85. package/src/test/translating.test.ts +42 -42
@@ -0,0 +1,100 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import React from 'react'
3
+ import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis } from 'recharts'
4
+ import { TLUiTranslationKey } from '../../../ui/hooks/useTranslation/TLUiTranslationKey'
5
+ import Styled from './styles'
6
+
7
+ const caseInsensitiveReducer = (acc: any[], item: { key: string; numVotes: number }) => {
8
+ const index = acc.findIndex((ans) => ans.key.toLowerCase() === item.key.toLowerCase())
9
+ if (index !== -1) {
10
+ if (acc[index].numVotes >= item.numVotes) acc[index].numVotes += item.numVotes
11
+ else {
12
+ const tempVotes = acc[index].numVotes
13
+ acc[index] = item
14
+ acc[index].numVotes += tempVotes
15
+ }
16
+ } else {
17
+ acc.push(item)
18
+ }
19
+ return acc
20
+ }
21
+
22
+ interface ChatPollContentProps {
23
+ metadata: string
24
+ height?: number
25
+ }
26
+
27
+ interface Metadata {
28
+ id: string
29
+ question: string
30
+ numRespondents: number
31
+ numResponders: number
32
+ questionText: string
33
+ questionType: string
34
+ answers: Array<Answers>
35
+ }
36
+
37
+ interface Answers {
38
+ key: string
39
+ numVotes: number
40
+ id: number
41
+ }
42
+
43
+ function assertAsMetadata(metadata: unknown): asserts metadata is Metadata {
44
+ if (typeof metadata !== 'object' || metadata === null) {
45
+ throw new Error('metadata is not an object')
46
+ }
47
+ if (typeof (metadata as Metadata).id !== 'string') {
48
+ throw new Error('metadata.id is not a string')
49
+ }
50
+ if (typeof (metadata as Metadata).numRespondents !== 'number') {
51
+ throw new Error('metadata.numRespondents is not a number')
52
+ }
53
+ if (typeof (metadata as Metadata).numResponders !== 'number') {
54
+ throw new Error('metadata.numResponders is not a number')
55
+ }
56
+ if (typeof (metadata as Metadata).questionText !== 'string') {
57
+ throw new Error('metadata.questionText is not a string')
58
+ }
59
+ if (typeof (metadata as Metadata).questionType !== 'string') {
60
+ throw new Error('metadata.questionType is not a string')
61
+ }
62
+ if (!Array.isArray((metadata as Metadata).answers)) {
63
+ throw new Error('metadata.answers is not an array')
64
+ }
65
+ }
66
+
67
+ const ChatPollContent: React.FC<ChatPollContentProps> = ({
68
+ metadata: string,
69
+ height = undefined,
70
+ }) => {
71
+ const pollData = JSON.parse(string) as unknown
72
+ assertAsMetadata(pollData)
73
+
74
+ const answers = pollData.answers.reduce(caseInsensitiveReducer, [])
75
+
76
+ const translatedAnswers = answers.map((answer: Answers) => {
77
+ const translationKey = answer.key as TLUiTranslationKey
78
+ const pollAnswer = translationKey ? translationKey : answer.key
79
+ return {
80
+ ...answer,
81
+ pollAnswer,
82
+ }
83
+ })
84
+
85
+ const useHeight = height || translatedAnswers.length * 50
86
+ return (
87
+ <Styled.PollWrapper data-test="chatPollMessageText">
88
+ <Styled.PollText>{pollData.questionText}</Styled.PollText>
89
+ <ResponsiveContainer width="90%" height={useHeight}>
90
+ <BarChart data={translatedAnswers} layout="vertical">
91
+ <XAxis type="number" />
92
+ <YAxis width={80} type="category" dataKey="pollAnswer" />
93
+ <Bar dataKey="numVotes" fill="#0C57A7" />
94
+ </BarChart>
95
+ </ResponsiveContainer>
96
+ </Styled.PollWrapper>
97
+ )
98
+ }
99
+
100
+ export default ChatPollContent
@@ -0,0 +1,21 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import styled from 'styled-components'
3
+
4
+ export const PollText = styled.div`
5
+ margin-top: 0.5rem;
6
+ margin-bottom: 0.5rem;
7
+ font-size: 1.25rem;
8
+ font-weight: 500;
9
+ margin-left: 2.75rem;
10
+ color: var(--color-text, var(--color-gray, #4e5a66));
11
+ word-break: break-word;
12
+ `
13
+
14
+ export const PollWrapper = styled.div`
15
+ width: 100%;
16
+ `
17
+
18
+ export default {
19
+ PollText,
20
+ PollWrapper,
21
+ }
@@ -0,0 +1,23 @@
1
+ import { defineMigrations } from '@bigbluebutton/editor'
2
+
3
+ // Migrations for the custom poll shape (optional but very helpful)
4
+ export const pollShapeMigrations = defineMigrations({
5
+ currentVersion: 1,
6
+ migrators: {
7
+ 1: {
8
+ // example, removing a property from the shape
9
+ up(shape) {
10
+ const migratedUpShape = { ...shape }
11
+ delete migratedUpShape.somePropertyToRemove
12
+ return migratedUpShape
13
+ },
14
+ down(shape) {
15
+ const migratedDownShape = { ...shape }
16
+ migratedDownShape.somePropertyToRemove = 'some value'
17
+ return migratedDownShape
18
+ },
19
+ },
20
+ },
21
+ })
22
+
23
+ export default pollShapeMigrations
@@ -0,0 +1,17 @@
1
+ import { DefaultColorStyle, ShapeProps, T } from '@bigbluebutton/editor'
2
+ import { IPollShape } from './poll-shape-types'
3
+
4
+ export const pollShapeProps: ShapeProps<IPollShape> = {
5
+ w: T.number,
6
+ h: T.number,
7
+ color: DefaultColorStyle,
8
+ fill: T.string,
9
+ question: T.string,
10
+ numRespondents: T.number,
11
+ numResponders: T.number,
12
+ questionText: T.string,
13
+ questionType: T.string,
14
+ answers: T.any,
15
+ }
16
+
17
+ export default pollShapeProps
@@ -0,0 +1,21 @@
1
+ import { TLBaseShape, TLDefaultColorStyle } from '@bigbluebutton/editor'
2
+
3
+ export type IPollShape = TLBaseShape<
4
+ 'poll',
5
+ {
6
+ w: number
7
+ h: number
8
+ color: TLDefaultColorStyle
9
+ fill: string
10
+ question: string
11
+ numRespondents: number
12
+ numResponders: number
13
+ questionText: string
14
+ questionType: string
15
+ answers: Array<{
16
+ id: number
17
+ key: string
18
+ numVotes: number
19
+ }>
20
+ }
21
+ >
@@ -1,4 +1,4 @@
1
- import { EASINGS, StateNode, TLClickEvent } from '@bigbluebutton/editor'
1
+ import { StateNode, TLClickEvent } from '@bigbluebutton/editor'
2
2
  import { Dragging } from './childStates/Dragging'
3
3
  import { Idle } from './childStates/Idle'
4
4
  import { Pointing } from './childStates/Pointing'
@@ -9,27 +9,26 @@ export class HandTool extends StateNode {
9
9
  static override initial = 'idle'
10
10
  static override children = () => [Idle, Pointing, Dragging]
11
11
 
12
- override onDoubleClick: TLClickEvent = (info) => {
12
+ override onDoubleClick: TLClickEvent = (_info) => {
13
13
  // if (info.phase === 'settle') {
14
14
  // const { currentScreenPoint } = this.editor.inputs
15
15
  // this.editor.zoomIn(currentScreenPoint, { duration: 220, easing: EASINGS.easeOutQuint })
16
16
  // }
17
17
  }
18
18
 
19
- override onTripleClick: TLClickEvent = (info) => {
19
+ override onTripleClick: TLClickEvent = (_info) => {
20
20
  // if (info.phase === 'settle') {
21
21
  // const { currentScreenPoint } = this.editor.inputs
22
22
  // this.editor.zoomOut(currentScreenPoint, { duration: 320, easing: EASINGS.easeOutQuint })
23
23
  // }
24
24
  }
25
25
 
26
- override onQuadrupleClick: TLClickEvent = (info) => {
26
+ override onQuadrupleClick: TLClickEvent = (_info) => {
27
27
  // if (info.phase === 'settle') {
28
28
  // const zoomLevel = this.editor.getZoomLevel()
29
29
  // const {
30
30
  // inputs: { currentScreenPoint },
31
31
  // } = this.editor
32
-
33
32
  // if (zoomLevel === 1) {
34
33
  // this.editor.zoomToFit({ duration: 400, easing: EASINGS.easeOutQuint })
35
34
  // } else {
@@ -65,7 +65,7 @@ export const ContextMenu = function ContextMenu({ children }: { children: any })
65
65
  [editor]
66
66
  )
67
67
 
68
- const container = useContainer()
68
+ // const container = useContainer()
69
69
 
70
70
  const [isOpen, handleOpenChange] = useMenuIsOpen('context menu', cb)
71
71
 
@@ -356,3 +356,8 @@ export type TLUiTranslationKey =
356
356
  | 'vscode.file-open.backup-failed'
357
357
  | 'vscode.file-open.dont-show-again'
358
358
  | 'cursor-chat.type-to-chat'
359
+ | 'app.poll.t'
360
+ | 'app.poll.f'
361
+ | 'app.poll.y'
362
+ | 'app.poll.n'
363
+ | 'app.poll.abstention'
@@ -366,4 +366,9 @@ export const DEFAULT_TRANSLATION = {
366
366
  'vscode.file-open.backup-failed': 'Backup failed: this is not a .tldr file.',
367
367
  'vscode.file-open.dont-show-again': "Don't ask again",
368
368
  'cursor-chat.type-to-chat': 'Type to chat...',
369
+ 'app.poll.t': 'True',
370
+ 'app.poll.f': 'False',
371
+ 'app.poll.y': 'Yes',
372
+ 'app.poll.n': 'No',
373
+ 'app.poll.abstention': 'Abstention',
369
374
  }
@@ -28,7 +28,7 @@ export async function fetchTranslation(
28
28
  locale: TLUiTranslation['locale'],
29
29
  assetUrls: TLUiAssetUrls
30
30
  ): Promise<TLUiTranslation> {
31
- const mainRes = await fetch(assetUrls.translations.en)
31
+ const mainRes = await fetch(assetUrls?.translations?.en ?? 'en')
32
32
 
33
33
  if (!mainRes.ok) {
34
34
  console.warn(`No main translations found.`)
@@ -511,13 +511,13 @@ describe('getShapeUtil', () => {
511
511
  it('throws if that shape type isnt registered', () => {
512
512
  const myMissingShape = { type: 'missing' } as TLShape
513
513
  expect(() => editor.getShapeUtil(myMissingShape)).toThrowErrorMatchingInlineSnapshot(
514
- `"No shape util found for type \\"missing\\""`
514
+ `"No shape util found for type "missing""`
515
515
  )
516
516
  })
517
517
 
518
518
  it('throws if that type isnt registered', () => {
519
519
  expect(() => editor.getShapeUtil('missing')).toThrowErrorMatchingInlineSnapshot(
520
- `"No shape util found for type \\"missing\\""`
520
+ `"No shape util found for type "missing""`
521
521
  )
522
522
  })
523
523
  })
@@ -1,5 +1,4 @@
1
- import { HandTool } from '../lib/tools/HandTool/HandTool'
2
- import { TestEditor, createDefaultShapes } from './TestEditor'
1
+ import { TestEditor } from './TestEditor'
3
2
 
4
3
  let editor: TestEditor
5
4
 
@@ -16,60 +15,60 @@ afterEach(() => {
16
15
 
17
16
  jest.useFakeTimers()
18
17
 
19
- describe(HandTool, () => {
20
- it('Double taps to zoom in', () => {
21
- editor.setCurrentTool('hand')
22
- expect(editor.getZoomLevel()).toBe(1)
23
- editor.click()
24
- editor.click() // double click!
25
- jest.advanceTimersByTime(300)
26
- expect(editor.getZoomLevel()).not.toBe(1) // animating
27
- jest.advanceTimersByTime(300)
28
- expect(editor.getZoomLevel()).toBe(2) // all done
29
- })
30
-
31
- it('Triple taps to zoom out', () => {
32
- editor.setCurrentTool('hand')
33
- expect(editor.getZoomLevel()).toBe(1)
34
- editor.click()
35
- editor.click()
36
- editor.click() // triple click!
37
- jest.advanceTimersByTime(300)
38
- expect(editor.getZoomLevel()).not.toBe(1) // animating
39
- jest.advanceTimersByTime(300)
40
- expect(editor.getZoomLevel()).toBe(0.5) // all done
41
- })
42
-
43
- it('Quadruple taps to reset zoom', () => {
44
- editor.setCurrentTool('hand')
45
- editor.zoomIn() // zoom to 2
46
- expect(editor.getZoomLevel()).toBe(2)
47
- editor.click()
48
- editor.click()
49
- editor.click()
50
- editor.click() // quad click!
51
- jest.advanceTimersByTime(300)
52
- expect(editor.getZoomLevel()).not.toBe(2) // animating
53
- jest.advanceTimersByTime(300)
54
- expect(editor.getZoomLevel()).toBe(1) // all done
55
- })
56
-
57
- it('Quadruple taps from zoom=1 to zoom to fit', () => {
58
- editor.setCurrentTool('hand')
59
- expect(editor.getZoomLevel()).toBe(1)
60
- editor.createShapes(createDefaultShapes()) // makes some shapes
61
- editor.click()
62
- editor.click()
63
- editor.click()
64
- editor.click() // quad click!
65
- jest.advanceTimersByTime(300)
66
- expect(editor.getZoomLevel()).not.toBe(1) // animating
67
- jest.advanceTimersByTime(300)
68
- const z = editor.getZoomLevel()
69
- editor.zoomToFit() // call zoom to fit manually to compare
70
- expect(editor.getZoomLevel()).toBe(z) // zoom should not have changed
71
- })
72
- })
18
+ // describe(HandTool, () => {
19
+ // it('Double taps to zoom in', () => {
20
+ // editor.setCurrentTool('hand')
21
+ // expect(editor.getZoomLevel()).toBe(1)
22
+ // editor.click()
23
+ // editor.click() // double click!
24
+ // jest.advanceTimersByTime(300)
25
+ // expect(editor.getZoomLevel()).not.toBe(1) // animating
26
+ // jest.advanceTimersByTime(300)
27
+ // expect(editor.getZoomLevel()).toBe(2) // all done
28
+ // })
29
+
30
+ // it('Triple taps to zoom out', () => {
31
+ // editor.setCurrentTool('hand')
32
+ // expect(editor.getZoomLevel()).toBe(1)
33
+ // editor.click()
34
+ // editor.click()
35
+ // editor.click() // triple click!
36
+ // jest.advanceTimersByTime(300)
37
+ // expect(editor.getZoomLevel()).not.toBe(1) // animating
38
+ // jest.advanceTimersByTime(300)
39
+ // expect(editor.getZoomLevel()).toBe(0.5) // all done
40
+ // })
41
+
42
+ // it('Quadruple taps to reset zoom', () => {
43
+ // editor.setCurrentTool('hand')
44
+ // editor.zoomIn() // zoom to 2
45
+ // expect(editor.getZoomLevel()).toBe(2)
46
+ // editor.click()
47
+ // editor.click()
48
+ // editor.click()
49
+ // editor.click() // quad click!
50
+ // jest.advanceTimersByTime(300)
51
+ // expect(editor.getZoomLevel()).not.toBe(2) // animating
52
+ // jest.advanceTimersByTime(300)
53
+ // expect(editor.getZoomLevel()).toBe(1) // all done
54
+ // })
55
+
56
+ // it('Quadruple taps from zoom=1 to zoom to fit', () => {
57
+ // editor.setCurrentTool('hand')
58
+ // expect(editor.getZoomLevel()).toBe(1)
59
+ // editor.createShapes(createDefaultShapes()) // makes some shapes
60
+ // editor.click()
61
+ // editor.click()
62
+ // editor.click()
63
+ // editor.click() // quad click!
64
+ // jest.advanceTimersByTime(300)
65
+ // expect(editor.getZoomLevel()).not.toBe(1) // animating
66
+ // jest.advanceTimersByTime(300)
67
+ // const z = editor.getZoomLevel()
68
+ // editor.zoomToFit() // call zoom to fit manually to compare
69
+ // expect(editor.getZoomLevel()).toBe(z) // zoom should not have changed
70
+ // })
71
+ // })
73
72
 
74
73
  describe('When in the idle state', () => {
75
74
  it('Returns to select on cancel', () => {
@@ -124,23 +124,23 @@ describe(extractSessionStateFromLegacySnapshot, () => {
124
124
  }
125
125
 
126
126
  expect(extractSessionStateFromLegacySnapshot(oldSnapshot as any)).toMatchInlineSnapshot(`
127
- Object {
127
+ {
128
128
  "currentPageId": "page:whatever",
129
129
  "exportBackground": false,
130
130
  "isDebugMode": false,
131
131
  "isFocusMode": false,
132
132
  "isGridMode": false,
133
133
  "isToolLocked": false,
134
- "pageStates": Array [
135
- Object {
136
- "camera": Object {
134
+ "pageStates": [
135
+ {
136
+ "camera": {
137
137
  "x": 0,
138
138
  "y": 0,
139
139
  "z": 1,
140
140
  },
141
141
  "focusedGroupId": null,
142
142
  "pageId": "page:whatever",
143
- "selectedShapeIds": Array [
143
+ "selectedShapeIds": [
144
144
  "shape:whatever",
145
145
  ],
146
146
  },
@@ -24,6 +24,7 @@ import {
24
24
  createTLStore,
25
25
  rotateSelectionHandle,
26
26
  } from '@bigbluebutton/editor'
27
+ import React from 'react'
27
28
  import { defaultShapeTools } from '../lib/defaultShapeTools'
28
29
  import { defaultShapeUtils } from '../lib/defaultShapeUtils'
29
30
  import { defaultTools } from '../lib/defaultTools'
@@ -560,7 +561,9 @@ export class TestEditor extends Editor {
560
561
  return this
561
562
  }
562
563
 
563
- createShapesFromJsx(shapesJsx: JSX.Element | JSX.Element[]): Record<string, TLShapeId> {
564
+ createShapesFromJsx(
565
+ shapesJsx: React.JSX.Element | React.JSX.Element[]
566
+ ): Record<string, TLShapeId> {
564
567
  const { shapes, ids } = shapesFromJsx(shapesJsx)
565
568
  this.createShapes(shapes)
566
569
  return ids
@@ -23,16 +23,16 @@ function checkAllShapes(editor: Editor, shapes: string[]) {
23
23
  }
24
24
 
25
25
  describe('<TldrawEditor />', () => {
26
- it('Renders without crashing', async () => {
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
- await screen.findByTestId('canvas-1')
32
+ screen.findByTestId('canvas-1')
33
33
  })
34
34
 
35
- it('Creates its own store with core shapes', async () => {
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
- await screen.findByTestId('canvas-1')
49
+ screen.findByTestId('canvas-1')
50
50
  checkAllShapes(editor!, ['group'])
51
51
  })
52
52
 
53
- it('Can be created with default shapes', async () => {
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
- await screen.findByTestId('canvas-1')
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', async () => {
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
- await screen.findByTestId('canvas-1')
89
+ screen.findByTestId('canvas-1')
90
90
  })
91
91
 
92
- it('throws if the store has different shapes to the ones passed in', async () => {
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', async () => {
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
- await screen.findByTestId('canvas-1')
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
- await screen.findByTestId('canvas-2')
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
- await screen.findByTestId('canvas-3')
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
- await act(async () =>
188
- render(
189
- <TldrawEditor
190
- shapeUtils={[GeoShapeUtil]}
191
- initialState="select"
192
- tools={defaultTools}
193
- autoFocus
194
- onMount={(editorApp) => {
195
- editor = editorApp
196
- }}
197
- >
198
- <Canvas />
199
- <div data-testid="canvas-1" />
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
- await screen.findByTestId('canvas-1')
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
- await screen.findByTestId('canvas-1')
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
- Object {
4
+ {
5
5
  "id": "shape:lineA",
6
6
  "index": "a3",
7
7
  "isLocked": false,
8
- "meta": Object {},
8
+ "meta": {},
9
9
  "opacity": 1,
10
10
  "parentId": "shape:boxA",
11
- "props": Object {
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": Array [
19
- Object {
20
- "points": Array [
21
- Object {
18
+ "segments": [
19
+ {
20
+ "points": [
21
+ {
22
22
  "x": 0,
23
23
  "y": 0,
24
24
  "z": 0.5,
25
25
  },
26
- Object {
26
+ {
27
27
  "x": 110,
28
28
  "y": 110,
29
29
  "z": 0.5,