Skip to content

Commit fd6a8db

Browse files
committedAug 3, 2023
website: add example. (#455)
1 parent 1502eef commit fd6a8db

File tree

7 files changed

+41
-13
lines changed

7 files changed

+41
-13
lines changed
 

‎www/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"react-code-preview-layout": "^3.0.1",
8383
"react-codemirror-merge": "4.21.9",
8484
"react-dom": "~18.2.0",
85-
"react-router-dom": "^6.3.0",
85+
"react-router-dom": "^6.14.2",
8686
"rehype-ignore": "^1.0.1",
8787
"styled-components": "^5.3.5"
8888
},

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Fragment } from 'react';
55
/**
66
* https://github.com/uiwjs/react-codemirror/issues/431
77
*/
8-
export const PageExample431 = () => {
8+
export function Component() {
99
return (
1010
<Fragment>
1111
<CodeMirror
@@ -18,4 +18,4 @@ export const PageExample431 = () => {
1818
/>
1919
</Fragment>
2020
);
21-
};
21+
}

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

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import CodeMirrorMerge from 'react-codemirror-merge';
2+
import { EditorView } from 'codemirror';
3+
import { EditorState } from '@codemirror/state';
4+
import { androidstudio } from '@uiw/codemirror-theme-androidstudio';
5+
6+
const Original = CodeMirrorMerge.Original;
7+
const Modified = CodeMirrorMerge.Modified;
8+
/**
9+
* https://github.com/uiwjs/react-codemirror/issues/455
10+
*/
11+
let doc = `one
12+
two
13+
three
14+
four
15+
five`;
16+
17+
export function Component() {
18+
return (
19+
<CodeMirrorMerge style={{ width: 540 }} orientation="b-a" theme={androidstudio}>
20+
<Original value={doc} />
21+
<Modified
22+
value={doc.replace(/t/g, 'T') + 'Six'}
23+
extensions={[EditorView.editable.of(false), EditorState.readOnly.of(true)]}
24+
/>
25+
</CodeMirrorMerge>
26+
);
27+
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ export function Component() {
2626
);
2727
}
2828

29-
Component.displayName = 'HomePage';
29+
Component.displayName = 'PageExampleRef';

‎www/src/pages/home/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const hyperlink: {
127127
},
128128
];
129129

130-
export default function App() {
130+
export function Component() {
131131
const version = VERSION;
132132
return (
133133
<div className="wmde-markdown-var">

‎www/src/pages/theme/home/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const CodeEditor = styled(CodeMirror)`
6969
}
7070
`;
7171

72-
export function ThemesHome() {
72+
export function Component() {
7373
return (
7474
<Warpper>
7575
<ThemesWarpper>

‎www/src/router.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import React from 'react';
22
import { Navigate, IndexRouteObject, NonIndexRouteObject, Outlet } from 'react-router-dom';
33
import { Layout } from './components/Layout';
44
import { ErrorPage } from './components/ErrorPage';
5-
import { ThemesHome } from './pages/theme/home';
65
import { ThemeEditor } from './pages/theme/editor';
7-
import { PageExample431 } from './pages/examples/Example431';
8-
9-
import Home from './pages/home';
106

117
import { BasicSetupExample } from './pages/extensions/basic-setup/example';
128
import { ClassNameExample } from './pages/extensions/classname/example';
@@ -40,7 +36,7 @@ export const routes: MenuRouteObject[] = [
4036
{
4137
index: true,
4238
label: 'Home',
43-
Component: Home,
39+
lazy: () => import('./pages/home'),
4440
},
4541
{
4642
path: 'extensions',
@@ -174,7 +170,7 @@ export const routes: MenuRouteObject[] = [
174170
{
175171
path: 'home',
176172
label: 'Home',
177-
Component: ThemesHome,
173+
lazy: () => import('./pages/theme/home'),
178174
},
179175
{
180176
path: 'data',
@@ -540,7 +536,12 @@ export const routes: MenuRouteObject[] = [
540536
{
541537
path: '431',
542538
label: 'How to remove all syntax highlighting?',
543-
Component: PageExample431,
539+
lazy: () => import('./pages/examples/Example431'),
540+
},
541+
{
542+
path: '455',
543+
label: 'CodeMirrorMerge use theme',
544+
lazy: () => import('./pages/examples/Example455'),
544545
},
545546
{
546547
path: 'refs',

0 commit comments

Comments
 (0)
Please sign in to comment.