@bloklabs/react 1.7.0 → 1.9.0

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/index.mjs CHANGED
@@ -1,54 +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, toRenderableData as te } from "@bloklabs/core/adapters";
4
- import { Fragment as w, jsx as T } from "react/jsx-runtime";
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";
3
+ import { BlockChildrenMounted as h, DATA_ATTR as g, EMPTY_API as _, EMPTY_OUTPUT_DATA as v, createBlocksApiForEditor as y, createEmittedEchoWindow as ee, deepEqual as b, deepEqual as x, equalsOutputData as te, fillDefaults as S, markSanitizerConfig as C, mountChildBlocks as w, normalizeReadOnlyConfig as ne, toRenderableData as re } from "@bloklabs/core/adapters";
4
+ import { Fragment as T, jsx as E } from "react/jsx-runtime";
5
+ import { getDirection as D, normalizeLocale as O } from "@bloklabs/core/locales";
6
+ import { createPortal as k, flushSync as A } from "react-dom";
7
+ import { blocksToViewNodes as j } from "@bloklabs/core/view";
8
+ import { createRoot as M } from "react-dom/client";
9
9
  //#region src/holder-map.ts
10
- var M = /* @__PURE__ */ new WeakMap();
11
- function ne(e, t) {
12
- M.set(e, t);
13
- }
14
- function N(e) {
15
- return M.get(e);
10
+ var N = /* @__PURE__ */ new WeakMap();
11
+ function ie(e, t) {
12
+ N.set(e, t);
16
13
  }
17
14
  function P(e) {
18
- M.delete(e);
15
+ return N.get(e);
16
+ }
17
+ function F(e) {
18
+ N.delete(e);
19
19
  }
20
20
  //#endregion
21
21
  //#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
22
- function F(e) {
22
+ function I(e) {
23
23
  "@babel/helpers - typeof";
24
- return F = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
24
+ return I = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
25
25
  return typeof e;
26
26
  } : function(e) {
27
27
  return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
28
- }, F(e);
28
+ }, I(e);
29
29
  }
30
30
  //#endregion
31
31
  //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
