@uiw/react-md-editor 4.0.11 → 4.1.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.
Files changed (63) hide show
  1. package/README.md +39 -4
  2. package/common.d.ts +17 -0
  3. package/dist/mdeditor.css +105 -110
  4. package/dist/mdeditor.js +3256 -4363
  5. package/dist/mdeditor.min.css +1 -1
  6. package/dist/mdeditor.min.js +1 -1
  7. package/dist/mdeditor.min.js.LICENSE.txt +2 -2
  8. package/esm/Editor.common.d.ts +5 -0
  9. package/esm/Editor.common.js +7 -0
  10. package/esm/Editor.d.ts +4 -11
  11. package/esm/Editor.factory.d.ts +14 -0
  12. package/esm/Editor.factory.js +270 -0
  13. package/esm/Editor.js +5 -261
  14. package/esm/Editor.nohighlight.d.ts +4 -11
  15. package/esm/Editor.nohighlight.js +5 -261
  16. package/esm/components/TextArea/Markdown.common.d.ts +5 -0
  17. package/esm/components/TextArea/Markdown.common.js +59 -0
  18. package/esm/components/TextArea/factory.d.ts +33 -0
  19. package/esm/components/TextArea/factory.js +105 -0
  20. package/esm/components/TextArea/index.common.d.ts +3 -0
  21. package/esm/components/TextArea/index.common.js +6 -0
  22. package/esm/components/TextArea/index.d.ts +3 -27
  23. package/esm/components/TextArea/index.js +5 -100
  24. package/esm/components/TextArea/index.nohighlight.d.ts +3 -27
  25. package/esm/components/TextArea/index.nohighlight.js +2 -93
  26. package/esm/index.common.d.ts +16 -0
  27. package/esm/index.common.js +16 -0
  28. package/esm/index.css +0 -1
  29. package/esm/react-markdown-preview.common.d.ts +4 -0
  30. package/lib/Editor.common.d.ts +5 -0
  31. package/lib/Editor.common.js +15 -0
  32. package/lib/Editor.d.ts +4 -11
  33. package/lib/Editor.factory.d.ts +14 -0
  34. package/lib/Editor.factory.js +333 -0
  35. package/lib/Editor.js +4 -318
  36. package/lib/Editor.nohighlight.d.ts +4 -11
  37. package/lib/Editor.nohighlight.js +4 -318
  38. package/lib/components/TextArea/Markdown.common.d.ts +5 -0
  39. package/lib/components/TextArea/Markdown.common.js +68 -0
  40. package/lib/components/TextArea/factory.d.ts +33 -0
  41. package/lib/components/TextArea/factory.js +109 -0
  42. package/lib/components/TextArea/index.common.d.ts +3 -0
  43. package/lib/components/TextArea/index.common.js +14 -0
  44. package/lib/components/TextArea/index.d.ts +3 -27
  45. package/lib/components/TextArea/index.js +6 -98
  46. package/lib/components/TextArea/index.nohighlight.d.ts +3 -27
  47. package/lib/components/TextArea/index.nohighlight.js +3 -92
  48. package/lib/index.common.d.ts +16 -0
  49. package/lib/index.common.js +123 -0
  50. package/lib/react-markdown-preview.common.d.ts +4 -0
  51. package/markdown-editor.css +0 -1
  52. package/package.json +8 -2
  53. package/src/Editor.common.tsx +7 -0
  54. package/src/Editor.factory.tsx +286 -0
  55. package/src/Editor.nohighlight.tsx +3 -271
  56. package/src/Editor.tsx +3 -271
  57. package/src/components/TextArea/Markdown.common.tsx +49 -0
  58. package/src/components/TextArea/factory.tsx +120 -0
  59. package/src/components/TextArea/index.common.tsx +6 -0
  60. package/src/components/TextArea/index.nohighlight.tsx +3 -108
  61. package/src/components/TextArea/index.tsx +3 -110
  62. package/src/index.common.tsx +19 -0
  63. package/src/react-markdown-preview.common.d.ts +4 -0
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  <div markdown="1">
2
2
  <sup>Using <a href="https://wangchujiang.com/#/app" target="_blank">my app</a> is also a way to <a href="https://wangchujiang.com/#/sponsor" target="_blank">support</a> me:</sup>
