1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-02 19:52:32 +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

@@ -73,7 +73,7 @@ const CheckListsExample = () => {
)
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
renderElement={renderElement}
placeholder="Get to work…"

View File

@@ -46,7 +46,7 @@ const CodeHighlightingExample = () => {
const onKeyDown = useOnKeydown(editor)
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<ExampleToolbar />
<SetNodeToDecorations />
<Editable
@@ -324,7 +324,7 @@ const App = () => {
const [editor] = useState(() => withReact(createEditor()))
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable />
</Slate>
)

View File

@@ -13,7 +13,7 @@ const initialValue: Descendant[] = [
const PlainTextExample = () => {
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
placeholder="Type something"
renderPlaceholder={({ children, attributes }) => (

View File

@@ -15,7 +15,7 @@ const EditableVoidsExample = () => {
)
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Toolbar>
<InsertEditableVoidButton />
</Toolbar>

View File

@@ -16,7 +16,7 @@ import {
const EmbedsExample = () => {
const editor = useMemo(() => withEmbeds(withReact(createEditor())), [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
renderElement={props => <Element {...props} />}
placeholder="Enter some text..."

View File

@@ -74,7 +74,7 @@ const ForcedLayoutExample = () => {
[]
)
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
renderElement={renderElement}
placeholder="Enter a title…"

View File

@@ -17,7 +17,7 @@ const HoveringMenuExample = () => {
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<HoveringToolbar />
<Editable
renderLeaf={props => <Leaf {...props} />}

View File

@@ -25,7 +25,7 @@ const HugeDocumentExample = () => {
const renderElement = useCallback(props => <Element {...props} />, [])
const editor = useMemo(() => withReact(createEditor()), [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable renderElement={renderElement} spellCheck autoFocus />
</Slate>
)

View File

@@ -25,7 +25,7 @@ const IFrameExample = () => {
const handleBlur = useCallback(() => ReactEditor.deselect(editor), [editor])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Toolbar>
<MarkButton format="bold" icon="format_bold" />
<MarkButton format="italic" icon="format_italic" />

View File

@@ -25,7 +25,7 @@ const ImagesExample = () => {
)
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Toolbar>
<InsertImageButton />
</Toolbar>

View File

@@ -98,7 +98,7 @@ const InlinesExample = () => {
}
return (
<SlateReact.Slate editor={editor} value={initialValue}>
<SlateReact.Slate editor={editor} initialValue={initialValue}>
<Toolbar>
<AddLinkButton />
<RemoveLinkButton />

View File

@@ -48,7 +48,7 @@ const MarkdownPreviewExample = () => {
}, [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
decorate={decorate}
renderLeaf={renderLeaf}

View File

@@ -70,7 +70,7 @@ const MarkdownShortcutsExample = () => {
)
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
onDOMBeforeInput={handleDOMBeforeInput}
renderElement={renderElement}

View File

@@ -73,7 +73,7 @@ const MentionExample = () => {
return (
<Slate
editor={editor}
value={initialValue}
initialValue={initialValue}
onChange={() => {
const { selection } = editor

View File

@@ -91,7 +91,7 @@ const PasteHtmlExample = () => {
[]
)
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable
renderElement={renderElement}
renderLeaf={renderLeaf}

View File

@@ -6,7 +6,7 @@ import { withHistory } from 'slate-history'
const PlainTextExample = () => {
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable placeholder="Enter some plain text..." />
</Slate>
)

View File

@@ -5,7 +5,7 @@ import { Slate, Editable, withReact } from 'slate-react'
const ReadOnlyExample = () => {
const editor = useMemo(() => withReact(createEditor()), [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable readOnly placeholder="Enter some plain text..." />
</Slate>
)

View File

@@ -28,7 +28,7 @@ const RichTextExample = () => {
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Toolbar>
<MarkButton format="bold" icon="format_bold" />
<MarkButton format="italic" icon="format_italic" />

View File

@@ -51,7 +51,7 @@ const ScrollIntoViewExample = () => {
const PlainTextEditor = () => {
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable placeholder="Enter some plain text..." />
</Slate>
)

View File

@@ -37,7 +37,7 @@ const SearchHighlightingExample = () => {
)
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Toolbar>
<div
className={css`

View File

@@ -31,7 +31,7 @@ const ShadowEditor = () => {
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable placeholder="Enter some plain text..." />
</Slate>
)

View File

@@ -11,7 +11,7 @@ const StylingExample = () => {
<div style={{ display: 'flex', flexDirection: 'column', gap: '40px' }}>
<Slate
editor={editor1}
value={[
initialValue={[
{
type: 'paragraph',
children: [{ text: 'This editor is styled using the style prop.' }],
@@ -29,7 +29,7 @@ const StylingExample = () => {
<Slate
editor={editor2}
value={[
initialValue={[
{
type: 'paragraph',
children: [

View File

@@ -18,7 +18,7 @@ const TablesExample = () => {
[]
)
return (
<Slate editor={editor} value={initialValue}>
<Slate editor={editor} initialValue={initialValue}>
<Editable renderElement={renderElement} renderLeaf={renderLeaf} />
</Slate>
)