32
- function I(e, t) {
33
- if (F(e) != "object" || !e) return e;
32
+ function L(e, t) {
33
+ if (I(e) != "object" || !e) return e;
34
34
  var n = e[Symbol.toPrimitive];
35
35
  if (n !== void 0) {
36
36
  var r = n.call(e, t || "default");
37
- if (F(r) != "object") return r;
37
+ if (I(r) != "object") return r;
38
38
  throw TypeError("@@toPrimitive must return a primitive value.");
39
39
  }
40
40
  return (t === "string" ? String : Number)(e);
41
41
  }
42
42
  //#endregion
43
43
  //#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
44
- function L(e) {
45
- var t = I(e, "string");
46
- return F(t) == "symbol" ? t : t + "";
44
+ function R(e) {
45
+ var t = L(e, "string");
46
+ return I(t) == "symbol" ? t : t + "";
47
47
  }
48
48
  //#endregion
49
49
  //#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
50
- function R(e, t, n) {
51
- return (t = L(t)) in e ? Object.defineProperty(e, t, {
50
+ function z(e, t, n) {
51
+ return (t = R(t)) in e ? Object.defineProperty(e, t, {
52
52
  value: n,
53
53
  enumerable: !0,
54
54
  configurable: !0,
@@ -57,7 +57,7 @@ function R(e, t, n) {
57
57
  }
58
58
  //#endregion
59
59
  //#region \0@oxc-project+runtime@0.139.0/helpers/esm/objectSpread2.js
60
- function z(e, t) {
60
+ function B(e, t) {
61
61
  var n = Object.keys(e);
62
62
  if (Object.getOwnPropertySymbols) {
63
63
  var r = Object.getOwnPropertySymbols(e);
@@ -67,12 +67,12 @@ function z(e, t) {
67
67
  }
68
68
  return n;
69
69
  }
70
- function B(e) {
70
+ function V(e) {
71
71
  for (var t = 1; t < arguments.length; t++) {
72
72
  var n = arguments[t] == null ? {} : arguments[t];
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) {
73
+ t % 2 ? B(Object(n), !0).forEach(function(t) {
74
+ z(e, t, n[t]);
75
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : B(Object(n)).forEach(function(t) {
76
76
  Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
77
77
  });
78
78
  }
@@ -80,53 +80,54 @@ function B(e) {
80
80
  }
81
81
  //#endregion
82
82
  //#region src/provide-blok.tsx
83
- var V = n({});
84
- function H({ defaults: e, children: t }) {
85
- return /* @__PURE__ */ T(V.Provider, {
83
+ var H = n({});
84
+ function U({ defaults: e, children: t }) {
85
+ return /* @__PURE__ */ E(H.Provider, {
86
86
  value: e,
87
87
  children: t
88
88
  });
89
89
  }
90
- function U() {
91
- return s(V);
90
+ function W() {
91
+ return s(H);
92
92
  }
93
- function re(e, t) {
93
+ function ae(e, t) {
94
94
  if (Object.keys(e).length === 0) return t;
95
- let n = B({}, e);
95
+ let n = V({}, e);
96
96
  for (let e of Object.keys(t)) {
97
97
  let r = t[e];
98
98
  r !== void 0 && (n[e] = r);
99
99
  }
100
- return (e.tools !== void 0 || t.tools !== void 0) && (n.tools = B(B({}, e.tools), t.tools)), n;
100
+ return (e.tools !== void 0 || t.tools !== void 0) && (n.tools = V(V({}, e.tools), t.tools)), n;
101
101
  }
102
102
  //#endregion
103
103
  //#region src/block-portal-registry.ts
104
- var W = "__blokPortalRegistry", G = "__blokToolName", K = () => {
104
+ var G = "__blokPortalRegistry", K = "__blokToolName", oe = () => {
105
105
  let e = { snapshot: /* @__PURE__ */ new Map() }, t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map(), r = (n) => {
106
106
  e.snapshot = n, t.forEach((e) => e());
107
107
  };
108
108
  return {
109
109
  register(t, i) {
110
110
  let a = new Map(e.snapshot), o = i.toolName === void 0 ? void 0 : n.get(i.toolName);
111
- a.set(t, o === void 0 ? i : B(B({}, i), {}, { props: B(B({}, i.props), {}, { config: o }) })), r(a);
111
+ a.set(t, o === void 0 ? i : V(V({}, i), {}, { props: V(V({}, i.props), {}, { config: o }) })), r(a);
112
112
  },
113
- unregister(t) {
114
- if (!e.snapshot.has(t)) return;
115
- let n = new Map(e.snapshot);
116
- n.delete(t), r(n);
113
+ unregister(t, n) {
114
+ let i = e.snapshot.get(t);
115
+ if (i === void 0 || n !== void 0 && i.hostEl !== n) return;
116
+ let a = new Map(e.snapshot);
117
+ a.delete(t), r(a);
117
118
  },
118
119
  setProps(t, n) {
119
120
  let i = e.snapshot.get(t);
120
121
  if (i === void 0) return;
121
122
  let a = new Map(e.snapshot);
122
- a.set(t, B(B({}, i), {}, { props: B(B({}, i.props), n) })), r(a);
123
+ a.set(t, V(V({}, i), {}, { props: V(V({}, i.props), n) })), r(a);
123
124
  },
124
125
  setToolConfig(t, i) {
125
126
  n.set(t, i);
126
127
  let a = [...e.snapshot].filter(([, e]) => e.toolName === t);
127
128
  if (a.length === 0) return;
128
129
  let o = new Map(e.snapshot);
129
- for (let [e, t] of a) o.set(e, B(B({}, t), {}, { props: B(B({}, t.props), {}, { config: i }) }));
130
+ for (let [e, t] of a) o.set(e, V(V({}, t), {}, { props: V(V({}, t.props), {}, { config: i }) }));
130
131
  r(o);
131
132
  },
132
133
  subscribe(e) {
@@ -139,44 +140,56 @@ var W = "__blokPortalRegistry", G = "__blokToolName", K = () => {
139
140
  }
140
141
  };
141
142
  }, q = /* @__PURE__ */ new WeakMap();
142
- function ie(e, t) {
143
+ function se(e, t) {
143
144
  q.set(e, t);
144
145
  }
145
- function ae(e) {
146
+ function ce(e) {
146
147
  return q.get(e);
147
148
  }
148
149
  function J(e) {
149
150
  q.delete(e);
150
151
  }
151
152
  //#endregion
153
+ //#region src/content-baseline-map.ts
154
+ var Y = /* @__PURE__ */ new WeakMap();
155
+ function le(e, t) {
156
+ Y.set(e, t);
157
+ }
158
+ function ue(e) {
159
+ return Y.get(e);
160
+ }
161
+ function X(e) {
162
+ Y.delete(e);
163
+ }
164
+ //#endregion
152
165
  //#region src/live-tool-config.ts
153
- var Y = (e) => {
166
+ var Z = (e) => {
154
167
  if (typeof e != "object" || !e) return !1;
155
168
  let t = Object.getPrototypeOf(e);
156
169
  return t === Object.prototype || t === null;
157
- }, oe = (e, t) => t.reduce((e, t) => {
170
+ }, de = (e, t) => t.reduce((e, t) => {
158
171
  if (Array.isArray(e)) return typeof t == "number" ? e[t] : void 0;
159
- if (Y(e)) return e[t];
160
- }, e), se = (e, t) => {
172
+ if (Z(e)) return e[t];
173
+ }, e), fe = (e, t) => {
161
174
  let n = (e, t) => {
162
175
  if (typeof e == "function") return typeof t == "function" ? t : e;
163
176
  if (Array.isArray(e)) {
164
177
  let r = Array.isArray(t) ? t : [];
165
178
  return e.map((e, t) => n(e, r[t]));
166
179
  }
167
- if (Y(e)) {
168
- let r = Y(t) ? t : {}, i = {};
180
+ if (Z(e)) {
181
+ let r = Z(t) ? t : {}, i = {};
169
182
  for (let [t, a] of Object.entries(e)) i[t] = n(a, r[t]);
170
183
  return i;
171
184
  }
172
185
  return e;
173
186
  }, r = n(t, e);
174
- return Y(r) ? r : {};
175
- }, ce = (e, t) => {
176
- if (!Y(e)) return e;
187
+ return Z(r) ? r : {};
188
+ }, pe = (e, t) => {
189
+ if (!Z(e)) return e;
177
190
  let n = {};
178
191
  for (let [r, i] of Object.entries(e)) {
179
- if (!Y(i) || !Y(i.config)) {
192
+ if (!Z(i) || !Z(i.config)) {
180
193
  n[r] = i;
181
194
  continue;
182
195
  }
@@ -184,12 +197,12 @@ var Y = (e) => {
184
197
  if (typeof n == "function") {
185
198
  let e = n;
186
199
  return function(...n) {
187
- let a = t(), o = Y(a) ? a[r] : void 0, s = oe(Y(o) ? o.config : void 0, i);
200
+ let a = t(), o = Z(a) ? a[r] : void 0, s = de(Z(o) ? o.config : void 0, i);
188
201
  return Reflect.apply(typeof s == "function" ? s : e, this, n);
189
202
  };
190
203
  }
191
204
  if (Array.isArray(n)) return e.has(n) ? n : (e.add(n), n.map((e, t) => a(e, [...i, t])));
192
- if (Y(n)) {
205
+ if (Z(n)) {
193
206
  if (e.has(n)) return n;
194
207
  e.add(n);
195
208
  let t = {};
@@ -198,37 +211,37 @@ var Y = (e) => {
198
211
  }
199
212
  return n;
200
213
  };
201
- n[r] = B(B({}, i), {}, { config: a(i.config, []) });
214
+ n[r] = V(V({}, i), {}, { config: a(i.config, []) });
202
215
  }
203
216
  return n;
204
- }, X = (e) => {
217
+ }, me = (e) => {
205
218
  let t = typeof e == "function" ? e : e == null ? void 0 : e.class;
206
219
  return typeof t == "function" && t.__isBlokReactBlock === !0;
207
- }, le = (e) => {
220
+ }, he = (e) => {
208
221
  let t = typeof e == "function" ? e : e == null ? void 0 : e.class;
209
222
  return typeof t == "function" && t.__isBlokReactInlineTool === !0;
210
- }, ue = (e, t) => {
223
+ }, ge = (e, t) => {
211
224
  if (typeof e != "object" || !e) return e;
212
225
  let n = {};
213
226
  for (let [i, a] of Object.entries(e)) {
214
227
  var r;
215
- if (!X(a) && !le(a)) {
228
+ if (!me(a) && !he(a)) {
216
229
  n[i] = a;
217
230
  continue;
218
231
  }
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
232
+ let e = typeof a == "function" ? { class: a } : V({}, a);
233
+ e.config = V(V({}, (r = e.config) == null ? {} : r), {}, {
234
+ [G]: t,
235
+ [K]: i
223
236
  });
224
237
  let o = e.class.__buildPortalToolbox, s = typeof o == "function" && e.toolbox === void 0 ? o(t, i) : void 0;
225
238
  s !== void 0 && (e.toolbox = s), n[i] = e;
226
239
  }
227
240
  return n;
228
241
  };
229
- function Z(e, t) {
242
+ function _e(e, t) {
230
243
  var n, r;
231
- let i = re(s(V), e), [a, o] = f(null), l = d(i);
244
+ let i = ae(s(H), e), [a, o] = f(null), l = d(i);
232
245
  l.current = i;
233
246
  let p = d({
234
247
  editor: null,
@@ -237,16 +250,23 @@ function Z(e, t) {
237
250
  isDestroyed: !1,
238
251
  isEditorReady: !1,
239
252
  depsToken: null
240
- }), h = u(() => ({}), t == null ? [] : t), g = d(i.data), _ = d(v()), y = d(null), x = d(i.data), S = d(Promise.resolve()), C = d(void 0), w = d(null), T = d(void 0), E = d(/* @__PURE__ */ new Map()), D = d(/* @__PURE__ */ new Map());
253
+ }), h = u(() => ({}), t == null ? [] : t), g = d(i.data), _ = d(ee()), v = d(null), y = d(i.data), b = d(Promise.resolve()), S = d(void 0), C = d(null), w = d(void 0), T = d(/* @__PURE__ */ new Map()), E = d(/* @__PURE__ */ new Map()), D = d(null), O = d({
254
+ onChange: !1,
255
+ onSave: !1,
256
+ onEnter: !1,
257
+ onSubmit: !1,
258
+ onBeforeRender: !1,
259
+ onAfterRender: !1
260
+ });
241
261
  c(() => {
242
262
  var e;
243
263
  if (typeof window > "u") return;
244
264
  let t = p.current;
245
265
  if (t.destroyTimeout !== null && (clearTimeout(t.destroyTimeout), t.destroyTimeout = null), t.editor !== null && !t.isDestroyed && t.depsToken === h) return t.isEditorReady && o(t.editor), () => {
246
- Q(t, o);
266
+ ve(t, o);
247
267
  };
248
268
  if (t.editor !== null && !t.isDestroyed) {
249
- P(t.editor), J(t.editor);
269
+ F(t.editor), J(t.editor), X(t.editor);
250
270
  try {
251
271
  t.editor.destroy();
252
272
  } catch (e) {}
@@ -254,63 +274,79 @@ function Z(e, t) {
254
274
  }
255
275
  let n = document.createElement("div");
256
276
  t.holder = n, t.isDestroyed = !1, t.isEditorReady = !1, t.depsToken = h;
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);
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]));
259
- let c = B(B(B({}, r), s === void 0 ? {} : { tools: s }), {}, {
260
- holder: n,
261
- onReady: (...e) => {
262
- var t, n;
263
- (t = (n = l.current).onReady) == null || t.call(n, ...e);
264
- },
277
+ let r = l.current, i = oe(), a = r.tools === void 0 ? void 0 : pe(r.tools, () => l.current.tools), s = a === void 0 ? void 0 : ge(a, i);
278
+ C.current = i, w.current = a, T.current = /* @__PURE__ */ new Map(), E.current = new Map(Object.entries((e = r.tools) == null ? {} : e).map(([e, t]) => [e, typeof t == "object" && t ? t.toolbox : void 0]));
279
+ let c = {
265
280
  onChange: (...e) => {
266
281
  var t, n;
267
282
  (t = (n = l.current).onChange) == null || t.call(n, ...e);
268
283
  },
284
+ onSave: (...e) => {
285
+ var t, n;
286
+ g.current = e[0], _.current.record(e[0]), (t = (n = l.current).onSave) == null || t.call(n, ...e);
287
+ },
269
288
  onEnter: (...e) => {
270
289
  var t, n;
271
290
  return (t = (n = l.current).onEnter) == null ? void 0 : t.call(n, ...e);
291
+ },
292
+ onSubmit: (...e) => {
293
+ var t, n;
294
+ (t = (n = l.current).onSubmit) == null || t.call(n, ...e);
295
+ },
296
+ onBeforeRender: (...e) => {
297
+ var t, n, r;
298
+ return (t = (n = (r = l.current).onBeforeRender) == null ? void 0 : n.call(r, ...e)) == null ? e[0] : t;
299
+ },
300
+ onAfterRender: (...e) => {
301
+ var t, n;
302
+ (t = (n = l.current).onAfterRender) == null || t.call(n, ...e);
272
303
  }
273
- });
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) => {
278
- var t, n;
279
- g.current = e[0], _.current.record(e[0]), (t = (n = l.current).onSave) == null || t.call(n, ...e);
280
- }), r.onBeforeRender && (c.onBeforeRender = (...e) => {
281
- var t, n, r;
282
- return (t = (n = (r = l.current).onBeforeRender) == null ? void 0 : n.call(r, ...e)) == null ? e[0] : t;
283
- }), r.onAfterRender && (c.onAfterRender = (...e) => {
284
- var t, n;
285
- (t = (n = l.current).onAfterRender) == null || t.call(n, ...e);
286
- });
287
- let u = new m(c);
288
- return t.editor = u, x.current = r.data, ne(u, n), ie(u, i), u.isReady.then(() => {
289
- t.editor === u && !t.isDestroyed && (t.isEditorReady = !0, o(u));
304
+ };
305
+ D.current = c;
306
+ let u = {
307
+ onChange: r.onChange !== void 0,
308
+ onSave: r.onSave !== void 0,
309
+ onEnter: r.onEnter !== void 0,
310
+ onSubmit: r.onSubmit !== void 0,
311
+ onBeforeRender: r.onBeforeRender !== void 0,
312
+ onAfterRender: r.onAfterRender !== void 0
313
+ };
314
+ O.current = u;
315
+ let d = new m(V(V(V(V(V(V(V(V({}, r), s === void 0 ? {} : { tools: s }), {}, {
316
+ holder: n,
317
+ onReady: (...e) => {
318
+ var t, n;
319
+ (t = (n = l.current).onReady) == null || t.call(n, ...e);
320
+ }
321
+ }, u.onChange ? { onChange: c.onChange } : {}), u.onSave ? { onSave: c.onSave } : {}), u.onEnter ? { onEnter: c.onEnter } : {}), u.onSubmit ? { onSubmit: c.onSubmit } : {}), u.onBeforeRender ? { onBeforeRender: c.onBeforeRender } : {}), u.onAfterRender ? { onAfterRender: c.onAfterRender } : {}));
322
+ return t.editor = d, y.current = r.data, ie(d, n), se(d, i), le(d, { markRendered: (e) => {
323
+ _.current.clear(), g.current = e, S.current = void 0;
324
+ } }), d.isReady.then(() => {
325
+ t.editor === d && !t.isDestroyed && (t.isEditorReady = !0, o(d));
290
326
  }).catch(() => {
291
- if (t.editor === u && !t.isDestroyed) {
292
- P(u), J(u);
327
+ if (t.editor === d && !t.isDestroyed) {
328
+ F(d), J(d), X(d);
293
329
  try {
294
- u.destroy();
330
+ d.destroy();
295
331
  } catch (e) {}
296
332
  t.editor = null, t.holder = null, t.isDestroyed = !0, t.isEditorReady = !1, o(null);
297
333
  }
298
334
  }), () => {
299
- Q(t, o);
335
+ ve(t, o);
300
336
  };
301
337
  }, [h]), c(() => {
302
- let e = w.current, t = p.current;
338
+ let e = C.current, t = p.current;
303
339
  if (e === null || t.editor === null || t.isDestroyed) return;
304
340
  let n = l.current.tools;
305
341
  if (typeof n != "object" || !n) return;
306
- let r = T.current;
342
+ let r = w.current;
307
343
  for (let [t, a] of Object.entries(n)) {
308
344
  var i;
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);
311
- if (c !== void 0 && b(s, c)) continue;
345
+ if (!me(a)) continue;
346
+ let n = typeof a == "function" || (i = a.config) == null ? {} : i, o = r == null ? void 0 : r[t], s = fe(typeof o == "object" && o ? o.config : void 0, n), c = T.current.get(t);
347
+ if (c !== void 0 && x(s, c)) continue;
312
348
  let l = Object.freeze(s);
313
- E.current.set(t, l), e.setToolConfig(t, l);
349
+ T.current.set(t, l), e.setToolConfig(t, l);
314
350
  }
315
351
  }), c(() => {
316
352
  let e = p.current;
@@ -318,76 +354,96 @@ function Z(e, t) {
318
354
  let t = l.current.tools;
319
355
  if (!(typeof t != "object" || !t)) for (let [r, i] of Object.entries(t)) {
320
356
  var n;
321
- if (!D.current.has(r)) continue;
357
+ if (!E.current.has(r)) continue;
322
358
  let t = typeof i == "object" && i ? i.toolbox : void 0;
323
- b(t, D.current.get(r)) || (D.current.set(r, t), (n = e.editor.tools) == null || n.update(r, { toolbox: t }));
359
+ x(t, E.current.get(r)) || (E.current.set(r, t), (n = e.editor.tools) == null || n.update(r, { toolbox: t }));
324
360
  }
361
+ }), c(() => {
362
+ let e = p.current, t = D.current;
363
+ if (e.editor === null || e.isDestroyed || !e.isEditorReady || t === null) return;
364
+ let n = l.current, r = O.current, i = {}, a = { value: !1 }, o = (e, i) => {
365
+ let o = n[e] !== void 0;
366
+ o !== r[e] && (r[e] = o, a.value = !0, i(o ? t[e] : void 0));
367
+ };
368
+ o("onChange", (e) => {
369
+ i.onChange = e;
370
+ }), o("onSave", (e) => {
371
+ i.onSave = e;
372
+ }), o("onEnter", (e) => {
373
+ i.onEnter = e;
374
+ }), o("onSubmit", (e) => {
375
+ i.onSubmit = e;
376
+ }), o("onBeforeRender", (e) => {
377
+ i.onBeforeRender = e;
378
+ }), o("onAfterRender", (e) => {
379
+ i.onAfterRender = e;
380
+ }), a.value && e.editor.handlers.set(i);
325
381
  });
326
- let O = typeof i.readOnly == "object" && i.readOnly !== null, { enabled: k, hideControls: A } = ee(i.readOnly);
382
+ let k = typeof i.readOnly == "object" && i.readOnly !== null, { enabled: A, hideControls: j } = ne(i.readOnly);
327
383
  c(() => {
328
- a !== null && (O ? a.readOnly.set(k, { hideControls: A }) : a.readOnly.set(k));
384
+ a !== null && (k ? a.readOnly.set(A, { hideControls: j }) : a.readOnly.set(A));
329
385
  }, [
330
386
  a,
331
- k,
332
387
  A,
333
- O
388
+ j,
389
+ k
334
390
  ]);
335
- let { hideToolbar: j } = i;
336
- c(() => {
337
- a === null || j === void 0 || a.toolbar.setHidden(j);
338
- }, [a, j]);
339
- let { inlineToolbar: M } = i;
391
+ let { hideToolbar: M } = i;
340
392
  c(() => {
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;
393
+ a === null || M === void 0 || a.toolbar.setHidden(M);
394
+ }, [a, M]);
395
+ let { inlineToolbar: N } = i;
344
396
  c(() => {
345
- a === null || !N || a.focus();
346
- }, [a, N]);
347
- let { theme: F } = i;
397
+ a === null || N === void 0 || a.tools.setInlineToolbar(N);
398
+ }, [a, N === void 0 ? void 0 : JSON.stringify(N)]);
399
+ let { autofocus: P } = i;
348
400
  c(() => {
349
- a === null || F === void 0 || a.theme.set(F);
350
- }, [a, F]);
351
- let { width: I } = i;
401
+ a === null || !P || a.focus();
402
+ }, [a, P]);
403
+ let { theme: I } = i;
352
404
  c(() => {
353
- a === null || I === void 0 || a.width.set(I);
405
+ a === null || I === void 0 || a.theme.set(I);
354
406
  }, [a, I]);
355
- let L = (n = i.style) == null ? void 0 : n.tokens, R = d((r = i.style) == null ? void 0 : r.tokens);
407
+ let { width: L } = i;
356
408
  c(() => {
357
- a === null || L === void 0 || b(L, R.current) || (R.current = L, a.tokens.set(L));
409
+ a === null || L === void 0 || a.width.set(L);
358
410
  }, [a, L]);
359
- let { i18n: z } = i, H = d(i.i18n);
411
+ let R = (n = i.style) == null ? void 0 : n.tokens, z = d((r = i.style) == null ? void 0 : r.tokens);
360
412
  c(() => {
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]);
366
- let { placeholder: U } = i;
413
+ a === null || R === void 0 || x(R, z.current) || (z.current = R, a.tokens.set(R));
414
+ }, [a, R]);
415
+ let { i18n: B } = i, U = d(i.i18n);
367
416
  c(() => {
368
- a === null || U === void 0 || a.placeholder.set(U);
369
- }, [a, U]);
370
- let { data: W } = i;
417
+ if (a === null || B === void 0 || x(B, U.current)) return;
418
+ U.current = B;
419
+ let { locale: e, messages: t, direction: n } = B;
420
+ a.i18n.update(V(V(V({}, e === void 0 ? {} : { locale: e }), t === void 0 ? {} : { messages: t }), n === void 0 ? {} : { direction: n }));
421
+ }, [a, B]);
422
+ let { placeholder: W } = i;
423
+ c(() => {
424
+ a === null || W === void 0 || a.placeholder.set(W);
425
+ }, [a, W]);
426
+ let { data: G } = i;
371
427
  return c(() => {
372
- if (a === null || W === void 0) return;
428
+ if (a === null || G === void 0) return;
373
429
  let e = p.current;
374
- if (!(e.editor !== a || e.isDestroyed)) {
375
- if (y.current !== a && (y.current = a, C.current = void 0, _.current.clear(), b(W, x.current))) {
376
- g.current = W;
377
- return;
378
- }
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;
381
- }, () => {}).then(() => {
382
- C.current === W && (C.current = void 0);
383
- }));
430
+ if (e.editor !== a || e.isDestroyed) return;
431
+ if (v.current !== a && (v.current = a, S.current = void 0, _.current.clear(), x(G, y.current))) {
432
+ g.current = G;
433
+ return;
384
434
  }
385
- }, [a, W]), a;
435
+ let t = g.current, n = S.current;
436
+ t !== void 0 && te(G, t) || n !== void 0 && te(G, n) || _.current.matches(G) || (_.current.clear(), S.current = G, b.current = b.current.catch(() => void 0).then(() => a.render(re(G))).then(() => {
437
+ g.current = G;
438
+ }, () => {}).then(() => {
439
+ S.current === G && (S.current = void 0);
440
+ }));
441
+ }, [a, G]), a;
386
442
  }
387
- function Q(e, t) {
443
+ function ve(e, t) {
388
444
  e.destroyTimeout = setTimeout(() => {
389
445
  if (e.editor !== null) {
390
- P(e.editor), J(e.editor);
446
+ F(e.editor), J(e.editor), X(e.editor);
391
447
  try {
392
448
  e.editor.destroy();
393
449
  } catch (e) {}
@@ -397,7 +453,7 @@ function Q(e, t) {
397
453
  }
398
454
  //#endregion
399
455
  //#region src/BlockPortalHost.tsx
400
- var de = class extends e {
456
+ var ye = class extends e {
401
457
  constructor(...e) {
402
458
  super(...e), this.state = { failed: !1 };
403
459
  }
@@ -409,16 +465,22 @@ var de = class extends e {
409
465
  return this.state.failed ? null : this.props.children;
410
466
  }
411
467
  };
412
- function fe({ registry: e }) {
468
+ function be({ registry: e }) {
413
469
  let t = p(e.subscribe, e.getSnapshot, e.getSnapshot);
414
- return /* @__PURE__ */ T(w, { children: Array.from(t.entries()).map(([e, t]) => {
470
+ return /* @__PURE__ */ E(T, { children: Array.from(t.entries()).map(([e, t]) => {
415
471
  let n = t.component;
416
- return O(/* @__PURE__ */ T(de, { children: /* @__PURE__ */ T(n, B({}, t.props)) }), t.hostEl, e);
472
+ return k(/* @__PURE__ */ E(ye, { children: /* @__PURE__ */ E(n, V({}, t.props)) }), t.hostEl, e);
417
473
  }) });
418
474
  }
419
475
  //#endregion
476
+ //#region src/blok-instance-context.ts
477
+ var xe = n(null);
478
+ function Se() {
479
+ return s(xe);
480
+ }
481
+ //#endregion
420
482
  //#region \0@oxc-project+runtime@0.139.0/helpers/esm/objectWithoutPropertiesLoose.js
421
- function pe(e, t) {
483
+ function Ce(e, t) {
422
484
  if (e == null) return {};
423
485
  var n = {};
424
486
  for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
@@ -429,9 +491,9 @@ function pe(e, t) {
429
491
  }
430
492
  //#endregion
431
493
  //#region \0@oxc-project+runtime@0.139.0/helpers/esm/objectWithoutProperties.js
432
- function $(e, t) {
494
+ function Q(e, t) {
433
495
  if (e == null) return {};
434
- var n, r, i = pe(e, t);
496
+ var n, r, i = Ce(e, t);
435
497
  if (Object.getOwnPropertySymbols) {
436
498
  var a = Object.getOwnPropertySymbols(e);
437
499
  for (r = 0; r < a.length; r++) n = a[r], t.includes(n) || {}.propertyIsEnumerable.call(e, n) && (i[n] = e[n]);
@@ -440,22 +502,22 @@ function $(e, t) {
440
502
  }
441
503
  //#endregion
442
504
  //#region src/BlokContent.tsx
443
- var me = ["editor"];
444
- function he(e) {
505
+ var we = ["editor"];
506
+ function Te(e) {
445
507
  var t, n;
446
508
  if (typeof window > "u") return;
447
509
  let r = window.location.hash.slice(1);
448
- r !== "" && ((t = (n = e.blocks).scrollToBlock) == null || t.call(n, ge(r)));
510
+ r !== "" && ((t = (n = e.blocks).scrollToBlock) == null || t.call(n, Ee(r)));
449
511
  }
450
- function ge(e) {
512
+ function Ee(e) {
451
513
  try {
452
514
  return decodeURIComponent(e);
453
515
  } catch (t) {
454
516
  return e;
455
517
  }
456
518
  }
457
- var _e = i(function(e, t) {
458
- let { editor: n } = e, r = $(e, me), i = d(null), a = (e) => {
519
+ var De = i(function(e, t) {
520
+ let { editor: n } = e, r = Q(e, we), i = d(null), a = (e) => {
459
521
  if (i.current = e, typeof t == "function") t(e);
460
522
  else if (t != null) {
461
523
  let n = t;
@@ -464,30 +526,33 @@ var _e = i(function(e, t) {
464
526
  };
465
527
  c(() => {
466
528
  if (n === null || i.current === null) return;
467
- let e = N(n);
468
- if (e !== void 0) return i.current.appendChild(e), he(n), () => {
529
+ let e = P(n);
530
+ if (e !== void 0) return i.current.appendChild(e), Te(n), () => {
469
531
  e.remove();
470
532
  };
471
533
  }, [n]);
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.migrations.uploader".split("."), ye = [
534
+ let o = n === null ? void 0 : ce(n);
535
+ return /* @__PURE__ */ E("div", V(V({ ref: a }, r), {}, { children: o === void 0 ? null : /* @__PURE__ */ E(xe.Provider, {
536
+ value: n,
537
+ children: /* @__PURE__ */ E(be, { registry: o })
538
+ }) }));
539
+ }), Oe = /* @__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.migrations.uploader.captureClicksBelowEditor".split("."), ke = [
475
540
  "deps",
476
541
  "onReady",
477
542
  "locale",
478
543
  "onBlocksRendered",
479
544
  "onBlockRendered"
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 = {};
545
+ ], Ae = new Set(Oe), je = i(function(e, t) {
546
+ let { deps: n, onReady: r, locale: i, onBlocksRendered: a, onBlockRendered: o } = e, s = Q(e, ke), u = {}, f = {};
482
547
  for (let e of Object.keys(s)) {
483
548
  let t = s[e];
484
- be.has(e) ? u[e] = t : f[e] = t;
549
+ Ae.has(e) ? u[e] = t : f[e] = t;
485
550
  }
486
551
  if (i !== void 0) {
487
552
  let e = u.i18n;
488
- u.i18n = B(B({}, e), {}, { locale: i });
553
+ u.i18n = V(V({}, e), {}, { locale: i });
489
554
  }
490
- let p = Z(u, n);
555
+ let p = _e(u, n);
491
556
  l(t, () => p, [p]);
492
557
  let m = d(r);
493
558
  m.current = r;
@@ -527,11 +592,11 @@ var _e = i(function(e, t) {
527
592
  p,
528
593
  v,
529
594
  y
530
- ]), /* @__PURE__ */ T(_e, B({ editor: p }, f));
595
+ ]), /* @__PURE__ */ E(De, V({ editor: p }, f));
531
596
  });
532
597
  //#endregion
533
598
  //#region src/useBlokHandle.ts
534
- function Se() {
599
+ function Me() {
535
600
  let e = d(null);
536
601
  return u(() => ({
537
602
  ref: (t) => {
@@ -548,13 +613,19 @@ function Se() {
548
613
  return (n = (r = e.current) == null ? void 0 : r.focus(t)) != null && n;
549
614
  },
550
615
  clear: () => {
551
- var t, n;
552
- return (t = (n = e.current) == null ? void 0 : n.clear()) == null ? Promise.resolve() : t;
616
+ let t = e.current;
617
+ return t === null ? Promise.resolve() : t.clear().then(() => {
618
+ var e;
619
+ (e = ue(t)) == null || e.markRendered(v);
620
+ });
553
621
  },
554
622
  save: () => e.current === null ? Promise.resolve(null) : e.current.save(),
555
623
  render: (t) => {
556
- var n, r;
557
- return (n = (r = e.current) == null ? void 0 : r.render(t)) == null ? Promise.resolve() : n;
624
+ let n = e.current;
625
+ return n === null ? Promise.resolve() : n.render(t).then(() => {
626
+ var e;
627
+ (e = ue(n)) == null || e.markRendered(t);
628
+ });
558
629
  },
559
630
  setReadOnly: (t) => {
560
631
  let n = e.current;
@@ -564,8 +635,8 @@ function Se() {
564
635
  }
565
636
  //#endregion
566
637
  //#region src/useBlocks.ts
567
- var Ce = "block changed";
568
- function we(e) {
638
+ var Ne = "block changed";
639
+ function Pe(e) {
569
640
  let t = d(0), n = d(e);
570
641
  n.current !== e && (n.current = e, t.current = 0);
571
642
  let r = o((n) => {
@@ -573,13 +644,13 @@ function we(e) {
573
644
  let r = () => {
574
645
  t.current += 1, n();
575
646
  };
576
- return e.on(Ce, r), () => e.off(Ce, r);
647
+ return e.on(Ne, r), () => e.off(Ne, r);
577
648
  }, [e]), i = o(() => t.current, []);
578
- return p(r, i, i), u(() => e === null ? g : _(e), [e]);
649
+ return p(r, i, i), u(() => e === null ? _ : y(e), [e]);
579
650
  }
580
651
  //#endregion
581
652
  //#region src/useBlokReady.ts
582
- function Te(e = {}) {
653
+ function Fe(e = {}) {
583
654
  let { within: t, settleOn: n } = e, [r, i] = f(!1);
584
655
  return c(() => {
585
656
  let e = () => {
@@ -595,7 +666,7 @@ function Te(e = {}) {
595
666
  }
596
667
  //#endregion
597
668
  //#region src/view-nodes-to-react.ts
598
- var Ee = /* @__PURE__ */ new Set([
669
+ var Ie = /* @__PURE__ */ new Set([
599
670
  "area",
600
671
  "base",
601
672
  "br",
@@ -610,7 +681,7 @@ var Ee = /* @__PURE__ */ new Set([
610
681
  "source",
611
682
  "track",
612
683
  "wbr"
613
- ]), De = /* @__PURE__ */ new Set([
684
+ ]), Le = /* @__PURE__ */ new Set([
614
685
  "disabled",
615
686
  "open",
616
687
  "controls",
@@ -626,7 +697,7 @@ var Ee = /* @__PURE__ */ new Set([
626
697
  "novalidate",
627
698
  "allowfullscreen",
628
699
  "itemscope"
629
- ]), Oe = {
700
+ ]), $ = {
630
701
  class: "className",
631
702
  for: "htmlFor",
632
703
  colspan: "colSpan",
@@ -648,7 +719,7 @@ var Ee = /* @__PURE__ */ new Set([
648
719
  minlength: "minLength",
649
720
  usemap: "useMap",
650
721
  itemscope: "itemScope"
651
- }, ke = (e) => {
722
+ }, Re = (e) => {
652
723
  let t = {};
653
724
  for (let n of e.split(";")) {
654
725
  let e = n.indexOf(":");
@@ -659,12 +730,12 @@ var Ee = /* @__PURE__ */ new Set([
659
730
  t[a] = i;
660
731
  }
661
732
  return t;
662
- }, Ae = (e, t) => {
733
+ }, ze = (e, t) => {
663
734
  let n = { key: t };
664
735
  for (let [t, a] of Object.entries(e)) {
665
736
  var r;
666
737
  if (t === "style") {
667
- n.style = ke(a);
738
+ n.style = Re(a);
668
739
  continue;
669
740
  }
670
741
  if (t === "checked") {
@@ -675,28 +746,29 @@ var Ee = /* @__PURE__ */ new Set([
675
746
  n.defaultValue = a;
676
747
  continue;
677
748
  }
678
- if (De.has(t)) {
749
+ if (Le.has(t)) {
679
750
  var i;
680
- n[(i = Oe[t]) == null ? t : i] = !0;
751
+ n[(i = $[t]) == null ? t : i] = !0;
681
752
  continue;
682
753
  }
683
- n[(r = Oe[t]) == null ? t : r] = a;
754
+ n[(r = $[t]) == null ? t : r] = a;
684
755
  }
685
756
  return n;
686
- }, je = (e) => e.map((e, t) => {
757
+ }, Be = (e) => e.map((e, t) => {
687
758
  if ("text" in e) return e.text;
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, d = n == null ? void 0 : n.classes;
692
- return u(() => r(t, null, ...je(A(e, {
759
+ let n = ze(e.attrs, t);
760
+ return Ie.has(e.tag) || e.children.length === 0 ? r(e.tag, n) : r(e.tag, n, ...Be(e.children));
761
+ }), Ve = (e, n) => {
762
+ 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, d = n == null ? void 0 : n.inlineRenderers, f = n == null ? void 0 : n.classes;
763
+ return u(() => r(t, null, ...Be(j(e, {
693
764
  schema: i,
694
765
  renderers: a,
695
766
  onUnknownBlock: o,
696
767
  toolAttributes: s,
697
768
  blockIds: c,
698
769
  transformUrl: l,
699
- classes: d
770
+ inlineRenderers: d,
771
+ classes: f
700
772
  }))), [
701
773
  e,
702
774
  i,
@@ -705,9 +777,10 @@ var Ee = /* @__PURE__ */ new Set([
705
777
  s,
706
778
  c,
707
779
  l,
708
- d
780
+ d,
781
+ f
709
782
  ]);
710
- }, Ne = [
783
+ }, He = [
711
784
  "data",
712
785
  "schema",
713
786
  "renderers",
@@ -715,36 +788,76 @@ var Ee = /* @__PURE__ */ new Set([
715
788
  "toolAttributes",
716
789
  "blockIds",
717
790
  "transformUrl",
791
+ "inlineRenderers",
718
792
  "classes"
719
- ], Pe = (e) => {
720
- let { data: t, schema: n, renderers: r, onUnknownBlock: i, toolAttributes: a, blockIds: o, transformUrl: s, classes: c } = e, l = $(e, Ne), u = Me(t, {
793
+ ], Ue = (e) => {
794
+ let { data: t, schema: n, renderers: r, onUnknownBlock: i, toolAttributes: a, blockIds: o, transformUrl: s, inlineRenderers: c, classes: l } = e, u = Q(e, He), d = Ve(t, {
721
795
  schema: n,
722
796
  renderers: r,
723
797
  onUnknownBlock: i,
724
798
  toolAttributes: a,
725
799
  blockIds: o,
726
800
  transformUrl: s,
727
- classes: c == null || c
801
+ inlineRenderers: c,
802
+ classes: l == null || l
728
803
  });
729
- return /* @__PURE__ */ T("div", B(B({ "data-blok-interface": "view" }, l), {}, { children: u }));
730
- }, Fe = ["icon", "title"], Ie = ["commit", "readOnly"], Le = [W, G];
731
- function Re(e) {
732
- var t;
733
- let n = (e) => {
804
+ return /* @__PURE__ */ E("div", V(V({ "data-blok-interface": "view" }, u), {}, { children: d }));
805
+ }, We = ["icon", "title"], Ge = ["commit", "readOnly"], Ke = [G, K], qe = (e, t, n) => {
806
+ let r = /* @__PURE__ */ new Map();
807
+ t.forEach((e, t) => {
808
+ var i;
809
+ let a = [];
810
+ for (let [r, o] of Object.entries((i = n == null ? void 0 : n(e, t)) == null ? {} : i)) {
811
+ if (o == null) {
812
+ e.holder.removeAttribute(r);
813
+ continue;
814
+ }
815
+ e.holder.setAttribute(r, String(o)), a.push(r);
816
+ }
817
+ r.set(e.id, {
818
+ holder: e.holder,
819
+ names: a
820
+ });
821
+ });
822
+ for (let [t, n] of e) {
823
+ let e = r.get(t);
824
+ n.names.filter((t) => e === void 0 || !e.names.includes(t)).forEach((e) => n.holder.removeAttribute(e));
825
+ }
826
+ e.clear(), r.forEach((t, n) => e.set(n, t));
827
+ }, Je = (e, t, n) => {
828
+ var r;
829
+ e == null || (r = e.events) == null || r.emit(h, {
830
+ blockId: t,
831
+ childIds: n.map((e) => e.id)
832
+ });
833
+ }, Ye = /* @__PURE__ */ new Set([
834
+ void 0,
835
+ "user",
836
+ "api",
837
+ "convert"
838
+ ]), Xe = [
839
+ "toolbox",
840
+ "isReadOnlySupported",
841
+ "__isBlokReactBlock",
842
+ "__buildPortalToolbox"
843
+ ];
844
+ function Ze(e) {
845
+ var t, n;
846
+ let r = (e) => {
734
847
  if (typeof document > "u") return null;
735
- let t = document.createElement("div"), n = j(t);
736
- k(() => {
848
+ let t = document.createElement("div"), n = M(t);
849
+ A(() => {
737
850
  n.render(e);
738
851
  });
739
852
  let r = t.innerHTML;
740
853
  return n.unmount(), r === "" ? null : r;
741
- }, r = (e) => {
742
- let { icon: t, title: r } = e, i = B({}, $(e, Fe));
743
- if (typeof r == "string" && (i.title = r), !a(t)) return t !== void 0 && (i.icon = t), {
854
+ }, i = (e) => {
855
+ let { icon: t, title: n } = e, i = V({}, Q(e, We));
856
+ if (typeof n == "string" && (i.title = n), !a(t)) return t !== void 0 && (i.icon = t), {
744
857
  entry: i,
745
858
  deferred: !1
746
859
  };
747
- let o = n(t);
860
+ let o = r(t);
748
861
  return o === null ? (i.icon = t, {
749
862
  entry: i,
750
863
  deferred: !0
@@ -752,94 +865,111 @@ function Re(e) {
752
865
  entry: i,
753
866
  deferred: !1
754
867
  });
755
- }, i = () => {
868
+ }, o = () => {
756
869
  if (e.toolbox === void 0) return {
757
870
  value: void 0,
758
871
  complete: !0
759
872
  };
760
- 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);
873
+ let t = (Array.isArray(e.toolbox) ? e.toolbox : [e.toolbox]).map((e) => i(e)), n = t.every((e) => !e.deferred), r = t.map((e) => e.entry);
761
874
  return {
762
- value: Array.isArray(e.toolbox) ? i : i[0],
875
+ value: Array.isArray(e.toolbox) ? r : r[0],
763
876
  complete: n
764
877
  };
765
- }, o = (t, n) => {
878
+ }, s = (t, n) => {
766
879
  if (e.toolbox === void 0) return;
767
- let i = Array.isArray(e.toolbox) ? e.toolbox : [e.toolbox];
768
- if (i.some((e) => a(e.title))) return i.map((e, i) => {
769
- let { entry: o } = r(e);
770
- if (!a(e.title)) return o;
771
- let s = document.createElement("span");
772
- s.setAttribute("data-blok-mutation-free", "true");
773
- let c = e.title, l = () => /* @__PURE__ */ T(w, { children: c });
774
- return l.displayName = `BlokToolboxTitle(${n})`, t.register(`__blok-toolbox-title__:${n}:${i}`, {
775
- hostEl: s,
776
- component: l,
880
+ let r = Array.isArray(e.toolbox) ? e.toolbox : [e.toolbox];
881
+ if (!r.some((e) => a(e.title))) return;
882
+ let o = r.map((e, r) => {
883
+ let { entry: o, deferred: s } = i(e);
884
+ if (s && delete o.icon, !a(e.title)) return o;
885
+ let c = document.createElement("span");
886
+ c.setAttribute("data-blok-mutation-free", "true");
887
+ let l = e.title, u = () => /* @__PURE__ */ E(T, { children: l });
888
+ return u.displayName = `BlokToolboxTitle(${n})`, t.register(`__blok-toolbox-title__:${n}:${r}`, {
889
+ hostEl: c,
890
+ component: u,
777
891
  props: {},
778
892
  toolName: n
779
- }), B(B({}, o), {}, { titleEl: s });
893
+ }), V(V({}, o), {}, { titleEl: c });
780
894
  });
781
- }, s = {
895
+ return Array.isArray(e.toolbox) ? o : o[0];
896
+ }, l = {
782
897
  resolved: !1,
783
898
  value: void 0
784
- }, l = () => {
785
- if (s.resolved) return s.value;
786
- let { value: e, complete: t } = i();
787
- return t && (s.value = e, s.resolved = !0), e;
788
- }, u = e.viewComponent === void 0 ? e.component : (t) => {
899
+ }, u = () => {
900
+ if (l.resolved) return l.value;
901
+ let { value: e, complete: t } = o();
902
+ return t && (l.value = e, l.resolved = !0), e;
903
+ }, f = e.viewComponent === void 0 ? e.component : (t) => {
789
904
  let n = e.viewComponent;
790
905
  if (t.readOnly && n !== void 0) {
791
906
  let { commit: e, readOnly: r } = t;
792
- return /* @__PURE__ */ T(n, B({}, $(t, Ie)));
907
+ return /* @__PURE__ */ E(n, V({}, Q(t, Ge)));
793
908
  }
794
909
  let r = e.component;
795
- return /* @__PURE__ */ T(r, B({}, t));
796
- };
797
- return t = class {
910
+ return /* @__PURE__ */ E(r, V({}, t));
911
+ }, p = (t = class {
798
912
  static get toolbox() {
799
- return l();
913
+ return u();
800
914
  }
801
915
  static __buildPortalToolbox(e, t) {
802
- return o(e, t);
916
+ return s(e, t);
803
917
  }
804
918
  static get isReadOnlySupported() {
805
919
  return !0;
806
920
  }
807
921
  constructor(t) {
808
- var n, r;
809
- this.hostEl = null, this.pendingDispatch = !1, this.commit = (t) => {
922
+ var n, r, i;
923
+ this.mountSignalled = !1, this.hostEl = null, this.pendingDispatch = !1, this.commit = (t) => {
810
924
  var n;
811
- let r = x(e.propSchema, B(B({}, this.mirror), t));
812
- y(r, this.mirror) || (this.mirror = r, this.lastRendered = r, (n = this.registry) == null || n.setProps(this.blockApi.id, { data: r }), this.flushDispatch());
925
+ let r = S(e.propSchema, V(V({}, this.mirror), t));
926
+ b(r, this.mirror) || (this.mirror = r, this.lastRendered = r, (n = this.registry) == null || n.setProps(this.blockApi.id, { data: r }), this.flushDispatch());
813
927
  }, this.blockApi = t.block;
814
- let i = (n = t.config) == null ? {} : n;
815
- this.registry = i[W];
816
- let a = i[G];
817
- this.toolName = typeof a == "string" ? a : void 0;
818
- let o = {};
819
- for (let [e, t] of Object.entries(i)) Le.includes(e) || (o[e] = t);
820
- this.toolConfig = Object.freeze(o);
821
- let s = t.api;
928
+ let a = (n = t.config) == null ? {} : n;
929
+ this.registry = a[G];
930
+ let o = a[K];
931
+ this.toolName = typeof o == "string" ? o : void 0;
932
+ let s = {};
933
+ for (let [e, t] of Object.entries(a)) Ke.includes(e) || (s[e] = t);
934
+ this.toolConfig = Object.freeze(s), this.api = t.api;
935
+ let l = t.api;
822
936
  this.pointerDrag = () => {
823
937
  var e;
824
- return (s == null || (e = s.blocks) == null ? void 0 : e.isPointerDragActive) === !0;
825
- }, this.mirror = x(e.propSchema, (r = t.data) == null ? {} : r), this.lastRendered = this.mirror, this.readOnly = t.readOnly;
826
- let l = this.blockApi;
827
- this.childrenComponent = function() {
828
- let e = d(null);
938
+ return (l == null || (e = l.blocks) == null ? void 0 : e.isPointerDragActive) === !0;
939
+ }, this.mirror = S(e.propSchema, (r = t.data) == null ? {} : r), this.lastRendered = this.mirror, this.readOnly = t.readOnly, this.origin = (i = t.origin) == null ? "api" : i;
940
+ let u = this.blockApi, f = this.api;
941
+ this.childrenComponent = function({ childAttributes: e }) {
942
+ let t = d(null), n = d(/* @__PURE__ */ new Map());
829
943
  return c(() => {
830
- e.current !== null && C(e.current, l.getChildren());
831
- }), /* @__PURE__ */ T("div", {
832
- ref: e,
833
- [h.nestedBlocks]: ""
944
+ if (t.current === null) return;
945
+ let r = u.getChildren();
946
+ w(t.current, r), qe(n.current, r, e), Je(f, u.id, r);
947
+ }), /* @__PURE__ */ E("div", {
948
+ ref: t,
949
+ [g.nestedBlocks]: ""
834
950
  });
835
- };
951
+ }, this.entryComponent = this.buildEntryComponent();
952
+ }
953
+ buildEntryComponent() {
954
+ let t = e.onMounted, n = e.onCreated;
955
+ if (t === void 0 && n === void 0) return f;
956
+ let r = f, i = () => {
957
+ if (this.mountSignalled) return;
958
+ this.mountSignalled = !0;
959
+ let e = {
960
+ origin: this.origin,
961
+ api: this.api
962
+ };
963
+ t == null || t(this.blockApi, e), Ye.has(this.origin) && (n == null || n(this.blockApi, e));
964
+ }, a = (e) => (c(i, []), /* @__PURE__ */ E(r, V({}, e)));
965
+ return a.displayName = `BlokBlockMount(${e.type})`, a;
836
966
  }
837
967
  render() {
838
968
  var e;
839
969
  let t = document.createElement("div");
840
970
  return t.setAttribute("data-blok-mutation-free", "true"), this.hostEl = t, (e = this.registry) == null || e.register(this.blockApi.id, {
841
971
  hostEl: t,
842
- component: u,
972
+ component: this.entryComponent,
843
973
  props: this.buildProps(),
844
974
  toolName: this.toolName
845
975
  }), t;
@@ -853,29 +983,35 @@ function Re(e) {
853
983
  }
854
984
  async setData(t) {
855
985
  var n = this;
856
- let r = x(e.propSchema, t == null ? {} : t);
857
- return y(r, n.lastRendered) ? !0 : (n.mirror = r, n.lastRendered = r, n.pushProps({ data: r }), !0);
986
+ let r = S(e.propSchema, t == null ? {} : t);
987
+ return b(r, n.lastRendered) ? !0 : (n.mirror = r, n.lastRendered = r, n.pushProps({ data: r }), !0);
858
988
  }
859
989
  setReadOnly(e) {
860
990
  this.readOnly = e, this.pushProps({ readOnly: e });
861
991
  }
992
+ getToolbarAnchorElement() {
993
+ var t;
994
+ let n = this.hostEl;
995
+ if (!(n === null || e.getToolbarAnchorElement === void 0)) return (t = e.getToolbarAnchorElement(n, this.blockApi)) == null ? void 0 : t;
996
+ }
862
997
  moved() {
863
998
  var t;
864
999
  (t = e.onMoved) == null || t.call(e, this.blockApi);
865
1000
  }
866
1001
  removed() {
867
- var t, n;
868
- (t = this.registry) == null || t.unregister(this.blockApi.id), (n = e.onRemoved) == null || n.call(e, this.blockApi);
1002
+ var t, n, r;
1003
+ (t = this.registry) == null || t.unregister(this.blockApi.id, (n = this.hostEl) == null ? void 0 : n), (r = e.onRemoved) == null || r.call(e, this.blockApi);
869
1004
  }
870
1005
  destroy() {
871
- var e;
872
- (e = this.registry) == null || e.unregister(this.blockApi.id);
1006
+ var e, t;
1007
+ (e = this.registry) == null || e.unregister(this.blockApi.id, (t = this.hostEl) == null ? void 0 : t);
873
1008
  }
874
1009
  buildProps() {
875
1010
  return {
876
1011
  data: this.mirror,
877
1012
  commit: this.commit,
878
1013
  block: this.blockApi,
1014
+ api: this.api,
879
1015
  readOnly: this.readOnly,
880
1016
  config: this.toolConfig,
881
1017
  BlockChildren: this.childrenComponent
@@ -883,7 +1019,7 @@ function Re(e) {
883
1019
  }
884
1020
  pushProps(e) {
885
1021
  let t = this.registry;
886
- t !== void 0 && k(() => {
1022
+ t !== void 0 && A(() => {
887
1023
  t.setProps(this.blockApi.id, e);
888
1024
  });
889
1025
  }
@@ -903,17 +1039,24 @@ function Re(e) {
903
1039
  };
904
1040
  requestAnimationFrame(e);
905
1041
  }
906
- }, t.__isBlokReactBlock = !0, t;
1042
+ }, t.__isBlokReactBlock = !0, t);
1043
+ for (let [t, r] of Object.entries((n = e.statics) == null ? {} : n)) Xe.includes(t) || Object.defineProperty(p, t, {
1044
+ value: r,
1045
+ writable: !0,
1046
+ enumerable: !0,
1047
+ configurable: !0
1048
+ });
1049
+ return p;
907
1050
  }
908
1051
  //#endregion
909
1052
  //#region src/createReactInlineTool.tsx
910
- var ze = [W, G], Be = (e) => `__blok-inline-tool__:${e}:${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`, Ve = n(null);
911
- function He() {
912
- let e = s(Ve);
1053
+ var Qe = [G, K], $e = (e) => `__blok-inline-tool__:${e}:${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`, et = n(null);
1054
+ function tt() {
1055
+ let e = s(et);
913
1056
  if (e === null) throw Error("useInlineTool() must be called from a component rendered by createReactInlineTool");
914
1057
  return e;
915
1058
  }
916
- function Ue(e) {
1059
+ function nt(e) {
917
1060
  var t;
918
1061
  return t = class {
919
1062
  static get type() {
@@ -933,7 +1076,7 @@ function Ue(e) {
933
1076
  return e.mark;
934
1077
  }
935
1078
  static get sanitize() {
936
- return e.sanitize === void 0 ? e.mark === void 0 ? void 0 : S(e.mark) : e.sanitize;
1079
+ return e.sanitize === void 0 ? e.mark === void 0 ? void 0 : C(e.mark) : e.sanitize;
937
1080
  }
938
1081
  static get isReadOnlySupported() {
939
1082
  var t;
@@ -943,11 +1086,11 @@ function Ue(e) {
943
1086
  var n;
944
1087
  this.active = !1, this.registered = !1;
945
1088
  let r = (n = t == null ? void 0 : t.config) == null ? {} : n;
946
- this.api = t == null ? void 0 : t.api, this.registry = r[W];
947
- let i = r[G];
948
- this.toolName = typeof i == "string" ? i : e.type, this.portalKey = Be(this.toolName);
1089
+ this.api = t == null ? void 0 : t.api, this.registry = r[G];
1090
+ let i = r[K];
1091
+ this.toolName = typeof i == "string" ? i : e.type, this.portalKey = $e(this.toolName);
949
1092
  let a = {};
950
- for (let [e, t] of Object.entries(r)) ze.includes(e) || (a[e] = t);
1093
+ for (let [e, t] of Object.entries(r)) Qe.includes(e) || (a[e] = t);
951
1094
  this.toolConfig = Object.freeze(a), this.portalComponent = this.createPortalComponent();
952
1095
  }
953
1096
  render() {
@@ -1010,9 +1153,9 @@ function Ue(e) {
1010
1153
  api: t,
1011
1154
  mark: i
1012
1155
  }), [e.active, e.config]);
1013
- return /* @__PURE__ */ T(Ve.Provider, {
1156
+ return /* @__PURE__ */ E(et.Provider, {
1014
1157
  value: n,
1015
- children: /* @__PURE__ */ T(r, {
1158
+ children: /* @__PURE__ */ E(r, {
1016
1159
  active: e.active,
1017
1160
  config: e.config
1018
1161
  })
@@ -1023,4 +1166,4 @@ function Ue(e) {
1023
1166
  }, t.__isBlokReactInlineTool = !0, t.isInline = !0, t;
1024
1167
  }
1025
1168
  //#endregion
1026
- 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 };
1169
+ export { G as BLOK_PORTAL_REGISTRY_CONFIG_KEY, K as BLOK_TOOL_NAME_CONFIG_KEY, be as BlockPortalHost, De as BlokContent, je as BlokEditor, U as BlokProvider, Ue as BlokView, oe as createBlockPortalRegistry, Ze as createReactBlock, nt as createReactInlineTool, D as getDirection, O as normalizeLocale, Pe as useBlocks, _e as useBlok, W as useBlokDefaults, Me as useBlokHandle, Se as useBlokInstance, Fe as useBlokReady, Ve as useBlokView, tt as useInlineTool };