@contentful/field-editor-rich-text 4.19.0 → 4.19.2

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.
@@ -18,7 +18,8 @@ describe('toSlateDoc', ()=>{
18
18
  text: ''
19
19
  }
20
20
  ],
21
- data: {}
21
+ data: {},
22
+ isVoid: false
22
23
  }
23
24
  ]
24
25
  },
@@ -33,7 +34,8 @@ describe('toSlateDoc', ()=>{
33
34
  text: ''
34
35
  }
35
36
  ],
36
- data: {}
37
+ data: {},
38
+ isVoid: false
37
39
  }
38
40
  ]
39
41
  },
@@ -48,7 +50,8 @@ describe('toSlateDoc', ()=>{
48
50
  text: ''
49
51
  }
50
52
  ],
51
- data: {}
53
+ data: {},
54
+ isVoid: false
52
55
  }
53
56
  ]
54
57
  },
@@ -86,7 +89,8 @@ describe('toSlateDoc', ()=>{
86
89
  data: {}
87
90
  }
88
91
  ],
89
- data: {}
92
+ data: {},
93
+ isVoid: false
90
94
  }
91
95
  ]
92
96
  },
@@ -107,7 +111,8 @@ describe('toSlateDoc', ()=>{
107
111
  {
108
112
  text: ''
109
113
  }
110
- ]
114
+ ],
115
+ isVoid: true
111
116
  },
112
117
  {
113
118
  text: ''
@@ -119,13 +124,15 @@ describe('toSlateDoc', ()=>{
119
124
  {
120
125
  text: ''
121
126
  }
122
- ]
127
+ ],
128
+ isVoid: true
123
129
  },
124
130
  {
125
131
  text: ''
126
132
  }
127
133
  ],
128
- data: {}
134
+ data: {},
135
+ isVoid: false
129
136
  }
130
137
  ]
131
138
  },
@@ -153,9 +160,11 @@ describe('toSlateDoc', ()=>{
153
160
  text: 'cell #1',
154
161
  data: {}
155
162
  }
156
- ]
163
+ ],
164
+ isVoid: false
157
165
  }
158
- ]
166
+ ],
167
+ isVoid: false
159
168
  },
160
169
  {
161
170
  type: 'table-header-cell',
@@ -168,9 +177,11 @@ describe('toSlateDoc', ()=>{
168
177
  {
169
178
  text: ''
170
179
  }
171
- ]
180
+ ],
181
+ isVoid: false
172
182
  }
173
- ]
183
+ ],
184
+ isVoid: false
174
185
  },
175
186
  {
176
187
  type: 'table-header-cell',
@@ -183,11 +194,14 @@ describe('toSlateDoc', ()=>{
183
194
  {
184
195
  text: ''
185
196
  }
186
- ]
197
+ ],
198
+ isVoid: false
187
199
  }
188
- ]
200
+ ],
201
+ isVoid: false
189
202
  }
190
- ]
203
+ ],
204
+ isVoid: false
191
205
  },
192
206
  {
193
207
  type: 'table-row',
@@ -205,9 +219,11 @@ describe('toSlateDoc', ()=>{
205
219
  text: 'cell #1',
206
220
  data: {}
207
221
  }
208
- ]
222
+ ],
223
+ isVoid: false
209
224
  }
210
- ]
225
+ ],
226
+ isVoid: false
211
227
  },
212
228
  {
213
229
  type: 'table-cell',
@@ -221,9 +237,11 @@ describe('toSlateDoc', ()=>{
221
237
  text: 'cell #2',
222
238
  data: {}
223
239
  }
224
- ]
240
+ ],
241
+ isVoid: false
225
242
  }
226
- ]
243
+ ],
244
+ isVoid: false
227
245
  },
228
246
  {
229
247
  type: 'table-cell',
@@ -237,11 +255,14 @@ describe('toSlateDoc', ()=>{
237
255
  text: 'cell #3',
238
256
  data: {}
239
257
  }
240
- ]
258
+ ],
259
+ isVoid: false
241
260
  }
242
- ]
261
+ ],
262
+ isVoid: false
243
263
  }
244
- ]
264
+ ],
265
+ isVoid: false
245
266
  },
