@khanacademy/perseus-editor 4.1.5 → 4.1.7

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 (175) hide show
  1. package/dist/es/index.js +1 -1
  2. package/dist/index.js +1 -1
  3. package/package.json +9 -6
  4. package/.babelrc.js +0 -8
  5. package/.eslintrc.js +0 -12
  6. package/CHANGELOG.md +0 -1155
  7. package/src/README.md +0 -7
  8. package/src/__stories__/editor-page.stories.tsx +0 -65
  9. package/src/__stories__/editor.stories.tsx +0 -134
  10. package/src/__stories__/item-editor.stories.tsx +0 -41
  11. package/src/__stories__/tex-error-view.stories.tsx +0 -26
  12. package/src/__testdata__/input-number.testdata.ts +0 -27
  13. package/src/__tests__/editor.test.tsx +0 -142
  14. package/src/__tests__/hint-editor.test.tsx +0 -83
  15. package/src/__tests__/i18n.test.ts +0 -501
  16. package/src/__tests__/integration.test.ts +0 -5
  17. package/src/__tests__/item-extras-editor.test.tsx +0 -85
  18. package/src/__tests__/traversal.test.ts +0 -377
  19. package/src/all-editors.test.ts +0 -16
  20. package/src/all-editors.ts +0 -83
  21. package/src/all-widgets.ts +0 -7
  22. package/src/article-editor.tsx +0 -438
  23. package/src/components/__stories__/blur-input.stories.tsx +0 -22
  24. package/src/components/__stories__/section-control-button.stories.tsx +0 -26
  25. package/src/components/__tests__/blur-input.test.tsx +0 -67
  26. package/src/components/blur-input.tsx +0 -69
  27. package/src/components/checkbox.tsx +0 -194
  28. package/src/components/device-framer.tsx +0 -90
  29. package/src/components/drag-target.tsx +0 -87
  30. package/src/components/dropdown-option.tsx +0 -311
  31. package/src/components/form-wrapped-text-field.tsx +0 -245
  32. package/src/components/graph-points-count-selector.tsx +0 -31
  33. package/src/components/graph-settings.tsx +0 -627
  34. package/src/components/graph-type-selector.tsx +0 -31
  35. package/src/components/hover-behavior.ts +0 -177
  36. package/src/components/json-editor.tsx +0 -121
  37. package/src/components/link.ts +0 -173
  38. package/src/components/section-control-button.tsx +0 -53
  39. package/src/components/segment-count-selector.tsx +0 -27
  40. package/src/components/simple-button.tsx +0 -85
  41. package/src/components/sortable.tsx +0 -187
  42. package/src/components/util.ts +0 -38
  43. package/src/components/viewport-resizer.tsx +0 -72
  44. package/src/components/widget-editor.tsx +0 -222
  45. package/src/components/widget-select.tsx +0 -48
  46. package/src/diffs/__stories__/perseus-diff-wrapper.tsx +0 -11
  47. package/src/diffs/__stories__/structured-item-diff.stories.tsx +0 -855
  48. package/src/diffs/__stories__/tags-diff.stories.tsx +0 -36
  49. package/src/diffs/__stories__/text-diff.stories.tsx +0 -35
  50. package/src/diffs/__tests__/split-diff.test.ts +0 -33
  51. package/src/diffs/__tests__/string-array-diff.test.ts +0 -73
  52. package/src/diffs/__tests__/structured-item-diff.test.ts +0 -433
  53. package/src/diffs/__tests__/widget-diff-performer.test.ts +0 -43
  54. package/src/diffs/article-diff.tsx +0 -69
  55. package/src/diffs/item-diff.tsx +0 -76
  56. package/src/diffs/renderer-diff.tsx +0 -137
  57. package/src/diffs/split-diff.ts +0 -31
  58. package/src/diffs/string-array-diff.ts +0 -74
  59. package/src/diffs/structured-item-diff.tsx +0 -275
  60. package/src/diffs/tags-diff.tsx +0 -49
  61. package/src/diffs/text-diff.tsx +0 -193
  62. package/src/diffs/widget-diff-performer.ts +0 -69
  63. package/src/diffs/widget-diff.tsx +0 -290
  64. package/src/editor-page.tsx +0 -325
  65. package/src/editor.tsx +0 -1099
  66. package/src/hint-editor.tsx +0 -469
  67. package/src/i18n.ts +0 -140
  68. package/src/iframe-content-renderer.tsx +0 -188
  69. package/src/index.ts +0 -30
  70. package/src/item-editor.tsx +0 -158
  71. package/src/item-extras-editor.tsx +0 -230
  72. package/src/katex-mhchem/index.js +0 -73
  73. package/src/katex-mhchem/parser.js +0 -2659
  74. package/src/multirenderer-editor.tsx +0 -1061
  75. package/src/stateful-article-editor.tsx +0 -173
  76. package/src/stateful-editor-page.tsx +0 -88
  77. package/src/styles/perseus-editor.less +0 -1321
  78. package/src/testing-widgets.ts +0 -11
  79. package/src/tex-error-view.tsx +0 -90
  80. package/src/util/points.test.ts +0 -24
  81. package/src/util/points.ts +0 -13
  82. package/src/util/register-all-widgets-and-editors-for-testing.test.ts +0 -17
  83. package/src/util/register-all-widgets-and-editors-for-testing.ts +0 -17
  84. package/src/version.ts +0 -10
  85. package/src/widgets/__stories__/categorizer-editor.stories.tsx +0 -24
  86. package/src/widgets/__stories__/definition-editor.stories.tsx +0 -18
  87. package/src/widgets/__stories__/dropdown-editor.stories.tsx +0 -18
  88. package/src/widgets/__stories__/explanation-editor.stories.tsx +0 -18
  89. package/src/widgets/__stories__/expression-editor.stories.tsx +0 -122
  90. package/src/widgets/__stories__/image-editor.stories.tsx +0 -72
  91. package/src/widgets/__stories__/input-number-editor.stories.tsx +0 -18
  92. package/src/widgets/__stories__/interaction-editor.stories.tsx +0 -37
  93. package/src/widgets/__stories__/label-image-editor.stories.tsx +0 -99
  94. package/src/widgets/__stories__/matcher-editor.stories.tsx +0 -18
  95. package/src/widgets/__stories__/number-line-editor.stories.tsx +0 -18
  96. package/src/widgets/__stories__/numeric-input-editor.stories.tsx +0 -18
  97. package/src/widgets/__stories__/radio-editor.stories.tsx +0 -116
  98. package/src/widgets/__stories__/sorter-editor.stories.tsx +0 -18
  99. package/src/widgets/__tests__/categorizer-editor.test.tsx +0 -51
  100. package/src/widgets/__tests__/definition-editor.test.tsx +0 -41
  101. package/src/widgets/__tests__/dropdown-editor.test.tsx +0 -57
  102. package/src/widgets/__tests__/explanation-editor.test.tsx +0 -59
  103. package/src/widgets/__tests__/expression-editor.test.tsx +0 -403
  104. package/src/widgets/__tests__/input-number-editor.test.tsx +0 -128
  105. package/src/widgets/__tests__/matcher-editor.test.tsx +0 -47
  106. package/src/widgets/__tests__/number-line-editor.test.tsx +0 -144
  107. package/src/widgets/__tests__/numeric-input-editor.test.tsx +0 -177
  108. package/src/widgets/__tests__/radio-editor.test.tsx +0 -118
  109. package/src/widgets/__tests__/sorter-editor.test.tsx +0 -55
  110. package/src/widgets/categorizer-editor.tsx +0 -104
  111. package/src/widgets/cs-program-editor.tsx +0 -256
  112. package/src/widgets/definition-editor.tsx +0 -77
  113. package/src/widgets/deprecated-standin-editor.tsx +0 -29
  114. package/src/widgets/dropdown-editor.tsx +0 -211
  115. package/src/widgets/example-graphie-widget-editor.tsx +0 -70
  116. package/src/widgets/example-graphie-widget.tsx +0 -172
  117. package/src/widgets/example-widget-editor.tsx +0 -62
  118. package/src/widgets/example-widget.tsx +0 -154
  119. package/src/widgets/explanation-editor.tsx +0 -92
  120. package/src/widgets/expression-editor.tsx +0 -557
  121. package/src/widgets/graded-group-editor.tsx +0 -161
  122. package/src/widgets/graded-group-set-editor.tsx +0 -104
  123. package/src/widgets/grapher-editor.tsx +0 -155
  124. package/src/widgets/group-editor.tsx +0 -83
  125. package/src/widgets/iframe-editor.tsx +0 -202
  126. package/src/widgets/image-editor.tsx +0 -367
  127. package/src/widgets/input-number-editor.tsx +0 -288
  128. package/src/widgets/interaction-editor/constraint-editor.tsx +0 -134
  129. package/src/widgets/interaction-editor/function-editor.tsx +0 -108
  130. package/src/widgets/interaction-editor/index.ts +0 -3
  131. package/src/widgets/interaction-editor/interaction-editor.tsx +0 -749
  132. package/src/widgets/interaction-editor/label-editor.tsx +0 -87
  133. package/src/widgets/interaction-editor/line-editor.tsx +0 -125
  134. package/src/widgets/interaction-editor/mathquill-input.tsx +0 -81
  135. package/src/widgets/interaction-editor/movable-line-editor.tsx +0 -121
  136. package/src/widgets/interaction-editor/movable-point-editor.tsx +0 -89
  137. package/src/widgets/interaction-editor/parametric-editor.tsx +0 -117
  138. package/src/widgets/interaction-editor/point-editor.tsx +0 -72
  139. package/src/widgets/interaction-editor/rectangle-editor.tsx +0 -96
  140. package/src/widgets/interactive-graph-editor.tsx +0 -571
  141. package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +0 -82
  142. package/src/widgets/label-image/__stories__/behavior.stories.tsx +0 -31
  143. package/src/widgets/label-image/__stories__/marker.stories.tsx +0 -75
  144. package/src/widgets/label-image/__stories__/question-markers.stories.tsx +0 -107
  145. package/src/widgets/label-image/__stories__/select-image.stories.tsx +0 -59
  146. package/src/widgets/label-image/answer-choices.tsx +0 -231
  147. package/src/widgets/label-image/behavior.tsx +0 -122
  148. package/src/widgets/label-image/marker.tsx +0 -290
  149. package/src/widgets/label-image/question-markers.tsx +0 -176
  150. package/src/widgets/label-image/select-image.tsx +0 -81
  151. package/src/widgets/label-image-editor.tsx +0 -252
  152. package/src/widgets/lights-puzzle-editor.tsx +0 -278
  153. package/src/widgets/matcher-editor.tsx +0 -149
  154. package/src/widgets/matrix-editor.tsx +0 -156
  155. package/src/widgets/measurer-editor.tsx +0 -253
  156. package/src/widgets/molecule-editor.tsx +0 -64
  157. package/src/widgets/number-line-editor.tsx +0 -512
  158. package/src/widgets/numeric-input-editor.tsx +0 -536
  159. package/src/widgets/orderer-editor.tsx +0 -172
  160. package/src/widgets/passage-editor.tsx +0 -117
  161. package/src/widgets/passage-ref-editor.tsx +0 -80
  162. package/src/widgets/passage-ref-target-editor.tsx +0 -49
  163. package/src/widgets/plotter-editor.tsx +0 -542
  164. package/src/widgets/radio/editor.tsx +0 -398
  165. package/src/widgets/reaction-diagram-editor.tsx +0 -131
  166. package/src/widgets/sequence-editor.tsx +0 -205
  167. package/src/widgets/simple-markdown-tester-editor.tsx +0 -86
  168. package/src/widgets/simple-markdown-tester.tsx +0 -92
  169. package/src/widgets/simulator-editor.tsx +0 -146
  170. package/src/widgets/sorter-editor.tsx +0 -103
  171. package/src/widgets/table-editor.tsx +0 -164
  172. package/src/widgets/unit-editor.tsx +0 -299
  173. package/src/widgets/video-editor.tsx +0 -73
  174. package/tsconfig-build.json +0 -22
  175. package/tsconfig-build.tsbuildinfo +0 -1
