@bloklabs/react 1.4.1 → 1.4.3
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/README.md +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +328 -213
- package/package.json +2 -2
- package/src/BlokContent.tsx +44 -0
- package/src/BlokEditor.tsx +26 -4
- package/src/BlokView.tsx +34 -14
- package/src/config-keys.ts +1 -0
- package/src/createReactBlock.tsx +134 -20
- package/src/createReactInlineTool.tsx +26 -3
- package/src/index.ts +6 -0
- package/src/useBlok.ts +32 -2
- package/src/useBlokHandle.ts +101 -0
- package/src/useBlokView.ts +11 -6
- package/types/index.d.ts +100 -21
package/dist/index.mjs
CHANGED
|
@@ -1,53 +1,54 @@
|
|
|
1
1
|
import { Component as e, Fragment as t, createContext as n, createElement as r, forwardRef as i, isValidElement as a, useCallback as o, useContext as s, useEffect as c, useImperativeHandle as l, useMemo as u, useRef as d, useState as f, useSyncExternalStore as p } from "react";
|
|
2
2
|
import { Blok as m } from "@bloklabs/core";
|
|
3
|
-
import { DATA_ATTR as h, EMPTY_API as g, createBlocksApiForEditor as _, createEmittedEchoWindow as v, deepEqual as y, deepEqual as b, fillDefaults as x, markSanitizerConfig as S, mountChildBlocks as C, normalizeReadOnlyConfig as ee } from "@bloklabs/core/adapters";
|
|
3
|
+
import { DATA_ATTR as h, EMPTY_API as g, createBlocksApiForEditor as _, createEmittedEchoWindow as v, deepEqual as y, deepEqual as b, fillDefaults as x, markSanitizerConfig as S, mountChildBlocks as C, normalizeReadOnlyConfig as ee, toRenderableData as te } from "@bloklabs/core/adapters";
|
|
4
4
|
import { Fragment as w, jsx as T } from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { getDirection as E, normalizeLocale as D } from "@bloklabs/core/locales";
|
|
6
|
+
import { createPortal as O, flushSync as k } from "react-dom";
|
|
7
|
+
import { blocksToViewNodes as A } from "@bloklabs/core/view";
|
|
8
|
+
import { createRoot as j } from "react-dom/client";
|
|
8
9
|
//#region src/holder-map.ts
|
|
9
|
-
var
|
|
10
|
-
function
|
|
11
|
-
|
|
10
|
+
var M = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
function ne(e, t) {
|
|
12
|
+
M.set(e, t);
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
14
|
+
function N(e) {
|
|
15
|
+
return M.get(e);
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
17
|
+
function P(e) {
|
|
18
|
+
M.delete(e);
|
|
18
19
|
}
|
|
19
20
|
//#endregion
|
|
20
21
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
|
|
21
|
-
function
|
|
22
|
+
function F(e) {
|
|
22
23
|
"@babel/helpers - typeof";
|
|
23
|
-
return
|
|
24
|
+
return F = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
24
25
|
return typeof e;
|
|
25
26
|
} : function(e) {
|
|
26
27
|
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
27
|
-
},
|
|
28
|
+
}, F(e);
|
|
28
29
|
}
|
|
29
30
|
//#endregion
|
|
30
31
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
|
|
31
|
-
function
|
|
32
|
-
if (
|
|
32
|
+
function I(e, t) {
|
|
33
|
+
if (F(e) != "object" || !e) return e;
|
|
33
34
|
var n = e[Symbol.toPrimitive];
|
|
34
35
|
if (n !== void 0) {
|
|
35
36
|
var r = n.call(e, t || "default");
|
|
36
|
-
if (
|
|
37
|
+
if (F(r) != "object") return r;
|
|
37
38
|
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
38
39
|
}
|
|
39
40
|
return (t === "string" ? String : Number)(e);
|
|
40
41
|
}
|
|
41
42
|
//#endregion
|
|
42
43
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
|
|
43
|
-
function
|
|
44
|
-
var t =
|
|
45
|
-
return
|
|
44
|
+
function L(e) {
|
|
45
|
+
var t = I(e, "string");
|
|
46
|
+
return F(t) == "symbol" ? t : t + "";
|
|
46
47
|
}
|
|
47
48
|
//#endregion
|
|
48
49
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
|
|
49
|
-
function
|
|
50
|
-
return (t =
|
|
50
|
+
function R(e, t, n) {
|
|
51
|
+
return (t = L(t)) in e ? Object.defineProperty(e, t, {
|
|
51
52
|
value: n,
|
|
52
53
|
enumerable: !0,
|
|
53
54
|
configurable: !0,
|
|
@@ -56,7 +57,7 @@ function I(e, t, n) {
|
|
|
56
57
|
}
|
|
57
58
|
//#endregion
|
|
58
59
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/objectSpread2.js
|
|
59
|
-
function
|
|
60
|
+
function z(e, t) {
|
|
60
61
|
var n = Object.keys(e);
|
|
61
62
|
if (Object.getOwnPropertySymbols) {
|
|
62
63
|
var r = Object.getOwnPropertySymbols(e);
|
|
@@ -66,12 +67,12 @@ function L(e, t) {
|
|
|
66
67
|
}
|
|
67
68
|
return n;
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
+
function B(e) {
|
|
70
71
|
for (var t = 1; t < arguments.length; t++) {
|
|
71
72
|
var n = arguments[t] == null ? {} : arguments[t];
|
|
72
|
-
t % 2 ?
|
|
73
|
-
|
|
74
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) :
|
|
73
|
+
t % 2 ? z(Object(n), !0).forEach(function(t) {
|
|
74
|
+
R(e, t, n[t]);
|
|
75
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : z(Object(n)).forEach(function(t) {
|
|
75
76
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
76
77
|
});
|
|
77
78
|
}
|
|
@@ -79,35 +80,35 @@ function R(e) {
|
|
|
79
80
|
}
|
|
80
81
|
//#endregion
|
|
81
82
|
//#region src/provide-blok.tsx
|
|
82
|
-
var
|
|
83
|
-
function
|
|
84
|
-
return /* @__PURE__ */ T(
|
|
83
|
+
var V = n({});
|
|
84
|
+
function H({ defaults: e, children: t }) {
|
|
85
|
+
return /* @__PURE__ */ T(V.Provider, {
|
|
85
86
|
value: e,
|
|
86
87
|
children: t
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
|
-
function
|
|
90
|
-
return s(
|
|
90
|
+
function U() {
|
|
91
|
+
return s(V);
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
+
function re(e, t) {
|
|
93
94
|
if (Object.keys(e).length === 0) return t;
|
|
94
|
-
let n =
|
|
95
|
+
let n = B({}, e);
|
|
95
96
|
for (let e of Object.keys(t)) {
|
|
96
97
|
let r = t[e];
|
|
97
98
|
r !== void 0 && (n[e] = r);
|
|
98
99
|
}
|
|
99
|
-
return (e.tools !== void 0 || t.tools !== void 0) && (n.tools =
|
|
100
|
+
return (e.tools !== void 0 || t.tools !== void 0) && (n.tools = B(B({}, e.tools), t.tools)), n;
|
|
100
101
|
}
|
|
101
102
|
//#endregion
|
|
102
103
|
//#region src/block-portal-registry.ts
|
|
103
|
-
var
|
|
104
|
+
var W = "__blokPortalRegistry", G = "__blokToolName", K = () => {
|
|
104
105
|
let e = { snapshot: /* @__PURE__ */ new Map() }, t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map(), r = (n) => {
|
|
105
106
|
e.snapshot = n, t.forEach((e) => e());
|
|
106
107
|
};
|
|
107
108
|
return {
|
|
108
109
|
register(t, i) {
|
|
109
110
|
let a = new Map(e.snapshot), o = i.toolName === void 0 ? void 0 : n.get(i.toolName);
|
|
110
|
-
a.set(t, o === void 0 ? i :
|
|
111
|
+
a.set(t, o === void 0 ? i : B(B({}, i), {}, { props: B(B({}, i.props), {}, { config: o }) })), r(a);
|
|
111
112
|
},
|
|
112
113
|
unregister(t) {
|
|
113
114
|
if (!e.snapshot.has(t)) return;
|
|
@@ -118,14 +119,14 @@ var H = "__blokPortalRegistry", U = "__blokToolName", W = () => {
|
|
|
118
119
|
let i = e.snapshot.get(t);
|
|
119
120
|
if (i === void 0) return;
|
|
120
121
|
let a = new Map(e.snapshot);
|
|
121
|
-
a.set(t,
|
|
122
|
+
a.set(t, B(B({}, i), {}, { props: B(B({}, i.props), n) })), r(a);
|
|
122
123
|
},
|
|
123
124
|
setToolConfig(t, i) {
|
|
124
125
|
n.set(t, i);
|
|
125
126
|
let a = [...e.snapshot].filter(([, e]) => e.toolName === t);
|
|
126
127
|
if (a.length === 0) return;
|
|
127
128
|
let o = new Map(e.snapshot);
|
|
128
|
-
for (let [e, t] of a) o.set(e,
|
|
129
|
+
for (let [e, t] of a) o.set(e, B(B({}, t), {}, { props: B(B({}, t.props), {}, { config: i }) }));
|
|
129
130
|
r(o);
|
|
130
131
|
},
|
|
131
132
|
subscribe(e) {
|
|
@@ -137,45 +138,45 @@ var H = "__blokPortalRegistry", U = "__blokToolName", W = () => {
|
|
|
137
138
|
return e.snapshot;
|
|
138
139
|
}
|
|
139
140
|
};
|
|
140
|
-
},
|
|
141
|
-
function
|
|
142
|
-
|
|
141
|
+
}, q = /* @__PURE__ */ new WeakMap();
|
|
142
|
+
function ie(e, t) {
|
|
143
|
+
q.set(e, t);
|
|
143
144
|
}
|
|
144
|
-
function
|
|
145
|
-
return
|
|
145
|
+
function ae(e) {
|
|
146
|
+
return q.get(e);
|
|
146
147
|
}
|
|
147
|
-
function
|
|
148
|
-
|
|
148
|
+
function J(e) {
|
|
149
|
+
q.delete(e);
|
|
149
150
|
}
|
|
150
151
|
//#endregion
|
|
151
152
|
//#region src/live-tool-config.ts
|
|
152
|
-
var
|
|
153
|
+
var Y = (e) => {
|
|
153
154
|
if (typeof e != "object" || !e) return !1;
|
|
154
155
|
let t = Object.getPrototypeOf(e);
|
|
155
156
|
return t === Object.prototype || t === null;
|
|
156
|
-
},
|
|
157
|
+
}, oe = (e, t) => t.reduce((e, t) => {
|
|
157
158
|
if (Array.isArray(e)) return typeof t == "number" ? e[t] : void 0;
|
|
158
|
-
if (
|
|
159
|
-
}, e),
|
|
159
|
+
if (Y(e)) return e[t];
|
|
160
|
+
}, e), se = (e, t) => {
|
|
160
161
|
let n = (e, t) => {
|
|
161
162
|
if (typeof e == "function") return typeof t == "function" ? t : e;
|
|
162
163
|
if (Array.isArray(e)) {
|
|
163
164
|
let r = Array.isArray(t) ? t : [];
|
|
164
165
|
return e.map((e, t) => n(e, r[t]));
|
|
165
166
|
}
|
|
166
|
-
if (
|
|
167
|
-
let r =
|
|
167
|
+
if (Y(e)) {
|
|
168
|
+
let r = Y(t) ? t : {}, i = {};
|
|
168
169
|
for (let [t, a] of Object.entries(e)) i[t] = n(a, r[t]);
|
|
169
170
|
return i;
|
|
170
171
|
}
|
|
171
172
|
return e;
|
|
172
173
|
}, r = n(t, e);
|
|
173
|
-
return
|
|
174
|
-
},
|
|
175
|
-
if (!
|
|
174
|
+
return Y(r) ? r : {};
|
|
175
|
+
}, ce = (e, t) => {
|
|
176
|
+
if (!Y(e)) return e;
|
|
176
177
|
let n = {};
|
|
177
178
|
for (let [r, i] of Object.entries(e)) {
|
|
178
|
-
if (!
|
|
179
|
+
if (!Y(i) || !Y(i.config)) {
|
|
179
180
|
n[r] = i;
|
|
180
181
|
continue;
|
|
181
182
|
}
|
|
@@ -183,12 +184,12 @@ var q = (e) => {
|
|
|
183
184
|
if (typeof n == "function") {
|
|
184
185
|
let e = n;
|
|
185
186
|
return function(...n) {
|
|
186
|
-
let a = t(), o =
|
|
187
|
+
let a = t(), o = Y(a) ? a[r] : void 0, s = oe(Y(o) ? o.config : void 0, i);
|
|
187
188
|
return Reflect.apply(typeof s == "function" ? s : e, this, n);
|
|
188
189
|
};
|
|
189
190
|
}
|
|
190
191
|
if (Array.isArray(n)) return e.has(n) ? n : (e.add(n), n.map((e, t) => a(e, [...i, t])));
|
|
191
|
-
if (
|
|
192
|
+
if (Y(n)) {
|
|
192
193
|
if (e.has(n)) return n;
|
|
193
194
|
e.add(n);
|
|
194
195
|
let t = {};
|
|
@@ -197,35 +198,37 @@ var q = (e) => {
|
|
|
197
198
|
}
|
|
198
199
|
return n;
|
|
199
200
|
};
|
|
200
|
-
n[r] =
|
|
201
|
+
n[r] = B(B({}, i), {}, { config: a(i.config, []) });
|
|
201
202
|
}
|
|
202
203
|
return n;
|
|
203
|
-
},
|
|
204
|
+
}, X = (e) => {
|
|
204
205
|
let t = typeof e == "function" ? e : e == null ? void 0 : e.class;
|
|
205
206
|
return typeof t == "function" && t.__isBlokReactBlock === !0;
|
|
206
|
-
},
|
|
207
|
+
}, le = (e) => {
|
|
207
208
|
let t = typeof e == "function" ? e : e == null ? void 0 : e.class;
|
|
208
209
|
return typeof t == "function" && t.__isBlokReactInlineTool === !0;
|
|
209
|
-
},
|
|
210
|
+
}, ue = (e, t) => {
|
|
210
211
|
if (typeof e != "object" || !e) return e;
|
|
211
212
|
let n = {};
|
|
212
213
|
for (let [i, a] of Object.entries(e)) {
|
|
213
214
|
var r;
|
|
214
|
-
if (!
|
|
215
|
+
if (!X(a) && !le(a)) {
|
|
215
216
|
n[i] = a;
|
|
216
217
|
continue;
|
|
217
218
|
}
|
|
218
|
-
let e = typeof a == "function" ? { class: a } :
|
|
219
|
-
e.config =
|
|
220
|
-
[
|
|
221
|
-
[
|
|
222
|
-
})
|
|
219
|
+
let e = typeof a == "function" ? { class: a } : B({}, a);
|
|
220
|
+
e.config = B(B({}, (r = e.config) == null ? {} : r), {}, {
|
|
221
|
+
[W]: t,
|
|
222
|
+
[G]: i
|
|
223
|
+
});
|
|
224
|
+
let o = e.class.__buildPortalToolbox, s = typeof o == "function" && e.toolbox === void 0 ? o(t, i) : void 0;
|
|
225
|
+
s !== void 0 && (e.toolbox = s), n[i] = e;
|
|
223
226
|
}
|
|
224
227
|
return n;
|
|
225
228
|
};
|
|
226
|
-
function
|
|
229
|
+
function Z(e, t) {
|
|
227
230
|
var n, r;
|
|
228
|
-
let i =
|
|
231
|
+
let i = re(s(V), e), [a, o] = f(null), l = d(i);
|
|
229
232
|
l.current = i;
|
|
230
233
|
let p = d({
|
|
231
234
|
editor: null,
|
|
@@ -240,10 +243,10 @@ function Y(e, t) {
|
|
|
240
243
|
if (typeof window > "u") return;
|
|
241
244
|
let t = p.current;
|
|
242
245
|
if (t.destroyTimeout !== null && (clearTimeout(t.destroyTimeout), t.destroyTimeout = null), t.editor !== null && !t.isDestroyed && t.depsToken === h) return t.isEditorReady && o(t.editor), () => {
|
|
243
|
-
|
|
246
|
+
Q(t, o);
|
|
244
247
|
};
|
|
245
248
|
if (t.editor !== null && !t.isDestroyed) {
|
|
246
|
-
|
|
249
|
+
P(t.editor), J(t.editor);
|
|
247
250
|
try {
|
|
248
251
|
t.editor.destroy();
|
|
249
252
|
} catch (e) {}
|
|
@@ -251,9 +254,9 @@ function Y(e, t) {
|
|
|
251
254
|
}
|
|
252
255
|
let n = document.createElement("div");
|
|
253
256
|
t.holder = n, t.isDestroyed = !1, t.isEditorReady = !1, t.depsToken = h;
|
|
254
|
-
let r = l.current, i =
|
|
257
|
+
let r = l.current, i = K(), a = r.tools === void 0 ? void 0 : ce(r.tools, () => l.current.tools), s = a === void 0 ? void 0 : ue(a, i);
|
|
255
258
|
w.current = i, T.current = a, E.current = /* @__PURE__ */ new Map(), D.current = new Map(Object.entries((e = r.tools) == null ? {} : e).map(([e, t]) => [e, typeof t == "object" && t ? t.toolbox : void 0]));
|
|
256
|
-
let c =
|
|
259
|
+
let c = B(B(B({}, r), s === void 0 ? {} : { tools: s }), {}, {
|
|
257
260
|
holder: n,
|
|
258
261
|
onReady: (...e) => {
|
|
259
262
|
var t, n;
|
|
@@ -268,7 +271,10 @@ function Y(e, t) {
|
|
|
268
271
|
return (t = (n = l.current).onEnter) == null ? void 0 : t.call(n, ...e);
|
|
269
272
|
}
|
|
270
273
|
});
|
|
271
|
-
r.
|
|
274
|
+
r.onSubmit && (c.onSubmit = (...e) => {
|
|
275
|
+
var t, n;
|
|
276
|
+
(t = (n = l.current).onSubmit) == null || t.call(n, ...e);
|
|
277
|
+
}), r.onSave && (c.onSave = (...e) => {
|
|
272
278
|
var t, n;
|
|
273
279
|
g.current = e[0], _.current.record(e[0]), (t = (n = l.current).onSave) == null || t.call(n, ...e);
|
|
274
280
|
}), r.onBeforeRender && (c.onBeforeRender = (...e) => {
|
|
@@ -279,18 +285,18 @@ function Y(e, t) {
|
|
|
279
285
|
(t = (n = l.current).onAfterRender) == null || t.call(n, ...e);
|
|
280
286
|
});
|
|
281
287
|
let u = new m(c);
|
|
282
|
-
return t.editor = u, x.current = r.data,
|
|
288
|
+
return t.editor = u, x.current = r.data, ne(u, n), ie(u, i), u.isReady.then(() => {
|
|
283
289
|
t.editor === u && !t.isDestroyed && (t.isEditorReady = !0, o(u));
|
|
284
290
|
}).catch(() => {
|
|
285
291
|
if (t.editor === u && !t.isDestroyed) {
|
|
286
|
-
|
|
292
|
+
P(u), J(u);
|
|
287
293
|
try {
|
|
288
294
|
u.destroy();
|
|
289
295
|
} catch (e) {}
|
|
290
296
|
t.editor = null, t.holder = null, t.isDestroyed = !0, t.isEditorReady = !1, o(null);
|
|
291
297
|
}
|
|
292
298
|
}), () => {
|
|
293
|
-
|
|
299
|
+
Q(t, o);
|
|
294
300
|
};
|
|
295
301
|
}, [h]), c(() => {
|
|
296
302
|
let e = w.current, t = p.current;
|
|
@@ -300,8 +306,8 @@ function Y(e, t) {
|
|
|
300
306
|
let r = T.current;
|
|
301
307
|
for (let [t, a] of Object.entries(n)) {
|
|
302
308
|
var i;
|
|
303
|
-
if (!
|
|
304
|
-
let n = typeof a == "function" || (i = a.config) == null ? {} : i, o = r == null ? void 0 : r[t], s =
|
|
309
|
+
if (!X(a)) continue;
|
|
310
|
+
let n = typeof a == "function" || (i = a.config) == null ? {} : i, o = r == null ? void 0 : r[t], s = se(typeof o == "object" && o ? o.config : void 0, n), c = E.current.get(t);
|
|
305
311
|
if (c !== void 0 && b(s, c)) continue;
|
|
306
312
|
let l = Object.freeze(s);
|
|
307
313
|
E.current.set(t, l), e.setToolConfig(t, l);
|
|
@@ -330,14 +336,14 @@ function Y(e, t) {
|
|
|
330
336
|
c(() => {
|
|
331
337
|
a === null || j === void 0 || a.toolbar.setHidden(j);
|
|
332
338
|
}, [a, j]);
|
|
333
|
-
let { inlineToolbar:
|
|
339
|
+
let { inlineToolbar: M } = i;
|
|
334
340
|
c(() => {
|
|
335
|
-
a === null ||
|
|
336
|
-
}, [a,
|
|
337
|
-
let { autofocus:
|
|
341
|
+
a === null || M === void 0 || a.tools.setInlineToolbar(M);
|
|
342
|
+
}, [a, M === void 0 ? void 0 : JSON.stringify(M)]);
|
|
343
|
+
let { autofocus: N } = i;
|
|
338
344
|
c(() => {
|
|
339
|
-
a === null || !
|
|
340
|
-
}, [a,
|
|
345
|
+
a === null || !N || a.focus();
|
|
346
|
+
}, [a, N]);
|
|
341
347
|
let { theme: F } = i;
|
|
342
348
|
c(() => {
|
|
343
349
|
a === null || F === void 0 || a.theme.set(F);
|
|
@@ -346,42 +352,42 @@ function Y(e, t) {
|
|
|
346
352
|
c(() => {
|
|
347
353
|
a === null || I === void 0 || a.width.set(I);
|
|
348
354
|
}, [a, I]);
|
|
349
|
-
let L = (n = i.style) == null ? void 0 : n.tokens,
|
|
355
|
+
let L = (n = i.style) == null ? void 0 : n.tokens, R = d((r = i.style) == null ? void 0 : r.tokens);
|
|
350
356
|
c(() => {
|
|
351
|
-
a === null || L === void 0 || b(L,
|
|
357
|
+
a === null || L === void 0 || b(L, R.current) || (R.current = L, a.tokens.set(L));
|
|
352
358
|
}, [a, L]);
|
|
353
|
-
let { i18n:
|
|
359
|
+
let { i18n: z } = i, H = d(i.i18n);
|
|
354
360
|
c(() => {
|
|
355
|
-
if (a === null ||
|
|
356
|
-
H.current =
|
|
357
|
-
let { locale: e, messages: t, direction: n } =
|
|
358
|
-
a.i18n.update(
|
|
359
|
-
}, [a,
|
|
361
|
+
if (a === null || z === void 0 || b(z, H.current)) return;
|
|
362
|
+
H.current = z;
|
|
363
|
+
let { locale: e, messages: t, direction: n } = z;
|
|
364
|
+
a.i18n.update(B(B(B({}, e === void 0 ? {} : { locale: e }), t === void 0 ? {} : { messages: t }), n === void 0 ? {} : { direction: n }));
|
|
365
|
+
}, [a, z]);
|
|
360
366
|
let { placeholder: U } = i;
|
|
361
367
|
c(() => {
|
|
362
368
|
a === null || U === void 0 || a.placeholder.set(U);
|
|
363
369
|
}, [a, U]);
|
|
364
|
-
let { data:
|
|
370
|
+
let { data: W } = i;
|
|
365
371
|
return c(() => {
|
|
366
|
-
if (a === null ||
|
|
372
|
+
if (a === null || W === void 0) return;
|
|
367
373
|
let e = p.current;
|
|
368
374
|
if (!(e.editor !== a || e.isDestroyed)) {
|
|
369
|
-
if (y.current !== a && (y.current = a, C.current = void 0, _.current.clear(), b(
|
|
370
|
-
g.current =
|
|
375
|
+
if (y.current !== a && (y.current = a, C.current = void 0, _.current.clear(), b(W, x.current))) {
|
|
376
|
+
g.current = W;
|
|
371
377
|
return;
|
|
372
378
|
}
|
|
373
|
-
b(
|
|
374
|
-
g.current =
|
|
379
|
+
b(W, g.current) || b(W, C.current) || _.current.matches(W) || (_.current.clear(), C.current = W, S.current = S.current.catch(() => void 0).then(() => a.render(te(W))).then(() => {
|
|
380
|
+
g.current = W;
|
|
375
381
|
}, () => {}).then(() => {
|
|
376
|
-
C.current ===
|
|
382
|
+
C.current === W && (C.current = void 0);
|
|
377
383
|
}));
|
|
378
384
|
}
|
|
379
|
-
}, [a,
|
|
385
|
+
}, [a, W]), a;
|
|
380
386
|
}
|
|
381
|
-
function
|
|
387
|
+
function Q(e, t) {
|
|
382
388
|
e.destroyTimeout = setTimeout(() => {
|
|
383
389
|
if (e.editor !== null) {
|
|
384
|
-
|
|
390
|
+
P(e.editor), J(e.editor);
|
|
385
391
|
try {
|
|
386
392
|
e.editor.destroy();
|
|
387
393
|
} catch (e) {}
|
|
@@ -391,7 +397,7 @@ function X(e, t) {
|
|
|
391
397
|
}
|
|
392
398
|
//#endregion
|
|
393
399
|
//#region src/BlockPortalHost.tsx
|
|
394
|
-
var
|
|
400
|
+
var de = class extends e {
|
|
395
401
|
constructor(...e) {
|
|
396
402
|
super(...e), this.state = { failed: !1 };
|
|
397
403
|
}
|
|
@@ -403,16 +409,16 @@ var ue = class extends e {
|
|
|
403
409
|
return this.state.failed ? null : this.props.children;
|
|
404
410
|
}
|
|
405
411
|
};
|
|
406
|
-
function
|
|
412
|
+
function fe({ registry: e }) {
|
|
407
413
|
let t = p(e.subscribe, e.getSnapshot, e.getSnapshot);
|
|
408
414
|
return /* @__PURE__ */ T(w, { children: Array.from(t.entries()).map(([e, t]) => {
|
|
409
415
|
let n = t.component;
|
|
410
|
-
return
|
|
416
|
+
return O(/* @__PURE__ */ T(de, { children: /* @__PURE__ */ T(n, B({}, t.props)) }), t.hostEl, e);
|
|
411
417
|
}) });
|
|
412
418
|
}
|
|
413
419
|
//#endregion
|
|
414
420
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/objectWithoutPropertiesLoose.js
|
|
415
|
-
function
|
|
421
|
+
function pe(e, t) {
|
|
416
422
|
if (e == null) return {};
|
|
417
423
|
var n = {};
|
|
418
424
|
for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
|
|
@@ -423,9 +429,9 @@ function de(e, t) {
|
|
|
423
429
|
}
|
|
424
430
|
//#endregion
|
|
425
431
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/objectWithoutProperties.js
|
|
426
|
-
function
|
|
432
|
+
function $(e, t) {
|
|
427
433
|
if (e == null) return {};
|
|
428
|
-
var n, r, i =
|
|
434
|
+
var n, r, i = pe(e, t);
|
|
429
435
|
if (Object.getOwnPropertySymbols) {
|
|
430
436
|
var a = Object.getOwnPropertySymbols(e);
|
|
431
437
|
for (r = 0; r < a.length; r++) n = a[r], t.includes(n) || {}.propertyIsEnumerable.call(e, n) && (i[n] = e[n]);
|
|
@@ -434,8 +440,22 @@ function Q(e, t) {
|
|
|
434
440
|
}
|
|
435
441
|
//#endregion
|
|
436
442
|
//#region src/BlokContent.tsx
|
|
437
|
-
var
|
|
438
|
-
|
|
443
|
+
var me = ["editor"];
|
|
444
|
+
function he(e) {
|
|
445
|
+
var t, n;
|
|
446
|
+
if (typeof window > "u") return;
|
|
447
|
+
let r = window.location.hash.slice(1);
|
|
448
|
+
r !== "" && ((t = (n = e.blocks).scrollToBlock) == null || t.call(n, ge(r)));
|
|
449
|
+
}
|
|
450
|
+
function ge(e) {
|
|
451
|
+
try {
|
|
452
|
+
return decodeURIComponent(e);
|
|
453
|
+
} catch (t) {
|
|
454
|
+
return e;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
var _e = i(function(e, t) {
|
|
458
|
+
let { editor: n } = e, r = $(e, me), i = d(null), a = (e) => {
|
|
439
459
|
if (i.current = e, typeof t == "function") t(e);
|
|
440
460
|
else if (t != null) {
|
|
441
461
|
let n = t;
|
|
@@ -444,67 +464,108 @@ var fe = ["editor"], pe = i(function(e, t) {
|
|
|
444
464
|
};
|
|
445
465
|
c(() => {
|
|
446
466
|
if (n === null || i.current === null) return;
|
|
447
|
-
let e =
|
|
448
|
-
if (e !== void 0) return i.current.appendChild(e), () => {
|
|
467
|
+
let e = N(n);
|
|
468
|
+
if (e !== void 0) return i.current.appendChild(e), he(n), () => {
|
|
449
469
|
e.remove();
|
|
450
470
|
};
|
|
451
471
|
}, [n]);
|
|
452
|
-
let o = n === null ? void 0 :
|
|
453
|
-
return /* @__PURE__ */ T("div",
|
|
454
|
-
}),
|
|
472
|
+
let o = n === null ? void 0 : ae(n);
|
|
473
|
+
return /* @__PURE__ */ T("div", B(B({ ref: a }, r), {}, { children: o === void 0 ? null : /* @__PURE__ */ T(fe, { registry: o }) }));
|
|
474
|
+
}), ve = /* @__PURE__ */ "autofocus.defaultBlock.dataModel.placeholder.sanitizer.hideToolbar.maxHistoryLength.historyDebounceTime.newGroupDelay.globalUndoRedo.tools.data.minHeight.logLevel.readOnly.i18n.link.linkPaste.onBeforePaste.onReady.onChange.onSave.onError.onEnter.onSubmit.onBeforeRender.onAfterRender.inlineToolbar.tunes.style.theme.onThemeChange.scrollToBlock.user.resolveUser.notifierPosition.notifier.width".split("."), ye = [
|
|
455
475
|
"deps",
|
|
456
476
|
"onReady",
|
|
477
|
+
"locale",
|
|
457
478
|
"onBlocksRendered",
|
|
458
479
|
"onBlockRendered"
|
|
459
|
-
],
|
|
460
|
-
let { deps: n, onReady: r,
|
|
461
|
-
for (let e of Object.keys(
|
|
462
|
-
let t =
|
|
463
|
-
|
|
480
|
+
], be = new Set(ve), xe = i(function(e, t) {
|
|
481
|
+
let { deps: n, onReady: r, locale: i, onBlocksRendered: a, onBlockRendered: o } = e, s = $(e, ye), u = {}, f = {};
|
|
482
|
+
for (let e of Object.keys(s)) {
|
|
483
|
+
let t = s[e];
|
|
484
|
+
be.has(e) ? u[e] = t : f[e] = t;
|
|
464
485
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
let
|
|
486
|
+
if (i !== void 0) {
|
|
487
|
+
let e = u.i18n;
|
|
488
|
+
u.i18n = B(B({}, e), {}, { locale: i });
|
|
489
|
+
}
|
|
490
|
+
let p = Z(u, n);
|
|
491
|
+
l(t, () => p, [p]);
|
|
492
|
+
let m = d(r);
|
|
493
|
+
m.current = r;
|
|
494
|
+
let h = d(null);
|
|
470
495
|
c(() => {
|
|
471
|
-
if (
|
|
496
|
+
if (p !== null && h.current !== p) {
|
|
472
497
|
var e;
|
|
473
|
-
|
|
498
|
+
h.current = p, (e = m.current) == null || e.call(m, p);
|
|
474
499
|
}
|
|
475
|
-
}, [
|
|
476
|
-
let h = d(i);
|
|
477
|
-
h.current = i;
|
|
500
|
+
}, [p]);
|
|
478
501
|
let g = d(a);
|
|
479
502
|
g.current = a;
|
|
480
|
-
let _ =
|
|
503
|
+
let _ = d(o);
|
|
504
|
+
_.current = o;
|
|
505
|
+
let v = !!a, y = !!o;
|
|
481
506
|
return c(() => {
|
|
482
|
-
if (
|
|
507
|
+
if (p === null) return;
|
|
483
508
|
let e = [];
|
|
484
|
-
if (
|
|
509
|
+
if (v) {
|
|
485
510
|
let t = (e) => {
|
|
486
511
|
var t;
|
|
487
|
-
return (t =
|
|
512
|
+
return (t = g.current) == null ? void 0 : t.call(g, e);
|
|
488
513
|
};
|
|
489
|
-
|
|
514
|
+
p.on("blocks:rendered", t), e.push(["blocks:rendered", t]);
|
|
490
515
|
}
|
|
491
|
-
if (
|
|
516
|
+
if (y) {
|
|
492
517
|
let t = (e) => {
|
|
493
518
|
var t;
|
|
494
|
-
return (t =
|
|
519
|
+
return (t = _.current) == null ? void 0 : t.call(_, e);
|
|
495
520
|
};
|
|
496
|
-
|
|
521
|
+
p.on("block:rendered", t), e.push(["block:rendered", t]);
|
|
497
522
|
}
|
|
498
523
|
return () => {
|
|
499
|
-
for (let [t, n] of e)
|
|
524
|
+
for (let [t, n] of e) p.off(t, n);
|
|
500
525
|
};
|
|
501
526
|
}, [
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
]), /* @__PURE__ */ T(
|
|
506
|
-
})
|
|
507
|
-
|
|
527
|
+
p,
|
|
528
|
+
v,
|
|
529
|
+
y
|
|
530
|
+
]), /* @__PURE__ */ T(_e, B({ editor: p }, f));
|
|
531
|
+
});
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region src/useBlokHandle.ts
|
|
534
|
+
function Se() {
|
|
535
|
+
let e = d(null);
|
|
536
|
+
return u(() => ({
|
|
537
|
+
ref: (t) => {
|
|
538
|
+
e.current = t;
|
|
539
|
+
},
|
|
540
|
+
get current() {
|
|
541
|
+
return e.current;
|
|
542
|
+
},
|
|
543
|
+
get isReady() {
|
|
544
|
+
return e.current !== null;
|
|
545
|
+
},
|
|
546
|
+
focus: (t) => {
|
|
547
|
+
var n, r;
|
|
548
|
+
return (n = (r = e.current) == null ? void 0 : r.focus(t)) != null && n;
|
|
549
|
+
},
|
|
550
|
+
clear: () => {
|
|
551
|
+
var t, n;
|
|
552
|
+
return (t = (n = e.current) == null ? void 0 : n.clear()) == null ? Promise.resolve() : t;
|
|
553
|
+
},
|
|
554
|
+
save: () => e.current === null ? Promise.resolve(null) : e.current.save(),
|
|
555
|
+
render: (t) => {
|
|
556
|
+
var n, r;
|
|
557
|
+
return (n = (r = e.current) == null ? void 0 : r.render(t)) == null ? Promise.resolve() : n;
|
|
558
|
+
},
|
|
559
|
+
setReadOnly: (t) => {
|
|
560
|
+
let n = e.current;
|
|
561
|
+
return n === null ? Promise.resolve(!1) : n.readOnly.set(t == null ? !n.readOnly.isEnabled : t);
|
|
562
|
+
}
|
|
563
|
+
}), []);
|
|
564
|
+
}
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region src/useBlocks.ts
|
|
567
|
+
var Ce = "block changed";
|
|
568
|
+
function we(e) {
|
|
508
569
|
let t = d(0), n = d(e);
|
|
509
570
|
n.current !== e && (n.current = e, t.current = 0);
|
|
510
571
|
let r = o((n) => {
|
|
@@ -512,13 +573,13 @@ function ye(e) {
|
|
|
512
573
|
let r = () => {
|
|
513
574
|
t.current += 1, n();
|
|
514
575
|
};
|
|
515
|
-
return e.on(
|
|
576
|
+
return e.on(Ce, r), () => e.off(Ce, r);
|
|
516
577
|
}, [e]), i = o(() => t.current, []);
|
|
517
578
|
return p(r, i, i), u(() => e === null ? g : _(e), [e]);
|
|
518
579
|
}
|
|
519
580
|
//#endregion
|
|
520
581
|
//#region src/useBlokReady.ts
|
|
521
|
-
function
|
|
582
|
+
function Te(e = {}) {
|
|
522
583
|
let { within: t, settleOn: n } = e, [r, i] = f(!1);
|
|
523
584
|
return c(() => {
|
|
524
585
|
let e = () => {
|
|
@@ -534,7 +595,7 @@ function be(e = {}) {
|
|
|
534
595
|
}
|
|
535
596
|
//#endregion
|
|
536
597
|
//#region src/view-nodes-to-react.ts
|
|
537
|
-
var
|
|
598
|
+
var Ee = /* @__PURE__ */ new Set([
|
|
538
599
|
"area",
|
|
539
600
|
"base",
|
|
540
601
|
"br",
|
|
@@ -549,7 +610,7 @@ var xe = /* @__PURE__ */ new Set([
|
|
|
549
610
|
"source",
|
|
550
611
|
"track",
|
|
551
612
|
"wbr"
|
|
552
|
-
]),
|
|
613
|
+
]), De = /* @__PURE__ */ new Set([
|
|
553
614
|
"disabled",
|
|
554
615
|
"open",
|
|
555
616
|
"controls",
|
|
@@ -565,7 +626,7 @@ var xe = /* @__PURE__ */ new Set([
|
|
|
565
626
|
"novalidate",
|
|
566
627
|
"allowfullscreen",
|
|
567
628
|
"itemscope"
|
|
568
|
-
]),
|
|
629
|
+
]), Oe = {
|
|
569
630
|
class: "className",
|
|
570
631
|
for: "htmlFor",
|
|
571
632
|
colspan: "colSpan",
|
|
@@ -587,7 +648,7 @@ var xe = /* @__PURE__ */ new Set([
|
|
|
587
648
|
minlength: "minLength",
|
|
588
649
|
usemap: "useMap",
|
|
589
650
|
itemscope: "itemScope"
|
|
590
|
-
},
|
|
651
|
+
}, ke = (e) => {
|
|
591
652
|
let t = {};
|
|
592
653
|
for (let n of e.split(";")) {
|
|
593
654
|
let e = n.indexOf(":");
|
|
@@ -598,12 +659,12 @@ var xe = /* @__PURE__ */ new Set([
|
|
|
598
659
|
t[a] = i;
|
|
599
660
|
}
|
|
600
661
|
return t;
|
|
601
|
-
},
|
|
662
|
+
}, Ae = (e, t) => {
|
|
602
663
|
let n = { key: t };
|
|
603
664
|
for (let [t, a] of Object.entries(e)) {
|
|
604
665
|
var r;
|
|
605
666
|
if (t === "style") {
|
|
606
|
-
n.style =
|
|
667
|
+
n.style = ke(a);
|
|
607
668
|
continue;
|
|
608
669
|
}
|
|
609
670
|
if (t === "checked") {
|
|
@@ -614,80 +675,127 @@ var xe = /* @__PURE__ */ new Set([
|
|
|
614
675
|
n.defaultValue = a;
|
|
615
676
|
continue;
|
|
616
677
|
}
|
|
617
|
-
if (
|
|
678
|
+
if (De.has(t)) {
|
|
618
679
|
var i;
|
|
619
|
-
n[(i =
|
|
680
|
+
n[(i = Oe[t]) == null ? t : i] = !0;
|
|
620
681
|
continue;
|
|
621
682
|
}
|
|
622
|
-
n[(r =
|
|
683
|
+
n[(r = Oe[t]) == null ? t : r] = a;
|
|
623
684
|
}
|
|
624
685
|
return n;
|
|
625
|
-
},
|
|
686
|
+
}, je = (e) => e.map((e, t) => {
|
|
626
687
|
if ("text" in e) return e.text;
|
|
627
|
-
let n =
|
|
628
|
-
return
|
|
629
|
-
}),
|
|
630
|
-
let i = n == null ? void 0 : n.schema, a = n == null ? void 0 : n.renderers, o = n == null ? void 0 : n.onUnknownBlock;
|
|
631
|
-
return u(() => r(t, null, ...
|
|
688
|
+
let n = Ae(e.attrs, t);
|
|
689
|
+
return Ee.has(e.tag) || e.children.length === 0 ? r(e.tag, n) : r(e.tag, n, ...je(e.children));
|
|
690
|
+
}), Me = (e, n) => {
|
|
691
|
+
let i = n == null ? void 0 : n.schema, a = n == null ? void 0 : n.renderers, o = n == null ? void 0 : n.onUnknownBlock, s = n == null ? void 0 : n.toolAttributes, c = n == null ? void 0 : n.blockIds, l = n == null ? void 0 : n.transformUrl;
|
|
692
|
+
return u(() => r(t, null, ...je(A(e, {
|
|
632
693
|
schema: i,
|
|
633
694
|
renderers: a,
|
|
634
|
-
onUnknownBlock: o
|
|
695
|
+
onUnknownBlock: o,
|
|
696
|
+
toolAttributes: s,
|
|
697
|
+
blockIds: c,
|
|
698
|
+
transformUrl: l
|
|
635
699
|
}))), [
|
|
636
700
|
e,
|
|
637
701
|
i,
|
|
638
702
|
a,
|
|
639
|
-
o
|
|
703
|
+
o,
|
|
704
|
+
s,
|
|
705
|
+
c,
|
|
706
|
+
l
|
|
640
707
|
]);
|
|
641
|
-
},
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
708
|
+
}, Ne = [
|
|
709
|
+
"data",
|
|
710
|
+
"schema",
|
|
711
|
+
"renderers",
|
|
712
|
+
"onUnknownBlock",
|
|
713
|
+
"toolAttributes",
|
|
714
|
+
"blockIds",
|
|
715
|
+
"transformUrl"
|
|
716
|
+
], Pe = (e) => {
|
|
717
|
+
let { data: t, schema: n, renderers: r, onUnknownBlock: i, toolAttributes: a, blockIds: o, transformUrl: s } = e, c = $(e, Ne), l = Me(t, {
|
|
718
|
+
schema: n,
|
|
719
|
+
renderers: r,
|
|
720
|
+
onUnknownBlock: i,
|
|
721
|
+
toolAttributes: a,
|
|
722
|
+
blockIds: o,
|
|
723
|
+
transformUrl: s
|
|
724
|
+
});
|
|
725
|
+
return /* @__PURE__ */ T("div", B(B({}, c), {}, { children: l }));
|
|
726
|
+
}, Fe = ["icon", "title"], Ie = ["commit", "readOnly"], Le = [W, G];
|
|
727
|
+
function Re(e) {
|
|
650
728
|
var t;
|
|
651
729
|
let n = (e) => {
|
|
652
730
|
if (typeof document > "u") return null;
|
|
653
|
-
let t = document.createElement("div"), n =
|
|
654
|
-
|
|
731
|
+
let t = document.createElement("div"), n = j(t);
|
|
732
|
+
k(() => {
|
|
655
733
|
n.render(e);
|
|
656
734
|
});
|
|
657
735
|
let r = t.innerHTML;
|
|
658
736
|
return n.unmount(), r === "" ? null : r;
|
|
659
|
-
}, r = () => {
|
|
660
|
-
let
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
737
|
+
}, r = (e) => {
|
|
738
|
+
let { icon: t, title: r } = e, i = B({}, $(e, Fe));
|
|
739
|
+
if (typeof r == "string" && (i.title = r), !a(t)) return t !== void 0 && (i.icon = t), {
|
|
740
|
+
entry: i,
|
|
741
|
+
deferred: !1
|
|
664
742
|
};
|
|
665
|
-
|
|
743
|
+
let o = n(t);
|
|
744
|
+
return o === null ? (i.icon = t, {
|
|
745
|
+
entry: i,
|
|
746
|
+
deferred: !0
|
|
747
|
+
}) : (i.icon = o, {
|
|
748
|
+
entry: i,
|
|
749
|
+
deferred: !1
|
|
750
|
+
});
|
|
751
|
+
}, i = () => {
|
|
752
|
+
if (e.toolbox === void 0) return {
|
|
666
753
|
value: void 0,
|
|
667
|
-
complete:
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
|
|
754
|
+
complete: !0
|
|
755
|
+
};
|
|
756
|
+
let t = (Array.isArray(e.toolbox) ? e.toolbox : [e.toolbox]).map((e) => r(e)), n = t.every((e) => !e.deferred), i = t.map((e) => e.entry);
|
|
757
|
+
return {
|
|
758
|
+
value: Array.isArray(e.toolbox) ? i : i[0],
|
|
759
|
+
complete: n
|
|
671
760
|
};
|
|
672
|
-
},
|
|
761
|
+
}, o = (t, n) => {
|
|
762
|
+
if (e.toolbox === void 0) return;
|
|
763
|
+
let i = Array.isArray(e.toolbox) ? e.toolbox : [e.toolbox];
|
|
764
|
+
if (i.some((e) => a(e.title))) return i.map((e, i) => {
|
|
765
|
+
let { entry: o } = r(e);
|
|
766
|
+
if (!a(e.title)) return o;
|
|
767
|
+
let s = document.createElement("span");
|
|
768
|
+
s.setAttribute("data-blok-mutation-free", "true");
|
|
769
|
+
let c = e.title, l = () => /* @__PURE__ */ T(w, { children: c });
|
|
770
|
+
return l.displayName = `BlokToolboxTitle(${n})`, t.register(`__blok-toolbox-title__:${n}:${i}`, {
|
|
771
|
+
hostEl: s,
|
|
772
|
+
component: l,
|
|
773
|
+
props: {},
|
|
774
|
+
toolName: n
|
|
775
|
+
}), B(B({}, o), {}, { titleEl: s });
|
|
776
|
+
});
|
|
777
|
+
}, s = {
|
|
673
778
|
resolved: !1,
|
|
674
779
|
value: void 0
|
|
675
|
-
},
|
|
676
|
-
if (
|
|
677
|
-
let { value: e, complete: t } =
|
|
678
|
-
return t && (
|
|
679
|
-
},
|
|
780
|
+
}, l = () => {
|
|
781
|
+
if (s.resolved) return s.value;
|
|
782
|
+
let { value: e, complete: t } = i();
|
|
783
|
+
return t && (s.value = e, s.resolved = !0), e;
|
|
784
|
+
}, u = e.viewComponent === void 0 ? e.component : (t) => {
|
|
680
785
|
let n = e.viewComponent;
|
|
681
786
|
if (t.readOnly && n !== void 0) {
|
|
682
787
|
let { commit: e, readOnly: r } = t;
|
|
683
|
-
return /* @__PURE__ */ T(n,
|
|
788
|
+
return /* @__PURE__ */ T(n, B({}, $(t, Ie)));
|
|
684
789
|
}
|
|
685
790
|
let r = e.component;
|
|
686
|
-
return /* @__PURE__ */ T(r,
|
|
791
|
+
return /* @__PURE__ */ T(r, B({}, t));
|
|
687
792
|
};
|
|
688
793
|
return t = class {
|
|
689
794
|
static get toolbox() {
|
|
690
|
-
return
|
|
795
|
+
return l();
|
|
796
|
+
}
|
|
797
|
+
static __buildPortalToolbox(e, t) {
|
|
798
|
+
return o(e, t);
|
|
691
799
|
}
|
|
692
800
|
static get isReadOnlySupported() {
|
|
693
801
|
return !0;
|
|
@@ -696,15 +804,15 @@ function je(e) {
|
|
|
696
804
|
var n, r;
|
|
697
805
|
this.hostEl = null, this.pendingDispatch = !1, this.commit = (t) => {
|
|
698
806
|
var n;
|
|
699
|
-
let r = x(e.propSchema,
|
|
807
|
+
let r = x(e.propSchema, B(B({}, this.mirror), t));
|
|
700
808
|
y(r, this.mirror) || (this.mirror = r, this.lastRendered = r, (n = this.registry) == null || n.setProps(this.blockApi.id, { data: r }), this.flushDispatch());
|
|
701
809
|
}, this.blockApi = t.block;
|
|
702
810
|
let i = (n = t.config) == null ? {} : n;
|
|
703
|
-
this.registry = i[
|
|
704
|
-
let a = i[
|
|
811
|
+
this.registry = i[W];
|
|
812
|
+
let a = i[G];
|
|
705
813
|
this.toolName = typeof a == "string" ? a : void 0;
|
|
706
814
|
let o = {};
|
|
707
|
-
for (let [e, t] of Object.entries(i))
|
|
815
|
+
for (let [e, t] of Object.entries(i)) Le.includes(e) || (o[e] = t);
|
|
708
816
|
this.toolConfig = Object.freeze(o);
|
|
709
817
|
let s = t.api;
|
|
710
818
|
this.pointerDrag = () => {
|
|
@@ -727,7 +835,7 @@ function je(e) {
|
|
|
727
835
|
let t = document.createElement("div");
|
|
728
836
|
return t.setAttribute("data-blok-mutation-free", "true"), this.hostEl = t, (e = this.registry) == null || e.register(this.blockApi.id, {
|
|
729
837
|
hostEl: t,
|
|
730
|
-
component:
|
|
838
|
+
component: u,
|
|
731
839
|
props: this.buildProps(),
|
|
732
840
|
toolName: this.toolName
|
|
733
841
|
}), t;
|
|
@@ -771,7 +879,7 @@ function je(e) {
|
|
|
771
879
|
}
|
|
772
880
|
pushProps(e) {
|
|
773
881
|
let t = this.registry;
|
|
774
|
-
t !== void 0 &&
|
|
882
|
+
t !== void 0 && k(() => {
|
|
775
883
|
t.setProps(this.blockApi.id, e);
|
|
776
884
|
});
|
|
777
885
|
}
|
|
@@ -795,24 +903,31 @@ function je(e) {
|
|
|
795
903
|
}
|
|
796
904
|
//#endregion
|
|
797
905
|
//#region src/createReactInlineTool.tsx
|
|
798
|
-
var
|
|
799
|
-
function
|
|
800
|
-
let e = s(
|
|
906
|
+
var ze = [W, G], Be = (e) => `__blok-inline-tool__:${e}:${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`, Ve = n(null);
|
|
907
|
+
function He() {
|
|
908
|
+
let e = s(Ve);
|
|
801
909
|
if (e === null) throw Error("useInlineTool() must be called from a component rendered by createReactInlineTool");
|
|
802
910
|
return e;
|
|
803
911
|
}
|
|
804
|
-
function
|
|
912
|
+
function Ue(e) {
|
|
805
913
|
var t;
|
|
806
914
|
return t = class {
|
|
915
|
+
static get type() {
|
|
916
|
+
return e.type;
|
|
917
|
+
}
|
|
807
918
|
static get title() {
|
|
808
919
|
return e.title;
|
|
809
920
|
}
|
|
810
921
|
static get titleKey() {
|
|
811
|
-
|
|
922
|
+
var t;
|
|
923
|
+
return (t = e.titleKey) == null ? e.type : t;
|
|
812
924
|
}
|
|
813
925
|
static get shortcut() {
|
|
814
926
|
return e.shortcut;
|
|
815
927
|
}
|
|
928
|
+
static get mark() {
|
|
929
|
+
return e.mark;
|
|
930
|
+
}
|
|
816
931
|
static get sanitize() {
|
|
817
932
|
return e.sanitize === void 0 ? e.mark === void 0 ? void 0 : S(e.mark) : e.sanitize;
|
|
818
933
|
}
|
|
@@ -824,11 +939,11 @@ function Fe(e) {
|
|
|
824
939
|
var n;
|
|
825
940
|
this.active = !1, this.registered = !1;
|
|
826
941
|
let r = (n = t == null ? void 0 : t.config) == null ? {} : n;
|
|
827
|
-
this.api = t == null ? void 0 : t.api, this.registry = r[
|
|
828
|
-
let i = r[
|
|
829
|
-
this.toolName = typeof i == "string" ? i : e.type, this.portalKey =
|
|
942
|
+
this.api = t == null ? void 0 : t.api, this.registry = r[W];
|
|
943
|
+
let i = r[G];
|
|
944
|
+
this.toolName = typeof i == "string" ? i : e.type, this.portalKey = Be(this.toolName);
|
|
830
945
|
let a = {};
|
|
831
|
-
for (let [e, t] of Object.entries(r))
|
|
946
|
+
for (let [e, t] of Object.entries(r)) ze.includes(e) || (a[e] = t);
|
|
832
947
|
this.toolConfig = Object.freeze(a), this.portalComponent = this.createPortalComponent();
|
|
833
948
|
}
|
|
834
949
|
render() {
|
|
@@ -891,7 +1006,7 @@ function Fe(e) {
|
|
|
891
1006
|
api: t,
|
|
892
1007
|
mark: i
|
|
893
1008
|
}), [e.active, e.config]);
|
|
894
|
-
return /* @__PURE__ */ T(
|
|
1009
|
+
return /* @__PURE__ */ T(Ve.Provider, {
|
|
895
1010
|
value: n,
|
|
896
1011
|
children: /* @__PURE__ */ T(r, {
|
|
897
1012
|
active: e.active,
|
|
@@ -904,4 +1019,4 @@ function Fe(e) {
|
|
|
904
1019
|
}, t.__isBlokReactInlineTool = !0, t.isInline = !0, t;
|
|
905
1020
|
}
|
|
906
1021
|
//#endregion
|
|
907
|
-
export {
|
|
1022
|
+
export { W as BLOK_PORTAL_REGISTRY_CONFIG_KEY, G as BLOK_TOOL_NAME_CONFIG_KEY, fe as BlockPortalHost, _e as BlokContent, xe as BlokEditor, H as BlokProvider, Pe as BlokView, K as createBlockPortalRegistry, Re as createReactBlock, Ue as createReactInlineTool, E as getDirection, D as normalizeLocale, we as useBlocks, Z as useBlok, U as useBlokDefaults, Se as useBlokHandle, Te as useBlokReady, Me as useBlokView, He as useInlineTool };
|