246
267
  {
247
268
  type: 'table-row',
@@ -259,9 +280,11 @@ describe('toSlateDoc', ()=>{
259
280
  text: 'cell #1',
260
281
  data: {}
261
282
  }
262
- ]
283
+ ],
284
+ isVoid: false
263
285
  }
264
- ]
286
+ ],
287
+ isVoid: false
265
288
  },
266
289
  {
267
290
  type: 'table-cell',
@@ -275,9 +298,11 @@ describe('toSlateDoc', ()=>{
275
298
  text: 'cell #2',
276
299
  data: {}
277
300
  }
278
- ]
301
+ ],
302
+ isVoid: false
279
303
  }
280
- ]
304
+ ],
305
+ isVoid: false
281
306
  },
282
307
  {
283
308
  type: 'table-cell',
@@ -290,13 +315,17 @@ describe('toSlateDoc', ()=>{
290
315
  {
291
316
  text: ''
292
317
  }
293
- ]
318
+ ],
319
+ isVoid: false
294
320
  }
295
- ]
321
+ ],
322
+ isVoid: false
296
323
  }
297
- ]
324
+ ],
325
+ isVoid: false
298
326
  }
299
- ]
327
+ ],
328
+ isVoid: false
300
329
  },
301
330
  {
302
331
  type: 'paragraph',
@@ -305,7 +334,8 @@ describe('toSlateDoc', ()=>{
305
334
  {
306
335
  text: ''
307
336
  }
308
- ]
337
+ ],
338
+ isVoid: false
309
339
  }
310
340
  ]
311
341
  },
@@ -324,9 +354,11 @@ describe('toSlateDoc', ()=>{
324
354
  {
325
355
  text: ''
326
356
  }
327
- ]
357
+ ],
358
+ isVoid: false
328
359
  }
329
- ]
360
+ ],
361
+ isVoid: false
330
362
  },
331
363
  {
332
364
  type: 'paragraph',
@@ -335,7 +367,8 @@ describe('toSlateDoc', ()=>{
335
367
  {
336
368
  text: ''
337
369
  }
338
- ]
370
+ ],
371
+ isVoid: false
339
372
  }
340
373
  ]
341
374
  },
@@ -354,9 +387,11 @@ describe('toSlateDoc', ()=>{
354
387
  {
355
388
  text: ''
356
389
  }
357
- ]
390
+ ],
391
+ isVoid: false
358
392
  }
359
- ]
393
+ ],
394
+ isVoid: false
360
395
  },
361
396
  {
362
397
  type: 'paragraph',
@@ -365,7 +400,8 @@ describe('toSlateDoc', ()=>{
365
400
  {
366
401
  text: ''
367
402
  }
368
- ]
403
+ ],
404
+ isVoid: false
369
405
  }
370
406
  ]
371
407
  },
@@ -388,11 +424,14 @@ describe('toSlateDoc', ()=>{
388
424
  {
389
425
  text: ''
390
426
  }
391
- ]
427
+ ],
428
+ isVoid: false
392
429
  }
393
- ]
430
+ ],
431
+ isVoid: false
394
432
  }
395
- ]
433
+ ],
434
+ isVoid: false
396
435
  },
397
436
  {
398
437
  type: 'ordered-list',
@@ -409,11 +448,14 @@ describe('toSlateDoc', ()=>{
409
448
  {
410
449
  text: ''
411
450
  }
412
- ]
451
+ ],
452
+ isVoid: false
413
453
  }
414
- ]
454
+ ],
455
+ isVoid: false
415
456
  }
416
- ]
457
+ ],
458
+ isVoid: false
417
459
  },
