@khanacademy/math-input 2.0.0 → 4.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 (264) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/components/input/__tests__/test-math-wrapper.d.ts +1 -1
  3. package/dist/components/input/__tests__/test-math-wrapper.js.flow +1 -1
  4. package/dist/components/input/key-handlers/handle-arrow.d.ts +3 -0
  5. package/dist/components/input/key-handlers/handle-arrow.js.flow +12 -0
  6. package/dist/components/input/key-handlers/handle-backspace.d.ts +7 -0
  7. package/dist/components/input/key-handlers/handle-backspace.js.flow +14 -0
  8. package/dist/components/input/key-handlers/handle-exponent.d.ts +3 -0
  9. package/dist/components/input/key-handlers/handle-exponent.js.flow +12 -0
  10. package/dist/components/input/key-handlers/handle-jump-out.d.ts +7 -0
  11. package/dist/components/input/key-handlers/handle-jump-out.js.flow +14 -0
  12. package/dist/components/input/math-input.d.ts +1 -1
  13. package/dist/components/input/math-input.js.flow +1 -1
  14. package/dist/components/input/math-wrapper.d.ts +7 -78
  15. package/dist/components/input/math-wrapper.js.flow +16 -78
  16. package/dist/components/input/mathquill-helpers.d.ts +46 -0
  17. package/dist/components/input/mathquill-helpers.js.flow +56 -0
  18. package/dist/components/input/mathquill-instance.d.ts +3 -0
  19. package/dist/components/input/mathquill-instance.js.flow +9 -0
  20. package/dist/components/input/mathquill-types.d.ts +25 -0
  21. package/dist/components/input/mathquill-types.js.flow +34 -0
  22. package/dist/components/key-translator.d.ts +4 -0
  23. package/dist/components/key-translator.js.flow +10 -0
  24. package/dist/components/keypad/button-assets.d.ts +2 -2
  25. package/dist/components/keypad/button-assets.js.flow +2 -2
  26. package/dist/components/keypad/button.d.ts +1 -2
  27. package/dist/components/keypad/button.js.flow +1 -1
  28. package/dist/components/keypad/{pre-algebra-page.d.ts → geometry-page/index.d.ts} +1 -1
  29. package/dist/components/keypad/{pre-algebra-page.js.flow → geometry-page/index.js.flow} +1 -1
  30. package/dist/components/keypad/index.d.ts +5 -4
  31. package/dist/components/keypad/index.js.flow +9 -4
  32. package/dist/components/keypad/keypad-page-items.d.ts +9 -3
  33. package/dist/components/keypad/keypad-page-items.js.flow +9 -3
  34. package/dist/components/keypad/{numeric-input-page.d.ts → numbers-page/index.d.ts} +3 -2
  35. package/dist/components/keypad/numbers-page/index.js.flow +17 -0
  36. package/dist/components/keypad/numbers-page/types.d.ts +4 -0
  37. package/dist/components/keypad/numbers-page/types.js.flow +10 -0
  38. package/dist/components/keypad/operators-page/advanced-relations-buttons.d.ts +7 -0
  39. package/dist/components/keypad/{numeric-input-page.js.flow → operators-page/advanced-relations-buttons.js.flow} +3 -4
  40. package/dist/components/keypad/operators-page/basic-relations-buttons.d.ts +7 -0
  41. package/dist/components/keypad/{trigonometry-page.js.flow → operators-page/basic-relations-buttons.js.flow} +3 -6
  42. package/dist/components/keypad/operators-page/index.d.ts +9 -0
  43. package/dist/components/keypad/operators-page/index.js.flow +17 -0
  44. package/dist/components/keypad/operators-page/logarithms-buttons.d.ts +7 -0
  45. package/dist/components/keypad/operators-page/logarithms-buttons.js.flow +12 -0
  46. package/dist/components/keypad/operators-page/pre-algebra-buttons.d.ts +7 -0
  47. package/dist/components/keypad/operators-page/pre-algebra-buttons.js.flow +12 -0
  48. package/dist/components/keypad/operators-page/types.d.ts +6 -0
  49. package/dist/components/keypad/operators-page/types.js.flow +12 -0
  50. package/dist/components/{compute-layout-parameters.d.ts → keypad-legacy/compute-layout-parameters.d.ts} +1 -1
  51. package/dist/components/{compute-layout-parameters.js.flow → keypad-legacy/compute-layout-parameters.js.flow} +1 -1
  52. package/dist/components/{echo-manager.d.ts → keypad-legacy/echo-manager.d.ts} +2 -11
  53. package/dist/components/{echo-manager.js.flow → keypad-legacy/echo-manager.js.flow} +2 -11
  54. package/dist/components/{expression-keypad.d.ts → keypad-legacy/expression-keypad.d.ts} +3 -4
  55. package/dist/components/{expression-keypad.js.flow → keypad-legacy/expression-keypad.js.flow} +3 -4
  56. package/dist/components/{fraction-keypad.d.ts → keypad-legacy/fraction-keypad.d.ts} +2 -2
  57. package/dist/components/{fraction-keypad.js.flow → keypad-legacy/fraction-keypad.js.flow} +2 -2
  58. package/dist/components/{gesture-manager.d.ts → keypad-legacy/gesture-manager.d.ts} +22 -10
  59. package/dist/components/{gesture-manager.js.flow → keypad-legacy/gesture-manager.js.flow} +28 -13
  60. package/dist/components/{gesture-state-machine.d.ts → keypad-legacy/gesture-state-machine.d.ts} +9 -9
  61. package/dist/components/{gesture-state-machine.js.flow → keypad-legacy/gesture-state-machine.js.flow} +10 -10
  62. package/dist/components/{icon.d.ts → keypad-legacy/icon.d.ts} +1 -1
  63. package/dist/components/{icon.js.flow → keypad-legacy/icon.js.flow} +1 -1
  64. package/dist/components/{keypad-button.d.ts → keypad-legacy/keypad-button.d.ts} +6 -6
  65. package/dist/components/{keypad-button.js.flow → keypad-legacy/keypad-button.js.flow} +7 -7
  66. package/dist/components/{keypad-container.d.ts → keypad-legacy/keypad-container.d.ts} +2 -2
  67. package/dist/components/{keypad-container.js.flow → keypad-legacy/keypad-container.js.flow} +3 -3
  68. package/dist/components/{keypad.d.ts → keypad-legacy/keypad.d.ts} +3 -3
  69. package/dist/components/{keypad.js.flow → keypad-legacy/keypad.js.flow} +3 -3
  70. package/dist/components/{multi-symbol-grid.d.ts → keypad-legacy/multi-symbol-grid.d.ts} +1 -1
  71. package/dist/components/{multi-symbol-grid.js.flow → keypad-legacy/multi-symbol-grid.js.flow} +1 -1
  72. package/dist/components/{multi-symbol-popover.d.ts → keypad-legacy/multi-symbol-popover.d.ts} +1 -1
  73. package/dist/components/{multi-symbol-popover.js.flow → keypad-legacy/multi-symbol-popover.js.flow} +1 -1
  74. package/dist/components/{node-manager.d.ts → keypad-legacy/node-manager.d.ts} +3 -4
  75. package/dist/components/{node-manager.js.flow → keypad-legacy/node-manager.js.flow} +3 -5
  76. package/dist/components/{popover-manager.d.ts → keypad-legacy/popover-manager.d.ts} +1 -1
  77. package/dist/components/{popover-manager.js.flow → keypad-legacy/popover-manager.js.flow} +1 -1
  78. package/dist/components/{popover-state-machine.d.ts → keypad-legacy/popover-state-machine.d.ts} +1 -1
  79. package/dist/components/{popover-state-machine.js.flow → keypad-legacy/popover-state-machine.js.flow} +1 -1
  80. package/dist/components/{provided-keypad.d.ts → keypad-legacy/provided-keypad.d.ts} +1 -1
  81. package/dist/components/{provided-keypad.js.flow → keypad-legacy/provided-keypad.js.flow} +1 -1
  82. package/dist/{store → components/keypad-legacy/store}/actions.d.ts +6 -17
  83. package/dist/{store → components/keypad-legacy/store}/actions.js.flow +7 -22
  84. package/dist/{store → components/keypad-legacy/store}/index.d.ts +0 -1
  85. package/dist/{store → components/keypad-legacy/store}/index.js.flow +0 -1
  86. package/dist/components/keypad-legacy/store/shared.d.ts +7 -0
  87. package/dist/components/keypad-legacy/store/shared.js.flow +14 -0
  88. package/dist/{store → components/keypad-legacy/store}/types.d.ts +5 -15
  89. package/dist/{store → components/keypad-legacy/store}/types.js.flow +5 -15
  90. package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +37 -0
  91. package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +59 -0
  92. package/dist/components/{two-page-keypad.d.ts → keypad-legacy/two-page-keypad.d.ts} +0 -1
  93. package/dist/components/{two-page-keypad.js.flow → keypad-legacy/two-page-keypad.js.flow} +0 -1
  94. package/dist/data/key-configs.d.ts +4 -5
  95. package/dist/data/key-configs.js.flow +3 -6
  96. package/dist/data/keys.d.ts +2 -56
  97. package/dist/data/keys.js.flow +116 -57
  98. package/dist/enums.d.ts +2 -9
  99. package/dist/enums.js.flow +2 -11
  100. package/dist/es/index.js +6393 -5116
  101. package/dist/es/index.js.map +1 -1
  102. package/dist/index.d.ts +5 -3
  103. package/dist/index.js +6868 -5330
  104. package/dist/index.js.flow +6 -3
  105. package/dist/index.js.map +1 -1
  106. package/dist/strings.js +26 -10
  107. package/dist/types.d.ts +19 -17
  108. package/dist/types.js.flow +28 -23
  109. package/package.json +1 -1
  110. package/src/components/input/__tests__/context-tracking.test.ts +43 -44
  111. package/src/components/input/__tests__/mathquill.test.ts +133 -135
  112. package/src/components/input/key-handlers/handle-arrow.ts +70 -0
  113. package/src/components/input/key-handlers/handle-backspace.ts +275 -0
  114. package/src/components/input/key-handlers/handle-exponent.ts +52 -0
  115. package/src/components/input/key-handlers/handle-jump-out.ts +103 -0
  116. package/src/components/input/math-input.tsx +12 -13
  117. package/src/components/input/math-wrapper.ts +88 -837
  118. package/src/components/input/mathquill-helpers.ts +268 -0
  119. package/src/components/input/mathquill-instance.ts +5 -0
  120. package/src/components/input/mathquill-types.ts +55 -0
  121. package/src/components/key-translator.ts +209 -0
  122. package/src/components/keypad/button-assets.tsx +452 -116
  123. package/src/components/keypad/button.stories.tsx +61 -13
  124. package/src/components/keypad/button.tsx +1 -1
  125. package/src/components/keypad/{trigonometry-page.tsx → geometry-page/index.tsx} +4 -5
  126. package/src/components/keypad/index.tsx +19 -14
  127. package/src/components/keypad/keypad-mathquill.stories.tsx +69 -0
  128. package/src/components/keypad/keypad-page-items.tsx +36 -22
  129. package/src/components/keypad/keypad-pages.stories.tsx +5 -5
  130. package/src/components/keypad/keypad.stories.tsx +75 -17
  131. package/src/components/keypad/{numeric-input-page.tsx → numbers-page/index.tsx} +47 -11
  132. package/src/components/keypad/numbers-page/types.ts +4 -0
  133. package/src/components/keypad/operators-page/advanced-relations-buttons.tsx +32 -0
  134. package/src/components/keypad/operators-page/basic-relations-buttons.tsx +32 -0
  135. package/src/components/keypad/{pre-algebra-page.tsx → operators-page/index.tsx} +26 -30
  136. package/src/components/keypad/operators-page/logarithms-buttons.tsx +32 -0
  137. package/src/components/keypad/operators-page/pre-algebra-buttons.tsx +36 -0
  138. package/src/components/keypad/operators-page/types.ts +6 -0
  139. package/src/components/{__tests__ → keypad-legacy/__tests__}/two-page-keypad.test.tsx +0 -2
  140. package/src/components/{compute-layout-parameters.ts → keypad-legacy/compute-layout-parameters.ts} +2 -3
  141. package/src/components/{corner-decal.tsx → keypad-legacy/corner-decal.tsx} +2 -3
  142. package/src/components/{echo-manager.tsx → keypad-legacy/echo-manager.tsx} +8 -21
  143. package/src/components/{empty-keypad-button.tsx → keypad-legacy/empty-keypad-button.tsx} +8 -6
  144. package/src/components/{expression-keypad.tsx → keypad-legacy/expression-keypad.tsx} +8 -17
  145. package/src/components/{fraction-keypad.tsx → keypad-legacy/fraction-keypad.tsx} +6 -6
  146. package/src/components/{gesture-manager.ts → keypad-legacy/gesture-manager.ts} +34 -11
  147. package/src/components/{gesture-state-machine.ts → keypad-legacy/gesture-state-machine.ts} +14 -14
  148. package/src/components/{icon.tsx → keypad-legacy/icon.tsx} +3 -3
  149. package/src/components/{keypad-button.tsx → keypad-legacy/keypad-button.tsx} +26 -26
  150. package/src/components/{keypad-container.tsx → keypad-legacy/keypad-container.tsx} +6 -6
  151. package/src/components/{keypad.tsx → keypad-legacy/keypad.tsx} +5 -5
  152. package/src/components/{many-keypad-button.tsx → keypad-legacy/many-keypad-button.tsx} +13 -6
  153. package/src/components/{math-icon.tsx → keypad-legacy/math-icon.tsx} +2 -2
  154. package/src/components/{multi-symbol-grid.tsx → keypad-legacy/multi-symbol-grid.tsx} +4 -4
  155. package/src/components/{multi-symbol-popover.tsx → keypad-legacy/multi-symbol-popover.tsx} +3 -4
  156. package/src/components/{navigation-pad.tsx → keypad-legacy/navigation-pad.tsx} +5 -5
  157. package/src/components/{node-manager.ts → keypad-legacy/node-manager.ts} +2 -10
  158. package/src/components/{popover-manager.tsx → keypad-legacy/popover-manager.tsx} +2 -2
  159. package/src/components/{popover-state-machine.ts → keypad-legacy/popover-state-machine.ts} +1 -1
  160. package/src/components/{provided-keypad.tsx → keypad-legacy/provided-keypad.tsx} +4 -5
  161. package/src/{store → components/keypad-legacy/store}/actions.ts +7 -36
  162. package/src/{store → components/keypad-legacy/store}/echo-reducer.ts +3 -7
  163. package/src/{store → components/keypad-legacy/store}/index.ts +7 -20
  164. package/src/{store → components/keypad-legacy/store}/input-reducer.ts +4 -5
  165. package/src/{store → components/keypad-legacy/store}/keypad-reducer.ts +3 -4
  166. package/src/{store → components/keypad-legacy/store}/layout-reducer.ts +3 -3
  167. package/src/{store → components/keypad-legacy/store}/shared.ts +3 -3
  168. package/src/{store → components/keypad-legacy/store}/types.ts +15 -19
  169. package/src/components/{styles.ts → keypad-legacy/styles.ts} +1 -1
  170. package/src/components/{text-icon.tsx → keypad-legacy/text-icon.tsx} +2 -2
  171. package/src/components/{touchable-keypad-button.tsx → keypad-legacy/touchable-keypad-button.tsx} +35 -21
  172. package/src/components/{two-page-keypad.tsx → keypad-legacy/two-page-keypad.tsx} +5 -6
  173. package/src/components/tabbar/icons.tsx +0 -2
  174. package/src/data/key-configs.ts +751 -309
  175. package/src/data/keys.ts +118 -70
  176. package/src/enums.ts +10 -9
  177. package/src/index.ts +6 -3
  178. package/src/math-input.stories.tsx +3 -3
  179. package/src/types.ts +21 -16
  180. package/tsconfig-build.tsbuildinfo +1 -1
  181. package/dist/components/keypad/trigonometry-page.d.ts +0 -8
  182. package/dist/components/touchable-keypad-button.d.ts +0 -30
  183. package/dist/components/touchable-keypad-button.js.flow +0 -35
  184. package/dist/components/velocity-tracker.d.ts +0 -48
  185. package/dist/components/velocity-tracker.js.flow +0 -54
  186. package/dist/store/pager-reducer.d.ts +0 -4
  187. package/dist/store/pager-reducer.js.flow +0 -13
  188. package/dist/store/shared.d.ts +0 -7
  189. package/dist/store/shared.js.flow +0 -14
  190. package/src/components/velocity-tracker.ts +0 -86
  191. package/src/store/pager-reducer.ts +0 -125
  192. /package/dist/components/{corner-decal.d.ts → keypad-legacy/corner-decal.d.ts} +0 -0
  193. /package/dist/components/{corner-decal.js.flow → keypad-legacy/corner-decal.js.flow} +0 -0
  194. /package/dist/components/{empty-keypad-button.d.ts → keypad-legacy/empty-keypad-button.d.ts} +0 -0
  195. /package/dist/components/{empty-keypad-button.js.flow → keypad-legacy/empty-keypad-button.js.flow} +0 -0
  196. /package/dist/components/{many-keypad-button.d.ts → keypad-legacy/many-keypad-button.d.ts} +0 -0
  197. /package/dist/components/{many-keypad-button.js.flow → keypad-legacy/many-keypad-button.js.flow} +0 -0
  198. /package/dist/components/{math-icon.d.ts → keypad-legacy/math-icon.d.ts} +0 -0
  199. /package/dist/components/{math-icon.js.flow → keypad-legacy/math-icon.js.flow} +0 -0
  200. /package/dist/components/{navigation-pad.d.ts → keypad-legacy/navigation-pad.d.ts} +0 -0
  201. /package/dist/components/{navigation-pad.js.flow → keypad-legacy/navigation-pad.js.flow} +0 -0
  202. /package/dist/{store → components/keypad-legacy/store}/echo-reducer.d.ts +0 -0
  203. /package/dist/{store → components/keypad-legacy/store}/echo-reducer.js.flow +0 -0
  204. /package/dist/{store → components/keypad-legacy/store}/input-reducer.d.ts +0 -0
  205. /package/dist/{store → components/keypad-legacy/store}/input-reducer.js.flow +0 -0
  206. /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.d.ts +0 -0
  207. /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.js.flow +0 -0
  208. /package/dist/{store → components/keypad-legacy/store}/layout-reducer.d.ts +0 -0
  209. /package/dist/{store → components/keypad-legacy/store}/layout-reducer.js.flow +0 -0
  210. /package/dist/components/{styles.d.ts → keypad-legacy/styles.d.ts} +0 -0
  211. /package/dist/components/{styles.js.flow → keypad-legacy/styles.js.flow} +0 -0
  212. /package/dist/components/{svg-icon.d.ts → keypad-legacy/svg-icon.d.ts} +0 -0
  213. /package/dist/components/{svg-icon.js.flow → keypad-legacy/svg-icon.js.flow} +0 -0
  214. /package/dist/components/{text-icon.d.ts → keypad-legacy/text-icon.d.ts} +0 -0
  215. /package/dist/components/{text-icon.js.flow → keypad-legacy/text-icon.js.flow} +0 -0
  216. /package/dist/components/{z-indexes.d.ts → keypad-legacy/z-indexes.d.ts} +0 -0
  217. /package/dist/components/{z-indexes.js.flow → keypad-legacy/z-indexes.js.flow} +0 -0
  218. /package/src/components/{__tests__ → keypad-legacy/__tests__}/gesture-state-machine.test.ts +0 -0
  219. /package/src/components/{__tests__ → keypad-legacy/__tests__}/node-manager.test.ts +0 -0
  220. /package/src/components/{iconography → keypad-legacy/iconography}/arrow.js +0 -0
  221. /package/src/components/{iconography → keypad-legacy/iconography}/backspace.js +0 -0
  222. /package/src/components/{iconography → keypad-legacy/iconography}/cdot.js +0 -0
  223. /package/src/components/{iconography → keypad-legacy/iconography}/cos.js +0 -0
  224. /package/src/components/{iconography → keypad-legacy/iconography}/cube-root.js +0 -0
  225. /package/src/components/{iconography → keypad-legacy/iconography}/dismiss.js +0 -0
  226. /package/src/components/{iconography → keypad-legacy/iconography}/divide.js +0 -0
  227. /package/src/components/{iconography → keypad-legacy/iconography}/down.js +0 -0
  228. /package/src/components/{iconography → keypad-legacy/iconography}/equal.js +0 -0
  229. /package/src/components/{iconography → keypad-legacy/iconography}/exp-2.js +0 -0
  230. /package/src/components/{iconography → keypad-legacy/iconography}/exp-3.js +0 -0
  231. /package/src/components/{iconography → keypad-legacy/iconography}/exp.js +0 -0
  232. /package/src/components/{iconography → keypad-legacy/iconography}/frac.js +0 -0
  233. /package/src/components/{iconography → keypad-legacy/iconography}/geq.js +0 -0
  234. /package/src/components/{iconography → keypad-legacy/iconography}/gt.js +0 -0
  235. /package/src/components/{iconography → keypad-legacy/iconography}/index.js +0 -0
  236. /package/src/components/{iconography → keypad-legacy/iconography}/jump-into-numerator.js +0 -0
  237. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-base.js +0 -0
  238. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-denominator.js +0 -0
  239. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-exponent.js +0 -0
  240. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-numerator.js +0 -0
  241. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-parentheses.js +0 -0
  242. /package/src/components/{iconography → keypad-legacy/iconography}/left-paren.js +0 -0
  243. /package/src/components/{iconography → keypad-legacy/iconography}/left.js +0 -0
  244. /package/src/components/{iconography → keypad-legacy/iconography}/leq.js +0 -0
  245. /package/src/components/{iconography → keypad-legacy/iconography}/ln.js +0 -0
  246. /package/src/components/{iconography → keypad-legacy/iconography}/log-n.js +0 -0
  247. /package/src/components/{iconography → keypad-legacy/iconography}/log.js +0 -0
  248. /package/src/components/{iconography → keypad-legacy/iconography}/lt.js +0 -0
  249. /package/src/components/{iconography → keypad-legacy/iconography}/minus.js +0 -0
  250. /package/src/components/{iconography → keypad-legacy/iconography}/neq.js +0 -0
  251. /package/src/components/{iconography → keypad-legacy/iconography}/parens.js +0 -0
  252. /package/src/components/{iconography → keypad-legacy/iconography}/percent.js +0 -0
  253. /package/src/components/{iconography → keypad-legacy/iconography}/period.js +0 -0
  254. /package/src/components/{iconography → keypad-legacy/iconography}/plus.js +0 -0
  255. /package/src/components/{iconography → keypad-legacy/iconography}/radical.js +0 -0
  256. /package/src/components/{iconography → keypad-legacy/iconography}/right-paren.js +0 -0
  257. /package/src/components/{iconography → keypad-legacy/iconography}/right.js +0 -0
  258. /package/src/components/{iconography → keypad-legacy/iconography}/sin.js +0 -0
  259. /package/src/components/{iconography → keypad-legacy/iconography}/sqrt.js +0 -0
  260. /package/src/components/{iconography → keypad-legacy/iconography}/tan.js +0 -0
  261. /package/src/components/{iconography → keypad-legacy/iconography}/times.js +0 -0
  262. /package/src/components/{iconography → keypad-legacy/iconography}/up.js +0 -0
  263. /package/src/components/{svg-icon.tsx → keypad-legacy/svg-icon.tsx} +0 -0
  264. /package/src/components/{z-indexes.ts → keypad-legacy/z-indexes.ts} +0 -0
