@khanacademy/math-input 17.0.4 → 17.0.6

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 (86) hide show
  1. package/dist/components/input/math-wrapper.d.ts +2 -2
  2. package/dist/components/input/mathquill-types.d.ts +49 -6
  3. package/dist/es/index.js +8 -6
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/index.js +8 -7
  6. package/dist/index.js.map +1 -1
  7. package/package.json +6 -3
  8. package/.eslintrc.js +0 -18
  9. package/CHANGELOG.md +0 -660
  10. package/less/main.less +0 -2
  11. package/less/overrides.less +0 -122
  12. package/src/components/__tests__/integration.test.tsx +0 -300
  13. package/src/components/aphrodite-css-transition-group/index.tsx +0 -78
  14. package/src/components/aphrodite-css-transition-group/transition-child.tsx +0 -192
  15. package/src/components/aphrodite-css-transition-group/types.ts +0 -20
  16. package/src/components/aphrodite-css-transition-group/util.ts +0 -97
  17. package/src/components/input/__tests__/context-tracking.test.ts +0 -176
  18. package/src/components/input/__tests__/mathquill-helpers.test.ts +0 -105
  19. package/src/components/input/__tests__/mathquill.test.ts +0 -747
  20. package/src/components/input/__tests__/test-math-wrapper.ts +0 -29
  21. package/src/components/input/cursor-contexts.ts +0 -37
  22. package/src/components/input/cursor-handle.tsx +0 -137
  23. package/src/components/input/cursor-styles.ts +0 -10
  24. package/src/components/input/drag-listener.ts +0 -79
  25. package/src/components/input/math-input.tsx +0 -1036
  26. package/src/components/input/math-wrapper.ts +0 -189
  27. package/src/components/input/mathquill-helpers.ts +0 -262
  28. package/src/components/input/mathquill-instance.ts +0 -106
  29. package/src/components/input/mathquill-types.ts +0 -32
  30. package/src/components/input/scroll-into-view.ts +0 -65
  31. package/src/components/key-handlers/__tests__/handle-jump-out.test.ts +0 -94
  32. package/src/components/key-handlers/handle-arrow.ts +0 -70
  33. package/src/components/key-handlers/handle-backspace.ts +0 -277
  34. package/src/components/key-handlers/handle-exponent.ts +0 -53
  35. package/src/components/key-handlers/handle-jump-out.ts +0 -107
  36. package/src/components/key-handlers/key-translator.ts +0 -222
  37. package/src/components/keypad/__tests__/__snapshots__/keypad.test.tsx.snap +0 -1913
  38. package/src/components/keypad/__tests__/__snapshots__/mobile-keypad.test.tsx.snap +0 -600
  39. package/src/components/keypad/__tests__/keypad-button.test.tsx +0 -84
  40. package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +0 -304
  41. package/src/components/keypad/__tests__/keypad-v2.cypress.ts +0 -16
  42. package/src/components/keypad/__tests__/keypad.test.tsx +0 -321
  43. package/src/components/keypad/__tests__/mobile-keypad.test.tsx +0 -115
  44. package/src/components/keypad/__tests__/test-data-tabs.ts +0 -21
  45. package/src/components/keypad/button-assets.tsx +0 -1880
  46. package/src/components/keypad/index.tsx +0 -2
  47. package/src/components/keypad/keypad-button.stories.tsx +0 -81
  48. package/src/components/keypad/keypad-button.tsx +0 -124
  49. package/src/components/keypad/keypad-mathquill.stories.tsx +0 -109
  50. package/src/components/keypad/keypad-pages/extras-page.tsx +0 -35
  51. package/src/components/keypad/keypad-pages/fractions-page.tsx +0 -125
  52. package/src/components/keypad/keypad-pages/geometry-page.tsx +0 -34
  53. package/src/components/keypad/keypad-pages/keypad-pages.stories.tsx +0 -37
  54. package/src/components/keypad/keypad-pages/numbers-page.tsx +0 -94
  55. package/src/components/keypad/keypad-pages/operators-page.tsx +0 -117
  56. package/src/components/keypad/keypad.tsx +0 -233
  57. package/src/components/keypad/mobile-keypad-internals.tsx +0 -240
  58. package/src/components/keypad/mobile-keypad.tsx +0 -24
  59. package/src/components/keypad/navigation-button.tsx +0 -127
  60. package/src/components/keypad/navigation-pad.stories.tsx +0 -26
  61. package/src/components/keypad/navigation-pad.tsx +0 -67
  62. package/src/components/keypad/shared-keys.tsx +0 -109
  63. package/src/components/keypad/utils.ts +0 -34
  64. package/src/components/keypad-context.tsx +0 -70
  65. package/src/components/prop-types.ts +0 -16
  66. package/src/components/tabbar/__tests__/tabbar.test.tsx +0 -105
  67. package/src/components/tabbar/icons.tsx +0 -122
  68. package/src/components/tabbar/index.ts +0 -1
  69. package/src/components/tabbar/item.tsx +0 -146
  70. package/src/components/tabbar/tabbar.stories.tsx +0 -83
  71. package/src/components/tabbar/tabbar.tsx +0 -65
  72. package/src/data/key-configs.ts +0 -770
  73. package/src/data/keys.ts +0 -123
  74. package/src/enums.ts +0 -27
  75. package/src/fake-react-native-web/index.ts +0 -11
  76. package/src/fake-react-native-web/text.tsx +0 -55
  77. package/src/fake-react-native-web/view.tsx +0 -91
  78. package/src/full-keypad.stories.tsx +0 -142
  79. package/src/full-mobile-input.stories.tsx +0 -115
  80. package/src/index.ts +0 -52
  81. package/src/types.ts +0 -70
  82. package/src/utils.test.ts +0 -33
  83. package/src/utils.ts +0 -61
  84. package/src/version.ts +0 -10
  85. package/tsconfig-build.json +0 -11
  86. package/tsconfig-build.tsbuildinfo +0 -1
