Skip to content

Commit d49f330

Browse files
authored
Merge pull request #468 from guardian/dblatcher/remove-animation-exports
remove animation exports
2 parents d21c410 + a0eb8f7 commit d49f330

File tree

10 files changed

+1081
-1259
lines changed

10 files changed

+1081
-1259
lines changed

.changeset/neat-deserts-enjoy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@guardian/prosemirror-elements": minor
3+
---
4+
5+
remove auto-animate and export field description interfaces

demo/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { schema as basicSchema, marks } from "prosemirror-schema-basic";
1010
import { EditorState } from "prosemirror-state";
1111
import { EditorView } from "prosemirror-view";
1212
import { buildElementPlugin, undefinedDropdownValue } from "../src";
13-
import { keyTakeawaysElement } from "../src/elements/alt-style/AltStyleElementForm";
1413
import { createCalloutElement } from "../src/elements/callout/Callout";
1514
import { createCartoonElement } from "../src/elements/cartoon/CartoonForm";
1615
import { codeElement } from "../src/elements/code/CodeElementForm";
@@ -23,6 +22,7 @@ import { transformElementOut } from "../src/elements/helpers/transform";
2322
import type { MediaPayload } from "../src/elements/helpers/types/Media";
2423
import { createImageElement } from "../src/elements/image/ImageElementForm";
2524
import { createInteractiveElement } from "../src/elements/interactive/InteractiveForm";
25+
import { keyTakeawaysElement } from "../src/elements/key-takeaways/KeyTakeawaysForm";
2626
import { membershipElement } from "../src/elements/membership/MembershipForm";
2727
import { nestedElement } from "../src/elements/nested/NestedElementForm";
2828
import { pullquoteElement } from "../src/elements/pullquote/PullquoteForm";

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"@emotion/core": "11.0.0",
2626
"@emotion/react": "11.1.5",
2727
"@emotion/styled": "11.1.5",
28-
"@formkit/auto-animate": "^0.8.2",
2928
"@guardian/src-button": "^3.8.0",
3029
"@guardian/src-checkbox": "^3.8.0",
3130
"@guardian/src-foundations": "^3.7.0",
@@ -85,5 +84,6 @@
8584
"webpack-cli": "5.1.4",
8685
"webpack-dev-server": "5.2.0",
8786
"webpack-node-externals": "^3.0.0"
88-
}
87+
},
88+
"packageManager": "yarn@1.22.22"
8989
}