@@ -1,5 +1,3 @@
1
- import Keys from "../../../data/keys";
2
-
3
1
  import TestMathWrapper from "./test-math-wrapper";
4
2
 
5
3
  const MQ = {L: "-1", R: "1"};
@@ -28,31 +26,31 @@ describe("MathQuill", () => {
28
26
  document.body.removeChild(span);
29
27
  });
30
28
 
31
- // TODO(charlie): Add tests for Keys.FRAC_EXCLUSIVE (the mixed-number
29
+ // TODO(charlie): Add tests for "FRAC_EXCLUSIVE" (the mixed-number
32
30
  // fraction key).
33
31
  describe("Fraction Bar", () => {
34
32
  it("should work with no content", () => {
35
- mathField.pressKey(Keys.FRAC_INCLUSIVE);
33
+ mathField.pressKey("FRAC_INCLUSIVE");
36
34
  expect(mathField.getContent()).toEqual("\\frac{ }{ }");
37
35
  });
38
36
 
39
37
  it("should work after an expression", () => {
40
38
  mathField.setContent("35x^2");
41
- mathField.pressKey(Keys.FRAC_INCLUSIVE);
39
+ mathField.pressKey("FRAC_INCLUSIVE");
42
40
  expect(mathField.getContent()).toEqual("\\frac{35x^2}{ }");
43
41
  });
44
42
 
45
43
  it("should work before an expression", () => {
46
44
  mathField.setContent("35x^2");
47
45
  mathField.moveToStart();
48
- mathField.pressKey(Keys.FRAC_INCLUSIVE);
46
+ mathField.pressKey("FRAC_INCLUSIVE");
49
47
  expect(mathField.getContent()).toEqual("\\frac{ }{ }35x^2");
50
48
  });
51
49
 
52
50
  it("should work with a selected expression", () => {
53
51
  mathField.setContent("35x^2");
54
52
  mathField.selectAll();
55
- mathField.pressKey(Keys.FRAC_INCLUSIVE);
53
+ mathField.pressKey("FRAC_INCLUSIVE");
56
54
  expect(mathField.getContent()).toEqual("\\frac{35x^2}{ }");
57
55
  });
58
56
  });
