Skip to content

Commit cddd558

Browse files
authored
Merge pull request #47 from kwinyyyc/fix/5.8.0
fix: ui display issue for strapi 5.8.0
2 parents 5aa17e0 + f6ec30c commit cddd558

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

admin/src/components/CustomField.tsx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { commands, ICommand } from "@uiw/react-md-editor";
55
import { useIntl } from "react-intl";
66
import { styled } from "styled-components";
77
import "@uiw/react-markdown-preview/markdown.css";
8-
import { PLUGIN_ID } from '../utils/pluginId';
8+
import { PLUGIN_ID } from "../utils/pluginId";
99
import MediaLib from "./MediaLib";
1010
import { useField } from "@strapi/strapi/admin";
1111
import assetsToMarkdown from "../utils/assetsToMarkdown";
@@ -20,6 +20,13 @@ const Wrapper = styled.div`
2020
display: none;
2121
}
2222
.w-md-editor {
23+
code[class*="language-"],
24+
pre[class*="language-"] {
25+
color: inherit;
26+
}
27+
.w-md-editor-text-pre {
28+
padding: 0;
29+
}
2330
border: 1px solid #dcdce4;
2431
border-radius: 4px;
2532
box-shadow: none;
@@ -33,8 +40,9 @@ const Wrapper = styled.div`
3340
img {
3441
max-width: 100%;
3542
}
36-
ul,ol{
37-
list-style:inherit;
43+
ul,
44+
ol {
45+
list-style: inherit;
3846
}
3947
.w-md-editor-preview {
4048
display: block;
@@ -100,22 +108,26 @@ const CustomField: FunctionComponent<FieldProps> = ({
100108
const formatMessage = (message: { id: string; defaultMessage: string }) =>
101109
message?.defaultMessage ?? "";
102110
const [mediaLibVisible, setMediaLibVisible] = useState(false);
103-
const [cursorPosition, setCursorPosition] = useState<CursorPosition | null>(null);
111+
const [cursorPosition, setCursorPosition] = useState<CursorPosition | null>(
112+
null
113+
);
104114

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

107-
const updateFieldValue = (value:any) => {
117+
const updateFieldValue = (value: any) => {
108118
field.onChange({ target: { name, value: value } });
109-
}
119+
};
110120

111121
const handleChangeAssets = (assets: Schema.Attribute.MediaValue<true>) => {
112-
113122
let output;
114123
const assetsString = assetsToMarkdown(assets);
115124

116125
if (cursorPosition) {
117-
output = field.value.slice(0, cursorPosition.start) + assetsString + field.value.slice(cursorPosition.end);
118-
}else{
126+
output =
127+
field.value.slice(0, cursorPosition.start) +
128+
assetsString +
129+
field.value.slice(cursorPosition.end);
130+
} else {
119131
output = field.value + assetsString;
120132
}
121133

@@ -144,9 +156,10 @@ const CustomField: FunctionComponent<FieldProps> = ({
144156
},
145157
};
146158
if (!config?.toolbarCommands) {
147-
return [...commands.getCommands(),
159+
return [
160+
...commands.getCommands(),
148161
commands.divider,
149-
mediaLibraryButton
162+
mediaLibraryButton,
150163
] as ICommand[];
151164
}
152165
const customCommands = config?.toolbarCommands

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "strapi-plugin-wysiwyg-react-md-editor",
3-
"version": "5.8.0",
3+
"version": "5.8.1",
44
"description": "Replaces the default Strapi WYSIWYG editor with react md editor.",
55
"keywords": [
66
"strapi",

0 commit comments

Comments
 (0)