418
460
  {
419
461
  type: 'paragraph',
@@ -422,7 +464,140 @@ describe('toSlateDoc', ()=>{
422
464
  {
423
465
  text: ''
424
466
  }
425
- ]
467
+ ],
468
+ isVoid: false
469
+ }
470
+ ]
471
+ },
472
+ {
473
+ title: 'list of embedded entry blocks',
474
+ input: (0, _nodeFactory.document)((0, _nodeFactory.block)(_richtexttypes.BLOCKS.EMBEDDED_ENTRY, {
475
+ target: {
476
+ sys: {
477
+ id: '4jo9APjyJs31WugGbV0E42',
478
+ type: 'Link',
479
+ linkType: 'Entry'
480
+ }
481
+ }
482
+ }), (0, _nodeFactory.block)(_richtexttypes.BLOCKS.EMBEDDED_ENTRY, {
483
+ target: {
484
+ sys: {
485
+ id: '2bwp9MdklBd4WVLGm1Fngy',
486
+ type: 'Link',
487
+ linkType: 'Entry'
488
+ }
489
+ }
490
+ }), (0, _nodeFactory.block)(_richtexttypes.BLOCKS.EMBEDDED_ENTRY, {
491
+ target: {
492
+ sys: {
493
+ id: '73qAHseh6G40k7ndmON5OD',
494
+ type: 'Link',
495
+ linkType: 'Entry'
496
+ }
497
+ }
498
+ }), (0, _nodeFactory.block)(_richtexttypes.BLOCKS.EMBEDDED_ENTRY, {
499
+ target: {
500
+ sys: {
501
+ id: '7FYYiCprd5VwItrHH3nNJj',
502
+ type: 'Link',
503
+ linkType: 'Entry'
504
+ }
505
+ }
506
+ }), (0, _nodeFactory.block)(_richtexttypes.BLOCKS.PARAGRAPH, {}, (0, _nodeFactory.text)('')), (0, _nodeFactory.block)(_richtexttypes.BLOCKS.PARAGRAPH, {}, (0, _nodeFactory.text)(''))),
507
+ expected: [
508
+ {
509
+ type: 'embedded-entry-block',
510
+ children: [
511
+ {
512
+ text: ''
513
+ }
514
+ ],
515
+ data: {
516
+ target: {
517
+ sys: {
518
+ id: '4jo9APjyJs31WugGbV0E42',
519
+ type: 'Link',
520
+ linkType: 'Entry'
521
+ }
522
+ }
523
+ },
524
+ isVoid: true
525
+ },
526
+ {
527
+ type: 'embedded-entry-block',
528
+ children: [
529
+ {
530
+ text: ''
531
+ }
532
+ ],
533
+ data: {
534
+ target: {
535
+ sys: {
536
+ id: '2bwp9MdklBd4WVLGm1Fngy',
537
+ type: 'Link',
538
+ linkType: 'Entry'
539
+ }
540
+ }
541
+ },
542
+ isVoid: true
543
+ },
544
+ {
545
+ type: 'embedded-entry-block',
546
+ children: [
547
+ {
548
+ text: ''
549
+ }
550
+ ],
551
+ data: {
552
+ target: {
553
+ sys: {
554
+ id: '73qAHseh6G40k7ndmON5OD',
555
+ type: 'Link',
556
+ linkType: 'Entry'
557
+ }
558
+ }
559
+ },
560
+ isVoid: true
561
+ },
562
+ {
563
+ type: 'embedded-entry-block',
564
+ children: [
565
+ {
566
+ text: ''
567
+ }
568
+ ],
569
+ data: {
570
+ target: {
571
+ sys: {
572
+ id: '7FYYiCprd5VwItrHH3nNJj',
573
+ type: 'Link',
574
+ linkType: 'Entry'
575
+ }
576
+ }
577
+ },
578
+ isVoid: true
579
+ },
580
+ {
581
+ type: 'paragraph',
582
+ children: [
583
+ {
584
+ text: '',
585
+ data: {}
586
+ }
587
+ ],
588
+ data: {},
589
+ isVoid: false
590
+ },
591
+ {
592
+ type: 'paragraph',
593
+ children: [
594
+ {
595
+ text: '',
596
+ data: {}
597
+ }
598
+ ],
599
+ data: {},
600
+ isVoid: false
426
601
  }
427
602
  ]
428
603
  }
@@ -12,6 +12,11 @@ const _richtexttypes = require("@contentful/rich-text-types");
12
12
  const _slate = require("slate");
13
13
  const _internal = require("../internal");
14
14
  const inlineTypes = new Set(Object.values(_richtexttypes.INLINES));
15
+ const voidTypes = new Set([
16
+ ..._richtexttypes.VOID_BLOCKS,
17
+ _richtexttypes.INLINES.EMBEDDED_ENTRY,
18
+ _richtexttypes.INLINES.EMBEDDED_RESOURCE
19
+ ]);
15
20
  function isEmptyHyperlink(node) {
16
21
  if (node.nodeType !== _richtexttypes.INLINES.HYPERLINK) {
17
22
  return false;
@@ -51,9 +56,11 @@ function maybeFixUnevenTableRows(el) {
51
56
  {
52
57
  text: ''
53
58
  }
54
- ]
59
+ ],
60
+ isVoid: false
55
61
  }
