Skip to content

Commit

Permalink
Update with-slate example
Browse files Browse the repository at this point in the history
## Changelog

- Updated slate.js to version 0.58.4
- Removed unused packages (immutable & slate-plain-serializer)
- Simplified example (we don’t need to demonstrate the multi editor case anymore since this issue is now handled by slate internally)
- Remove deprecated `KeyUtils`
- Removed deprecated Components

## Related:

- ianstormtaylor/slate#870
  • Loading branch information
HaNdTriX committed Sep 9, 2020
1 parent fceb566 commit 2ff8f2f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 68 deletions.
19 changes: 0 additions & 19 deletions examples/with-slate/components/NextEditor.js

This file was deleted.

14 changes: 0 additions & 14 deletions examples/with-slate/lib/useCustomKeygen.js

This file was deleted.

7 changes: 3 additions & 4 deletions examples/with-slate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
"start": "next start"
},
"dependencies": {
"immutable": "^3.8.2",
"next": "latest",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"slate": "^0.37.0",
"slate-plain-serializer": "^0.5.27",
"slate-react": "^0.15.0"
"slate": "^0.58.4",
"slate-history": "0.58.4",
"slate-react": "^0.58.4"
},
"license": "MIT"
}
31 changes: 18 additions & 13 deletions examples/with-slate/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import Link from 'next/link'
import NextEditor from '../components/NextEditor'
import React, { useState, useMemo } from 'react'
import { createEditor } from 'slate'
import { Slate, Editable, withReact } from 'slate-react'
import { withHistory } from 'slate-history'

const IndexPage = (props) => {
const IndexPage = () => {
const [value, setValue] = useState(initialValue)
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return (
<>
<Link href="/multiple">
<a>Go to multiple</a>
</Link>
<hr />
<NextEditor
slateKey="someUniqueKey"
defaultValue="This is editable plain text, just like a <textarea>!"
/>
</>
<Slate editor={editor} value={value} onChange={(value) => setValue(value)}>
<Editable placeholder="Enter some plain text..." />
</Slate>
)
}

const initialValue = [
{
children: [
{ text: 'This is editable plain text, just like a <textarea>!' },
],
},
]

export default IndexPage
18 changes: 0 additions & 18 deletions examples/with-slate/pages/multiple.js

This file was deleted.

0 comments on commit 2ff8f2f

Please sign in to comment.