@@ -1,749 +0,0 @@
1
- /* eslint-disable @khanacademy/ts-no-error-suppressions */
2
- /* eslint-disable @babel/no-invalid-this, react/no-unsafe */
3
- import {
4
- Changeable,
5
- Dependencies,
6
- EditorJsonify,
7
- Util,
8
- ElementContainer,
9
- } from "@khanacademy/perseus";
10
- import * as React from "react";
11
- import _ from "underscore";
12
-
13
- import GraphSettings from "../../components/graph-settings";
14
-
15
- import FunctionEditor from "./function-editor";
16
- import LabelEditor from "./label-editor";
17
- import LineEditor from "./line-editor";
18
- import MovableLineEditor from "./movable-line-editor";
19
- import MovablePointEditor from "./movable-point-editor";
20
- import ParametricEditor from "./parametric-editor";
21
- import PointEditor from "./point-editor";
22
- import RectangleEditor from "./rectangle-editor";
23
-
24
- const {getDependencies} = Dependencies;
25
- const {unescapeMathMode} = Util;
26
-
27
- const defaultInteractionProps = {
28
- graph: {
29
- box: [400, 400],
30
- labels: ["x", "y"],
31
- range: [
32
- [-10, 10],
33
- [-10, 10],
34
- ],
35
- tickStep: [1, 1],
36
- gridStep: [1, 1],
37
- markings: "graph",
38
- },
39
- elements: [],
40
- } as const;
41
-
42
- type Graph = {
43
- box: ReadonlyArray<number>;
44
- labels: ReadonlyArray<string>;
45
- range: ReadonlyArray<ReadonlyArray<number>>;
46
- tickStep: ReadonlyArray<number>;
47
- gridStep: ReadonlyArray<number>;
48
- markings: string;
49
- valid?: boolean;
50
- };
51
-
52
- type Props = Changeable.ChangeableProps & {
53
- elements: ReadonlyArray<any>;
54
- graph: Graph;
55
- };
56
-
57
- type DefaultProps = {
58
- elements: Props["elements"];
59
- graph: Props["graph"];
60
- };
61
-
62
- type State = any;
63
-
64
- class InteractionEditor extends React.Component<Props, State> {
65
- static widgetName = "interaction" as const;
66
- static defaultProps: DefaultProps = defaultInteractionProps;
67
-
68
- state: State = {
69
- usedVarSubscripts: this._getAllVarSubscripts(this.props.elements),
70
- usedFunctionNames: this._getAllFunctionNames(this.props.elements),
71
- };
72
-
73
- UNSAFE_componentWillReceiveProps(nextProps: Props) {
74
- this.setState({
75
- usedVarSubscripts: this._getAllVarSubscripts(nextProps.elements),
76
- usedFunctionNames: this._getAllFunctionNames(nextProps.elements),
77
- });
78
- }
79
-
80
- _getAllVarSubscripts(elements: ReadonlyArray<any>): ReadonlyArray<any> {
81
- return _.map(
82
- _.where(elements, {type: "movable-point"}),
83
- (element) => element.options.varSubscript,
84
- )
85
- .concat(
86
- _.map(
87
- _.where(elements, {type: "movable-line"}),
88
- (element) => element.options.startSubscript,
89
- ),
90
- )
91
- .concat(
92
- _.map(
93
- _.where(elements, {type: "movable-line"}),
94
- (element) => element.options.endSubscript,
95
- ),
96
- );
97
- }
98
-
99
- _getAllFunctionNames(elements: ReadonlyArray<any>): ReadonlyArray<string> {
100
- return _.map(
101
- _.where(elements, {type: "function"}),
102
- (element) => element.options.funcName,
103
- );
104
- }
105
-
106
- _updateGraphProps: (arg1: any) => any = (newProps) => {
107
- // TODO(eater): GraphSettings should name this tickStep instead
108
- // of step. Grr..
109
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
110
- this.change({
111
- graph: _.extend(_.omit(newProps, "step"), {
112
- tickStep: newProps.step,
113
- }),
114
- });
115
- };
116
-
117
- _addNewElement: (arg1: React.ChangeEvent<HTMLInputElement>) => void = (
118
- e,
119
- ) => {
120
- const elementType = e.target.value;
121
- if (elementType === "") {
122
- return;
123
- }
124
- e.target.value = "";
125
- const newElement = {
126
- type: elementType,
127
- key:
128
- elementType +
129
- "-" +
130
- ((Math.random() * 0xffffff) << 0).toString(16),
131
- options:
132
- elementType === "point"
133
- ? _.clone(PointEditor.defaultProps)
134
- : elementType === "line"
135
- ? _.clone(LineEditor.defaultProps)
136
- : elementType === "movable-point"
137
- ? _.clone(MovablePointEditor.defaultProps)
138
- : elementType === "movable-line"
139
- ? _.clone(MovableLineEditor.defaultProps)
140
- : elementType === "function"
141
- ? _.clone(FunctionEditor.defaultProps)
142
- : elementType === "parametric"
143
- ? _.clone(ParametricEditor.defaultProps)
144
- : elementType === "label"
145
- ? _.clone(LabelEditor.defaultProps)
146
- : elementType === "rectangle"
147
- ? _.clone(RectangleEditor.defaultProps)
148
- : {},
149
- } as const;
150
-
151
- let nextSubscript;
152
- if (elementType === "movable-point") {
153
- nextSubscript =
154
- _.max([_.max(this.state.usedVarSubscripts), -1]) + 1;
155
- // @ts-expect-error - TS2339 - Property 'varSubscript' does not exist on type '{}'.
156
- newElement.options.varSubscript = nextSubscript;
157
- } else if (elementType === "movable-line") {
158
- nextSubscript =
159
- _.max([_.max(this.state.usedVarSubscripts), -1]) + 1;
160
- // @ts-expect-error - TS2339 - Property 'startSubscript' does not exist on type '{}'.
161
- newElement.options.startSubscript = nextSubscript;
162
- // @ts-expect-error - TS2339 - Property 'endSubscript' does not exist on type '{}'.
163
- newElement.options.endSubscript = nextSubscript + 1;
164
- } else if (elementType === "function") {
165
- // TODO(eater): The 22nd function added will be {(x) since '{'
166
- // comes after 'z'
167
- const nextLetter = String.fromCharCode(
168
- _.max([
169
- _.max(
170
- _.map(this.state.usedFunctionNames, function (c) {
171
- return c.charCodeAt(0);
172
- }),
173
- ),
174
- "e".charCodeAt(0),
175
- ]) + 1,
176
- );
177
- // @ts-expect-error - TS2339 - Property 'funcName' does not exist on type '{}'.
178
- newElement.options.funcName = nextLetter;
179
- }
180
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
181
- this.change({
182
- elements: this.props.elements.concat(newElement),
183
- });
184
- };
185
-
186
- _deleteElement: (arg1: number) => void = (index) => {
187
- const element = this.props.elements[index];
188
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
189
- this.change({elements: _.without(this.props.elements, element)});
190
- };
191
-
192
- _moveElementUp: (arg1: number) => void = (index) => {
193
- const element = this.props.elements[index];
194
- const newElements = _.without(this.props.elements, element);
195
- newElements.splice(index - 1, 0, element);
196
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
197
- this.change({elements: newElements});
198
- };
199
-
200
- _moveElementDown: (arg1: number) => void = (index) => {
201
- const element = this.props.elements[index];
202
- const newElements = _.without(this.props.elements, element);
203
- newElements.splice(index + 1, 0, element);
204
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
205
- this.change({elements: newElements});
206
- };
207
-
208
- change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
209
- return Changeable.change.apply(this, args);
210
- };
211
-
212
- serialize: () => any = () => {
213
- return EditorJsonify.serialize.call(this);
214
- };
215
-
216
- render(): React.ReactNode {
217
- const {TeX} = getDependencies();
218
-
219
- return (
220
- <div className="perseus-widget-interaction-editor">
221
- {/* @ts-expect-error - TS2322 - Type '{ children: (false | Element)[]; title: string; }' is not assignable to type 'Pick<Readonly<ElementContainerProps> & Readonly<{ children?: ReactNode; }>, "children" | "onDelete" | "onDown" | "onUp">'. */}
222
- <ElementContainer title="Grid settings">
223
- <GraphSettings
224
- editableSettings={["canvas", "graph"]}
225
- box={this.props.graph.box}
226
- labels={this.props.graph.labels}
227
- range={this.props.graph.range}
228
- step={this.props.graph.tickStep}
229
- gridStep={this.props.graph.gridStep}
230
- markings={this.props.graph.markings}
231
- onChange={this._updateGraphProps}
232
- />
233
- {this.props.graph.valid !== true && (
234
- <div>{this.props.graph.valid}</div>
235
- )}
236
- </ElementContainer>
237
- {_.map(
238
- this.props.elements,
239
- function (element, n) {
240
- if (element.type === "movable-point") {
241
- return (
242
- <ElementContainer
243
- title={
244
- <span>
245
- Movable point{" "}
246
- <TeX>
247
- {"(x_{" +
248
- element.options
249
- .varSubscript +
250
- "}, y_{" +
251
- element.options
252
- .varSubscript +
253
- "})"}
254
- </TeX>
255
- </span>
256
- }
257
- // eslint-disable-next-line react/jsx-no-bind
258
- onUp={
259
- n === 0
260
- ? null
261
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
262
- this._moveElementUp.bind(this, n)
263
- }
264
- // eslint-disable-next-line react/jsx-no-bind
265
- onDown={
266
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
267
- n === this.props.elements.length - 1
268
- ? null
269
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
270
- this._moveElementDown.bind(
271
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
272
- this,
273
- n,
274
- )
275
- }
276
- // eslint-disable-next-line react/jsx-no-bind
277
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
278
- onDelete={this._deleteElement.bind(this, n)}
279
- key={element.key}
280
- >
281
- <MovablePointEditor
282
- {...element.options}
283
- onChange={(newProps) => {
284
- const elements = JSON.parse(
285
- JSON.stringify(
286
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
287
- this.props.elements,
288
- ),
289
- );
290
- _.extend(
291
- elements[n].options,
292
- newProps,
293
- );
294
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
295
- this.change({elements: elements});
296
- }}
297
- />
298
- </ElementContainer>
299
- );
300
- }
301
- if (element.type === "movable-line") {
302
- return (
303
- <ElementContainer
304
- title={
305
- <span>
306
- Movable line{" "}
307
- <TeX>
308
- {"(x_{" +
309
- element.options
310
- .startSubscript +
311
- "}, y_{" +
312
- element.options
313
- .startSubscript +
314
- "})"}
315
- </TeX>{" "}
316
- to{" "}
317
- <TeX>
318
- {"(x_{" +
319
- element.options
320
- .endSubscript +
321
- "}, y_{" +
322
- element.options
323
- .endSubscript +
324
- "})"}
325
- </TeX>
326
- </span>
327
- }
328
- // eslint-disable-next-line react/jsx-no-bind
329
- onUp={
330
- n === 0
331
- ? null
332
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
333
- this._moveElementUp.bind(this, n)
334
- }
335
- // eslint-disable-next-line react/jsx-no-bind
336
- onDown={
337
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
338
- n === this.props.elements.length - 1
339
- ? null
340
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
341
- this._moveElementDown.bind(
342
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
343
- this,
344
- n,
345
- )
346
- }
347
- // eslint-disable-next-line react/jsx-no-bind
348
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
349
- onDelete={this._deleteElement.bind(this, n)}
350
- key={element.key}
351
- >
352
- <MovableLineEditor
353
- {...element.options}
354
- onChange={(newProps) => {
355
- const elements = JSON.parse(
356
- JSON.stringify(
357
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
358
- this.props.elements,
359
- ),
360
- );
361
- _.extend(
362
- elements[n].options,
363
- newProps,
364
- );
365
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
366
- this.change({elements: elements});
367
- }}
368
- />
369
- </ElementContainer>
370
- );
371
- }
372
- if (element.type === "point") {
373
- return (
374
- <ElementContainer
375
- title={
376
- <span>
377
- Point{" "}
378
- <TeX>
379
- {"(" +
380
- element.options.coordX +
381
- ", " +
382
- element.options.coordY +
383
- ")"}
384
- </TeX>
385
- </span>
386
- }
387
- // eslint-disable-next-line react/jsx-no-bind
388
- onUp={
389
- n === 0
390
- ? null
391
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
392
- this._moveElementUp.bind(this, n)
393
- }
394
- // eslint-disable-next-line react/jsx-no-bind
395
- onDown={
396
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
397
- n === this.props.elements.length - 1
398
- ? null
399
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
400
- this._moveElementDown.bind(
401
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
402
- this,
403
- n,
404
- )
405
- }
406
- // eslint-disable-next-line react/jsx-no-bind
407
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
408
- onDelete={this._deleteElement.bind(this, n)}
409
- key={element.key}
410
- >
411
- <PointEditor
412
- {...element.options}
413
- onChange={(newProps) => {
414
- const elements = JSON.parse(
415
- JSON.stringify(
416
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
417
- this.props.elements,
418
- ),
419
- );
420
- _.extend(
421
- elements[n].options,
422
- newProps,
423
- );
424
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
425
- this.change({elements: elements});
426
- }}
427
- />
428
- </ElementContainer>
429
- );
430
- }
431
- if (element.type === "line") {
432
- return (
433
- <ElementContainer
434
- title={
435
- <span>
436
- Line{" "}
437
- <TeX>
438
- {"(" +
439
- element.options.startX +
440
- ", " +
441
- element.options.startY +
442
- ")"}
443
- </TeX>{" "}
444
- to{" "}
445
- <TeX>
446
- {"(" +
447
- element.options.endX +
448
- ", " +
449
- element.options.endY +
450
- ")"}
451
- </TeX>
452
- </span>
453
- }
454
- // eslint-disable-next-line react/jsx-no-bind
455
- onUp={
456
- n === 0
457
- ? null
458
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
459
- this._moveElementUp.bind(this, n)
460
- }
461
- // eslint-disable-next-line react/jsx-no-bind
462
- onDown={
463
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
464
- n === this.props.elements.length - 1
465
- ? null
466
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
467
- this._moveElementDown.bind(
468
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
469
- this,
470
- n,
471
- )
472
- }
473
- // eslint-disable-next-line react/jsx-no-bind
474
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
475
- onDelete={this._deleteElement.bind(this, n)}
476
- key={element.key}
477
- >
478
- <LineEditor
479
- {...element.options}
480
- onChange={(newProps) => {
481
- const elements = JSON.parse(
482
- JSON.stringify(
483
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
484
- this.props.elements,
485
- ),
486
- );
487
- _.extend(
488
- elements[n].options,
489
- newProps,
490
- );
491
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
492
- this.change({elements: elements});
493
- }}
494
- />
495
- </ElementContainer>
496
- );
497
- }
498
- if (element.type === "function") {
499
- return (
500
- <ElementContainer
501
- title={
502
- <span>
503
- Function{" "}
504
- <TeX>
505
- {element.options.funcName +
506
- "(x) = " +
507
- element.options.value}
508
- </TeX>
509
- </span>
510
- }
511
- // eslint-disable-next-line react/jsx-no-bind
512
- onUp={
513
- n === 0
514
- ? null
515
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
516
- this._moveElementUp.bind(this, n)
517
- }
518
- // eslint-disable-next-line react/jsx-no-bind
519
- onDown={
520
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
521
- n === this.props.elements.length - 1
522
- ? null
523
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
524
- this._moveElementDown.bind(
525
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
526
- this,
527
- n,
528
- )
529
- }
530
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
531
- onDelete={this._deleteElement}
532
- key={element.key}
533
- >
534
- <FunctionEditor
535
- {...element.options}
536
- onChange={(newProps) => {
537
- const elements = JSON.parse(
538
- JSON.stringify(
539
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
540
- this.props.elements,
541
- ),
542
- );
543
- _.extend(
544
- elements[n].options,
545
- newProps,
546
- );
547
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
548
- this.change({elements: elements});
549
- }}
550
- />
551
- </ElementContainer>
552
- );
553
- }
554
- if (element.type === "parametric") {
555
- return (
556
- <ElementContainer
557
- title={<span>Parametric</span>}
558
- // eslint-disable-next-line react/jsx-no-bind
559
- onUp={
560
- n === 0
561
- ? null
562
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
563
- this._moveElementUp.bind(this, n)
564
- }
565
- // eslint-disable-next-line react/jsx-no-bind
566
- onDown={
567
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
568
- n === this.props.elements.length - 1
569
- ? null
570
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
571
- this._moveElementDown.bind(
572
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
573
- this,
574
- n,
575
- )
576
- }
577
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
578
- onDelete={this._deleteElement}
579
- key={element.key}
580
- >
581
- <ParametricEditor
582
- {...element.options}
583
- onChange={(newProps) => {
584
- const elements = JSON.parse(
585
- JSON.stringify(
586
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
587
- this.props.elements,
588
- ),
589
- );
590
- _.extend(
591
- elements[n].options,
592
- newProps,
593
- );
594
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
595
- this.change({elements: elements});
596
- }}
597
- />
598
- </ElementContainer>
599
- );
600
- }
601
- if (element.type === "label") {
602
- return (
603
- <ElementContainer
604
- title={
605
- <span>
606
- Label{" "}
607
- <TeX>
608
- {unescapeMathMode(
609
- element.options.label,
610
- )}
611
- </TeX>{" "}
612
- </span>
613
- }
614
- // eslint-disable-next-line react/jsx-no-bind
615
- onUp={
616
- n === 0
617
- ? null
618
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
619
- this._moveElementUp.bind(this, n)
620
- }
621
- // eslint-disable-next-line react/jsx-no-bind
622
- onDown={
623
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
624
- n === this.props.elements.length - 1
625
- ? null
626
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
627
- this._moveElementDown.bind(
628
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
629
- this,
630
- n,
631
- )
632
- }
633
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
634
- onDelete={this._deleteElement}
635
- key={element.key}
636
- >
637
- <LabelEditor
638
- {...element.options}
639
- onChange={(newProps) => {
640
- const elements = JSON.parse(
641
- JSON.stringify(
642
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
643
- this.props.elements,
644
- ),
645
- );
646
- _.extend(
647
- elements[n].options,
648
- newProps,
649
- );
650
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
651
- this.change({elements: elements});
652
- }}
653
- />
654
- </ElementContainer>
655
- );
656
- }
657
- if (element.type === "rectangle") {
658
- return (
659
- <ElementContainer
660
- title={
661
- <span>
662
- Rectangle{" "}
663
- <TeX>
664
- {"(" +
665
- element.options.coordX +
666
- ", " +
667
- element.options.coordY +
668
- ")"}
669
- </TeX>
670
- &nbsp;&mdash;&nbsp;
671
- <TeX>
672
- {element.options.width +
673
- " \\times " +
674
- element.options.height}
675
- </TeX>
676
- </span>
677
- }
678
- // eslint-disable-next-line react/jsx-no-bind
679
- onUp={
680
- n === 0
681
- ? null
682
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation. | TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
683
- this._moveElementUp.bind(this, n)
684
- }
685
- // eslint-disable-next-line react/jsx-no-bind
686
- onDown={
687
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
688
- n === this.props.elements.length - 1
689
- ? null
690
- : // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
691
- this._moveElementDown.bind(
692
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
693
- this,
694
- n,
695
- )
696
- }
697
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
698
- onDelete={this._deleteElement}
699
- key={element.key}
700
- >
701
- <RectangleEditor
702
- {...element.options}
703
- onChange={(newProps) => {
704
- const elements = JSON.parse(
705
- JSON.stringify(
706
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
707
- this.props.elements,
708
- ),
709
- );
710
- _.extend(
711
- elements[n].options,
712
- newProps,
713
- );
714
- // @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
715
- this.change({elements: elements});
716
- }}
717
- />
718
- </ElementContainer>
719
- );
720
- }
721
- },
722
- this,
723
- )}
724
- <div className="perseus-widget-interaction-editor-select-element">
725
- {/* @ts-expect-error - TS2322 - Type '(arg1: ChangeEvent<HTMLInputElement>) => void' is not assignable to type 'ChangeEventHandler<HTMLSelectElement>'. */}
726
- <select onChange={this._addNewElement}>
727
- <option value="">Add an element{"\u2026"}</option>
728
- <option disabled>--</option>
729
- <option value="point">Point</option>
730
- <option value="line">Line segment</option>
731
- <option value="function">Function plot</option>
732
- <option value="parametric">Parametric plot</option>
733
- <option value="label">Label</option>
734
- <option value="rectangle">Rectangle</option>
735
- <option value="movable-point">
736
- &#x2605; Movable point
737
- </option>
738
- <option value="movable-line">
739
- &#x2605; Movable line segment
740
- </option>
741
- </select>
742
- </div>
743
- </div>
744
- );
745
- /* eslint-enable max-len */
746
- }
747
- }
748
-
749
- export default InteractionEditor;