@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.
Files changed (55) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/article-editor.d.ts +2 -2
  3. package/dist/article-editor.js.flow +2 -2
  4. package/dist/components/dropdown-option.d.ts +2 -2
  5. package/dist/components/dropdown-option.js.flow +2 -2
  6. package/dist/components/link.d.ts +2 -2
  7. package/dist/components/link.js.flow +2 -2
  8. package/dist/diffs/__stories__/perseus-diff-wrapper.d.ts +3 -2
  9. package/dist/diffs/__stories__/perseus-diff-wrapper.js.flow +3 -2
  10. package/dist/editor.d.ts +7 -7
  11. package/dist/editor.js.flow +7 -7
  12. package/dist/es/index.js +0 -22
  13. package/dist/es/index.js.map +1 -1
  14. package/dist/index.js +0 -22
  15. package/dist/index.js.map +1 -1
  16. package/dist/section-control-button.d.ts +10 -1
  17. package/dist/section-control-button.js.flow +13 -1
  18. package/dist/widgets/label-image/answer-choices.d.ts +1 -1
  19. package/dist/widgets/label-image/answer-choices.js.flow +1 -1
  20. package/dist/widgets/label-image/behavior.d.ts +2 -2
  21. package/dist/widgets/label-image/behavior.js.flow +2 -2
  22. package/dist/widgets/label-image/marker.d.ts +5 -5
  23. package/dist/widgets/label-image/marker.js.flow +5 -7
  24. package/dist/widgets/label-image/question-markers.d.ts +2 -2
  25. package/dist/widgets/label-image/question-markers.js.flow +2 -4
  26. package/dist/widgets/label-image/select-image.d.ts +2 -2
  27. package/dist/widgets/label-image/select-image.js.flow +2 -2
  28. package/dist/widgets/label-image-editor.d.ts +3 -3
  29. package/dist/widgets/label-image-editor.js.flow +3 -3
  30. package/package.json +2 -2
  31. package/src/__stories__/section-control-button.stories.tsx +3 -3
  32. package/src/article-editor.tsx +2 -5
  33. package/src/components/dropdown-option.tsx +2 -2
  34. package/src/components/link.ts +2 -2
  35. package/src/diffs/__stories__/perseus-diff-wrapper.tsx +4 -2
  36. package/src/diffs/__stories__/structured-item-diff.stories.tsx +5 -9
  37. package/src/diffs/__stories__/tags-diff.stories.tsx +1 -1
  38. package/src/diffs/__stories__/text-diff.stories.tsx +1 -1
  39. package/src/editor.tsx +8 -10
  40. package/src/multirenderer-editor.tsx +6 -12
  41. package/src/widgets/__stories__/label-image-editor.stories.tsx +1 -1
  42. package/src/widgets/__stories__/radio-editor.stories.tsx +1 -1
  43. package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +3 -7
  44. package/src/widgets/label-image/__stories__/behavior.stories.tsx +1 -1
  45. package/src/widgets/label-image/__stories__/marker.stories.tsx +2 -2
  46. package/src/widgets/label-image/__stories__/question-markers.stories.tsx +3 -3
  47. package/src/widgets/label-image/__stories__/select-image.stories.tsx +3 -3
  48. package/src/widgets/label-image/answer-choices.tsx +5 -5
  49. package/src/widgets/label-image/behavior.tsx +3 -3
  50. package/src/widgets/label-image/marker.tsx +5 -5
  51. package/src/widgets/label-image/question-markers.tsx +2 -2
  52. package/src/widgets/label-image/select-image.tsx +2 -5
  53. package/src/widgets/label-image-editor.tsx +3 -3
  54. package/src/widgets/numeric-input-editor.tsx +0 -20
  55. package/tsconfig.tsbuildinfo +1 -1
@@ -1,5 +1,14 @@
1
1
  import * as React from "react";