3
3
  <br>
4
+ <a target="_blank" href="https://apps.apple.com/app/6758053530" title="Scap: Screenshot & Markup Edit for macOS"><img alt="Scap: Screenshot & Markup Edit" height="52" width="52" src="https://wangchujiang.com/appicon/scap.png"></a>
5
+ <a target="_blank" href="https://apps.apple.com/app/6757317079" title="Screen Test for macOS"><img alt="Screen Test" height="52" width="52" src="https://wangchujiang.com/appicon/screen-test.png"></a>
4
6
  <a target="_blank" href="https://apps.apple.com/app/Deskmark/6755948110" title="Deskmark for macOS"><img alt="Deskmark" height="52" width="52" src="https://wangchujiang.com/appicon/deskmark.png"></a>
5
7
  <a target="_blank" href="https://apps.apple.com/app/Keyzer/6500434773" title="Keyzer for macOS"><img alt="Keyzer" height="52" width="52" src="https://wangchujiang.com/appicon/keyzer.png"></a>
6
8
  <a target="_blank" href="https://github.com/jaywcjlove/vidwall-hub" title="Vidwall Hub for macOS"><img alt="Vidwall Hub" height="52" width="52" src="https://wangchujiang.com/appicon/vidwall-hub.png"></a>
@@ -16,7 +18,7 @@
16
18
  <a target="_blank" href="https://apps.apple.com/app/6740425504" title="KeyClicker for macOS"><img alt="KeyClicker" height="52" width="52" src="https://wangchujiang.com/appicon/key-clicker.png"></a>
17
19
  <a target="_blank" href="https://apps.apple.com/app/6739052447" title="DayBar for macOS"><img alt="DayBar" height="52" width="52" src="https://wangchujiang.com/appicon/daybar.png"></a>
18
20
  <a target="_blank" href="https://apps.apple.com/app/6739444407" title="Iconed for macOS"><img alt="Iconed" height="52" width="52" src="https://wangchujiang.com/appicon/iconed.png"></a>
19
- <a target="_blank" href="https://apps.apple.com/app/6737160756" title="Mousio for macOS"><img alt="Mousio" height="52" width="52" src="https://wangchujiang.com/appicon/rightmenu-master.png"></a>
21
+ <a target="_blank" href="https://apps.apple.com/app/6737160756" title="Menuist for macOS"><img alt="Menuist" height="52" width="52" src="https://wangchujiang.com/appicon/rightmenu-master.png"></a>
20
22
  <a target="_blank" href="https://apps.apple.com/app/6723903021" title="Paste Quick for macOS"><img alt="Quick RSS" height="52" width="52" src="https://wangchujiang.com/appicon/paste-quick.png"></a>
21
23
  <a target="_blank" href="https://apps.apple.com/app/6670696072" title="Quick RSS for macOS/iOS"><img alt="Quick RSS" height="52" width="52" src="https://wangchujiang.com/appicon/quick-rss.png"></a>
22
24
  <a target="_blank" href="https://apps.apple.com/app/6670167443" title="Web Serve for macOS"><img alt="Web Serve" height="52" width="52" src="https://wangchujiang.com/appicon/web-serve.png"></a>
@@ -43,8 +45,11 @@
43
45
  </p>
44
46
 
45
47
  <p align="center">
46
- <a href="https://jaywcjlove.github.io/#/sponsor" target="__blank">
47
- <img alt="Buy me a coffee" src="https://img.shields.io/badge/Buy%20me%20a%20coffee-048754?logo=buymeacoffee">
48
+ <a href="https://jaywcjlove.github.io/#/sponsor" title="Buy me a coffee">
49
+ <img src="https://img.shields.io/badge/Buy_Me_a_Coffee-ffdd00?logo=buy-me-a-coffee&logoColor=black" alt="Buy me a coffee">
50
+ </a>
51
+ <a href="https://x.com/jaywcjlove" title="Follow On X">
52
+ <img src="https://img.shields.io/badge/Follow%20on%20X-333333?logo=x&logoColor=white" alt="Follow On X">
48
53
  </a>