@@ -60,34 +58,34 @@ describe("MathQuill", () => {
60
58
  describe("Parentheses", () => {
61
59
  it("should work with no content", () => {
62
60
  mathField.setContent("");
63
- mathField.pressKey(Keys.LEFT_PAREN);
61
+ mathField.pressKey("LEFT_PAREN");
64
62
  expect(mathField.getContent()).toEqual("\\left(\\right)");
65
63
  });
66
64
 
67
65
  it("should work after an expression", () => {
68
66
  mathField.setContent("35x^2");
69
- mathField.pressKey(Keys.RIGHT_PAREN);
67
+ mathField.pressKey("RIGHT_PAREN");
70
68
  expect(mathField.getContent()).toEqual("\\left(35x^2\\right)");
71
69
  });
72
70
 
73
71
  it("should work before an expression", () => {
74
72
  mathField.setContent("35x^2");
75
73
  mathField.moveToStart();
76
- mathField.pressKey(Keys.LEFT_PAREN);
74
+ mathField.pressKey("LEFT_PAREN");
77
75
  expect(mathField.getContent()).toEqual("\\left(35x^2\\right)");
78
76
  });
79
77
 
80
78
  it.skip("should work on a selected expression", () => {
81
79
  mathField.setContent("35x + 5");
82
80
  mathField.selectAll();
83
- mathField.pressKey(Keys.LEFT_PAREN);
81
+ mathField.pressKey("LEFT_PAREN");
84
82
  expect(mathField.getContent()).toEqual("\\left(35x^2\\right)");
85
83
  });
86
84
  });
87
85
 
88
86
  describe("Squared", () => {
89
87
  it("should prefix with empty parens after no content", () => {
90
- mathField.pressKey(Keys.EXP_2);
88
+ mathField.pressKey("EXP_2");
91
89
  expect(mathField.getContent()).toEqual("\\left(\\right)^2");
92
90
 
93
91
  // Verify that the cursor is in parens.
@@ -95,28 +93,28 @@ describe("MathQuill", () => {
95
93
  });
96
94
 
97
95
  it("should prefix with empty parens after an operator", () => {
98
- mathField.pressKey(Keys.DIVIDE);
99
- mathField.pressKey(Keys.EXP_2);
96
+ mathField.pressKey("DIVIDE");
97
+ mathField.pressKey("EXP_2");
100
98
  expect(mathField.getContent()).toEqual("\\div\\left(\\right)^2");
101
99
  });
102
100
 
103
101
  it("should work after an expression", () => {
104
102
  mathField.setContent("35x");
105
- mathField.pressKey(Keys.EXP_2);
103
+ mathField.pressKey("EXP_2");
106
104
  expect(mathField.getContent()).toEqual("35x^2");
107
105
  });
108
106
 
109
107
  it.skip("should work on a selected expression", () => {
110
108
  mathField.setContent("35x+5");
111
109
  mathField.selectAll();
112
- mathField.pressKey(Keys.EXP_2);
110
+ mathField.pressKey("EXP_2");
113
111
  expect(mathField.getContent()).toEqual("\\left(35x+5\\right)^2");
114
112
  });
115
113
  });
116
114
 
117
115
  describe("Cubed", () => {
118
116
  it("should prefix with empty parens after no content", () => {
119
- mathField.pressKey(Keys.EXP_3);
117
+ mathField.pressKey("EXP_3");
120
118
  expect(mathField.getContent()).toEqual("\\left(\\right)^3");
121
119
 
122
120
  // Verify that the cursor is in parens.
@@ -124,46 +122,46 @@ describe("MathQuill", () => {
124
122
  });
125
123
 
126
124
  it("should prefix with empty parens after an operator", () => {
127
- mathField.pressKey(Keys.EQUAL);
128
- mathField.pressKey(Keys.EXP_3);
125
+ mathField.pressKey("EQUAL");
126
+ mathField.pressKey("EXP_3");
129
127
  expect(mathField.getContent()).toEqual("=\\left(\\right)^3");
130
128
  });
131
129
 
132
130
  it("should work after an expression", () => {
133
131
  mathField.setContent("35x");
134
- mathField.pressKey(Keys.EXP_3);
132
+ mathField.pressKey("EXP_3");
135
133
  expect(mathField.getContent()).toEqual("35x^3");
136
134
  });
137
135
 
138
136
  it.skip("should work on a selected expression", () => {
139
137
  mathField.setContent("35x+5");
140
138
  mathField.selectAll();
141
- mathField.pressKey(Keys.EXP_3);
139
+ mathField.pressKey("EXP_3");
142
140
  expect(mathField.getContent()).toEqual("\\left(35x+5\\right)^3");
143
141
  });
144
142
  });
145
143
 
146
144
  describe("Exponent", () => {
147
145
  it("should prefix with empty parens after no content", () => {
148
- mathField.pressKey(Keys.EXP);
146
+ mathField.pressKey("EXP");
149
147
  expect(mathField.getContent()).toEqual("\\left(\\right)^{ }");
150
148
 
151
149
  // Verify that the cursor is in the exponent, not within the parens,
152
150
  // writing a unique character to verify cursor position.
153
151
  expect(isInsideEmptyParens(mathField.getCursor())).toBeFalsy();
154
- mathField.pressKey(Keys.PLUS);
152
+ mathField.pressKey("PLUS");
155
153
  expect(mathField.getContent()).toEqual("\\left(\\right)^+");
156
154
  });
157
155
 
158
156
  it("should prefix with empty parens after an operator", () => {
159
- mathField.pressKey(Keys.PLUS);
160
- mathField.pressKey(Keys.EXP);
157
+ mathField.pressKey("PLUS");
158
+ mathField.pressKey("EXP");
161
159
  expect(mathField.getContent()).toEqual("+\\left(\\right)^{ }");
162
160
  });
163
161
 
164
162
  it("should work after an expression", () => {
165
163
  mathField.setContent("35x");
166
- mathField.pressKey(Keys.EXP);
164
+ mathField.pressKey("EXP");
167
165
  expect(mathField.getContent()).toEqual("35x^{ }");
168
166
  });
169
167
 
@@ -171,47 +169,47 @@ describe("MathQuill", () => {
171
169
  it.skip("should work on a selected expression", () => {
172
170
  mathField.setContent("35x+5");
173
171
  mathField.selectAll();
174
- mathField.pressKey(Keys.EXP);
172
+ mathField.pressKey("EXP");
175
173
  expect(mathField.getContent()).toEqual("\\left(35x+5\\right)^{ }");
176
174
  });
177
175
  });
178
176
 
179
177
  describe("Square Root", () => {
180
178
  it("should work with no content", () => {
181
- mathField.pressKey(Keys.SQRT);
179
+ mathField.pressKey("SQRT");
182
180
  expect(mathField.getContent()).toEqual("\\sqrt{ }");
183
181
  });
184
182
 
185
183
  it("should work after an expression", () => {
186
184
  mathField.setContent("35x^2");
187
- mathField.pressKey(Keys.SQRT);
185
+ mathField.pressKey("SQRT");
188
186
  expect(mathField.getContent()).toEqual("35x^2\\sqrt{ }");
189
187
  });
190
188
 
191
189
  it("should work on a selected expression", () => {
192
190
  mathField.setContent("35x+5");
193
191
  mathField.selectAll();
194
- mathField.pressKey(Keys.SQRT);
192
+ mathField.pressKey("SQRT");
195
193
  expect(mathField.getContent()).toEqual("\\sqrt{35x+5}");
196
194
  });
197
195
  });
198
196
 
199
197
  describe("Radical", () => {
200
198
  it("should work with no content", () => {
201
- mathField.pressKey(Keys.RADICAL);
199
+ mathField.pressKey("RADICAL");
202
200
  expect(mathField.getContent()).toEqual("\\sqrt[]{}");
203
201
  });
204
202
 
205
203
  it("should work after an expression", () => {
206
204
  mathField.setContent("35x^2");
207
- mathField.pressKey(Keys.RADICAL);
205
+ mathField.pressKey("RADICAL");
208
206
  expect(mathField.getContent()).toEqual("35x^2\\sqrt[]{}");
209
207
  });
210
208
 
211
209
  it.skip("should work on a selected expression", () => {
212
210
  mathField.setContent("35x+5");
213
211
  mathField.selectAll();
214
- mathField.pressKey(Keys.RADICAL);
212
+ mathField.pressKey("RADICAL");
215
213
  // TODO(kevinb): check cursor location
216
214
  expect(mathField.getContent()).toEqual("\\sqrt[ ]{35x+5}");
217
215
  });
@@ -219,33 +217,33 @@ describe("MathQuill", () => {
219
217
 
220
218
  describe("Log", () => {
221
219
  it("should work with no content", () => {
222
- mathField.pressKey(Keys.LOG);
220
+ mathField.pressKey("LOG");
223
221
  expect(mathField.getContent()).toEqual("\\log\\left(\\right)");
224
222
  });
225
223
 
226
224
  it("should work after an expression", () => {
227
225
  mathField.setContent("35x^2");
228
- mathField.pressKey(Keys.LOG);
226
+ mathField.pressKey("LOG");
229
227
  expect(mathField.getContent()).toEqual("35x^2\\log\\left(\\right)");
230
228
  });
231
229
 
232
230
  it.skip("should work on a selected expression", () => {
233
231
  mathField.setContent("35x+5");
234
232
  mathField.selectAll();
235
- mathField.pressKey(Keys.LOG);
233
+ mathField.pressKey("LOG");
236
234
  expect(mathField.getContent()).toEqual("\\log\\left(35x+5\\right)");
237
235
  });
238
236
  });
239
237
 
240
238
  describe("Log w/ base n", () => {
241
239
  it("should work with no content", () => {
242
- mathField.pressKey(Keys.LOG_N);
240
+ mathField.pressKey("LOG_N");
243
241
  expect(mathField.getContent()).toEqual("\\log_{ }\\left(\\right)");
244
242
  });
245
243
 
246
244
  it("should work after an expression", () => {
247
245
  mathField.setContent("35x^2");
248
- mathField.pressKey(Keys.LOG_N);
246
+ mathField.pressKey("LOG_N");
249
247
  expect(mathField.getContent()).toEqual(
250
248
  "35x^2\\log_{ }\\left(\\right)",
251
249
  );
@@ -254,7 +252,7 @@ describe("MathQuill", () => {
254
252
  it.skip("should work on a selected expression", () => {
255
253
  mathField.setContent("35x+5");
256
254
  mathField.selectAll();
257
- mathField.pressKey(Keys.LOG_N);
255
+ mathField.pressKey("LOG_N");
258
256
  expect(mathField.getContent()).toEqual(
259
257
  "\\log_{ }\\left(35x+5\\right)",
260
258
  );
@@ -265,15 +263,15 @@ describe("MathQuill", () => {
265
263
  it("should delete an empty fraction from the numerator", () => {
266
264
  mathField.setContent("\\frac{ }{ }");
267
265
  mathField.moveToStart();
268
- mathField.pressKey(Keys.RIGHT);
269
- mathField.pressKey(Keys.BACKSPACE);
266
+ mathField.pressKey("RIGHT");
267
+ mathField.pressKey("BACKSPACE");
270
268
  expect(mathField.getContent()).toEqual("");
271
269
  });
272
270
 
273
271
  it("should convert a fraction when deleting the denominator", () => {
274
272
  mathField.setContent("\\frac{35x^2}{ }");
275
- mathField.pressKey(Keys.LEFT);
276
- mathField.pressKey(Keys.BACKSPACE);
273
+ mathField.pressKey("LEFT");
274
+ mathField.pressKey("BACKSPACE");
277
275
  expect(mathField.getContent()).toEqual("35x^2");
278
276
  });
279
277
 
@@ -281,29 +279,29 @@ describe("MathQuill", () => {
281
279
  it("should select a fraction when deleting from outside of it", () => {
282
280
  const expr = "\\frac{35x+5}{x^2}";
283
281
  mathField.setContent(expr);
284
- mathField.pressKey(Keys.BACKSPACE);
282
+ mathField.pressKey("BACKSPACE");
285
283
  expect(mathField.isSelected()).toBeTruthy();
286
284
  expect(mathField.getContent()).toEqual(expr);
287
285
  });
288
286
 
289
287
  it("should delete parens when inside empty parens", () => {
290
288
  mathField.setContent("\\left(\\right)");
291
- mathField.pressKey(Keys.LEFT);
292
- mathField.pressKey(Keys.BACKSPACE);
289
+ mathField.pressKey("LEFT");
290
+ mathField.pressKey("BACKSPACE");
293
291
  expect(mathField.getContent()).toEqual("");
294
292
  });
295
293
 
296
294
  it("deletes only the first parens when inside empty parens", () => {
297
295
  mathField.setContent("\\left(\\right)\\left(\\right)");
298
- mathField.pressKey(Keys.LEFT);
299
- mathField.pressKey(Keys.BACKSPACE);
296
+ mathField.pressKey("LEFT");
297
+ mathField.pressKey("BACKSPACE");
300
298
  expect(mathField.getContent()).toEqual("\\left(\\right)");
301
299
  });
302
300
 
303
301
  it("should select an expression when deleting from outside (1)", () => {
304
302
  const expr = "\\left(35x+5\\right)";
305
303
  mathField.setContent(expr);
306
- mathField.pressKey(Keys.BACKSPACE);
304
+ mathField.pressKey("BACKSPACE");
307
305
  expect(mathField.isSelected()).toBeTruthy();
308
306
  expect(mathField.getContent()).toEqual(expr);
309
307
  });
@@ -311,7 +309,7 @@ describe("MathQuill", () => {
311
309
  it("should select an expression when deleting from outside (2)", () => {
312
310
  const expr = "1+\\left(35x+5\\right)";
313
311
  mathField.setContent(expr);
314
- mathField.pressKey(Keys.BACKSPACE);
312
+ mathField.pressKey("BACKSPACE");
315
313
  const selection = mathField.getSelection();
316
314
  const left = selection.ends[MQ.L][MQ.L];
317
315
  const right = selection.ends[MQ.R][MQ.R];
@@ -324,9 +322,9 @@ describe("MathQuill", () => {
324
322
  it("should select an expression when deleting from outside (3)", () => {
325
323
  const expr = "1+\\left(35x+5\\right)-1";
326
324
  mathField.setContent(expr);
327
- mathField.pressKey(Keys.LEFT);
328
- mathField.pressKey(Keys.LEFT);
329
- mathField.pressKey(Keys.BACKSPACE);
325
+ mathField.pressKey("LEFT");
326
+ mathField.pressKey("LEFT");
327
+ mathField.pressKey("BACKSPACE");
330
328
  const selection = mathField.getSelection();
331
329
  const left = selection.ends[MQ.L][MQ.L];
332
330
  const right = selection.ends[MQ.R][MQ.R];
@@ -339,9 +337,9 @@ describe("MathQuill", () => {
339
337
  it("should select an expression when deleting from outside (4)", () => {
340
338
  const expr = "\\left(35x+5\\right)-1";
341
339
  mathField.setContent(expr);
342
- mathField.pressKey(Keys.LEFT);
343
- mathField.pressKey(Keys.LEFT);
344
- mathField.pressKey(Keys.BACKSPACE);
340
+ mathField.pressKey("LEFT");
341
+ mathField.pressKey("LEFT");
342
+ mathField.pressKey("BACKSPACE");
345
343
  const selection = mathField.getSelection();
346
344
  const left = selection.ends[MQ.L][MQ.L];
347
345
  const right = selection.ends[MQ.R][MQ.R];
@@ -353,7 +351,7 @@ describe("MathQuill", () => {
353
351
 
354
352
  it("should select an expression when deleting from outside", () => {
355
353
  mathField.setContent("\\left(35x+5\\right)");
356
- mathField.pressKey(Keys.BACKSPACE);
354
+ mathField.pressKey("BACKSPACE");
357
355
  expect(mathField.isSelected()).toBeTruthy();
358
356
  expect(mathField.getContent()).toEqual("\\left(35x+5\\right)");
359
357
  });
@@ -361,64 +359,64 @@ describe("MathQuill", () => {
361
359
  // TODO(kevinb) fix this behavior so that we delete the exponent too
362
360
  it.skip("should not delete squared exponents", () => {
363
361
  mathField.setContent("35x^2");
364
- mathField.pressKey(Keys.BACKSPACE);
362
+ mathField.pressKey("BACKSPACE");
365
363
  expect(mathField.getContent()).toEqual("35x^2");
366
- mathField.pressKey(Keys.BACKSPACE);
364
+ mathField.pressKey("BACKSPACE");
367
365
  expect(mathField.getContent()).toEqual("35x^{ }");
368
366
  });
369
367
 
370
368
  it("should not delete non-square exponents", () => {
371
369
  mathField.setContent("35x^5");
372
- mathField.pressKey(Keys.BACKSPACE);
370
+ mathField.pressKey("BACKSPACE");
373
371
  expect(mathField.getContent()).toEqual("35x^5");
374
- mathField.pressKey(Keys.BACKSPACE);
372
+ mathField.pressKey("BACKSPACE");
375
373
  expect(mathField.getContent()).toEqual("35x^{ }");
376
374
  });
377
375
 
378
376
  it("should delete an empty exponent", () => {
379
377
  mathField.setContent("35x^{}");
380
- mathField.pressKey(Keys.LEFT);
381
- mathField.pressKey(Keys.BACKSPACE);
378
+ mathField.pressKey("LEFT");
379
+ mathField.pressKey("BACKSPACE");
382
380
  expect(mathField.getContent()).toEqual("35x");
383
381
  });
384
382
 
385
383
  it("should delete an empty square root", () => {
386
384
  mathField.setContent("\\sqrt{}");
387
- mathField.pressKey(Keys.LEFT);
388
- mathField.pressKey(Keys.BACKSPACE);
385
+ mathField.pressKey("LEFT");
386
+ mathField.pressKey("BACKSPACE");
389
387
  expect(mathField.getContent()).toEqual("");
390
388
  });
391
389
 
392
390
  it("should delete an empty radical when cursor is in index", () => {
393
391
  mathField.setContent("\\sqrt[]{}");
394
392
  mathField.moveToStart();
395
- mathField.pressKey(Keys.RIGHT);
396
- mathField.pressKey(Keys.BACKSPACE);
393
+ mathField.pressKey("RIGHT");
394
+ mathField.pressKey("BACKSPACE");
397
395
  expect(mathField.getContent()).toEqual("");
398
396
  });
399
397
 
400
398
  it("should delete an empty radical when cursor is in body", () => {
401
- mathField.pressKey(Keys.RADICAL);
402
- mathField.pressKey(Keys.RIGHT);
403
- mathField.pressKey(Keys.BACKSPACE);
399
+ mathField.pressKey("RADICAL");
400
+ mathField.pressKey("RIGHT");
401
+ mathField.pressKey("BACKSPACE");
404
402
  expect(mathField.getContent()).toEqual("");
405
403
  });
406
404
 
407
405
  it("should select an empty radical with non-empty root", () => {
408
- mathField.pressKey(Keys.CUBE_ROOT);
406
+ mathField.pressKey("CUBE_ROOT");
409
407
  const expr = mathField.getContent();
410
- mathField.pressKey(Keys.BACKSPACE);
408
+ mathField.pressKey("BACKSPACE");
411
409
 
412
410
  expect(mathField.isSelected()).toBeTruthy();
413
411
  expect(mathField.getContent()).toEqual(expr);
414
412
  });
415
413
 
416
414
  it("should normally delete within a non-empty radical", () => {
417
- mathField.pressKey(Keys.CUBE_ROOT);
415
+ mathField.pressKey("CUBE_ROOT");
418
416
  const expr = mathField.getContent();
419
417
 
420
418
  mathField.pressKey("NUM_2");
421
- mathField.pressKey(Keys.BACKSPACE);
419
+ mathField.pressKey("BACKSPACE");
422
420
 
423
421
  expect(mathField.getContent()).toEqual(expr);
424
422
  });
@@ -426,9 +424,9 @@ describe("MathQuill", () => {
426
424
  it("deletes nthroot index normally", () => {
427
425
  mathField.setContent("\\sqrt[3]{35x+5}");
428
426
  mathField.moveToStart();
429
- mathField.pressKey(Keys.RIGHT);
430
- mathField.pressKey(Keys.RIGHT);
431
- mathField.pressKey(Keys.BACKSPACE);
427
+ mathField.pressKey("RIGHT");
428
+ mathField.pressKey("RIGHT");
429
+ mathField.pressKey("BACKSPACE");
432
430
 
433
431
  const cursor = mathField.getCursor();
434
432
 
@@ -439,8 +437,8 @@ describe("MathQuill", () => {
439
437
  it("converts nthroot to sqrt when deleting from index (1)", () => {
440
438
  mathField.setContent("\\sqrt[]{35x+5}");
441
439
  mathField.moveToStart();
442
- mathField.pressKey(Keys.RIGHT);
443
- mathField.pressKey(Keys.BACKSPACE);
440
+ mathField.pressKey("RIGHT");
441
+ mathField.pressKey("BACKSPACE");
444
442
 
445
443
  const cursor = mathField.getCursor();
446
444
 
@@ -451,10 +449,10 @@ describe("MathQuill", () => {
451
449
  it("converts nthroot to sqrt when deleting from index (2)", () => {
452
450
  mathField.setContent("1+\\sqrt[]{35x+5}");
453
451
  mathField.moveToStart();
454
- mathField.pressKey(Keys.RIGHT);
455
- mathField.pressKey(Keys.RIGHT);
456
- mathField.pressKey(Keys.RIGHT);
457
- mathField.pressKey(Keys.BACKSPACE);
452
+ mathField.pressKey("RIGHT");
453
+ mathField.pressKey("RIGHT");
454
+ mathField.pressKey("RIGHT");
455
+ mathField.pressKey("BACKSPACE");
458
456
 
459
457
  const cursor = mathField.getCursor();
460
458
 
@@ -466,8 +464,8 @@ describe("MathQuill", () => {
466
464
  const expr = "\\sqrt[3]{35x+5}";
467
465
  mathField.setContent(expr);
468
466
  mathField.moveToStart();
469
- mathField.pressKey(Keys.RIGHT);
470
- mathField.pressKey(Keys.BACKSPACE);
467
+ mathField.pressKey("RIGHT");
468
+ mathField.pressKey("BACKSPACE");
471
469
 
472
470
  expect(mathField.getContent()).toEqual(expr);
473
471
  });
@@ -475,7 +473,7 @@ describe("MathQuill", () => {
475
473
  it("should select a full square root before deleting it", () => {
476
474
  const expr = "\\sqrt{35x+5}";
477
475
  mathField.setContent(expr);
478
- mathField.pressKey(Keys.BACKSPACE);
476
+ mathField.pressKey("BACKSPACE");
479
477
 
480
478
  expect(mathField.isSelected()).toBeTruthy();
481
479
  expect(mathField.getContent()).toEqual(expr);
@@ -484,7 +482,7 @@ describe("MathQuill", () => {
484
482
  it("should select a full nth-root before deleting it", () => {
485
483
  const expr = "\\sqrt[3]{35x+5}";
486
484
  mathField.setContent(expr);
487
- mathField.pressKey(Keys.BACKSPACE);
485
+ mathField.pressKey("BACKSPACE");
488
486
 
489
487
  expect(mathField.isSelected()).toBeTruthy();
490
488
  expect(mathField.getContent()).toEqual(expr);
@@ -492,8 +490,8 @@ describe("MathQuill", () => {
492
490
 
493
491
  it("should delete log when inside empty log", () => {
494
492
  mathField.setContent("\\log\\left(\\right)");
495
- mathField.pressKey(Keys.LEFT);
496
- mathField.pressKey(Keys.BACKSPACE);
493
+ mathField.pressKey("LEFT");
494
+ mathField.pressKey("BACKSPACE");
497
495
  expect(mathField.getContent()).toEqual("");
498
496
  });
499
497
 
@@ -501,8 +499,8 @@ describe("MathQuill", () => {
501
499
  const expr = "\\log\\left(35x\\right)";
502
500
  mathField.setContent(expr);
503
501
  mathField.moveToStart();
504
- mathField.pressKey(Keys.RIGHT);
505
- mathField.pressKey(Keys.BACKSPACE);
502
+ mathField.pressKey("RIGHT");
503
+ mathField.pressKey("BACKSPACE");
506
504
  expect(mathField.isSelected()).toBeTruthy();
507
505
  expect(mathField.getContent()).toEqual(expr);
508
506
  });
@@ -510,7 +508,7 @@ describe("MathQuill", () => {
510
508
  it("should select log when outside full log at tail (1)", () => {
511
509
  const expr = "\\log\\left(35x\\right)";
512
510
  mathField.setContent(expr);
513
- mathField.pressKey(Keys.BACKSPACE);
511
+ mathField.pressKey("BACKSPACE");
514
512
  expect(mathField.isSelected()).toBeTruthy();
515
513
  expect(mathField.getContent()).toEqual(expr);
516
514
  });
@@ -518,7 +516,7 @@ describe("MathQuill", () => {
518
516
  it("should select log when outside full log at tail (2)", () => {
519
517
  const expr = "1+\\log\\left(35x\\right)";
520
518
  mathField.setContent(expr);
521
- mathField.pressKey(Keys.BACKSPACE);
519
+ mathField.pressKey("BACKSPACE");
522
520
  const selection = mathField.getSelection();
523
521
  const left = selection.ends[MQ.L][MQ.L];
524
522
  const right = selection.ends[MQ.R][MQ.R];
@@ -531,9 +529,9 @@ describe("MathQuill", () => {
531
529
  it("should select log when outside full log at tail (3)", () => {
532
530
  const expr = "1+\\log\\left(35x\\right)-1";
533
531
  mathField.setContent(expr);
534
- mathField.pressKey(Keys.LEFT);
535
- mathField.pressKey(Keys.LEFT);
536
- mathField.pressKey(Keys.BACKSPACE);
532
+ mathField.pressKey("LEFT");
533
+ mathField.pressKey("LEFT");
534
+ mathField.pressKey("BACKSPACE");
537
535
  const selection = mathField.getSelection();
538
536
  const left = selection.ends[MQ.L][MQ.L];
539
537
  const right = selection.ends[MQ.R][MQ.R];
@@ -546,9 +544,9 @@ describe("MathQuill", () => {
546
544
  it("should select log when outside full log at tail (4)", () => {
547
545
  const expr = "\\log\\left(35x\\right)-1";
548
546
  mathField.setContent(expr);
549
- mathField.pressKey(Keys.LEFT);
550
- mathField.pressKey(Keys.LEFT);
551
- mathField.pressKey(Keys.BACKSPACE);
547
+ mathField.pressKey("LEFT");
548
+ mathField.pressKey("LEFT");
549
+ mathField.pressKey("BACKSPACE");
552
550
  const selection = mathField.getSelection();
553
551
  const left = selection.ends[MQ.L][MQ.L];
554
552
  const right = selection.ends[MQ.R][MQ.R];
@@ -564,11 +562,11 @@ describe("MathQuill", () => {
564
562
 
565
563
  // Move right once to get into the parens, and then left twice to
566
564
  // get to the empty index.
567
- mathField.pressKey(Keys.RIGHT);
568
- mathField.pressKey(Keys.LEFT);
569
- mathField.pressKey(Keys.LEFT);
565
+ mathField.pressKey("RIGHT");
566
+ mathField.pressKey("LEFT");
567
+ mathField.pressKey("LEFT");
570
568
 
571
- mathField.pressKey(Keys.BACKSPACE);
569
+ mathField.pressKey("BACKSPACE");
572
570
  expect(mathField.getContent()).toEqual("");
573
571
  });
574
572
 
@@ -578,18 +576,18 @@ describe("MathQuill", () => {
578
576
 
579
577
  // Move right once to get into the parens, and then left twice to
580
578
  // get to the index.
581
- mathField.pressKey(Keys.RIGHT);
582
- mathField.pressKey(Keys.LEFT);
583
- mathField.pressKey(Keys.LEFT);
579
+ mathField.pressKey("RIGHT");
580
+ mathField.pressKey("LEFT");
581
+ mathField.pressKey("LEFT");
584
582
 
585
- mathField.pressKey(Keys.BACKSPACE);
583
+ mathField.pressKey("BACKSPACE");
586
584
  expect(mathField.getContent()).toEqual("\\log_{ }\\left(\\right)");
587
585
  });
588
586
 
589
587
  it("should move to index from inside empty log with index", () => {
590
588
  mathField.setContent("\\log_5\\left(\\right)");
591
- mathField.pressKey(Keys.LEFT);
592
- mathField.pressKey(Keys.BACKSPACE);
589
+ mathField.pressKey("LEFT");
590
+ mathField.pressKey("BACKSPACE");
593
591
 
594
592
  const cursor = mathField.getCursor();
595
593
 
@@ -604,11 +602,11 @@ describe("MathQuill", () => {
604
602
 
605
603
  // Move right once to get into the parens, and then left twice to
606
604
  // get to the empty index.
607
- mathField.pressKey(Keys.RIGHT);
608
- mathField.pressKey(Keys.LEFT);
609
- mathField.pressKey(Keys.LEFT);
605
+ mathField.pressKey("RIGHT");
606
+ mathField.pressKey("LEFT");
607
+ mathField.pressKey("LEFT");
610
608
 
611
- mathField.pressKey(Keys.BACKSPACE);
609
+ mathField.pressKey("BACKSPACE");
612
610
 
613
611
  expect(mathField.isSelected()).toBeTruthy();
614
612
  expect(mathField.getContent()).toEqual(expr);
@@ -621,13 +619,13 @@ describe("MathQuill", () => {
621
619
 
622
620
  // Move right once to get into the parens, and then left twice to
623
621
  // get to the empty index.
624
- mathField.pressKey(Keys.RIGHT);
625
- mathField.pressKey(Keys.RIGHT);
626
- mathField.pressKey(Keys.RIGHT);
627
- mathField.pressKey(Keys.LEFT);
628
- mathField.pressKey(Keys.LEFT);
622
+ mathField.pressKey("RIGHT");
623
+ mathField.pressKey("RIGHT");
624
+ mathField.pressKey("RIGHT");
625
+ mathField.pressKey("LEFT");
626
+ mathField.pressKey("LEFT");
629
627
 
630
- mathField.pressKey(Keys.BACKSPACE);
628
+ mathField.pressKey("BACKSPACE");
631
629
 
632
630
  const selection = mathField.getSelection();
633
631
  const left = selection.ends[MQ.L][MQ.L];
@@ -645,13 +643,13 @@ describe("MathQuill", () => {
645
643
 
646
644
  // Move right three times to get into the parens, and then left
647
645
  // twice to get to the start of the empty index.
648
- mathField.pressKey(Keys.RIGHT);
649
- mathField.pressKey(Keys.RIGHT);
650
- mathField.pressKey(Keys.RIGHT);
651
- mathField.pressKey(Keys.LEFT);
652
- mathField.pressKey(Keys.LEFT);
646
+ mathField.pressKey("RIGHT");
647
+ mathField.pressKey("RIGHT");
648
+ mathField.pressKey("RIGHT");
649
+ mathField.pressKey("LEFT");
650
+ mathField.pressKey("LEFT");
653
651
 
654
- mathField.pressKey(Keys.BACKSPACE);
652
+ mathField.pressKey("BACKSPACE");
655
653
 
656
654
  const selection = mathField.getSelection();
657
655
  const left = selection.ends[MQ.L][MQ.L];
@@ -669,11 +667,11 @@ describe("MathQuill", () => {
669
667
 
670
668
  // Move right once to get into the parens, and then left twice to
671
669
  // get to the start of the empty index.
672
- mathField.pressKey(Keys.RIGHT);
673
- mathField.pressKey(Keys.LEFT);
674
- mathField.pressKey(Keys.LEFT);
670
+ mathField.pressKey("RIGHT");
671
+ mathField.pressKey("LEFT");
672
+ mathField.pressKey("LEFT");
675
673
 
676
- mathField.pressKey(Keys.BACKSPACE);
674
+ mathField.pressKey("BACKSPACE");
677
675
 
678
676
  const selection = mathField.getSelection();
679
677
  const left = selection.ends[MQ.L][MQ.L];
@@ -687,7 +685,7 @@ describe("MathQuill", () => {
687
685
 
688
686
  describe("Left arrow", () => {
689
687
  it("skips function names", () => {
690
- mathField.pressKey(Keys.COS);
688
+ mathField.pressKey("COS");
691
689
  const cursor = mathField.getCursor();
692
690
 
693
691
  // Verify that we're inside the function.
@@ -695,7 +693,7 @@ describe("MathQuill", () => {
695
693
  expect(cursor[MQ.R]).toEqual(END_OF_EXPR);
696
694
 
697
695
  // Navigate left.
698
- mathField.pressKey(Keys.LEFT);
696
+ mathField.pressKey("LEFT");
699
697
 
700
698
  // Verify that we moved beyond the body of the function.
701
699
  expect(cursor[MQ.L]).toEqual(END_OF_EXPR);
@@ -703,8 +701,8 @@ describe("MathQuill", () => {
703
701
  });
704
702
 
705
703
  it("does not skip out of a function with valid content present", () => {
706
- mathField.pressKey(Keys.COS);
707
- mathField.pressKey(Keys.PLUS);
704
+ mathField.pressKey("COS");
705
+ mathField.pressKey("PLUS");
708
706
  const cursor = mathField.getCursor();
709
707
 
710
708
  // Verify that we're inside the function.
@@ -712,7 +710,7 @@ describe("MathQuill", () => {
712
710
  expect(cursor[MQ.R]).toEqual(END_OF_EXPR);
713
711
 
714
712
  // Navigate left.
715
- mathField.pressKey(Keys.LEFT);
713
+ mathField.pressKey("LEFT");
716
714
 
717
715
  // Verify that we didn't move out of the function.
718
716
  expect(cursor[MQ.L]).toEqual(END_OF_EXPR);
@@ -731,7 +729,7 @@ describe("MathQuill", () => {
731
729
  expect(cursor[MQ.R].ctrlSeq).toEqual("\\c");
732
730
 
733
731
  // Navigate right.
734
- mathField.pressKey(Keys.RIGHT);
732
+ mathField.pressKey("RIGHT");
735
733
 
736
734
  // Verify that we moved into the body of the function.
737
735
  expect(cursor[MQ.L]).toEqual(END_OF_EXPR);