@khanacademy/perseus-editor 1.1.0 → 2.0.0

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 (312) hide show
  1. package/.babelrc.js +1 -1
  2. package/.eslintrc.js +1 -0
  3. package/CHANGELOG.md +21 -0
  4. package/dist/all-editors.d.ts +2 -0
  5. package/dist/all-editors.js.flow +8 -0
  6. package/dist/all-widgets.d.ts +22 -0
  7. package/dist/all-widgets.js.flow +34 -0
  8. package/dist/article-editor.d.ts +59 -0
  9. package/dist/article-editor.js.flow +72 -0
  10. package/dist/components/blur-input.d.ts +19 -0
  11. package/dist/components/blur-input.js.flow +25 -0
  12. package/dist/components/checkbox.d.ts +20 -0
  13. package/dist/components/checkbox.js.flow +26 -0
  14. package/dist/components/device-framer.d.ts +15 -0
  15. package/dist/components/device-framer.js.flow +20 -0
  16. package/dist/components/drag-target.d.ts +2 -0
  17. package/dist/components/drag-target.js.flow +8 -0
  18. package/dist/components/dropdown-option.d.ts +35 -0
  19. package/dist/components/dropdown-option.js.flow +49 -0
  20. package/dist/components/form-wrapped-text-field.d.ts +48 -0
  21. package/dist/components/form-wrapped-text-field.js.flow +48 -0
  22. package/dist/components/graph-settings.d.ts +2 -0
  23. package/dist/components/graph-settings.js.flow +8 -0
  24. package/dist/components/hover-behavior.d.ts +85 -0
  25. package/dist/components/hover-behavior.js.flow +48 -0
  26. package/dist/components/json-editor.d.ts +2 -0
  27. package/dist/components/json-editor.js.flow +8 -0
  28. package/dist/components/link.d.ts +41 -0
  29. package/dist/components/link.js.flow +50 -0
  30. package/dist/components/simple-button.d.ts +16 -0
  31. package/dist/components/simple-button.js.flow +18 -0
  32. package/dist/components/sortable.d.ts +2 -0
  33. package/dist/components/sortable.js.flow +8 -0
  34. package/dist/components/util.d.ts +1 -0
  35. package/dist/components/util.js.flow +9 -0
  36. package/dist/components/viewport-resizer.d.ts +16 -0
  37. package/dist/components/viewport-resizer.js.flow +22 -0
  38. package/dist/diffs/__stories__/perseus-diff-wrapper.d.ts +5 -0
  39. package/dist/diffs/__stories__/perseus-diff-wrapper.js.flow +11 -0
  40. package/dist/diffs/article-diff.d.ts +50 -0
  41. package/dist/diffs/article-diff.js.flow +71 -0
  42. package/dist/diffs/item-diff.d.ts +23 -0
  43. package/dist/diffs/item-diff.js.flow +41 -0
  44. package/dist/diffs/renderer-diff.d.ts +22 -0
  45. package/dist/diffs/renderer-diff.js.flow +25 -0
  46. package/dist/diffs/split-diff.d.ts +2 -0
  47. package/dist/diffs/split-diff.js.flow +8 -0
  48. package/dist/diffs/string-array-diff.d.ts +2 -0
  49. package/dist/diffs/string-array-diff.js.flow +11 -0
  50. package/dist/diffs/structured-item-diff.d.ts +25 -0
  51. package/dist/diffs/structured-item-diff.js.flow +37 -0
  52. package/dist/diffs/tags-diff.d.ts +21 -0
  53. package/dist/diffs/tags-diff.js.flow +24 -0
  54. package/dist/diffs/text-diff.d.ts +15 -0
  55. package/dist/diffs/text-diff.js.flow +21 -0
  56. package/dist/diffs/widget-diff-performer.d.ts +2 -0
  57. package/dist/diffs/widget-diff-performer.js.flow +8 -0
  58. package/dist/diffs/widget-diff.d.ts +21 -0
  59. package/dist/diffs/widget-diff.js.flow +31 -0
  60. package/dist/editor-page.d.ts +57 -0
  61. package/dist/editor-page.js.flow +73 -0
  62. package/dist/editor.d.ts +82 -0
  63. package/dist/editor.js.flow +98 -0
  64. package/dist/es/index.js +1428 -2587
  65. package/dist/es/index.js.map +1 -1
  66. package/dist/hint-editor.d.ts +64 -0
  67. package/dist/hint-editor.js.flow +87 -0
  68. package/dist/i18n.d.ts +7 -0
  69. package/dist/i18n.js.flow +13 -0
  70. package/dist/iframe-content-renderer.d.ts +22 -0
  71. package/dist/iframe-content-renderer.js.flow +28 -0
  72. package/dist/index.d.ts +17 -2
  73. package/dist/index.js +1492 -2548
  74. package/dist/index.js.flow +23 -2
  75. package/dist/index.js.map +1 -1
  76. package/dist/item-editor.d.ts +36 -0
  77. package/dist/item-editor.js.flow +46 -0
  78. package/dist/item-extras-editor.d.ts +17 -0
  79. package/dist/item-extras-editor.js.flow +23 -0
  80. package/dist/katex-error-view.d.ts +16 -0
  81. package/dist/katex-error-view.js.flow +24 -0
  82. package/dist/multirenderer-editor.d.ts +32 -0
  83. package/dist/multirenderer-editor.js.flow +46 -0
  84. package/dist/section-control-button.d.ts +12 -0
  85. package/dist/section-control-button.js.flow +20 -0
  86. package/dist/stateful-article-editor.d.ts +10 -0
  87. package/dist/stateful-article-editor.js.flow +16 -0
  88. package/dist/stateful-editor-page.d.ts +2 -0
  89. package/dist/stateful-editor-page.js.flow +8 -0
  90. package/dist/testing-widgets.d.ts +22 -0
  91. package/dist/testing-widgets.js.flow +34 -0
  92. package/dist/util/register-all-widgets-and-editors-for-testing.d.ts +1 -0
  93. package/dist/util/register-all-widgets-and-editors-for-testing.js.flow +7 -0
  94. package/dist/widgets/categorizer-editor.d.ts +47 -0
  95. package/dist/widgets/categorizer-editor.js.flow +61 -0
  96. package/dist/widgets/cs-program-editor.d.ts +21 -0
  97. package/dist/widgets/cs-program-editor.js.flow +25 -0
  98. package/dist/widgets/definition-editor.d.ts +17 -0
  99. package/dist/widgets/definition-editor.js.flow +23 -0
  100. package/dist/widgets/dropdown-editor.d.ts +23 -0
  101. package/dist/widgets/dropdown-editor.js.flow +37 -0
  102. package/dist/widgets/example-graphie-widget-editor.d.ts +18 -0
  103. package/dist/widgets/example-graphie-widget-editor.js.flow +25 -0
  104. package/dist/widgets/example-graphie-widget.d.ts +87 -0
  105. package/dist/widgets/example-graphie-widget.js.flow +101 -0
  106. package/dist/widgets/example-widget-editor.d.ts +19 -0
  107. package/dist/widgets/example-widget-editor.js.flow +26 -0
  108. package/dist/widgets/example-widget.d.ts +71 -0
  109. package/dist/widgets/example-widget.js.flow +86 -0
  110. package/dist/widgets/explanation-editor.d.ts +21 -0
  111. package/dist/widgets/explanation-editor.js.flow +27 -0
  112. package/dist/widgets/expression-editor.d.ts +33 -0
  113. package/dist/widgets/expression-editor.js.flow +41 -0
  114. package/dist/widgets/graded-group-editor.d.ts +53 -0
  115. package/dist/widgets/graded-group-editor.js.flow +67 -0
  116. package/dist/widgets/graded-group-set-editor.d.ts +51 -0
  117. package/dist/widgets/graded-group-set-editor.js.flow +65 -0
  118. package/dist/widgets/grapher-editor.d.ts +14 -0
  119. package/dist/widgets/grapher-editor.js.flow +21 -0
  120. package/dist/widgets/group-editor.d.ts +49 -0
  121. package/dist/widgets/group-editor.js.flow +63 -0
  122. package/dist/widgets/iframe-editor.d.ts +18 -0
  123. package/dist/widgets/iframe-editor.js.flow +24 -0
  124. package/dist/widgets/image-editor.d.ts +2 -0
  125. package/dist/widgets/image-editor.js.flow +8 -0
  126. package/dist/widgets/input-number-editor.d.ts +47 -0
  127. package/dist/widgets/input-number-editor.js.flow +77 -0
  128. package/dist/widgets/interaction/constraint-editor.d.ts +26 -0
  129. package/dist/widgets/interaction/constraint-editor.js.flow +35 -0
  130. package/dist/widgets/interaction-editor.d.ts +28 -0
  131. package/dist/widgets/interaction-editor.js.flow +36 -0
  132. package/dist/widgets/interactive-graph-editor.d.ts +2 -0
  133. package/dist/widgets/interactive-graph-editor.js.flow +8 -0
  134. package/dist/widgets/label-image/answer-choices.d.ts +13 -0
  135. package/dist/widgets/label-image/answer-choices.js.flow +16 -0
  136. package/dist/widgets/label-image/behavior.d.ts +14 -0
  137. package/dist/widgets/label-image/behavior.js.flow +17 -0
  138. package/dist/widgets/label-image/marker.d.ts +30 -0
  139. package/dist/widgets/label-image/marker.js.flow +34 -0
  140. package/dist/widgets/label-image/question-markers.d.ts +22 -0
  141. package/dist/widgets/label-image/question-markers.js.flow +25 -0
  142. package/dist/widgets/label-image/select-image.d.ts +10 -0
  143. package/dist/widgets/label-image/select-image.js.flow +13 -0
  144. package/dist/widgets/label-image-editor.d.ts +45 -0
  145. package/dist/widgets/label-image-editor.js.flow +44 -0
  146. package/dist/widgets/lights-puzzle-editor.d.ts +24 -0
  147. package/dist/widgets/lights-puzzle-editor.js.flow +34 -0
  148. package/dist/widgets/matcher-editor.d.ts +19 -0
  149. package/dist/widgets/matcher-editor.js.flow +28 -0
  150. package/dist/widgets/matrix-editor.d.ts +20 -0
  151. package/dist/widgets/matrix-editor.js.flow +26 -0
  152. package/dist/widgets/measurer-editor.d.ts +32 -0
  153. package/dist/widgets/measurer-editor.js.flow +42 -0
  154. package/dist/widgets/molecule-editor.d.ts +17 -0
  155. package/dist/widgets/molecule-editor.js.flow +23 -0
  156. package/dist/widgets/number-line-editor.d.ts +36 -0
  157. package/dist/widgets/number-line-editor.js.flow +45 -0
  158. package/dist/widgets/numeric-input-editor.d.ts +2 -0
  159. package/dist/widgets/numeric-input-editor.js.flow +8 -0
  160. package/dist/widgets/orderer-editor.d.ts +20 -0
  161. package/dist/widgets/orderer-editor.js.flow +30 -0
  162. package/dist/widgets/passage-editor.d.ts +18 -0
  163. package/dist/widgets/passage-editor.js.flow +24 -0
  164. package/dist/widgets/passage-ref-editor.d.ts +11 -0
  165. package/dist/widgets/passage-ref-editor.js.flow +17 -0
  166. package/dist/widgets/passage-ref-target-editor.d.ts +16 -0
  167. package/dist/widgets/passage-ref-target-editor.js.flow +22 -0
  168. package/dist/widgets/plotter-editor.d.ts +45 -0
  169. package/dist/widgets/plotter-editor.js.flow +53 -0
  170. package/dist/widgets/radio/editor.d.ts +64 -0
  171. package/dist/widgets/radio/editor.js.flow +80 -0
  172. package/dist/widgets/reaction-diagram-editor.d.ts +20 -0
  173. package/dist/widgets/reaction-diagram-editor.js.flow +26 -0
  174. package/dist/widgets/sequence-editor.d.ts +56 -0
  175. package/dist/widgets/sequence-editor.js.flow +72 -0
  176. package/dist/widgets/simple-markdown-tester-editor.d.ts +14 -0
  177. package/dist/widgets/simple-markdown-tester-editor.js.flow +23 -0
  178. package/dist/widgets/simple-markdown-tester.d.ts +52 -0
  179. package/dist/widgets/simple-markdown-tester.js.flow +61 -0
  180. package/dist/widgets/simulator-editor.d.ts +20 -0
  181. package/dist/widgets/simulator-editor.js.flow +26 -0
  182. package/dist/widgets/sorter-editor.d.ts +16 -0
  183. package/dist/widgets/sorter-editor.js.flow +22 -0
  184. package/dist/widgets/table-editor.d.ts +18 -0
  185. package/dist/widgets/table-editor.js.flow +24 -0
  186. package/dist/widgets/transformer-editor.d.ts +11 -0
  187. package/dist/widgets/transformer-editor.js.flow +17 -0
  188. package/dist/widgets/unit-editor.d.ts +33 -0
  189. package/dist/widgets/unit-editor.js.flow +41 -0
  190. package/dist/widgets/video-editor.d.ts +19 -0
  191. package/dist/widgets/video-editor.js.flow +25 -0
  192. package/package.json +6 -5
  193. package/src/__stories__/{editor.stories.js → editor.stories.tsx} +4 -5
  194. package/src/__stories__/{section-control-button.stories.jsx → section-control-button.stories.tsx} +10 -11
  195. package/src/__testdata__/{input-number_testdata.js → input-number.testdata.ts} +2 -3
  196. package/src/__tests__/{editor_test.jsx → editor.test.tsx} +4 -7
  197. package/src/__tests__/{i18n_test.jsx → i18n.test.ts} +5 -5
  198. package/src/__tests__/{traversal_test.jsx → traversal.test.ts} +9 -10
  199. package/src/{all-editors_test.js → all-editors.test.ts} +1 -2
  200. package/src/all-editors.ts +83 -0
  201. package/src/all-widgets.ts +7 -0
  202. package/src/{article-editor.jsx → article-editor.tsx} +52 -42
  203. package/src/components/__stories__/{blur-input.stories.jsx → blur-input.stories.tsx} +2 -4
  204. package/src/components/{blur-input.jsx → blur-input.tsx} +12 -13
  205. package/src/components/{checkbox.jsx → checkbox.tsx} +18 -19
  206. package/src/components/{device-framer.jsx → device-framer.tsx} +4 -5
  207. package/src/components/{drag-target.jsx → drag-target.tsx} +0 -1
  208. package/src/components/{dropdown-option.jsx → dropdown-option.tsx} +40 -40
  209. package/src/components/{form-wrapped-text-field.jsx → form-wrapped-text-field.tsx} +47 -53
  210. package/src/components/{graph-settings.jsx → graph-settings.tsx} +4 -8
  211. package/src/components/{hover-behavior.jsx → hover-behavior.ts} +32 -33
  212. package/src/components/{json-editor.jsx → json-editor.tsx} +4 -3
  213. package/src/components/{link.jsx → link.ts} +33 -33
  214. package/src/components/{simple-button.jsx → simple-button.tsx} +3 -4
  215. package/src/components/{sortable.jsx → sortable.tsx} +3 -3
  216. package/src/components/{util.js → util.ts} +1 -2
  217. package/src/components/{viewport-resizer.jsx → viewport-resizer.tsx} +5 -6
  218. package/src/diffs/__stories__/{perseus-diff-wrapper.jsx → perseus-diff-wrapper.tsx} +3 -2
  219. package/src/diffs/__stories__/{structured-item-diff.stories.jsx → structured-item-diff.stories.tsx} +27 -22
  220. package/src/diffs/__stories__/{tags-diff.stories.jsx → tags-diff.stories.tsx} +12 -14
  221. package/src/diffs/__stories__/{text-diff.stories.jsx → text-diff.stories.tsx} +12 -14
  222. package/src/diffs/__tests__/{split-diff_test.js → split-diff.test.ts} +1 -2
  223. package/src/diffs/__tests__/{string-array-diff_test.js → string-array-diff.test.ts} +1 -2
  224. package/src/diffs/__tests__/{structured-item-diff_test.js → structured-item-diff.test.ts} +15 -14
  225. package/src/diffs/__tests__/{widget-diff-performer_test.js → widget-diff-performer.test.ts} +1 -2
  226. package/src/diffs/{article-diff.jsx → article-diff.tsx} +5 -6
  227. package/src/diffs/{item-diff.jsx → item-diff.tsx} +4 -5
  228. package/src/diffs/{renderer-diff.jsx → renderer-diff.tsx} +22 -28
  229. package/src/diffs/{split-diff.jsx → split-diff.ts} +4 -3
  230. package/src/diffs/{string-array-diff.jsx → string-array-diff.ts} +8 -9
  231. package/src/diffs/{structured-item-diff.jsx → structured-item-diff.tsx} +32 -27
  232. package/src/diffs/{tags-diff.jsx → tags-diff.tsx} +15 -16
  233. package/src/diffs/{text-diff.jsx → text-diff.tsx} +13 -13
  234. package/src/diffs/{widget-diff-performer.jsx → widget-diff-performer.ts} +3 -8
  235. package/src/diffs/{widget-diff.jsx → widget-diff.tsx} +15 -14
  236. package/src/{editor-page.jsx → editor-page.tsx} +52 -60
  237. package/src/{editor.jsx → editor.tsx} +315 -277
  238. package/src/{hint-editor.jsx → hint-editor.tsx} +105 -79
  239. package/src/{i18n.jsx → i18n.ts} +9 -6
  240. package/src/{iframe-content-renderer.jsx → iframe-content-renderer.tsx} +23 -17
  241. package/src/{index.js → index.ts} +15 -16
  242. package/src/{item-editor.jsx → item-editor.tsx} +35 -30
  243. package/src/{item-extras-editor.jsx → item-extras-editor.tsx} +3 -4
  244. package/src/{katex-error-view.jsx → katex-error-view.tsx} +4 -5
  245. package/src/{multirenderer-editor.jsx → multirenderer-editor.tsx} +132 -127
  246. package/src/{section-control-button.jsx → section-control-button.tsx} +10 -9
  247. package/src/{stateful-article-editor.jsx → stateful-article-editor.tsx} +2 -5
  248. package/src/{stateful-editor-page.jsx → stateful-editor-page.tsx} +1 -3
  249. package/src/{testing-widgets.js → testing-widgets.ts} +5 -6
  250. package/src/util/{register-all-widgets-and-editors-for-testing_test.js → register-all-widgets-and-editors-for-testing.test.ts} +1 -2
  251. package/src/util/{register-all-widgets-and-editors-for-testing.js → register-all-widgets-and-editors-for-testing.ts} +2 -3
  252. package/src/widgets/__stories__/{label-image-editor.stories.jsx → label-image-editor.stories.tsx} +22 -18
  253. package/src/widgets/__stories__/{radio-editor.stories.jsx → radio-editor.stories.tsx} +15 -10
  254. package/src/widgets/{categorizer-editor.jsx → categorizer-editor.tsx} +8 -6
  255. package/src/widgets/{cs-program-editor.jsx → cs-program-editor.tsx} +17 -17
  256. package/src/widgets/{definition-editor.jsx → definition-editor.tsx} +9 -8
  257. package/src/widgets/{dropdown-editor.jsx → dropdown-editor.tsx} +27 -19
  258. package/src/widgets/{example-graphie-widget-editor.jsx → example-graphie-widget-editor.tsx} +8 -8
  259. package/src/widgets/{example-graphie-widget.jsx → example-graphie-widget.tsx} +14 -17
  260. package/src/widgets/{example-widget-editor.jsx → example-widget-editor.tsx} +10 -7
  261. package/src/widgets/{example-widget.jsx → example-widget.tsx} +14 -12
  262. package/src/widgets/{explanation-editor.jsx → explanation-editor.tsx} +12 -10
  263. package/src/widgets/{expression-editor.jsx → expression-editor.tsx} +36 -26
  264. package/src/widgets/{graded-group-editor.jsx → graded-group-editor.tsx} +18 -10
  265. package/src/widgets/{graded-group-set-editor.jsx → graded-group-set-editor.tsx} +15 -12
  266. package/src/widgets/{grapher-editor.jsx → grapher-editor.tsx} +10 -9
  267. package/src/widgets/{group-editor.jsx → group-editor.tsx} +11 -9
  268. package/src/widgets/{iframe-editor.jsx → iframe-editor.tsx} +16 -13
  269. package/src/widgets/{image-editor.jsx → image-editor.tsx} +4 -7
  270. package/src/widgets/{input-number-editor.jsx → input-number-editor.tsx} +61 -47
  271. package/src/widgets/interaction/{constraint-editor.jsx → constraint-editor.tsx} +21 -24
  272. package/src/widgets/{interaction-editor.jsx → interaction-editor.tsx} +160 -61
  273. package/src/widgets/{interactive-graph-editor.jsx → interactive-graph-editor.tsx} +13 -10
  274. package/src/widgets/label-image/__stories__/{answer-choices.stories.jsx → answer-choices.stories.tsx} +22 -17
  275. package/src/widgets/label-image/__stories__/{behavior.stories.jsx → behavior.stories.tsx} +9 -10
  276. package/src/widgets/label-image/__stories__/{marker.stories.jsx → marker.stories.tsx} +11 -12
  277. package/src/widgets/label-image/__stories__/{question-markers.stories.jsx → question-markers.stories.tsx} +17 -16
  278. package/src/widgets/label-image/__stories__/{select-image.stories.jsx → select-image.stories.tsx} +12 -13
  279. package/src/widgets/label-image/{answer-choices.jsx → answer-choices.tsx} +18 -18
  280. package/src/widgets/label-image/{behavior.jsx → behavior.tsx} +9 -11
  281. package/src/widgets/label-image/{marker.jsx → marker.tsx} +17 -19
  282. package/src/widgets/label-image/{question-markers.jsx → question-markers.tsx} +16 -21
  283. package/src/widgets/label-image/{select-image.jsx → select-image.tsx} +5 -7
  284. package/src/widgets/{label-image-editor.jsx → label-image-editor.tsx} +38 -44
  285. package/src/widgets/{lights-puzzle-editor.jsx → lights-puzzle-editor.tsx} +34 -24
  286. package/src/widgets/{matcher-editor.jsx → matcher-editor.tsx} +9 -7
  287. package/src/widgets/{matrix-editor.jsx → matrix-editor.tsx} +10 -9
  288. package/src/widgets/{measurer-editor.jsx → measurer-editor.tsx} +21 -14
  289. package/src/widgets/{molecule-editor.jsx → molecule-editor.tsx} +9 -8
  290. package/src/widgets/{number-line-editor.jsx → number-line-editor.tsx} +19 -17
  291. package/src/widgets/{numeric-input-editor.jsx → numeric-input-editor.tsx} +10 -10
  292. package/src/widgets/{orderer-editor.jsx → orderer-editor.tsx} +17 -12
  293. package/src/widgets/{passage-editor.jsx → passage-editor.tsx} +9 -7
  294. package/src/widgets/{passage-ref-editor.jsx → passage-ref-editor.tsx} +8 -6
  295. package/src/widgets/{passage-ref-target-editor.jsx → passage-ref-target-editor.tsx} +9 -7
  296. package/src/widgets/{plotter-editor.jsx → plotter-editor.tsx} +34 -33
  297. package/src/widgets/radio/{editor.jsx → editor.tsx} +22 -21
  298. package/src/widgets/{reaction-diagram-editor.jsx → reaction-diagram-editor.tsx} +14 -10
  299. package/src/widgets/{sequence-editor.jsx → sequence-editor.tsx} +13 -13
  300. package/src/widgets/{simple-markdown-tester-editor.jsx → simple-markdown-tester-editor.tsx} +11 -9
  301. package/src/widgets/{simple-markdown-tester.jsx → simple-markdown-tester.tsx} +8 -7
  302. package/src/widgets/{simulator-editor.jsx → simulator-editor.tsx} +10 -8
  303. package/src/widgets/{sorter-editor.jsx → sorter-editor.tsx} +8 -6
  304. package/src/widgets/{table-editor.jsx → table-editor.tsx} +11 -10
  305. package/src/widgets/{transformer-editor.jsx → transformer-editor.tsx} +37 -35
  306. package/src/widgets/{unit-editor.jsx → unit-editor.tsx} +31 -25
  307. package/src/widgets/{video-editor.jsx → video-editor.tsx} +8 -9
  308. package/tsconfig.json +22 -0
  309. package/tsconfig.tsbuildinfo +1 -0
  310. package/src/all-editors.js +0 -85
  311. package/src/all-widgets.js +0 -10
  312. /package/dist/{strings.js → strings} +0 -0
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  /**
3
2
  * Editor for a multi-item question.
4
3
  *
@@ -19,10 +18,10 @@ import lens from "hubble";
19
18
  import * as React from "react";
20
19
  import ReactDOM from "react-dom";
21
20
 
22
- import JsonEditor from "./components/json-editor.jsx";
23
- import SimpleButton from "./components/simple-button.jsx";
24
- import Editor from "./editor.jsx";
25
- import {HintEditor} from "./hint-editor.jsx";
21
+ import JsonEditor from "./components/json-editor";
22
+ import SimpleButton from "./components/simple-button";
23
+ import Editor from "./editor";
24
+ import {HintEditor} from "./hint-editor";
26
25
 
27
26
  import type {
28
27
  APIOptions,
@@ -32,7 +31,7 @@ import type {
32
31
  // Multi-item item types
33
32
  Item,
34
33
  // ItemTree is used below, the linter is confused.
35
- ItemTree, // eslint-disable-line no-unused-vars
34
+ ItemTree, // eslint-disable-line @typescript-eslint/no-unused-vars
36
35
  ItemObjectNode,
37
36
  ItemArrayNode,
38
37
  ContentNode,
@@ -53,14 +52,13 @@ const {iconChevronDown, iconTrash} = icons;
53
52
  const {MultiRenderer} = MultiItems;
54
53
 
55
54
  // TODO(CP-4849): figure out when $ReadOnlyArray<number> vs $ReadOnlyArray<string> should be used
56
- type Path = $ReadOnlyArray<$FlowFixMe>;
57
-
58
- type ModeDropdownProps = {|
59
- currentMode: EditorMode,
55
+ type Path = ReadonlyArray<any>;
60
56
 
57
+ type ModeDropdownProps = {
58
+ currentMode: EditorMode;
61
59
  // A function that takes in a string signifying the mode (ex: "edit")
62
- onChange: (mode: EditorMode) => mixed,
63
- |};
60
+ onChange: (mode: EditorMode) => unknown;
61
+ };
64
62
 
65
63
  /**
66
64
  * Component that displays the mode dropdown.
@@ -69,17 +67,17 @@ type ModeDropdownProps = {|
69
67
  * switch between edit, preview, and dev-only JSON mode.
70
68
  */
