@khanacademy/perseus-editor 4.1.5 → 4.1.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 (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,172 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars, react/forbid-prop-types, react/sort-comp */
2
- /**
3
- * This is an example graphie-using widget
4
- *
5
- * TODO(jack): Add more comments
6
- */
7
-
8
- import {number as knumber, point as kpoint} from "@khanacademy/kmath";
9
- import {
10
- components,
11
- ApiOptions,
12
- Changeable,
13
- Util,
14
- WidgetJsonifyDeprecated,
15
- } from "@khanacademy/perseus";
16
- import PropTypes from "prop-types";
17
- import * as React from "react";
18
- import _ from "underscore";
19
-
20
- import type {Coord, WidgetExports} from "@khanacademy/perseus";
21
-
22
- const {Graphie} = components;
23
-
24
- // @ts-expect-error - TS2339 - Property 'MovablePoint' does not exist on type 'typeof Graphie'.
25
- const MovablePoint = Graphie.MovablePoint;
26
-
27
- type Props = any;
28
-
29
- /**
30
- * This is the widget's renderer. It shows up in the right column
31
- * in the demo, and is what is visible to users, and where
32
- * users enter their answers.
33
- */
34
- class ExampleGraphieWidget extends React.Component<Props> {
35
- static propTypes = {
36
- ...Changeable.propTypes,
37
- apiOptions: ApiOptions.propTypes,
38
-
39
- graph: PropTypes.object.isRequired,
40
- coord: PropTypes.arrayOf(PropTypes.number),
41
- };
42
-
43
- static defaultProps: Props = {
44
- // We want to allow our coord to be null to test if the
45
- // user has interacted with this widget yet when grading it
46
- coord: null,
47
- graph: {
48
- box: [400, 400],
49
- labels: ["x", "y"],
50
- range: [
51
- [-10, 10],
52
- [-10, 10],
53
- ],
54
- step: [1, 1],
55
- gridStep: [1, 1],
56
- valid: true,
57
- backgroundImage: null,
58
- markings: "grid",
59
- showProtractor: false,
60
- },
61
- };
62
-
63
- /**
64
- * This is the widget's grading function
65
- */
66
- static validate(state: any, rubric: any): any {
67
- if (state.coord == null) {
68
- return {
69
- type: "invalid",
70
- message: null,
71
- };
72
- }
73
- if (kpoint.equal(state.coord, rubric.correct)) {
74
- return {
75
- type: "points",
76
- earned: 1,
77
- total: 1,
78
- message: null,
79
- };
80
- }
81
- return {
82
- type: "points",
83
- earned: 0,
84
- total: 1,
85
- message: null,
86
- };
87
- }
88
-
89
- getUserInput: () => any = () => {
90
- return WidgetJsonifyDeprecated.getUserInput.call(this);
91
- };
92
-
93
- render(): React.ReactNode {
94
- return (
95
- <Graphie
96
- // eslint-disable-next-line react/no-string-refs
97
- ref="graphie"
98
- box={this.props.graph.box}
99
- range={this.props.graph.range}
100
- options={this.props.graph}
101
- setup={this.setupGraphie}
102
- setDrawingAreaAvailable={
103
- this.props.apiOptions.setDrawingAreaAvailable
104
- }
105
- >
106
- <MovablePoint
107
- pointSize={5}
108
- coord={this.props.coord || [0, 0]}
109
- constraints={[
110
- MovablePoint.constraints.snap(),
111
- MovablePoint.constraints.bound(),
112
- ]}
113
- onMove={this.movePoint}
114
- />
115
- </Graphie>
116
- );
117
- }
118
-
119
- change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
120
- return Changeable.change.apply(this, args);
121
- };
122
-
123
- movePoint: (arg1: Coord) => void = (newCoord) => {
124
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
125
- this.change({
126
- coord: newCoord,
127
- });
128
- };
129
-
130
- _getGridConfig: (arg1: any) => any = (options) => {
131
- return _.map(options.step, function (step, i) {
132
- return Util.gridDimensionConfig(
133
- step,
134
- options.range[i],
135
- options.box[i],
136
- options.gridStep[i],
137
- );
138
- });
139
- };
140
-
141
- setupGraphie: (arg1: any, arg2: any) => any = (graphie, options) => {
142
- const gridConfig = this._getGridConfig(options);
143
- graphie.graphInit({
144
- range: options.range,
145
- scale: _.pluck(gridConfig, "scale"),
146
- axisArrows: "<->",
147
- labelFormat: function (s) {
148
- return "\\small{" + s + "}";
149
- },
150
- gridStep: options.gridStep,
151
- tickStep: _.pluck(gridConfig, "tickStep"),
152
- labelStep: 1,
153
- unityLabels: _.pluck(gridConfig, "unityLabel"),
154
- });
155
- graphie.label([0, options.range[1][1]], options.labels[1], "above");
156
- };
157
-
158
- simpleValidate: (arg1: any) => any = (rubric) => {
159
- return ExampleGraphieWidget.validate(this.getUserInput(), rubric);
160
- };
161
- }
162
-
163
- /**
164
- * For this widget to work, we must export it.
165
- * We also must import this file in src/all-widgets.js
166
- */
167
- export default {
168
- name: "example-graphie-widget",
169
- displayName: "Example Graphie Widget",
170
- hidden: true, // Hides this widget from the Perseus.Editor widget select
171
- widget: ExampleGraphieWidget,
172
- } as WidgetExports<typeof ExampleGraphieWidget>;
@@ -1,62 +0,0 @@
1
- /* eslint-disable react/sort-comp */
2
- import {Changeable, EditorJsonify} from "@khanacademy/perseus";
3
- import * as React from "react";
4
-
5
- type Props = any;
6
-
7
- /**
8
- * This is the widget's editor. This is what shows up on the left side
9
- * of the screen in the demo. Only the question writer sees this.
10
- */
11
- class ExampleWidgetEditor extends React.Component<Props> {
12
- static propTypes = {
13
- ...Changeable.propTypes,
14
- };
15
-
16
- static widgetName = "example-widget" as const;
17
-
18
- static defaultProps: Props = {
19
- correct: "",
20
- };
21
-
22
- input = React.createRef<HTMLInputElement>();
23
-
24
- handleAnswerChange: (arg1: React.ChangeEvent<HTMLInputElement>) => void = (
25
- event,
26
- ) => {
27
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
28
- this.change({
29
- correct: event.target.value,
30
- });
31
- };
32
-
33
- render(): React.ReactNode {
34
- return (
35
- <div>
36
- <label>
37
- Correct answer:
38
- <input
39
- value={this.props.correct}
40
- onChange={this.handleAnswerChange}
41
- ref={this.input}
42
- />
43
- </label>
44
- </div>
45
- );
46
- }
47
-
48
- change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
49
- return Changeable.change.apply(this, args);
50
- };
51
-
52
- focus: () => boolean = () => {
53
- this.input.current?.focus();
54
- return true;
55
- };
56
-
57
- serialize: () => any = () => {
58
- return EditorJsonify.serialize.call(this);
59
- };
60
- }
61
-
62
- export default ExampleWidgetEditor;
@@ -1,154 +0,0 @@
1
- /* eslint-disable @khanacademy/ts-no-error-suppressions */
2
- /* eslint-disable react/sort-comp */
3
- /**
4
- * This is a simple number-entry widget
5
- * It is not as powerful as number-input, but has a simpler, more
6
- * representative structure as an example widget, and is easier to
7
- * test new ideas on.
8
- *
9
- * TODO(jack): Add more comments
10
- */
11
- import {Changeable} from "@khanacademy/perseus";
12
- import PropTypes from "prop-types";
13
- import * as React from "react";
14
- import _ from "underscore";
15
-
16
- import type {WidgetExports} from "@khanacademy/perseus";
17
-
18
- class TextInput extends React.Component<any> {
19
- input = React.createRef<HTMLInputElement>();
20
-
21
- render(): React.ReactNode {
22
- return (
23
- <input
24
- ref={this.input}
25
- value={this.props.value || ""}
26
- onChange={this.changeValue}
27
- />
28
- );
29
- }
30
-
31
- focus = () => {
32
- this.input.current?.focus();
33
- return true;
34
- };
35
-
36
- changeValue = (e: any) => {
37
- // Translating from the js event e to the value
38
- // of the textbox to send to onChange
39
- this.props.onChange(e.target.value);
40
- };
41
- }
42
-
43
- /**
44
- * This is the widget's renderer. It shows up in the right column
45
- * in the demo, and is what is visible to users, and where
46
- * users enter their answers.
47
- */
48
- class ExampleWidget extends React.Component<any> {
49
- static propTypes = {
50
- ...Changeable.propTypes,
51
- value: PropTypes.string,
52
- };
53
-
54
- static defaultProps: any = {
55
- value: "",
56
- };
57
-
58
- input = React.createRef<TextInput>();
59
-
60
- /**
61
- * This is the widget's grading function. simpleValidate generally
62
- * defers to this function.
63
- *
64
- * value is usually the result of getUserInput on the widget
65
- * rubric is the result of calling serialize() on the editor
66
- */
67
- static validate(value: string, rubric: any): any {
68
- if (value === "") {
69
- return {
70
- type: "invalid",
71
- message:
72
- "It looks like you haven't answered all of the " +
73
- "question yet.",
74
- };
75
- }
76
- if (value === rubric.correct) {
77
- return {
78
- type: "points",
79
- earned: 1,
80
- total: 1,
81
- message: null,
82
- };
83
- }
84
- return {
85
- type: "points",
86
- earned: 0,
87
- total: 1,
88
- message: null,
89
- };
90
- }
91
-
92
- /**
93
- * Tell our parent to update our props.
94
- */
95
- change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
96
- return Changeable.change.apply(this, args);
97
- };
98
-
99
- render(): React.ReactNode {
100
- return (
101
- <TextInput
102
- ref={this.input}
103
- value={this.props.value}
104
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
105
- onChange={this.change("value")}
106
- />
107
- );
108
- }
109
-
110
- getUserInput: () => string = () => {
111
- return this.props.value;
112
- };
113
-
114
- /**
115
- * Widgets that are focusable should add a focus method that returns
116
- * true if focusing succeeded. The first such widget found will be
117
- * focused on page load.
118
- */
119
- focus: () => boolean = () => {
120
- this.input.current?.focus();
121
- return true;
122
- };
123
-
124
- /**
125
- * simpleValidate is called for grading. Rubric is the result of calling
126
- * getUserInput() on the editor that created this widget.
127
- *
128
- * Should return an object representing the grading result, such as
129
- * {
130
- * type: "points",
131
- * earned: 1,
132
- * total: 1,
133
- * message: null
134
- * }
135
- */
136
- simpleValidate: (arg1: any) => any = (rubric) => {
137
- return ExampleWidget.validate(this.getUserInput(), rubric);
138
- };
139
- }
140
-
141
- /**
142
- * For this widget to work, we must import this file in src/all-widgets.js
143
- */
144
- export default {
145
- name: "example-widget",
146
- displayName: "Example Widget",
147
-
148
- // Tell the renderer what type of `display:` style we would like
149
- // for the component wrapping this one.
150
- defaultAlignment: "inline-block",
151
-
152
- hidden: true, // Hides this widget from the Perseus.Editor widget select
153
- widget: ExampleWidget,
154
- } as WidgetExports<typeof ExampleWidget>;
@@ -1,92 +0,0 @@
1
- /* eslint-disable @khanacademy/ts-no-error-suppressions */
2
- /* eslint-disable react/forbid-prop-types */
3
- import {components, Changeable, EditorJsonify} from "@khanacademy/perseus";
4
- import PropTypes from "prop-types";
5
- import * as React from "react";
6
- import _ from "underscore";
7
-
8
- import Editor from "../editor";
9
-
10
- const {TextInput} = components;
11
-
12
- const defaultExplanationProps = {
13
- showPrompt: "Explain",
14
- hidePrompt: "Hide explanation",
15
- explanation: "explanation goes here\n\nmore explanation",
16
- widgets: {},
17
- } as const;
18
-
19
- type Props = any;
20
- type State = any;
21
-
22
- class ExplanationEditor extends React.Component<Props, State> {
23
- static propTypes = {
24
- ...Changeable.propTypes,
25
- showPrompt: PropTypes.string,
26
- hidePrompt: PropTypes.string,
27
- explanation: PropTypes.string,
28
- widgets: PropTypes.object,
29
- apiOptions: PropTypes.any,
30
- };
31
-
32
- static widgetName = "explanation" as const;
33
- static defaultProps: Props = defaultExplanationProps;
34
- state: State = {};
35
-
36
- change: (arg1: any, arg2: any, arg3: any) => any = (...args) => {
37
- return Changeable.change.apply(this, args);
38
- };
39
-
40
- serialize: () => any = () => {
41
- return EditorJsonify.serialize.call(this);
42
- };
43
-
44
- render(): React.ReactNode {
45
- return (
46
- <div className="perseus-widget-explanation-editor">
47
- <div className="perseus-widget-row">
48
- <label>
49
- Prompt to show explanation:{" "}
50
- <TextInput
51
- value={this.props.showPrompt}
52
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
53
- onChange={this.change("showPrompt")}
54
- />
55
- </label>
56
- </div>
57
- <div className="perseus-widget-row">
58
- <label>
59
- Prompt to hide explanation:{" "}
60
- <TextInput
61
- value={this.props.hidePrompt}
62
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
63
- onChange={this.change("hidePrompt")}
64
- />
65
- </label>
66
- </div>
67
- <div className="perseus-widget-row">
68
- <Editor
69
- apiOptions={this.props.apiOptions}
70
- content={this.props.explanation}
71
- widgets={this.props.widgets}
72
- widgetEnabled={true}
73
- immutableWidgets={false}
74
- onChange={(props) => {
75
- const newProps: Record<string, any> = {};
76
- if (_.has(props, "content")) {
77
- newProps.explanation = props.content;
78
- }
79
- if (_.has(props, "widgets")) {
80
- newProps.widgets = props.widgets;
81
- }
82
- // @ts-expect-error - TS2554 - Expected 3 arguments, but got 1.
83
- this.change(newProps);
84
- }}
85
- />
86
- </div>
87
- </div>
88
- );
89
- }
90
- }
91
-
92
- export default ExplanationEditor;