Skip to content

Commit 131bab3

Browse files
fix: Error caused by converting hardBreak nodes (#229)
* Added `HardBreak` type of `InlineContent` * Changed `hardBreak` nodes to be parsed as "\n" characters instead of `HardBreak`s * Implemented PR feedback * comments inside of if branches --------- Co-authored-by: yousefed <[email protected]>
1 parent 555fae6 commit 131bab3

File tree

3 files changed

+694
-35
lines changed

3 files changed

+694
-35
lines changed

packages/core/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,298 @@ exports[`Simple ProseMirror Node Conversions > Convert simple node to block 1`]
183183
}
184184
`;
185185

186+
exports[`hard breaks > Convert a block with a hard break 1`] = `
187+
{
188+
"attrs": {
189+
"backgroundColor": "default",
190+
"id": "4",
191+
"textColor": "default",
192+
},
193+
"content": [
194+
{
195+
"attrs": {
196+
"textAlignment": "left",
197+
},
198+
"content": [
199+
{
200+
"text": "Text1",
201+
"type": "text",
202+
},
203+
{
204+
"type": "hardBreak",
205+
},
206+
{
207+
"text": "Text2",
208+
"type": "text",
209+
},
210+
],
211+
"type": "paragraph",
212+
},
213+
],
214+
"type": "blockContainer",
215+
}
216+
`;
217+
218+
exports[`hard breaks > Convert a block with a hard break and different styles 1`] = `
219+
{
220+
"attrs": {
221+
"backgroundColor": "default",
222+
"id": "4",
223+
"textColor": "default",
224+
},
225+
"content": [
226+
{
227+
"attrs": {
228+
"textAlignment": "left",
229+
},
230+
"content": [
231+
{
232+
"text": "Text1",
233+
"type": "text",
234+
},
235+
{
236+
"type": "hardBreak",
237+
},
238+
{
239+
"marks": [
240+
{
241+
"type": "bold",
242+
},
243+
],
244+
"text": "Text2",
245+
"type": "text",
246+
},
247+
],
248+
"type": "paragraph",
249+
},
250+
],
251+
"type": "blockContainer",
252+
}
253+
`;
254+
255+
exports[`hard breaks > Convert a block with a hard break at the end 1`] = `
256+
{
257+
"attrs": {
258+
"backgroundColor": "default",
259+
"id": "4",
260+
"textColor": "default",
261+
},
262+
"content": [
263+
{
264+
"attrs": {
265+
"textAlignment": "left",
266+
},
267+
"content": [
268+
{
269+
"text": "Text1",
270+
"type": "text",
271+
},
272+
{
273+
"type": "hardBreak",
274+
},
275+
],
276+
"type": "paragraph",
277+
},
278+
],
279+
"type": "blockContainer",
280+
}
281+
`;
282+
283+
exports[`hard breaks > Convert a block with a hard break at the start 1`] = `
284+
{
285+
"attrs": {
286+
"backgroundColor": "default",
287+
"id": "4",
288+
"textColor": "default",
289+
},
290+
"content": [
291+
{
292+
"attrs": {
293+
"textAlignment": "left",
294+
},
295+
"content": [
296+
{
297+
"type": "hardBreak",
298+
},
299+
{
300+
"text": "Text1",
301+
"type": "text",
302+
},
303+
],
304+
"type": "paragraph",
305+
},
306+
],
307+
"type": "blockContainer",
308+
}
309+
`;
310+
311+
exports[`hard breaks > Convert a block with a hard break between links 1`] = `
312+
{
313+
"attrs": {
314+
"backgroundColor": "default",
315+
"id": "4",
316+
"textColor": "default",
317+
},
318+
"content": [
319+
{
320+
"attrs": {
321+
"textAlignment": "left",
322+
},
323+
"content": [
324+
{
325+
"marks": [
326+
{
327+
"attrs": {
328+
"class": null,
329+
"href": "https://www.website.com",
330+
"target": "_blank",
331+
},
332+
"type": "link",
333+
},
334+
],
335+
"text": "Link1",
336+
"type": "text",
337+
},
338+
{
339+
"type": "hardBreak",
340+
},
341+
{
342+
"marks": [
343+
{
344+
"attrs": {
345+
"class": null,
346+
"href": "https://www.website2.com",
347+
"target": "_blank",
348+
},
349+
"type": "link",
350+
},
351+
],
352+
"text": "Link2",
353+
"type": "text",
354+
},
355+
],
356+
"type": "paragraph",
357+
},
358+
],
359+
"type": "blockContainer",
360+
}
361+
`;
362+
363+
exports[`hard breaks > Convert a block with a hard break in a link 1`] = `
364+
{
365+
"attrs": {
366+
"backgroundColor": "default",
367+
"id": "4",
368+
"textColor": "default",
369+
},
370+
"content": [
371+
{
372+
"attrs": {
373+
"textAlignment": "left",
374+
},
375+
"content": [
376+
{
377+
"marks": [
378+
{
379+
"attrs": {
380+
"class": null,
381+
"href": "https://www.website.com",
382+
"target": "_blank",
383+
},
384+
"type": "link",
385+
},
386+
],
387+
"text": "Link1",
388+
"type": "text",
389+
},
390+
{
391+
"type": "hardBreak",
392+
},
393+
{
394+
"marks": [
395+
{
396+
"attrs": {
397+
"class": null,
398+
"href": "https://www.website.com",
399+
"target": "_blank",
400+
},
401+
"type": "link",
402+
},
403+
],
404+
"text": "Link1",
405+
"type": "text",
406+
},
407+
],
408+
"type": "paragraph",
409+
},
410+
],
411+
"type": "blockContainer",
412+
}
413+
`;
414+
415+
exports[`hard breaks > Convert a block with multiple hard breaks 1`] = `
416+
{
417+
"attrs": {
418+
"backgroundColor": "default",
419+
"id": "4",
420+
"textColor": "default",
421+
},
422+
"content": [
423+
{
424+
"attrs": {
425+
"textAlignment": "left",
426+
},
427+
"content": [
428+
{
429+
"text": "Text1",
430+
"type": "text",
431+
},
432+
{
433+
"type": "hardBreak",
434+
},
435+
{
436+
"text": "Text2",
437+
"type": "text",
438+
},
439+
{
440+
"type": "hardBreak",
441+
},
442+
{
443+
"text": "Text3",
444+
"type": "text",
445+
},
446+
],
447+
"type": "paragraph",
448+
},
449+
],
450+
"type": "blockContainer",
451+
}
452+
`;
453+
454+
exports[`hard breaks > Convert a block with only a hard break 1`] = `
455+
{
456+
"attrs": {
457+
"backgroundColor": "default",
458+
"id": "4",
459+
"textColor": "default",
460+
},
461+
"content": [
462+
{
463+
"attrs": {
464+
"textAlignment": "left",
465+
},
466+
"content": [
467+
{
468+
"type": "hardBreak",
469+
},
470+
],
471+
"type": "paragraph",
472+
},
473+
],
474+
"type": "blockContainer",
475+
}
476+
`;
477+
186478
exports[`links > Convert a block with link 1`] = `
187479
{
188480
"attrs": {

0 commit comments

Comments
 (0)