@bloklabs/react 1.7.0 → 1.8.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,21 +746,21 @@ 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) => {
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) => {
691
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.classes;
692
- return u(() => r(t, null, ...je(A(e, {
763
+ return u(() => r(t, null, ...Be(j(e, {
693
764
  schema: i,
694
765
  renderers: a,
695
766
  onUnknownBlock: o,
@@ -707,7 +778,7 @@ var Ee = /* @__PURE__ */ new Set([
707
778
  l,
708
779
  d
709
780
  ]);
710
- }, Ne = [
781
+ }, He = [
711
782
  "data",
712
783
  "schema",
713
784
  "renderers",
@@ -716,8 +787,8 @@ var Ee = /* @__PURE__ */ new Set([
716
787
  "blockIds",
717
788
  "transformUrl",
718
789
  "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, {
790
+ ], Ue = (e) => {
791
+ let { data: t, schema: n, renderers: r, onUnknownBlock: i, toolAttributes: a, blockIds: o, transformUrl: s, classes: c } = e, l = Q(e, He), u = Ve(t, {
721
792
  schema: n,
722
793
  renderers: r,
723
794
  onUnknownBlock: i,
@@ -726,25 +797,63 @@ var Ee = /* @__PURE__ */ new Set([
726
797
  transformUrl: s,
727
798
  classes: c == null || c
728
799
  });
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) => {
800
+ return /* @__PURE__ */ E("div", V(V({ "data-blok-interface": "view" }, l), {}, { children: u }));
801
+ }, We = ["icon", "title"], Ge = ["commit", "readOnly"], Ke = [G, K], qe = (e, t, n) => {
802
+ let r = /* @__PURE__ */ new Map();
803
+ t.forEach((e, t) => {
804
+ var i;
805
+ let a = [];
806
+ for (let [r, o] of Object.entries((i = n == null ? void 0 : n(e, t)) == null ? {} : i)) {
807
+ if (o == null) {
808
+ e.holder.removeAttribute(r);
809
+ continue;
810
+ }
811
+ e.holder.setAttribute(r, String(o)), a.push(r);
812
+ }
813
+ r.set(e.id, {
814
+ holder: e.holder,
815
+ names: a
816
+ });
817
+ });
818
+ for (let [t, n] of e) {
819
+ let e = r.get(t);
820
+ n.names.filter((t) => e === void 0 || !e.names.includes(t)).forEach((e) => n.holder.removeAttribute(e));
821
+ }
822
+ e.clear(), r.forEach((t, n) => e.set(n, t));
823
+ }, Je = (e, t, n) => {
824
+ var r;
825
+ e == null || (r = e.events) == null || r.emit(h, {
826
+ blockId: t,
827
+ childIds: n.map((e) => e.id)
828
+ });
829
+ }, Ye = /* @__PURE__ */ new Set([
830
+ void 0,
831
+ "user",
832
+ "api",
833
+ "convert"
834
+ ]), Xe = [
835
+ "toolbox",
836
+ "isReadOnlySupported",
837
+ "__isBlokReactBlock",
838
+ "__buildPortalToolbox"
839
+ ];
840
+ function Ze(e) {
841
+ var t, n;
842
+ let r = (e) => {
734
843
  if (typeof document > "u") return null;
735
- let t = document.createElement("div"), n = j(t);
736
- k(() => {
844
+ let t = document.createElement("div"), n = M(t);
845
+ A(() => {
737
846
  n.render(e);
738
847
  });
739
848
  let r = t.innerHTML;
740
849
  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), {
850
+ }, i = (e) => {
851
+ let { icon: t, title: n } = e, i = V({}, Q(e, We));
852
+ if (typeof n == "string" && (i.title = n), !a(t)) return t !== void 0 && (i.icon = t), {
744
853
  entry: i,
745
854
  deferred: !1
746
855
  };
747
- let o = n(t);
856
+ let o = r(t);
748
857
  return o === null ? (i.icon = t, {
749
858
  entry: i,
750
859
  deferred: !0
@@ -752,94 +861,111 @@ function Re(e) {
752
861
  entry: i,
753
862
  deferred: !1
754
863
  });
755
- }, i = () => {
864
+ }, o = () => {
756
865
  if (e.toolbox === void 0) return {
757
866
  value: void 0,
758
867
  complete: !0
759
868
  };
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);
869
+ 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
870
  return {
762
- value: Array.isArray(e.toolbox) ? i : i[0],
871
+ value: Array.isArray(e.toolbox) ? r : r[0],
763
872
  complete: n
764
873
  };
765
- }, o = (t, n) => {
874
+ }, s = (t, n) => {
766
875
  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,
876
+ let r = Array.isArray(e.toolbox) ? e.toolbox : [e.toolbox];
877
+ if (!r.some((e) => a(e.title))) return;
878
+ let o = r.map((e, r) => {
879
+ let { entry: o, deferred: s } = i(e);
880
+ if (s && delete o.icon, !a(e.title)) return o;
881
+ let c = document.createElement("span");
882
+ c.setAttribute("data-blok-mutation-free", "true");
883
+ let l = e.title, u = () => /* @__PURE__ */ E(T, { children: l });
884
+ return u.displayName = `BlokToolboxTitle(${n})`, t.register(`__blok-toolbox-title__:${n}:${r}`, {
885
+ hostEl: c,
886
+ component: u,
777
887
  props: {},
778
888
  toolName: n
779
- }), B(B({}, o), {}, { titleEl: s });
889
+ }), V(V({}, o), {}, { titleEl: c });
780
890
  });
781
- }, s = {
891
+ return Array.isArray(e.toolbox) ? o : o[0];
892
+ }, l = {
782
893
  resolved: !1,
783
894
  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) => {
895
+ }, u = () => {
896
+ if (l.resolved) return l.value;
897
+ let { value: e, complete: t } = o();
898
+ return t && (l.value = e, l.resolved = !0), e;
899
+ }, f = e.viewComponent === void 0 ? e.component : (t) => {
789
900
  let n = e.viewComponent;
790
901
  if (t.readOnly && n !== void 0) {
791
902
  let { commit: e, readOnly: r } = t;
792
- return /* @__PURE__ */ T(n, B({}, $(t, Ie)));
903
+ return /* @__PURE__ */ E(n, V({}, Q(t, Ge)));
793
904
  }
794
905
  let r = e.component;
795
- return /* @__PURE__ */ T(r, B({}, t));
796
- };
797
- return t = class {
906
+ return /* @__PURE__ */ E(r, V({}, t));
907
+ }, p = (t = class {
798
908
  static get toolbox() {
799
- return l();
909
+ return u();
800
910
  }
801
911
  static __buildPortalToolbox(e, t) {
802
- return o(e, t);
912
+ return s(e, t);
803
913
  }
804
914
  static get isReadOnlySupported() {
805
915
  return !0;
806
916
  }
807
917
  constructor(t) {
808
- var n, r;
809
- this.hostEl = null, this.pendingDispatch = !1, this.commit = (t) => {
918
+ var n, r, i;
919
+ this.mountSignalled = !1, this.hostEl = null, this.pendingDispatch = !1, this.commit = (t) => {
810
920
  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());
921
+ let r = S(e.propSchema, V(V({}, this.mirror), t));
922
+ b(r, this.mirror) || (this.mirror = r, this.lastRendered = r, (n = this.registry) == null || n.setProps(this.blockApi.id, { data: r }), this.flushDispatch());
813
923
  }, 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;
924
+ let a = (n = t.config) == null ? {} : n;
925
+ this.registry = a[G];
926
+ let o = a[K];
927
+ this.toolName = typeof o == "string" ? o : void 0;
928
+ let s = {};
929
+ for (let [e, t] of Object.entries(a)) Ke.includes(e) || (s[e] = t);
930
+ this.toolConfig = Object.freeze(s), this.api = t.api;
931
+ let l = t.api;
822
932
  this.pointerDrag = () => {
823
933
  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);
934
+ return (l == null || (e = l.blocks) == null ? void 0 : e.isPointerDragActive) === !0;
935
+ }, 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;
936
+ let u = this.blockApi, f = this.api;
937
+ this.childrenComponent = function({ childAttributes: e }) {
938
+ let t = d(null), n = d(/* @__PURE__ */ new Map());
829
939
  return c(() => {
830
- e.current !== null && C(e.current, l.getChildren());
831
- }), /* @__PURE__ */ T("div", {
832
- ref: e,
833
- [h.nestedBlocks]: ""
940
+ if (t.current === null) return;
941
+ let r = u.getChildren();
942
+ w(t.current, r), qe(n.current, r, e), Je(f, u.id, r);
943
+ }), /* @__PURE__ */ E("div", {
944
+ ref: t,
945
+ [g.nestedBlocks]: ""
834
946
  });
835
- };
947
+ }, this.entryComponent = this.buildEntryComponent();
948
+ }
949
+ buildEntryComponent() {
950
+ let t = e.onMounted, n = e.onCreated;
951
+ if (t === void 0 && n === void 0) return f;
952
+ let r = f, i = () => {
953
+ if (this.mountSignalled) return;
954
+ this.mountSignalled = !0;
955
+ let e = {
956
+ origin: this.origin,
957
+ api: this.api
958
+ };
959
+ t == null || t(this.blockApi, e), Ye.has(this.origin) && (n == null || n(this.blockApi, e));
960
+ }, a = (e) => (c(i, []), /* @__PURE__ */ E(r, V({}, e)));
961
+ return a.displayName = `BlokBlockMount(${e.type})`, a;
836
962
  }
837
963
  render() {
838
964
  var e;
839
965
  let t = document.createElement("div");
840
966
  return t.setAttribute("data-blok-mutation-free", "true"), this.hostEl = t, (e = this.registry) == null || e.register(this.blockApi.id, {
841
967
  hostEl: t,
842
- component: u,
968
+ component: this.entryComponent,
843
969
  props: this.buildProps(),
844
970
  toolName: this.toolName
845
971
  }), t;
@@ -853,29 +979,35 @@ function Re(e) {
853
979
  }
854
980
  async setData(t) {
855
981
  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);
982
+ let r = S(e.propSchema, t == null ? {} : t);
983
+ return b(r, n.lastRendered) ? !0 : (n.mirror = r, n.lastRendered = r, n.pushProps({ data: r }), !0);
858
984
  }
859
985
  setReadOnly(e) {
860
986
  this.readOnly = e, this.pushProps({ readOnly: e });
861
987
  }
988
+ getToolbarAnchorElement() {
989
+ var t;
990
+ let n = this.hostEl;
991
+ if (!(n === null || e.getToolbarAnchorElement === void 0)) return (t = e.getToolbarAnchorElement(n, this.blockApi)) == null ? void 0 : t;
992
+ }
862
993
  moved() {
863
994
  var t;
864
995
  (t = e.onMoved) == null || t.call(e, this.blockApi);
865
996
  }
866
997
  removed() {
867
- var t, n;
868
- (t = this.registry) == null || t.unregister(this.blockApi.id), (n = e.onRemoved) == null || n.call(e, this.blockApi);
998
+ var t, n, r;
999
+ (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
1000
  }
870
1001
  destroy() {
871
- var e;
872
- (e = this.registry) == null || e.unregister(this.blockApi.id);
1002
+ var e, t;
1003
+ (e = this.registry) == null || e.unregister(this.blockApi.id, (t = this.hostEl) == null ? void 0 : t);
873
1004
  }
874
1005
  buildProps() {
875
1006
  return {
876
1007
  data: this.mirror,
877
1008
  commit: this.commit,
878
1009
  block: this.blockApi,
1010
+ api: this.api,
879
1011
  readOnly: this.readOnly,
880
1012
  config: this.toolConfig,
881
1013
  BlockChildren: this.childrenComponent
@@ -883,7 +1015,7 @@ function Re(e) {
883
1015
  }
884
1016
  pushProps(e) {
885
1017
  let t = this.registry;
886
- t !== void 0 && k(() => {
1018
+ t !== void 0 && A(() => {
887
1019
  t.setProps(this.blockApi.id, e);
888
1020
  });
889
1021
  }
@@ -903,17 +1035,24 @@ function Re(e) {
903
1035
  };
904
1036
  requestAnimationFrame(e);
905
1037
  }
906
- }, t.__isBlokReactBlock = !0, t;
1038
+ }, t.__isBlokReactBlock = !0, t);
1039
+ for (let [t, r] of Object.entries((n = e.statics) == null ? {} : n)) Xe.includes(t) || Object.defineProperty(p, t, {
1040
+ value: r,
1041
+ writable: !0,
1042
+ enumerable: !0,
1043
+ configurable: !0
1044
+ });
1045
+ return p;
907
1046
  }
908
1047
  //#endregion
909
1048
  //#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);
1049
+ var Qe = [G, K], $e = (e) => `__blok-inline-tool__:${e}:${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`, et = n(null);
1050
+ function tt() {
1051
+ let e = s(et);
913
1052
  if (e === null) throw Error("useInlineTool() must be called from a component rendered by createReactInlineTool");
914
1053
  return e;
915
1054
  }
916
- function Ue(e) {
1055
+ function nt(e) {
917
1056
  var t;
918
1057
  return t = class {
919
1058
  static get type() {
@@ -933,7 +1072,7 @@ function Ue(e) {
933
1072
  return e.mark;
934
1073
  }
935
1074
  static get sanitize() {
936
- return e.sanitize === void 0 ? e.mark === void 0 ? void 0 : S(e.mark) : e.sanitize;
1075
+ return e.sanitize === void 0 ? e.mark === void 0 ? void 0 : C(e.mark) : e.sanitize;
937
1076
  }
938
1077
  static get isReadOnlySupported() {
939
1078
  var t;
@@ -943,11 +1082,11 @@ function Ue(e) {
943
1082
  var n;
944
1083
  this.active = !1, this.registered = !1;
945
1084
  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);
1085
+ this.api = t == null ? void 0 : t.api, this.registry = r[G];
1086
+ let i = r[K];
1087
+ this.toolName = typeof i == "string" ? i : e.type, this.portalKey = $e(this.toolName);
949
1088
  let a = {};
950
- for (let [e, t] of Object.entries(r)) ze.includes(e) || (a[e] = t);
1089
+ for (let [e, t] of Object.entries(r)) Qe.includes(e) || (a[e] = t);
951
1090
  this.toolConfig = Object.freeze(a), this.portalComponent = this.createPortalComponent();
952
1091
  }
953
1092
  render() {
@@ -1010,9 +1149,9 @@ function Ue(e) {
1010
1149
  api: t,
1011
1150
  mark: i
1012
1151
  }), [e.active, e.config]);
1013
- return /* @__PURE__ */ T(Ve.Provider, {
1152
+ return /* @__PURE__ */ E(et.Provider, {
1014
1153
  value: n,
1015
- children: /* @__PURE__ */ T(r, {
1154
+ children: /* @__PURE__ */ E(r, {
1016
1155
  active: e.active,
1017
1156
  config: e.config
1018
1157
  })
@@ -1023,4 +1162,4 @@ function Ue(e) {
1023
1162
  }, t.__isBlokReactInlineTool = !0, t.isInline = !0, t;
1024
1163
  }
1025
1164
  //#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 };
1165
+ 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 };