@bloklabs/vue 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.cjs +1 -1
- package/dist/index.mjs +328 -160
- package/package.json +2 -2
- package/src/BlokContent.ts +24 -1
- package/src/BlokEditor.ts +78 -8
- package/src/block-portal-registry.ts +17 -3
- package/src/blok-instance.ts +40 -0
- package/src/config-keys.ts +1 -0
- package/src/content-baseline-map.ts +38 -0
- package/src/createVueBlock.ts +389 -27
- package/src/index.ts +5 -0
- package/src/useBlok.ts +157 -14
- package/types/index.d.ts +139 -2
package/dist/index.mjs
CHANGED
|
@@ -1,49 +1,61 @@
|
|
|
1
1
|
import { Fragment as e, Teleport as t, computed as n, defineComponent as r, getCurrentInstance as i, h as a, inject as o, markRaw as s, nextTick as c, onBeforeUnmount as l, onErrorCaptured as u, onMounted as d, onScopeDispose as f, onUpdated as p, provide as m, reactive as h, ref as g, shallowRef as _, toRaw as v, toValue as y, watch as b } from "vue";
|
|
2
2
|
import { Blok as x } from "@bloklabs/core";
|
|
3
|
-
import {
|
|
4
|
-
//#region src/
|
|
3
|
+
import { BlockChildrenMounted as ee, DATA_ATTR as S, EMPTY_API as C, createBlocksApiForEditor as w, deepEqual as T, equalsOutputData as te, fillDefaults as E, mountChildBlocks as D, normalizeReadOnlyConfig as O, toRenderableData as ne } from "@bloklabs/core/adapters";
|
|
4
|
+
//#region src/content-baseline-map.ts
|
|
5
5
|
var k = /* @__PURE__ */ new WeakMap();
|
|
6
|
-
function
|
|
6
|
+
function A(e, t) {
|
|
7
7
|
k.set(e, t);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function re(e) {
|
|
10
10
|
return k.get(e);
|
|
11
11
|
}
|
|
12
12
|
function j(e) {
|
|
13
13
|
k.delete(e);
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
|
+
//#region src/holder-map.ts
|
|
17
|
+
var M = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
function N(e, t) {
|
|
19
|
+
M.set(e, t);
|
|
20
|
+
}
|
|
21
|
+
function P(e) {
|
|
22
|
+
return M.get(e);
|
|
23
|
+
}
|
|
24
|
+
function F(e) {
|
|
25
|
+
M.delete(e);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
16
28
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
|
|
17
|
-
function
|
|
29
|
+
function I(e) {
|
|
18
30
|
"@babel/helpers - typeof";
|
|
19
|
-
return
|
|
31
|
+
return I = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
20
32
|
return typeof e;
|
|
21
33
|
} : function(e) {
|
|
22
34
|
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
23
|
-
},
|
|
35
|
+
}, I(e);
|
|
24
36
|
}
|
|
25
37
|
//#endregion
|
|
26
38
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
|
|
27
|
-
function
|
|
28
|
-
if (
|
|
39
|
+
function ie(e, t) {
|
|
40
|
+
if (I(e) != "object" || !e) return e;
|
|
29
41
|
var n = e[Symbol.toPrimitive];
|
|
30
42
|
if (n !== void 0) {
|
|
31
43
|
var r = n.call(e, t || "default");
|
|
32
|
-
if (
|
|
44
|
+
if (I(r) != "object") return r;
|
|
33
45
|
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
34
46
|
}
|
|
35
47
|
return (t === "string" ? String : Number)(e);
|
|
36
48
|
}
|
|
37
49
|
//#endregion
|
|
38
50
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
|
|
39
|
-
function
|
|
40
|
-
var t =
|
|
41
|
-
return
|
|
51
|
+
function ae(e) {
|
|
52
|
+
var t = ie(e, "string");
|
|
53
|
+
return I(t) == "symbol" ? t : t + "";
|
|
42
54
|
}
|
|
43
55
|
//#endregion
|
|
44
56
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
|
|
45
|
-
function
|
|
46
|
-
return (t =
|
|
57
|
+
function L(e, t, n) {
|
|
58
|
+
return (t = ae(t)) in e ? Object.defineProperty(e, t, {
|
|
47
59
|
value: n,
|
|
48
60
|
enumerable: !0,
|
|
49
61
|
configurable: !0,
|
|
@@ -52,7 +64,7 @@ function F(e, t, n) {
|
|
|
52
64
|
}
|
|
53
65
|
//#endregion
|
|
54
66
|
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/objectSpread2.js
|
|
55
|
-
function
|
|
67
|
+
function R(e, t) {
|
|
56
68
|
var n = Object.keys(e);
|
|
57
69
|
if (Object.getOwnPropertySymbols) {
|
|
58
70
|
var r = Object.getOwnPropertySymbols(e);
|
|
@@ -62,12 +74,12 @@ function I(e, t) {
|
|
|
62
74
|
}
|
|
63
75
|
return n;
|
|
64
76
|
}
|
|
65
|
-
function
|
|
77
|
+
function z(e) {
|
|
66
78
|
for (var t = 1; t < arguments.length; t++) {
|
|
67
79
|
var n = arguments[t] == null ? {} : arguments[t];
|
|
68
|
-
t % 2 ?
|
|
69
|
-
|
|
70
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) :
|
|
80
|
+
t % 2 ? R(Object(n), !0).forEach(function(t) {
|
|
81
|
+
L(e, t, n[t]);
|
|
82
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : R(Object(n)).forEach(function(t) {
|
|
71
83
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
72
84
|
});
|
|
73
85
|
}
|
|
@@ -75,52 +87,60 @@ function L(e) {
|
|
|
75
87
|
}
|
|
76
88
|
//#endregion
|
|
77
89
|
//#region src/provide-blok.ts
|
|
78
|
-
var
|
|
79
|
-
function
|
|
80
|
-
m(
|
|
90
|
+
var B = Symbol("BLOK_DEFAULT_CONFIG");
|
|
91
|
+
function V(e) {
|
|
92
|
+
m(B, e);
|
|
81
93
|
}
|
|
82
|
-
function
|
|
83
|
-
return o(
|
|
94
|
+
function H() {
|
|
95
|
+
return o(B, {});
|
|
84
96
|
}
|
|
85
|
-
function
|
|
97
|
+
function U(e, t) {
|
|
86
98
|
if (Object.keys(e).length === 0) return t;
|
|
87
|
-
let n =
|
|
99
|
+
let n = z({}, e);
|
|
88
100
|
for (let e of Object.keys(t)) {
|
|
89
101
|
let r = t[e];
|
|
90
102
|
r !== void 0 && (n[e] = r);
|
|
91
103
|
}
|
|
92
|
-
return (e.tools !== void 0 || t.tools !== void 0) && (n.tools =
|
|
104
|
+
return (e.tools !== void 0 || t.tools !== void 0) && (n.tools = z(z({}, e.tools), t.tools)), n;
|
|
93
105
|
}
|
|
94
106
|
//#endregion
|
|
95
107
|
//#region src/block-portal-registry.ts
|
|
96
|
-
var
|
|
108
|
+
var W = "__blokPortalRegistry", G = () => {
|
|
97
109
|
let e = h(/* @__PURE__ */ new Map());
|
|
98
110
|
return {
|
|
99
111
|
entries: e,
|
|
100
112
|
register(t, n) {
|
|
101
113
|
e.set(t, s(n));
|
|
102
114
|
},
|
|
103
|
-
unregister(t) {
|
|
104
|
-
|
|
115
|
+
unregister(t, n) {
|
|
116
|
+
var r;
|
|
117
|
+
n !== void 0 && ((r = e.get(t)) == null ? void 0 : r.hostEl) !== n || e.delete(t);
|
|
105
118
|
},
|
|
106
119
|
setProps(t, n) {
|
|
107
120
|
let r = e.get(t);
|
|
108
121
|
r !== void 0 && Object.assign(r.props, n);
|
|
109
122
|
}
|
|
110
123
|
};
|
|
111
|
-
},
|
|
112
|
-
function
|
|
113
|
-
|
|
124
|
+
}, K = /* @__PURE__ */ new WeakMap();
|
|
125
|
+
function q(e, t) {
|
|
126
|
+
K.set(e, t);
|
|
114
127
|
}
|
|
115
|
-
function
|
|
116
|
-
return
|
|
128
|
+
function J(e) {
|
|
129
|
+
return K.get(e);
|
|
117
130
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
131
|
+
function oe(e) {
|
|
132
|
+
K.delete(e);
|
|
120
133
|
}
|
|
121
134
|
//#endregion
|
|
122
135
|
//#region src/useBlok.ts
|
|
123
|
-
var
|
|
136
|
+
var Y = (e) => ({
|
|
137
|
+
onChange: e.onChange !== void 0,
|
|
138
|
+
onSave: e.onSave !== void 0,
|
|
139
|
+
onEnter: e.onEnter !== void 0,
|
|
140
|
+
onSubmit: e.onSubmit !== void 0,
|
|
141
|
+
onBeforeRender: e.onBeforeRender !== void 0,
|
|
142
|
+
onAfterRender: e.onAfterRender !== void 0
|
|
143
|
+
}), se = (e, t) => {
|
|
124
144
|
if (typeof e != "object" || !e) return e;
|
|
125
145
|
let n = {};
|
|
126
146
|
for (let [i, a] of Object.entries(e)) {
|
|
@@ -130,48 +150,82 @@ var J = (e, t) => {
|
|
|
130
150
|
n[i] = a;
|
|
131
151
|
continue;
|
|
132
152
|
}
|
|
133
|
-
let o = typeof a == "function" ? { class: a } :
|
|
134
|
-
o.config =
|
|
153
|
+
let o = typeof a == "function" ? { class: a } : z({}, a);
|
|
154
|
+
o.config = z(z({}, (r = o.config) == null ? {} : r), {}, { [W]: t }), n[i] = o;
|
|
135
155
|
}
|
|
136
156
|
return n;
|
|
137
157
|
};
|
|
138
|
-
function
|
|
139
|
-
let n = _(null), r = o(
|
|
158
|
+
function X(e, t) {
|
|
159
|
+
let n = _(null), r = o(B, {}), i = () => U(r, y(e)), a = {
|
|
140
160
|
current: null,
|
|
141
161
|
holder: null,
|
|
142
162
|
lastRenderedData: i().data,
|
|
143
163
|
seededEditor: null,
|
|
144
|
-
renderChain: Promise.resolve()
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
164
|
+
renderChain: Promise.resolve(),
|
|
165
|
+
appliedHandlerPresence: {
|
|
166
|
+
onChange: !1,
|
|
167
|
+
onSave: !1,
|
|
168
|
+
onEnter: !1,
|
|
169
|
+
onSubmit: !1,
|
|
170
|
+
onBeforeRender: !1,
|
|
171
|
+
onAfterRender: !1
|
|
172
|
+
}
|
|
173
|
+
}, s = {
|
|
174
|
+
onChange: (...e) => {
|
|
175
|
+
var t, n;
|
|
176
|
+
(t = (n = i()).onChange) == null || t.call(n, ...e);
|
|
177
|
+
},
|
|
178
|
+
onSave: (...e) => {
|
|
179
|
+
var t, n;
|
|
180
|
+
a.lastRenderedData = e[0], (t = (n = i()).onSave) == null || t.call(n, ...e);
|
|
181
|
+
},
|
|
182
|
+
onEnter: (...e) => {
|
|
183
|
+
var t, n;
|
|
184
|
+
return (t = (n = i()).onEnter) == null ? void 0 : t.call(n, ...e);
|
|
185
|
+
},
|
|
186
|
+
onSubmit: (...e) => {
|
|
187
|
+
var t, n;
|
|
188
|
+
(t = (n = i()).onSubmit) == null || t.call(n, ...e);
|
|
189
|
+
},
|
|
190
|
+
onBeforeRender: (...e) => {
|
|
191
|
+
var t, n, r;
|
|
192
|
+
return (t = (n = (r = i()).onBeforeRender) == null ? void 0 : n.call(r, ...e)) == null ? e[0] : t;
|
|
193
|
+
},
|
|
194
|
+
onAfterRender: (...e) => {
|
|
195
|
+
var t, n;
|
|
196
|
+
(t = (n = i()).onAfterRender) == null || t.call(n, ...e);
|
|
197
|
+
}
|
|
148
198
|
}, c = () => {
|
|
199
|
+
let t = z({}, U(v(r), v(y(e))));
|
|
200
|
+
return delete t.holder, t.data !== void 0 && (t.data = v(t.data)), t;
|
|
201
|
+
}, u = () => {
|
|
149
202
|
if (a.current !== null) {
|
|
150
|
-
|
|
203
|
+
F(a.current), oe(a.current), j(a.current);
|
|
151
204
|
try {
|
|
152
205
|
a.current.destroy();
|
|
153
206
|
} catch (e) {}
|
|
154
207
|
}
|
|
155
208
|
a.current = null, a.holder = null, n.value = null;
|
|
156
|
-
},
|
|
209
|
+
}, f = () => {
|
|
157
210
|
let e = document.createElement("div");
|
|
158
211
|
a.holder = e;
|
|
159
|
-
let t =
|
|
160
|
-
t.tools !== void 0 && (t.tools =
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
212
|
+
let t = c(), r = G();
|
|
213
|
+
t.tools !== void 0 && (t.tools = se(t.tools, r));
|
|
214
|
+
let o = Y(i());
|
|
215
|
+
t.onChange = o.onChange ? s.onChange : void 0, t.onSave = o.onSave ? s.onSave : void 0, t.onEnter = o.onEnter ? s.onEnter : void 0, t.onSubmit = o.onSubmit ? s.onSubmit : void 0, t.onBeforeRender = o.onBeforeRender ? s.onBeforeRender : void 0, t.onAfterRender = o.onAfterRender ? s.onAfterRender : void 0, a.appliedHandlerPresence = o;
|
|
216
|
+
let l = new x(z(z({}, t), {}, { holder: e }));
|
|
217
|
+
a.current = l, N(l, e), q(l, r), A(l, { markRendered: (e) => {
|
|
218
|
+
a.lastRenderedData = e;
|
|
219
|
+
} }), l.isReady.then(() => {
|
|
220
|
+
a.current === l && (n.value = l);
|
|
167
221
|
}).catch(() => {
|
|
168
|
-
a.current ===
|
|
222
|
+
a.current === l && u();
|
|
169
223
|
});
|
|
170
224
|
};
|
|
171
225
|
b([
|
|
172
226
|
n,
|
|
173
|
-
() =>
|
|
174
|
-
() =>
|
|
227
|
+
() => O(i().readOnly).enabled,
|
|
228
|
+
() => O(i().readOnly).hideControls,
|
|
175
229
|
() => typeof i().readOnly == "object"
|
|
176
230
|
], ([e, t, n, r]) => {
|
|
177
231
|
e && (r ? e.readOnly.set(t, { hideControls: n }) : e.readOnly.set(t));
|
|
@@ -184,75 +238,93 @@ function Y(e, t) {
|
|
|
184
238
|
}, { immediate: !0 }), b([n, () => i().placeholder], ([e, t]) => {
|
|
185
239
|
e && t !== void 0 && e.placeholder.set(t);
|
|
186
240
|
}, { immediate: !0 });
|
|
187
|
-
let
|
|
241
|
+
let p = { value: void 0 };
|
|
188
242
|
b([n, () => {
|
|
189
243
|
var e;
|
|
190
244
|
return (e = i().style) == null ? void 0 : e.tokens;
|
|
191
245
|
}], ([e, t]) => {
|
|
192
|
-
!e || t === void 0 ||
|
|
246
|
+
!e || t === void 0 || T(t, p.value) || (p.value = z({}, t), e.tokens.set(t));
|
|
193
247
|
}, {
|
|
194
248
|
immediate: !0,
|
|
195
249
|
deep: !0
|
|
196
250
|
});
|
|
197
|
-
let
|
|
251
|
+
let m = { value: i().i18n };
|
|
198
252
|
b([n, () => i().i18n], ([e, t]) => {
|
|
199
|
-
if (!e || t === void 0 ||
|
|
200
|
-
|
|
253
|
+
if (!e || t === void 0 || T(t, m.value)) return;
|
|
254
|
+
m.value = z({}, t);
|
|
201
255
|
let { locale: n, messages: r, direction: i } = t;
|
|
202
|
-
e.i18n.update(
|
|
256
|
+
e.i18n.update(z(z(z({}, n === void 0 ? {} : { locale: n }), r === void 0 ? {} : { messages: r }), i === void 0 ? {} : { direction: i }));
|
|
203
257
|
}, {
|
|
204
258
|
immediate: !0,
|
|
205
259
|
deep: !0
|
|
206
260
|
});
|
|
207
|
-
let
|
|
261
|
+
let h = {
|
|
208
262
|
editor: null,
|
|
209
263
|
value: void 0
|
|
210
264
|
};
|
|
211
265
|
return b([n, () => i().inlineToolbar], ([e, t]) => {
|
|
212
|
-
if (!e || t === void 0 ||
|
|
266
|
+
if (!e || t === void 0 || h.editor === e && T(t, h.value)) return;
|
|
213
267
|
let n = Array.isArray(t) ? [...t] : t;
|
|
214
|
-
|
|
268
|
+
h.editor = e, h.value = n, e.tools.setInlineToolbar(n);
|
|
215
269
|
}, {
|
|
216
270
|
immediate: !0,
|
|
217
271
|
deep: !0
|
|
218
272
|
}), b([n, () => i().autofocus], ([e, t]) => {
|
|
219
273
|
e && t && e.focus();
|
|
274
|
+
}, { immediate: !0 }), b([n, () => JSON.stringify(Y(i()))], ([e]) => {
|
|
275
|
+
if (!e) return;
|
|
276
|
+
let t = Y(i()), n = a.appliedHandlerPresence, r = {}, o = { value: !1 }, c = (e, r) => {
|
|
277
|
+
t[e] !== n[e] && (n[e] = t[e], o.value = !0, r(t[e] ? s[e] : void 0));
|
|
278
|
+
};
|
|
279
|
+
c("onChange", (e) => {
|
|
280
|
+
r.onChange = e;
|
|
281
|
+
}), c("onSave", (e) => {
|
|
282
|
+
r.onSave = e;
|
|
283
|
+
}), c("onEnter", (e) => {
|
|
284
|
+
r.onEnter = e;
|
|
285
|
+
}), c("onSubmit", (e) => {
|
|
286
|
+
r.onSubmit = e;
|
|
287
|
+
}), c("onBeforeRender", (e) => {
|
|
288
|
+
r.onBeforeRender = e;
|
|
289
|
+
}), c("onAfterRender", (e) => {
|
|
290
|
+
r.onAfterRender = e;
|
|
291
|
+
}), o.value && e.handlers.set(r);
|
|
220
292
|
}, { immediate: !0 }), b([n, () => i().data], ([e, t]) => {
|
|
221
|
-
if (!
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
w(t, a.lastRenderedData) || (a.lastRenderedData = t, a.renderChain = a.renderChain.catch(() => void 0).then(() => e.render(O(v(t)))));
|
|
293
|
+
if (!e || t === void 0) return;
|
|
294
|
+
if (a.seededEditor !== e) {
|
|
295
|
+
a.seededEditor = e, a.lastRenderedData = t;
|
|
296
|
+
return;
|
|
227
297
|
}
|
|
298
|
+
let n = a.lastRenderedData;
|
|
299
|
+
n !== void 0 && te(t, n) || (a.lastRenderedData = t, a.renderChain = a.renderChain.catch(() => void 0).then(() => e.render(ne(v(t)))));
|
|
228
300
|
}, { immediate: !0 }), t !== void 0 && b(() => y(t), () => {
|
|
229
|
-
|
|
230
|
-
}), d(
|
|
301
|
+
u(), f();
|
|
302
|
+
}), d(f), l(u), n;
|
|
231
303
|
}
|
|
232
304
|
//#endregion
|
|
233
305
|
//#region src/useBlocks.ts
|
|
234
|
-
var
|
|
235
|
-
function
|
|
306
|
+
var Z = "block changed";
|
|
307
|
+
function ce(e) {
|
|
236
308
|
let t = _(0), n = () => {
|
|
237
309
|
let t = y(e);
|
|
238
310
|
return t === null ? null : v(t);
|
|
239
311
|
}, r = () => {
|
|
240
312
|
t.value;
|
|
241
|
-
}, i = _(
|
|
313
|
+
}, i = _(C), a = {
|
|
242
314
|
editor: null,
|
|
243
315
|
handler: null
|
|
244
316
|
}, o = () => {
|
|
245
|
-
a.editor !== null && a.handler !== null && a.editor.off(
|
|
317
|
+
a.editor !== null && a.handler !== null && a.editor.off(Z, a.handler), a.editor = null, a.handler = null;
|
|
246
318
|
};
|
|
247
319
|
return b(() => n(), (e) => {
|
|
248
320
|
if (o(), t.value += 1, e === null) {
|
|
249
|
-
i.value =
|
|
321
|
+
i.value = C;
|
|
250
322
|
return;
|
|
251
323
|
}
|
|
252
324
|
let n = () => {
|
|
253
325
|
t.value += 1;
|
|
254
326
|
};
|
|
255
|
-
e.on(
|
|
327
|
+
e.on(Z, n), a.editor = e, a.handler = n, i.value = w(e, r);
|
|
256
328
|
}, { immediate: !0 }), f(o), {
|
|
257
329
|
getById: (e) => i.value.getById(e),
|
|
258
330
|
getChildren: (e) => i.value.getChildren(e),
|
|
@@ -287,7 +359,7 @@ function Z(e) {
|
|
|
287
359
|
}
|
|
288
360
|
//#endregion
|
|
289
361
|
//#region src/useBlokReady.ts
|
|
290
|
-
function
|
|
362
|
+
function le(e = {}) {
|
|
291
363
|
let { within: t, settleOn: n } = e, r = _(!1), i = () => {
|
|
292
364
|
var e;
|
|
293
365
|
let i = t === void 0 || (e = y(t)) == null ? null : e;
|
|
@@ -300,7 +372,7 @@ function ne(e = {}) {
|
|
|
300
372
|
}
|
|
301
373
|
//#endregion
|
|
302
374
|
//#region src/BlockPortalHost.ts
|
|
303
|
-
var
|
|
375
|
+
var ue = r({
|
|
304
376
|
name: "BlockErrorBoundary",
|
|
305
377
|
setup(e, { slots: t }) {
|
|
306
378
|
return u(() => !1), () => {
|
|
@@ -308,7 +380,7 @@ var re = r({
|
|
|
308
380
|
return (e = t.default) == null ? void 0 : e.call(t);
|
|
309
381
|
};
|
|
310
382
|
}
|
|
311
|
-
}),
|
|
383
|
+
}), de = r({
|
|
312
384
|
name: "BlockPortalHost",
|
|
313
385
|
props: { registry: {
|
|
314
386
|
type: Object,
|
|
@@ -318,35 +390,43 @@ var re = r({
|
|
|
318
390
|
return () => a(e, Array.from(n.registry.entries.entries()).map(([e, n]) => a(t, {
|
|
319
391
|
key: e,
|
|
320
392
|
to: n.hostEl
|
|
321
|
-
}, [a(
|
|
393
|
+
}, [a(ue, null, { default: () => a(n.component, n.props) })])));
|
|
322
394
|
}
|
|
323
|
-
}),
|
|
395
|
+
}), Q = Symbol("BLOK_EDITOR_INSTANCE"), fe = _(null);
|
|
396
|
+
function pe() {
|
|
397
|
+
return o(Q, fe);
|
|
398
|
+
}
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/BlokContent.ts
|
|
401
|
+
var $ = r({
|
|
324
402
|
name: "BlokContent",
|
|
325
403
|
props: { editor: {
|
|
326
404
|
type: Object,
|
|
327
405
|
default: null
|
|
328
406
|
} },
|
|
329
407
|
setup(e) {
|
|
330
|
-
let t = g(null)
|
|
408
|
+
let t = g(null);
|
|
409
|
+
m(Q, n(() => e.editor === null ? null : v(e.editor)));
|
|
410
|
+
let r = (e) => {
|
|
331
411
|
if (t.value === null || e === null) return;
|
|
332
|
-
let n =
|
|
412
|
+
let n = P(v(e));
|
|
333
413
|
n !== void 0 && t.value.appendChild(n);
|
|
334
|
-
},
|
|
414
|
+
}, i = (e) => {
|
|
335
415
|
var t;
|
|
336
|
-
e !== null && ((t =
|
|
416
|
+
e !== null && ((t = P(v(e))) == null || t.remove());
|
|
337
417
|
};
|
|
338
418
|
return d(() => {
|
|
339
|
-
|
|
419
|
+
r(e.editor);
|
|
340
420
|
}), b(() => e.editor, (e, t) => {
|
|
341
|
-
|
|
421
|
+
i(t == null ? null : t), r(e);
|
|
342
422
|
}), l(() => {
|
|
343
|
-
|
|
423
|
+
i(e.editor);
|
|
344
424
|
}), () => {
|
|
345
|
-
let n = e.editor, r = n === null ? void 0 :
|
|
346
|
-
return a("div", { ref: t }, r === void 0 ? [] : [a(
|
|
425
|
+
let n = e.editor, r = n === null ? void 0 : J(v(n));
|
|
426
|
+
return a("div", { ref: t }, r === void 0 ? [] : [a(de, { registry: r })]);
|
|
347
427
|
};
|
|
348
428
|
}
|
|
349
|
-
}),
|
|
429
|
+
}), me = /* @__PURE__ */ "autofocus.defaultBlock.dataModel.placeholder.sanitizer.hideToolbar.maxHistoryLength.historyDebounceTime.newGroupDelay.globalUndoRedo.tools.data.minHeight.logLevel.readOnly.i18n.link.linkPaste.inlineToolbar.tunes.style.theme.scrollToBlock.user.resolveUser.notifierPosition.notifier.width.onBeforeRender.onBeforePaste.onEnter.onSubmit.onError.migrations.uploader.captureClicksBelowEditor".split("."), he = r({
|
|
350
430
|
name: "BlokEditor",
|
|
351
431
|
inheritAttrs: !1,
|
|
352
432
|
props: {
|
|
@@ -490,6 +570,10 @@ var re = r({
|
|
|
490
570
|
type: Object,
|
|
491
571
|
default: void 0
|
|
492
572
|
},
|
|
573
|
+
captureClicksBelowEditor: {
|
|
574
|
+
type: Boolean,
|
|
575
|
+
default: void 0
|
|
576
|
+
},
|
|
493
577
|
recreateKey: { type: null }
|
|
494
578
|
},
|
|
495
579
|
emits: {
|
|
@@ -503,36 +587,40 @@ var re = r({
|
|
|
503
587
|
"block-rendered": (e) => !0
|
|
504
588
|
},
|
|
505
589
|
setup(e, { emit: t, expose: r, attrs: o }) {
|
|
506
|
-
let s = i(), c = (
|
|
507
|
-
let
|
|
508
|
-
return
|
|
509
|
-
}, l = ()
|
|
590
|
+
let s = i(), c = () => {
|
|
591
|
+
let e = s == null ? void 0 : s.vnode.props;
|
|
592
|
+
return e == null ? "" : Object.keys(e).filter((e) => e.startsWith("on")).sort().join("|");
|
|
593
|
+
}, l = g(c());
|
|
594
|
+
p(() => {
|
|
595
|
+
l.value = c();
|
|
596
|
+
});
|
|
597
|
+
let u = (e) => l.value.split("|").includes(e), d = () => {
|
|
510
598
|
let n = {};
|
|
511
|
-
for (let t of
|
|
599
|
+
for (let t of me) {
|
|
512
600
|
let r = e[t];
|
|
513
601
|
r !== void 0 && (n[t] = r);
|
|
514
602
|
}
|
|
515
|
-
return
|
|
603
|
+
return u("onChange") && (n.onChange = (e, n) => {
|
|
516
604
|
t("change", {
|
|
517
605
|
api: e,
|
|
518
606
|
event: n
|
|
519
607
|
});
|
|
520
|
-
}), (
|
|
608
|
+
}), (u("onSave") || u("onUpdate:data")) && (n.onSave = (e) => {
|
|
521
609
|
t("update:data", e), t("save", e);
|
|
522
|
-
}),
|
|
610
|
+
}), u("onAfterRender") && (n.onAfterRender = (e) => {
|
|
523
611
|
t("after-render", e);
|
|
524
|
-
}),
|
|
612
|
+
}), u("onThemeChange") && (n.onThemeChange = (e) => {
|
|
525
613
|
t("theme-change", e);
|
|
526
614
|
}), n;
|
|
527
|
-
},
|
|
528
|
-
b(
|
|
615
|
+
}, f = X(() => d(), () => e.recreateKey);
|
|
616
|
+
b([f, l], ([e], n, r) => {
|
|
529
617
|
if (e === null) return;
|
|
530
618
|
let i = [];
|
|
531
|
-
if (
|
|
619
|
+
if (u("onBlocksRendered")) {
|
|
532
620
|
let n = (e) => t("blocks-rendered", e);
|
|
533
621
|
e.on("blocks:rendered", n), i.push(["blocks:rendered", n]);
|
|
534
622
|
}
|
|
535
|
-
if (
|
|
623
|
+
if (u("onBlockRendered")) {
|
|
536
624
|
let n = (e) => t("block-rendered", e);
|
|
537
625
|
e.on("block:rendered", n), i.push(["block:rendered", n]);
|
|
538
626
|
}
|
|
@@ -540,41 +628,87 @@ var re = r({
|
|
|
540
628
|
for (let [t, n] of i) e.off(t, n);
|
|
541
629
|
});
|
|
542
630
|
});
|
|
543
|
-
let
|
|
544
|
-
return b(
|
|
545
|
-
e !== null && e !==
|
|
631
|
+
let m = { last: null };
|
|
632
|
+
return b(f, (e) => {
|
|
633
|
+
e !== null && e !== m.last && (m.last = e, t("ready", e));
|
|
546
634
|
}), r({
|
|
547
|
-
instance: n(() =>
|
|
635
|
+
instance: n(() => f.value),
|
|
548
636
|
save: () => {
|
|
549
637
|
var e;
|
|
550
|
-
return (e =
|
|
638
|
+
return (e = f.value) == null ? void 0 : e.save();
|
|
551
639
|
},
|
|
552
640
|
focus: (e) => {
|
|
553
641
|
var t;
|
|
554
|
-
(t =
|
|
642
|
+
(t = f.value) == null || t.focus(e);
|
|
555
643
|
},
|
|
556
644
|
render: (e) => {
|
|
557
|
-
|
|
558
|
-
|
|
645
|
+
let t = f.value;
|
|
646
|
+
if (t !== null) return t.render(e).then(() => {
|
|
647
|
+
var n;
|
|
648
|
+
(n = re(t)) == null || n.markRendered(e);
|
|
649
|
+
});
|
|
559
650
|
}
|
|
560
|
-
}), () => a($,
|
|
651
|
+
}), () => a($, z({ editor: f.value }, o));
|
|
561
652
|
}
|
|
562
|
-
})
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
653
|
+
}), ge = [
|
|
654
|
+
"toolbox",
|
|
655
|
+
"isReadOnlySupported",
|
|
656
|
+
"__isBlokVueBlock"
|
|
657
|
+
], _e = /* @__PURE__ */ new Set([
|
|
658
|
+
void 0,
|
|
659
|
+
"user",
|
|
660
|
+
"api",
|
|
661
|
+
"convert"
|
|
662
|
+
]), ve = (e, t, n) => {
|
|
663
|
+
let r = /* @__PURE__ */ new Map();
|
|
664
|
+
t.forEach((e, t) => {
|
|
665
|
+
var i;
|
|
666
|
+
let a = [];
|
|
667
|
+
for (let [r, o] of Object.entries((i = n == null ? void 0 : n(e, t)) == null ? {} : i)) {
|
|
668
|
+
if (o == null) {
|
|
669
|
+
e.holder.removeAttribute(r);
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
672
|
+
e.holder.setAttribute(r, String(o)), a.push(r);
|
|
673
|
+
}
|
|
674
|
+
r.set(e.id, {
|
|
675
|
+
holder: e.holder,
|
|
676
|
+
names: a
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
for (let [t, n] of e) {
|
|
680
|
+
let e = r.get(t);
|
|
681
|
+
n.names.filter((t) => e === void 0 || !e.names.includes(t)).forEach((e) => n.holder.removeAttribute(e));
|
|
682
|
+
}
|
|
683
|
+
e.clear(), r.forEach((t, n) => e.set(n, t));
|
|
684
|
+
}, ye = (e, t, n) => {
|
|
685
|
+
var r;
|
|
686
|
+
e == null || (r = e.events) == null || r.emit(ee, {
|
|
687
|
+
blockId: t,
|
|
688
|
+
childIds: n.map((e) => e.id)
|
|
689
|
+
});
|
|
690
|
+
};
|
|
691
|
+
function be(e) {
|
|
692
|
+
var t, n;
|
|
693
|
+
let i = () => r({
|
|
568
694
|
name: `VueBlock(${e.type})`,
|
|
569
|
-
props: {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
695
|
+
props: {
|
|
696
|
+
ctx: {
|
|
697
|
+
type: Object,
|
|
698
|
+
required: !0
|
|
699
|
+
},
|
|
700
|
+
notifyMounted: {
|
|
701
|
+
type: Function,
|
|
702
|
+
default: void 0
|
|
703
|
+
}
|
|
704
|
+
},
|
|
573
705
|
setup(t) {
|
|
574
|
-
return
|
|
706
|
+
return d(() => {
|
|
707
|
+
var e;
|
|
708
|
+
return (e = t.notifyMounted) == null ? void 0 : e.call(t);
|
|
709
|
+
}), e.setup(t.ctx);
|
|
575
710
|
}
|
|
576
|
-
})
|
|
577
|
-
return t = class {
|
|
711
|
+
}), o = (t = class {
|
|
578
712
|
static get toolbox() {
|
|
579
713
|
return e.toolbox;
|
|
580
714
|
}
|
|
@@ -582,28 +716,46 @@ function oe(e) {
|
|
|
582
716
|
return !0;
|
|
583
717
|
}
|
|
584
718
|
constructor(t) {
|
|
585
|
-
var n,
|
|
586
|
-
this.hostEl = null, this.pendingDispatch = !1, this.
|
|
587
|
-
|
|
588
|
-
|
|
719
|
+
var n, o, s;
|
|
720
|
+
this.wrappedComponent = i(), this.mountSignalled = !1, this.hostEl = null, this.pendingDispatch = !1, this.notifyMounted = () => {
|
|
721
|
+
var t;
|
|
722
|
+
if (this.mountSignalled) return;
|
|
723
|
+
this.mountSignalled = !0;
|
|
724
|
+
let n = {
|
|
725
|
+
origin: this.origin,
|
|
726
|
+
api: this.api
|
|
727
|
+
};
|
|
728
|
+
if ((t = e.onMounted) == null || t.call(e, this.blockApi, n), _e.has(this.origin)) {
|
|
729
|
+
var r;
|
|
730
|
+
(r = e.onCreated) == null || r.call(e, this.blockApi, n);
|
|
731
|
+
}
|
|
732
|
+
}, this.commit = (t) => {
|
|
733
|
+
let n = E(e.propSchema, z(z({}, this.mirror), t));
|
|
734
|
+
T(n, this.mirror) || (this.mirror = n, this.lastRendered = n, this.dataRef.value = n, this.flushDispatch());
|
|
589
735
|
}, this.blockApi = t.block;
|
|
590
|
-
let
|
|
591
|
-
this.registry =
|
|
592
|
-
let
|
|
736
|
+
let c = (n = t.config) == null ? {} : n;
|
|
737
|
+
this.registry = c[W], this.api = t.api;
|
|
738
|
+
let l = t.api;
|
|
593
739
|
this.pointerDrag = () => {
|
|
594
740
|
var e;
|
|
595
|
-
return (
|
|
596
|
-
}, this.mirror =
|
|
597
|
-
let
|
|
741
|
+
return (l == null || (e = l.blocks) == null ? void 0 : e.isPointerDragActive) === !0;
|
|
742
|
+
}, this.mirror = E(e.propSchema, v((o = t.data) == null ? {} : o)), this.lastRendered = this.mirror, this.dataRef = _(this.mirror), this.readOnlyRef = _(t.readOnly), this.origin = (s = t.origin) == null ? "api" : s;
|
|
743
|
+
let u = this.blockApi, f = this.api;
|
|
598
744
|
this.childrenComponent = r({
|
|
599
745
|
name: `VueBlockChildren(${e.type})`,
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
746
|
+
props: { childAttributes: {
|
|
747
|
+
type: Function,
|
|
748
|
+
default: void 0
|
|
749
|
+
} },
|
|
750
|
+
setup(e) {
|
|
751
|
+
let t = g(null), n = /* @__PURE__ */ new Map(), r = () => {
|
|
752
|
+
if (t.value === null) return;
|
|
753
|
+
let r = u.getChildren();
|
|
754
|
+
D(t.value, r), ve(n, r, e.childAttributes), ye(f, u.id, r);
|
|
603
755
|
};
|
|
604
|
-
return d(
|
|
605
|
-
ref:
|
|
606
|
-
[
|
|
756
|
+
return d(r), p(r), () => a("div", {
|
|
757
|
+
ref: t,
|
|
758
|
+
[S.nestedBlocks]: ""
|
|
607
759
|
});
|
|
608
760
|
}
|
|
609
761
|
});
|
|
@@ -612,17 +764,21 @@ function oe(e) {
|
|
|
612
764
|
var e;
|
|
613
765
|
let t = document.createElement("div");
|
|
614
766
|
t.setAttribute("data-blok-mutation-free", "true"), this.hostEl = t;
|
|
615
|
-
let
|
|
767
|
+
let n = {
|
|
616
768
|
data: this.dataRef,
|
|
617
769
|
commit: this.commit,
|
|
618
770
|
block: this.blockApi,
|
|
771
|
+
api: this.api,
|
|
619
772
|
readOnly: this.readOnlyRef,
|
|
620
773
|
BlockChildren: this.childrenComponent
|
|
621
774
|
};
|
|
622
775
|
return (e = this.registry) == null || e.register(this.blockApi.id, {
|
|
623
776
|
hostEl: t,
|
|
624
|
-
component:
|
|
625
|
-
props: {
|
|
777
|
+
component: this.wrappedComponent,
|
|
778
|
+
props: {
|
|
779
|
+
ctx: n,
|
|
780
|
+
notifyMounted: this.notifyMounted
|
|
781
|
+
}
|
|
626
782
|
}), t;
|
|
627
783
|
}
|
|
628
784
|
rendered() {
|
|
@@ -634,23 +790,28 @@ function oe(e) {
|
|
|
634
790
|
}
|
|
635
791
|
async setData(t) {
|
|
636
792
|
var n = this;
|
|
637
|
-
let r =
|
|
638
|
-
return
|
|
793
|
+
let r = E(e.propSchema, v(t == null ? {} : t));
|
|
794
|
+
return T(r, n.lastRendered) ? !0 : (n.mirror = r, n.lastRendered = r, n.dataRef.value = r, await c(), !0);
|
|
639
795
|
}
|
|
640
796
|
setReadOnly(e) {
|
|
641
797
|
this.readOnlyRef.value = e;
|
|
642
798
|
}
|
|
799
|
+
getToolbarAnchorElement() {
|
|
800
|
+
var t;
|
|
801
|
+
let n = this.hostEl;
|
|
802
|
+
if (!(n === null || e.getToolbarAnchorElement === void 0)) return (t = e.getToolbarAnchorElement(n, this.blockApi)) == null ? void 0 : t;
|
|
803
|
+
}
|
|
643
804
|
moved() {
|
|
644
805
|
var t;
|
|
645
806
|
(t = e.onMoved) == null || t.call(e, this.blockApi);
|
|
646
807
|
}
|
|
647
808
|
removed() {
|
|
648
|
-
var t, n;
|
|
649
|
-
(t = this.registry) == null || t.unregister(this.blockApi.id
|
|
809
|
+
var t, n, r;
|
|
810
|
+
(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);
|
|
650
811
|
}
|
|
651
812
|
destroy() {
|
|
652
|
-
var e;
|
|
653
|
-
(e = this.registry) == null || e.unregister(this.blockApi.id);
|
|
813
|
+
var e, t;
|
|
814
|
+
(e = this.registry) == null || e.unregister(this.blockApi.id, (t = this.hostEl) == null ? void 0 : t);
|
|
654
815
|
}
|
|
655
816
|
flushDispatch() {
|
|
656
817
|
if (!this.pointerDrag()) {
|
|
@@ -668,7 +829,14 @@ function oe(e) {
|
|
|
668
829
|
};
|
|
669
830
|
requestAnimationFrame(e);
|
|
670
831
|
}
|
|
671
|
-
}, t.__isBlokVueBlock = !0, t;
|
|
832
|
+
}, t.__isBlokVueBlock = !0, t);
|
|
833
|
+
for (let [t, r] of Object.entries((n = e.statics) == null ? {} : n)) ge.includes(t) || Object.defineProperty(o, t, {
|
|
834
|
+
value: r,
|
|
835
|
+
writable: !0,
|
|
836
|
+
enumerable: !0,
|
|
837
|
+
configurable: !0
|
|
838
|
+
});
|
|
839
|
+
return o;
|
|
672
840
|
}
|
|
673
841
|
//#endregion
|
|
674
|
-
export {
|
|
842
|
+
export { B as BLOK_DEFAULT_CONFIG, Q as BLOK_EDITOR_INSTANCE, $ as BlokContent, he as BlokEditor, be as createVueBlock, V as provideBlok, ce as useBlocks, X as useBlok, H as useBlokDefaults, pe as useBlokInstance, le as useBlokReady };
|