@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.
- package/dist/es/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +9 -6
- package/.babelrc.js +0 -8
- package/.eslintrc.js +0 -12
- package/CHANGELOG.md +0 -1155
- package/src/README.md +0 -7
- package/src/__stories__/editor-page.stories.tsx +0 -65
- package/src/__stories__/editor.stories.tsx +0 -134
- package/src/__stories__/item-editor.stories.tsx +0 -41
- package/src/__stories__/tex-error-view.stories.tsx +0 -26
- package/src/__testdata__/input-number.testdata.ts +0 -27
- package/src/__tests__/editor.test.tsx +0 -142
- package/src/__tests__/hint-editor.test.tsx +0 -83
- package/src/__tests__/i18n.test.ts +0 -501
- package/src/__tests__/integration.test.ts +0 -5
- package/src/__tests__/item-extras-editor.test.tsx +0 -85
- package/src/__tests__/traversal.test.ts +0 -377
- package/src/all-editors.test.ts +0 -16
- package/src/all-editors.ts +0 -83
- package/src/all-widgets.ts +0 -7
- package/src/article-editor.tsx +0 -438
- package/src/components/__stories__/blur-input.stories.tsx +0 -22
- package/src/components/__stories__/section-control-button.stories.tsx +0 -26
- package/src/components/__tests__/blur-input.test.tsx +0 -67
- package/src/components/blur-input.tsx +0 -69
- package/src/components/checkbox.tsx +0 -194
- package/src/components/device-framer.tsx +0 -90
- package/src/components/drag-target.tsx +0 -87
- package/src/components/dropdown-option.tsx +0 -311
- package/src/components/form-wrapped-text-field.tsx +0 -245
- package/src/components/graph-points-count-selector.tsx +0 -31
- package/src/components/graph-settings.tsx +0 -627
- package/src/components/graph-type-selector.tsx +0 -31
- package/src/components/hover-behavior.ts +0 -177
- package/src/components/json-editor.tsx +0 -121
- package/src/components/link.ts +0 -173
- package/src/components/section-control-button.tsx +0 -53
- package/src/components/segment-count-selector.tsx +0 -27
- package/src/components/simple-button.tsx +0 -85
- package/src/components/sortable.tsx +0 -187
- package/src/components/util.ts +0 -38
- package/src/components/viewport-resizer.tsx +0 -72
- package/src/components/widget-editor.tsx +0 -222
- package/src/components/widget-select.tsx +0 -48
- package/src/diffs/__stories__/perseus-diff-wrapper.tsx +0 -11
- package/src/diffs/__stories__/structured-item-diff.stories.tsx +0 -855
- package/src/diffs/__stories__/tags-diff.stories.tsx +0 -36
- package/src/diffs/__stories__/text-diff.stories.tsx +0 -35
- package/src/diffs/__tests__/split-diff.test.ts +0 -33
- package/src/diffs/__tests__/string-array-diff.test.ts +0 -73
- package/src/diffs/__tests__/structured-item-diff.test.ts +0 -433
- package/src/diffs/__tests__/widget-diff-performer.test.ts +0 -43
- package/src/diffs/article-diff.tsx +0 -69
- package/src/diffs/item-diff.tsx +0 -76
- package/src/diffs/renderer-diff.tsx +0 -137
- package/src/diffs/split-diff.ts +0 -31
- package/src/diffs/string-array-diff.ts +0 -74
- package/src/diffs/structured-item-diff.tsx +0 -275
- package/src/diffs/tags-diff.tsx +0 -49
- package/src/diffs/text-diff.tsx +0 -193
- package/src/diffs/widget-diff-performer.ts +0 -69
- package/src/diffs/widget-diff.tsx +0 -290
- package/src/editor-page.tsx +0 -325
- package/src/editor.tsx +0 -1099
- package/src/hint-editor.tsx +0 -469
- package/src/i18n.ts +0 -140
- package/src/iframe-content-renderer.tsx +0 -188
- package/src/index.ts +0 -30
- package/src/item-editor.tsx +0 -158
- package/src/item-extras-editor.tsx +0 -230
- package/src/katex-mhchem/index.js +0 -73
- package/src/katex-mhchem/parser.js +0 -2659
- package/src/multirenderer-editor.tsx +0 -1061
- package/src/stateful-article-editor.tsx +0 -173
- package/src/stateful-editor-page.tsx +0 -88
- package/src/styles/perseus-editor.less +0 -1321
- package/src/testing-widgets.ts +0 -11
- package/src/tex-error-view.tsx +0 -90
- package/src/util/points.test.ts +0 -24
- package/src/util/points.ts +0 -13
- package/src/util/register-all-widgets-and-editors-for-testing.test.ts +0 -17
- package/src/util/register-all-widgets-and-editors-for-testing.ts +0 -17
- package/src/version.ts +0 -10
- package/src/widgets/__stories__/categorizer-editor.stories.tsx +0 -24
- package/src/widgets/__stories__/definition-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/dropdown-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/explanation-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/expression-editor.stories.tsx +0 -122
- package/src/widgets/__stories__/image-editor.stories.tsx +0 -72
- package/src/widgets/__stories__/input-number-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/interaction-editor.stories.tsx +0 -37
- package/src/widgets/__stories__/label-image-editor.stories.tsx +0 -99
- package/src/widgets/__stories__/matcher-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/number-line-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/numeric-input-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/radio-editor.stories.tsx +0 -116
- package/src/widgets/__stories__/sorter-editor.stories.tsx +0 -18
- package/src/widgets/__tests__/categorizer-editor.test.tsx +0 -51
- package/src/widgets/__tests__/definition-editor.test.tsx +0 -41
- package/src/widgets/__tests__/dropdown-editor.test.tsx +0 -57
- package/src/widgets/__tests__/explanation-editor.test.tsx +0 -59
- package/src/widgets/__tests__/expression-editor.test.tsx +0 -403
- package/src/widgets/__tests__/input-number-editor.test.tsx +0 -128
- package/src/widgets/__tests__/matcher-editor.test.tsx +0 -47
- package/src/widgets/__tests__/number-line-editor.test.tsx +0 -144
- package/src/widgets/__tests__/numeric-input-editor.test.tsx +0 -177
- package/src/widgets/__tests__/radio-editor.test.tsx +0 -118
- package/src/widgets/__tests__/sorter-editor.test.tsx +0 -55
- package/src/widgets/categorizer-editor.tsx +0 -104
- package/src/widgets/cs-program-editor.tsx +0 -256
- package/src/widgets/definition-editor.tsx +0 -77
- package/src/widgets/deprecated-standin-editor.tsx +0 -29
- package/src/widgets/dropdown-editor.tsx +0 -211
- package/src/widgets/example-graphie-widget-editor.tsx +0 -70
- package/src/widgets/example-graphie-widget.tsx +0 -172
- package/src/widgets/example-widget-editor.tsx +0 -62
- package/src/widgets/example-widget.tsx +0 -154
- package/src/widgets/explanation-editor.tsx +0 -92
- package/src/widgets/expression-editor.tsx +0 -557
- package/src/widgets/graded-group-editor.tsx +0 -161
- package/src/widgets/graded-group-set-editor.tsx +0 -104
- package/src/widgets/grapher-editor.tsx +0 -155
- package/src/widgets/group-editor.tsx +0 -83
- package/src/widgets/iframe-editor.tsx +0 -202
- package/src/widgets/image-editor.tsx +0 -367
- package/src/widgets/input-number-editor.tsx +0 -288
- package/src/widgets/interaction-editor/constraint-editor.tsx +0 -134
- package/src/widgets/interaction-editor/function-editor.tsx +0 -108
- package/src/widgets/interaction-editor/index.ts +0 -3
- package/src/widgets/interaction-editor/interaction-editor.tsx +0 -749
- package/src/widgets/interaction-editor/label-editor.tsx +0 -87
- package/src/widgets/interaction-editor/line-editor.tsx +0 -125
- package/src/widgets/interaction-editor/mathquill-input.tsx +0 -81
- package/src/widgets/interaction-editor/movable-line-editor.tsx +0 -121
- package/src/widgets/interaction-editor/movable-point-editor.tsx +0 -89
- package/src/widgets/interaction-editor/parametric-editor.tsx +0 -117
- package/src/widgets/interaction-editor/point-editor.tsx +0 -72
- package/src/widgets/interaction-editor/rectangle-editor.tsx +0 -96
- package/src/widgets/interactive-graph-editor.tsx +0 -571
- package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +0 -82
- package/src/widgets/label-image/__stories__/behavior.stories.tsx +0 -31
- package/src/widgets/label-image/__stories__/marker.stories.tsx +0 -75
- package/src/widgets/label-image/__stories__/question-markers.stories.tsx +0 -107
- package/src/widgets/label-image/__stories__/select-image.stories.tsx +0 -59
- package/src/widgets/label-image/answer-choices.tsx +0 -231
- package/src/widgets/label-image/behavior.tsx +0 -122
- package/src/widgets/label-image/marker.tsx +0 -290
- package/src/widgets/label-image/question-markers.tsx +0 -176
- package/src/widgets/label-image/select-image.tsx +0 -81
- package/src/widgets/label-image-editor.tsx +0 -252
- package/src/widgets/lights-puzzle-editor.tsx +0 -278
- package/src/widgets/matcher-editor.tsx +0 -149
- package/src/widgets/matrix-editor.tsx +0 -156
- package/src/widgets/measurer-editor.tsx +0 -253
- package/src/widgets/molecule-editor.tsx +0 -64
- package/src/widgets/number-line-editor.tsx +0 -512
- package/src/widgets/numeric-input-editor.tsx +0 -536
- package/src/widgets/orderer-editor.tsx +0 -172
- package/src/widgets/passage-editor.tsx +0 -117
- package/src/widgets/passage-ref-editor.tsx +0 -80
- package/src/widgets/passage-ref-target-editor.tsx +0 -49
- package/src/widgets/plotter-editor.tsx +0 -542
- package/src/widgets/radio/editor.tsx +0 -398
- package/src/widgets/reaction-diagram-editor.tsx +0 -131
- package/src/widgets/sequence-editor.tsx +0 -205
- package/src/widgets/simple-markdown-tester-editor.tsx +0 -86
- package/src/widgets/simple-markdown-tester.tsx +0 -92
- package/src/widgets/simulator-editor.tsx +0 -146
- package/src/widgets/sorter-editor.tsx +0 -103
- package/src/widgets/table-editor.tsx +0 -164
- package/src/widgets/unit-editor.tsx +0 -299
- package/src/widgets/video-editor.tsx +0 -73
- package/tsconfig-build.json +0 -22
- package/tsconfig-build.tsbuildinfo +0 -1
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
import {traverse, Widgets} from "@khanacademy/perseus";
|
|
2
|
-
import _ from "underscore";
|
|
3
|
-
|
|
4
|
-
import {registerAllWidgetsAndEditorsForTesting} from "../util/register-all-widgets-and-editors-for-testing";
|
|
5
|
-
|
|
6
|
-
const missingOptions = {
|
|
7
|
-
content: "[[☃ radio 1]]\n\n",
|
|
8
|
-
images: {},
|
|
9
|
-
widgets: {
|
|
10
|
-
"radio 1": {
|
|
11
|
-
type: "radio",
|
|
12
|
-
graded: true,
|
|
13
|
-
static: false,
|
|
14
|
-
options: {
|
|
15
|
-
choices: [
|
|
16
|
-
{
|
|
17
|
-
content: "A",
|
|
18
|
-
correct: true,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
correct: false,
|
|
22
|
-
content: "B",
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
version: {
|
|
27
|
-
major: 0,
|
|
28
|
-
minor: 0,
|
|
29
|
-
},
|
|
30
|
-
alignment: "default",
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
} as const;
|
|
34
|
-
|
|
35
|
-
const clonedMissingOptions = JSON.parse(JSON.stringify(missingOptions));
|
|
36
|
-
|
|
37
|
-
const sampleOptions = {
|
|
38
|
-
content: "[[☃ input-number 1]]",
|
|
39
|
-
images: {},
|
|
40
|
-
widgets: {
|
|
41
|
-
"input-number 1": {
|
|
42
|
-
type: "input-number",
|
|
43
|
-
graded: true,
|
|
44
|
-
static: false,
|
|
45
|
-
options: {
|
|
46
|
-
value: "0",
|
|
47
|
-
simplify: "required",
|
|
48
|
-
size: "normal",
|
|
49
|
-
inexact: false,
|
|
50
|
-
maxError: 0.1,
|
|
51
|
-
answerType: "number",
|
|
52
|
-
rightAlign: false,
|
|
53
|
-
},
|
|
54
|
-
version: {
|
|
55
|
-
major: 0,
|
|
56
|
-
minor: 0,
|
|
57
|
-
},
|
|
58
|
-
alignment: "default",
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
} as const;
|
|
62
|
-
|
|
63
|
-
const clonedSampleOptions = JSON.parse(JSON.stringify(sampleOptions));
|
|
64
|
-
|
|
65
|
-
const sampleOptions2 = {
|
|
66
|
-
content: "[[☃ radio 1]]\n\n",
|
|
67
|
-
images: {},
|
|
68
|
-
widgets: {
|
|
69
|
-
"radio 1": {
|
|
70
|
-
type: "radio",
|
|
71
|
-
graded: true,
|
|
72
|
-
static: false,
|
|
73
|
-
options: {
|
|
74
|
-
choices: [
|
|
75
|
-
{
|
|
76
|
-
content: "A",
|
|
77
|
-
correct: true,
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
correct: false,
|
|
81
|
-
content: "B",
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
randomize: false,
|
|
85
|
-
multipleSelect: false,
|
|
86
|
-
displayCount: null,
|
|
87
|
-
noneOfTheAbove: false,
|
|
88
|
-
deselectEnabled: false,
|
|
89
|
-
countChoices: false,
|
|
90
|
-
},
|
|
91
|
-
version: {
|
|
92
|
-
major: 0,
|
|
93
|
-
minor: 0,
|
|
94
|
-
},
|
|
95
|
-
alignment: "default",
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
} as const;
|
|
99
|
-
|
|
100
|
-
const clonedSampleOptions2 = JSON.parse(JSON.stringify(sampleOptions2));
|
|
101
|
-
|
|
102
|
-
const sampleOptions2Upgraded = {
|
|
103
|
-
content: "[[☃ radio 1]]\n\n",
|
|
104
|
-
images: {},
|
|
105
|
-
widgets: {
|
|
106
|
-
"radio 1": {
|
|
107
|
-
type: "radio",
|
|
108
|
-
graded: true,
|
|
109
|
-
static: false,
|
|
110
|
-
options: {
|
|
111
|
-
choices: [
|
|
112
|
-
{
|
|
113
|
-
content: "A",
|
|
114
|
-
correct: true,
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
correct: false,
|
|
118
|
-
content: "B",
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
randomize: false,
|
|
122
|
-
multipleSelect: false,
|
|
123
|
-
displayCount: null,
|
|
124
|
-
hasNoneOfTheAbove: false,
|
|
125
|
-
deselectEnabled: false,
|
|
126
|
-
countChoices: false,
|
|
127
|
-
},
|
|
128
|
-
version: {
|
|
129
|
-
major: 1,
|
|
130
|
-
minor: 0,
|
|
131
|
-
},
|
|
132
|
-
alignment: "default",
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
} as const;
|
|
136
|
-
|
|
137
|
-
const sampleGroup = {
|
|
138
|
-
content: "[[☃ group 1]]\n\n",
|
|
139
|
-
images: {},
|
|
140
|
-
widgets: {
|
|
141
|
-
"group 1": {
|
|
142
|
-
type: "group",
|
|
143
|
-
graded: true,
|
|
144
|
-
static: false,
|
|
145
|
-
options: {
|
|
146
|
-
content: "[[☃ radio 1]]\n\n",
|
|
147
|
-
images: {},
|
|
148
|
-
widgets: {
|
|
149
|
-
"radio 1": {
|
|
150
|
-
type: "radio",
|
|
151
|
-
graded: true,
|
|
152
|
-
static: false,
|
|
153
|
-
options: {
|
|
154
|
-
choices: [
|
|
155
|
-
{
|
|
156
|
-
content: "A",
|
|
157
|
-
correct: true,
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
correct: false,
|
|
161
|
-
content: "B",
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
randomize: false,
|
|
165
|
-
multipleSelect: false,
|
|
166
|
-
displayCount: null,
|
|
167
|
-
noneOfTheAbove: false,
|
|
168
|
-
deselectEnabled: false,
|
|
169
|
-
countChoices: false,
|
|
170
|
-
},
|
|
171
|
-
version: {
|
|
172
|
-
major: 0,
|
|
173
|
-
minor: 0,
|
|
174
|
-
},
|
|
175
|
-
alignment: "default",
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
version: {
|
|
180
|
-
major: 0,
|
|
181
|
-
minor: 0,
|
|
182
|
-
},
|
|
183
|
-
alignment: "default",
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
} as const;
|
|
187
|
-
|
|
188
|
-
const sampleGroupUpgraded = {
|
|
189
|
-
content: "[[☃ group 1]]\n\n",
|
|
190
|
-
images: {},
|
|
191
|
-
widgets: {
|
|
192
|
-
"group 1": {
|
|
193
|
-
type: "group",
|
|
194
|
-
graded: true,
|
|
195
|
-
static: false,
|
|
196
|
-
options: {
|
|
197
|
-
content: "[[☃ radio 1]]\n\n",
|
|
198
|
-
images: {},
|
|
199
|
-
widgets: {
|
|
200
|
-
"radio 1": {
|
|
201
|
-
type: "radio",
|
|
202
|
-
graded: true,
|
|
203
|
-
static: false,
|
|
204
|
-
options: {
|
|
205
|
-
choices: [
|
|
206
|
-
{
|
|
207
|
-
content: "A",
|
|
208
|
-
correct: true,
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
correct: false,
|
|
212
|
-
content: "B",
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
randomize: false,
|
|
216
|
-
multipleSelect: false,
|
|
217
|
-
displayCount: null,
|
|
218
|
-
hasNoneOfTheAbove: false,
|
|
219
|
-
deselectEnabled: false,
|
|
220
|
-
countChoices: false,
|
|
221
|
-
},
|
|
222
|
-
version: {
|
|
223
|
-
major: 1,
|
|
224
|
-
minor: 0,
|
|
225
|
-
},
|
|
226
|
-
alignment: "default",
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
metadata: undefined,
|
|
230
|
-
},
|
|
231
|
-
version: {
|
|
232
|
-
major: 0,
|
|
233
|
-
minor: 0,
|
|
234
|
-
},
|
|
235
|
-
alignment: "default",
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
} as const;
|
|
239
|
-
|
|
240
|
-
const clonedSampleGroup = JSON.parse(JSON.stringify(sampleGroup));
|
|
241
|
-
|
|
242
|
-
const assertNonMutative = () => {
|
|
243
|
-
expect(missingOptions).toEqual(clonedMissingOptions);
|
|
244
|
-
expect(sampleOptions).toEqual(clonedSampleOptions);
|
|
245
|
-
expect(sampleOptions2).toEqual(clonedSampleOptions2);
|
|
246
|
-
expect(sampleGroup).toEqual(clonedSampleGroup);
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
describe("Traversal", () => {
|
|
250
|
-
beforeAll(() => {
|
|
251
|
-
registerAllWidgetsAndEditorsForTesting();
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it("should call a root level content field", () => {
|
|
255
|
-
let readContent = null;
|
|
256
|
-
traverse(sampleOptions, (content) => {
|
|
257
|
-
expect(readContent === null).toBeTruthy();
|
|
258
|
-
readContent = content;
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
expect(readContent).toBe("[[☃ input-number 1]]");
|
|
262
|
-
assertNonMutative();
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
it("should be able to modify root level content", () => {
|
|
266
|
-
const newOptions = traverse(sampleOptions, (content) => {
|
|
267
|
-
return "new content text";
|
|
268
|
-
});
|
|
269
|
-
expect(newOptions).toEqual(
|
|
270
|
-
_.extend({}, sampleOptions, {
|
|
271
|
-
content: "new content text",
|
|
272
|
-
}),
|
|
273
|
-
);
|
|
274
|
-
assertNonMutative();
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it("should have access to widgets", () => {
|
|
278
|
-
const widgetMap: Record<string, any> = {};
|
|
279
|
-
traverse(sampleOptions, null, (widgetInfo) => {
|
|
280
|
-
widgetMap[widgetInfo.type] = (widgetMap[widgetInfo.type] || 0) + 1;
|
|
281
|
-
});
|
|
282
|
-
expect(widgetMap).toEqual({
|
|
283
|
-
"input-number": 1,
|
|
284
|
-
});
|
|
285
|
-
assertNonMutative();
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it("should be able to modify widgetInfo", () => {
|
|
289
|
-
const newOptions = traverse(sampleOptions, null, (widgetInfo) => {
|
|
290
|
-
return _.extend({}, widgetInfo, {
|
|
291
|
-
graded: false,
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
expect(newOptions).toEqual(
|
|
295
|
-
_.extend({}, sampleOptions, {
|
|
296
|
-
widgets: {
|
|
297
|
-
"input-number 1": _.extend(
|
|
298
|
-
{},
|
|
299
|
-
sampleOptions.widgets["input-number 1"],
|
|
300
|
-
{graded: false},
|
|
301
|
-
),
|
|
302
|
-
},
|
|
303
|
-
}),
|
|
304
|
-
);
|
|
305
|
-
assertNonMutative();
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it("should have access to modify full renderer options", () => {
|
|
309
|
-
const newOptions = traverse(sampleOptions, null, null, (options) => {
|
|
310
|
-
return _.extend({}, options, {
|
|
311
|
-
content: `${options.content}\n\nnew content!`,
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
expect(newOptions.content).toBe("[[☃ input-number 1]]\n\nnew content!");
|
|
315
|
-
expect(newOptions.widgets).toEqual(sampleOptions.widgets);
|
|
316
|
-
assertNonMutative();
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
it("should upgrade widgets automagickally", () => {
|
|
320
|
-
const newOptions = traverse(sampleOptions2);
|
|
321
|
-
expect(newOptions).toEqual(sampleOptions2Upgraded);
|
|
322
|
-
assertNonMutative();
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
it("should use defaults for missing options when upgrading widgets", () => {
|
|
326
|
-
const newOptions = traverse(missingOptions);
|
|
327
|
-
expect(newOptions).toEqual(sampleOptions2Upgraded);
|
|
328
|
-
assertNonMutative();
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it("should be able to see group widgets", () => {
|
|
332
|
-
const widgetMap: Record<string, any> = {};
|
|
333
|
-
traverse(sampleGroup, null, (widgetInfo) => {
|
|
334
|
-
widgetMap[widgetInfo.type] = (widgetMap[widgetInfo.type] || 0) + 1;
|
|
335
|
-
});
|
|
336
|
-
expect(widgetMap).toEqual({
|
|
337
|
-
group: 1,
|
|
338
|
-
radio: 1,
|
|
339
|
-
});
|
|
340
|
-
assertNonMutative();
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
it("should see upgraded widgets inside groups", () => {
|
|
344
|
-
let sawRadio = false;
|
|
345
|
-
traverse(sampleGroup, null, (widgetInfo) => {
|
|
346
|
-
if (widgetInfo.type === "radio") {
|
|
347
|
-
expect(widgetInfo.version).toEqual(Widgets.getVersion("radio"));
|
|
348
|
-
sawRadio = true;
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
expect(sawRadio).toBe(true);
|
|
352
|
-
assertNonMutative();
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it("should upgrade widgets in groups automagickally", () => {
|
|
356
|
-
const newGroup = traverse(sampleGroup);
|
|
357
|
-
expect(newGroup).toEqual(sampleGroupUpgraded);
|
|
358
|
-
assertNonMutative();
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
it("should modify full renderer options inside of groups", () => {
|
|
362
|
-
const newOptions = traverse(sampleGroup, null, null, (options) => {
|
|
363
|
-
if (/radio/.test(options.content)) {
|
|
364
|
-
return _.extend({}, options, {
|
|
365
|
-
content: "Extra instructions\n\n" + options.content,
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
return undefined;
|
|
369
|
-
});
|
|
370
|
-
const newContent = newOptions.widgets["group 1"].options.content;
|
|
371
|
-
expect(/^Extra instructions/.test(newContent)).toBeTruthy();
|
|
372
|
-
expect(newOptions.widgets["group 1"].options.widgets).toEqual(
|
|
373
|
-
sampleGroupUpgraded.widgets["group 1"].options.widgets,
|
|
374
|
-
);
|
|
375
|
-
assertNonMutative();
|
|
376
|
-
});
|
|
377
|
-
});
|
package/src/all-editors.test.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import allEditors from "./all-editors";
|
|
4
|
-
|
|
5
|
-
describe("All editors", () => {
|
|
6
|
-
it("should export react components with a widgetName property", () => {
|
|
7
|
-
for (const editor of allEditors) {
|
|
8
|
-
expect(
|
|
9
|
-
editor.displayName ||
|
|
10
|
-
editor.__proto__ === React.Component ||
|
|
11
|
-
editor.__proto__ === React.PureComponent,
|
|
12
|
-
).toBeTruthy();
|
|
13
|
-
expect(typeof editor.widgetName === "string").toBeTruthy();
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
package/src/all-editors.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import CategorizerEditor from "./widgets/categorizer-editor";
|
|
2
|
-
import CSProgramEditor from "./widgets/cs-program-editor";
|
|
3
|
-
import DefinitionEditor from "./widgets/definition-editor";
|
|
4
|
-
import DeprecatedStandinEditor from "./widgets/deprecated-standin-editor";
|
|
5
|
-
import DropdownEditor from "./widgets/dropdown-editor";
|
|
6
|
-
import ExampleGraphieWidgetEditor from "./widgets/example-graphie-widget-editor";
|
|
7
|
-
import ExampleWidgetEditor from "./widgets/example-widget-editor";
|
|
8
|
-
import ExplanationEditor from "./widgets/explanation-editor";
|
|
9
|
-
import ExpressionEditor from "./widgets/expression-editor";
|
|
10
|
-
import GradedGroupEditor from "./widgets/graded-group-editor";
|
|
11
|
-
import GradedGroupSetEditor from "./widgets/graded-group-set-editor";
|
|
12
|
-
import GrapherEditor from "./widgets/grapher-editor";
|
|
13
|
-
import GroupEditor from "./widgets/group-editor";
|
|
14
|
-
import IframeEditor from "./widgets/iframe-editor";
|
|
15
|
-
import ImageEditor from "./widgets/image-editor";
|
|
16
|
-
import InputNumberEditor from "./widgets/input-number-editor";
|
|
17
|
-
import InteractionEditor from "./widgets/interaction-editor";
|
|
18
|
-
import InteractiveGraphEditor from "./widgets/interactive-graph-editor";
|
|
19
|
-
import LabelImageEditor from "./widgets/label-image-editor";
|
|
20
|
-
import LightsPuzzleEditor from "./widgets/lights-puzzle-editor";
|
|
21
|
-
import MatcherEditor from "./widgets/matcher-editor";
|
|
22
|
-
import MatrixEditor from "./widgets/matrix-editor";
|
|
23
|
-
import MeasurerEditor from "./widgets/measurer-editor";
|
|
24
|
-
import MoleculeEditor from "./widgets/molecule-editor";
|
|
25
|
-
import NumberLineEditor from "./widgets/number-line-editor";
|
|
26
|
-
import NumericInputEditor from "./widgets/numeric-input-editor";
|
|
27
|
-
import OrdererEditor from "./widgets/orderer-editor";
|
|
28
|
-
import PassageEditor from "./widgets/passage-editor";
|
|
29
|
-
import PassageRefEditor from "./widgets/passage-ref-editor";
|
|
30
|
-
import PassageRefTargetEditor from "./widgets/passage-ref-target-editor";
|
|
31
|
-
import PlotterEditor from "./widgets/plotter-editor";
|
|
32
|
-
import RadioEditor from "./widgets/radio/editor";
|
|
33
|
-
import ReactionDiagramEditor from "./widgets/reaction-diagram-editor";
|
|
34
|
-
import SequenceEditor from "./widgets/sequence-editor";
|
|
35
|
-
import SimpleMarkdownTesterEditor from "./widgets/simple-markdown-tester-editor";
|
|
36
|
-
import SimulatorEditor from "./widgets/simulator-editor";
|
|
37
|
-
import SorterEditor from "./widgets/sorter-editor";
|
|
38
|
-
import TableEditor from "./widgets/table-editor";
|
|
39
|
-
import UnitEditor from "./widgets/unit-editor";
|
|
40
|
-
import VideoEditor from "./widgets/video-editor";
|
|
41
|
-
|
|
42
|
-
export default [
|
|
43
|
-
CategorizerEditor,
|
|
44
|
-
CSProgramEditor,
|
|
45
|
-
DefinitionEditor,
|
|
46
|
-
DropdownEditor,
|
|
47
|
-
ExampleGraphieWidgetEditor,
|
|
48
|
-
ExampleWidgetEditor,
|
|
49
|
-
ExplanationEditor,
|
|
50
|
-
ExpressionEditor,
|
|
51
|
-
GradedGroupEditor,
|
|
52
|
-
GradedGroupSetEditor,
|
|
53
|
-
GrapherEditor,
|
|
54
|
-
GroupEditor,
|
|
55
|
-
IframeEditor,
|
|
56
|
-
ImageEditor,
|
|
57
|
-
InputNumberEditor,
|
|
58
|
-
InteractionEditor,
|
|
59
|
-
InteractiveGraphEditor,
|
|
60
|
-
LabelImageEditor,
|
|
61
|
-
LightsPuzzleEditor,
|
|
62
|
-
MatcherEditor,
|
|
63
|
-
MatrixEditor,
|
|
64
|
-
MeasurerEditor,
|
|
65
|
-
MoleculeEditor,
|
|
66
|
-
NumberLineEditor,
|
|
67
|
-
NumericInputEditor,
|
|
68
|
-
OrdererEditor,
|
|
69
|
-
PassageEditor,
|
|
70
|
-
PassageRefEditor,
|
|
71
|
-
PassageRefTargetEditor,
|
|
72
|
-
PlotterEditor,
|
|
73
|
-
ReactionDiagramEditor,
|
|
74
|
-
SequenceEditor,
|
|
75
|
-
SimpleMarkdownTesterEditor,
|
|
76
|
-
SimulatorEditor,
|
|
77
|
-
SorterEditor,
|
|
78
|
-
TableEditor,
|
|
79
|
-
UnitEditor,
|
|
80
|
-
VideoEditor,
|
|
81
|
-
RadioEditor,
|
|
82
|
-
DeprecatedStandinEditor,
|
|
83
|
-
];
|
package/src/all-widgets.ts
DELETED