@vonaffenfels/slate-editor 1.1.51 → 1.1.52

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonaffenfels/slate-editor",
3
- "version": "1.1.51",
3
+ "version": "1.1.52",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -72,7 +72,7 @@
72
72
  "cssnano": "^5.0.1",
73
73
  "escape-html": "^1.0.3"
74
74
  },
75
- "gitHead": "b95716b54761425787bdbbd58d7324005c26902c",
75
+ "gitHead": "88c7407b7b42841eb1d38405a5c24c78bc5e6b7d",
76
76
  "publishConfig": {
77
77
  "access": "public"
78
78
  }
@@ -168,6 +168,20 @@ export default function BlockEditor({
168
168
  }
169
169
  };
170
170
 
171
+ const fixedValue = useMemo(() => {
172
+ if (!Array.isArray(value)) {
173
+ return [];
174
+ }
175
+
176
+ return value.map(node => {
177
+ if (!node.children) {
178
+ node.children = [{text: ""}];
179
+ }
180
+
181
+ return node;
182
+ });
183
+ }, [value]);
184
+
171
185
  const editor = useMemo(() => {
172
186
  const editor = withHistory(withReact(createEditor()));
173
187
  const {
@@ -391,7 +405,7 @@ export default function BlockEditor({
391
405
  left={<div className="slate-editor h-full">
392
406
  <Slate
393
407
  editor={editor}
394
- value={value}
408
+ value={fixedValue}
395
409
  onChange={v => {
396
410
  onSlateChange(v);
397
411
  }}
@@ -406,7 +420,11 @@ export default function BlockEditor({
406
420
  sdk={contentfulSdk}
407
421
  lastSelection={lastSelection}
408
422
  buttons={<div className="flex gap-2">
409
- <TranslationToolbarButton sdk={contentfulSdk} setEditorValue={onSlateChange} locale={locale} setLocale={setLocale}/>
423
+ <TranslationToolbarButton
424
+ sdk={contentfulSdk}
425
+ setEditorValue={onSlateChange}
426
+ locale={locale}
427
+ setLocale={setLocale}/>
410
428
  {liveLink && (
411
429
  <a href={liveLink} target="_blank" rel="noreferrer">
412
430
  <button className='button button--secondary'>Live-Seite öffnen</button>