56
- ]
62
+ ],
63
+ isVoid: false
57
64
  });
58
65
  }
59
66
  fixedRows.push(paddedRow);
@@ -74,7 +81,8 @@ function transformNode(node) {
74
81
  const el = {
75
82
  type: node.nodeType,
76
83
  children: [],
77
- data: node.data ?? {}
84
+ data: node.data ?? {},
85
+ isVoid: voidTypes.has(node.nodeType)
78
86
  };
79
87
  for (const child of node.content){
80
88
  const lastChild = el.children.at(-1);
@@ -110,7 +118,8 @@ function transformNode(node) {
110
118
  {
111
119
  text: ''
112
120
  }
113
- ]
121
+ ],
122
+ isVoid: false
114
123
  });
115
124
  break;
116
125
  case _richtexttypes.BLOCKS.UL_LIST:
@@ -126,9 +135,11 @@ function transformNode(node) {
126
135
  {
127
136
  text: ''
128
137
  }
129
- ]
138
+ ],
139
+ isVoid: false
130
140
  }
131
- ]
141
+ ],
142
+ isVoid: false
132
143
  });
133
144
  break;
134
145
  default:
@@ -159,7 +170,8 @@ function toSlateDoc(doc) {
159
170
  text: ''
160
171
  }
161
172
  ],
162
- data: {}
173
+ data: {},
174
+ isVoid: false
163
175
  }
164
176
  ];
165
177
  }
@@ -173,7 +185,8 @@ function toSlateDoc(doc) {
173
185
  text: ''
174
186
  }
175
187
  ],
176
- data: {}
188
+ data: {},
189
+ isVoid: false
177
190
  });
178
191
  }
179
192
  return elements;
@@ -14,7 +14,8 @@ describe('toSlateDoc', ()=>{
14
14
  text: ''
15
15
  }
16
16
  ],
17
- data: {}
17
+ data: {},
18
+ isVoid: false
18
19
  }
19
20
  ]
20
21
  },
@@ -29,7 +30,8 @@ describe('toSlateDoc', ()=>{
29
30
  text: ''
30
31
  }
31
32
  ],
32
- data: {}
33
+ data: {},
34
+ isVoid: false
33
35
  }
34
36
  ]
35
37
  },
@@ -44,7 +46,8 @@ describe('toSlateDoc', ()=>{
44
46
  text: ''
45
47
  }
46
48
  ],
47
- data: {}
49
+ data: {},
50
+ isVoid: false
48
51
  }
49
52
  ]
50
53
  },
@@ -82,7 +85,8 @@ describe('toSlateDoc', ()=>{
82
85
  data: {}
83
86
  }
84
87
  ],
85
- data: {}
88
+ data: {},
89
+ isVoid: false
86
90
  }
87
91
  ]
88
92
  },
@@ -103,7 +107,8 @@ describe('toSlateDoc', ()=>{
103
107
  {
104
108
  text: ''
105
109
  }
106
- ]
110
+ ],
111
+ isVoid: true
107
112
  },
108
113
  {
109
114
  text: ''
@@ -115,13 +120,15 @@ describe('toSlateDoc', ()=>{
115
120
  {
116
121
  text: ''
117
122
  }
118
- ]
123
+ ],
124
+ isVoid: true
119
125
  },
120
126
  {
121
127
  text: ''
122
128
  }
123
129
  ],
124
- data: {}
130
+ data: {},
131
+ isVoid: false
125
132
  }
126
133
  ]
127
134
  },
@@ -149,9 +156,11 @@ describe('toSlateDoc', ()=>{
149
156
  text: 'cell #1',
150
157
  data: {}
151
158
  }
152
- ]
159
+ ],
160
+ isVoid: false
153
161
  }
154
- ]
162
+ ],
163
+ isVoid: false
155
164
  },
156
165
  {
157
166
  type: 'table-header-cell',
@@ -164,9 +173,11 @@ describe('toSlateDoc', ()=>{
164
173
  {
165
174
  text: ''
166
175
  }
167
- ]
176
+ ],
177
+ isVoid: false
168
178
  }