2
- declare const InlineIcon: React.FC<import("../../perseus/src/components/inline-icon").InlineIconProps>;
2
+ declare const InlineIcon: {
3
+ ({ path, width, height, style, title, }: import("../../perseus/src/components/inline-icon").InlineIconProps): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
4
+ propTypes: {
5
+ path: import("prop-types").Validator<string>;
6
+ height: import("prop-types").Validator<number>;
7
+ width: import("prop-types").Validator<number>;
8
+ style: import("prop-types").Requireable<object>;
9
+ title: import("prop-types").Requireable<string>;
10
+ };
11
+ };
3
12
  type InlineIconProps = JSX.LibraryManagedAttributes<typeof InlineIcon, React.ComponentProps<typeof InlineIcon>>;
4
13
  type SectionControlButtonProps = {
5
14
  icon: InlineIconProps;
@@ -5,8 +5,20 @@
5
5
  * @flow
6
6
  */
7
7
  import * as $Flowgen$Import$_2e__2e__2f__2e__2e__2f_perseus_2f_src_2f_components_2f_inline_2d_icon from "../../perseus/src/components/inline-icon";
8
+ import * as $Flowgen$Import$prop_2d_types from "prop-types";
8
9
  import * as React from "react";
9
- declare var InlineIcon: React.StatelessFunctionalComponent<$Flowgen$Import$_2e__2e__2f__2e__2e__2f_perseus_2f_src_2f_components_2f_inline_2d_icon.InlineIconProps>;
10
+ declare var InlineIcon: {|
11
+ (
12
+ x: $Flowgen$Import$_2e__2e__2f__2e__2e__2f_perseus_2f_src_2f_components_2f_inline_2d_icon.InlineIconProps
13
+ ): React.Element<any, string | React.JSXElementConstructor<any>>,
14
+ propTypes: {|
15
+ path: $Flowgen$Import$prop_2d_types.Validator<string>,
16
+ height: $Flowgen$Import$prop_2d_types.Validator<number>,
17
+ width: $Flowgen$Import$prop_2d_types.Validator<number>,
18
+ style: $Flowgen$Import$prop_2d_types.Requireable<{ ... }>,
19
+ title: $Flowgen$Import$prop_2d_types.Requireable<string>,
20
+ |},
21
+ |};
10
22
  declare type InlineIconProps = React.ElementConfig<typeof InlineIcon>;
11
23
  declare type SectionControlButtonProps = {|
12
24
  icon: InlineIconProps,
@@ -9,5 +9,5 @@ type AnswerChoicesProps = {
9
9
  /**
10
10
  * The list of choices, handles adding, removing and reording of answers.
11
11
  */
12
- declare const AnswerChoices: React.FC<AnswerChoicesProps>;
12
+ declare const AnswerChoices: ({ choices, onChange, }: AnswerChoicesProps) => React.ReactElement;
13
13
  export default AnswerChoices;
@@ -12,5 +12,5 @@ declare type AnswerChoicesProps = {|
12
12
  /**
13
13
  * The list of choices, handles adding, removing and reording of answers.
14
14
  */
15
- declare var AnswerChoices: React.StatelessFunctionalComponent<AnswerChoicesProps>;
15
+ declare var AnswerChoices: (x: AnswerChoicesProps) => React.Element<any>;
16
16
  declare export default typeof AnswerChoices;
@@ -2,7 +2,7 @@
2
2
  * Controlled component to display and change widget options.
3
3
  */
4
4
  import * as React from "react";
5
- type BehaviorProps = {
5
+ type Props = {
6
6
  multipleAnswers: boolean;
7
7
  hideChoicesFromInstructions: boolean;
8
8
  onChange: (options: {
@@ -10,5 +10,5 @@ type BehaviorProps = {
10
10
  hideChoicesFromInstructions?: boolean;
11
11
  }) => void;
12
12
  };
13
- declare const Behavior: React.FC<BehaviorProps>;
13
+ declare const Behavior: ({ multipleAnswers, hideChoicesFromInstructions, onChange, }: Props) => React.ReactElement;
14
14
  export default Behavior;
@@ -5,7 +5,7 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
- declare type BehaviorProps = {|
8
+ declare type Props = {|
9
9
  multipleAnswers: boolean,
10
10
  hideChoicesFromInstructions: boolean,
11
11
  onChange: (options: {|
@@ -13,5 +13,5 @@ declare type BehaviorProps = {|
13
13
  hideChoicesFromInstructions?: boolean,
14
14
  |}) => void,
15
15
  |};
16
- declare var Behavior: React.StatelessFunctionalComponent<BehaviorProps>;
16
+ declare var Behavior: (x: Props) => React.Element<any>;
17
17
  declare export default typeof Behavior;
@@ -6,19 +6,19 @@
6
6
  */
7
7
  import * as React from "react";
8
8
  import type { MarkerType } from "@khanacademy/perseus";
9
- type MarkerProps = MarkerType & {
9
+ type Props = MarkerType & {
10
10
  choices: ReadonlyArray<string>;
11
11
  onChange: (marker: MarkerType) => void;
12
12
  onRemove: () => void;
13
13
  };
14
- type MarkerState = {
14
+ type State = {
15
15
  showDropdown: boolean;
16
16
  };
17
- export default class Marker extends React.Component<MarkerProps, MarkerState> {
17
+ export default class Marker extends React.Component<Props, State> {
18
18
  _marker: HTMLElement | null | undefined;
19
- constructor(props: MarkerProps);
19
+ constructor(props: Props);
20
20
  componentDidMount(): void;
21
- UNSAFE_componentWillReceiveProps(nextProps: MarkerProps): void;
21
+ UNSAFE_componentWillReceiveProps(nextProps: Props): void;
22
22
  componentWillUnmount(): void;
23
23
  openDropdown(): void;
24
24
  updateMarker(props: any): void;
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import * as React from "react";
8
8
  import type { MarkerType } from "@khanacademy/perseus";
9
- declare type MarkerProps = {|
9
+ declare type Props = {|
10
10
  ...MarkerType,
11
11
  ...{|
12
12
  choices: $ReadOnlyArray<string>,
@@ -14,16 +14,14 @@ declare type MarkerProps = {|
14
14
  onRemove: () => void,
15
15
  |},
16
16
  |};
17
- declare type MarkerState = {|
17
+ declare type State = {|
18
18
  showDropdown: boolean,
19
19
  |};
20
- declare export default class Marker
21
- extends React.Component<MarkerProps, MarkerState>
22
- {
20
+ declare export default class Marker extends React.Component<Props, State> {
23
21
  _marker: HTMLElement | null | void;
24
- constructor(props: MarkerProps): this;
22
+ constructor(props: Props): this;
25
23
  componentDidMount(): void;
26
- UNSAFE_componentWillReceiveProps(nextProps: MarkerProps): void;
24
+ UNSAFE_componentWillReceiveProps(nextProps: Props): void;
27
25
  componentWillUnmount(): void;
28
26
  openDropdown(): void;
29
27
  updateMarker(props: any): void;
@@ -5,7 +5,7 @@
5
5
  import * as React from "react";
6
6
  import Marker from "./marker";
7
7
  import type { MarkerType } from "@khanacademy/perseus";
8
- type QuestionMarkersProps = {
8
+ type Props = {
9
9
  choices: ReadonlyArray<string>;
10
10
  imageUrl: string;
11
11
  imageWidth: number;
@@ -13,7 +13,7 @@ type QuestionMarkersProps = {
13
13
  markers: ReadonlyArray<MarkerType>;
14
14
  onChange: (markers: ReadonlyArray<MarkerType>) => void;
15
15
  };
16
- export default class QuestionMarkers extends React.Component<QuestionMarkersProps> {
16
+ export default class QuestionMarkers extends React.Component<Props> {
17
17
  _markers: Array<Marker | null | undefined>;
18
18
  openDropdownForMarkerIndices(indices: ReadonlyArray<number>): void;
19
19
  handleImageDoubleClick: (e: React.MouseEvent) => void;
@@ -7,7 +7,7 @@
7
7
  import * as React from "react";
8
8
  import Marker from "./marker";
9
9
  import type { MarkerType } from "@khanacademy/perseus";
10
- declare type QuestionMarkersProps = {|
10
+ declare type Props = {|
11
11
  choices: $ReadOnlyArray<string>,
12
12
  imageUrl: string,
13
13
  imageWidth: number,
@@ -15,9 +15,7 @@ declare type QuestionMarkersProps = {|
15
15
  markers: $ReadOnlyArray<MarkerType>,
16
16
  onChange: (markers: $ReadOnlyArray<MarkerType>) => void,
17
17
  |};
18
- declare export default class QuestionMarkers
19
- extends React.Component<QuestionMarkersProps>
20
- {
18
+ declare export default class QuestionMarkers extends React.Component<Props> {
21
19
  _markers: Array<Marker | null | void>;
22
20
  openDropdownForMarkerIndices(indices: $ReadOnlyArray<number>): void;
23
21
  handleImageDoubleClick: (e: SyntheticMouseEvent<>) => void;
@@ -2,9 +2,9 @@
2
2
  * Controlled component for selecting the question image, for answer labeling.
3
3
  */
4
4
  import * as React from "react";
5
- type SelectImageProps = {
5
+ type Props = {
6
6
  onChange: (url: string) => void;
7
7
  url: string;
8
8
  };
9
- declare const SelectImage: React.FC<SelectImageProps>;
9
+ declare const SelectImage: ({ onChange, url }: Props) => React.ReactElement;
10
10
  export default SelectImage;
@@ -5,9 +5,9 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
- declare type SelectImageProps = {|
8
+ declare type Props = {|
9
9
  onChange: (url: string) => void,
10
10
  url: string,
11
11
  |};
12
- declare var SelectImage: React.StatelessFunctionalComponent<SelectImageProps>;
12
+ declare var SelectImage: (x: Props) => React.Element<any>;
13
13
  declare export default typeof SelectImage;
@@ -8,7 +8,7 @@
8
8
  import * as React from "react";
9
9
  import QuestionMarkers from "./label-image/question-markers";
10
10
  import type { MarkerType } from "@khanacademy/perseus";
11
- type LabelImageEditorProps = {
11
+ type Props = {
12
12
  choices: ReadonlyArray<string>;
13
13
  imageAlt: string;
14
14
  imageUrl: string;
@@ -19,7 +19,7 @@ type LabelImageEditorProps = {
19
19
  hideChoicesFromInstructions: boolean;
20
20
  onChange: (options: any) => void;
21
21
  };
22
- declare class LabelImageEditor extends React.Component<LabelImageEditorProps> {
22
+ declare class LabelImageEditor extends React.Component<Props> {
23
23
  _questionMarkers: QuestionMarkers | null | undefined;
24
24
  static defaultProps: {
25
25
  choices: ReadonlyArray<any>;
@@ -32,7 +32,7 @@ declare class LabelImageEditor extends React.Component<LabelImageEditorProps> {
32
32
  multipleAnswers: boolean;
33
33
  };
34
34
  static widgetName: "label-image";
35
- componentDidUpdate(prevProps: LabelImageEditorProps): void;
35
+ componentDidUpdate(prevProps: Props): void;
36
36
  getSaveWarnings: () => ReadonlyArray<any | string>;
37
37
  serialize(): any;
38
38
  handleImageChange: (url: string) => void;
@@ -7,7 +7,7 @@
7
7
  import * as React from "react";
8
8
  import QuestionMarkers from "./label-image/question-markers";
9
9
  import type { MarkerType } from "@khanacademy/perseus";
10
- declare type LabelImageEditorProps = {|
10
+ declare type Props = {|
11
11
  choices: $ReadOnlyArray<string>,
12
12
  imageAlt: string,
13
13
  imageUrl: string,
@@ -18,7 +18,7 @@ declare type LabelImageEditorProps = {|
18
18
  hideChoicesFromInstructions: boolean,
19
19
  onChange: (options: any) => void,
20
20
  |};
21
- declare class LabelImageEditor extends React.Component<LabelImageEditorProps> {
21
+ declare class LabelImageEditor extends React.Component<Props> {
22
22
  _questionMarkers: QuestionMarkers | null | void;
23
23
  static defaultProps: {|
24
24
  choices: $ReadOnlyArray<any>,
@@ -31,7 +31,7 @@ declare class LabelImageEditor extends React.Component<LabelImageEditorProps> {
31
31
  multipleAnswers: boolean,
32
32
  |};
33
33
  static widgetName: "label-image";
34
- componentDidUpdate(prevProps: LabelImageEditorProps): void;
34
+ componentDidUpdate(prevProps: Props): void;
35
35
  getSaveWarnings: () => $ReadOnlyArray<any | string>;
36
36
  serialize(): any;
37
37
  handleImageChange: (url: string) => void;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Perseus editors",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "2.0.2",
6
+ "version": "2.0.3",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@khanacademy/kas": "^0.3.1",
25
25
  "@khanacademy/kmath": "^0.1.1",
26
- "@khanacademy/perseus": "^4.0.2"
26
+ "@khanacademy/perseus": "^5.0.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@khanacademy/wonder-blocks-button": "^4.0.8",
@@ -13,9 +13,9 @@ export default {
13
13
  title: "Perseus Editor/Widgets/Section Control Button",
14
14
  } as Story;
15
15
 
16
- export const ButtonForEditingSectionsOfContentWithInArticleEditor: React.FC<
17
- StoryArgs
18
- > = (args): React.ReactElement => {
16
+ export const ButtonForEditingSectionsOfContentWithInArticleEditor = (
17
+ args: StoryArgs,
18
+ ): React.ReactElement => {
19
19
  return (
20
20
  <SectionControlButton
21
21
  icon={icons.iconTrash}
@@ -44,7 +44,7 @@ type DefaultProps = {
44
44
  ) => React.ReactElement<React.ComponentProps<"span">>;
45
45
  useNewStyles: boolean;
46
46
  };
47
- type PerseusArticleEditorProps = DefaultProps & {
47
+ type Props = DefaultProps & {
48
48
  apiOptions?: APIOptions;
49
49
  imageUploader?: (arg1: string, arg2: (arg1: string) => unknown) => unknown;
50
50
  // URL of the route to show on initial load of the preview frames.
@@ -54,10 +54,7 @@ type PerseusArticleEditorProps = DefaultProps & {
54
54
  type State = {
55
55
  highlightLint: boolean;
56
56
  };
57
- export default class ArticleEditor extends React.Component<
58
- PerseusArticleEditorProps,
59
- State
60
- > {
57
+ export default class ArticleEditor extends React.Component<Props, State> {
61
58
  static defaultProps: DefaultProps = {
62
59
  contentPaths: [],
63
60
  json: [{}],
@@ -31,7 +31,7 @@ const findAndFocusElement = (component?: Element | null) => {
31
31
  }
32
32
  };
33
33
 
34
- type OptionProps = {
34
+ type Props = {
35
35
  // The value to use when the option is selected
36
36
  value: string;
37
37
  // The display of the option
@@ -65,7 +65,7 @@ const check = `M10,3.8C10,4,9.9,4.2,9.8,4.3L5.1,8.9L4.3,9.8C4.2,9.9,4,10,3.8,10
65
65
 
66
66
  export const optionHeight = 30;
67
67
 
68
- class Option extends React.Component<OptionProps> {
68
+ class Option extends React.Component<Props> {
69
69
  // @ts-expect-error [FEI-5003] - TS2564 - Property 'node' has no initializer and is not definitely assigned in the constructor.
70
70
  node: HTMLDivElement;
71
71
 
@@ -24,7 +24,7 @@ type DefaultProps = {
24
24
  style: CSSProperties | Array<CSSProperties>;
25
25
  };
26
26
 
27
- type LinkProps = DefaultProps & {
27
+ type Props = DefaultProps & {
28
28
  children?: React.ReactNode;
29
29
  // An additional class name to add. This is supported so-as to allow
30
30
  // Perseus to add class-based styles to links when using this
@@ -66,7 +66,7 @@ type LinkProps = DefaultProps & {
66
66
  /**
67
67
  * A wrapper that creates an anchor tag with normalized styles
68
68
  */
69
- class Link extends React.Component<LinkProps> {
69
+ class Link extends React.Component<Props> {
70
70
  static defaultProps: DefaultProps = {
71
71
  highlighted: false,
72
72
  href: DEFAULT_HREF,
@@ -1,8 +1,10 @@
1
1
  import * as React from "react";
2
2
 
3
- const Wrapper: React.FC<{
3
+ type Props = {
4
4
  children: React.ReactNode;
5
- }> = ({children}): React.ReactElement => {
5
+ };
6
+
7
+ const Wrapper = ({children}: Props): React.ReactElement => {
6
8
  return <div className="perseus-diff">{children}</div>;
7
9
  };
8
10
 
@@ -33,7 +33,7 @@ const tags = {
33
33
  c: "c tag",
34
34
  } as const;
35
35
 
36
- export const ContentAdded: React.FC<StoryArgs> = (args): React.ReactElement => {
36
+ export const ContentAdded = (args: StoryArgs): React.ReactElement => {
37
37
  const props = {
38
38
  before: {
39
39
  _multi: {
@@ -175,8 +175,8 @@ export const ContentAdded: React.FC<StoryArgs> = (args): React.ReactElement => {
175
175
  };
176
176
 
177
177
  // second instance
178
- export const ContentAddedRemovedAndChanged: React.FC<StoryArgs> = (
179
- args,
178
+ export const ContentAddedRemovedAndChanged = (
179
+ args: StoryArgs,
180
180
  ): React.ReactElement => {
181
181
  const props = {
182
182
  before: {
@@ -383,9 +383,7 @@ export const ContentAddedRemovedAndChanged: React.FC<StoryArgs> = (
383
383
  };
384
384
 
385
385
  // third instance
386
- export const MiscContentChanges: React.FC<StoryArgs> = (
387
- args,
388
- ): React.ReactElement => {
386
+ export const MiscContentChanges = (args: StoryArgs): React.ReactElement => {
389
387
  const props = {
390
388
  before: {
391
389
  _multi: {
@@ -681,9 +679,7 @@ export const MiscContentChanges: React.FC<StoryArgs> = (
681
679
  };
682
680
 
683
681
  // fourth
684
- export const ContentRemoved: React.FC<StoryArgs> = (
685
- args,
686
- ): React.ReactElement => {
682
+ export const ContentRemoved = (args: StoryArgs): React.ReactElement => {
687
683
  const props = {
688
684
  before: {
689
685
  _multi: {
@@ -24,7 +24,7 @@ export default {
24
24
  ],
25
25
  } as Story;
26
26
 
27
- export const Example: React.FC<StoryArgs> = (args): React.ReactElement => {
27
+ export const Example = (args: StoryArgs): React.ReactElement => {
28
28
  return (
29
29
  <TagsDiff
30
30
  title="tags"
@@ -24,7 +24,7 @@ export default {
24
24
  ],
25
25
  } as Story;
26
26
 
27
- export const Example: React.FC<StoryArgs> = (args): React.ReactElement => {
27
+ export const Example = (args: StoryArgs): React.ReactElement => {
28
28
  return (
29
29
  <TextDiff
30
30
  title="A day in the life of a text diff"
package/src/editor.tsx CHANGED
@@ -127,9 +127,7 @@ type WidgetEditorState = {
127
127
  widgetInfo: WidgetInfo;
128
128
  };
129
129
 
130
- const _upgradeWidgetInfo: React.FC<WidgetEditorProps> = (
131
- props,
132
- ): React.ReactElement => {
130
+ const _upgradeWidgetInfo = (props: WidgetEditorProps): React.ReactElement => {
133
131
  // We can't call serialize here because this.refs.widget
134
132
  // doesn't exist before this component is mounted.
135
133
  const filteredProps = _.omit(props, WIDGET_PROP_DENYLIST);
@@ -368,7 +366,7 @@ const imageUrlsFromContent = function (content: string) {
368
366
  return _.map(allMatches(IMAGE_REGEX, content), (capture) => capture[1]);
369
367
  };
370
368
 
371
- type EditorProps = Readonly<{
369
+ type Props = Readonly<{
372
370
  apiOptions: any;
373
371
  className?: string;
374
372
  content: string;
@@ -406,14 +404,14 @@ type DeafultProps = {
406
404
  };
407
405
  };
408
406
 
409
- type EditorState = {
407
+ type State = {
410
408
  showKatexErrors: boolean;
411
409
  textAreaValue: string;
412
410
  katex?: katex;
413
411
  };
414
412
 
415
413
  // eslint-disable-next-line react/no-unsafe
416
- class Editor extends React.Component<EditorProps, EditorState> {
414
+ class Editor extends React.Component<Props, State> {
417
415
  lastUserValue: string | null | undefined;
418
416
  deferredChange: any | null | undefined;
419
417
  widgetIds: any | null | undefined;
@@ -431,7 +429,7 @@ class Editor extends React.Component<EditorProps, EditorState> {
431
429
  warnNoWidgets: false,
432
430
  };
433
431
 
434
- state: EditorState = {
432
+ state: State = {
435
433
  katex: undefined,
436
434
  showKatexErrors: false,
437
435
  textAreaValue: this.props.content,
@@ -463,13 +461,13 @@ class Editor extends React.Component<EditorProps, EditorState> {
463
461
  }
464
462
 
465
463
  // TODO(arun): This is a deprecated method, use the appropriate replacement
466
- UNSAFE_componentWillReceiveProps(nextProps: EditorProps) {
464
+ UNSAFE_componentWillReceiveProps(nextProps: Props) {
467
465
  if (this.props.content !== nextProps.content) {
468
466
  this.setState({textAreaValue: nextProps.content});
469
467
  }
470
468
  }
471
469
 
472
- componentDidUpdate(prevProps: EditorProps) {
470
+ componentDidUpdate(prevProps: Props) {
473
471
  // TODO(alpert): Maybe fix React so this isn't necessary
474
472
  // eslint-disable-next-line react/no-string-refs
475
473
  const textarea = ReactDOM.findDOMNode(this.refs.textarea);
@@ -574,7 +572,7 @@ class Editor extends React.Component<EditorProps, EditorState> {
574
572
  * Calculate the size of all the images in props.content, and send
575
573
  * those sizes to this.props.images using props.onChange.
576
574
  */
577
- _sizeImages: (props: EditorProps) => void = (props: EditorProps) => {
575
+ _sizeImages: (props: Props) => void = (props: Props) => {
578
576
  const imageUrls = imageUrlsFromContent(props.content);
579
577
 
580
578
  // Discard any images in our dimension table that no
@@ -141,13 +141,9 @@ type HeaderProps = {
141
141
  depth: number;
142
142
  };
143
143
 
144
- const Header: React.FC<HeaderProps> = ({
145
- depth,
146
- ...props
147
- }): React.ReactElement => {
144
+ const Header = ({depth, ...props}: HeaderProps): React.ReactElement => {
148
145
  const headerLevel = Math.min(depth, 5) + 1;
149
146
  const HeaderTag = `h${headerLevel}`;
150
- // @ts-expect-error [FEI-5003] - TS2559 - Type '{ children?: ReactNode; }' has no properties in common with type 'IntrinsicAttributes'.
151
147
  return <HeaderTag {...props} />;
152
148
  };
153
149
 
@@ -268,13 +264,13 @@ type LeafContainerProps = {
268
264
  path: Path;
269
265
  shape: Shape;
270
266
  };
271
- const LeafContainer: React.FC<LeafContainerProps> = ({
267
+ const LeafContainer = ({
272
268
  name,
273
269
  controls,
274
270
  children,
275
271
  path,
276
272
  shape,
277
- }): React.ReactElement => {
273
+ }: LeafContainerProps): React.ReactElement => {
278
274
  const hasPreviewHeading = shape.type === "content" || shape.type === "hint";
279
275
  const previewHeading = hasPreviewHeading && (
280
276
  <div className={css(styles.containerHeader)}>
@@ -314,9 +310,7 @@ type ArrayContainerProps = {
314
310
  shape: ArrayShape;
315
311
  actions: ArrayContainerActions;
316
312
  };
317
- const ArrayContainer: React.FC<ArrayContainerProps> = (
318
- props,
319
- ): React.ReactElement => {
313
+ const ArrayContainer = (props: ArrayContainerProps): React.ReactElement => {
320
314
  const {name, controls, children, path, shape, actions} = props;
321
315
  return (
322
316
  <div className={css(styles.container)}>
@@ -347,12 +341,12 @@ type ObjectContainerProps = {
347
341
  children?: React.ReactNode;
348
342
  path: Path;
349
343
  };
350
- const ObjectContainer: React.FC<ObjectContainerProps> = ({
344
+ const ObjectContainer = ({
351
345
  name,
352
346
  controls,
353
347
  children,
354
348
  path,
355
- }): React.ReactElement => {
349
+ }: ObjectContainerProps): React.ReactElement => {
356
350
  const headingEditor = (
357
351
  <div className={css(styles.containerHeader)}>
358
352
  {/* @ts-expect-error [FEI-5003] - TS2322 - Type '{ children: string; depth: number; className: string; }' is not assignable to type 'IntrinsicAttributes & HeaderProps & { children?: ReactNode; }'. */}
@@ -93,6 +93,6 @@ class WithState extends React.Component<Empty, State> {
93
93
  }
94
94
  }
95
95
 
96
- export const Default: React.FC<StoryArgs> = (args): React.ReactElement => {
96
+ export const Default = (args: StoryArgs): React.ReactElement => {
97
97
  return <WithState />;
98
98
  };
@@ -110,6 +110,6 @@ class WithState extends React.Component<Empty, PerseusRadioWidgetOptions> {
110
110
  }
111
111
  }
112
112
 
113
- export const Default: React.FC<StoryArgs> = (args): React.ReactElement => {
113
+ export const Default = (args: StoryArgs): React.ReactElement => {
114
114
  return <WithState />;
115
115
  };
@@ -57,16 +57,12 @@ class WithState extends React.Component<
57
57
  }
58
58
  }
59
59
 
60
- export const EmptyNonInteractive: React.FC<StoryArgs> = (
61
- args,
62
- ): React.ReactElement => {
60
+ export const EmptyNonInteractive = (args: StoryArgs): React.ReactElement => {
63
61
  const props = {choices: [], onChange: (...args) => {}} as const;
64
62
  return <Wrapper {...props} />;
65
63
  };
66
64
 
67
- export const FilledNonInteractive: React.FC<StoryArgs> = (
68
- args,
69
- ): React.ReactElement => {
65
+ export const FilledNonInteractive = (args: StoryArgs): React.ReactElement => {
70
66
  const props = {
71
67
  choices: [
72
68
  "Lamborghini",
@@ -81,6 +77,6 @@ export const FilledNonInteractive: React.FC<StoryArgs> = (
81
77
  return <Wrapper {...props} />;
82
78
  };
83
79
 
84
- export const Interactive: React.FC<StoryArgs> = (args): React.ReactElement => {
80
+ export const Interactive = (args: StoryArgs): React.ReactElement => {
85
81
  return <WithState />;
86
82
  };
@@ -13,7 +13,7 @@ export default {
13
13
  title: "Perseus/Editor/Widgets/Label Image/Behavior",
14
14
  } as Story;
15
15
 
16
- export const Default: React.FC<StoryArgs> = (args): React.ReactElement => {
16
+ export const Default = (args: StoryArgs): React.ReactElement => {
17
17
  const [state, setState] = React.useState({
18
18
  multipleAnswers: false,
19
19
  hideChoicesFromInstructions: false,
@@ -33,7 +33,7 @@ const Wrapper = (props) => (
33
33
  </div>
34
34
  );
35
35
 
36
- export const Empty: React.FC<StoryArgs> = (args): React.ReactElement => {
36
+ export const Empty = (args: StoryArgs): React.ReactElement => {
37
37
  const props = {
38
38
  answers: [],
39
39
  choices: [],
@@ -50,7 +50,7 @@ export const Empty: React.FC<StoryArgs> = (args): React.ReactElement => {
50
50
  return <Wrapper {...props} />;
51
51
  };
52
52
 
53
- export const WithAnswers: React.FC<StoryArgs> = (args): React.ReactElement => {
53
+ export const WithAnswers = (args: StoryArgs): React.ReactElement => {
54
54
  const props = {
55
55
  answers: ["BMW", "Ferrari"],
56
56
  choices: [