@khanacademy/perseus-editor 2.0.2 → 2.0.3
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/CHANGELOG.md +10 -0
- package/dist/article-editor.d.ts +2 -2
- package/dist/article-editor.js.flow +2 -2
- package/dist/components/dropdown-option.d.ts +2 -2
- package/dist/components/dropdown-option.js.flow +2 -2
- package/dist/components/link.d.ts +2 -2
- package/dist/components/link.js.flow +2 -2
- package/dist/diffs/__stories__/perseus-diff-wrapper.d.ts +3 -2
- package/dist/diffs/__stories__/perseus-diff-wrapper.js.flow +3 -2
- package/dist/editor.d.ts +7 -7
- package/dist/editor.js.flow +7 -7
- package/dist/es/index.js +0 -22
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +0 -22
- package/dist/index.js.map +1 -1
- package/dist/section-control-button.d.ts +10 -1
- package/dist/section-control-button.js.flow +13 -1
- package/dist/widgets/label-image/answer-choices.d.ts +1 -1
- package/dist/widgets/label-image/answer-choices.js.flow +1 -1
- package/dist/widgets/label-image/behavior.d.ts +2 -2
- package/dist/widgets/label-image/behavior.js.flow +2 -2
- package/dist/widgets/label-image/marker.d.ts +5 -5
- package/dist/widgets/label-image/marker.js.flow +5 -7
- package/dist/widgets/label-image/question-markers.d.ts +2 -2
- package/dist/widgets/label-image/question-markers.js.flow +2 -4
- package/dist/widgets/label-image/select-image.d.ts +2 -2
- package/dist/widgets/label-image/select-image.js.flow +2 -2
- package/dist/widgets/label-image-editor.d.ts +3 -3
- package/dist/widgets/label-image-editor.js.flow +3 -3
- package/package.json +2 -2
- package/src/__stories__/section-control-button.stories.tsx +3 -3
- package/src/article-editor.tsx +2 -5
- package/src/components/dropdown-option.tsx +2 -2
- package/src/components/link.ts +2 -2
- package/src/diffs/__stories__/perseus-diff-wrapper.tsx +4 -2
- package/src/diffs/__stories__/structured-item-diff.stories.tsx +5 -9
- package/src/diffs/__stories__/tags-diff.stories.tsx +1 -1
- package/src/diffs/__stories__/text-diff.stories.tsx +1 -1
- package/src/editor.tsx +8 -10
- package/src/multirenderer-editor.tsx +6 -12
- package/src/widgets/__stories__/label-image-editor.stories.tsx +1 -1
- package/src/widgets/__stories__/radio-editor.stories.tsx +1 -1
- package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +3 -7
- package/src/widgets/label-image/__stories__/behavior.stories.tsx +1 -1
- package/src/widgets/label-image/__stories__/marker.stories.tsx +2 -2
- package/src/widgets/label-image/__stories__/question-markers.stories.tsx +3 -3
- package/src/widgets/label-image/__stories__/select-image.stories.tsx +3 -3
- package/src/widgets/label-image/answer-choices.tsx +5 -5
- package/src/widgets/label-image/behavior.tsx +3 -3
- package/src/widgets/label-image/marker.tsx +5 -5
- package/src/widgets/label-image/question-markers.tsx +2 -2
- package/src/widgets/label-image/select-image.tsx +2 -5
- package/src/widgets/label-image-editor.tsx +3 -3
- package/src/widgets/numeric-input-editor.tsx +0 -20
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -70,7 +70,7 @@ class WithState extends React.Component<
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export const Empty
|
|
73
|
+
export const Empty = (args: StoryArgs): React.ReactElement => {
|
|
74
74
|
const props = {
|
|
75
75
|
choices: [],
|
|
76
76
|
imageUrl: "",
|
|
@@ -82,7 +82,7 @@ export const Empty: React.FC<StoryArgs> = (args): React.ReactElement => {
|
|
|
82
82
|
return <Wrapper {...props} />;
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
export const Filled
|
|
85
|
+
export const Filled = (args: StoryArgs): React.ReactElement => {
|
|
86
86
|
const props = {
|
|
87
87
|
choices: [],
|
|
88
88
|
imageUrl:
|
|
@@ -102,6 +102,6 @@ export const Filled: React.FC<StoryArgs> = (args): React.ReactElement => {
|
|
|
102
102
|
return <Wrapper {...props} />;
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
export const Interactive
|
|
105
|
+
export const Interactive = (args: StoryArgs): React.ReactElement => {
|
|
106
106
|
return <WithState />;
|
|
107
107
|
};
|
|
@@ -36,7 +36,7 @@ const WithState = () => {
|
|
|
36
36
|
);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
export const Empty
|
|
39
|
+
export const Empty = (args: StoryArgs): React.ReactElement => {
|
|
40
40
|
const props = {
|
|
41
41
|
url: "",
|
|
42
42
|
onChange: () => {},
|
|
@@ -45,7 +45,7 @@ export const Empty: React.FC<StoryArgs> = (args): React.ReactElement => {
|
|
|
45
45
|
return <Wrapper {...props} />;
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
export const Filled
|
|
48
|
+
export const Filled = (args: StoryArgs): React.ReactElement => {
|
|
49
49
|
const props = {
|
|
50
50
|
url: "https://ka-perseus-images.s3.amazonaws.com/2ee5fc32e35c5178373b39fd304b325b2994c913.png",
|
|
51
51
|
onChange: () => {},
|
|
@@ -54,6 +54,6 @@ export const Filled: React.FC<StoryArgs> = (args): React.ReactElement => {
|
|
|
54
54
|
return <Wrapper {...props} />;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
export const Interactive
|
|
57
|
+
export const Interactive = (args: StoryArgs): React.ReactElement => {
|
|
58
58
|
return <WithState />;
|
|
59
59
|
};
|
|
@@ -89,7 +89,7 @@ const DraggableGripIcon = () => (
|
|
|
89
89
|
/**
|
|
90
90
|
* A button link to add a new answer.
|
|
91
91
|
*/
|
|
92
|
-
const AddAnswer
|
|
92
|
+
const AddAnswer = ({onClick}: AddAnswerProps): React.ReactElement => (
|
|
93
93
|
<Link
|
|
94
94
|
className={css(styles.addAnswer, editorStyles.addAnswer)}
|
|
95
95
|
onClick={onClick}
|
|
@@ -105,11 +105,11 @@ const AddAnswer: React.FC<AddAnswerProps> = ({onClick}): React.ReactElement => (
|
|
|
105
105
|
*
|
|
106
106
|
* TODO(michaelpolyak): Implement answer reordering, CP-117
|
|
107
107
|
*/
|
|
108
|
-
const Answer
|
|
108
|
+
const Answer = ({
|
|
109
109
|
answer,
|
|
110
110
|
onChange,
|
|
111
111
|
onRemove,
|
|
112
|
-
}): React.ReactElement => (
|
|
112
|
+
}: AnswerProps): React.ReactElement => (
|
|
113
113
|
<li className={css(styles.answer)}>
|
|
114
114
|
<Link onClick={onRemove}>
|
|
115
115
|
<Icon icon={removeIcon} size={24} color="#D92916" />
|
|
@@ -137,10 +137,10 @@ const Answer: React.FC<AnswerProps> = ({
|
|
|
137
137
|
/**
|
|
138
138
|
* The list of choices, handles adding, removing and reording of answers.
|
|
139
139
|
*/
|
|
140
|
-
const AnswerChoices
|
|
140
|
+
const AnswerChoices = ({
|
|
141
141
|
choices,
|
|
142
142
|
onChange,
|
|
143
|
-
}): React.ReactElement => (
|
|
143
|
+
}: AnswerChoicesProps): React.ReactElement => (
|
|
144
144
|
<div>
|
|
145
145
|
<div className={css(styles.title)}>Answer Choices</div>
|
|
146
146
|
|
|
@@ -10,7 +10,7 @@ import Checkbox from "../../components/checkbox";
|
|
|
10
10
|
|
|
11
11
|
const {colors, typography} = globalStyles;
|
|
12
12
|
|
|
13
|
-
type
|
|
13
|
+
type Props = {
|
|
14
14
|
// Whether multiple answer choices may be selected for markers.
|
|
15
15
|
multipleAnswers: boolean;
|
|
16
16
|
// Whether to hide answer choices from user instructions.
|
|
@@ -22,11 +22,11 @@ type BehaviorProps = {
|
|
|
22
22
|
}) => void;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const Behavior
|
|
25
|
+
const Behavior = ({
|
|
26
26
|
multipleAnswers,
|
|
27
27
|
hideChoicesFromInstructions,
|
|
28
28
|
onChange,
|
|
29
|
-
}): React.ReactElement => (
|
|
29
|
+
}: Props): React.ReactElement => (
|
|
30
30
|
<div>
|
|
31
31
|
<div className={css(styles.title)}>Behavior</div>
|
|
32
32
|
|
|
@@ -17,7 +17,7 @@ import type {MarkerType} from "@khanacademy/perseus";
|
|
|
17
17
|
|
|
18
18
|
const {colors, borderRadius} = globalStyles;
|
|
19
19
|
|
|
20
|
-
type
|
|
20
|
+
type Props = MarkerType & {
|
|
21
21
|
// The list of possible answer choices.
|
|
22
22
|
choices: ReadonlyArray<string>;
|
|
23
23
|
// Callback for when any of the marker props are changed.
|
|
@@ -26,16 +26,16 @@ type MarkerProps = MarkerType & {
|
|
|
26
26
|
onRemove: () => void;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
type
|
|
29
|
+
type State = {
|
|
30
30
|
// Whether answer choices dropdown is shown, controlled by the user clicking
|
|
31
31
|
// on the marker icon.
|
|
32
32
|
showDropdown: boolean;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
export default class Marker extends React.Component<
|
|
35
|
+
export default class Marker extends React.Component<Props, State> {
|
|
36
36
|
_marker: HTMLElement | null | undefined;
|
|
37
37
|
|
|
38
|
-
constructor(props:
|
|
38
|
+
constructor(props: Props) {
|
|
39
39
|
super(props);
|
|
40
40
|
|
|
41
41
|
this.state = {
|
|
@@ -47,7 +47,7 @@ export default class Marker extends React.Component<MarkerProps, MarkerState> {
|
|
|
47
47
|
document.addEventListener("click", this.handleClick, true);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
UNSAFE_componentWillReceiveProps(nextProps:
|
|
50
|
+
UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
|
51
51
|
const {answers} = this.props;
|
|
52
52
|
|
|
53
53
|
// Exclude those answers that are no longer present in choices.
|
|
@@ -13,7 +13,7 @@ import type {MarkerType} from "@khanacademy/perseus";
|
|
|
13
13
|
|
|
14
14
|
const {colors, typography} = globalStyles;
|
|
15
15
|
|
|
16
|
-
type
|
|
16
|
+
type Props = {
|
|
17
17
|
// The list of possible answers in a specific order.
|
|
18
18
|
choices: ReadonlyArray<string>;
|
|
19
19
|
// The question image properties.
|
|
@@ -26,7 +26,7 @@ type QuestionMarkersProps = {
|
|
|
26
26
|
onChange: (markers: ReadonlyArray<MarkerType>) => void;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export default class QuestionMarkers extends React.Component<
|
|
29
|
+
export default class QuestionMarkers extends React.Component<Props> {
|
|
30
30
|
_markers: Array<Marker | null | undefined> = [];
|
|
31
31
|
|
|
32
32
|
openDropdownForMarkerIndices(indices: ReadonlyArray<number>) {
|
|
@@ -11,17 +11,14 @@ import FormWrappedTextField from "../../components/form-wrapped-text-field";
|
|
|
11
11
|
|
|
12
12
|
const {colors, typography} = globalStyles;
|
|
13
13
|
|
|
14
|
-
type
|
|
14
|
+
type Props = {
|
|
15
15
|
// Callback for when image URL is changed.
|
|
16
16
|
onChange: (url: string) => void;
|
|
17
17
|
// The selected image URL.
|
|
18
18
|
url: string;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const SelectImage: React.
|
|
22
|
-
onChange,
|
|
23
|
-
url,
|
|
24
|
-
}): React.ReactElement => (
|
|
21
|
+
const SelectImage = ({onChange, url}: Props): React.ReactElement => (
|
|
25
22
|
<div>
|
|
26
23
|
<div className={css(styles.title)}>Image</div>
|
|
27
24
|
|
|
@@ -19,7 +19,7 @@ import SelectImage from "./label-image/select-image";
|
|
|
19
19
|
|
|
20
20
|
import type {MarkerType} from "@khanacademy/perseus";
|
|
21
21
|
|
|
22
|
-
type
|
|
22
|
+
type Props = {
|
|
23
23
|
// List of answer choices to label question image with.
|
|
24
24
|
choices: ReadonlyArray<string>;
|
|
25
25
|
// The question image properties.
|
|
@@ -37,7 +37,7 @@ type LabelImageEditorProps = {
|
|
|
37
37
|
onChange: (options: any) => void;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
class LabelImageEditor extends React.Component<
|
|
40
|
+
class LabelImageEditor extends React.Component<Props> {
|
|
41
41
|
_questionMarkers: QuestionMarkers | null | undefined;
|
|
42
42
|
|
|
43
43
|
static defaultProps: {
|
|
@@ -62,7 +62,7 @@ class LabelImageEditor extends React.Component<LabelImageEditorProps> {
|
|
|
62
62
|
|
|
63
63
|
static widgetName = "label-image" as const;
|
|
64
64
|
|
|
65
|
-
componentDidUpdate(prevProps:
|
|
65
|
+
componentDidUpdate(prevProps: Props) {
|
|
66
66
|
const coordsToMarkers: Record<string, any> = {};
|
|
67
67
|
|
|
68
68
|
prevProps.markers.forEach(
|
|
@@ -66,7 +66,6 @@ const NumericInputEditor: any = createReactClass({
|
|
|
66
66
|
size: "normal",
|
|
67
67
|
coefficient: false,
|
|
68
68
|
labelText: "",
|
|
69
|
-
multipleNumberInput: false,
|
|
70
69
|
rightAlign: false,
|
|
71
70
|
};
|
|
72
71
|
},
|
|
@@ -417,16 +416,6 @@ const NumericInputEditor: any = createReactClass({
|
|
|
417
416
|
|
|
418
417
|
return (
|
|
419
418
|
<div className="perseus-input-number-editor">
|
|
420
|
-
<div ref={(e) => (this.multInputOption = e)}>
|
|
421
|
-
<select onChange={this.onMultipleInputChange}>
|
|
422
|
-
<option value="simple-numeric-input">
|
|
423
|
-
Ask for one correct solution
|
|
424
|
-
</option>
|
|
425
|
-
<option value="multiple-numeric-input">
|
|
426
|
-
Ask for all correct solutions
|
|
427
|
-
</option>
|
|
428
|
-
</select>
|
|
429
|
-
</div>
|
|
430
419
|
<div className="ui-title">User input</div>
|
|
431
420
|
<div className="msg-title">
|
|
432
421
|
Message shown to user on attempt
|
|
@@ -480,15 +469,6 @@ const NumericInputEditor: any = createReactClass({
|
|
|
480
469
|
});
|
|
481
470
|
},
|
|
482
471
|
|
|
483
|
-
onMultipleInputChange: function (event) {
|
|
484
|
-
const newOption = event.target.value;
|
|
485
|
-
if (newOption === "multiple-numeric-input") {
|
|
486
|
-
this.props.onChange({multipleNumberInput: true});
|
|
487
|
-
} else {
|
|
488
|
-
this.props.onChange({multipleNumberInput: false});
|
|
489
|
-
}
|
|
490
|
-
},
|
|
491
|
-
|
|
492
472
|
updateAnswer: function (choiceIndex, update) {
|
|
493
473
|
if (!_.isObject(update)) {
|
|
494
474
|
return _.partial(
|