Skip to content

Commit 7d69894

Browse files
committedMay 22, 2023
website: update example.
1 parent ec88a44 commit 7d69894

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
 

‎www/src/pages/examples/ExampleRef.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import CodeMirror, { ReactCodeMirrorRef } from '@uiw/react-codemirror';
2+
import { langs } from '@uiw/codemirror-extensions-langs';
3+
import { useEffect, useRef } from 'react';
4+
5+
export function Component() {
6+
const $edit = useRef<ReactCodeMirrorRef>(null);
7+
useEffect(() => {
8+
console.log('$edit:', $edit);
9+
setTimeout(() => {
10+
console.log('$edit:view:', $edit.current?.view);
11+
console.log('$edit:state:', $edit.current?.state);
12+
}, 300);
13+
console.log('$edit:', $edit.current?.view);
14+
}, [$edit]);
15+
return (
16+
<div>
17+
<CodeMirror
18+
value={`console.log('hello')`}
19+
theme="none"
20+
ref={$edit}
21+
height="400px"
22+
width="100%"
23+
style={{ margin: '0 0 23px 0', flex: 1 }}
24+
extensions={[langs.markdown()]}
25+
/>
26+
</div>
27+
);
28+
}
29+
30+
Component.displayName = 'HomePage';

‎www/src/router.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,11 @@ export const routes: MenuRouteObject[] = [
525525
label: 'How to remove all syntax highlighting?',
526526
Component: PageExample431,
527527
},
528+
{
529+
path: 'refs',
530+
label: 'Refs Example',
531+
lazy: () => import('./pages/examples/ExampleRef'),
532+
},
528533
],
529534
},
530535
],

0 commit comments

Comments
 (0)
Please sign in to comment.