@jackuait/blok 0.4.1-beta.13 → 0.4.1-beta.14
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-CqdUPkVp.mjs} +385 -387
- package/dist/chunks/{i18next-loader-BMO6Rg_l.mjs → i18next-loader-DGwfKvj7.mjs} +1 -1
- package/dist/chunks/{index-DyPp5v5e.mjs → index-Bq6UT5hl.mjs} +1 -1
- package/dist/chunks/{inline-tool-convert-DhHW7EYl.mjs → inline-tool-convert-CmxgdS16.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 +21 -16
|
@@ -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.14", 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-CqdUPkVp.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-CmxgdS16.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-CmxgdS16.mjs";
|
|
14
|
+
import { a0 as Dt } from "./chunks/inline-tool-convert-CmxgdS16.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.14",
|
|
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 };
|
|
@@ -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
|
}
|