@jackuait/blok 0.4.1-beta.14 → 0.4.1-beta.16
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-CqdUPkVp.mjs → blok-B9aLxqRM.mjs} +266 -263
- package/dist/chunks/{i18next-loader-DGwfKvj7.mjs → i18next-loader-CYVZ-4iE.mjs} +1 -1
- package/dist/chunks/{index-Bq6UT5hl.mjs → index-DI4NIAy_.mjs} +1 -1
- package/dist/chunks/{inline-tool-convert-CmxgdS16.mjs → inline-tool-convert-DPhl4gmP.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 +28 -9
|
@@ -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.16", 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-B9aLxqRM.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-DPhl4gmP.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-DPhl4gmP.mjs";
|
|
14
|
+
import { a0 as Dt } from "./chunks/inline-tool-convert-DPhl4gmP.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.16",
|
|
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",
|
|
@@ -10,12 +10,13 @@ import { generateBlockId } from '../utils';
|
|
|
10
10
|
/**
|
|
11
11
|
* Legacy list item structure for data model transformation.
|
|
12
12
|
* Used internally for transforming legacy nested list data to the hierarchical model.
|
|
13
|
+
* Can be either an object with content property or a plain string.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
type LegacyListItem = {
|
|
15
16
|
content: string;
|
|
16
17
|
checked?: boolean;
|
|
17
18
|
items?: LegacyListItem[];
|
|
18
|
-
}
|
|
19
|
+
} | string;
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Legacy list data structure for data model transformation.
|
|
@@ -41,11 +42,26 @@ export interface DataFormatAnalysis {
|
|
|
41
42
|
hasHierarchy: boolean;
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Normalize a legacy list item to object format
|
|
47
|
+
*/
|
|
48
|
+
const normalizeListItem = (item: LegacyListItem): { content: string; checked?: boolean; items?: LegacyListItem[] } => {
|
|
49
|
+
if (typeof item === 'string') {
|
|
50
|
+
return { content: item };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return item;
|
|
54
|
+
};
|
|
55
|
+
|
|
44
56
|
/**
|
|
45
57
|
* Recursively check if any list item has nested items (for hasHierarchy flag)
|
|
46
58
|
*/
|
|
47
59
|
const hasNestedListItems = (items: LegacyListItem[]): boolean => {
|
|
48
|
-
return items.some(item =>
|
|
60
|
+
return items.some(item => {
|
|
61
|
+
const normalized = normalizeListItem(item);
|
|
62
|
+
|
|
63
|
+
return normalized.items !== undefined && normalized.items.length > 0;
|
|
64
|
+
});
|
|
49
65
|
};
|
|
50
66
|
|
|
51
67
|
/**
|
|
@@ -114,7 +130,9 @@ const expandListItems = (
|
|
|
114
130
|
): BlockId[] => {
|
|
115
131
|
const childIds: BlockId[] = [];
|
|
116
132
|
|
|
117
|
-
items.forEach((
|
|
133
|
+
items.forEach((rawItem, index) => {
|
|
134
|
+
// Normalize item to handle both string and object formats
|
|
135
|
+
const item = normalizeListItem(rawItem);
|
|
118
136
|
const itemId = generateBlockId();
|
|
119
137
|
|
|
120
138
|
childIds.push(itemId);
|
|
@@ -123,7 +141,7 @@ const expandListItems = (
|
|
|
123
141
|
const includeStart = style === 'ordered' && depth === 0 && index === 0 && start !== undefined && start !== 1;
|
|
124
142
|
|
|
125
143
|
// Check if there are nested items (we'll get their IDs after pushing the parent)
|
|
126
|
-
const
|
|
144
|
+
const hasChildren = item.items && item.items.length > 0;
|
|
127
145
|
|
|
128
146
|
// Create the list block (flat model - each item is a separate 'list' block)
|
|
129
147
|
// We'll update with content IDs after processing children
|
|
@@ -145,7 +163,7 @@ const expandListItems = (
|
|
|
145
163
|
blocks.push(itemBlock);
|
|
146
164
|
|
|
147
165
|
// Now recursively expand nested items (they will be added after the parent)
|
|
148
|
-
if (!
|
|
166
|
+
if (!hasChildren) {
|
|
149
167
|
return;
|
|
150
168
|
}
|
|
151
169
|
|
|
@@ -377,11 +395,12 @@ export const shouldExpandToHierarchical = (
|
|
|
377
395
|
dataModelConfig: 'legacy' | 'hierarchical' | 'auto',
|
|
378
396
|
detectedFormat: DataFormatAnalysis['format']
|
|
379
397
|
): boolean => {
|
|
380
|
-
|
|
381
|
-
|
|
398
|
+
// Always expand legacy format - each list item becomes a separate block
|
|
399
|
+
// This is required for the flat List tool model to render all items
|
|
400
|
+
if (detectedFormat === 'legacy') {
|
|
401
|
+
return dataModelConfig !== 'legacy';
|
|
382
402
|
}
|
|
383
403
|
|
|
384
|
-
// For 'auto' and 'legacy', don't expand
|
|
385
404
|
return false;
|
|
386
405
|
};
|
|
387
406
|
|