Download react-page/docs/examples/slate-plugin-src/migrations/v002.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 653 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-page/docs/examples/slate-plugin-src/migrations/v002.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-page/docs/examples/slate-plugin-src/migrations/v002.ts
-
curl -L -o v002.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-page/docs/examples/slate-plugin-src/migrations/v002.ts
653 Bytes
| import { Migration } from '@react-page/editor'; | |
| import rename from 'deep-rename-keys'; | |
| const migration = new Migration({ | |
| toVersion: '0.0.2', | |
| fromVersionRange: '^0.0.1', | |
| migrate: (state) => { | |
| // wrap with document | |
| state = { | |
| ...state, | |
| ...(state.serialized | |
| ? { serialized: { document: state.serialized } } | |
| : {}), | |
| }; | |
| // rename keys | |
| state = rename(state, (key: string) => { | |
| switch (key) { | |
| case 'kind': | |
| return 'object'; | |
| case 'ranges': | |
| return 'leaves'; | |
| default: | |
| return key; | |
| } | |
| }); | |
| return state; | |
| }, | |
| }); | |
| export default migration; | |