testomatio-editor-blocks 0.4.64 → 0.4.65

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.
@@ -262,8 +262,7 @@ function serializeBlock(block, ctx, orderedIndex, stepIndex) {
262
262
  return lines;
263
263
  }
264
264
  case "codeBlock": {
265
- const rawLanguage = block.props.language || "";
266
- const language = /[\s`]/.test(rawLanguage) ? "" : rawLanguage;
265
+ const language = block.props.language || "";
267
266
  const fence = "```" + language;
268
267
  const body = inlineContentToPlainText(block.content);
269
268
  lines.push(fence);
@@ -1088,17 +1087,8 @@ function parseCodeBlock(lines, index) {
1088
1087
  nextIndex: index + 1,
1089
1088
  };
1090
1089
  }
1091
- const info = afterOpening.trim();
1092
- let language = "";
1090
+ const language = afterOpening.trim();
1093
1091
  const body = [];
1094
- if (info.length > 0) {
1095
- if (/[\s`]/.test(info)) {
1096
- body.push(afterOpening);
1097
- }
1098
- else {
1099
- language = info;
1100
- }
1101
- }
1102
1092
  let next = index + 1;
1103
1093
  while (next < lines.length && !lines[next].startsWith("```")) {
1104
1094
  body.push(lines[next]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testomatio-editor-blocks",
3
- "version": "0.4.64",
3
+ "version": "0.4.65",
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",
@@ -2685,90 +2685,6 @@ describe("markdownToBlocks", () => {
2685
2685
  },
2686
2686
  ]);
2687
2687
  });
2688
-
2689
- it("preserves opening-fence content when it is not a clean language identifier", () => {
2690
- const markdown = [
2691
- "```curl `http://localhost:3000/projects/classic-project/test/e1c1b38c/edit` \\",
2692
- "{{baseURL}}/endpoint?query_param_one=value_one&query_param_two=value_two",
2693
- "```",
2694
- ].join("\n");
2695
- const blocks = markdownToBlocks(markdown);
2696
- expect(blocks).toEqual([
2697
- {
2698
- type: "codeBlock",
2699
- props: { language: "" },
2700
- content: [
2701
- {
2702
- type: "text",
2703
- text: [
2704
- "curl `http://localhost:3000/projects/classic-project/test/e1c1b38c/edit` \\",
2705
- "{{baseURL}}/endpoint?query_param_one=value_one&query_param_two=value_two",
2706
- ].join("\n"),
2707
- styles: {},
2708
- },
2709
- ],
2710
- children: [],
2711
- },
2712
- ]);
2713
- });
2714
-
2715
- it("round-trips an opening-fence-with-content code block to stable markdown", () => {
2716
- const markdown = [
2717
- "```curl `http://localhost:3000/projects/classic-project/test/e1c1b38c/edit` \\",
2718
- "{{baseURL}}/endpoint?query_param_one=value_one&query_param_two=value_two",
2719
- "```",
2720
- ].join("\n");
2721
- const blocks = markdownToBlocks(markdown);
2722
- const serialized = blocksToMarkdown(blocks as CustomEditorBlock[]);
2723
- expect(serialized).toBe(
2724
- [
2725
- "```",
2726
- "curl `http://localhost:3000/projects/classic-project/test/e1c1b38c/edit` \\",
2727
- "{{baseURL}}/endpoint?query_param_one=value_one&query_param_two=value_two",
2728
- "```",
2729
- ].join("\n"),
2730
- );
2731
- expect(markdownToBlocks(serialized)).toEqual(blocks);
2732
- });
2733
-
2734
- it("preserves hyphenated language identifiers like shell-session", () => {
2735
- const markdown = ["```shell-session", "$ ls", "```"].join("\n");
2736
- const blocks = markdownToBlocks(markdown);
2737
- expect(blocks).toEqual([
2738
- {
2739
- type: "codeBlock",
2740
- props: { language: "shell-session" },
2741
- content: [{ type: "text", text: "$ ls", styles: {} }],
2742
- children: [],
2743
- },
2744
- ]);
2745
- });
2746
-
2747
- it("preserves digit-prefixed language identifiers like 1c-enterprise", () => {
2748
- const markdown = ["```1c-enterprise", "code", "```"].join("\n");
2749
- const blocks = markdownToBlocks(markdown);
2750
- expect(blocks).toEqual([
2751
- {
2752
- type: "codeBlock",
2753
- props: { language: "1c-enterprise" },
2754
- content: [{ type: "text", text: "code", styles: {} }],
2755
- children: [],
2756
- },
2757
- ]);
2758
- });
2759
-
2760
- it("sanitizes a malformed in-memory language prop on serialize", () => {
2761
- const blocks: CustomEditorBlock[] = [
2762
- {
2763
- id: "1",
2764
- type: "codeBlock",
2765
- props: { ...baseProps, language: "curl http://x" } as any,
2766
- content: [{ type: "text", text: "body", styles: {} }] as any,
2767
- children: [],
2768
- },
2769
- ];
2770
- expect(blocksToMarkdown(blocks)).toBe(["```", "body", "```"].join("\n"));
2771
- });
2772
2688
  });
2773
2689
 
2774
2690
  describe("file block serialization", () => {
@@ -334,8 +334,7 @@ function serializeBlock(
334
334
  return lines;
335
335
  }
336
336
  case "codeBlock": {
337
- const rawLanguage = (block.props as any).language || "";
338
- const language = /[\s`]/.test(rawLanguage) ? "" : rawLanguage;
337
+ const language = (block.props as any).language || "";
339
338
  const fence = "```" + language;
340
339
  const body = inlineContentToPlainText(block.content);
341
340
  lines.push(fence);
@@ -1291,16 +1290,8 @@ function parseCodeBlock(lines: string[], index: number): { block: CustomPartialB
1291
1290
  };
1292
1291
  }
1293
1292
 
1294
- const info = afterOpening.trim();
1295
- let language = "";
1293
+ const language = afterOpening.trim();
1296
1294
  const body: string[] = [];
1297
- if (info.length > 0) {
1298
- if (/[\s`]/.test(info)) {
1299
- body.push(afterOpening);
1300
- } else {
1301
- language = info;
1302
- }
1303
- }
1304
1295
  let next = index + 1;
1305
1296
  while (next < lines.length && !lines[next].startsWith("```") ) {
1306
1297
  body.push(lines[next]);