@@ -31,9 +31,9 @@ declare class MathWrapper {
31
31
  * should be placed
32
32
  */
33
33
  setCursorPosition(x: number, y: number, hitNode: HTMLElement): void;
34
- getCursor(): any;
34
+ getCursor(): import("mathquill").Cursor;
35
35
  contextForCursor(): import("./cursor-contexts").CursorContext;
36
- getSelection(): any;
36
+ getSelection(): import("mathquill").MQSelection | undefined;
37
37
  getContent(): string;
38
38
  setContent(latex: string): void;
39
39
  isEmpty(): boolean;
@@ -7,17 +7,60 @@ export type MathFieldConfig = MathQuill.v3.Config;
7
7
  * the ones listed here.
8
8
  * https://docs.mathquill.com/en/latest/Api_Methods/
9
9
  */
10
- export type MathFieldInterface = MathQuill.v3.EditableMathQuill;
10
+ export type MathFieldInterface = MathQuill.v3.EditableMathQuill & {
11
+ cursor: () => MathQuill.Cursor;
12
+ controller: () => MathQuill.Controller;
13
+ };
11
14
  export declare enum MathFieldActionType {
12
15
  WRITE = "write",
13
16
  CMD = "cmd",
14
17
  KEYSTROKE = "keystroke",
15
18
  MQ_END = 0
16
19
  }
20
+ export type MathFieldUpdaterCallback = (mathField: MathFieldInterface, key: Key) => void;
17
21
  /**
18
- * The MathQuill MathField Cursor
19
- * it's not part of the public API for MathQuill,
20
- * we reach into the internals to get it
22
+ * The MathQuill API (see mathuill.d.ts) does not include types
23
+ * for cursor() and controller(), and adding these types there
24
+ * in the MathQuill repo causes unexpected conflicts with other types.
25
+ *
26
+ * We don't want to use the cursor and controller default type `any`
27
+ * so we declare the types here.
21
28
  */
22
- export type MathFieldCursor = any;
23
- export type MathFieldUpdaterCallback = (mathField: MathFieldInterface, key: Key) => void;
29
+ declare module "mathquill" {
30
+ interface MQNode extends ControllerRoot {
31
+ id: number;
32
+ parent: NodeBase;
33
+ }
34
+ interface MQSelection {
35
+ id: number;
36
+ getEnd(dir: number): number;
37
+ }
38
+ interface NodeBase extends MQNode {
39
+ ctrlSeq: string | undefined;
40
+ blocks: MQNode;
41
+ latex(): string;
42
+ }
43
+ interface Cursor {
44
+ parent: MQNode;
45
+ selection: MQSelection | undefined;
46
+ select(): void;
47
+ endSelection(): void;
48
+ show(): Cursor;
49
+ hide(): Cursor;
50
+ insAtRightEnd(root: ControllerRoot): Cursor;
51
+ insRightOf(el: MQNode): Cursor;
52
+ insLeftOf(el: MQNode): Cursor;
53
+ startSelection(): void;
54
+ }
55
+ interface Controller {
56
+ parent: string;
57
+ root: ControllerRoot;
58
+ cursor: Cursor;
59
+ backspace(): Controller;
60
+ seek(targetElm: HTMLElement, clientX: number, _clientY: number): Controller;
61
+ }
62
+ interface ControllerRoot {
63
+ controller: Controller;
64
+ cursor?: Cursor;
65
+ }
66
+ }
package/dist/es/index.js CHANGED
@@ -7,7 +7,6 @@ import { StyleSheet, css } from 'aphrodite';
7
7
  import * as React from 'react';
8
8
  import { useState, useMemo, useEffect } from 'react';
9
9
  import ReactDOM from 'react-dom';
10
- import $ from 'jquery';
11
10
  import MathQuill from 'mathquill';
12
11
  import { View as View$1 } from '@khanacademy/wonder-blocks-core';
13
12
  import Clickable from '@khanacademy/wonder-blocks-clickable';
@@ -17,7 +16,7 @@ import PropTypes from 'prop-types';
17
16
 
18
17
  // This file is processed by a Rollup plugin (replace) to inject the production
19
18
  const libName = "@khanacademy/math-input";
20
- const libVersion = "17.0.4";
19
+ const libVersion = "17.0.6";
21
20
  addLibraryVersionToPerseusDebug(libName, libVersion);
22
21
 
23
22
  function _extends() {
@@ -408,9 +407,12 @@ let MathFieldActionType = /*#__PURE__*/function (MathFieldActionType) {
408
407
  }({});
409
408
 
410
409
  /**
411
- * The MathQuill MathField Cursor
412
- * it's not part of the public API for MathQuill,
413
- * we reach into the internals to get it
410
+ * The MathQuill API (see mathuill.d.ts) does not include types
411
+ * for cursor() and controller(), and adding these types there
412
+ * in the MathQuill repo causes unexpected conflicts with other types.
413
+ *
414
+ * We don't want to use the cursor and controller default type `any`
415
+ * so we declare the types here.
414
416
  */
415
417
 
416
418
  const Numerals = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
@@ -1323,7 +1325,7 @@ class MathWrapper {
1323
1325
  const controller = this.mathField.controller();
1324
1326
  const pageX = x - document.body.scrollLeft;
1325
1327
  const pageY = y - document.body.scrollTop;
1326
- controller.seek($(el), pageX, pageY).cursor.startSelection();
1328
+ controller.seek(el, pageX, pageY).cursor.startSelection();
1327
1329
 
1328
1330
  // Unless that would leave us mid-command, in which case, we
1329
1331
  // need to adjust and place the cursor inside the parens