From b437af90d15cf05dc88433b6cf185af3041faf25 Mon Sep 17 00:00:00 2001 From: Kwinten Date: Sat, 14 May 2022 22:26:31 +0800 Subject: [PATCH] show the content field name --- admin/src/components/ReactMdEditor/index.js | 137 ++++++++++++-------- package.json | 7 +- 2 files changed, 90 insertions(+), 54 deletions(-) diff --git a/admin/src/components/ReactMdEditor/index.js b/admin/src/components/ReactMdEditor/index.js index ccf7317..915597b 100644 --- a/admin/src/components/ReactMdEditor/index.js +++ b/admin/src/components/ReactMdEditor/index.js @@ -5,6 +5,10 @@ import MediaLib from "../MediaLib"; import styled from "styled-components"; import "@uiw/react-markdown-preview/dist/markdown.css"; import "@uiw/react-md-editor/dist/markdown-editor.css"; +import { Stack } from "@strapi/design-system/Stack"; +import { Box } from "@strapi/design-system/Box"; +import { Typography } from "@strapi/design-system/Typography"; +import { useIntl } from "react-intl"; const Wrapper = styled.div` > div:nth-child(2) { @@ -48,7 +52,17 @@ const Wrapper = styled.div` } `; -const Editor = ({ onChange, name, value }) => { +const Editor = ({ + name, + onChange, + value, + intlLabel, + disabled, + error, + description, + required, +}) => { + const { formatMessage } = useIntl(); const [mediaLibVisible, setMediaLibVisible] = useState(false); const handleToggleMediaLib = () => setMediaLibVisible((prev) => !prev); @@ -70,57 +84,78 @@ const Editor = ({ onChange, name, value }) => { handleToggleMediaLib(); }; return ( - - - - - ), - execute: (state, api) => { - handleToggleMediaLib(); + + + + {formatMessage(intlLabel)} + + {required && ( + + * + + )} + + + + + + ), + execute: (state, api) => { + handleToggleMediaLib(); + }, }, - }, - commands.unorderedListCommand, - commands.orderedListCommand, - commands.checkedListCommand, - commands.codeEdit, - commands.codeLive, - commands.codePreview, - commands.fullscreen, - ]} - value={value || ""} - onChange={(newValue) => { - onChange({ target: { name, value: newValue || "" } }); - }} - /> -
- - - + commands.unorderedListCommand, + commands.orderedListCommand, + commands.checkedListCommand, + commands.codeEdit, + commands.codeLive, + commands.codePreview, + commands.fullscreen, + ]} + value={value || ""} + onChange={(newValue) => { + onChange({ target: { name, value: newValue || "" } }); + }} + /> +
+ + + + {error && ( + + {formatMessage({ id: error, defaultMessage: error })} + + )} + {description && ( + {formatMessage(description)} + )} + ); }; diff --git a/package.json b/package.json index 4e189c2..ddd95dd 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "strapi-plugin-wysiwsg-react-md-editor", - "version": "4.1.3", - "description": "This is a strapi rich text editor plugin using react md editor.", + "version": "4.1.4", + "description": "Replaces the default Strapi WYSIWYG editor with react md editor.", "strapi": { "name": "wysiwsg-react-md-editor", "icon": "plug", - "description": "This is a strapi rich text editor plugin using react md editor.", + "displayName": "React MD Editor", + "description": "Replaces the default Strapi WYSIWYG editor with react md editor.", "required": false, "kind": "plugin" },