@portabletext/editor 1.10.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -62,15 +62,32 @@ Use `useEditor` to create an `editor` and pass that into `PortableTextEditor`. U
62
62
 
63
63
  ```tsx
64
64
  function App() {
65
+ const [value, setValue] = useState<Array<PortableTextBlock> | undefined>(
66
+ // Initial value
67
+ () => [
68
+ {
69
+ _type: 'block',
70
+ _key: keyGenerator(),
71
+ children: [
72
+ {_type: 'span', _key: keyGenerator(), text: 'Hello, '},
73
+ {
74
+ _type: 'span',
75
+ _key: keyGenerator(),
76
+ text: 'world!',
77
+ marks: ['strong'],
78
+ },
79
+ ],
80
+ },
81
+ ],
82
+ )
83
+
65
84
  // Create an editor
66
85
  const editor = useEditor({
67
86
  schemaDefinition,
87
+ // With an optional initial value
88
+ initialValue: value,
68
89
  })
69
90
 
70
- const [value, setValue] = useState<Array<PortableTextBlock> | undefined>(
71
- undefined,
72
- )
73
-
74
91
  // Subscribe to editor changes
75
92
  useEffect(() => {
76
93
  const subscription = editor.on('mutation', (mutation) => {
@@ -87,8 +104,6 @@ function App() {
87
104
  <PortableTextEditor
88
105
  // Pass in the `editor` you created earlier
89
106
  editor={editor}
90
- // And an optional value
91
- value={value}
92
107
  >
93
108
  {/* Toolbar needs to be rendered inside the `PortableTextEditor` component */}
94
109
  <Toolbar />