@uiw/react-md-editor 3.14.5 → 3.17.0
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 +71 -4
- package/dist/mdeditor.css +1 -0
- package/dist/mdeditor.js +686 -83
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/esm/Context.d.ts +17 -2
- package/esm/Context.js.map +2 -2
- package/esm/Editor.d.ts +20 -4
- package/esm/Editor.js +6 -4
- package/esm/Editor.js.map +4 -3
- package/esm/commands/index.d.ts +2 -0
- package/esm/commands/index.js.map +2 -2
- package/esm/components/Toolbar/index.js +4 -1
- package/esm/components/Toolbar/index.js.map +7 -2
- package/esm/index.css +1 -0
- package/esm/index.less +1 -0
- package/lib/Context.d.ts +17 -2
- package/lib/Context.js.map +2 -2
- package/lib/Editor.d.ts +20 -4
- package/lib/Editor.js +6 -4
- package/lib/Editor.js.map +4 -3
- package/lib/commands/index.d.ts +2 -0
- package/lib/commands/index.js.map +2 -2
- package/lib/components/Toolbar/index.js +4 -1
- package/lib/components/Toolbar/index.js.map +8 -3
- package/lib/index.less +1 -0
- package/markdown-editor.css +1 -0
- package/package.json +1 -1
- package/src/Context.tsx +3 -1
- package/src/Editor.tsx +25 -8
- package/src/commands/index.ts +7 -0
- package/src/components/Toolbar/index.tsx +9 -3
- package/src/index.less +1 -0
package/README.md
CHANGED
|
@@ -162,6 +162,34 @@ const title3 = {
|
|
|
162
162
|
},
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
+
const title2 = {
|
|
166
|
+
name: 'title3',
|
|
167
|
+
keyCommand: 'title3',
|
|
168
|
+
render: (command, disabled, executeCommand) => {
|
|
169
|
+
return (
|
|
170
|
+
<button
|
|
171
|
+
aria-label="Insert title3"
|
|
172
|
+
disabled={disabled}
|
|
173
|
+
onClick={(evn) => {
|
|
174
|
+
evn.stopPropagation();
|
|
175
|
+
executeCommand(command, command.groupName)
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
<svg width="12" height="12" viewBox="0 0 520 520">
|
|
179
|
+
<path fill="currentColor" d="M15.7083333,468 C7.03242448,468 0,462.030833 0,454.666667 L0,421.333333 C0,413.969167 7.03242448,408 15.7083333,408 L361.291667,408 C369.967576,408 377,413.969167 377,421.333333 L377,454.666667 C377,462.030833 369.967576,468 361.291667,468 L15.7083333,468 Z M21.6666667,366 C9.69989583,366 0,359.831861 0,352.222222 L0,317.777778 C0,310.168139 9.69989583,304 21.6666667,304 L498.333333,304 C510.300104,304 520,310.168139 520,317.777778 L520,352.222222 C520,359.831861 510.300104,366 498.333333,366 L21.6666667,366 Z M136.835938,64 L136.835937,126 L107.25,126 L107.25,251 L40.75,251 L40.75,126 L-5.68434189e-14,126 L-5.68434189e-14,64 L136.835938,64 Z M212,64 L212,251 L161.648438,251 L161.648438,64 L212,64 Z M378,64 L378,126 L343.25,126 L343.25,251 L281.75,251 L281.75,126 L238,126 L238,64 L378,64 Z M449.047619,189.550781 L520,189.550781 L520,251 L405,251 L405,64 L449.047619,64 L449.047619,189.550781 Z" />
|
|
180
|
+
</svg>
|
|
181
|
+
</button>
|
|
182
|
+
)
|
|
183
|
+
},
|
|
184
|
+
execute: (state, api) => {
|
|
185
|
+
let modifyText = `## ${state.selectedText}\n`;
|
|
186
|
+
if (!state.selectedText) {
|
|
187
|
+
modifyText = `## `;
|
|
188
|
+
}
|
|
189
|
+
api.replaceSelection(modifyText);
|
|
190
|
+
},
|
|
191
|
+
}
|
|
192
|
+
|
|
165
193
|
export default function App() {
|
|
166
194
|
const [value, setValue] = React.useState("Hello Markdown! `Tab` key uses default behavior");
|
|
167
195
|
return (
|
|
@@ -171,7 +199,7 @@ export default function App() {
|
|
|
171
199
|
onChange={setValue}
|
|
172
200
|
commands={[
|
|
173
201
|
// Custom Toolbars
|
|
174
|
-
title3,
|
|
202
|
+
title3, title2,
|
|
175
203
|
commands.group([commands.title1, commands.title2, commands.title3, commands.title4, commands.title5, commands.title6], {
|
|
176
204
|
name: 'title',
|
|
177
205
|
groupName: 'title',
|
|
@@ -263,6 +291,44 @@ export default function App() {
|
|
|
263
291
|
}
|
|
264
292
|
```
|
|
265
293
|
|
|
294
|
+
re-render `toolbar` element.
|
|
295
|
+
|
|
296
|
+
```jsx mdx:preview
|
|
297
|
+
import React from "react";
|
|
298
|
+
import MDEditor, { commands } from '@uiw/react-md-editor';
|
|
299
|
+
|
|
300
|
+
export default function App() {
|
|
301
|
+
const [value, setValue] = React.useState("Hello Markdown! `Tab` key uses default behavior");
|
|
302
|
+
return (
|
|
303
|
+
<div className="container">
|
|
304
|
+
<MDEditor
|
|
305
|
+
value={value}
|
|
306
|
+
onChange={setValue}
|
|
307
|
+
preview="edit"
|
|
308
|
+
components={{
|
|
309
|
+
toolbar: (command, disabled, executeCommand) => {
|
|
310
|
+
if (command.keyCommand === 'code') {
|
|
311
|
+
return (
|
|
312
|
+
<button
|
|
313
|
+
aria-label="Insert code"
|
|
314
|
+
disabled={disabled}
|
|
315
|
+
onClick={(evn) => {
|
|
316
|
+
evn.stopPropagation();
|
|
317
|
+
executeCommand(command, command.groupName)
|
|
318
|
+
}}
|
|
319
|
+
>
|
|
320
|
+
Code
|
|
321
|
+
</button>
|
|
322
|
+
)
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}}
|
|
326
|
+
/>
|
|
327
|
+
</div>
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
266
332
|
### Preview Markdown
|
|
267
333
|
|
|
268
334
|
[](https://codesandbox.io/embed/react-md-editor-preview-markdown-vrucl?fontsize=14&hidenavigation=1&theme=dark)
|
|
@@ -564,15 +630,16 @@ Inherit custom color variables by adding [`.wmde-markdown-var`](https://github.c
|
|
|
564
630
|
|
|
565
631
|
- `value: string`: The Markdown value.
|
|
566
632
|
- `onChange?: (value?: string, event?: React.ChangeEvent<HTMLTextAreaElement>, state?: ContextStore)`: Event handler for the `onChange` event.
|
|
567
|
-
- `onHeightChange?: (value?:
|
|
633
|
+
- `onHeightChange?: ((value?: CSSProperties['height'], oldValue?: CSSProperties['height'], state?: ContextStore)`: editor height change listener.
|
|
568
634
|
- `commands?: ICommand[]`: An array of [`ICommand`](https://github.com/uiwjs/react-md-editor/blob/d02543050c9abd8f7c72ae02b6421ac2e6ae421a/src/commands/index.ts#L39-L57), which, each one, contain a [`commands`](https://github.com/uiwjs/react-md-editor/blob/d02543050c9abd8f7c72ae02b6421ac2e6ae421a/src/commands/index.ts#L155-L180) property. If no commands are specified, the default will be used. Commands are explained in more details below.
|
|
569
635
|
- `commandsFilter?: (command: ICommand, isExtra: boolean) => false | ICommand`: Filter or modify your commands.
|
|
570
636
|
- `extraCommands?: ICommand[]`: Displayed on the right side of the toolbar.
|
|
571
637
|
- `autoFocus?: true`: Can be used to make `Markdown Editor` focus itself on initialization.
|
|
572
638
|
- `previewOptions?: ReactMarkdown.ReactMarkdownProps`: This is reset [@uiw/react-markdown-preview](https://github.com/uiwjs/react-markdown-preview/tree/e6e8462d9a5c64a7045e25adcb4928095d74ca37#options-props) settings.
|
|
573
639
|
- `textareaProps?: TextareaHTMLAttributes`: Set the `textarea` related props.
|
|
574
|
-
-
|
|
575
|
-
- `
|
|
640
|
+
- ~~`renderTextarea?: (props, opts) => JSX.Element;`~~: `@deprecated` Please use ~~`renderTextarea`~~ -> `components`. Use div to replace TextArea or re-render TextArea. [#193](https://github.com/uiwjs/react-md-editor/issues/193)
|
|
641
|
+
- `components`: re-render textarea/toolbar element. [#419](https://github.com/uiwjs/react-md-editor/issues/419)
|
|
642
|
+
- `height?: number=200`: The height of the editor. ️⚠️ `Dragbar` is invalid when **`height`** parameter percentage.
|
|
576
643
|
- `visibleDragbar?: boolean=true`: Show drag and drop tool. Set the height of the editor.
|
|
577
644
|
- `highlightEnable?: boolean=true`: Disable editing area code highlighting. The value is `false`, which increases the editing speed.
|
|
578
645
|
- `fullscreen?: boolean=false`: Show markdown preview.
|