@uiw/react-md-editor 3.20.10 → 3.21.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 +44 -24
- package/dist/mdeditor.js +1110 -566
- package/dist/mdeditor.min.js +1 -1
- package/esm/Context.d.ts +2 -0
- package/esm/commands/index.d.ts +1 -0
- package/esm/commands/index.js +1 -0
- package/esm/components/TextArea/Markdown.d.ts +1 -1
- package/esm/components/TextArea/Textarea.d.ts +1 -1
- package/esm/components/TextArea/Textarea.js +16 -12
- package/esm/components/TextArea/index.d.ts +1 -1
- package/esm/components/Toolbar/Child.d.ts +1 -1
- package/esm/components/Toolbar/index.d.ts +2 -3
- package/esm/components/Toolbar/index.js +2 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/lib/Context.d.ts +2 -0
- package/lib/commands/index.d.ts +1 -0
- package/lib/commands/index.js +1 -0
- package/lib/components/TextArea/Markdown.d.ts +1 -1
- package/lib/components/TextArea/Textarea.d.ts +1 -1
- package/lib/components/TextArea/Textarea.js +5 -2
- package/lib/components/TextArea/index.d.ts +1 -1
- package/lib/components/Toolbar/Child.d.ts +1 -1
- package/lib/components/Toolbar/index.d.ts +2 -3
- package/lib/components/Toolbar/index.js +2 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/package.json +1 -1
- package/src/Context.tsx +1 -0
- package/src/commands/index.ts +2 -0
- package/src/components/TextArea/Textarea.tsx +2 -0
- package/src/components/Toolbar/index.tsx +1 -0
- package/src/index.tsx +1 -0
package/README.md
CHANGED
|
@@ -141,7 +141,7 @@ export default function App() {
|
|
|
141
141
|
[](https://codesandbox.io/embed/react-md-editor-custom-toolbars-m2n10?fontsize=14&hidenavigation=1&theme=dark)
|
|
142
142
|
|
|
143
143
|
```jsx mdx:preview
|
|
144
|
-
import React from "react";
|
|
144
|
+
import React, { useState } from "react";
|
|
145
145
|
import MDEditor, { commands } from '@uiw/react-md-editor';
|
|
146
146
|
|
|
147
147
|
const title3 = {
|
|
@@ -190,6 +190,47 @@ const title2 = {
|
|
|
190
190
|
},
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
function SubChildren({ close, execute, getState, textApi, dispatch }) {
|
|
194
|
+
const [value, setValue] = useState('')
|
|
195
|
+
const insert = () => {
|
|
196
|
+
console.log('value:::', value)
|
|
197
|
+
textApi.replaceSelection(value)
|
|
198
|
+
}
|
|
199
|
+
return (
|
|
200
|
+
<div style={{ width: 120, padding: 10 }}>
|
|
201
|
+
<div>My Custom Toolbar</div>
|
|
202
|
+
<input type="text" onChange={(e) => setValue(e.target.value)} />
|
|
203
|
+
<button
|
|
204
|
+
type="button"
|
|
205
|
+
onClick={() => {
|
|
206
|
+
dispatch({ $value: '~~~~~~' })
|
|
207
|
+
console.log('> execute: >>>>>', getState())
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
State
|
|
211
|
+
</button>
|
|
212
|
+
<button type="button" onClick={insert}>Insert</button>
|
|
213
|
+
<button type="button" onClick={() => close()}>Close</button>
|
|
214
|
+
<button type="button" onClick={() => execute()}>Execute</button>
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const subChild = {
|
|
220
|
+
name: 'update',
|
|
221
|
+
groupName: 'update',
|
|
222
|
+
icon: (
|
|
223
|
+
<svg viewBox="0 0 1024 1024" width="12" height="12">
|
|
224
|
+
<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" />
|
|
225
|
+
</svg>
|
|
226
|
+
),
|
|
227
|
+
children: (props) => <SubChildren {...props} />,
|
|
228
|
+
execute: (state, api) => {
|
|
229
|
+
console.log('>>>>>>update>>>>>', state)
|
|
230
|
+
},
|
|
231
|
+
buttonProps: { 'aria-label': 'Insert title'}
|
|
232
|
+
}
|
|
233
|
+
|
|
193
234
|
export default function App() {
|
|
194
235
|
const [value, setValue] = React.useState("Hello Markdown! `Tab` key uses default behavior");
|
|
195
236
|
return (
|
|
@@ -206,29 +247,7 @@ export default function App() {
|
|
|
206
247
|
buttonProps: { 'aria-label': 'Insert title'}
|
|
207
248
|
}),
|
|
208
249
|
commands.divider,
|
|
209
|
-
commands.group([],
|
|
210
|
-
name: 'update',
|
|
211
|
-
groupName: 'update',
|
|
212
|
-
icon: (
|
|
213
|
-
<svg viewBox="0 0 1024 1024" width="12" height="12">
|
|
214
|
-
<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" />
|
|
215
|
-
</svg>
|
|
216
|
-
),
|
|
217
|
-
children: ({ close, execute, getState, textApi }) => {
|
|
218
|
-
return (
|
|
219
|
-
<div style={{ width: 120, padding: 10 }}>
|
|
220
|
-
<div>My Custom Toolbar</div>
|
|
221
|
-
<button type="button" onClick={() => console.log('> execute: >>>>>', getState())}>State</button>
|
|
222
|
-
<button type="button" onClick={() => close()}>Close</button>
|
|
223
|
-
<button type="button" onClick={() => execute()}>Execute</button>
|
|
224
|
-
</div>
|
|
225
|
-
);
|
|
226
|
-
},
|
|
227
|
-
execute: (state, api) => {
|
|
228
|
-
console.log('>>>>>>update>>>>>', state)
|
|
229
|
-
},
|
|
230
|
-
buttonProps: { 'aria-label': 'Insert title'}
|
|
231
|
-
}),
|
|
250
|
+
commands.group([], subChild),
|
|
232
251
|
]}
|
|
233
252
|
/>
|
|
234
253
|
</div>
|
|
@@ -648,6 +667,7 @@ export default function App() {
|
|
|
648
667
|
|
|
649
668
|
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)
|
|
650
669
|
|
|
670
|
+
[](https://codesandbox.io/embed/nextjs-example-react-md-editor-https-github-com-uiwjs-react-md-editor-issues-516-1z56px?fontsize=14&hidenavigation=1&theme=dark)
|
|
651
671
|
[](https://codesandbox.io/embed/nextjs-example-react-md-editor-qjhn7?fontsize=14&hidenavigation=1&theme=dark) [](https://stackblitz.com/edit/nextjs-react-md-editor?embed=1&file=pages/index.js&hideExplorer=1&hideNavigation=1&theme=dark)
|
|
652
672
|
[](https://github.com/uiwjs/react-md-editor/issues/52#issuecomment-848969341)
|
|
653
673
|
[](https://github.com/uiwjs/react-md-editor/issues/224#issuecomment-901112079)
|