@reiwuzen/blocky 1.4.7 → 1.5.0

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/dist/index.cjs CHANGED
@@ -74,15 +74,16 @@ function generateId(fn) {
74
74
  return fn ? fn() : (0, import_uuid.v7)();
75
75
  }
76
76
  var defaultContent = {
77
- paragraph: [],
78
- heading1: [],
79
- heading2: [],
80
- heading3: [],
81
- bullet: [],
82
- number: [],
83
- todo: [],
77
+ paragraph: [{ type: "text", text: "" }],
78
+ heading1: [{ type: "text", text: "" }],
79
+ heading2: [{ type: "text", text: "" }],
80
+ heading3: [{ type: "text", text: "" }],
81
+ bullet: [{ type: "text", text: "" }],
82
+ number: [{ type: "text", text: "" }],
83
+ todo: [{ type: "text", text: "" }],
84
84
  code: [{ type: "code", text: "" }],
85
- equation: [{ type: "equation", latex: "" }]
85
+ equation: [{ type: "equation", latex: "" }],
86
+ error: [{ type: "text", text: "" }]
86
87
  };
87
88
  var defaultMeta = {
88
89
  paragraph: {},
@@ -93,7 +94,12 @@ var defaultMeta = {
93
94
  number: { depth: 0 },
94
95
  todo: { depth: 0 },
95
96
  code: {},
96
- equation: {}
97
+ equation: {},
98
+ error: {
99
+ timestamp: Date.now(),
100
+ source: "unknown",
101
+ severity: "error"
102
+ }
97
103
  };
98
104
  function createBlock(type, idFn) {
99
105
  return import_result.Result.try(() => {
@@ -596,11 +602,10 @@ function applyEnterTransform(block) {
596
602
  const text = getRawText(block);
597
603
  if (text !== "```")
598
604
  return import_result4.Result.Ok({ block, converted: false });
599
- const strippedContent = stripPrefix(block, "```");
600
605
  const converted = {
601
606
  id: block.id,
602
607
  type: "code",
603
- content: strippedContent,
608
+ content: [{ type: "code", text: "" }],
604
609
  meta: buildMetaForTarget("code")
605
610
  };
606
611
  return import_result4.Result.Ok({ block: converted, converted: true });
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Result } from '@reiwuzen/result';
2
2
 
3
- type BlockType = "paragraph" | "heading1" | "heading2" | "heading3" | "bullet" | "number" | "todo" | "equation" | "code";
3
+ type BlockType = "paragraph" | "heading1" | "heading2" | "heading3" | "bullet" | "number" | "todo" | "equation" | "code" | "error";
4
4
  type Node = {
5
5
  type: "text";
6
6
  text: string;
@@ -22,6 +22,14 @@ type Node = {
22
22
  type: "equation";
23
23
  latex: string;
24
24
  };
25
+ type ErrorSource = "runtime" | "promise" | "react" | "system" | "unknown";
26
+ type ErrorSeverity = "error" | "warning" | "critical";
27
+ type ErrorMeta = {
28
+ timestamp: number;
29
+ source: ErrorSource;
30
+ severity: ErrorSeverity;
31
+ context?: string;
32
+ };
25
33
  type BlockMeta<T extends BlockType> = T extends "todo" ? {
26
34
  checked?: true;
27
35
  depth: number;
@@ -29,7 +37,7 @@ type BlockMeta<T extends BlockType> = T extends "todo" ? {
29
37
  depth: number;
30
38
  } : T extends "code" ? {
31
39
  language?: string;
32
- } : Record<string, never>;
40
+ } : T extends "error" ? ErrorMeta : Record<string, never>;
33
41
  type BlockContent<T extends BlockType> = T extends "code" ? [Extract<Node, {
34
42
  type: "code";
35
43
  }>] : T extends "equation" ? [Extract<Node, {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Result } from '@reiwuzen/result';
2
2
 
3
- type BlockType = "paragraph" | "heading1" | "heading2" | "heading3" | "bullet" | "number" | "todo" | "equation" | "code";
3
+ type BlockType = "paragraph" | "heading1" | "heading2" | "heading3" | "bullet" | "number" | "todo" | "equation" | "code" | "error";
4
4
  type Node = {
5
5
  type: "text";
6
6
  text: string;
@@ -22,6 +22,14 @@ type Node = {
22
22
  type: "equation";
23
23
  latex: string;
24
24
  };
25
+ type ErrorSource = "runtime" | "promise" | "react" | "system" | "unknown";
26
+ type ErrorSeverity = "error" | "warning" | "critical";
27
+ type ErrorMeta = {
28
+ timestamp: number;
29
+ source: ErrorSource;
30
+ severity: ErrorSeverity;
31
+ context?: string;
32
+ };
25
33
  type BlockMeta<T extends BlockType> = T extends "todo" ? {
26
34
  checked?: true;
27
35
  depth: number;
@@ -29,7 +37,7 @@ type BlockMeta<T extends BlockType> = T extends "todo" ? {
29
37
  depth: number;
30
38
  } : T extends "code" ? {
31
39
  language?: string;
32
- } : Record<string, never>;
40
+ } : T extends "error" ? ErrorMeta : Record<string, never>;
33
41
  type BlockContent<T extends BlockType> = T extends "code" ? [Extract<Node, {
34
42
  type: "code";
35
43
  }>] : T extends "equation" ? [Extract<Node, {
package/dist/index.js CHANGED
@@ -5,15 +5,16 @@ function generateId(fn) {
5
5
  return fn ? fn() : v7();
6
6
  }
7
7
  var defaultContent = {
8
- paragraph: [],
9
- heading1: [],
10
- heading2: [],
11
- heading3: [],
12
- bullet: [],
13
- number: [],
14
- todo: [],
8
+ paragraph: [{ type: "text", text: "" }],
9
+ heading1: [{ type: "text", text: "" }],
10
+ heading2: [{ type: "text", text: "" }],
11
+ heading3: [{ type: "text", text: "" }],
12
+ bullet: [{ type: "text", text: "" }],
13
+ number: [{ type: "text", text: "" }],
14
+ todo: [{ type: "text", text: "" }],
15
15
  code: [{ type: "code", text: "" }],
16
- equation: [{ type: "equation", latex: "" }]
16
+ equation: [{ type: "equation", latex: "" }],
17
+ error: [{ type: "text", text: "" }]
17
18
  };
18
19
  var defaultMeta = {
19
20
  paragraph: {},
@@ -24,7 +25,12 @@ var defaultMeta = {
24
25
  number: { depth: 0 },
25
26
  todo: { depth: 0 },
26
27
  code: {},
27
- equation: {}
28
+ equation: {},
29
+ error: {
30
+ timestamp: Date.now(),
31
+ source: "unknown",
32
+ severity: "error"
33
+ }
28
34
  };
29
35
  function createBlock(type, idFn) {
30
36
  return Result.try(() => {
@@ -527,11 +533,10 @@ function applyEnterTransform(block) {
527
533
  const text = getRawText(block);
528
534
  if (text !== "```")
529
535
  return Result4.Ok({ block, converted: false });
530
- const strippedContent = stripPrefix(block, "```");
531
536
  const converted = {
532
537
  id: block.id,
533
538
  type: "code",
534
- content: strippedContent,
539
+ content: [{ type: "code", text: "" }],
535
540
  meta: buildMetaForTarget("code")
536
541
  };
537
542
  return Result4.Ok({ block: converted, converted: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reiwuzen/blocky",
3
- "version": "1.4.7",
3
+ "version": "1.5.0",
4
4
  "description": "Pure TypeScript block editor engine. Headless, framework-agnostic — content mutation, formatting, transforms, serialization, and history.",
5
5
  "author": "Rei WuZen",
6
6
  "license": "ISC",