MCPcopy Create free account
hub / github.com/uiwjs/react-md-editor / Example

Function Example

www/src/Example.tsx:13–173  ·  view source on GitHub ↗
(props = {} as { mdStr: string })

Source from the content-addressed store, hash-verified

11let count = 1;
12
13const Example = (props = {} as { mdStr: string }) => {
14 const [state, setVisible] = React.useState<MDEditorProps>({
15 visibleDragbar: true,
16 hideToolbar: true,
17 overflow: true,
18 highlightEnable: true,
19 enableScroll: true,
20 value: props.mdStr || '',
21 preview: 'live',
22 toolbarBottom: false,
23 });
24 const upPreview = (e: React.ChangeEvent<HTMLInputElement>) => {
25 setVisible({ ...state, preview: e.target.value as MDEditorProps['preview'] });
26 };
27 const updateHandle = (str: string) => {
28 setVisible({ ...state, value: str });
29 };
30 return (
31 <Fragment>
32 <MDEditor
33 autoFocus
34 value={state.value}
35 overflow={state.overflow}
36 previewOptions={{
37 rehypePlugins: [
38 [
39 rehypeSanitize,
40 {
41 ...defaultSchema,
42 attributes: {
43 ...defaultSchema.attributes,
44 span: [
45 // @ts-ignore
46 ...(defaultSchema.attributes.span || []),
47 // List of all allowed tokens:
48 ['className'],
49 ],
50 code: [['className']],
51 },
52 },
53 ],
54 ],
55 }}
56 height={400}
57 highlightEnable={state.highlightEnable}
58 hideToolbar={!state.hideToolbar}
59 enableScroll={state.enableScroll}
60 toolbarBottom={state.toolbarBottom}
61 visibleDragbar={state.visibleDragbar}
62 textareaProps={{
63 placeholder: 'Please enter Markdown text',
64 }}
65 preview={state.preview}
66 onChange={(newValue = '') => {
67 setVisible({ ...state, value: newValue });
68 }}
69 />
70 <Toolbar>

Callers

nothing calls this directly

Calls 1

updateHandleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…