169
- ]
179
+ ],
180
+ isVoid: false
170
181
  },
171
182
  {
172
183
  type: 'table-header-cell',
@@ -179,11 +190,14 @@ describe('toSlateDoc', ()=>{
179
190
  {
180
191
  text: ''
181
192
  }
182
- ]
193
+ ],
194
+ isVoid: false
183
195
  }
184
- ]
196
+ ],
197
+ isVoid: false
185
198
  }
186
- ]
199
+ ],
200
+ isVoid: false
187
201
  },
188
202
  {
189
203
  type: 'table-row',
@@ -201,9 +215,11 @@ describe('toSlateDoc', ()=>{
201
215
  text: 'cell #1',
202
216
  data: {}
203
217
  }
204
- ]
218
+ ],
219
+ isVoid: false
205
220
  }
206
- ]
221
+ ],
222
+ isVoid: false
207
223
  },
208
224
  {
209
225
  type: 'table-cell',
@@ -217,9 +233,11 @@ describe('toSlateDoc', ()=>{
217
233
  text: 'cell #2',
218
234
  data: {}
219
235
  }
220
- ]
236
+ ],
237
+ isVoid: false
221
238
  }
222
- ]
239
+ ],
240
+ isVoid: false
223
241
  },
224
242
  {
225
243
  type: 'table-cell',
@@ -233,11 +251,14 @@ describe('toSlateDoc', ()=>{
233
251
  text: 'cell #3',
234
252
  data: {}
235
253
  }
236
- ]
254
+ ],
255
+ isVoid: false
237
256
  }
238
- ]
257
+ ],
258
+ isVoid: false
239
259
  }
240
- ]
260
+ ],
261
+ isVoid: false
241
262
  },
242
263
  {
243
264
  type: 'table-row',
@@ -255,9 +276,11 @@ describe('toSlateDoc', ()=>{
255
276
  text: 'cell #1',
256
277
  data: {}
257
278
  }
258
- ]
279
+ ],
280
+ isVoid: false
259
281
  }
260
- ]
282
+ ],
283
+ isVoid: false
261
284
  },
262
285
  {
263
286
  type: 'table-cell',
@@ -271,9 +294,11 @@ describe('toSlateDoc', ()=>{
271
294
  text: 'cell #2',
272
295
  data: {}
273
296
  }
274
- ]
297
+ ],
298
+ isVoid: false
275
299
  }
276
- ]
300
+ ],
301
+ isVoid: false
277
302
  },
278
303
  {
279
304
  type: 'table-cell',
@@ -286,13 +311,17 @@ describe('toSlateDoc', ()=>{
286
311
  {
287
312
  text: ''
288
313
  }
289
- ]
314
+ ],
315
+ isVoid: false
290
316
  }
291
- ]
317
+ ],
318
+ isVoid: false
292
319
  }
293
- ]
320
+ ],
321
+ isVoid: false
294
322
  }
295
- ]
323
+ ],
324
+ isVoid: false
296
325
  },
297
326
  {
298
327
  type: 'paragraph',
@@ -301,7 +330,8 @@ describe('toSlateDoc', ()=>{
301
330
  {
302
331
  text: ''
303
332
  }
304
- ]
333
+ ],
334
+ isVoid: false
305
335
  }
306
336
  ]
307
337
  },
@@ -320,9 +350,11 @@ describe('toSlateDoc', ()=>{
320
350
  {
321
351
  text: ''
322
352
  }
323
- ]
353
+ ],
354
+ isVoid: false
324
355
  }
325
- ]
356
+ ],
357
+ isVoid: false
326
358
  },
327
359
  {
328
360
  type: 'paragraph',
@@ -331,7 +363,8 @@ describe('toSlateDoc', ()=>{
331
363
  {
332
364
  text: ''
333
365
  }
334
- ]
366
+ ],
367
+ isVoid: false
335
368
  }
336
369
  ]
337
370
  },
@@ -350,9 +383,11 @@ describe('toSlateDoc', ()=>{
350
383
  {
351
384
  text: ''
352
385
  }
353
- ]
386
+ ],
387
+ isVoid: false
354
388
  }
355
- ]
389
+ ],
390
+ isVoid: false
356
391
  },
