Skip to content

Commit 4f0109a

Browse files
committed
doc: Update Document (#378).
1 parent 5ce66e2 commit 4f0109a

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

core/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,17 @@ CodeMirror allows to serialize editor state to JSON representation with [toJSON]
283283

284284
For example, this is how undo history can be saved in the local storage, so that it remains after the page reloads
285285

286-
```
287-
import CodeMirror from '@uiw/react-codemirror'
288-
import { historyField } from '@codemirror/commands'
286+
```jsx
287+
import CodeMirror from '@uiw/react-codemirror';
288+
import { historyField } from '@codemirror/commands';
289289

290290
// When custom fields should be serialized, you can pass them in as an object mapping property names to fields.
291291
// See [toJSON](https://codemirror.net/docs/ref/#state.EditorState.toJSON) documentation for more details
292-
const stateFields = { history: historyField }
292+
const stateFields = { history: historyField };
293293

294294
export function EditorWithInitialState() {
295-
const serializedState = localStorage.getItem('myEditorState')
296-
const value = localStorage.getItem('myValue') || ''
295+
const serializedState = localStorage.getItem('myEditorState');
296+
const value = localStorage.getItem('myValue') || '';
297297

298298
return (
299299
<CodeMirror
@@ -307,13 +307,13 @@ export function EditorWithInitialState() {
307307
: undefined
308308
}
309309
onChange={(value, viewUpdate) => {
310-
localStorage.setItem('myValue', value)
310+
localStorage.setItem('myValue', value);
311311

312-
const state = viewUpdate.state.toJSON(stateFields)
313-
localStorage.setItem('myEditorState', JSON.stringify(state))
312+
const state = viewUpdate.state.toJSON(stateFields);
313+
localStorage.setItem('myEditorState', JSON.stringify(state));
314314
}}
315315
/>
316-
)
316+
);
317317
}
318318
```
319319

core/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface ReactCodeMirrorProps
7474
*/
7575
initialState?: {
7676
json: any;
77-
fields?: Record<'string', StateField<any>>;
77+
fields?: Record<string, StateField<any>>;
7878
};
7979
}
8080

0 commit comments

Comments
 (0)