(props = {} as { mdStr: string })
| 11 | let count = 1; |
| 12 | |
| 13 | const 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> |
nothing calls this directly
no test coverage detected
searching dependent graphs…