@jackuait/blok 0.4.1-beta.5 → 0.4.1

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.
@@ -1,4 +1,4 @@
1
- import { t as f, a as i } from "./blok-DvN73wsH.mjs";
1
+ import { t as f, a as i } from "./blok-BwPfU8ro.mjs";
2
2
  const a = {
3
3
  wrapper: i(
4
4
  "fixed z-[2] bottom-5 left-5",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jackuait/blok",
3
- "version": "0.4.1-beta.5",
3
+ "version": "0.4.1",
4
4
  "description": "Blok — headless, highly extensible rich text editor built for developers who need to implement a block-based editing experience (similar to Notion) without building it from scratch",
5
5
  "main": "dist/blok.umd.js",
6
6
  "module": "dist/blok.mjs",
@@ -53,7 +53,7 @@
53
53
  "release:rc": "./scripts/release.sh prerelease rc",
54
54
  "release:dry": "./scripts/release.sh release beta true",
55
55
  "storybook": "storybook dev -p 6006 --no-open",
56
- "storybook:build": "storybook build",
56
+ "storybook:build": "storybook build --stats-json",
57
57
  "storybook:test": "vitest --project=storybook --run",
58
58
  "chromatic": "chromatic --exit-zero-on-changes",
59
59
  "release:beta": "npm version prerelease --preid=beta",
package/types/index.d.ts CHANGED
@@ -144,6 +144,8 @@ export interface API {
144
144
  }
145
145
 
146
146
  import { HeaderConstructable } from './tools/header';
147
+ import { ParagraphConstructable } from './tools/paragraph';
148
+ import { ListConstructable } from './tools/list';
147
149
 
148
150
  /**
149
151
  * Main Blok class
@@ -156,6 +158,16 @@ declare class Blok {
156
158
  */
157
159
  public static Header: HeaderConstructable;
158
160
 
161
+ /**
162
+ * Paragraph tool bundled with Blok
163
+ */
164
+ public static Paragraph: ParagraphConstructable;
165
+
166
+ /**
167
+ * List tool bundled with Blok
168
+ */
169
+ public static List: ListConstructable;
170
+
159
171
  public isReady: Promise<void>;
160
172
 
161
173
  public blocks: Blocks;
@@ -217,4 +229,4 @@ declare class Blok {
217
229
  }
218
230
 
219
231
  export as namespace Blok;
220
- export default Blok;
232
+ export default Blok;
@@ -11,6 +11,22 @@ export interface HeaderData extends BlockToolData {
11
11
  level: number;
12
12
  }
13
13
 
14
+ /**
15
+ * Level-specific overrides for customization
16
+ */
17
+ export interface HeaderLevelConfig {
18
+ /** Custom HTML tag to use (e.g., 'div', 'p', 'span') */
19
+ tag?: string;
20
+ /** Custom display name for this level */
21
+ name?: string;
22
+ /** Custom font size (e.g., '3em', '24px') */
23
+ size?: string;
24
+ /** Custom margin top (e.g., '20px', '1rem') */
25
+ marginTop?: string;
26
+ /** Custom margin bottom (e.g., '10px', '0.5rem') */
27
+ marginBottom?: string;
28
+ }
29
+
14
30
  /**
15
31
  * Header Tool's configuration
16
32
  */
@@ -21,6 +37,8 @@ export interface HeaderConfig {
21
37
  levels?: number[];
22
38
  /** Default level */
23
39
  defaultLevel?: number;
40
+ /** Level-specific overrides keyed by level number (1-6) */
41
+ levelOverrides?: Record<number, HeaderLevelConfig>;
24
42
  }
25
43
 
26
44
  /**
@@ -12,6 +12,7 @@ export * from './paste-events';
12
12
  export * from './hook-events';
13
13
  export * from './menu-config';
14
14
  export * from './header';
15
+ export * from './list';
15
16
 
16
17
  export type Tool = BlockTool | InlineTool | BlockTune;
17
18
  export type ToolConstructable = BlockToolConstructable | InlineToolConstructable | BlockTuneConstructable;
@@ -0,0 +1,84 @@
1
+ import { BlockTool, BlockToolConstructable, BlockToolConstructorOptions, BlockToolData } from './block-tool';
2
+ import { MenuConfig } from './menu-config';
3
+
4
+ /**
5
+ * List styles enum
6
+ */
7
+ export type ListStyle = 'unordered' | 'ordered' | 'checklist';
8
+
9
+ /**
10
+ * Single list item data
11
+ */
12
+ export interface ListItem {
13
+ /** Item content (can include HTML) */
14
+ content: string;
15
+ /** Checked state for checklist items */
16
+ checked?: boolean;
17
+ /** Nested items for indentation */
18
+ items?: ListItem[];
19
+ }
20
+
21
+ /**
22
+ * List Tool's input and output data format
23
+ */
24
+ export interface ListData extends BlockToolData {
25
+ /** List style: unordered, ordered, or checklist */
26
+ style: ListStyle;
27
+ /** Array of list items */
28
+ items: ListItem[];
29
+ }
30
+
31
+ /**
32
+ * List Tool's configuration
33
+ */
34
+ export interface ListConfig {
35
+ /** Default list style */
36
+ defaultStyle?: ListStyle;
37
+ /** Available list styles */
38
+ styles?: ListStyle[];
39
+ /** List styles to show in the toolbox */
40
+ toolboxStyles?: ListStyle[];
41
+ /** Custom color for list items */
42
+ itemColor?: string;
43
+ /** Custom font size for list items */
44
+ itemSize?: string;
45
+ }
46
+
47
+ /**
48
+ * List Tool for the Blok Editor
49
+ * Provides Ordered, Unordered, and Checklist Blocks
50
+ */
51
+ export interface List extends BlockTool {
52
+ /**
53
+ * Return Tool's view
54
+ */
55
+ render(): HTMLElement;
56
+
57
+ /**
58
+ * Returns list block tunes config
59
+ */
60
+ renderSettings(): MenuConfig;
61
+
62
+ /**
63
+ * Method that specified how to merge two List blocks.
64
+ * Called by Editor by backspace at the beginning of the Block
65
+ */
66
+ merge(data: ListData): void;
67
+
68
+ /**
69
+ * Validate List block data
70
+ */
71
+ validate(blockData: ListData): boolean;
72
+
73
+ /**
74
+ * Extract Tool's data from the view
75
+ */
76
+ save(): ListData;
77
+ }
78
+
79
+ /**
80
+ * List Tool constructor
81
+ */
82
+ export interface ListConstructable extends BlockToolConstructable {
83
+ new(config: BlockToolConstructorOptions<ListData, ListConfig>): List;
84
+ }
@@ -0,0 +1,71 @@
1
+ import { BlockTool, BlockToolConstructable, BlockToolConstructorOptions, BlockToolData } from './block-tool';
2
+
3
+ /**
4
+ * Paragraph Tool's input and output data format
5
+ */
6
+ export interface ParagraphData extends BlockToolData {
7
+ /** Paragraph's content. Can include HTML tags: <a><b><i> */
8
+ text: string;
9
+ }
10
+
11
+ /**
12
+ * Style overrides for paragraph customization
13
+ */
14
+ export interface ParagraphStyleConfig {
15
+ /** Custom font size (e.g., '16px', '1rem') */
16
+ size?: string;
17
+ /** Custom line height (e.g., '1.6', '24px') */
18
+ lineHeight?: string;
19
+ /** Custom margin top (e.g., '10px', '0.5rem') */
20
+ marginTop?: string;
21
+ /** Custom margin bottom (e.g., '10px', '0.5rem') */
22
+ marginBottom?: string;
23
+ }
24
+
25
+ /**
26
+ * Paragraph Tool's configuration
27
+ */
28
+ export interface ParagraphConfig {
29
+ /** Placeholder for the empty paragraph */
30
+ placeholder?: string;
31
+ /** Whether or not to keep blank paragraphs when saving editor data */
32
+ preserveBlank?: boolean;
33
+ /** Style overrides for paragraph customization */
34
+ styles?: ParagraphStyleConfig;
35
+ /** Custom icon SVG string for the toolbox */
36
+ icon?: string;
37
+ }
38
+
39
+ /**
40
+ * Paragraph Tool for the Blok Editor
41
+ * Provides Text Block
42
+ */
43
+ export interface Paragraph extends BlockTool {
44
+ /**
45
+ * Return Tool's view
46
+ */
47
+ render(): HTMLDivElement;
48
+
49
+ /**
50
+ * Method that specified how to merge two Paragraph blocks.
51
+ * Called by Editor by backspace at the beginning of the Block
52
+ */
53
+ merge(data: ParagraphData): void;
54
+
55
+ /**
56
+ * Validate Paragraph block data
57
+ */
58
+ validate(savedData: ParagraphData): boolean;
59
+
60
+ /**
61
+ * Extract Tool's data from the view
62
+ */
63
+ save(toolsContent: HTMLDivElement): ParagraphData;
64
+ }
65
+
66
+ /**
67
+ * Paragraph Tool constructor
68
+ */
69
+ export interface ParagraphConstructable extends BlockToolConstructable {
70
+ new(config: BlockToolConstructorOptions<ParagraphData, ParagraphConfig>): Paragraph;
71
+ }
@@ -24,7 +24,14 @@ export interface ToolboxConfigEntry {
24
24
  /**
25
25
  * May contain overrides for tool default data
26
26
  */
27
- data?: BlockToolData
27
+ data?: BlockToolData;
28
+
29
+ /**
30
+ * Unique name for the toolbox entry, used for data-blok-item-name attribute.
31
+ * If not provided, falls back to the tool name.
32
+ * Useful when a tool has multiple toolbox entries (e.g., list with ordered/unordered/checklist variants).
33
+ */
34
+ name?: string;
28
35
  }
29
36
 
30
37
  /**