Skip to content

Commit

Permalink
Merge pull request #22 from kwinyyyc/release/v4.3.0
Browse files Browse the repository at this point in the history
Release/v4.3.0
  • Loading branch information
kwinyyyc authored Jan 1, 2023
2 parents 62f135e + 0de0da2 commit 8c8563e
Show file tree
Hide file tree
Showing 3 changed files with 1,198 additions and 505 deletions.
22 changes: 8 additions & 14 deletions admin/src/components/ReactMdEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import MDEditor, { commands } from "@uiw/react-md-editor";
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 "@uiw/react-md-editor/dist/mdeditor.min.css";
import { Stack } from "@strapi/design-system/Stack";
import { Box } from "@strapi/design-system/Box";
import { Typography } from "@strapi/design-system/Typography";
Expand Down Expand Up @@ -50,9 +50,6 @@ const Wrapper = styled.div`
.w-md-editor-text {
margin: 0;
}
.wmde-markdown {
display: none;
}
.w-md-editor-preview ol {
list-style: auto;
}
Expand All @@ -70,7 +67,7 @@ const Editor = ({
}) => {
const { formatMessage } = useIntl();
const [mediaLibVisible, setMediaLibVisible] = useState(false);
const [ mediaLibSelection, setMediaLibSelection ] = useState(-1);
const [mediaLibSelection, setMediaLibSelection] = useState(-1);

const handleToggleMediaLib = () => setMediaLibVisible((prev) => !prev);

Expand All @@ -79,8 +76,11 @@ const Editor = ({
assets.map((asset) => {
if (asset.mime.includes("image")) {
const imgTag = ` ![](${asset.url}) `;
if (mediaLibSelection > -1){
newValue = value.substring(0,mediaLibSelection) + imgTag + value.substring(mediaLibSelection)
if (mediaLibSelection > -1) {
newValue =
value.substring(0, mediaLibSelection) +
imgTag +
value.substring(mediaLibSelection);
} else {
newValue = `${newValue}${imgTag}`;
}
Expand All @@ -90,6 +90,7 @@ const Editor = ({
onChange({ target: { name, value: newValue || "" } });
handleToggleMediaLib();
};

return (
<Stack size={1}>
<Box>
Expand Down Expand Up @@ -142,20 +143,13 @@ const Editor = ({
commands.unorderedListCommand,
commands.orderedListCommand,
commands.checkedListCommand,
commands.divider,
commands.codeEdit,
commands.codeLive,
commands.codePreview,
commands.divider,
commands.fullscreen,
]}
value={value || ""}
onChange={(newValue) => {
onChange({ target: { name, value: newValue || "" } });
}}
/>
<div style={{ padding: "50px 0 0 0" }} />
<MDEditor.Markdown source={value || ""} />
<MediaLib
isOpen={mediaLibVisible}
onChange={handleChangeAssets}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "strapi-plugin-wysiwyg-react-md-editor",
"version": "4.2.0",
"version": "4.3.0",
"description": "Replaces the default Strapi WYSIWYG editor with react md editor.",
"strapi": {
"name": "wysiwyg-react-md-editor",
Expand All @@ -11,7 +11,7 @@
"kind": "plugin"
},
"dependencies": {
"@uiw/react-md-editor": "2.1.11",
"@uiw/react-md-editor": "^3.20",
"styled-components": "^5.3.3"
},
"author": {
Expand Down
Loading

0 comments on commit 8c8563e

Please sign in to comment.