357
392
  {
358
393
  type: 'paragraph',
@@ -361,7 +396,8 @@ describe('toSlateDoc', ()=>{
361
396
  {
362
397
  text: ''
363
398
  }
364
- ]
399
+ ],
400
+ isVoid: false
365
401
  }
366
402
  ]
367
403
  },
@@ -384,11 +420,14 @@ describe('toSlateDoc', ()=>{
384
420
  {
385
421
  text: ''
386
422
  }
387
- ]
423
+ ],
424
+ isVoid: false
388
425
  }
389
- ]
426
+ ],
427
+ isVoid: false
390
428
  }
391
- ]
429
+ ],
430
+ isVoid: false
392
431
  },
393
432
  {
394
433
  type: 'ordered-list',
@@ -405,11 +444,14 @@ describe('toSlateDoc', ()=>{
405
444
  {
406
445
  text: ''
407
446
  }
408
- ]
447
+ ],
448
+ isVoid: false
409
449
  }
410
- ]
450
+ ],
451
+ isVoid: false
411
452
  }
412
- ]
453
+ ],
454
+ isVoid: false
413
455
  },
414
456
  {
415
457
  type: 'paragraph',
@@ -418,7 +460,140 @@ describe('toSlateDoc', ()=>{
418
460
  {
419
461
  text: ''
420
462
  }
421
- ]
463
+ ],
464
+ isVoid: false
465
+ }
466
+ ]
467
+ },
468
+ {
469
+ title: 'list of embedded entry blocks',
470
+ input: document(block(BLOCKS.EMBEDDED_ENTRY, {
471
+ target: {
472
+ sys: {
473
+ id: '4jo9APjyJs31WugGbV0E42',
474
+ type: 'Link',
475
+ linkType: 'Entry'
476
+ }
477
+ }
478
+ }), block(BLOCKS.EMBEDDED_ENTRY, {
479
+ target: {
480
+ sys: {
481
+ id: '2bwp9MdklBd4WVLGm1Fngy',
482
+ type: 'Link',
483
+ linkType: 'Entry'
484
+ }
485
+ }
486
+ }), block(BLOCKS.EMBEDDED_ENTRY, {
487
+ target: {
488
+ sys: {
489
+ id: '73qAHseh6G40k7ndmON5OD',
490
+ type: 'Link',
491
+ linkType: 'Entry'
492
+ }
493
+ }
494
+ }), block(BLOCKS.EMBEDDED_ENTRY, {
495
+ target: {
496
+ sys: {
497
+ id: '7FYYiCprd5VwItrHH3nNJj',
498
+ type: 'Link',
499
+ linkType: 'Entry'
500
+ }
501
+ }
502
+ }), block(BLOCKS.PARAGRAPH, {}, text('')), block(BLOCKS.PARAGRAPH, {}, text(''))),
503
+ expected: [
504
+ {
505
+ type: 'embedded-entry-block',
506
+ children: [
507
+ {
508
+ text: ''
509
+ }
510
+ ],
511
+ data: {
512
+ target: {
513
+ sys: {
514
+ id: '4jo9APjyJs31WugGbV0E42',
515
+ type: 'Link',
516
+ linkType: 'Entry'
517
+ }
518
+ }
519
+ },
520
+ isVoid: true
521
+ },
522
+ {
523
+ type: 'embedded-entry-block',
524
+ children: [
525
+ {
526
+ text: ''
527
+ }
528
+ ],
529
+ data: {
530
+ target: {
531
+ sys: {
532
+ id: '2bwp9MdklBd4WVLGm1Fngy',
533
+ type: 'Link',
534
+ linkType: 'Entry'
535
+ }
536
+ }
537
+ },
538
+ isVoid: true
539
+ },
540
+ {
541
+ type: 'embedded-entry-block',
542
+ children: [
543
+ {
544
+ text: ''
545
+ }
546
+ ],
547
+ data: {
548
+ target: {
549
+ sys: {
550
+ id: '73qAHseh6G40k7ndmON5OD',
551
+ type: 'Link',
552
+ linkType: 'Entry'
553
+ }
554
+ }
555
+ },
556
+ isVoid: true
557
+ },
558
+ {
559
+ type: 'embedded-entry-block',
560
+ children: [
561
+ {
562
+ text: ''
563
+ }
564
+ ],
565
+ data: {
566
+ target: {
567
+ sys: {
568
+ id: '7FYYiCprd5VwItrHH3nNJj',
569
+ type: 'Link',
570
+ linkType: 'Entry'
571
+ }
572
+ }
573
+ },
574
+ isVoid: true
575
+ },
576
+ {
577
+ type: 'paragraph',
578
+ children: [
579
+ {
580
+ text: '',
581
+ data: {}
582
+ }
583
+ ],
584
+ data: {},
585
+ isVoid: false
586
+ },
587
+ {
588
+ type: 'paragraph',
589
+ children: [
590
+ {
591
+ text: '',
592
+ data: {}
593
+ }
594
+ ],
595
+ data: {},
596
+ isVoid: false
422
597
  }
423
598
  ]
424
599
  }
