@khanacademy/perseus-editor 2.0.1 → 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 (66) hide show
  1. package/CHANGELOG.md +17 -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 +9 -70
  13. package/dist/es/index.js.map +1 -1
  14. package/dist/index.js +9 -70
  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 -6
  33. package/src/components/dropdown-option.tsx +2 -10
  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/diffs/text-diff.tsx +0 -1
  40. package/src/diffs/widget-diff.tsx +0 -2
  41. package/src/editor.tsx +8 -11
  42. package/src/multirenderer-editor.tsx +8 -32
  43. package/src/widgets/__stories__/label-image-editor.stories.tsx +1 -4
  44. package/src/widgets/__stories__/radio-editor.stories.tsx +1 -2
  45. package/src/widgets/categorizer-editor.tsx +0 -1
  46. package/src/widgets/cs-program-editor.tsx +0 -2
  47. package/src/widgets/expression-editor.tsx +0 -2
  48. package/src/widgets/grapher-editor.tsx +0 -1
  49. package/src/widgets/iframe-editor.tsx +0 -2
  50. package/src/widgets/input-number-editor.tsx +0 -1
  51. package/src/widgets/interaction-editor.tsx +0 -1
  52. package/src/widgets/interactive-graph-editor.tsx +0 -1
  53. package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +3 -7
  54. package/src/widgets/label-image/__stories__/behavior.stories.tsx +1 -1
  55. package/src/widgets/label-image/__stories__/marker.stories.tsx +2 -2
  56. package/src/widgets/label-image/__stories__/question-markers.stories.tsx +3 -3
  57. package/src/widgets/label-image/__stories__/select-image.stories.tsx +3 -3
  58. package/src/widgets/label-image/answer-choices.tsx +5 -5
  59. package/src/widgets/label-image/behavior.tsx +3 -3
  60. package/src/widgets/label-image/marker.tsx +5 -6
  61. package/src/widgets/label-image/question-markers.tsx +2 -2
  62. package/src/widgets/label-image/select-image.tsx +2 -5
  63. package/src/widgets/label-image-editor.tsx +3 -3
  64. package/src/widgets/numeric-input-editor.tsx +0 -20
  65. package/src/widgets/transformer-editor.tsx +0 -1
  66. 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.1",
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.1"
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,13 +54,9 @@ 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
- // $FlowFixMe[incompatible-exact]
64
60
  json: [{}],
65
61
  mode: "edit",
66
62
  screen: "desktop",
@@ -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
 
@@ -113,9 +113,6 @@ class Option extends React.Component<OptionProps> {
113
113
 
114
114
  return (
115
115
  <button
116
- // TODO(mdr): We found a new Flow error when upgrading:
117
- // "node (null) This type is incompatible with this.node (HTMLDivElement)"
118
- // $FlowFixMe[incompatible-type](0.52.0->0.53.0)
119
116
  // @ts-expect-error [FEI-5003] - TS2322 - Type 'HTMLButtonElement | null' is not assignable to type 'HTMLDivElement'.
120
117
  ref={(node) => (this.node = node)}
121
118
  value={value}
@@ -129,11 +126,6 @@ class Option extends React.Component<OptionProps> {
129
126
  // @ts-expect-error [FEI-5003] - TS2322 - Type '(value: string) => void' is not assignable to type 'MouseEventHandler<HTMLButtonElement>'.
130
127
  onClick={(value: string) => {
131
128
  if (!disabled && onClick) {
132
- // TODO(mdr): We found a new Flow error here when upgrading
133
- // from 0.35.0 to 0.52.0: "value (unused function
134
- // argument)". This comment was automatically added to
135
- // this file, to suppress the error for now. Please
136
- // consider fixing!
137
129
  // @ts-expect-error [FEI-5003] - TS2554 - Expected 0 arguments, but got 1.
138
130
  onClick(value);
139
131
  }
@@ -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"
@@ -49,7 +49,6 @@ class ImageDiffSide extends React.Component<any> {
49
49
  return (
50
50
  <div key={index}>
51
51
  <div className={className}>
52
- {/* $FlowFixMe[prop-missing]: the alt prop is missing */}
53
52
  {/* @ts-expect-error [FEI-5003] - TS2741 - Property 'alt' is missing in type '{ src: any; title: any; }' but required in type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | "height" | "width" | "title" | "alt" | "trackInteraction" | "preloader" | "allowFullBleed" | "extraGraphie" | "overrideAriaHidden">'. */}
54
53
  <SvgImage
55
54
  src={entry.value}
@@ -227,7 +227,6 @@ class ImageWidgetDiff extends React.Component<any> {
227
227
  "image-removed": beforeSrc !== afterSrc,
228
228
  })}
229
229
  >
230
- {/* $FlowFixMe[prop-missing]: the alt props is missing */}
231
230
  {/* @ts-expect-error [FEI-5003] - TS2741 - Property 'alt' is missing in type '{ src: any; title: any; }' but required in type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | "height" | "width" | "title" | "alt" | "trackInteraction" | "preloader" | "allowFullBleed" | "extraGraphie" | "overrideAriaHidden">'. */}
232
231
  <SvgImage src={beforeSrc} title={beforeSrc} />
233
232
  </div>
@@ -242,7 +241,6 @@ class ImageWidgetDiff extends React.Component<any> {
242
241
  "image-added": beforeSrc !== afterSrc,
243
242
  })}
244
243
  >
245
- {/* $FlowFixMe[prop-missing]: the alt props is missing */}
246
244
  {/* @ts-expect-error [FEI-5003] - TS2741 - Property 'alt' is missing in type '{ src: any; title: any; }' but required in type 'Pick<Readonly<Props> & Readonly<{ children?: ReactNode; }>, "children" | "height" | "width" | "title" | "alt" | "trackInteraction" | "preloader" | "allowFullBleed" | "extraGraphie" | "overrideAriaHidden">'. */}
247
245
  <SvgImage src={afterSrc} title={afterSrc} />
248
246
  </div>
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
@@ -983,7 +981,6 @@ class Editor extends React.Component<EditorProps, EditorState> {
983
981
  function () {
984
982
  Util.textarea.moveCursor(
985
983
  // findDOMNode can return Text but we know this is Element
986
- // $FlowFixMe[incompatible-call]
987
984
  // @ts-expect-error [FEI-5003] - TS2345 - Argument of type 'Element | Text | null' is not assignable to parameter of type 'HTMLTextAreaElement'.
988
985
  textarea,
989
986
  // We want to put the cursor after the widget