@uiw/react-md-editor 3.16.0 → 3.17.2

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.
Files changed (48) hide show
  1. package/README.md +56 -2
  2. package/dist/mdeditor.css +20 -5
  3. package/dist/mdeditor.js +70 -653
  4. package/dist/mdeditor.min.css +1 -1
  5. package/dist/mdeditor.min.js +1 -1
  6. package/esm/Context.d.ts +15 -0
  7. package/esm/Context.js.map +2 -2
  8. package/esm/Editor.d.ts +19 -1
  9. package/esm/Editor.js +4 -8
  10. package/esm/Editor.js.map +4 -3
  11. package/esm/commands/index.d.ts +1 -1
  12. package/esm/commands/index.js.map +1 -1
  13. package/esm/components/DragBar/index.css +1 -0
  14. package/esm/components/DragBar/index.less +1 -0
  15. package/esm/components/Toolbar/Child.js +0 -1
  16. package/esm/components/Toolbar/Child.js.map +2 -2
  17. package/esm/components/Toolbar/index.css +6 -1
  18. package/esm/components/Toolbar/index.d.ts +0 -2
  19. package/esm/components/Toolbar/index.js +4 -5
  20. package/esm/components/Toolbar/index.js.map +6 -3
  21. package/esm/components/Toolbar/index.less +6 -1
  22. package/esm/index.css +10 -3
  23. package/esm/index.less +9 -3
  24. package/lib/Context.d.ts +15 -0
  25. package/lib/Context.js.map +2 -2
  26. package/lib/Editor.d.ts +19 -1
  27. package/lib/Editor.js +4 -9
  28. package/lib/Editor.js.map +4 -3
  29. package/lib/commands/index.d.ts +1 -1
  30. package/lib/commands/index.js.map +1 -1
  31. package/lib/components/DragBar/index.less +1 -0
  32. package/lib/components/Toolbar/Child.js +0 -1
  33. package/lib/components/Toolbar/Child.js.map +2 -2
  34. package/lib/components/Toolbar/index.d.ts +0 -2
  35. package/lib/components/Toolbar/index.js +4 -6
  36. package/lib/components/Toolbar/index.js.map +7 -4
  37. package/lib/components/Toolbar/index.less +6 -1
  38. package/lib/index.less +9 -3
  39. package/markdown-editor.css +17 -4
  40. package/package.json +2 -2
  41. package/src/Context.tsx +2 -0
  42. package/src/Editor.tsx +25 -11
  43. package/src/commands/index.ts +1 -1
  44. package/src/components/DragBar/index.less +1 -0
  45. package/src/components/Toolbar/Child.tsx +1 -1
  46. package/src/components/Toolbar/index.less +6 -1
  47. package/src/components/Toolbar/index.tsx +10 -7
  48. package/src/index.less +9 -3
package/README.md CHANGED
@@ -291,6 +291,57 @@ export default function App() {
291
291
  }
292
292
  ```
293
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
+
332
+ ### Editor Font Size
333
+
334
+ [![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?logo=codesandbox)](https://codesandbox.io/embed/markdown-editor-for-react-uiwjs-react-md-editor-issues-425-2epmgh?fontsize=14&hidenavigation=1&theme=dark)
335
+ [![#425](https://img.shields.io/github/issues/detail/state/uiwjs/react-md-editor/425)](https://github.com/uiwjs/react-md-editor/issues/425#issuecomment-1209514536)
336
+
337
+ ```css
338
+ .w-md-editor-text-pre > code,
339
+ .w-md-editor-text-input {
340
+ font-size: 23px !important;
341
+ line-height: 24px !important;
342
+ }
343
+ ```
344
+
294
345
  ### Preview Markdown
295
346
 
296
347
  [![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?logo=codesandbox)](https://codesandbox.io/embed/react-md-editor-preview-markdown-vrucl?fontsize=14&hidenavigation=1&theme=dark)
@@ -528,9 +579,11 @@ ReactDOM.render(<App />, document.getElementById("container"));
528
579
 
529
580
  ### Support Nextjs
530
581
 
531
- Use examples in [nextjs](https://nextjs.org/). [#52](https://github.com/uiwjs/react-md-editor/issues/52#issuecomment-848969341) [#224](https://github.com/uiwjs/react-md-editor/issues/224#issuecomment-901112079)
582
+ Use examples in [nextjs](https://nextjs.org/). [`#52`](https://github.com/uiwjs/react-md-editor/issues/52#issuecomment-848969341) [`#224`](https://github.com/uiwjs/react-md-editor/issues/224#issuecomment-901112079)
532
583
 