src/elements/alt-style/AltStyleElementForm.tsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import styled from "@emotion/styled";
22
import { neutral, space } from "@guardian/src-foundations";
33
import React from "react";
4-
import { DemoFieldWrapper } from "../../editorial-source-components/DemoFieldWrapper";
54
import { FieldLayoutVertical } from "../../editorial-source-components/FieldLayout";
65
import {
76
actionSpacing,
@@ -16,12 +15,10 @@ import type {
1615
import { AltStyleElementWrapper } from "../../renderers/react/AltStyleElementWrapper";
1716
import { createReactElementSpec } from "../../renderers/react/createReactElementSpec";
1817
import { Body } from "../../renderers/react/ElementWrapper";
19-
import { useAutoAnimate } from "../../renderers/react/useAutoAnimate";
2018
import {
2119
LeftRepeaterActionControls,
2220
RightRepeaterActionControls,
2321
} from "../../renderers/react/WrapperControls";
24-
import { keyTakeawaysFields } from "./AltStyleElementSpec";
2522

2623
export const AltStyleElementTestId = "AltStyleElement";
2724

@@ -81,12 +78,10 @@ export const createReactAltStylesElementSpec = <
8178
fieldDescriptions,
8279
component: ({ fields }) => {
8380
const repeaterField = repeaterFieldExtractor(fields);
84-
const [parent] = useAutoAnimate();
8581
return (
8682
<FieldLayoutVertical
8783
data-cy={AltStyleElementTestId}
8884
useAlternateStyles={true}
89-
ref={parent}
9085
>
9186
{repeaterField.children.map((child, index) => (
9287
// Use field ID as key instead of node index to avoid React render conflicts
@@ -116,22 +111,3 @@ export const createReactAltStylesElementSpec = <
116111
},
117112
wrapperComponent: AltStyleElementWrapper,
118113
});
119-
120-
export const keyTakeawaysElement = createReactAltStylesElementSpec(
121-
keyTakeawaysFields,
122-
(fields) => fields.repeater,
123-
(repeaterChild) => (
124-
<>
125-
<DemoFieldWrapper
126-
field={repeaterChild.title}
127-
showHeading={false}
128-
useAlternateStyles={true}
129-
/>
130-
<DemoFieldWrapper
131-
field={repeaterChild.content}
132-
showHeading={false}
133-
useAlternateStyles={true}
134-
/>
135-
</>
136-
)
137-
);

src/elements/helpers/__tests__/transformFixtures.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ import { createTestSchema } from "../test";
1616
import { transformElementIn, transformElementOut } from "../transform";
1717
import { allElementFixtures } from "./fixtures";
1818

19-
jest.mock("@formkit/auto-animate", () => ({
20-
autoAnimate: jest.fn(),
21-
}));
22-
2319
describe("Element fixtures", () => {
2420
/**
2521
* This spec runs every fixture declared in `./fixtures/index.ts` through
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { DemoFieldWrapper } from "../../editorial-source-components/DemoFieldWrapper";
2+
import { createReactAltStylesElementSpec } from "../alt-style/AltStyleElementForm";
3+
import { keyTakeawaysFields } from "./KeyTakeawaysSpec";
4+
5+
export const keyTakeawaysElement = createReactAltStylesElementSpec(
6+
keyTakeawaysFields,
7+
(fields) => fields.repeater,
8+
(repeaterChild) => (
9+
<>
10+
<DemoFieldWrapper
11+
field={repeaterChild.title}
12+
showHeading={false}
13+
useAlternateStyles={true}
14+
/>
15+
<DemoFieldWrapper
16+
field={repeaterChild.content}
17+
showHeading={false}
18+
useAlternateStyles={true}
19+
/>
20+
</>
21+
)
22+
);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { createNestedElementField } from "../../plugin/fieldViews/NestedElementFieldView";
2+
import { createRepeaterField } from "../../plugin/fieldViews/RepeaterFieldView";
3+
import { createTextField } from "../../plugin/fieldViews/TextFieldView";
4+
import { required } from "../../plugin/helpers/validation";
5+
import { useTyperighterAttrs } from "../helpers/typerighter";
6+
7+
export const keyTakeawaysFields = {
8+
repeater: createRepeaterField(
9+
{
10+
title: createTextField({
11+
rows: 1,
12+
isResizeable: false,
13+
validators: [required("Title is required")],
14+
}),
15+
content: createNestedElementField({
16+
isResizeable: false,
17+
placeholder: "Don't show description",
18+
content: "block*",
19+
marks: "em strong link",
20+
attrs: useTyperighterAttrs,
21+
minRows: 6,
22+
validators: [required("Body is required")],
23+
}),
24+
},
25+
1
26+
),
27+
};

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export type {
77
export { buildElementPlugin } from "./plugin/element";
88
export { fieldGroupName, isProseMirrorElement } from "./plugin/nodeSpec";
99
export type { CustomField, Field } from "./plugin/types/Element";
10-
1110
export type { Options } from "./plugin/fieldViews/DropdownFieldView";
1211
export type { FieldView } from "./plugin/fieldViews/FieldView";
1312
export { createTextField } from "./plugin/fieldViews/TextFieldView";
@@ -59,3 +58,7 @@ export {
5958
INNER_EDITOR_BLUR,
6059
} from "./plugin/fieldViews/NestedElementFieldView";
6160
export { RepeaterFieldMapIDKey } from "./plugin/helpers/constants";
61+
export { RepeaterField } from "./plugin/types/Element";
62+
export { CustomFieldDescription } from "./plugin/fieldViews/CustomFieldView";
63+
export { TextFieldDescription } from "./plugin/fieldViews/TextFieldView";
64+
export { RepeaterFieldDescription } from "./plugin/fieldViews/RepeaterFieldView";

src/renderers/react/useAutoAnimate.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)