49
54
  <a href="https://www.npmjs.com/package/@uiw/react-md-editor" target="__blank">
50
55
  <img alt="Downloads" src="https://img.shields.io/npm/dm/@uiw/react-md-editor.svg?style=flat">
@@ -251,6 +256,36 @@ export default function App() {
251
256
  }
252
257
  ```
253
258
 
259
+ ### Common Code Highlight
260
+
261
+ Use `@uiw/react-md-editor/common` to keep syntax highlighting while only including the `rehype-prism-plus/common` language subset. This is a middle ground between the default full-language build and `nohighlight`.
262
+
263
+ ```jsx mdx:preview
264
+ import React from "react";
265
+ import MDEditor from '@uiw/react-md-editor/common';
266
+
267
+ const code = `**Hello world!!!**
268
+ \`\`\`js
269
+ function greet(name) {
270
+ console.log('hello', name);
271
+ }
272
+ \`\`\`
273
+ `
274
+
275
+ export default function App() {
276
+ const [value, setValue] = React.useState(code);
277
+ return (
278
+ <div className="container">
279
+ <MDEditor
280
+ value={value}
281
+ onChange={setValue}
282
+ />
283
+ <MDEditor.Markdown source={value} style={{ whiteSpace: 'pre-wrap' }} />
284
+ </div>
285
+ );
286
+ }
287
+ ```
288
+
254
289
  ### Placeholder & maxLength
255
290
 
256
291
  "Below is an example that sets the `placeholder` for the editor and defines the maximum input character length as `10` characters."
@@ -1132,6 +1167,7 @@ As always, thanks to our amazing contributors!
1132
1167
  <a href="https://github.com/renovate-bot" title="Mend Renovate"><img src="https://avatars.githubusercontent.com/u/25180681?v=4" width="42;" alt="Mend Renovate"/></a>
1133
1168
  <a href="https://github.com/stevemk14ebr" title="Stephen Eckels"><img src="https://avatars.githubusercontent.com/u/6619205?v=4" width="42;" alt="Stephen Eckels"/></a>
1134
1169
  <a href="https://github.com/RARgames" title="RAR"><img src="https://avatars.githubusercontent.com/u/13639766?v=4" width="42;" alt="RAR"/></a>
1170
+ <a href="https://github.com/Stopa" title="Stepan Bolotnikov"><img src="https://avatars.githubusercontent.com/u/408256?v=4" width="42;" alt="Stepan Bolotnikov"/></a>
1135
1171
  <a href="https://github.com/alpharomercoma" title="Alpha Romer Coma"><img src="https://avatars.githubusercontent.com/u/108984668?v=4" width="42;" alt="Alpha Romer Coma"/></a>
1136
1172
  <a href="https://github.com/Exmirai" title="UniqueUlysees"><img src="https://avatars.githubusercontent.com/u/6436703?v=4" width="42;" alt="UniqueUlysees"/></a>
1137
1173
  <a href="https://github.com/sandiiarov" title="Alex Sandiiarov"><img src="https://avatars.githubusercontent.com/u/15861257?v=4" width="42;" alt="Alex Sandiiarov"/></a>
@@ -1149,7 +1185,6 @@ As always, thanks to our amazing contributors!
1149
1185
  <a href="https://github.com/peterj" title="Peter Jausovec"><img src="https://avatars.githubusercontent.com/u/11080940?v=4" width="42;" alt="Peter Jausovec"/></a>
1150
1186
  <a href="https://github.com/phillipb" title="Phillip Burch"><img src="https://avatars.githubusercontent.com/u/1482089?v=4" width="42;" alt="Phillip Burch"/></a>
1151
1187
  <a href="https://github.com/psycho-baller" title="Rami Maalouf"><img src="https://avatars.githubusercontent.com/u/81759594?v=4" width="42;" alt="Rami Maalouf"/></a>
1152
- <a href="https://github.com/Stopa" title="Stepan Bolotnikov"><img src="https://avatars.githubusercontent.com/u/408256?v=4" width="42;" alt="Stepan Bolotnikov"/></a>
1153
1188
  <a href="https://github.com/toresbe" title="Tore Sinding Bekkedal"><img src="https://avatars.githubusercontent.com/u/1761606?v=4" width="42;" alt="Tore Sinding Bekkedal"/></a>
1154
1189
  <a href="https://github.com/valenfv" title="Valentin"><img src="https://avatars.githubusercontent.com/u/34139820?v=4" width="42;" alt="Valentin"/></a>
1155
1190
  <a href="https://github.com/jmtes" title="juno tesoro"><img src="https://avatars.githubusercontent.com/u/38450133?v=4" width="42;" alt="juno tesoro"/></a>
package/common.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ declare module '@uiw/react-md-editor/common' {
2
+ import MDEditor from '@uiw/react-md-editor/esm/Editor.common';
3
+ import * as commands from '@uiw/react-md-editor/esm/commands';
4
+ import * as MarkdownUtil from '@uiw/react-md-editor/esm/utils/markdownUtils';
5
+ export { headingExecute } from '@uiw/react-md-editor/esm/commands/title';
6
+ export * from '@uiw/react-md-editor/esm/commands';
7
+ export * from '@uiw/react-md-editor/esm/commands/group';
8
+ export * from '@uiw/react-md-editor/esm/utils/markdownUtils';
9
+ export * from '@uiw/react-md-editor/esm/utils/InsertTextAtPosition';
10
+ export * from '@uiw/react-md-editor/esm/Editor.common';
11
+ export * from '@uiw/react-md-editor/esm/Context';
12
+ export * from '@uiw/react-md-editor/esm/Types';
13
+ export { default as handleKeyDown } from '@uiw/react-md-editor/esm/components/TextArea/handleKeyDown';
14
+ export { default as shortcuts } from '@uiw/react-md-editor/esm/components/TextArea/shortcuts';
15
+ export { MarkdownUtil, commands };
16
+ export default MDEditor;
17
+ }
package/dist/mdeditor.css CHANGED
@@ -1099,113 +1099,6 @@ body[data-color-mode*='light'] {
1099
1099
  cursor: help;
1100
1100
  }
1101
1101
 
1102
- .w-md-editor-toolbar-child {
1103
- position: absolute;
1104
- border-radius: 3px;
1105
- box-shadow: 0 0 0 1px var(--md-editor-box-shadow-color), 0 0 0 var(--md-editor-box-shadow-color), 0 1px 1px var(--md-editor-box-shadow-color);
1106
- background-color: var(--md-editor-background-color);
1107
- z-index: 1;
1108
- display: none;
1109
- }
1110
- .w-md-editor-toolbar-child.active {
1111
- display: block;
1112
- }
1113
- .w-md-editor-toolbar-child .w-md-editor-toolbar {
1114
- border-bottom: 0;
1115
- padding: 3px;
1116
- border-radius: 3px;
1117
- }
1118
- .w-md-editor-toolbar-child .w-md-editor-toolbar ul > li {
1119
- display: block;
1120
- }
1121
- .w-md-editor-toolbar-child .w-md-editor-toolbar ul > li button {
1122
- width: -webkit-fill-available;
1123
- height: auto;
1124
- height: initial;
1125
- box-sizing: border-box;
1126
- padding: 3px 4px 2px 4px;
1127
- margin: 0;
1128
- }
1129
-
1130
- .w-md-editor-toolbar {
1131
- border-bottom: 1px solid var(--md-editor-box-shadow-color);
1132
- background-color: var(--md-editor-background-color);
1133
- padding: 3px;
1134
- display: flex;
1135
- justify-content: space-between;
1136
- align-items: center;
1137
- border-radius: 3px 3px 0 0;
1138
- -webkit-user-select: none;
1139
- -moz-user-select: none;
1140
- user-select: none;
1141
- flex-wrap: wrap;
1142
- }
1143
- .w-md-editor-toolbar.bottom {
1144
- border-bottom: 0px;
1145
- border-top: 1px solid var(--md-editor-box-shadow-color);
1146
- border-radius: 0 0 3px 3px;
1147
- }
1148
- .w-md-editor-toolbar ul,
1149
- .w-md-editor-toolbar li {
1150
- margin: 0;
1151
- padding: 0;
1152
- list-style: none;
1153
- line-height: normal;
1154
- line-height: initial;
1155
- }
1156
- .w-md-editor-toolbar li {
1157
- display: inline-block;
1158
- font-size: 14px;
1159
- }
1160
- .w-md-editor-toolbar li + li {
1161
- margin: 0;
1162
- }
1163
- .w-md-editor-toolbar li > button {
1164
- border: none;
1165
- height: 20px;
1166
- line-height: 14px;
1167
- background: none;
1168
- padding: 4px;
1169
- margin: 0 1px;
1170
- border-radius: 2px;
1171
- text-transform: none;
1172
- font-weight: normal;
1173
- overflow: visible;
1174
- outline: none;
1175
- cursor: pointer;
1176
- transition: all 0.3s;
1177
- white-space: nowrap;
1178
- color: var(--color-fg-default);
1179
- }
1180
- .w-md-editor-toolbar li > button:hover,
1181
- .w-md-editor-toolbar li > button:focus {
1182
- background-color: var(--color-neutral-muted);
1183
- color: var(--color-accent-fg);
1184
- }
1185
- .w-md-editor-toolbar li > button:active {
1186
- background-color: var(--color-neutral-muted);
1187
- color: var(--color-danger-fg);
1188
- }
1189
- .w-md-editor-toolbar li > button:disabled {
1190
- color: var(--md-editor-box-shadow-color);
1191
- cursor: not-allowed;
1192
- }
1193
- .w-md-editor-toolbar li > button:disabled:hover {
1194
- background-color: transparent;
1195
- color: var(--md-editor-box-shadow-color);
1196
- }
1197
- .w-md-editor-toolbar li.active > button {
1198
- color: var(--color-accent-fg);
1199
- background-color: var(--color-neutral-muted);
1200
- }
1201
- .w-md-editor-toolbar-divider {
1202
- height: 14px;
1203
- width: 1px;
1204
- margin: -3px 3px 0 3px !important;
1205
- vertical-align: middle;
1206
- background-color: var(--md-editor-box-shadow-color);
1207
- }
1208
-
1209
1102
  .w-md-editor-area {
1210
1103
  overflow: auto;
1211
1104
  border-radius: 5px;
@@ -1344,7 +1237,111 @@ body[data-color-mode*='light'] {
1344
1237
  color: #82071e !important;
1345
1238
  color: var(--color-prettylights-syntax-markup-deleted-text, #82071e) !important;
1346
1239
  }
1347
-
1240
+ .w-md-editor-toolbar-child {
1241
+ position: absolute;
1242
+ border-radius: 3px;
1243
+ box-shadow: 0 0 0 1px var(--md-editor-box-shadow-color), 0 0 0 var(--md-editor-box-shadow-color), 0 1px 1px var(--md-editor-box-shadow-color);
1244
+ background-color: var(--md-editor-background-color);
1245
+ z-index: 1;
1246
+ display: none;
1247
+ }
1248
+ .w-md-editor-toolbar-child.active {
1249
+ display: block;
1250
+ }
1251
+ .w-md-editor-toolbar-child .w-md-editor-toolbar {
1252
+ border-bottom: 0;
1253
+ padding: 3px;
1254
+ border-radius: 3px;
1255
+ }
1256
+ .w-md-editor-toolbar-child .w-md-editor-toolbar ul > li {
1257
+ display: block;
1258
+ }
1259
+ .w-md-editor-toolbar-child .w-md-editor-toolbar ul > li button {
1260
+ width: -webkit-fill-available;
1261
+ height: auto;
1262
+ height: initial;
1263
+ box-sizing: border-box;
1264
+ padding: 3px 4px 2px 4px;
1265
+ margin: 0;
1266
+ }
1267
+ .w-md-editor-toolbar {
1268
+ border-bottom: 1px solid var(--md-editor-box-shadow-color);
1269
+ background-color: var(--md-editor-background-color);
1270
+ padding: 3px;
1271
+ display: flex;
1272
+ justify-content: space-between;
1273
+ align-items: center;
1274
+ border-radius: 3px 3px 0 0;
1275
+ -webkit-user-select: none;
1276
+ -moz-user-select: none;
1277
+ user-select: none;
1278
+ flex-wrap: wrap;
1279
+ }
1280
+ .w-md-editor-toolbar.bottom {
1281
+ border-bottom: 0px;
1282
+ border-top: 1px solid var(--md-editor-box-shadow-color);
1283
+ border-radius: 0 0 3px 3px;
1284
+ }
1285
+ .w-md-editor-toolbar ul,
1286
+ .w-md-editor-toolbar li {
1287
+ margin: 0;
1288
+ padding: 0;
1289
+ list-style: none;
1290
+ line-height: normal;
1291
+ line-height: initial;
1292
+ }
1293
+ .w-md-editor-toolbar li {
1294
+ display: inline-block;
1295
+ font-size: 14px;
1296
+ }
1297
+ .w-md-editor-toolbar li + li {
1298
+ margin: 0;
1299
+ }
1300
+ .w-md-editor-toolbar li > button {
1301
+ border: none;
1302
+ height: 20px;
1303
+ line-height: 14px;
1304
+ background: none;
1305
+ padding: 4px;
1306
+ margin: 0 1px;
1307
+ border-radius: 2px;
1308
+ text-transform: none;
1309
+ font-weight: normal;
1310
+ overflow: visible;
1311
+ outline: none;
1312
+ cursor: pointer;
1313
+ transition: all 0.3s;
1314
+ white-space: nowrap;
1315
+ color: var(--color-fg-default);
1316
+ }
1317
+ .w-md-editor-toolbar li > button:hover,
1318
+ .w-md-editor-toolbar li > button:focus {
1319
+ background-color: var(--color-neutral-muted);
1320
+ color: var(--color-accent-fg);
1321
+ }
1322
+ .w-md-editor-toolbar li > button:active {
1323
+ background-color: var(--color-neutral-muted);
1324
+ color: var(--color-danger-fg);
1325
+ }
1326
+ .w-md-editor-toolbar li > button:disabled {
1327
+ color: var(--md-editor-box-shadow-color);
1328
+ cursor: not-allowed;
1329
+ }
1330
+ .w-md-editor-toolbar li > button:disabled:hover {
1331
+ background-color: transparent;
1332
+ color: var(--md-editor-box-shadow-color);
1333
+ }
1334
+ .w-md-editor-toolbar li.active > button {
1335
+ color: var(--color-accent-fg);
1336
+ background-color: var(--color-neutral-muted);
1337
+ }
1338
+ .w-md-editor-toolbar-divider {
1339
+ height: 14px;
1340
+ width: 1px;
1341
+ margin: -3px 3px 0 3px !important;
1342
+ vertical-align: middle;
1343
+ background-color: var(--md-editor-box-shadow-color);
1344
+ }
1348
1345
  .w-md-editor-bar {
1349
1346
  position: absolute;
1350
1347
  cursor: s-resize;
@@ -1364,7 +1361,6 @@ body[data-color-mode*='light'] {
1364
1361
  display: block;
1365
1362
  margin: 0 auto;
1366
1363
  }
1367
-
1368
1364
  .w-md-editor {
1369
1365
  text-align: left;
1370
1366
  border-radius: 3px;
@@ -1466,4 +1462,3 @@ body[data-color-mode*='light'] {
1466
1462
  .w-md-editor-fullscreen .w-md-editor-content {
1467
1463
  height: 100%;
1468
1464
  }
1469
-