@jackuait/blok 0.4.1-beta.13 → 0.4.1-beta.15
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/blok.mjs +2 -2
- package/dist/chunks/{blok-Xfgk2kCJ.mjs → blok-CeuuGrRq.mjs} +385 -387
- package/dist/chunks/{i18next-loader-BMO6Rg_l.mjs → i18next-loader-Bb7mZZ5c.mjs} +1 -1
- package/dist/chunks/{index-DyPp5v5e.mjs → index-CH3ZRv_X.mjs} +1 -1
- package/dist/chunks/{inline-tool-convert-DhHW7EYl.mjs → inline-tool-convert-D8zvXApV.mjs} +1 -1
- package/dist/full.mjs +2 -2
- package/dist/tools.mjs +2 -2
- package/package.json +1 -1
- package/src/components/utils/data-model-transform.ts +27 -21
|
@@ -18,7 +18,7 @@ let nt = (o = 21) => {
|
|
|
18
18
|
return t;
|
|
19
19
|
};
|
|
20
20
|
var ot = /* @__PURE__ */ ((o) => (o.VERBOSE = "VERBOSE", o.INFO = "INFO", o.WARN = "WARN", o.ERROR = "ERROR", o))(ot || {});
|
|
21
|
-
const rt = () => "0.4.1-beta.
|
|
21
|
+
const rt = () => "0.4.1-beta.15", Ct = {
|
|
22
22
|
BACKSPACE: 8,
|
|
23
23
|
TAB: 9,
|
|
24
24
|
ENTER: 13,
|
package/dist/full.mjs
CHANGED
|
@@ -10,10 +10,10 @@ var e = (a, l, o) => l in a ? n(a, l, { enumerable: !0, configurable: !0, writab
|
|
|
10
10
|
d.call(l, o) && e(a, o, l[o]);
|
|
11
11
|
return a;
|
|
12
12
|
}, r = (a, l) => t(a, c(l));
|
|
13
|
-
import { B as v, v as A } from "./chunks/blok-
|
|
13
|
+
import { B as v, v as A } from "./chunks/blok-CeuuGrRq.mjs";
|
|
14
14
|
import { List as p, Header as f, Paragraph as I, Link as k, Italic as u, Bold as B } from "./tools.mjs";
|
|
15
15
|
import { defaultBlockTools as H, defaultInlineTools as P } from "./tools.mjs";
|
|
16
|
-
import { D as _ } from "./chunks/inline-tool-convert-
|
|
16
|
+
import { D as _ } from "./chunks/inline-tool-convert-D8zvXApV.mjs";
|
|
17
17
|
const m = {
|
|
18
18
|
paragraph: {
|
|
19
19
|
class: I,
|
package/dist/tools.mjs
CHANGED
|
@@ -10,8 +10,8 @@ var U = (f, t, e) => t in f ? nt(f, t, { enumerable: !0, configurable: !0, writa
|
|
|
10
10
|
it.call(t, e) && U(f, e, t[e]);
|
|
11
11
|
return f;
|
|
12
12
|
}, P = (f, t) => rt(f, st(t));
|
|
13
|
-
import { t as x, D as m, a9 as et, aa as at, ab as lt, A as ct, ac as dt, ad as ut, ae as ht, af as ft, ag as pt, ah as mt, ai as G, aj as j, ak as $, f as A, al as gt, am as Et, S as H, P as Tt, an as Ct, l as At, J as yt } from "./chunks/inline-tool-convert-
|
|
14
|
-
import { a0 as Dt } from "./chunks/inline-tool-convert-
|
|
13
|
+
import { t as x, D as m, a9 as et, aa as at, ab as lt, A as ct, ac as dt, ad as ut, ae as ht, af as ft, ag as pt, ah as mt, ai as G, aj as j, ak as $, f as A, al as gt, am as Et, S as H, P as Tt, an as Ct, l as At, J as yt } from "./chunks/inline-tool-convert-D8zvXApV.mjs";
|
|
14
|
+
import { a0 as Dt } from "./chunks/inline-tool-convert-D8zvXApV.mjs";
|
|
15
15
|
const W = [
|
|
16
16
|
"empty:before:pointer-events-none",
|
|
17
17
|
"empty:before:text-gray-text",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jackuait/blok",
|
|
3
|
-
"version": "0.4.1-beta.
|
|
3
|
+
"version": "0.4.1-beta.15",
|
|
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
|
"module": "dist/blok.mjs",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -42,20 +42,26 @@ export interface DataFormatAnalysis {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Recursively check if any list item has nested items
|
|
45
|
+
* Recursively check if any list item has nested items (for hasHierarchy flag)
|
|
46
46
|
*/
|
|
47
47
|
const hasNestedListItems = (items: LegacyListItem[]): boolean => {
|
|
48
48
|
return items.some(item => item.items !== undefined && item.items.length > 0);
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* Check if a block
|
|
53
|
-
*
|
|
52
|
+
* Check if a block is in legacy list format (has items[] array with content field)
|
|
53
|
+
* Legacy format: { items: [{ content: "text" }], style: "unordered" }
|
|
54
|
+
* Flat format: { text: "text", style: "unordered" }
|
|
54
55
|
*/
|
|
55
|
-
const
|
|
56
|
-
|
|
56
|
+
const isLegacyListBlock = (block: OutputBlockData): boolean => {
|
|
57
|
+
return block.type === 'list' && Array.isArray(block.data?.items);
|
|
58
|
+
};
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Check if a block contains nested hierarchy in its items
|
|
62
|
+
*/
|
|
63
|
+
const hasNestedItems = (block: OutputBlockData): boolean => {
|
|
64
|
+
if (!isLegacyListBlock(block)) {
|
|
59
65
|
return false;
|
|
60
66
|
}
|
|
61
67
|
|
|
@@ -81,10 +87,14 @@ export const analyzeDataFormat = (blocks: OutputBlockData[]): DataFormatAnalysis
|
|
|
81
87
|
return { format: 'hierarchical', hasHierarchy: true };
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
|
|
90
|
+
// Check if any block uses legacy list format (items[] array)
|
|
91
|
+
const foundLegacyList = blocks.some(isLegacyListBlock);
|
|
92
|
+
|
|
93
|
+
if (foundLegacyList) {
|
|
94
|
+
// Check if there's actual nesting for the hasHierarchy flag
|
|
95
|
+
const hasNesting = blocks.some(hasNestedItems);
|
|
85
96
|
|
|
86
|
-
|
|
87
|
-
return { format: 'legacy', hasHierarchy: true };
|
|
97
|
+
return { format: 'legacy', hasHierarchy: hasNesting };
|
|
88
98
|
}
|
|
89
99
|
|
|
90
100
|
return { format: 'flat', hasHierarchy: false };
|
|
@@ -113,7 +123,7 @@ const expandListItems = (
|
|
|
113
123
|
const includeStart = style === 'ordered' && depth === 0 && index === 0 && start !== undefined && start !== 1;
|
|
114
124
|
|
|
115
125
|
// Check if there are nested items (we'll get their IDs after pushing the parent)
|
|
116
|
-
const
|
|
126
|
+
const hasChildren = item.items && item.items.length > 0;
|
|
117
127
|
|
|
118
128
|
// Create the list block (flat model - each item is a separate 'list' block)
|
|
119
129
|
// We'll update with content IDs after processing children
|
|
@@ -135,7 +145,7 @@ const expandListItems = (
|
|
|
135
145
|
blocks.push(itemBlock);
|
|
136
146
|
|
|
137
147
|
// Now recursively expand nested items (they will be added after the parent)
|
|
138
|
-
if (!
|
|
148
|
+
if (!hasChildren) {
|
|
139
149
|
return;
|
|
140
150
|
}
|
|
141
151
|
|
|
@@ -176,12 +186,7 @@ export const expandToHierarchical = (blocks: OutputBlockData[]): OutputBlockData
|
|
|
176
186
|
const expandedBlocks: OutputBlockData[] = [];
|
|
177
187
|
|
|
178
188
|
for (const block of blocks) {
|
|
179
|
-
|
|
180
|
-
const blockId = block.id ?? generateBlockId();
|
|
181
|
-
|
|
182
|
-
const isListBlock = block.type === 'list' && block.data?.items;
|
|
183
|
-
|
|
184
|
-
if (isListBlock) {
|
|
189
|
+
if (isLegacyListBlock(block)) {
|
|
185
190
|
// Expand List tool nested items to flat blocks
|
|
186
191
|
const listData = block.data as LegacyListData;
|
|
187
192
|
const expanded = expandListToHierarchical(listData, block.tunes);
|
|
@@ -191,7 +196,7 @@ export const expandToHierarchical = (blocks: OutputBlockData[]): OutputBlockData
|
|
|
191
196
|
// Non-list blocks pass through unchanged (with guaranteed ID)
|
|
192
197
|
expandedBlocks.push({
|
|
193
198
|
...block,
|
|
194
|
-
id:
|
|
199
|
+
id: block.id ?? generateBlockId(),
|
|
195
200
|
});
|
|
196
201
|
}
|
|
197
202
|
}
|
|
@@ -372,11 +377,12 @@ export const shouldExpandToHierarchical = (
|
|
|
372
377
|
dataModelConfig: 'legacy' | 'hierarchical' | 'auto',
|
|
373
378
|
detectedFormat: DataFormatAnalysis['format']
|
|
374
379
|
): boolean => {
|
|
375
|
-
|
|
376
|
-
|
|
380
|
+
// Always expand legacy format - each list item becomes a separate block
|
|
381
|
+
// This is required for the flat List tool model to render all items
|
|
382
|
+
if (detectedFormat === 'legacy') {
|
|
383
|
+
return dataModelConfig !== 'legacy';
|
|
377
384
|
}
|
|
378
385
|
|
|
379
|
-
// For 'auto' and 'legacy', don't expand
|
|
380
386
|
return false;
|
|
381
387
|
};
|
|
382
388
|
|