testomatio-editor-blocks 0.4.36 → 0.4.37

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.
@@ -426,7 +426,16 @@ function serializeBlock(block, ctx, orderedIndex, stepIndex) {
426
426
  const formatCell = (value) => {
427
427
  if (!value.length)
428
428
  return " ";
429
- return value.replace(/\n/g, "<br/>");
429
+ // Handle newlines inside backtick code spans:
430
+ // close code before <br>, reopen after
431
+ let result = value.replace(/`([^`]*)`/g, (match) => {
432
+ if (!match.includes("\n"))
433
+ return match;
434
+ const inner = match.slice(1, -1);
435
+ const parts = inner.split("\n");
436
+ return parts.map((p) => (p ? `\`${p}\`` : "")).join("<br>");
437
+ });
438
+ return result.replace(/\n/g, "<br>");
430
439
  };
431
440
  const toAlignmentToken = (alignment) => {
432
441
  switch (alignment) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testomatio-editor-blocks",
3
- "version": "0.4.36",
3
+ "version": "0.4.37",
4
4
  "description": "Custom BlockNote schema, markdown conversion helpers, and UI for Testomatio-style test cases and steps.",
5
5
  "type": "module",
6
6
  "main": "./package/index.js",
@@ -438,7 +438,64 @@ describe("blocksToMarkdown", () => {
438
438
  [
439
439
  "| Steps | Expected Results |",
440
440
  "| --- | --- |",
441
- "| line1<br/>line2 | ok |",
441
+ "| line1<br>line2 | ok |",
442
+ ].join("\n"),
443
+ );
444
+ });
445
+
446
+ it("serializes table cell with code style and newline placing br outside backticks", () => {
447
+ const blocks: CustomEditorBlock[] = [
448
+ {
449
+ id: "tbl-code",
450
+ type: "table",
451
+ props: { textColor: "default" },
452
+ content: {
453
+ type: "tableContent",
454
+ columnWidths: [undefined, undefined],
455
+ headerRows: 1,
456
+ rows: [
457
+ {
458
+ cells: [
459
+ {
460
+ type: "tableCell",
461
+ props: cellProps,
462
+ content: [{ type: "text", text: "A", styles: {} }],
463
+ },
464
+ {
465
+ type: "tableCell",
466
+ props: cellProps,
467
+ content: [{ type: "text", text: "B", styles: {} }],
468
+ },
469
+ ],
470
+ },
471
+ {
472
+ cells: [
473
+ {
474
+ type: "tableCell",
475
+ props: cellProps,
476
+ content: [
477
+ { type: "text", text: "code", styles: { code: true } },
478
+ { type: "text", text: "\nnext line", styles: {} },
479
+ ],
480
+ },
481
+ {
482
+ type: "tableCell",
483
+ props: cellProps,
484
+ content: [{ type: "text", text: "ok", styles: {} }],
485
+ },
486
+ ],
487
+ },
488
+ ],
489
+ },
490
+ children: [],
491
+ },
492
+ ];
493
+
494
+ expect(blocksToMarkdown(blocks)).toBe(
495
+ [
496
+ "| A | B |",
497
+ "| --- | --- |",
498
+ "| `code`<br>next line | ok |",
442
499
  ].join("\n"),
443
500
  );
444
501
  });
@@ -494,7 +551,7 @@ describe("blocksToMarkdown", () => {
494
551
  [
495
552
  "| Col A | Col B |",
496
553
  "| --- | --- |",
497
- "| ok | **opened**<br/>**newline** |",
554
+ "| ok | **opened**<br>**newline** |",
498
555
  ].join("\n"),
499
556
  );
500
557
  });
@@ -1436,7 +1493,7 @@ describe("markdownToBlocks", () => {
1436
1493
  const markdown = [
1437
1494
  "| A | B |",
1438
1495
  "| --- | --- |",
1439
- "| line1<br/>line2 | ok |",
1496
+ "| line1<br>line2 | ok |",
1440
1497
  ].join("\n");
1441
1498
 
1442
1499
  const blocks = markdownToBlocks(markdown);
@@ -1530,7 +1587,7 @@ describe("markdownToBlocks", () => {
1530
1587
  ];
1531
1588
 
1532
1589
  const markdown = blocksToMarkdown(blocks);
1533
- expect(markdown).toContain("first<br/>second<br/>third");
1590
+ expect(markdown).toContain("first<br>second<br>third");
1534
1591
 
1535
1592
  const parsed = markdownToBlocks(markdown);
1536
1593
  const row = (parsed[0] as any).content.rows[1];
@@ -525,7 +525,15 @@ function serializeBlock(
525
525
  const formattedRows = rows.map(normalizeRow);
526
526
  const formatCell = (value: string) => {
527
527
  if (!value.length) return " ";
528
- return value.replace(/\n/g, "<br/>");
528
+ // Handle newlines inside backtick code spans:
529
+ // close code before <br>, reopen after
530
+ let result = value.replace(/`([^`]*)`/g, (match) => {
531
+ if (!match.includes("\n")) return match;
532
+ const inner = match.slice(1, -1);
533
+ const parts = inner.split("\n");
534
+ return parts.map((p) => (p ? `\`${p}\`` : "")).join("<br>");
535
+ });
536
+ return result.replace(/\n/g, "<br>");
529
537
  };
530
538
  const toAlignmentToken = (alignment: string) => {
531
539
  switch (alignment) {