diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json
index 414af4209..d786531cc 100644
--- a/locale/defaultMessages.json
+++ b/locale/defaultMessages.json
@@ -1785,28 +1785,6 @@
"src_dot_components_dot_RadioGroupField_dot_4205644805": {
"string": "No results found"
},
- "src_dot_components_dot_RichTextEditor_dot_1603794322": {
- "context": "dialog header",
- "string": "Add Image Link"
- },
- "src_dot_components_dot_RichTextEditor_dot_2049070632": {
- "context": "replace image, button",
- "string": "Replace"
- },
- "src_dot_components_dot_RichTextEditor_dot_2160163587": {
- "context": "button",
- "string": "Add or Edit Link"
- },
- "src_dot_components_dot_RichTextEditor_dot_286109898": {
- "context": "rich text error",
- "string": "Invalid content"
- },
- "src_dot_components_dot_RichTextEditor_dot_2925475978": {
- "string": "URL Linked"
- },
- "src_dot_components_dot_RichTextEditor_dot_4035057905": {
- "string": "Image URL"
- },
"src_dot_components_dot_RowNumberSelect_dot_1154361791": {
"string": "No of Rows:"
},
diff --git a/package-lock.json b/package-lock.json
index 73d557208..99cf8bf48 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1949,6 +1949,35 @@
}
}
},
+ "@editorjs/editorjs": {
+ "version": "2.19.0",
+ "resolved": "https://registry.npmjs.org/@editorjs/editorjs/-/editorjs-2.19.0.tgz",
+ "integrity": "sha512-8PUVaBZx69IrG8dNrE+FZbHSiRTR8ql8L/cmEi1mOdEdTqnOLq5Wv9dgemK00mBWEgNoavMAjtGQpItGknAa8A==",
+ "requires": {
+ "codex-notifier": "^1.1.2",
+ "codex-tooltip": "^1.0.1"
+ }
+ },
+ "@editorjs/header": {
+ "version": "2.6.0",
+ "resolved": "https://registry.npmjs.org/@editorjs/header/-/header-2.6.0.tgz",
+ "integrity": "sha512-1psNX/irDjJ8Bp1l7DjkYWz7IBtjVIRANk7kPkNoY2CfAeeCFYbJmMlXdqTF2WeAjYv2WMy5ey/aR5fTccgFaw=="
+ },
+ "@editorjs/image": {
+ "version": "2.6.0",
+ "resolved": "https://registry.npmjs.org/@editorjs/image/-/image-2.6.0.tgz",
+ "integrity": "sha512-lX4Pz9cW3gGFzlmYLRAsBXTiqUG/MRG7NK4QVU+n/VnUWPU1e791eiIpgRLHfpPj6Maaw5a+GRut90D5EdXtqg=="
+ },
+ "@editorjs/list": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/@editorjs/list/-/list-1.6.0.tgz",
+ "integrity": "sha512-2oJ3Nj3lDcIKS6GcrHYHzUUabIjg7zlXTYXQWdEWXevbnM0/fq+4psyI/AYtqbaa3jN+bycPBIW4OG3zD+3d5A=="
+ },
+ "@editorjs/quote": {
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/@editorjs/quote/-/quote-2.4.0.tgz",
+ "integrity": "sha512-IWOBWjL2ngPP63GcIAltyD9kc7OVZFma4kS+T5JRHvKKDspYsnmrxsbRmCPc+coZQzqPxXHkiOZuNMdmGX/Y3w=="
+ },
"@emotion/cache": {
"version": "10.0.19",
"resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-10.0.19.tgz",
@@ -8778,6 +8807,16 @@
"urlgrey": "0.4.4"
}
},
+ "codex-notifier": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/codex-notifier/-/codex-notifier-1.1.2.tgz",
+ "integrity": "sha512-DCp6xe/LGueJ1N5sXEwcBc3r3PyVkEEDNWCVigfvywAkeXcZMk9K41a31tkEFBW0Ptlwji6/JlAb49E3Yrxbtg=="
+ },
+ "codex-tooltip": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/codex-tooltip/-/codex-tooltip-1.0.1.tgz",
+ "integrity": "sha512-1xLb1NZbxguNtf02xBRhDphq/EXvMMeEbY0ievjQTHqf8UjXsD41evGk9rqcbjpl+JOjNgtwnp1OaU/X/h6fhQ=="
+ },
"coffeescript": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-2.5.1.tgz",
@@ -10306,6 +10345,16 @@
"safer-buffer": "^2.1.0"
}
},
+ "editorjs-inline-tool": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/editorjs-inline-tool/-/editorjs-inline-tool-0.4.0.tgz",
+ "integrity": "sha512-Ppb4e8IFPjWuNcoNM4tg9bDSo7FgMYAlqP4UhuV5W2JoJBubV5pUcpLrFrSyGTt1HJVEpbrib134zf4wxO+7VA=="
+ },
+ "editorjs-undo": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/editorjs-undo/-/editorjs-undo-0.1.4.tgz",
+ "integrity": "sha512-YW+5x8tqMXQ+iQD+1OrroqUT1O/erDrysZLJ+8yB+zjls55rwUw9P7hdQCJ0DFm+WDSaRuEXb2p3dQ6VdrkYCg=="
+ },
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
diff --git a/package.json b/package.json
index 87724860c..f9f472a16 100644
--- a/package.json
+++ b/package.json
@@ -17,6 +17,11 @@
"npm": ">=6.11.0"
},
"dependencies": {
+ "@editorjs/editorjs": "^2.19.0",
+ "@editorjs/header": "^2.6.0",
+ "@editorjs/image": "^2.6.0",
+ "@editorjs/list": "^1.6.0",
+ "@editorjs/quote": "^2.4.0",
"@material-ui/core": "^4.5.1",
"@material-ui/icons": "^4.5.1",
"@material-ui/styles": "^4.5.2",
@@ -36,6 +41,8 @@
"draft-js": "^0.10.5",
"draftail": "^1.2.1",
"draftjs-to-html": "^0.9.1",
+ "editorjs-inline-tool": "^0.4.0",
+ "editorjs-undo": "^0.1.4",
"fast-array-diff": "^0.2.0",
"fuzzaldrin": "^2.1.0",
"graphql": "^14.4.2",
diff --git a/src/Baseline.tsx b/src/Baseline.tsx
index 169464771..db200dda8 100644
--- a/src/Baseline.tsx
+++ b/src/Baseline.tsx
@@ -1,12 +1,19 @@
import CssBaseline from "@material-ui/core/CssBaseline";
-import { createStyles, withStyles } from "@material-ui/core/styles";
+import { createStyles, Theme, withStyles } from "@material-ui/core/styles";
+import { fade } from "@material-ui/core/styles/colorManipulator";
import React from "react";
-const styles = createStyles({
+const styles = createStyles((theme: Theme) => ({
"@global": {
- "@import": "url('https://rsms.me/inter/inter.css')"
+ "@import": "url('https://rsms.me/inter/inter.css')",
+
+ // For some reason @import clause must be put on top
+ // eslint-disable-next-line sort-keys
+ "::selection": {
+ background: fade(theme.palette.primary.main, 0.2)
+ }
}
-});
+}));
const Baseline = withStyles(styles, {
name: "Baseline"
diff --git a/src/categories/components/CategoryBackground/CategoryBackground.tsx b/src/categories/components/CategoryBackground/CategoryBackground.tsx
index b801afa95..29e4a93f4 100644
--- a/src/categories/components/CategoryBackground/CategoryBackground.tsx
+++ b/src/categories/components/CategoryBackground/CategoryBackground.tsx
@@ -13,7 +13,7 @@ import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { CategoryDetails_category_backgroundImage } from "../../types/CategoryDetails";
-import { FormData } from "../CategoryUpdatePage";
+import { CategoryUpdateData } from "../CategoryUpdatePage/form";
const useStyles = makeStyles(
theme => ({
@@ -42,7 +42,7 @@ const useStyles = makeStyles(
);
export interface CategoryBackgroundProps {
- data: FormData;
+ data: CategoryUpdateData;
image: CategoryDetails_category_backgroundImage;
onChange: (event: React.ChangeEvent) => void;
onImageDelete: () => void;
diff --git a/src/categories/components/CategoryCreatePage/CategoryCreatePage.tsx b/src/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
index 0ac329841..91b91d136 100644
--- a/src/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
+++ b/src/categories/components/CategoryCreatePage/CategoryCreatePage.tsx
@@ -2,43 +2,23 @@ import AppHeader from "@saleor/components/AppHeader";
import { CardSpacer } from "@saleor/components/CardSpacer";
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
import Container from "@saleor/components/Container";
-import Form from "@saleor/components/Form";
-import Metadata, { MetadataFormData } from "@saleor/components/Metadata";
+import Metadata from "@saleor/components/Metadata";
import PageHeader from "@saleor/components/PageHeader";
import SaveButtonBar from "@saleor/components/SaveButtonBar";
import SeoForm from "@saleor/components/SeoForm";
import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment";
import { sectionNames } from "@saleor/intl";
-import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
-import { ContentState, convertToRaw, RawDraftContentState } from "draft-js";
import React from "react";
import { useIntl } from "react-intl";
import CategoryDetailsForm from "../../components/CategoryDetailsForm";
-
-export interface FormData extends MetadataFormData {
- description: RawDraftContentState;
- name: string;
- slug: string;
- seoTitle: string;
- seoDescription: string;
-}
-
-const initialData: FormData = {
- description: convertToRaw(ContentState.createFromText("")),
- metadata: [],
- name: "",
- privateMetadata: [],
- seoDescription: "",
- seoTitle: "",
- slug: ""
-};
+import CategoryCreateForm, { CategoryCreateData } from "./form";
export interface CategoryCreatePageProps {
errors: ProductErrorFragment[];
disabled: boolean;
saveButtonBarState: ConfirmButtonTransitionState;
- onSubmit(data: FormData);
+ onSubmit(data: CategoryCreateData);
onBack();
}
@@ -50,63 +30,57 @@ export const CategoryCreatePage: React.FC = ({
saveButtonBarState
}) => {
const intl = useIntl();
- const {
- makeChangeHandler: makeMetadataChangeHandler
- } = useMetadataChangeTrigger();
return (
-
@@ -33484,520 +32175,22 @@ exports[`Storyshots Views / Categories / Update category default 1`] = `
class="FormSpacer-spacer-id"
/>
-
-
- Category Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Category Description
+
+
+
@@ -34216,195 +32409,13 @@ Ctrl + K"
class="CardTitle-hr-id"
/>
-
-
-
+
+
-
-
-
+
+
-
-
- Category Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Category Description
+
+
This field is required
-
+
@@ -35509,195 +32992,13 @@ Ctrl + K"
class="CardTitle-hr-id"
/>
-
-
-
+
+
-
-
-
+
+
-
-
- Category Description
-
-
-
+ Category Description
+
+
+
@@ -36951,520 +33931,22 @@ exports[`Storyshots Views / Categories / Update category no background 1`] = `
class="FormSpacer-spacer-id"
/>
-
-
- Category Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Category Description
+
+
+
@@ -37638,195 +34120,13 @@ Ctrl + K"
class="CardTitle-hr-id"
/>
-
-
-
+
+
-
-
-
+
+
-
-
- Category Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Category Description
+
+
+
@@ -38921,195 +34696,13 @@ Ctrl + K"
class="CardTitle-hr-id"
/>
-
-
-
+
+
-
-
-
+
+
-
-
- Category Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Category Description
+
+
+
@@ -40209,195 +35277,13 @@ Ctrl + K"
class="CardTitle-hr-id"
/>
-
-
-
+
+
-
-
-
+
+
-
-
- Category Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Category Description
+
+
+
@@ -41492,195 +35853,13 @@ Ctrl + K"
class="CardTitle-hr-id"
/>
-
-
-
+
+
-
-
-
+
+
-
-
- Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Description
+
+
+
@@ -44737,525 +38391,24 @@ exports[`Storyshots Views / Collections / Collection details form errors 1`] = `
class="FormSpacer-spacer-id"
/>
-
-
- Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Description
+
+
This field is required
-
+
@@ -46631,316 +39784,22 @@ exports[`Storyshots Views / Collections / Collection details loading 1`] = `
class="FormSpacer-spacer-id"
/>
@@ -47751,520 +40610,22 @@ exports[`Storyshots Views / Collections / Collection details no products 1`] = `
class="FormSpacer-spacer-id"
/>
-
-
- Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Description
+
+
+
@@ -50706,316 +43067,22 @@ exports[`Storyshots Views / Collections / Create collection default 1`] = `
class="FormSpacer-spacer-id"
/>
@@ -51547,321 +43614,24 @@ exports[`Storyshots Views / Collections / Create collection form errors 1`] = `
class="FormSpacer-spacer-id"
/>
-
+ Description
+
+
This field is required
-
+
@@ -52395,316 +44165,22 @@ exports[`Storyshots Views / Collections / Create collection loading 1`] = `
class="FormSpacer-spacer-id"
/>
@@ -112831,520 +104307,22 @@ exports[`Storyshots Views / Pages / Page details default 1`] = `
class="FormSpacer-spacer-id"
/>
-
-
- Content
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Content
+
+
+
@@ -113938,520 +104916,22 @@ exports[`Storyshots Views / Pages / Page details form errors 1`] = `
class="FormSpacer-spacer-id"
/>
-
-
- Content
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Content
+
+
+
@@ -115052,316 +105532,22 @@ exports[`Storyshots Views / Pages / Page details loading 1`] = `
class="FormSpacer-spacer-id"
/>
@@ -138025,316 +128211,22 @@ exports[`Storyshots Views / Products / Create product When loading 1`] = `
class="FormSpacer-spacer-id"
/>
@@ -139312,316 +129204,22 @@ exports[`Storyshots Views / Products / Create product default 1`] = `
class="FormSpacer-spacer-id"
/>
@@ -140588,316 +130186,22 @@ exports[`Storyshots Views / Products / Create product form errors 1`] = `
class="FormSpacer-spacer-id"
/>
@@ -146224,520 +135528,22 @@ exports[`Storyshots Views / Products / Product edit form errors 1`] = `
class="FormSpacer-spacer-id"
/>
-
-
- Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Description
+
+
+
@@ -148747,520 +137553,22 @@ exports[`Storyshots Views / Products / Product edit no product attributes 1`] =
class="FormSpacer-spacer-id"
/>
-
-
- Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Description
+
+
+
@@ -150995,520 +139303,22 @@ exports[`Storyshots Views / Products / Product edit no stock and no variants 1`]
class="FormSpacer-spacer-id"
/>
-
-
- Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Description
+
+
+
@@ -153470,520 +141280,22 @@ exports[`Storyshots Views / Products / Product edit no stock, no variants and no
class="FormSpacer-spacer-id"
/>
-
-
- Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Description
+
+
+
@@ -155882,520 +143194,22 @@ exports[`Storyshots Views / Products / Product edit no variants 1`] = `
class="FormSpacer-spacer-id"
/>
-
-
- Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Description
+
+
+
@@ -158491,520 +145305,22 @@ exports[`Storyshots Views / Products / Product edit when data is fully loaded 1`
class="FormSpacer-spacer-id"
/>
-
-
- Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Description
+
+
+
@@ -161004,316 +147320,22 @@ exports[`Storyshots Views / Products / Product edit when loading data 1`] = `
class="FormSpacer-spacer-id"
/>
@@ -162422,520 +148444,22 @@ exports[`Storyshots Views / Products / Product edit when product has no images 1
class="FormSpacer-spacer-id"
/>
-
-
- Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Description
+
+
+
@@ -164885,520 +150409,22 @@ exports[`Storyshots Views / Products / Product edit when product has no variants
class="FormSpacer-spacer-id"
/>
-
-
- Description
-
-
-
-
-
-
-
-
-
-
-
-
-
- strikethrough
-
-
-
-
-
-
-
-
-
-
-
- blockquote
-
-
-
-
-
-
- -
-
-
-
- ol
-
-
-
-
-
-
-
-
-
-
-
-
+ Description
+
+
+
diff --git a/src/storybook/config.js b/src/storybook/config.js
index 28b2fc2ef..d088e83e8 100644
--- a/src/storybook/config.js
+++ b/src/storybook/config.js
@@ -35,7 +35,6 @@ function loadStories() {
require("./stories/components/Percent");
require("./stories/components/PhoneField");
require("./stories/components/PriceField");
- require("./stories/components/RichTextEditor");
require("./stories/components/SaveButtonBar");
require("./stories/components/SaveFilterTabDialog");
require("./stories/components/SingleSelectField");
diff --git a/src/storybook/stories/components/RichTextEditor.tsx b/src/storybook/stories/components/RichTextEditor.tsx
deleted file mode 100644
index e645acb4f..000000000
--- a/src/storybook/stories/components/RichTextEditor.tsx
+++ /dev/null
@@ -1,119 +0,0 @@
-import RichTextEditor from "@saleor/components/RichTextEditor";
-import { storiesOf } from "@storybook/react";
-import { RawDraftContentState } from "draft-js";
-import React from "react";
-
-import CardDecorator from "../../CardDecorator";
-import Decorator from "../../Decorator";
-
-export const content: RawDraftContentState = {
- blocks: [
- {
- data: {},
- depth: 0,
- entityRanges: [],
- inlineStyleRanges: [{ length: 4, offset: 0, style: "BOLD" }],
- key: "rosn",
- text: "bold",
- type: "unstyled"
- },
- {
- data: {},
- depth: 0,
- entityRanges: [],
- inlineStyleRanges: [{ length: 6, offset: 0, style: "ITALIC" }],
- key: "6tbch",
- text: "italic",
- type: "unstyled"
- },
- {
- data: {},
- depth: 0,
- entityRanges: [],
- inlineStyleRanges: [{ length: 13, offset: 0, style: "STRIKETHROUGH" }],
- key: "1p044",
- text: "strikethrough",
- type: "unstyled"
- },
- {
- data: {},
- depth: 0,
- entityRanges: [],
- inlineStyleRanges: [],
- key: "aven6",
- text: "h1",
- type: "header-one"
- },
- {
- data: {},
- depth: 0,
- entityRanges: [],
- inlineStyleRanges: [],
- key: "9rabl",
- text: "h2",
- type: "header-two"
- },
- {
- data: {},
- depth: 0,
- entityRanges: [],
- inlineStyleRanges: [],
- key: "bv0ac",
- text: "h3",
- type: "header-three"
- },
- {
- data: {},
- depth: 0,
- entityRanges: [],
- inlineStyleRanges: [],
- key: "2ip7q",
- text: "blockquote",
- type: "blockquote"
- },
- {
- data: {},
- depth: 0,
- entityRanges: [],
- inlineStyleRanges: [],
- key: "8r8ss",
- text: "ul",
- type: "unordered-list-item"
- },
- {
- data: {},
- depth: 0,
- entityRanges: [],
- inlineStyleRanges: [],
- key: "911hc",
- text: "ol",
- type: "ordered-list-item"
- },
- {
- data: {},
- depth: 0,
- entityRanges: [{ key: 0, length: 4, offset: 0 }],
- inlineStyleRanges: [],
- key: "5aejo",
- text: "link",
- type: "unstyled"
- }
- ],
- entityMap: {
- "0": { data: { url: "#" }, mutability: "MUTABLE", type: "LINK" }
- }
-};
-storiesOf("Generics / Rich text editor", module)
- .addDecorator(CardDecorator)
- .addDecorator(Decorator)
- .add("default", () => (
- undefined}
- />
- ));
diff --git a/src/storybook/stories/pages/PageDetailsPage.tsx b/src/storybook/stories/pages/PageDetailsPage.tsx
index 51af7b057..f8814abe9 100644
--- a/src/storybook/stories/pages/PageDetailsPage.tsx
+++ b/src/storybook/stories/pages/PageDetailsPage.tsx
@@ -1,9 +1,9 @@
+import { PageData } from "@saleor/pages/components/PageDetailsPage/form";
import { PageErrorCode } from "@saleor/types/globalTypes";
import { storiesOf } from "@storybook/react";
import React from "react";
import PageDetailsPage, {
- PageDetailsPageFormData,
PageDetailsPageProps
} from "../../../pages/components/PageDetailsPage";
import { page } from "../../../pages/fixtures";
@@ -36,7 +36,7 @@ storiesOf("Views / Pages / Page details", module)
"isPublished",
"seoDescription",
"seoTitle"
- ] as Array).map(field => ({
+ ] as Array).map(field => ({
__typename: "PageError",
code: PageErrorCode.INVALID,
field
diff --git a/src/translations/components/TranslationFields/TranslationFields.tsx b/src/translations/components/TranslationFields/TranslationFields.tsx
index 1b82272ab..953300a1d 100644
--- a/src/translations/components/TranslationFields/TranslationFields.tsx
+++ b/src/translations/components/TranslationFields/TranslationFields.tsx
@@ -1,3 +1,4 @@
+import { OutputData } from "@editorjs/editorjs";
import Button from "@material-ui/core/Button";
import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
@@ -36,7 +37,7 @@ export interface TranslationFieldsProps {
saveButtonState: ConfirmButtonTransitionState;
onEdit: (field: string) => void;
onDiscard: () => void;
- onSubmit: (field: string, data: string) => void;
+ onSubmit: (field: string, data: string | OutputData) => void;
}
const useStyles = makeStyles(
diff --git a/src/translations/components/TranslationFields/TranslationFieldsRich.tsx b/src/translations/components/TranslationFields/TranslationFieldsRich.tsx
index 1a940fc45..51dde46b7 100644
--- a/src/translations/components/TranslationFields/TranslationFieldsRich.tsx
+++ b/src/translations/components/TranslationFields/TranslationFieldsRich.tsx
@@ -1,8 +1,9 @@
+import { OutputData } from "@editorjs/editorjs";
import Typography from "@material-ui/core/Typography";
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
-import DraftRenderer from "@saleor/components/DraftRenderer";
-import Form from "@saleor/components/Form";
import RichTextEditor from "@saleor/components/RichTextEditor";
+import RichTextEditorContent from "@saleor/components/RichTextEditor/RichTextEditorContent";
+import useRichText from "@saleor/utils/richText/useRichText";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
@@ -14,7 +15,7 @@ interface TranslationFieldsRichProps {
initial: string;
saveButtonState: ConfirmButtonTransitionState;
onDiscard: () => void;
- onSubmit: (data: string) => void;
+ onSubmit: (data: OutputData) => void;
}
const TranslationFieldsRich: React.FC = ({
@@ -26,40 +27,39 @@ const TranslationFieldsRich: React.FC = ({
onSubmit
}) => {
const intl = useIntl();
+ const [content, change] = useRichText({
+ initial,
+ triggerChange: () => undefined
+ });
+
+ const submit = () => onSubmit(content.current);
return edit ? (
-
+
) : initial === null ? (
) : (
-
+
);
};
diff --git a/src/translations/components/TranslationFields/TranslationFieldsSave.tsx b/src/translations/components/TranslationFields/TranslationFieldsSave.tsx
index ab2a40b02..c925414c5 100644
--- a/src/translations/components/TranslationFields/TranslationFieldsSave.tsx
+++ b/src/translations/components/TranslationFields/TranslationFieldsSave.tsx
@@ -43,7 +43,7 @@ const TranslationFieldsSave: React.FC = props => {
>
-