From 91e388ecd9e6a540b4a651978436f196f38f667d Mon Sep 17 00:00:00 2001 From: Ivan Voskoboinyk Date: Fri, 26 May 2023 17:53:39 +0300 Subject: [PATCH] Rename `` 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 --- .changeset/tiny-suns-lick.md | 5 +++++ docs/concepts/12-typescript.md | 2 +- docs/general/changelog.md | 2 +- docs/walkthroughs/01-installing-slate.md | 4 ++-- docs/walkthroughs/02-adding-event-handlers.md | 6 +++--- .../03-defining-custom-elements.md | 8 ++++---- .../04-applying-custom-formatting.md | 6 +++--- docs/walkthroughs/05-executing-commands.md | 6 +++--- docs/walkthroughs/06-saving-to-a-database.md | 8 ++++---- packages/slate-react/src/components/slate.tsx | 12 ++++++------ packages/slate-react/test/index.spec.tsx | 18 ++++++++++++++---- site/examples/check-lists.tsx | 2 +- site/examples/code-highlighting.tsx | 4 ++-- site/examples/custom-placeholder.tsx | 2 +- site/examples/editable-voids.tsx | 2 +- site/examples/embeds.tsx | 2 +- site/examples/forced-layout.tsx | 2 +- site/examples/hovering-toolbar.tsx | 2 +- site/examples/huge-document.tsx | 2 +- site/examples/iframe.tsx | 2 +- site/examples/images.tsx | 2 +- site/examples/inlines.tsx | 2 +- site/examples/markdown-preview.tsx | 2 +- site/examples/markdown-shortcuts.tsx | 2 +- site/examples/mentions.tsx | 2 +- site/examples/paste-html.tsx | 2 +- site/examples/plaintext.tsx | 2 +- site/examples/read-only.tsx | 2 +- site/examples/richtext.tsx | 2 +- site/examples/scroll-into-view.tsx | 2 +- site/examples/search-highlighting.tsx | 2 +- site/examples/shadow-dom.tsx | 2 +- site/examples/styling.tsx | 4 ++-- site/examples/tables.tsx | 2 +- 34 files changed, 71 insertions(+), 56 deletions(-) create mode 100644 .changeset/tiny-suns-lick.md diff --git a/.changeset/tiny-suns-lick.md b/.changeset/tiny-suns-lick.md new file mode 100644 index 000000000..91740edd9 --- /dev/null +++ b/.changeset/tiny-suns-lick.md @@ -0,0 +1,5 @@ +--- +'slate-react': minor +--- + +Rename `` component prop from `value` to `initialValue` to emphasize uncontrolled nature of it diff --git a/docs/concepts/12-typescript.md b/docs/concepts/12-typescript.md index 51f494379..647cdb05d 100644 --- a/docs/concepts/12-typescript.md +++ b/docs/concepts/12-typescript.md @@ -53,7 +53,7 @@ const App = () => { const [editor] = useState(() => withReact(createEditor())) return ( - + ) diff --git a/docs/general/changelog.md b/docs/general/changelog.md index da54e2c5d..8612a3319 100644 --- a/docs/general/changelog.md +++ b/docs/general/changelog.md @@ -309,7 +309,7 @@ const [value, setValue] = useState(initialValue) const [selection, setSelection] = useState(null) { setValue(value) diff --git a/docs/walkthroughs/01-installing-slate.md b/docs/walkthroughs/01-installing-slate.md index df78cdfab..49f384cc7 100644 --- a/docs/walkthroughs/01-installing-slate.md +++ b/docs/walkthroughs/01-installing-slate.md @@ -81,7 +81,7 @@ const initialValue = [ const App = () => { const [editor] = useState(() => withReact(createEditor())) // Render the Slate context. - return + return } ``` @@ -107,7 +107,7 @@ const App = () => { const [editor] = useState(() => withReact(createEditor())) return ( // Add the editable component inside the context. - + ) diff --git a/docs/walkthroughs/02-adding-event-handlers.md b/docs/walkthroughs/02-adding-event-handlers.md index 254194539..8b509ddc6 100644 --- a/docs/walkthroughs/02-adding-event-handlers.md +++ b/docs/walkthroughs/02-adding-event-handlers.md @@ -20,7 +20,7 @@ const App = () => { const [editor] = useState(() => withReact(createEditor())) return ( - + ) @@ -41,7 +41,7 @@ const App = () => { const [editor] = useState(() => withReact(createEditor())) return ( - + { @@ -71,7 +71,7 @@ const App = () => { const [editor] = useState(() => withReact(createEditor())) return ( - + { if (event.key === '&') { diff --git a/docs/walkthroughs/03-defining-custom-elements.md b/docs/walkthroughs/03-defining-custom-elements.md index 26ab208fb..1adbafa76 100644 --- a/docs/walkthroughs/03-defining-custom-elements.md +++ b/docs/walkthroughs/03-defining-custom-elements.md @@ -18,7 +18,7 @@ const App = () => { const [editor] = useState(() => withReact(createEditor())) return ( - + { if (event.key === '&') { @@ -88,7 +88,7 @@ const App = () => { }, []) return ( - + { }, []) return ( - + { @@ -200,7 +200,7 @@ const App = () => { }, []) return ( - + { diff --git a/docs/walkthroughs/04-applying-custom-formatting.md b/docs/walkthroughs/04-applying-custom-formatting.md index 7208c802c..bf6fd51c3 100644 --- a/docs/walkthroughs/04-applying-custom-formatting.md +++ b/docs/walkthroughs/04-applying-custom-formatting.md @@ -27,7 +27,7 @@ const App = () => { const [editor] = useState(() => withReact(createEditor())) return ( - + { @@ -72,7 +72,7 @@ const App = () => { }, []) return ( - + { @@ -163,7 +163,7 @@ const App = () => { }, []) return ( - + { }, []) return ( - + { }, []) return ( - + { return ( // Add a toolbar with buttons that call the same methods. - +