533
584
  [![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?logo=codesandbox)](https://codesandbox.io/embed/nextjs-example-react-md-editor-qjhn7?fontsize=14&hidenavigation=1&theme=dark) [![Open in StackBlitz](https://img.shields.io/badge/Open%20In-StackBlitz-green)](https://stackblitz.com/edit/nextjs-react-md-editor?embed=1&file=pages/index.js&hideExplorer=1&hideNavigation=1&theme=dark)
585
+ [![#52](https://img.shields.io/github/issues/detail/state/uiwjs/react-md-editor/52)](https://github.com/uiwjs/react-md-editor/issues/52#issuecomment-848969341)
586
+ [![#224](https://img.shields.io/github/issues/detail/state/uiwjs/react-md-editor/224)](https://github.com/uiwjs/react-md-editor/issues/224#issuecomment-901112079)
534
587
 
535
588
  ```bash
536
589
  npm install next-remove-imports
@@ -599,7 +652,8 @@ Inherit custom color variables by adding [`.wmde-markdown-var`](https://github.c
599
652
  - `autoFocus?: true`: Can be used to make `Markdown Editor` focus itself on initialization.
600
653
  - `previewOptions?: ReactMarkdown.ReactMarkdownProps`: This is reset [@uiw/react-markdown-preview](https://github.com/uiwjs/react-markdown-preview/tree/e6e8462d9a5c64a7045e25adcb4928095d74ca37#options-props) settings.
601
654
  - `textareaProps?: TextareaHTMLAttributes`: Set the `textarea` related props.
602
- - `renderTextarea?: (props, opts) => JSX.Element;`: Use div to replace TextArea or re-render TextArea. [#193](https://github.com/uiwjs/react-md-editor/issues/193)
655
+ - ~~`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)
656
+ - `components`: re-render textarea/toolbar element. [#419](https://github.com/uiwjs/react-md-editor/issues/419)
603
657
  - `height?: number=200`: The height of the editor. ️⚠️ `Dragbar` is invalid when **`height`** parameter percentage.
604
658
  - `visibleDragbar?: boolean=true`: Show drag and drop tool. Set the height of the editor.
605
659
  - `highlightEnable?: boolean=true`: Disable editing area code highlighting. The value is `false`, which increases the editing speed.
package/dist/mdeditor.css CHANGED
@@ -278,12 +278,12 @@ body[data-color-mode*='light'] {
278
278
  box-sizing: content-box;
279
279
  overflow: hidden;
280
280
  background: transparent;
281
+ border: 0;
281
282
  border-bottom: 1px solid var(--color-border-muted);
282
283
  height: 0.25em;
283
284
  padding: 0;
284
285
  margin: 24px 0;
285
286
  background-color: var(--color-border-default);
286
- border: 0;
287
287
  }
288
288
  .wmde-markdown input {
289
289
  font: inherit;
@@ -1166,7 +1166,7 @@ body[data-color-mode*='light'] {
1166
1166
  .w-md-editor-toolbar {
1167
1167
  border-bottom: 1px solid var(--color-border-default);
1168
1168
  background-color: var(--color-canvas-default);
1169
- padding: 0 5px 0 5px;
1169
+ padding: 5px 5px;
1170
1170
  display: flex;
1171
1171
  justify-content: space-between;
1172
1172
  align-items: center;
@@ -1174,6 +1174,7 @@ body[data-color-mode*='light'] {
1174
1174
  -webkit-user-select: none;
1175
1175
  -moz-user-select: none;
1176
1176
  user-select: none;
1177
+ flex-wrap: wrap;
1177
1178
  }
1178
1179
  .w-md-editor-toolbar.bottom {
1179
1180
  border-bottom: 0px;
@@ -1185,11 +1186,16 @@ body[data-color-mode*='light'] {
1185
1186
  margin: 0;
1186
1187
  padding: 0;
1187
1188
  list-style: none;
1189
+ line-height: normal;
1190
+ line-height: initial;
1188
1191
  }
1189
1192
  .w-md-editor-toolbar li {
1190
1193
  display: inline-block;
1191
1194
  font-size: 14px;
1192
1195
  }
1196
+ .w-md-editor-toolbar li + li {
1197
+ margin: 0;
1198
+ }
1193
1199
  .w-md-editor-toolbar li > button {
1194
1200
  border: none;
1195
1201
  height: 20px;
@@ -1240,6 +1246,7 @@ body[data-color-mode*='light'] {
1240
1246
  position: absolute;
1241
1247
  cursor: s-resize;
1242
1248
  right: 0;
1249
+ bottom: 0;
1243
1250
  margin-top: -11px;
1244
1251
  margin-right: 0;
1245
1252
  width: 14px;
@@ -1264,14 +1271,22 @@ body[data-color-mode*='light'] {
1264
1271
  box-shadow: 0 0 0 1px var(--color-border-default), 0 0 0 var(--color-border-default), 0 1px 1px var(--color-border-default);
1265
1272
  background-color: var(--color-canvas-default);
1266
1273
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
1274
+ display: flex;
1275
+ flex-direction: column;
1267
1276
  }
1268
- .w-md-editor .copied {
1269
- display: none !important;
1277
+ .w-md-editor-toolbar {
1278
+ height: -webkit-fit-content;
1279
+ height: -moz-fit-content;
1280
+ height: fit-content;
1270
1281
  }
1271
1282
  .w-md-editor-content {
1283
+ height: 100%;
1284
+ overflow: auto;
1272
1285
  position: relative;
1273
1286
  border-radius: 0 0 3px 0;
1274
- height: calc(100% - 39.1px);
1287
+ }
1288
+ .w-md-editor .copied {
1289
+ display: none !important;
1275
1290
  }
1276
1291
  .w-md-editor-input {
1277
1292
  width: 50%;