1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-31 19:01:54 +02:00

Rename <Slate> component value prop to initialValue (#5421)

* Rename `slate-react` Slate component `value` prop to `initialValue`

Fixes #4992

* Update documentation: `value` -> `initialValue`

* Add a changeset record

* Make props order consistent
This commit is contained in:
Ivan Voskoboinyk
2023-05-26 17:53:39 +03:00
committed by GitHub
parent 0b1799091a
commit 91e388ecd9
34 changed files with 71 additions and 56 deletions

View File

@@ -53,7 +53,7 @@ const App = () => {
const [editor] = useState(() => withReact(createEditor()))
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable />
</Slate>
)

View File

@@ -309,7 +309,7 @@ const [value, setValue] = useState(initialValue)
const [selection, setSelection] = useState(null)
<Slate
value={value}
initialValue={initialValue}
selection={selection}
onChange={(value, selection) => {
setValue(value)

View File

@@ -81,7 +81,7 @@ const initialValue = [
const App = () => {
const [editor] = useState(() => withReact(createEditor()))
// Render the Slate context.
return <Slate editor={editor} value={initialValue} />
return <Slate editor={editor} initialValue={initialValue} />
}
```
@@ -107,7 +107,7 @@ const App = () => {
const [editor] = useState(() => withReact(createEditor()))
return (
// Add the editable component inside the context.
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable />
</Slate>
)

View File

@@ -20,7 +20,7 @@ const App = () => {
const [editor] = useState(() => withReact(createEditor()))
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable />
</Slate>
)
@@ -41,7 +41,7 @@ const App = () => {
const [editor] = useState(() => withReact(createEditor()))
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
// Define a new handler which prints the key that was pressed.
onKeyDown={event => {
@@ -71,7 +71,7 @@ const App = () => {
const [editor] = useState(() => withReact(createEditor()))
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
onKeyDown={event => {
if (event.key === '&') {

View File

@@ -18,7 +18,7 @@ const App = () => {
const [editor] = useState(() => withReact(createEditor()))
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
onKeyDown={event => {
if (event.key === '&') {
@@ -88,7 +88,7 @@ const App = () => {
}, [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
// Pass in the `renderElement` function.
renderElement={renderElement}
@@ -142,7 +142,7 @@ const App = () => {
}, [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
renderElement={renderElement}
onKeyDown={event => {
@@ -200,7 +200,7 @@ const App = () => {
}, [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
renderElement={renderElement}
onKeyDown={event => {

View File

@@ -27,7 +27,7 @@ const App = () => {
const [editor] = useState(() => withReact(createEditor()))
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
renderElement={renderElement}
onKeyDown={event => {
@@ -72,7 +72,7 @@ const App = () => {
}, [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
renderElement={renderElement}
onKeyDown={event => {
@@ -163,7 +163,7 @@ const App = () => {
}, [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
renderElement={renderElement}
// Pass in the `renderLeaf` function.

View File

@@ -35,7 +35,7 @@ const App = () => {
}, [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
renderElement={renderElement}
renderLeaf={renderLeaf}
@@ -142,7 +142,7 @@ const App = () => {
}, [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
renderElement={renderElement}
renderLeaf={renderLeaf}
@@ -200,7 +200,7 @@ const App = () => {
return (
// Add a toolbar with buttons that call the same methods.
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<div>
<button
onMouseDown={event => {

View File

@@ -18,7 +18,7 @@ const App = () => {
const [editor] = useState(() => withReact(createEditor()))
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable />
</Slate>
)
@@ -45,7 +45,7 @@ const App = () => {
return (
<Slate
editor={editor}
value={initialValue}
initialValue={initialValue}
onChange={value => {
const isAstChange = editor.operations.some(
op => 'set_selection' !== op.type
@@ -85,7 +85,7 @@ const App = () => {
return (
<Slate
editor={editor}
value={initialValue}
initialValue={initialValue}
onChange={value => {
const isAstChange = editor.operations.some(
op => 'set_selection' !== op.type
@@ -145,7 +145,7 @@ const App = () => {
return (
<Slate
editor={editor}
value={initialValue}
initialValue={initialValue}
onChange={value => {
const isAstChange = editor.operations.some(
op => 'set_selection' !== op.type