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