@@ -1,7 +1,12 @@
1
- import { INLINES, BLOCKS } from '@contentful/rich-text-types';
1
+ import { INLINES, BLOCKS, VOID_BLOCKS } from '@contentful/rich-text-types';
2
2
  import { Text as TextInterface, Element as ElementInterface } from 'slate';
3
3
  import { isText } from '../internal';
4
4
  const inlineTypes = new Set(Object.values(INLINES));
5
+ const voidTypes = new Set([
6
+ ...VOID_BLOCKS,
7
+ INLINES.EMBEDDED_ENTRY,
8
+ INLINES.EMBEDDED_RESOURCE
9
+ ]);
5
10
  function isEmptyHyperlink(node) {
6
11
  if (node.nodeType !== INLINES.HYPERLINK) {
7
12
  return false;
@@ -41,9 +46,11 @@ function maybeFixUnevenTableRows(el) {
41
46
  {
42
47
  text: ''
43
48
  }
44
- ]
49
+ ],
50
+ isVoid: false
45
51
  }
46
- ]
52
+ ],
53
+ isVoid: false
47
54
  });
48
55
  }
49
56
  fixedRows.push(paddedRow);
@@ -64,7 +71,8 @@ function transformNode(node) {
64
71
  const el = {
65
72
  type: node.nodeType,
66
73
  children: [],
67
- data: node.data ?? {}
74
+ data: node.data ?? {},
75
+ isVoid: voidTypes.has(node.nodeType)
68
76
  };
69
77
  for (const child of node.content){
70
78
  const lastChild = el.children.at(-1);
@@ -100,7 +108,8 @@ function transformNode(node) {
100
108
  {
101
109
  text: ''
102
110
  }
103
- ]
111
+ ],
112
+ isVoid: false
104
113
  });
105
114
  break;
106
115
  case BLOCKS.UL_LIST:
@@ -116,9 +125,11 @@ function transformNode(node) {
116
125
  {
117
126
  text: ''
118
127
  }
119
- ]
128
+ ],
129
+ isVoid: false
120
130
  }
121
- ]
131
+ ],
132
+ isVoid: false
122
133
  });
123
134
  break;
124
135
  default:
@@ -149,7 +160,8 @@ export function toSlateDoc(doc) {
149
160
  text: ''
150
161
  }
151
162
  ],
152
- data: {}
163
+ data: {},
164
+ isVoid: false
153
165
  }
154
166
  ];
155
167
  }
@@ -163,7 +175,8 @@ export function toSlateDoc(doc) {
163
175
  text: ''
164
176
  }
165
177
  ],
166
- data: {}
178
+ data: {},
179
+ isVoid: false
167
180
  });
168
181
  }
169
182
  return elements;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "4.19.0",
3
+ "version": "4.19.2",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -44,7 +44,7 @@
44
44
  "@contentful/f36-icons": "^5.4.1",
45
45
  "@contentful/f36-tokens": "^5.1.0",
46
46
  "@contentful/f36-utils": "^5.1.0",
47
- "@contentful/field-editor-reference": "^6.19.0",
47
+ "@contentful/field-editor-reference": "^6.19.1",
48
48
  "@contentful/field-editor-shared": "^2.17.0",
49
49
  "@contentful/rich-text-plain-text-renderer": "^17.0.0",
50
50
  "@contentful/rich-text-types": "^17.2.5",
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "registry": "https://npm.pkg.github.com/"
93
93
  },
94
- "gitHead": "cfe222b9d0e4ca9d69e62697c48bbeaca1e52b51"
94
+ "gitHead": "df62d5fb562de590a6de09e86d2e72913c64ac93"
95
95
  }