@uiw/react-md-editor 3.14.2 → 3.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -0
- package/dist/mdeditor.css +0 -6
- package/dist/mdeditor.js +137 -274
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/esm/commands/group.d.ts +1 -1
- package/esm/components/TextArea/Markdown.js +1 -1
- package/esm/components/TextArea/Markdown.js.map +1 -1
- package/esm/components/TextArea/index.js +10 -5
- package/esm/components/TextArea/index.js.map +6 -4
- package/lib/commands/group.d.ts +1 -1
- package/lib/components/TextArea/Markdown.js +1 -1
- package/lib/components/TextArea/Markdown.js.map +1 -1
- package/lib/components/TextArea/index.js +11 -6
- package/lib/components/TextArea/index.js.map +6 -4
- package/package.json +2 -2
- package/src/components/TextArea/Markdown.tsx +1 -1
- package/src/components/TextArea/index.tsx +4 -5
package/README.md
CHANGED
|
@@ -77,6 +77,39 @@ export default function App() {
|
|
|
77
77
|
}
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
### Special Markdown syntax
|
|
81
|
+
|
|
82
|
+
**Supports for CSS Style**
|
|
83
|
+
|
|
84
|
+
Use HTML comments `<!--rehype:xxx-->`<!--rehype:style=color: red; font-weight: bold;--> to let Markdown support style customization.
|
|
85
|
+
|
|
86
|
+
```markdown
|
|
87
|
+
## Title
|
|
88
|
+
<!--rehype:style=display: flex; height: 230px; align-items: center; justify-content: center; font-size: 38px;-->
|
|
89
|
+
|
|
90
|
+
Markdown Supports **Style**<!--rehype:style=color: red;-->
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Ignore content display via HTML comments**
|
|
94
|
+
|
|
95
|
+
Shown in GitHub readme, excluded in HTML.
|
|
96
|
+
|
|
97
|
+
```markdown
|
|
98
|
+
# Hello World
|
|
99
|
+
|
|
100
|
+
<!--rehype:ignore:start-->Hello World<!--rehype:ignore:end-->
|
|
101
|
+
|
|
102
|
+
Good!
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Output:
|
|
106
|
+
|
|
107
|
+
```html
|
|
108
|
+
<h1>Hello World</h1>
|
|
109
|
+
|
|
110
|
+
<p>Good!</p>
|
|
111
|
+
```
|
|
112
|
+
|
|
80
113
|
### Security
|
|
81
114
|
|
|
82
115
|
Please note markdown needs to be sanitized if you do not **completely trust** your authors.
|
|
@@ -175,6 +208,61 @@ export default function App() {
|
|
|
175
208
|
}
|
|
176
209
|
```
|
|
177
210
|
|
|
211
|
+
Customize the toolbar with `commands` and `extraCommands` props.
|
|
212
|
+
|
|
213
|
+
```jsx mdx:preview
|
|
214
|
+
import React from "react";
|
|
215
|
+
import MDEditor, { commands } from '@uiw/react-md-editor';
|
|
216
|
+
|
|
217
|
+
export default function App() {
|
|
218
|
+
const [value, setValue] = React.useState("Hello Markdown! `Tab` key uses default behavior");
|
|
219
|
+
return (
|
|
220
|
+
<div className="container">
|
|
221
|
+
<MDEditor
|
|
222
|
+
value={value}
|
|
223
|
+
onChange={setValue}
|
|
224
|
+
preview="edit"
|
|
225
|
+
commands={[
|
|
226
|
+
commands.codeEdit, commands.codePreview
|
|
227
|
+
]}
|
|
228
|
+
extraCommands={[
|
|
229
|
+
commands.group([commands.title1, commands.title2, commands.title3, commands.title4, commands.title5, commands.title6], {
|
|
230
|
+
name: 'title',
|
|
231
|
+
groupName: 'title',
|
|
232
|
+
buttonProps: { 'aria-label': 'Insert title'}
|
|
233
|
+
}),
|
|
234
|
+
commands.divider,
|
|
235
|
+
commands.group([], {
|
|
236
|
+
name: 'update',
|
|
237
|
+
groupName: 'update',
|
|
238
|
+
icon: (
|
|
239
|
+
<svg viewBox="0 0 1024 1024" width="12" height="12">
|
|
240
|
+
<path fill="currentColor" d="M716.8 921.6a51.2 51.2 0 1 1 0 102.4H307.2a51.2 51.2 0 1 1 0-102.4h409.6zM475.8016 382.1568a51.2 51.2 0 0 1 72.3968 0l144.8448 144.8448a51.2 51.2 0 0 1-72.448 72.3968L563.2 541.952V768a51.2 51.2 0 0 1-45.2096 50.8416L512 819.2a51.2 51.2 0 0 1-51.2-51.2v-226.048l-57.3952 57.4464a51.2 51.2 0 0 1-67.584 4.2496l-4.864-4.2496a51.2 51.2 0 0 1 0-72.3968zM512 0c138.6496 0 253.4912 102.144 277.1456 236.288l10.752 0.3072C924.928 242.688 1024 348.0576 1024 476.5696 1024 608.9728 918.8352 716.8 788.48 716.8a51.2 51.2 0 1 1 0-102.4l8.3968-0.256C866.2016 609.6384 921.6 550.0416 921.6 476.5696c0-76.4416-59.904-137.8816-133.12-137.8816h-97.28v-51.2C691.2 184.9856 610.6624 102.4 512 102.4S332.8 184.9856 332.8 287.488v51.2H235.52c-73.216 0-133.12 61.44-133.12 137.8816C102.4 552.96 162.304 614.4 235.52 614.4l5.9904 0.3584A51.2 51.2 0 0 1 235.52 716.8C105.1648 716.8 0 608.9728 0 476.5696c0-132.1984 104.8064-239.872 234.8544-240.2816C258.5088 102.144 373.3504 0 512 0z" />
|
|
241
|
+
</svg>
|
|
242
|
+
),
|
|
243
|
+
children: ({ close, execute, getState, textApi }) => {
|
|
244
|
+
return (
|
|
245
|
+
<div style={{ width: 120, padding: 10 }}>
|
|
246
|
+
<div>My Custom Toolbar</div>
|
|
247
|
+
<button type="button" onClick={() => console.log('> execute: >>>>>', getState())}>State</button>
|
|
248
|
+
<button type="button" onClick={() => close()}>Close</button>
|
|
249
|
+
<button type="button" onClick={() => execute()}>Execute</button>
|
|
250
|
+
</div>
|
|
251
|
+
);
|
|
252
|
+
},
|
|
253
|
+
execute: (state, api) => {
|
|
254
|
+
console.log('>>>>>>update>>>>>', state)
|
|
255
|
+
},
|
|
256
|
+
buttonProps: { 'aria-label': 'Insert title'}
|
|
257
|
+
}),
|
|
258
|
+
commands.divider, commands.fullscreen
|
|
259
|
+
]}
|
|
260
|
+
/>
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
178
266
|
### Preview Markdown
|
|
179
267
|
|
|
180
268
|
[](https://codesandbox.io/embed/react-md-editor-preview-markdown-vrucl?fontsize=14&hidenavigation=1&theme=dark)
|
package/dist/mdeditor.css
CHANGED
|
@@ -496,10 +496,6 @@ body[data-color-mode*='light'] {
|
|
|
496
496
|
color: var(--color-fg-subtle);
|
|
497
497
|
opacity: 1;
|
|
498
498
|
}
|
|
499
|
-
.wmde-markdown :-ms-input-placeholder {
|
|
500
|
-
color: var(--color-fg-subtle);
|
|
501
|
-
opacity: 1;
|
|
502
|
-
}
|
|
503
499
|
.wmde-markdown ::placeholder {
|
|
504
500
|
color: var(--color-fg-subtle);
|
|
505
501
|
opacity: 1;
|
|
@@ -1177,7 +1173,6 @@ body[data-color-mode*='light'] {
|
|
|
1177
1173
|
border-radius: 3px 3px 0 0;
|
|
1178
1174
|
-webkit-user-select: none;
|
|
1179
1175
|
-moz-user-select: none;
|
|
1180
|
-
-ms-user-select: none;
|
|
1181
1176
|
user-select: none;
|
|
1182
1177
|
}
|
|
1183
1178
|
.w-md-editor-toolbar.bottom {
|
|
@@ -1253,7 +1248,6 @@ body[data-color-mode*='light'] {
|
|
|
1253
1248
|
border-radius: 0 0 3px 0;
|
|
1254
1249
|
-webkit-user-select: none;
|
|
1255
1250
|
-moz-user-select: none;
|
|
1256
|
-
-ms-user-select: none;
|
|
1257
1251
|
user-select: none;
|
|
1258
1252
|
}
|
|
1259
1253
|
.w-md-editor-bar svg {
|