71
69
  class ModeDropdown extends React.Component<ModeDropdownProps> {
72
- _handleSelectMode = (event: SyntheticInputEvent<HTMLSelectElement>) => {
70
+ _handleSelectMode = (event: React.ChangeEvent<HTMLSelectElement>) => {
73
71
  if (this.props.onChange) {
74
72
  // event.target.value corresponds to the options' values below which
75
73
  // are limited to EditorMode, but flow doesn't know that so we have
76
74
  // to cast through any here.
77
- const value = ((event.target.value: any): EditorMode);
75
+ const value = event.target.value as EditorMode;
78
76
  this.props.onChange(value);
79
77
  }
80
78
  };
81
79
 
82
- render(): React.Node {
80
+ render(): React.ReactNode {
83
81
  return (
84
82
  <label>
85
83
  Mode:{" "}
@@ -133,28 +131,31 @@ function pluralToSingular(str: string) {
133
131
  * `_multi` part at the beginning. This is a helper function which takes a path
134
132
  * and prepends that key.
135
133
  */
136
- function multiPath(path) {
134
+ function multiPath(path: Path | Array<any>) {
137
135
  return ["_multi", ...path];
138
136
  }
139
137
 
140
138
  // Return an h1 if depth=0, h2 if depth=1, etc.
141
139
  // NOTE: This component accepts pass-through props.
142
140
  type HeaderProps = {
143
- depth: number,
144
- ...
141
+ depth: number;
145
142
  };
146
143
 
147
- const Header = ({depth, ...props}: HeaderProps) => {
144
+ const Header: React.FC<HeaderProps> = ({
145
+ depth,
146
+ ...props
147
+ }): React.ReactElement => {
148
148
  const headerLevel = Math.min(depth, 5) + 1;
149
149
  const HeaderTag = `h${headerLevel}`;
150
+ // @ts-expect-error [FEI-5003] - TS2559 - Type '{ children?: ReactNode; }' has no properties in common with type 'IntrinsicAttributes'.
150
151
  return <HeaderTag {...props} />;
151
152
  };
152
153
 
153
154
  // Actions is inexact so that we can pass an instance MultiRendererEditor.
154
155
  interface Actions {
155
156
  addArrayElement: (path: Path, shape: Shape) => void;
156
- mergeValueAtPath: (path: Path, newValue: any) => void;
157
- setValueAtPath: (path: Path, newValue: any) => void;
157
+ mergeValueAtPath: (path: Path, newValue?: any) => void;
158
+ setValueAtPath: (path: Path, newValue?: any) => void;
158
159
  moveArrayElementDown: (path: Path) => void;
159
160
  moveArrayElementUp: (path: Path) => void;
160
161
  removeArrayElement: (path: Path) => void;
@@ -163,19 +164,19 @@ interface Actions {
163
164
  // This type is used to define prop types for various nodes. The S and D type
164
165
  // params should match when used, e.g. the prop types for `HintNodeContent` is
165
166
  // `NodePropTypes<HintShape, HintNode>`.
166
- type NodePropTypes<S = Shape, D = ItemTree> = {|
167
- shape: S,
168
- data: D,
169
- path: Path,
170
- actions: Actions,
171
- apiOptions: APIOptions,
167
+ type NodePropTypes<S = Shape, D = ItemTree> = {
168
+ shape: S;
169
+ data: D;
170
+ path: Path;
171
+ actions: Actions;
172
+ apiOptions: APIOptions;
172
173
  // For the left-hand column, we use edit mode and leave renderers empty.
173
174
  // For the right-hand column, we use preview mode and provide renderers
174
175
  // via a MultiRenderer.
175
176
  // TODO(CP-4850): figure out how to type this, it appears to be a tree where the
176
177
  // leaf nodes could be typed using RendererInterface.
177
- renderers?: $FlowFixMe,
178
- |};
178
+ renderers?: any;
179
+ };
179
180
 
180
181
  /**
181
182
  * Render a node in the editor tree, given the shape of the target
@@ -191,11 +192,12 @@ type NodePropTypes<S = Shape, D = ItemTree> = {|
191
192
  * content. Container nodes, like arrays and objects, render a header above
192
193
  * their content.
193
194
  */
194
- const NodeContainer = (props: {|
195
- ...NodePropTypes<>,
196
- controls?: $ReadOnlyArray<React.Node>,
197
- name?: string,
198
- |}) => {
195
+ const NodeContainer = (
196
+ props: NodePropTypes & {
197
+ controls?: ReadonlyArray<React.ReactNode>;
198
+ name?: string;
199
+ },
200
+ ) => {
199
201
  const {
200
202
  shape,
201
203
  data,
@@ -259,23 +261,24 @@ const NodeContainer = (props: {|
259
261
  );
260
262
  };
261
263
 
262
- type LeafContainerProps = {|
263
- name: string,
264
- controls?: React.Node,
265
- children?: React.Node,
266
- path: Path,
267
- shape: Shape,
268
- |};
269
- const LeafContainer = ({
264
+ type LeafContainerProps = {
265
+ name: string;
266
+ controls?: React.ReactNode;
267
+ children?: React.ReactNode;
268
+ path: Path;
269
+ shape: Shape;
270
+ };
271
+ const LeafContainer: React.FC<LeafContainerProps> = ({
270
272
  name,
271
273
  controls,
272
274
  children,
273
275
  path,
274
276
  shape,
275
- }: LeafContainerProps) => {
277
+ }): React.ReactElement => {
276
278
  const hasPreviewHeading = shape.type === "content" || shape.type === "hint";
277
279
  const previewHeading = hasPreviewHeading && (
278
280
  <div className={css(styles.containerHeader)}>
281
+ {/* @ts-expect-error [FEI-5003] - TS2322 - Type '{ children: string; depth: number; className: string; }' is not assignable to type 'IntrinsicAttributes & HeaderProps & { children?: ReactNode; }'. */}
279
282
  <Header depth={path.length} className={css(styles.containerTitle)}>
280
283
  {capitalize(name)}
281
284
  </Header>
@@ -303,15 +306,17 @@ interface ArrayContainerActions {
303
306
  addArrayElement: (path: Path, shape: Shape) => void;
304
307
  }
305
308
 
306
- type ArrayContainerProps = {|
307
- name: string,
308
- controls?: React.Node,
309
- children?: React.Node,
310
- path: Path,
311
- shape: ArrayShape,
312
- actions: ArrayContainerActions,
313
- |};
314
- const ArrayContainer = (props: ArrayContainerProps) => {
309
+ type ArrayContainerProps = {
310
+ name: string;
311
+ controls?: React.ReactNode;
312
+ children?: React.ReactNode;
313
+ path: Path;
314
+ shape: ArrayShape;
315
+ actions: ArrayContainerActions;
316
+ };
317
+ const ArrayContainer: React.FC<ArrayContainerProps> = (
318
+ props,
319
+ ): React.ReactElement => {
315
320
  const {name, controls, children, path, shape, actions} = props;
316
321
  return (
317
322
  <div className={css(styles.container)}>
@@ -336,20 +341,21 @@ const ArrayContainer = (props: ArrayContainerProps) => {
336
341
  );
337
342
  };
338
343
 
339
- type ObjectContainerProps = {|
340
- name: string,
341
- controls?: React.Node,
342
- children?: React.Node,
343
- path: Path,
344
- |};
345
- const ObjectContainer = ({
344
+ type ObjectContainerProps = {
345
+ name: string;
346
+ controls?: React.ReactNode;
347
+ children?: React.ReactNode;
348
+ path: Path;
349
+ };
350
+ const ObjectContainer: React.FC<ObjectContainerProps> = ({
346
351
  name,
347
352
  controls,
348
353
  children,
349
354
  path,
350
- }: ObjectContainerProps) => {
355
+ }): React.ReactElement => {
351
356
  const headingEditor = (
352
357
  <div className={css(styles.containerHeader)}>
358
+ {/* @ts-expect-error [FEI-5003] - TS2322 - Type '{ children: string; depth: number; className: string; }' is not assignable to type 'IntrinsicAttributes & HeaderProps & { children?: ReactNode; }'. */}
353
359
  <Header depth={path.length} className={css(styles.containerTitle)}>
354
360
  {capitalize(name)}
355
361
  </Header>
@@ -363,6 +369,7 @@ const ObjectContainer = ({
363
369
  styles.previewCollectionHeader,
364
370
  )}
365
371
  >
372
+ {/* @ts-expect-error [FEI-5003] - TS2322 - Type '{ children: string; depth: number; className: string; }' is not assignable to type 'IntrinsicAttributes & HeaderProps & { children?: ReactNode; }'. */}
366
373
  <Header depth={path.length} className={css(styles.containerTitle)}>
367
374
  {capitalize(name)}
368
375
  </Header>
@@ -397,7 +404,7 @@ const ObjectContainer = ({
397
404
  * iterates over the child nodes, and outputs `NodeContainer` for
398
405
  * each of them. The two functions are mutually recursive.
399
406
  */
400
- const NodeContent = (props: NodePropTypes<>) => {
407
+ const NodeContent = (props: NodePropTypes) => {
401
408
  const {shape, data, ...restProps} = props;
402
409
 
403
410
  // All uses of `data` have been cast through any which isn't safe. This was
@@ -409,7 +416,7 @@ const NodeContent = (props: NodePropTypes<>) => {
409
416
  return (
410
417
  <ItemNodeContent
411
418
  shape={shape}
412
- data={((data: any): ContentNode)}
419
+ data={data as ContentNode}
413
420
  {...restProps}
414
421
  />
415
422
  );
@@ -418,7 +425,7 @@ const NodeContent = (props: NodePropTypes<>) => {
418
425
  return (
419
426
  <HintNodeContent
420
427
  shape={shape}
421
- data={((data: any): HintNode)}
428
+ data={data as HintNode}
422
429
  {...restProps}
423
430
  />
424
431
  );
@@ -427,7 +434,7 @@ const NodeContent = (props: NodePropTypes<>) => {
427
434
  return (
428
435
  <TagsNodeContent
429
436
  shape={shape}
430
- data={((data: any): TagsNode)}
437
+ data={data as TagsNode}
431
438
  {...restProps}
432
439
  />
433
440
  );
@@ -436,7 +443,7 @@ const NodeContent = (props: NodePropTypes<>) => {
436
443
  return (
437
444
  <ArrayNodeContent
438
445
  shape={shape}
439
- data={((data: any): ItemArrayNode)}
446
+ data={data as ItemArrayNode}
440
447
  {...restProps}
441
448
  />
442
449
  );
@@ -445,7 +452,7 @@ const NodeContent = (props: NodePropTypes<>) => {
445
452
  return (
446
453
  <ObjectNodeContent
447
454
  shape={shape}
448
- data={((data: any): ItemObjectNode)}
455
+ data={data as ItemObjectNode}
449
456
  {...restProps}
450
457
  />
451
458
  );
@@ -453,16 +460,11 @@ const NodeContent = (props: NodePropTypes<>) => {
453
460
  return null;
454
461
  };
455
462
 
456
- type WithStickinessProps = {|
457
- sticky: boolean,
458
- |};
459
-
460
- type WithStickiness<T> = {|
461
- ...$Exact<T>,
462
- ...WithStickinessProps,
463
- |};
463
+ type WithStickinessProps = {
464
+ sticky: boolean;
465
+ };
464
466
 
465
- type WithoutStickiness<T> = $Exact<$Rest<T, WithStickinessProps>>;
467
+ type WithStickiness<T> = T & WithStickinessProps;
466
468
 
467
469
  /**
468
470
  * HOC that adds a "sticky" prop to the wrapped component that is true
@@ -473,14 +475,17 @@ type WithoutStickiness<T> = $Exact<$Rest<T, WithStickinessProps>>;
473
475
  * It does so by polling the height and comparing it to the window height.
474
476
  */
475
477
  const withStickiness = <
476
- Config: {...},
477
- Component: React.ComponentType<WithStickiness<Config>>,
478
+ Config extends Record<any, any>,
479
+ Component extends React.ComponentType<WithStickiness<Config>>,
478
480
  >(
479
481
  WrappedComponent: Component,
480
- ): React.ComponentType<WithoutStickiness<React.ElementConfig<Component>>> => {
481
- type State = {|sticky: boolean|};
482
+ ): React.ComponentType<Config> => {
483
+ type State = {
484
+ sticky: boolean;
485
+ };
482
486
  return class StickyComponent extends React.Component<Config, State> {
483
- stickynessTimer: IntervalID;
487
+ // @ts-expect-error [FEI-5003] - TS2564 - Property 'stickynessTimer' has no initializer and is not definitely assigned in the constructor.
488
+ stickynessTimer: number;
484
489
 
485
490
  state = {
486
491
  sticky: false,
@@ -489,6 +494,7 @@ const withStickiness = <
489
494
  componentDidMount() {
490
495
  // TODO(jeff, CP-3128): Use Wonder Blocks Timing API.
491
496
  // eslint-disable-next-line no-restricted-syntax
497
+ // @ts-expect-error [FEI-5003] - TS2322 - Type 'Timer' is not assignable to type 'number'.
492
498
  this.stickynessTimer = setInterval(this.updateStickiness, 1000);
493
499
  this.updateStickiness();
494
500
  }
@@ -501,8 +507,7 @@ const withStickiness = <
501
507
 
502
508
  updateStickiness = () => {
503
509
  const domNode = ReactDOM.findDOMNode(this);
504
- // $FlowFixMe[prop-missing]
505
- // $FlowFixMe[incompatible-use]: findDOMNode returns null | Text | Element
510
+ // @ts-expect-error [FEI-5003] - TS2531 - Object is possibly 'null'. | TS2339 - Property 'offsetHeight' does not exist on type 'Element | Text'.
506
511
  const height = domNode.offsetHeight;
507
512
  const windowHeight = window.innerHeight;
508
513
  const sticky = height > windowHeight;
@@ -513,7 +518,7 @@ const withStickiness = <
513
518
  }
514
519
  };
515
520
 
516
- render(): React.Node {
521
+ render(): React.ReactNode {
517
522
  return (
518
523
  /**
519
524
  * $FlowFixMe[incompatible-exact]
@@ -521,6 +526,7 @@ const withStickiness = <
521
526
  * Cannot create WrappedComponent element because inexact props
522
527
  * [1] is incompatible with exact WithStickiness [2].
523
528
  */
529
+ // @ts-expect-error [FEI-5003] - TS2322 - Type 'Readonly<Config> & { sticky: boolean; children?: ReactNode; }' is not assignable to type 'IntrinsicAttributes & LibraryManagedAttributes<Component, PropsWithChildren<WithStickiness<Config>>>'.
524
530
  <WrappedComponent {...this.props} sticky={this.state.sticky} />
525
531
  );
526
532
  }
@@ -528,10 +534,7 @@ const withStickiness = <
528
534
  };
529
535
 
530
536
  const ItemNodeContent = withStickiness(
531
- (props: {|
532
- ...NodePropTypes<ContentShape, ContentNode>,
533
- ...WithStickinessProps,
534
- |}) => {
537
+ (props: NodePropTypes<ContentShape, ContentNode> & WithStickinessProps) => {
535
538
  const {data, path, actions, apiOptions, renderers, sticky} = props;
536
539
 
537
540
  const preview = (
@@ -548,6 +551,7 @@ const ItemNodeContent = withStickiness(
548
551
  // $FlowFixMe[incompatible-exact]: {...data} pass too many props
549
552
  // $FlowFixMe[incompatible-type]
550
553
  // $FlowFixMe[prop-missing]
554
+ // @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
551
555
  <Editor
552
556
  {...data}
553
557
  onChange={(newVal) =>
@@ -570,10 +574,7 @@ const ItemNodeContent = withStickiness(
570
574
  );
571
575
 
572
576
  const HintNodeContent = withStickiness(
573
- (props: {|
574
- ...NodePropTypes<HintShape, HintNode>,
575
- ...WithStickinessProps,
576
- |}) => {
577
+ (props: NodePropTypes<HintShape, HintNode> & WithStickinessProps) => {
577
578
  const {data, path, actions, apiOptions, renderers, sticky} = props;
578
579
 
579
580
  const preview = (
@@ -656,8 +657,6 @@ const ArrayNodeContent = (props: NodePropTypes<ArrayShape, ItemArrayNode>) => {
656
657
  * the type more before doing this work, or rework the `ArrayNodeContent`
657
658
  * component to be less permissive about the props it accepts.
658
659
  */
659
- // $FlowFixMe[prop-missing]
660
- // $FlowFixMe[not-a-function]
661
660
  const children = data.map((subdata, i) => {
662
661
  const subpath = path.concat(i);
663
662
  const controls = [
@@ -749,21 +748,19 @@ interface LayoutStatics {
749
748
  shape: Shape;
750
749
  }
751
750
 
752
- type MultiRendererEditorProps = {|
751
+ type MultiRendererEditorProps = {
753
752
  // eslint-disable-next-line no-restricted-syntax
754
- Layout: React.ComponentType<any> & LayoutStatics,
755
- apiOptions: APIOptions,
756
-
757
- item: Item,
758
- editorMode: EditorMode,
759
-
760
- onChange: ChangeHandler,
761
- |};
753
+ Layout: React.ComponentType<any> & LayoutStatics;
754
+ apiOptions: APIOptions;
755
+ item: Item;
756
+ editorMode: EditorMode;
757
+ onChange: ChangeHandler;
758
+ };
762
759
 
763
760
  class MultiRendererEditor extends React.Component<MultiRendererEditorProps> {
764
- layout: ?React.ElementRef<$FlowFixMe>;
761
+ layout: React.ElementRef<any> | null | undefined;
765
762
 
766
- _renderLayout: () => React.Node = () => {
763
+ _renderLayout: () => React.ReactElement = () => {
767
764
  const {Layout, apiOptions, item} = this.props;
768
765
 
769
766
  return (
@@ -775,7 +772,7 @@ class MultiRendererEditor extends React.Component<MultiRendererEditorProps> {
775
772
  );
776
773
  };
777
774
 
778
- _renderJson: () => React.Element<"div"> = () => {
775
+ _renderJson: () => React.ReactElement<React.ComponentProps<"div">> = () => {
779
776
  return (
780
777
  <div>
781
778
  <ModeDropdown
@@ -791,21 +788,24 @@ class MultiRendererEditor extends React.Component<MultiRendererEditorProps> {
791
788
  );
792
789
  };
793
790
 
794
- _renderPreview: () => React.Element<"div"> = () => {
795
- return (
796
- <div>
797
- <ModeDropdown
798
- currentMode={this.props.editorMode}
799
- onChange={(editorMode) => this.props.onChange({editorMode})}
800
- />
801
- {this._renderLayout()}
802
- </div>
803
- );
804
- };
791
+ _renderPreview: () => React.ReactElement<React.ComponentProps<"div">> =
792
+ () => {
793
+ return (
794
+ <div>
795
+ <ModeDropdown
796
+ currentMode={this.props.editorMode}
797
+ onChange={(editorMode) =>
798
+ this.props.onChange({editorMode})
799
+ }
800
+ />
801
+ {this._renderLayout()}
802
+ </div>
803
+ );
804
+ };
805
805
 
806
- mergeValueAtPath: (path: Path, newValue: any) => void = (
806
+ mergeValueAtPath: (path: Path, newValue?: any) => void = (
807
807
  path: Path,
808
- newValue: mixed,
808
+ newValue: unknown,
809
809
  ) => {
810
810
  this.props.onChange({
811
811
  item: lens(this.props.item)
@@ -814,9 +814,9 @@ class MultiRendererEditor extends React.Component<MultiRendererEditorProps> {
814
814
  });
815
815
  };
816
816
 
817
- setValueAtPath: (path: Path, newValue: any) => void = (
817
+ setValueAtPath: (path: Path, newValue?: any) => void = (
818
818
  path: Path,
819
- newValue: mixed,
819
+ newValue: unknown,
820
820
  ) => {
821
821
  this.props.onChange({
822
822
  item: lens(this.props.item).set(multiPath(path), newValue).freeze(),
@@ -871,11 +871,11 @@ class MultiRendererEditor extends React.Component<MultiRendererEditorProps> {
871
871
  this.moveArrayElementDown(previousElementPath);
872
872
  };
873
873
 
874
- _renderEdit: () => React.Element<"div"> = () => {
874
+ _renderEdit: () => React.ReactElement<React.ComponentProps<"div">> = () => {
875
875
  const apiOptions = {
876
876
  ...ApiOptions.defaults,
877
877
  ...this.props.apiOptions,
878
- };
878
+ } as const;
879
879
 
880
880
  const {item} = this.props;
881
881
  const itemShape: Shape = this.props.Layout.shape;
@@ -907,25 +907,30 @@ class MultiRendererEditor extends React.Component<MultiRendererEditorProps> {
907
907
  );
908
908
  };
909
909
 
910
- score: () => any | void = () => {
910
+ score: () => any | undefined = () => {
911
911
  if (this.layout) {
912
+ // @ts-expect-error [FEI-5003] - TS2571 - Object is of type 'unknown'.
912
913
  return this.layout.score();
913
914
  }
914
915
  };
915
916
 
916
- getSerializedState: () => any | void = () => {
917
+ getSerializedState: () => any | undefined = () => {
917
918
  if (this.layout) {
919
+ // @ts-expect-error [FEI-5003] - TS2571 - Object is of type 'unknown'.
918
920
  return this.layout.getSerializedState();
919
921
  }
920
922
  };
921
923
 
922
- restoreSerializedState: (state: any) => void = (state: $FlowFixMe) => {
924
+ restoreSerializedState: (state?: any) => void = (state: any) => {
923
925
  if (this.layout) {
926
+ // @ts-expect-error [FEI-5003] - TS2571 - Object is of type 'unknown'.
924
927
  this.layout.restoreSerializedState(state);
925
928
  }
926
929
  };
927
930
 
928
- _renderContent: () => React.Element<"div"> | React.Node = () => {
931
+ _renderContent: () =>
932
+ | React.ReactElement<React.ComponentProps<"div">>
933
+ | React.ReactNode = () => {
929
934
  switch (this.props.editorMode) {
930
935
  case "json":
931
936
  return this._renderJson();
@@ -947,7 +952,7 @@ class MultiRendererEditor extends React.Component<MultiRendererEditorProps> {
947
952
  }
948
953
  };
949
954
 
950
- render(): React.Element<"div"> {
955
+ render(): React.ReactNode {
951
956
  return <div id="perseus">{this._renderContent()}</div>;
952
957
  }
953
958
  }
@@ -1,5 +1,3 @@
1
- // @flow
2
-
3
1
  import {components} from "@khanacademy/perseus";
4
2
  import Clickable from "@khanacademy/wonder-blocks-clickable";
5
3
  import Color from "@khanacademy/wonder-blocks-color";
@@ -8,16 +6,19 @@ import * as React from "react";
8
6
 
9
7
  const {InlineIcon} = components;
10
8
 
11
- type InlineIconProps = React.ElementConfig<typeof InlineIcon>;
9
+ type InlineIconProps = JSX.LibraryManagedAttributes<
10
+ typeof InlineIcon,
11
+ React.ComponentProps<typeof InlineIcon>
12
+ >;
12
13
 
13
- type SectionControlButtonProps = {|
14
- icon: InlineIconProps,
15
- onClick: () => mixed,
16
- title: string,
17
- |};
14
+ type SectionControlButtonProps = {
15
+ icon: InlineIconProps;
16
+ onClick: () => unknown;
17
+ title: string;
18
+ };
18
19
 
19
20
  export default class SectionControlButton extends React.Component<SectionControlButtonProps> {
20
- render(): React$Element<typeof Clickable> {
21
+ render(): React.ReactNode {
21
22
  const {icon, onClick, title} = this.props;
22
23
 
23
24
  return (
@@ -1,6 +1,4 @@
1
1
  /* eslint-disable react/no-unsafe */
2
- // @flow
3
-
4
2
  /**
5
3
  * Renders an ArticleEditor as a non-controlled component.
6
4
  *
@@ -14,9 +12,8 @@ import createReactClass from "create-react-class";
14
12
  import * as React from "react";
15
13
  import _ from "underscore";
16
14
 
17
- import ArticleEditor from "./article-editor.jsx";
15
+ import ArticleEditor from "./article-editor";
18
16
 
19
- // $FlowFixMe[signature-verification-failure]
20
17
  const StatefulArticleEditor = createReactClass({
21
18
  displayName: "StatefulArticleEditor",
22
19
 
@@ -171,6 +168,6 @@ const styles = {
171
168
  editor: {
172
169
  marginTop: -20,
173
170
  },
174
- };
171
+ } as const;
175
172
 
176
173
  export default StatefulArticleEditor;
@@ -1,11 +1,10 @@
1
1
  /* eslint-disable react/no-unsafe, react/sort-comp */
2
- // @flow
3
2
  import createReactClass from "create-react-class";
4
3
  import PropTypes from "prop-types";
5
4
  import * as React from "react";
6
5
  import _ from "underscore";
7
6
 
8
- import EditorPage from "./editor-page.jsx";
7
+ import EditorPage from "./editor-page";
9
8
 
10
9
  /* Renders an EditorPage (or an ArticleEditor) as a non-controlled component.
11
10
  *
@@ -14,7 +13,6 @@ import EditorPage from "./editor-page.jsx";
14
13
  * changes. With StatefulEditorPage changes are stored in state so you can
15
14
  * query them with serialize.
16
15
  */
17
- // $FlowFixMe[signature-verification-failure]
18
16
  const StatefulEditorPage = createReactClass({
19
17
  displayName: "StatefulEditorPage",
20
18
 
@@ -1,12 +1,11 @@
1
- // @flow
2
- import ExampleGraphieWidget from "./widgets/example-graphie-widget.jsx";
3
- import ExampleWidget from "./widgets/example-widget.jsx";
4
- import SimpleMarkdownTester from "./widgets/simple-markdown-tester.jsx";
1
+ import ExampleGraphieWidget from "./widgets/example-graphie-widget";
2
+ import ExampleWidget from "./widgets/example-widget";
3
+ import SimpleMarkdownTester from "./widgets/simple-markdown-tester";
5
4
 
6
5
  import type {WidgetExports} from "@khanacademy/perseus";
7
6
 
8
- export default ([
7
+ export default [
9
8
  ExampleGraphieWidget,
10
9
  ExampleWidget,
11
10
  SimpleMarkdownTester,
12
- ]: $ReadOnlyArray<WidgetExports<>>);
11
+ ] as ReadonlyArray<WidgetExports>;
@@ -1,7 +1,6 @@
1
- // @flow
2
1
  import {Widgets} from "@khanacademy/perseus";
3
2
 
4
- import {registerAllWidgetsAndEditorsForTesting} from "./register-all-widgets-and-editors-for-testing.js";
3
+ import {registerAllWidgetsAndEditorsForTesting} from "./register-all-widgets-and-editors-for-testing";
5
4
 
6
5
  describe("Registering all widgets and editors", () => {
7
6
  it("should have an editor for every widget", () => {