@jackuait/blok 0.6.0-beta.7 → 0.6.0-beta.9
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/blok.mjs +2 -2
- package/dist/chunks/{blok-Bjkxis7j.mjs → blok-Bn6Q_o8h.mjs} +127 -114
- package/dist/chunks/{i18next-loader-D-sjerXt.mjs → i18next-loader-DjR4d8M7.mjs} +1 -1
- package/dist/chunks/{index-CJfN4Vuv.mjs → index-oe38cp86.mjs} +1 -1
- package/dist/chunks/{inline-tool-convert-5DE7c2fi.mjs → inline-tool-convert-SRTkyaZn.mjs} +1 -1
- package/dist/full.mjs +2 -2
- package/dist/tools.mjs +43 -39
- package/package.json +1 -1
- package/src/components/modules/api/blocks.ts +18 -0
- package/src/components/modules/rectangleSelection.ts +3 -4
- package/src/components/modules/toolbar/index.ts +21 -20
- package/src/tools/paragraph/index.ts +6 -2
- package/src/tools/table/table-cell-blocks.ts +6 -0
- package/types/api/blocks.d.ts +8 -0
package/dist/blok.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as s, v as a } from "./chunks/blok-
|
|
2
|
-
import { D as A } from "./chunks/inline-tool-convert-
|
|
1
|
+
import { B as s, v as a } from "./chunks/blok-Bn6Q_o8h.mjs";
|
|
2
|
+
import { D as A } from "./chunks/inline-tool-convert-SRTkyaZn.mjs";
|
|
3
3
|
export {
|
|
4
4
|
s as Blok,
|
|
5
5
|
A as DATA_ATTR,
|
|
@@ -20,7 +20,7 @@ var Eo = (s, t) => {
|
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
22
|
var Ie = (s, t, e) => Io(s, typeof t != "symbol" ? t + "" : t, e);
|
|
23
|
-
import { L as uo, l as C, c as Qi, i as z, a as k, S as w, D as y, t as O, b as I, P as G, E as yn, g as wt, d as tl, e as gr, f as $e, h as
|
|
23
|
+
import { L as uo, l as C, c as Qi, i as z, a as k, S as w, D as y, t as O, b as I, P as G, E as yn, g as wt, d as tl, e as gr, f as $e, h as ot, j as A, k as le, m as Ut, n as kr, s as el, o as po, p as Bn, q as wn, r as T, u as Vo, v as hs, F as ae, w as Wo, x as ds, y as us, z as ut, A as ol, B as nl, C as sl, I as rl, G as Xo, H as Ke, J as ce, K as Mt, M as br, N as Ot, O as K, Q as Ht, R as il, T as ll, U as ps, V as al, W as cl, X as hl, Y as dl, Z as ul, _ as mr, $ as pl, a0 as yr, a1 as Br, a2 as Ct, a3 as fl, a4 as wr, a5 as vr, a6 as gl, a7 as kl, a8 as bl, a9 as ml, aa as yl, ab as Bl, ac as fs, ad as xr, ae as wl, af as vl, ag as xl, ah as Tl, ai as Sl, aj as Cl, ak as Il, al as El } from "./inline-tool-convert-SRTkyaZn.mjs";
|
|
24
24
|
function Ml(s) {
|
|
25
25
|
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
|
|
26
26
|
}
|
|
@@ -928,7 +928,7 @@ class jl {
|
|
|
928
928
|
});
|
|
929
929
|
}
|
|
930
930
|
}
|
|
931
|
-
var
|
|
931
|
+
var st = /* @__PURE__ */ ((s) => (s.RENDERED = "rendered", s.MOVED = "moved", s.UPDATED = "updated", s.REMOVED = "removed", s.ON_PASTE = "onPaste", s))(st || {});
|
|
932
932
|
class vn extends yn {
|
|
933
933
|
/**
|
|
934
934
|
* @param options - block constructor options
|
|
@@ -1411,6 +1411,7 @@ class Ul extends x {
|
|
|
1411
1411
|
update: this.update,
|
|
1412
1412
|
composeBlockData: this.composeBlockData,
|
|
1413
1413
|
convert: this.convert,
|
|
1414
|
+
setBlockParent: (t, e) => this.setBlockParent(t, e),
|
|
1414
1415
|
stopBlockMutationWatching: (t) => this.stopBlockMutationWatching(t),
|
|
1415
1416
|
splitBlock: this.splitBlock
|
|
1416
1417
|
};
|
|
@@ -1436,7 +1437,7 @@ class Ul extends x {
|
|
|
1436
1437
|
getBlockIndex(t) {
|
|
1437
1438
|
const e = this.Blok.BlockManager.getBlockById(t);
|
|
1438
1439
|
if (!e) {
|
|
1439
|
-
|
|
1440
|
+
ot("There is no block with id `" + t + "`", "warn");
|
|
1440
1441
|
return;
|
|
1441
1442
|
}
|
|
1442
1443
|
return this.Blok.BlockManager.getBlockIndex(e);
|
|
@@ -1448,7 +1449,7 @@ class Ul extends x {
|
|
|
1448
1449
|
getBlockByIndex(t) {
|
|
1449
1450
|
const e = this.Blok.BlockManager.getBlockByIndex(t);
|
|
1450
1451
|
if (e === void 0) {
|
|
1451
|
-
|
|
1452
|
+
ot("There is no block at index `" + t + "`", "warn");
|
|
1452
1453
|
return;
|
|
1453
1454
|
}
|
|
1454
1455
|
return new et(e);
|
|
@@ -1459,7 +1460,7 @@ class Ul extends x {
|
|
|
1459
1460
|
*/
|
|
1460
1461
|
getById(t) {
|
|
1461
1462
|
const e = this.Blok.BlockManager.getBlockById(t);
|
|
1462
|
-
return e === void 0 ? (
|
|
1463
|
+
return e === void 0 ? (ot("There is no block with id `" + t + "`", "warn"), null) : new et(e);
|
|
1463
1464
|
}
|
|
1464
1465
|
/**
|
|
1465
1466
|
* Get Block API object by any child html element
|
|
@@ -1469,7 +1470,7 @@ class Ul extends x {
|
|
|
1469
1470
|
var o, n;
|
|
1470
1471
|
const e = this.Blok.BlockManager.getBlock(t);
|
|
1471
1472
|
if (e === void 0) {
|
|
1472
|
-
|
|
1473
|
+
ot(`There is no block corresponding to element <${(n = (o = t.tagName) == null ? void 0 : o.toLowerCase()) != null ? n : "unknown"}>`, "warn");
|
|
1473
1474
|
return;
|
|
1474
1475
|
}
|
|
1475
1476
|
return new et(e);
|
|
@@ -1498,13 +1499,13 @@ class Ul extends x {
|
|
|
1498
1499
|
async delete(t = this.Blok.BlockManager.currentBlockIndex) {
|
|
1499
1500
|
const e = this.Blok.BlockManager.getBlockByIndex(t);
|
|
1500
1501
|
if (e === void 0) {
|
|
1501
|
-
|
|
1502
|
+
ot(`There is no block at index \`${t}\``, "warn");
|
|
1502
1503
|
return;
|
|
1503
1504
|
}
|
|
1504
1505
|
try {
|
|
1505
1506
|
await this.Blok.BlockManager.removeBlock(e);
|
|
1506
1507
|
} catch (o) {
|
|
1507
|
-
|
|
1508
|
+
ot(o, "warn");
|
|
1508
1509
|
return;
|
|
1509
1510
|
}
|
|
1510
1511
|
this.Blok.BlockManager.blocks.length === 0 && this.Blok.BlockManager.insert(), this.Blok.BlockManager.currentBlock && this.Blok.Caret.setToBlock(this.Blok.BlockManager.currentBlock, this.Blok.Caret.positions.END), this.Blok.Toolbar.close();
|
|
@@ -1532,6 +1533,19 @@ class Ul extends x {
|
|
|
1532
1533
|
async renderFromHTML(t) {
|
|
1533
1534
|
return await this.Blok.BlockManager.clear(), this.Blok.Paste.processText(t, !0);
|
|
1534
1535
|
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Sets the parent of a block, updating both the block's parentId and the parent's contentIds.
|
|
1538
|
+
* @param blockId - id of the block to reparent
|
|
1539
|
+
* @param parentId - id of the new parent block, or null for root level
|
|
1540
|
+
*/
|
|
1541
|
+
setBlockParent(t, e) {
|
|
1542
|
+
const o = this.Blok.BlockManager.getBlockById(t);
|
|
1543
|
+
if (o === void 0) {
|
|
1544
|
+
ot("There is no block with id `" + t + "`", "warn");
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
this.Blok.BlockManager.setBlockParent(o, e);
|
|
1548
|
+
}
|
|
1535
1549
|
/**
|
|
1536
1550
|
* Stops mutation watching on a block at the specified index.
|
|
1537
1551
|
* This is used to prevent spurious block-changed events during block replacement.
|
|
@@ -1783,7 +1797,7 @@ class ql {
|
|
|
1783
1797
|
* @returns {Promise<NotifierModule>} loaded notifier module
|
|
1784
1798
|
*/
|
|
1785
1799
|
loadNotifierModule() {
|
|
1786
|
-
return this.notifierModule !== null ? Promise.resolve(this.notifierModule) : (this.loadingPromise === null && (this.loadingPromise = import("./index-
|
|
1800
|
+
return this.notifierModule !== null ? Promise.resolve(this.notifierModule) : (this.loadingPromise === null && (this.loadingPromise = import("./index-oe38cp86.mjs").then((t) => {
|
|
1787
1801
|
const e = t;
|
|
1788
1802
|
if (!this.isNotifierModule(e))
|
|
1789
1803
|
throw new Error('notifier module does not expose a "show" method.');
|
|
@@ -1919,7 +1933,7 @@ function ta() {
|
|
|
1919
1933
|
}
|
|
1920
1934
|
var b = i(f), g;
|
|
1921
1935
|
b && (g = Array.prototype.some.call(f.childNodes, n));
|
|
1922
|
-
var m = !!u.parentNode, v = n(u) && n(f) && m,
|
|
1936
|
+
var m = !!u.parentNode, v = n(u) && n(f) && m, S = f.nodeName.toLowerCase(), L = a(this.config, S, f), Q = b && g;
|
|
1923
1937
|
if (Q || c(f, L) || !this.config.keepNestedBlockElements && v) {
|
|
1924
1938
|
if (!(f.nodeName === "SCRIPT" || f.nodeName === "STYLE"))
|
|
1925
1939
|
for (; f.childNodes.length > 0; )
|
|
@@ -2140,7 +2154,7 @@ class ba extends x {
|
|
|
2140
2154
|
var r, i;
|
|
2141
2155
|
const t = "Blok's content can not be saved in read-only mode";
|
|
2142
2156
|
if (this.Blok.ReadOnly.isEnabled)
|
|
2143
|
-
throw
|
|
2157
|
+
throw ot(t, "warn"), new Error(t);
|
|
2144
2158
|
const e = await this.Blok.Saver.save();
|
|
2145
2159
|
if (e !== void 0)
|
|
2146
2160
|
return e;
|
|
@@ -2268,7 +2282,7 @@ class Ba extends x {
|
|
|
2268
2282
|
*/
|
|
2269
2283
|
toggleBlockSettings(t) {
|
|
2270
2284
|
if (this.Blok.BlockManager.currentBlockIndex === -1) {
|
|
2271
|
-
|
|
2285
|
+
ot("Could't toggle the Toolbar because there is no block selected ", "warn");
|
|
2272
2286
|
return;
|
|
2273
2287
|
}
|
|
2274
2288
|
(t != null ? t : !this.Blok.BlockSettings.opened) ? (this.Blok.Toolbar.moveAndOpen(), this.Blok.BlockSettings.open()) : this.Blok.BlockSettings.close();
|
|
@@ -2279,7 +2293,7 @@ class Ba extends x {
|
|
|
2279
2293
|
*/
|
|
2280
2294
|
toggleToolbox(t) {
|
|
2281
2295
|
if (this.Blok.BlockManager.currentBlockIndex === -1) {
|
|
2282
|
-
|
|
2296
|
+
ot("Could't toggle the Toolbox because there is no block selected ", "warn");
|
|
2283
2297
|
return;
|
|
2284
2298
|
}
|
|
2285
2299
|
(t != null ? t : !this.Blok.Toolbar.toolbox.opened) ? (this.Blok.Toolbar.moveAndOpen(), this.Blok.Toolbar.toolbox.open()) : this.Blok.Toolbar.toolbox.close();
|
|
@@ -4393,8 +4407,8 @@ class Ih extends Ir {
|
|
|
4393
4407
|
c ? this.stopCapturing() : h || this.clear(!1, !0);
|
|
4394
4408
|
const u = new Hn();
|
|
4395
4409
|
a.afterState.forEach((g, m) => {
|
|
4396
|
-
const v = a.beforeState.get(m) || 0,
|
|
4397
|
-
|
|
4410
|
+
const v = a.beforeState.get(m) || 0, S = g - v;
|
|
4411
|
+
S > 0 && jn(u, m, v, S);
|
|
4398
4412
|
});
|
|
4399
4413
|
const p = ec();
|
|
4400
4414
|
let f = !1;
|
|
@@ -8985,14 +8999,14 @@ class Pi extends x {
|
|
|
8985
8999
|
}
|
|
8986
9000
|
}
|
|
8987
9001
|
const tr = {
|
|
8988
|
-
Backspace:
|
|
8989
|
-
Delete:
|
|
8990
|
-
Enter:
|
|
8991
|
-
Tab:
|
|
8992
|
-
ArrowDown:
|
|
8993
|
-
ArrowRight:
|
|
8994
|
-
ArrowUp:
|
|
8995
|
-
ArrowLeft:
|
|
9002
|
+
Backspace: T.BACKSPACE,
|
|
9003
|
+
Delete: T.DELETE,
|
|
9004
|
+
Enter: T.ENTER,
|
|
9005
|
+
Tab: T.TAB,
|
|
9006
|
+
ArrowDown: T.DOWN,
|
|
9007
|
+
ArrowRight: T.RIGHT,
|
|
9008
|
+
ArrowUp: T.UP,
|
|
9009
|
+
ArrowLeft: T.LEFT
|
|
8996
9010
|
}, pd = /* @__PURE__ */ new Set(["Enter", "Process", "Spacebar", "Space", "Dead"]), De = '[contenteditable="true"], textarea, input', Pt = "list", er = "header", fd = /^\[(x|X| )?\]\s([\s\S]*)$/, gd = /^[-*]\s([\s\S]*)$/, kd = /^(\d+)[.)]\s([\s\S]*)$/, bd = /^(#{1,6})\s([\s\S]*)$/;
|
|
8997
9011
|
class Co {
|
|
8998
9012
|
constructor(t) {
|
|
@@ -9238,31 +9252,31 @@ class yd extends Co {
|
|
|
9238
9252
|
const e = so(t);
|
|
9239
9253
|
if (e === null || or(t, "down"))
|
|
9240
9254
|
return;
|
|
9241
|
-
const o = ae.usedKeys.includes(e) && (!t.shiftKey || e ===
|
|
9255
|
+
const o = ae.usedKeys.includes(e) && (!t.shiftKey || e === T.TAB);
|
|
9242
9256
|
if (this.Blok.UI.someToolbarOpened && o)
|
|
9243
9257
|
return;
|
|
9244
9258
|
t.shiftKey || (this.Blok.Toolbar.close(), this.Blok.InlineToolbar.close());
|
|
9245
9259
|
const n = w.get();
|
|
9246
9260
|
n != null && n.anchorNode && !this.Blok.BlockSelection.anyBlockSelected && this.Blok.BlockManager.setCurrentBlockByChildNode(n.anchorNode);
|
|
9247
9261
|
const { currentBlock: r } = this.Blok.BlockManager, i = t.target, l = document.activeElement instanceof HTMLElement ? document.activeElement : null, a = [
|
|
9248
|
-
r == null ? void 0 : r.inputs.find((
|
|
9249
|
-
r == null ? void 0 : r.inputs.find((
|
|
9262
|
+
r == null ? void 0 : r.inputs.find((S) => i !== null && S.contains(i)),
|
|
9263
|
+
r == null ? void 0 : r.inputs.find((S) => l !== null && S.contains(l)),
|
|
9250
9264
|
i == null ? void 0 : i.closest(De),
|
|
9251
9265
|
l == null ? void 0 : l.closest(De)
|
|
9252
9266
|
], c = (v = r == null ? void 0 : r.currentInput) != null ? v : a.find(
|
|
9253
|
-
(
|
|
9254
|
-
), d = (c !== void 0 ? se(c) : void 0) || this.Blok.BlockSelection.anyBlockSelected, u = t.shiftKey && e ===
|
|
9267
|
+
(S) => S instanceof HTMLElement
|
|
9268
|
+
), d = (c !== void 0 ? se(c) : void 0) || this.Blok.BlockSelection.anyBlockSelected, u = t.shiftKey && e === T.DOWN;
|
|
9255
9269
|
if (u && d) {
|
|
9256
9270
|
this.Blok.CrossBlockSelection.toggleBlockSelectedState();
|
|
9257
9271
|
return;
|
|
9258
9272
|
}
|
|
9259
9273
|
u && this.Blok.InlineToolbar.tryToShow();
|
|
9260
|
-
const f = e ===
|
|
9274
|
+
const f = e === T.RIGHT && !t.shiftKey && !this.isRtl && c instanceof HTMLElement ? ud(c) : null;
|
|
9261
9275
|
if (f !== null) {
|
|
9262
9276
|
w.setCursor(f.node, f.offset), t.preventDefault();
|
|
9263
9277
|
return;
|
|
9264
9278
|
}
|
|
9265
|
-
const b = e ===
|
|
9279
|
+
const b = e === T.DOWN, g = e === T.RIGHT && !this.isRtl;
|
|
9266
9280
|
if (b ? this.Blok.Caret.navigateVerticalNext() : g ? this.Blok.Caret.navigateNext() : !1) {
|
|
9267
9281
|
t.preventDefault();
|
|
9268
9282
|
return;
|
|
@@ -9278,7 +9292,7 @@ class yd extends Co {
|
|
|
9278
9292
|
handleArrowLeftAndUp(t) {
|
|
9279
9293
|
var g;
|
|
9280
9294
|
const e = this.Blok.UI.someToolbarOpened, o = so(t);
|
|
9281
|
-
if (o === null || or(t, "up") || e && ae.usedKeys.includes(o) && (!t.shiftKey || o ===
|
|
9295
|
+
if (o === null || or(t, "up") || e && ae.usedKeys.includes(o) && (!t.shiftKey || o === T.TAB))
|
|
9282
9296
|
return;
|
|
9283
9297
|
e && this.Blok.UI.closeAllToolbars(), t.shiftKey || (this.Blok.Toolbar.close(), this.Blok.InlineToolbar.close());
|
|
9284
9298
|
const n = window.getSelection();
|
|
@@ -9290,13 +9304,13 @@ class yd extends Co {
|
|
|
9290
9304
|
l == null ? void 0 : l.closest(De)
|
|
9291
9305
|
], c = (g = r == null ? void 0 : r.currentInput) != null ? g : a.find(
|
|
9292
9306
|
(m) => m instanceof HTMLElement
|
|
9293
|
-
), d = (c !== void 0 ? Ue(c) : void 0) || this.Blok.BlockSelection.anyBlockSelected, u = t.shiftKey && o ===
|
|
9307
|
+
), d = (c !== void 0 ? Ue(c) : void 0) || this.Blok.BlockSelection.anyBlockSelected, u = t.shiftKey && o === T.UP;
|
|
9294
9308
|
if (u && d) {
|
|
9295
9309
|
this.Blok.CrossBlockSelection.toggleBlockSelectedState(!1);
|
|
9296
9310
|
return;
|
|
9297
9311
|
}
|
|
9298
9312
|
u && this.Blok.InlineToolbar.tryToShow();
|
|
9299
|
-
const p = o ===
|
|
9313
|
+
const p = o === T.UP, f = o === T.LEFT && !this.isRtl;
|
|
9300
9314
|
if (p ? this.Blok.Caret.navigateVerticalPrevious() : f ? this.Blok.Caret.navigatePrevious() : !1) {
|
|
9301
9315
|
t.preventDefault();
|
|
9302
9316
|
return;
|
|
@@ -9334,16 +9348,16 @@ class Bd extends Co {
|
|
|
9334
9348
|
const i = r.textContent || "", l = o.holder.getAttribute("data-blok-depth"), a = l ? parseInt(l, 10) : 0, c = fd.exec(i);
|
|
9335
9349
|
if (c) {
|
|
9336
9350
|
this.Blok.YjsManager.stopCapturing();
|
|
9337
|
-
const
|
|
9351
|
+
const S = ((v = c[1]) == null ? void 0 : v.toLowerCase()) === "x", L = c[1] !== void 0 ? 4 : 3, Q = this.extractRemainingHtml(r, L), X = this.getCaretOffset(r) - L, St = t.replace(o, Pt, B({
|
|
9338
9352
|
text: Q,
|
|
9339
9353
|
style: "checklist",
|
|
9340
|
-
checked:
|
|
9354
|
+
checked: S
|
|
9341
9355
|
}, a > 0 ? { depth: a } : {}));
|
|
9342
9356
|
return this.setCaretAfterConversion(St, X), this.Blok.YjsManager.stopCapturing(), !0;
|
|
9343
9357
|
}
|
|
9344
9358
|
if (gd.exec(i)) {
|
|
9345
9359
|
this.Blok.YjsManager.stopCapturing();
|
|
9346
|
-
const
|
|
9360
|
+
const S = 2, L = this.extractRemainingHtml(r, S), Q = this.getCaretOffset(r) - S, X = t.replace(o, Pt, B({
|
|
9347
9361
|
text: L,
|
|
9348
9362
|
style: "unordered",
|
|
9349
9363
|
checked: !1
|
|
@@ -9521,24 +9535,24 @@ class vd extends x {
|
|
|
9521
9535
|
if (this.navigationMode.handleKey(t) || this.navigationMode.handleEscape(t) || (this.beforeKeydownProcessing(t), this.blockSelectionKeys.handleDeletion(t)) || t.defaultPrevented)
|
|
9522
9536
|
return;
|
|
9523
9537
|
switch (so(t)) {
|
|
9524
|
-
case
|
|
9538
|
+
case T.BACKSPACE:
|
|
9525
9539
|
this.keyboardNavigation.handleBackspace(t);
|
|
9526
9540
|
break;
|
|
9527
|
-
case
|
|
9541
|
+
case T.DELETE:
|
|
9528
9542
|
this.keyboardNavigation.handleDelete(t);
|
|
9529
9543
|
break;
|
|
9530
|
-
case
|
|
9544
|
+
case T.ENTER:
|
|
9531
9545
|
this.keyboardNavigation.handleEnter(t);
|
|
9532
9546
|
break;
|
|
9533
|
-
case
|
|
9534
|
-
case
|
|
9547
|
+
case T.DOWN:
|
|
9548
|
+
case T.RIGHT:
|
|
9535
9549
|
this.keyboardNavigation.handleArrowRightAndDown(t);
|
|
9536
9550
|
break;
|
|
9537
|
-
case
|
|
9538
|
-
case
|
|
9551
|
+
case T.UP:
|
|
9552
|
+
case T.LEFT:
|
|
9539
9553
|
this.keyboardNavigation.handleArrowLeftAndUp(t);
|
|
9540
9554
|
break;
|
|
9541
|
-
case
|
|
9555
|
+
case T.TAB:
|
|
9542
9556
|
if (this.blockSelectionKeys.handleIndent(t))
|
|
9543
9557
|
return;
|
|
9544
9558
|
this.keyboardNavigation.handleTab(t);
|
|
@@ -9635,7 +9649,7 @@ class vd extends x {
|
|
|
9635
9649
|
* @param {KeyboardEvent} event - keyboard event
|
|
9636
9650
|
*/
|
|
9637
9651
|
needToolbarClosing(t) {
|
|
9638
|
-
const e = so(t), o = e ===
|
|
9652
|
+
const e = so(t), o = e === T.ENTER, n = e === T.TAB, r = o && this.Blok.Toolbar.toolbox.opened, i = o && this.Blok.BlockSettings.opened, l = o && this.Blok.InlineToolbar.opened, a = n, c = this.Blok.Toolbar.toolbox.opened && !o && !n;
|
|
9639
9653
|
return !(t.shiftKey || a || r || i || l || c);
|
|
9640
9654
|
}
|
|
9641
9655
|
}
|
|
@@ -9709,7 +9723,7 @@ class zo {
|
|
|
9709
9723
|
const r = t - 1, i = Math.max(0, r), l = this.blocks[i], a = t > 0 ? "afterend" : "beforebegin";
|
|
9710
9724
|
this.insertToDOM(n, a, l);
|
|
9711
9725
|
}
|
|
9712
|
-
this.blocks.splice(t, 0, n), n.call(
|
|
9726
|
+
this.blocks.splice(t, 0, n), n.call(st.MOVED, {
|
|
9713
9727
|
fromIndex: e,
|
|
9714
9728
|
toIndex: t
|
|
9715
9729
|
});
|
|
@@ -9728,7 +9742,7 @@ class zo {
|
|
|
9728
9742
|
const n = t > this.length ? this.length : t;
|
|
9729
9743
|
if (o) {
|
|
9730
9744
|
const l = this.blocks[n];
|
|
9731
|
-
l.call(
|
|
9745
|
+
l.call(st.REMOVED), l.destroy(), l.holder.remove();
|
|
9732
9746
|
}
|
|
9733
9747
|
const r = o ? 1 : 0;
|
|
9734
9748
|
if (this.blocks.splice(n, r, e), n > 0) {
|
|
@@ -9752,7 +9766,7 @@ class zo {
|
|
|
9752
9766
|
if (!(t in this.blocks))
|
|
9753
9767
|
throw Error("Incorrect index");
|
|
9754
9768
|
const o = this.blocks[t];
|
|
9755
|
-
o.holder.replaceWith(e.holder), o.call(
|
|
9769
|
+
o.holder.replaceWith(e.holder), o.call(st.REMOVED), this.blocks[t] = e, e.call(st.RENDERED);
|
|
9756
9770
|
}
|
|
9757
9771
|
/**
|
|
9758
9772
|
* Inserts several blocks at once
|
|
@@ -9764,14 +9778,14 @@ class zo {
|
|
|
9764
9778
|
for (const n of t)
|
|
9765
9779
|
o.appendChild(n.holder);
|
|
9766
9780
|
if (!this.length) {
|
|
9767
|
-
this.blocks.push(...t), this.workingArea.appendChild(o), t.forEach((n) => n.call(
|
|
9781
|
+
this.blocks.push(...t), this.workingArea.appendChild(o), t.forEach((n) => n.call(st.RENDERED));
|
|
9768
9782
|
return;
|
|
9769
9783
|
}
|
|
9770
9784
|
if (e > 0) {
|
|
9771
9785
|
const n = Math.min(e - 1, this.length - 1);
|
|
9772
9786
|
this.blocks[n].holder.after(o);
|
|
9773
9787
|
}
|
|
9774
|
-
e === 0 && this.workingArea.prepend(o), this.blocks.splice(e, 0, ...t), t.forEach((n) => n.call(
|
|
9788
|
+
e === 0 && this.workingArea.prepend(o), this.blocks.splice(e, 0, ...t), t.forEach((n) => n.call(st.RENDERED));
|
|
9775
9789
|
}
|
|
9776
9790
|
/**
|
|
9777
9791
|
* Remove block
|
|
@@ -9779,13 +9793,13 @@ class zo {
|
|
|
9779
9793
|
*/
|
|
9780
9794
|
remove(t) {
|
|
9781
9795
|
const e = isNaN(t) ? this.length - 1 : t, o = this.blocks[e];
|
|
9782
|
-
o.call(
|
|
9796
|
+
o.call(st.REMOVED), o.destroy(), o.holder.remove(), this.blocks.splice(e, 1);
|
|
9783
9797
|
}
|
|
9784
9798
|
/**
|
|
9785
9799
|
* Remove all blocks
|
|
9786
9800
|
*/
|
|
9787
9801
|
removeAll() {
|
|
9788
|
-
this.workingArea.innerHTML = "", this.blocks.forEach((t) => t.call(
|
|
9802
|
+
this.workingArea.innerHTML = "", this.blocks.forEach((t) => t.call(st.REMOVED)), this.blocks.length = 0;
|
|
9789
9803
|
}
|
|
9790
9804
|
/**
|
|
9791
9805
|
* Insert Block after passed target
|
|
@@ -9820,7 +9834,7 @@ class zo {
|
|
|
9820
9834
|
* @param {Block} target — Block related to position
|
|
9821
9835
|
*/
|
|
9822
9836
|
insertToDOM(t, e, o) {
|
|
9823
|
-
e && o !== void 0 ? o.holder.insertAdjacentElement(e, t.holder) : this.workingArea.appendChild(t.holder), t.call(
|
|
9837
|
+
e && o !== void 0 ? o.holder.insertAdjacentElement(e, t.holder) : this.workingArea.appendChild(t.holder), t.call(st.RENDERED);
|
|
9824
9838
|
}
|
|
9825
9839
|
}
|
|
9826
9840
|
class xd {
|
|
@@ -10418,7 +10432,7 @@ class Ad {
|
|
|
10418
10432
|
skipYjsSync: !0
|
|
10419
10433
|
}, n);
|
|
10420
10434
|
this.yjsSync.withAtomicOperation(() => void r.ready.then(() => {
|
|
10421
|
-
r.call(
|
|
10435
|
+
r.call(st.ON_PASTE, e), r.refreshToolRootElement();
|
|
10422
10436
|
}).catch((l) => {
|
|
10423
10437
|
C(`${t}: onPaste callback call is failed`, "error", l);
|
|
10424
10438
|
}));
|
|
@@ -10799,7 +10813,7 @@ class _d {
|
|
|
10799
10813
|
return (this.registeredShortcuts.get(t) || []).find(({ name: n }) => n === e);
|
|
10800
10814
|
}
|
|
10801
10815
|
}
|
|
10802
|
-
const
|
|
10816
|
+
const nt = new _d();
|
|
10803
10817
|
class Pd {
|
|
10804
10818
|
/**
|
|
10805
10819
|
* @param wrapper - Editor wrapper element
|
|
@@ -10816,17 +10830,17 @@ class Pd {
|
|
|
10816
10830
|
setTimeout(() => {
|
|
10817
10831
|
const t = ["CMD+SHIFT+UP", "CMD+SHIFT+DOWN"];
|
|
10818
10832
|
for (const e of this.registeredShortcutNames)
|
|
10819
|
-
|
|
10833
|
+
nt.remove(document, e);
|
|
10820
10834
|
this.registeredShortcutNames.length = 0;
|
|
10821
10835
|
for (const e of t)
|
|
10822
|
-
|
|
10823
|
-
|
|
10836
|
+
nt.remove(document, e);
|
|
10837
|
+
nt.add({
|
|
10824
10838
|
name: "CMD+SHIFT+UP",
|
|
10825
10839
|
on: document,
|
|
10826
10840
|
handler: (e) => {
|
|
10827
10841
|
this.shouldHandleShortcut(e) && (e.preventDefault(), this.handlers.onMoveUp());
|
|
10828
10842
|
}
|
|
10829
|
-
}), this.registeredShortcutNames.push("CMD+SHIFT+UP"),
|
|
10843
|
+
}), this.registeredShortcutNames.push("CMD+SHIFT+UP"), nt.add({
|
|
10830
10844
|
name: "CMD+SHIFT+DOWN",
|
|
10831
10845
|
on: document,
|
|
10832
10846
|
handler: (e) => {
|
|
@@ -10840,7 +10854,7 @@ class Pd {
|
|
|
10840
10854
|
*/
|
|
10841
10855
|
unregister() {
|
|
10842
10856
|
for (const t of this.registeredShortcutNames)
|
|
10843
|
-
|
|
10857
|
+
nt.remove(document, t);
|
|
10844
10858
|
this.registeredShortcutNames.length = 0;
|
|
10845
10859
|
}
|
|
10846
10860
|
/**
|
|
@@ -11681,7 +11695,7 @@ class jd extends x {
|
|
|
11681
11695
|
* to select all and copy them
|
|
11682
11696
|
*/
|
|
11683
11697
|
prepare() {
|
|
11684
|
-
this.selection = new w(),
|
|
11698
|
+
this.selection = new w(), nt.add({
|
|
11685
11699
|
name: "CMD+A",
|
|
11686
11700
|
handler: (t) => {
|
|
11687
11701
|
const { BlockManager: e, ReadOnly: o } = this.Blok;
|
|
@@ -11861,7 +11875,7 @@ class jd extends x {
|
|
|
11861
11875
|
* De-registers Shortcut CMD+A
|
|
11862
11876
|
*/
|
|
11863
11877
|
destroy() {
|
|
11864
|
-
|
|
11878
|
+
nt.remove(this.Blok.UI.nodes.redactor, "CMD+A");
|
|
11865
11879
|
}
|
|
11866
11880
|
/**
|
|
11867
11881
|
* First CMD+A selects all input content by native behaviour,
|
|
@@ -13607,7 +13621,7 @@ class lu extends x {
|
|
|
13607
13621
|
async ensureI18nextLoaded(t, e) {
|
|
13608
13622
|
if (this.i18nextWrapper !== null)
|
|
13609
13623
|
return;
|
|
13610
|
-
const { loadI18next: o } = await import("./i18next-loader-
|
|
13624
|
+
const { loadI18next: o } = await import("./i18next-loader-DjR4d8M7.mjs");
|
|
13611
13625
|
this.i18nextWrapper = await o(t, e);
|
|
13612
13626
|
}
|
|
13613
13627
|
/**
|
|
@@ -13781,7 +13795,7 @@ class Se {
|
|
|
13781
13795
|
* Process paste of single Block tool content.
|
|
13782
13796
|
*/
|
|
13783
13797
|
async processSingleBlock(t, e) {
|
|
13784
|
-
const { Caret: o, BlockManager: n } = this.Blok, { currentBlock: r } = n, { Dom: i } = await import("./inline-tool-convert-
|
|
13798
|
+
const { Caret: o, BlockManager: n } = this.Blok, { currentBlock: r } = n, { Dom: i } = await import("./inline-tool-convert-SRTkyaZn.mjs").then((a) => a.aI), l = i;
|
|
13785
13799
|
if (!r || t.tool !== r.name || !l.containsOnlyInlineElements(t.content.innerHTML)) {
|
|
13786
13800
|
await this.insertBlock(t, e);
|
|
13787
13801
|
return;
|
|
@@ -14568,13 +14582,13 @@ class uu extends x {
|
|
|
14568
14582
|
const i = r.getBoundingClientRect(), l = this.getScrollTop(), a = e - l;
|
|
14569
14583
|
if (!(a >= i.top && a <= i.bottom))
|
|
14570
14584
|
return;
|
|
14571
|
-
const h = this.getScrollLeft(), d = t - h, u =
|
|
14572
|
-
!
|
|
14585
|
+
const h = this.getScrollLeft(), d = t - h, u = this.Blok.UI.contentRect, p = d >= u.left && d <= u.right, f = document.elementFromPoint(t - h, a);
|
|
14586
|
+
!f || (!f.closest(ut(y.toolbar)) && !o && (this.Blok.BlockSelection.allBlocksSelected = !1, this.clearSelection(), this.stackOfSelected = []), [
|
|
14573
14587
|
ut(y.elementContent),
|
|
14574
14588
|
ut(y.toolbar),
|
|
14575
14589
|
ut(y.popover),
|
|
14576
14590
|
rl
|
|
14577
|
-
].some((
|
|
14591
|
+
].some((v) => !!f.closest(v))) || (p && this.Blok.Toolbar.close(), this.mousedown = !0, this.startX = t, this.startY = e);
|
|
14578
14592
|
}
|
|
14579
14593
|
/**
|
|
14580
14594
|
* Clear all params to end selection
|
|
@@ -14970,29 +14984,29 @@ class Du extends x {
|
|
|
14970
14984
|
const r = this.config.dataModel || "auto", i = vu(t);
|
|
14971
14985
|
this.detectedInputFormat = i.format;
|
|
14972
14986
|
const a = (Mu(r, i.format) ? Tu(t) : t).map((c) => {
|
|
14973
|
-
const { tunes: h, id: d, parent: u, content: p } = c, f = c.type, g = ((
|
|
14987
|
+
const { tunes: h, id: d, parent: u, content: p } = c, f = c.type, g = ((S) => typeof S == "object" && S !== null)(c.data) ? c.data : {}, m = o.available.has(f) ? {
|
|
14974
14988
|
tool: f,
|
|
14975
14989
|
data: g
|
|
14976
|
-
} : (
|
|
14990
|
+
} : (ot(`Tool «${f}» is not found. Check 'tools' property at the Blok config.`, "warn"), {
|
|
14977
14991
|
tool: o.stubTool,
|
|
14978
14992
|
data: this.composeStubDataForTool(f, g, d)
|
|
14979
14993
|
});
|
|
14980
|
-
return ((
|
|
14994
|
+
return ((S, L) => {
|
|
14981
14995
|
try {
|
|
14982
14996
|
return n.composeBlock({
|
|
14983
14997
|
id: d,
|
|
14984
|
-
tool:
|
|
14998
|
+
tool: S,
|
|
14985
14999
|
data: L,
|
|
14986
15000
|
tunes: h,
|
|
14987
15001
|
parentId: u,
|
|
14988
15002
|
contentIds: p
|
|
14989
15003
|
});
|
|
14990
15004
|
} catch (Q) {
|
|
14991
|
-
C(`Block «${
|
|
15005
|
+
C(`Block «${S}» skipped because of plugins error`, "error", {
|
|
14992
15006
|
data: L,
|
|
14993
15007
|
error: Q
|
|
14994
15008
|
});
|
|
14995
|
-
const X = this.composeStubDataForTool(
|
|
15009
|
+
const X = this.composeStubDataForTool(S, L, d);
|
|
14996
15010
|
return n.composeBlock({
|
|
14997
15011
|
id: d,
|
|
14998
15012
|
tool: o.stubTool,
|
|
@@ -15062,7 +15076,7 @@ class Ru extends x {
|
|
|
15062
15076
|
} catch (i) {
|
|
15063
15077
|
this.lastSaveError = i;
|
|
15064
15078
|
const l = i instanceof Error ? i : new Error(String(i));
|
|
15065
|
-
|
|
15079
|
+
ot("Saving failed due to the Error %o", "error", l);
|
|
15066
15080
|
return;
|
|
15067
15081
|
}
|
|
15068
15082
|
}
|
|
@@ -15111,7 +15125,7 @@ class Ru extends x {
|
|
|
15111
15125
|
C("Stub block data is malformed and was skipped");
|
|
15112
15126
|
return;
|
|
15113
15127
|
}
|
|
15114
|
-
const m = u === void 0 || z(u), v = b !== void 0 && b.length > 0,
|
|
15128
|
+
const m = u === void 0 || z(u), v = b !== void 0 && b.length > 0, S = B(B(B({
|
|
15115
15129
|
id: c,
|
|
15116
15130
|
type: h,
|
|
15117
15131
|
data: d
|
|
@@ -15122,7 +15136,7 @@ class Ru extends x {
|
|
|
15122
15136
|
}), v && {
|
|
15123
15137
|
content: b
|
|
15124
15138
|
});
|
|
15125
|
-
e.push(
|
|
15139
|
+
e.push(S);
|
|
15126
15140
|
});
|
|
15127
15141
|
const o = this.config.dataModel || "auto", n = (a = (l = (i = this.Blok.Renderer) == null ? void 0 : i.getDetectedInputFormat) == null ? void 0 : l.call(i)) != null ? a : "flat", r = Au(o, n) ? Eu(e) : e;
|
|
15128
15142
|
return {
|
|
@@ -15210,10 +15224,10 @@ class ur extends ce {
|
|
|
15210
15224
|
const e = !Mt(), o = new ae({
|
|
15211
15225
|
focusedItemClass: br.focused,
|
|
15212
15226
|
allowedKeys: [
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15227
|
+
T.TAB,
|
|
15228
|
+
T.UP,
|
|
15229
|
+
T.DOWN,
|
|
15230
|
+
T.ENTER
|
|
15217
15231
|
]
|
|
15218
15232
|
});
|
|
15219
15233
|
super(
|
|
@@ -15592,12 +15606,12 @@ class Pu extends x {
|
|
|
15592
15606
|
super(...arguments), this.opened = !1, this.isOpening = !1, this.selection = new w(), this.popover = null, this.flipperInstance = new ae({
|
|
15593
15607
|
focusedItemClass: br.focused,
|
|
15594
15608
|
allowedKeys: [
|
|
15595
|
-
|
|
15596
|
-
|
|
15597
|
-
|
|
15598
|
-
|
|
15599
|
-
|
|
15600
|
-
|
|
15609
|
+
T.TAB,
|
|
15610
|
+
T.UP,
|
|
15611
|
+
T.DOWN,
|
|
15612
|
+
T.ENTER,
|
|
15613
|
+
T.RIGHT,
|
|
15614
|
+
T.LEFT
|
|
15601
15615
|
]
|
|
15602
15616
|
}), this.flipperKeydownHandler = null, this.flipperKeydownSource = null, this.close = () => {
|
|
15603
15617
|
this.opened && (this.opened = !1, this.isOpening = !1, w.isAtBlok || this.selection.restore(), this.selection.clearSaved(), this.detachFlipperKeydownListener(), this.clearBlockSelectionOnClose(), this.eventsDispatcher.emit(this.events.closed), this.popover && (this.popover.off(Ht.Closed, this.onPopoverClose), this.popover.destroy(), this.popover.getElement().remove(), this.popover = null));
|
|
@@ -16140,7 +16154,7 @@ class Hu extends yn {
|
|
|
16140
16154
|
* @param {string} shortcut - shortcut according to the ShortcutData Module format
|
|
16141
16155
|
*/
|
|
16142
16156
|
enableShortcutForTool(t, e) {
|
|
16143
|
-
|
|
16157
|
+
nt.add({
|
|
16144
16158
|
name: e,
|
|
16145
16159
|
on: this.api.ui.nodes.redactor,
|
|
16146
16160
|
handler: async (o) => {
|
|
@@ -16164,7 +16178,7 @@ class Hu extends yn {
|
|
|
16164
16178
|
removeAllShortcuts() {
|
|
16165
16179
|
this.toolsToBeDisplayed.forEach((t) => {
|
|
16166
16180
|
const e = t.shortcut;
|
|
16167
|
-
e &&
|
|
16181
|
+
e && nt.remove(this.api.ui.nodes.redactor, e);
|
|
16168
16182
|
});
|
|
16169
16183
|
}
|
|
16170
16184
|
/**
|
|
@@ -16333,10 +16347,10 @@ class Uu {
|
|
|
16333
16347
|
this.closeToolbox();
|
|
16334
16348
|
return;
|
|
16335
16349
|
}
|
|
16336
|
-
const i = this.hoveredBlockInternal, l = (i == null ? void 0 : i.name) === "paragraph", a = l && ((v = i.pluginsContent.textContent) == null ? void 0 : v.startsWith("/")), c = l && i.isEmpty, h = i !== null ? e.getBlockIndex(i) : e.currentBlockIndex, d = t ? h : h + 1, u = e.blocks.slice(d), p = (
|
|
16350
|
+
const i = this.hoveredBlockInternal, l = (i == null ? void 0 : i.name) === "paragraph", a = l && ((v = i.pluginsContent.textContent) == null ? void 0 : v.startsWith("/")), c = l && i.isEmpty, h = i !== null ? e.getBlockIndex(i) : e.currentBlockIndex, d = t ? h : h + 1, u = e.blocks.slice(d), p = (S) => {
|
|
16337
16351
|
var L;
|
|
16338
|
-
return ((L =
|
|
16339
|
-
}, f = !t && i && u.length > 0 ? u.findIndex((
|
|
16352
|
+
return ((L = S.holder.parentElement) == null ? void 0 : L.closest('[data-blok-testid="block-wrapper"]')) !== null;
|
|
16353
|
+
}, f = !t && i && u.length > 0 ? u.findIndex((S) => !p(S)) : 0, b = d + (f === -1 ? u.length : f), g = c || a ? i : e.insertDefaultBlockAtIndex(b, !0);
|
|
16340
16354
|
g !== i && p(g) && (i == null || i.holder.after(g.holder)), a ? r.setToBlock(g, r.positions.DEFAULT, 1) : (r.setToBlock(g, r.positions.START), r.insertContentAtCaretPosition("/")), this.moveAndOpenToolbar(g), this.openToolbox();
|
|
16341
16355
|
}
|
|
16342
16356
|
}
|
|
@@ -16375,11 +16389,11 @@ class zu {
|
|
|
16375
16389
|
* @returns the Y position in pixels, or null if calculation is not possible
|
|
16376
16390
|
*/
|
|
16377
16391
|
calculateToolbarY(t, e) {
|
|
16378
|
-
var
|
|
16392
|
+
var S;
|
|
16379
16393
|
const { targetBlock: o, hoveredTarget: n, isMobile: r } = t;
|
|
16380
16394
|
if (!o || !e)
|
|
16381
16395
|
return null;
|
|
16382
|
-
const l = o.holder.getBoundingClientRect(), a = n == null ? void 0 : n.closest('[role="listitem"]'), c = a == null ? void 0 : a.querySelector("[contenteditable]"), h = (
|
|
16396
|
+
const l = o.holder.getBoundingClientRect(), a = n == null ? void 0 : n.closest('[role="listitem"]'), c = a == null ? void 0 : a.querySelector("[contenteditable]"), h = (S = c != null ? c : a) != null ? S : o.pluginsContent, u = h.getBoundingClientRect().top - l.top, p = window.getComputedStyle(h), f = parseInt(p.paddingTop, 10) || 0, b = parseFloat(p.lineHeight) || 24, g = parseInt(window.getComputedStyle(e).height, 10);
|
|
16383
16397
|
return r ? u - g : u + f + b / 2 - g / 2;
|
|
16384
16398
|
}
|
|
16385
16399
|
/**
|
|
@@ -16759,21 +16773,23 @@ class Ku extends x {
|
|
|
16759
16773
|
const o = t != null ? t : this.Blok.BlockManager.currentBlock;
|
|
16760
16774
|
if (!o)
|
|
16761
16775
|
return;
|
|
16776
|
+
this.hoveredBlockIsFromTableCell = o.holder.closest("[data-blok-table-cell-blocks]") !== null;
|
|
16762
16777
|
const n = this.resolveTableCellBlock(o);
|
|
16763
|
-
this.
|
|
16778
|
+
this.hoveredBlock && this.hoveredBlock !== n && this.hoveredBlock.cleanupDraggable(), this.hoveredBlock = n, this.plusButtonHandler.setHoveredBlock(n), this.settingsTogglerHandler.setHoveredBlock(n), this.positioner.setHoveredTarget(e != null ? e : null), this.positioner.resetCachedPosition();
|
|
16764
16779
|
const { wrapper: r, plusButton: i, settingsToggler: l } = this.nodes;
|
|
16765
16780
|
if (!r || !i)
|
|
16766
16781
|
return;
|
|
16767
|
-
|
|
16768
|
-
|
|
16769
|
-
|
|
16782
|
+
const a = this.hoveredBlockIsFromTableCell ? "none" : "";
|
|
16783
|
+
i.style.display = a, l && (l.style.display = a);
|
|
16784
|
+
const c = n.holder, { isMobile: h } = this.Blok.UI, d = this.positioner.calculateToolbarY(
|
|
16785
|
+
{ targetBlock: n, hoveredTarget: e != null ? e : null, isMobile: h },
|
|
16770
16786
|
i
|
|
16771
16787
|
);
|
|
16772
|
-
if (
|
|
16788
|
+
if (d === null)
|
|
16773
16789
|
return;
|
|
16774
|
-
this.positioner.moveToY(this.nodes,
|
|
16775
|
-
const
|
|
16776
|
-
this.Blok.BlockManager.blocks.length === 1 && n.isEmpty && !
|
|
16790
|
+
this.positioner.moveToY(this.nodes, d), c.appendChild(r), l && !this.Blok.ReadOnly.isEnabled && n.setupDraggable(l, this.Blok.DragManager), this.positioner.applyContentOffset(this.nodes, n);
|
|
16791
|
+
const u = n.getTunes(), p = u.toolTunes.length > 0 || u.commonTunes.length > 0;
|
|
16792
|
+
this.Blok.BlockManager.blocks.length === 1 && n.isEmpty && !p ? this.blockTunesToggler.hide() : this.blockTunesToggler.show(), this.open();
|
|
16777
16793
|
}
|
|
16778
16794
|
/**
|
|
16779
16795
|
* Move Toolbar to the specified block (or first selected block) and open it for multi-block selection.
|
|
@@ -16793,18 +16809,15 @@ class Ku extends x {
|
|
|
16793
16809
|
this.toolboxInstance.opened && this.toolboxInstance.close(), this.explicitlyClosed = !1;
|
|
16794
16810
|
const o = t != null ? t : e[0];
|
|
16795
16811
|
this.hoveredBlock && this.hoveredBlock !== o && this.hoveredBlock.cleanupDraggable(), this.hoveredBlock = o, this.plusButtonHandler.setHoveredBlock(o), this.settingsTogglerHandler.setHoveredBlock(o), this.positioner.setHoveredTarget(null), this.positioner.resetCachedPosition();
|
|
16796
|
-
const { wrapper: n, plusButton: r } = this.nodes;
|
|
16812
|
+
const { wrapper: n, plusButton: r, settingsToggler: i } = this.nodes;
|
|
16797
16813
|
if (!n || !r)
|
|
16798
16814
|
return;
|
|
16799
|
-
|
|
16815
|
+
r.style.display = "", i && (i.style.display = "");
|
|
16816
|
+
const l = o.holder, a = this.positioner.calculateToolbarY(
|
|
16800
16817
|
{ targetBlock: o, hoveredTarget: null, isMobile: !1 },
|
|
16801
16818
|
r
|
|
16802
16819
|
);
|
|
16803
|
-
|
|
16804
|
-
return;
|
|
16805
|
-
this.positioner.moveToY(this.nodes, l), i.appendChild(n);
|
|
16806
|
-
const { settingsToggler: a } = this.nodes;
|
|
16807
|
-
a && !this.Blok.ReadOnly.isEnabled && o.setupDraggable(a, this.Blok.DragManager), this.positioner.applyContentOffset(this.nodes, o), this.blockTunesToggler.show(), this.open();
|
|
16820
|
+
a !== null && (this.positioner.moveToY(this.nodes, a), l.appendChild(n), i && !this.Blok.ReadOnly.isEnabled && o.setupDraggable(i, this.Blok.DragManager), this.positioner.applyContentOffset(this.nodes, o), this.blockTunesToggler.show(), this.open());
|
|
16808
16821
|
}
|
|
16809
16822
|
/**
|
|
16810
16823
|
* Close the Toolbar
|
|
@@ -17349,7 +17362,7 @@ class tp {
|
|
|
17349
17362
|
*/
|
|
17350
17363
|
destroy() {
|
|
17351
17364
|
for (const [, t] of this.registeredShortcuts.entries())
|
|
17352
|
-
|
|
17365
|
+
nt.remove(document, t);
|
|
17353
17366
|
this.registeredShortcuts.clear(), this.shortcutsRegistered = !1;
|
|
17354
17367
|
}
|
|
17355
17368
|
/**
|
|
@@ -17380,7 +17393,7 @@ class tp {
|
|
|
17380
17393
|
*/
|
|
17381
17394
|
enableShortcuts(t, e) {
|
|
17382
17395
|
const o = this.registeredShortcuts.get(t);
|
|
17383
|
-
o !== e && (this.isShortcutTakenByAnotherTool(t, e) || (o !== void 0 && (
|
|
17396
|
+
o !== e && (this.isShortcutTakenByAnotherTool(t, e) || (o !== void 0 && (nt.remove(document, o), this.registeredShortcuts.delete(t)), nt.add({
|
|
17384
17397
|
name: e,
|
|
17385
17398
|
handler: (n) => {
|
|
17386
17399
|
const { BlockManager: r } = this.getBlok(), { currentBlock: i } = r;
|
|
@@ -17587,7 +17600,7 @@ class op extends x {
|
|
|
17587
17600
|
* Shows Inline Toolbar
|
|
17588
17601
|
*/
|
|
17589
17602
|
async open() {
|
|
17590
|
-
var i, l, a, c, h, d, u, p, f, b, g, m, v,
|
|
17603
|
+
var i, l, a, c, h, d, u, p, f, b, g, m, v, S, L, Q, X, St, rs, is, ls;
|
|
17591
17604
|
if (this.opened || (this.initialize(), this.opened = !0, this.popover && ((l = (i = this.popover).hide) == null || l.call(i), (c = (a = this.popover).destroy) == null || c.call(a), this.popover = null), this.createToolsInstances(), !this.nodes.wrapper))
|
|
17592
17605
|
return;
|
|
17593
17606
|
this.nodes.wrapper.innerHTML = "";
|
|
@@ -17600,7 +17613,7 @@ class op extends x {
|
|
|
17600
17613
|
search: this.Blok.I18n.t("popover.search")
|
|
17601
17614
|
}
|
|
17602
17615
|
});
|
|
17603
|
-
const o = (
|
|
17616
|
+
const o = (S = (g = (b = this.popover).getMountElement) == null ? void 0 : g.call(b)) != null ? S : (v = (m = this.popover).getElement) == null ? void 0 : v.call(m), n = (Q = (L = this.popover).getElement) == null ? void 0 : Q.call(L), r = (rs = (St = (X = this.popover.size) == null ? void 0 : X.width) != null ? St : n == null ? void 0 : n.getBoundingClientRect().width) != null ? rs : 0;
|
|
17604
17617
|
this.applyPosition(r), o && this.nodes.wrapper && this.nodes.wrapper.appendChild(o), (ls = (is = this.popover).show) == null || ls.call(is);
|
|
17605
17618
|
}
|
|
17606
17619
|
/**
|
|
@@ -19436,9 +19449,9 @@ const Sp = Ke(), ie = class ie {
|
|
|
19436
19449
|
save: "save"
|
|
19437
19450
|
}
|
|
19438
19451
|
}).forEach(([g, m]) => {
|
|
19439
|
-
Object.entries(m).forEach(([v,
|
|
19452
|
+
Object.entries(m).forEach(([v, S]) => {
|
|
19440
19453
|
const L = g, Q = t.moduleInstances.API.methods[L];
|
|
19441
|
-
this[
|
|
19454
|
+
this[S] = Q[v];
|
|
19442
19455
|
});
|
|
19443
19456
|
});
|
|
19444
19457
|
const b = t.moduleInstances.API.methods.ui;
|
|
@@ -278,7 +278,7 @@ const d = {
|
|
|
278
278
|
DELETE: 46
|
|
279
279
|
}, Ae = {
|
|
280
280
|
LEFT: 0
|
|
281
|
-
}, Se = 650, Wt = () => "0.6.0-beta.
|
|
281
|
+
}, Se = 650, Wt = () => "0.6.0-beta.9";
|
|
282
282
|
var Vt = /* @__PURE__ */ ((n) => (n.VERBOSE = "VERBOSE", n.INFO = "INFO", n.WARN = "WARN", n.ERROR = "ERROR", n))(Vt || {});
|
|
283
283
|
const V = (n, t, e = "log", o, s = "color: inherit") => {
|
|
284
284
|
const i = typeof console == "undefined" ? void 0 : console;
|
package/dist/full.mjs
CHANGED
|
@@ -12,8 +12,8 @@ var e = (a, l, o) => l in a ? n(a, l, { enumerable: !0, configurable: !0, writab
|
|
|
12
12
|
}, r = (a, l) => t(a, c(l));
|
|
13
13
|
import { Link as p, Italic as f, Bold as I, List as k, Header as u, Paragraph as B } from "./tools.mjs";
|
|
14
14
|
import { defaultBlockTools as v, defaultInlineTools as A } from "./tools.mjs";
|
|
15
|
-
import { B as H, v as P } from "./chunks/blok-
|
|
16
|
-
import { D as _ } from "./chunks/inline-tool-convert-
|
|
15
|
+
import { B as H, v as P } from "./chunks/blok-Bn6Q_o8h.mjs";
|
|
16
|
+
import { D as _ } from "./chunks/inline-tool-convert-SRTkyaZn.mjs";
|
|
17
17
|
const m = {
|
|
18
18
|
paragraph: {
|
|
19
19
|
class: B,
|
package/dist/tools.mjs
CHANGED
|
@@ -10,8 +10,8 @@ var Tt = (i, t, e) => t in i ? ke(i, t, { enumerable: !0, configurable: !0, writ
|
|
|
10
10
|
Le.call(t, e) && Tt(i, e, t[e]);
|
|
11
11
|
return i;
|
|
12
12
|
}, tt = (i, t) => xe(i, Te(t));
|
|
13
|
-
import { t as v, D as E, am as Be, an as Ie, _ as Ne, ao as De, ap as
|
|
14
|
-
import { ab as xo } from "./chunks/inline-tool-convert-
|
|
13
|
+
import { t as v, D as E, am as Be, an as Ie, _ as Ne, ao as De, ap as Pe, aq as He, ar as _e, as as Oe, at as Me, au as Qt, av as te, aw as ee, o as We, p as Rt, a5 as Lt, a3 as $e, ax as Ge, J as ne, Q as se, P as F, ay as qe, az as Fe, a0 as oe, aA as ze, aB as Ve, aC as Ue, aD as Ke, aE as je, z as P, aF as Xe, aG as Ye, S as et, aH as Ze, l as Je, a8 as Qe } from "./chunks/inline-tool-convert-SRTkyaZn.mjs";
|
|
14
|
+
import { ab as xo } from "./chunks/inline-tool-convert-SRTkyaZn.mjs";
|
|
15
15
|
const ie = (i) => {
|
|
16
16
|
if (!i || !i.includes("data-blok-fake-background"))
|
|
17
17
|
return i;
|
|
@@ -194,7 +194,11 @@ const ie = (i) => {
|
|
|
194
194
|
static get sanitize() {
|
|
195
195
|
return {
|
|
196
196
|
text: {
|
|
197
|
-
br: !0
|
|
197
|
+
br: !0,
|
|
198
|
+
img: {
|
|
199
|
+
src: !0,
|
|
200
|
+
style: !0
|
|
201
|
+
}
|
|
198
202
|
}
|
|
199
203
|
};
|
|
200
204
|
}
|
|
@@ -550,8 +554,8 @@ const O = class O {
|
|
|
550
554
|
};
|
|
551
555
|
O.BASE_STYLES = "py-[3px] px-[2px] m-0 !leading-[1.3] outline-none [&_p]:!p-0 [&_p]:!m-0 [&_div]:!p-0 [&_div]:!m-0", O.DEFAULT_LEVELS = [
|
|
552
556
|
{ number: 1, tag: "H1", nameKey: "tools.header.heading1", name: "Heading 1", icon: De, styles: "text-4xl font-bold mt-8 mb-1" },
|
|
553
|
-
{ number: 2, tag: "H2", nameKey: "tools.header.heading2", name: "Heading 2", icon:
|
|
554
|
-
{ number: 3, tag: "H3", nameKey: "tools.header.heading3", name: "Heading 3", icon:
|
|
557
|
+
{ number: 2, tag: "H2", nameKey: "tools.header.heading2", name: "Heading 2", icon: Pe, styles: "text-3xl font-semibold mt-6 mb-px" },
|
|
558
|
+
{ number: 3, tag: "H3", nameKey: "tools.header.heading3", name: "Heading 3", icon: He, styles: "text-2xl font-semibold mt-4 mb-px" },
|
|
555
559
|
{ number: 4, tag: "H4", nameKey: "tools.header.heading4", name: "Heading 4", icon: _e, styles: "text-xl font-semibold mt-3 mb-px" },
|
|
556
560
|
{ number: 5, tag: "H5", nameKey: "tools.header.heading5", name: "Heading 5", icon: Oe, styles: "text-base font-semibold mt-3 mb-px" },
|
|
557
561
|
{ number: 6, tag: "H6", nameKey: "tools.header.heading6", name: "Heading 6", icon: Me, styles: "text-sm font-semibold mt-3 mb-px" }
|
|
@@ -728,7 +732,7 @@ const z = 24, rn = "outline-none py-[3px] mt-[2px] mb-px", ln = "outline-none pl
|
|
|
728
732
|
return !1;
|
|
729
733
|
const e = Object.entries(i).find(([n]) => n === "items");
|
|
730
734
|
return e === void 0 ? !1 : Array.isArray(e[1]);
|
|
731
|
-
}, Ln = (i) => typeof i == "object" && i !== null, Bn = (i) => typeof i == "string" ? i : "", In = (i, t) => i === "unordered" || i === "ordered" || i === "checklist" ? i : t, Nn = (i) => !!i, Dn = (i, t) => typeof i == "number" ? i : t,
|
|
735
|
+
}, Ln = (i) => typeof i == "object" && i !== null, Bn = (i) => typeof i == "string" ? i : "", In = (i, t) => i === "unordered" || i === "ordered" || i === "checklist" ? i : t, Nn = (i) => !!i, Dn = (i, t) => typeof i == "number" ? i : t, Pn = (i, t) => {
|
|
732
736
|
const e = t.defaultStyle || "unordered";
|
|
733
737
|
if (!i || typeof i != "object")
|
|
734
738
|
return {
|
|
@@ -822,7 +826,7 @@ class ce {
|
|
|
822
826
|
return n ? Math.round(parseInt(n[1], 10) / z) : 0;
|
|
823
827
|
}
|
|
824
828
|
}
|
|
825
|
-
const
|
|
829
|
+
const Hn = (i, t) => {
|
|
826
830
|
if (!i) return null;
|
|
827
831
|
if (t === "checklist") {
|
|
828
832
|
const n = i.querySelector("[contenteditable]");
|
|
@@ -849,7 +853,7 @@ const Pn = (i, t) => {
|
|
|
849
853
|
n.style
|
|
850
854
|
);
|
|
851
855
|
return l === null ? 1 : o.getBlockStartValue(l);
|
|
852
|
-
},
|
|
856
|
+
}, Pt = (i, t, e, n, s, o) => {
|
|
853
857
|
const l = Mn(i, t, n, e, s, o) + i;
|
|
854
858
|
return o.formatNumber(l, t);
|
|
855
859
|
}, Wn = (i, t, e, n) => n.findGroupStart(i, t, e), ue = (i, t, e, n) => {
|
|
@@ -1412,7 +1416,7 @@ const Yn = (i) => i instanceof HTMLElement, Zn = /* @__PURE__ */ new Set([
|
|
|
1412
1416
|
style: "unordered",
|
|
1413
1417
|
checked: !1
|
|
1414
1418
|
})
|
|
1415
|
-
}),
|
|
1419
|
+
}), Ht = [
|
|
1416
1420
|
{
|
|
1417
1421
|
name: "bulletedList",
|
|
1418
1422
|
titleKey: "bulletedList",
|
|
@@ -1471,11 +1475,11 @@ class vo {
|
|
|
1471
1475
|
return typeof t == "object" && t !== null && "event" in t && typeof t.event == "object" && t.event !== null && "type" in t.event && typeof t.event.type == "string";
|
|
1472
1476
|
}
|
|
1473
1477
|
normalizeData(t) {
|
|
1474
|
-
return
|
|
1478
|
+
return Pn(t, this._settings);
|
|
1475
1479
|
}
|
|
1476
1480
|
get availableStyles() {
|
|
1477
1481
|
const t = this._settings.styles;
|
|
1478
|
-
return !t || t.length === 0 ?
|
|
1482
|
+
return !t || t.length === 0 ? Ht : Ht.filter((e) => t.includes(e.style));
|
|
1479
1483
|
}
|
|
1480
1484
|
get itemColor() {
|
|
1481
1485
|
return this._settings.itemColor;
|
|
@@ -1535,7 +1539,7 @@ class vo {
|
|
|
1535
1539
|
const t = (o = this._element) == null ? void 0 : o.querySelector("[data-list-marker]");
|
|
1536
1540
|
if (!t)
|
|
1537
1541
|
return;
|
|
1538
|
-
const e = this.getDepth(), n = Dt(this.blockId, e, this._data.style, this.api.blocks, this.markerCalculator), s =
|
|
1542
|
+
const e = this.getDepth(), n = Dt(this.blockId, e, this._data.style, this.api.blocks, this.markerCalculator), s = Pt(n, e, this._data, this.blockId, this.api.blocks, this.markerCalculator);
|
|
1539
1543
|
t.textContent = s;
|
|
1540
1544
|
}
|
|
1541
1545
|
updateSiblingListMarkers() {
|
|
@@ -1548,7 +1552,7 @@ class vo {
|
|
|
1548
1552
|
const n = (s = this._element) == null ? void 0 : s.querySelector('[aria-hidden="true"]');
|
|
1549
1553
|
if (n instanceof HTMLElement)
|
|
1550
1554
|
if (e === "ordered") {
|
|
1551
|
-
const o = Dt(this.blockId, t, this._data.style, this.api.blocks, this.markerCalculator), r =
|
|
1555
|
+
const o = Dt(this.blockId, t, this._data.style, this.api.blocks, this.markerCalculator), r = Pt(o, t, this._data, this.blockId, this.api.blocks, this.markerCalculator);
|
|
1552
1556
|
n.textContent = r;
|
|
1553
1557
|
} else {
|
|
1554
1558
|
const o = On(t, this.markerCalculator);
|
|
@@ -1638,7 +1642,7 @@ class vo {
|
|
|
1638
1642
|
e instanceof HTMLInputElement && (this._data.checked = e.checked);
|
|
1639
1643
|
}
|
|
1640
1644
|
getContentElement() {
|
|
1641
|
-
return
|
|
1645
|
+
return Hn(this._element, this._data.style);
|
|
1642
1646
|
}
|
|
1643
1647
|
renderSettings() {
|
|
1644
1648
|
return vn(this.availableStyles, this._data.style, this.api.i18n.t, (t) => this.setStyle(t));
|
|
@@ -1886,7 +1890,7 @@ class ds {
|
|
|
1886
1890
|
e && (e.setAttribute("width", $t), e.setAttribute("height", $t), e.setAttribute("viewBox", "0 0 24 24"), e.classList.add("text-gray-500", "pointer-events-none"));
|
|
1887
1891
|
}
|
|
1888
1892
|
}
|
|
1889
|
-
const g = "data-blok-table-row", u = "data-blok-table-cell",
|
|
1893
|
+
const g = "data-blok-table-row", u = "data-blok-table-cell", H = 1, nt = `${H}px solid #d1d5db`, hs = [
|
|
1890
1894
|
"flex"
|
|
1891
1895
|
], us = [
|
|
1892
1896
|
"py-1",
|
|
@@ -2189,7 +2193,7 @@ class fs {
|
|
|
2189
2193
|
return;
|
|
2190
2194
|
const d = c.getAttribute("data-blok-id");
|
|
2191
2195
|
d && this.api.caret.setToBlock(d, "end");
|
|
2192
|
-
}, this.api = t.api, this.gridElement = t.gridElement, this.onNavigateToCell = t.onNavigateToCell, this.api.events.on("block changed", this.handleBlockMutation), this.gridElement.addEventListener("click", this.handleCellBlankSpaceClick);
|
|
2196
|
+
}, this.api = t.api, this.gridElement = t.gridElement, this.tableBlockId = t.tableBlockId, this.onNavigateToCell = t.onNavigateToCell, this.api.events.on("block changed", this.handleBlockMutation), this.gridElement.addEventListener("click", this.handleCellBlankSpaceClick);
|
|
2193
2197
|
}
|
|
2194
2198
|
/**
|
|
2195
2199
|
* Get the currently active cell that contains blocks
|
|
@@ -2314,7 +2318,7 @@ class fs {
|
|
|
2314
2318
|
a.push({ blocks: f });
|
|
2315
2319
|
else {
|
|
2316
2320
|
const m = typeof c == "string" ? c : "", C = this.api.blocks.insert("paragraph", { text: m }, {}, this.api.blocks.getBlocksCount(), !1);
|
|
2317
|
-
p.appendChild(C.holder), a.push({ blocks: [C.id] });
|
|
2321
|
+
p.appendChild(C.holder), this.api.blocks.setBlockParent(C.id, this.tableBlockId), a.push({ blocks: [C.id] });
|
|
2318
2322
|
}
|
|
2319
2323
|
this.stripPlaceholders(p);
|
|
2320
2324
|
}), n.push(a);
|
|
@@ -2342,7 +2346,7 @@ class fs {
|
|
|
2342
2346
|
if (o === void 0)
|
|
2343
2347
|
continue;
|
|
2344
2348
|
const r = this.api.blocks.getBlockByIndex(o);
|
|
2345
|
-
r && (t.appendChild(r.holder), n.push(s));
|
|
2349
|
+
r && (t.appendChild(r.holder), this.api.blocks.setBlockParent(s, this.tableBlockId), n.push(s));
|
|
2346
2350
|
}
|
|
2347
2351
|
return n;
|
|
2348
2352
|
}
|
|
@@ -2357,7 +2361,7 @@ class fs {
|
|
|
2357
2361
|
if (s === void 0)
|
|
2358
2362
|
return;
|
|
2359
2363
|
const o = this.api.blocks.getBlockByIndex(s);
|
|
2360
|
-
o && (n.appendChild(o.holder), this.stripPlaceholders(n));
|
|
2364
|
+
o && (n.appendChild(o.holder), this.api.blocks.setBlockParent(e, this.tableBlockId), this.stripPlaceholders(n));
|
|
2361
2365
|
}
|
|
2362
2366
|
/**
|
|
2363
2367
|
* Given a new block's index, find which cell it should belong to
|
|
@@ -2386,7 +2390,7 @@ class fs {
|
|
|
2386
2390
|
if (!e || e.querySelector("[data-blok-id]") !== null)
|
|
2387
2391
|
return;
|
|
2388
2392
|
const s = this.api.blocks.insert("paragraph", { text: "" }, {}, this.api.blocks.getBlocksCount(), !0);
|
|
2389
|
-
e.appendChild(s.holder), this.stripPlaceholders(e);
|
|
2393
|
+
e.appendChild(s.holder), this.api.blocks.setBlockParent(s.id, this.tableBlockId), this.stripPlaceholders(e);
|
|
2390
2394
|
}
|
|
2391
2395
|
/**
|
|
2392
2396
|
* If the removed block's holder is currently inside a cell of this table,
|
|
@@ -2714,7 +2718,7 @@ const U = (i) => {
|
|
|
2714
2718
|
);
|
|
2715
2719
|
}, ct = (i, t) => {
|
|
2716
2720
|
const e = t.reduce((o, r) => o + r, 0), n = i;
|
|
2717
|
-
n.style.width = `${e +
|
|
2721
|
+
n.style.width = `${e + H}px`, i.querySelectorAll(`[${g}]`).forEach((o) => {
|
|
2718
2722
|
o.querySelectorAll(`[${u}]`).forEach((l, a) => {
|
|
2719
2723
|
if (a < t.length) {
|
|
2720
2724
|
const c = l;
|
|
@@ -2785,7 +2789,7 @@ const U = (i) => {
|
|
|
2785
2789
|
return [];
|
|
2786
2790
|
const s = i.querySelectorAll(`[${g}]`)[e];
|
|
2787
2791
|
return s ? (o = t == null ? void 0 : t.getBlockIdsFromCells(s.querySelectorAll(`[${u}]`))) != null ? o : [] : [];
|
|
2788
|
-
},
|
|
2792
|
+
}, Ps = (i, t, e) => {
|
|
2789
2793
|
var o;
|
|
2790
2794
|
if (!i)
|
|
2791
2795
|
return [];
|
|
@@ -2814,7 +2818,7 @@ const U = (i) => {
|
|
|
2814
2818
|
i.querySelectorAll(`[${u}]`).forEach((n) => {
|
|
2815
2819
|
t == null || t.ensureCellHasBlock(n);
|
|
2816
2820
|
});
|
|
2817
|
-
},
|
|
2821
|
+
}, Hs = (i, t, e) => {
|
|
2818
2822
|
const n = i.querySelectorAll(`[${g}]`);
|
|
2819
2823
|
t.forEach((s, o) => {
|
|
2820
2824
|
const r = n[o];
|
|
@@ -2929,7 +2933,7 @@ class Gs {
|
|
|
2929
2933
|
}
|
|
2930
2934
|
createHandle(t) {
|
|
2931
2935
|
const e = document.createElement("div"), n = this.getHandleLeftPx(t);
|
|
2932
|
-
return e.setAttribute(Ft, ""), e.setAttribute("data-col", String(t)), e.style.position = "absolute", e.style.top = `-${
|
|
2936
|
+
return e.setAttribute(Ft, ""), e.setAttribute("data-col", String(t)), e.style.position = "absolute", e.style.top = `-${H}px`, e.style.bottom = "0px", e.style.width = `${Ct}px`, e.style.left = `${n - Ct / 2}px`, e.style.cursor = "col-resize", e.style.zIndex = "2", e.style.background = "linear-gradient(to right, transparent 7px, #3b82f6 7px, #3b82f6 9px, transparent 9px)", e.style.opacity = "0", e.style.transition = "opacity 150ms ease", e.setAttribute("contenteditable", "false"), e.addEventListener("mouseenter", () => {
|
|
2933
2937
|
this.isDragging || (e.style.opacity = "1");
|
|
2934
2938
|
}), e.addEventListener("mouseleave", () => {
|
|
2935
2939
|
this.isDragging || (e.style.opacity = "0");
|
|
@@ -2971,7 +2975,7 @@ class Gs {
|
|
|
2971
2975
|
}
|
|
2972
2976
|
applyWidths() {
|
|
2973
2977
|
const t = this.colWidths.reduce((n, s) => n + s, 0);
|
|
2974
|
-
this.gridEl.style.width = `${t +
|
|
2978
|
+
this.gridEl.style.width = `${t + H}px`, this.gridEl.querySelectorAll(`[${Ws}]`).forEach((n) => {
|
|
2975
2979
|
n.querySelectorAll(`[${Ms}]`).forEach((o, r) => {
|
|
2976
2980
|
if (r < this.colWidths.length) {
|
|
2977
2981
|
const l = o;
|
|
@@ -3138,10 +3142,10 @@ class js {
|
|
|
3138
3142
|
this.dropIndicator = document.createElement("div");
|
|
3139
3143
|
const t = this.dropIndicator.style;
|
|
3140
3144
|
if (t.position = "absolute", t.backgroundColor = "#3b82f6", t.borderRadius = "1.5px", t.zIndex = "5", t.pointerEvents = "none", this.dropIndicator.setAttribute("contenteditable", "false"), this.dragType === "row")
|
|
3141
|
-
t.height = "3px", t.left = `${-
|
|
3145
|
+
t.height = "3px", t.left = `${-H}px`, t.right = "0", t.transition = "top 100ms ease";
|
|
3142
3146
|
else {
|
|
3143
3147
|
const e = this.grid.querySelectorAll(`[${g}]`), n = e[e.length - 1], s = n ? n.offsetTop + n.offsetHeight : 0;
|
|
3144
|
-
t.width = "3px", t.top = `${-
|
|
3148
|
+
t.width = "3px", t.top = `${-H}px`, t.height = `${s + H}px`, t.transition = "left 100ms ease";
|
|
3145
3149
|
}
|
|
3146
3150
|
this.grid.appendChild(this.dropIndicator);
|
|
3147
3151
|
}
|
|
@@ -3530,12 +3534,12 @@ class ao {
|
|
|
3530
3534
|
if (o + 1 >= n.length)
|
|
3531
3535
|
return;
|
|
3532
3536
|
const r = (n[o] + n[o + 1]) / 2, l = s.style;
|
|
3533
|
-
l.top = `${-
|
|
3537
|
+
l.top = `${-H / 2}px`, l.left = `${r}px`;
|
|
3534
3538
|
}), this.rowGrips.forEach((s, o) => {
|
|
3535
3539
|
if (o >= t.length)
|
|
3536
3540
|
return;
|
|
3537
3541
|
const r = t[o], l = r.offsetTop + r.offsetHeight / 2, a = s.style;
|
|
3538
|
-
a.left = `${-
|
|
3542
|
+
a.left = `${-H / 2}px`, a.top = `${l}px`;
|
|
3539
3543
|
});
|
|
3540
3544
|
}
|
|
3541
3545
|
/**
|
|
@@ -3745,7 +3749,7 @@ class So {
|
|
|
3745
3749
|
const t = this.element.firstElementChild;
|
|
3746
3750
|
if (t) {
|
|
3747
3751
|
if (this.readOnly) {
|
|
3748
|
-
|
|
3752
|
+
Hs(t, this.data.content, this.api);
|
|
3749
3753
|
return;
|
|
3750
3754
|
}
|
|
3751
3755
|
if (this.data.content = (n = (e = this.cellBlocks) == null ? void 0 : e.initializeCells(this.data.content)) != null ? n : this.data.content, this.isNewTable && G(t, this.cellBlocks), this.data.initialColWidth === void 0) {
|
|
@@ -3810,7 +3814,7 @@ class So {
|
|
|
3810
3814
|
return Ds(this.element, this.cellBlocks, t);
|
|
3811
3815
|
}
|
|
3812
3816
|
getBlockIdsInColumn(t) {
|
|
3813
|
-
return
|
|
3817
|
+
return Ps(this.element, this.cellBlocks, t);
|
|
3814
3818
|
}
|
|
3815
3819
|
initAddControls(t) {
|
|
3816
3820
|
var n;
|
|
@@ -4140,7 +4144,7 @@ const q = (i) => {
|
|
|
4140
4144
|
*/
|
|
4141
4145
|
synchronize(t) {
|
|
4142
4146
|
var r, l;
|
|
4143
|
-
const e = (r = t == null ? void 0 : t.anchorNode) != null ? r : t == null ? void 0 : t.focusNode, n = e && e.nodeType === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, s = (l = n == null ? void 0 : n.closest(
|
|
4147
|
+
const e = (r = t == null ? void 0 : t.anchorNode) != null ? r : t == null ? void 0 : t.focusNode, n = e && e.nodeType === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, s = (l = n == null ? void 0 : n.closest(P(E.editor))) != null ? l : n == null ? void 0 : n.ownerDocument;
|
|
4144
4148
|
if (!s)
|
|
4145
4149
|
return;
|
|
4146
4150
|
const o = `strong[${S.COLLAPSED_ACTIVE}="true"]`;
|
|
@@ -4178,7 +4182,7 @@ const q = (i) => {
|
|
|
4178
4182
|
const e = (r = t == null ? void 0 : t.anchorNode) != null ? r : t == null ? void 0 : t.focusNode;
|
|
4179
4183
|
if (!e)
|
|
4180
4184
|
return;
|
|
4181
|
-
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, s = n == null ? void 0 : n.closest(
|
|
4185
|
+
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, s = n == null ? void 0 : n.closest(P(E.editor));
|
|
4182
4186
|
if (!s)
|
|
4183
4187
|
return;
|
|
4184
4188
|
s.querySelectorAll(`strong[${S.COLLAPSED_LENGTH}]`).forEach((l) => {
|
|
@@ -4513,8 +4517,8 @@ class R {
|
|
|
4513
4517
|
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
4514
4518
|
if (!n)
|
|
4515
4519
|
return null;
|
|
4516
|
-
const s = (l = n.closest('[data-blok-component="paragraph"]')) != null ? l : n.closest(
|
|
4517
|
-
return s || n.closest(
|
|
4520
|
+
const s = (l = n.closest('[data-blok-component="paragraph"]')) != null ? l : n.closest(P(E.elementContent));
|
|
4521
|
+
return s || n.closest(P(E.editor));
|
|
4518
4522
|
}
|
|
4519
4523
|
}
|
|
4520
4524
|
const T = class T {
|
|
@@ -4921,7 +4925,7 @@ const Co = (i, t) => {
|
|
|
4921
4925
|
const t = window.getSelection();
|
|
4922
4926
|
if (!t)
|
|
4923
4927
|
return;
|
|
4924
|
-
const e = t.anchorNode, n = (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, s = n == null ? void 0 : n.closest(
|
|
4928
|
+
const e = t.anchorNode, n = (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, s = n == null ? void 0 : n.closest(P(E.editor));
|
|
4925
4929
|
if (!s)
|
|
4926
4930
|
return;
|
|
4927
4931
|
const o = s.querySelector("[data-blok-testid=inline-toolbar]");
|
|
@@ -4976,7 +4980,7 @@ const Co = (i, t) => {
|
|
|
4976
4980
|
*/
|
|
4977
4981
|
static findBlokScopeFromNode(t) {
|
|
4978
4982
|
const e = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
|
|
4979
|
-
return !e || typeof e.closest != "function" ? null : e.closest(`${
|
|
4983
|
+
return !e || typeof e.closest != "function" ? null : e.closest(`${P(E.interface)}, ${P(E.editor)}`);
|
|
4980
4984
|
}
|
|
4981
4985
|
/**
|
|
4982
4986
|
* Get a bold element at the boundary of a collapsed range
|
|
@@ -5020,7 +5024,7 @@ const Co = (i, t) => {
|
|
|
5020
5024
|
if (!e)
|
|
5021
5025
|
return !1;
|
|
5022
5026
|
const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
|
|
5023
|
-
return !!(n != null && n.closest(
|
|
5027
|
+
return !!(n != null && n.closest(P(E.editor)));
|
|
5024
5028
|
}
|
|
5025
5029
|
/**
|
|
5026
5030
|
* Get HTML content of a range with bold tags removed
|
|
@@ -5366,7 +5370,7 @@ const j = class j {
|
|
|
5366
5370
|
*/
|
|
5367
5371
|
getButtonElement() {
|
|
5368
5372
|
const t = document.querySelector(
|
|
5369
|
-
`${
|
|
5373
|
+
`${P(E.interface, Qe)} [data-blok-item-name="link"]`
|
|
5370
5374
|
);
|
|
5371
5375
|
return t && t !== this.nodes.button && (t.addEventListener("click", this.handleButtonClick, !0), this.nodes.button = t), t;
|
|
5372
5376
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jackuait/blok",
|
|
3
|
-
"version": "0.6.0-beta.
|
|
3
|
+
"version": "0.6.0-beta.9",
|
|
4
4
|
"description": "Blok — headless, highly extensible rich text editor built for developers who need to implement a block-based editing experience (similar to Notion) without building it from scratch",
|
|
5
5
|
"module": "dist/blok.mjs",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -38,6 +38,7 @@ export class BlocksAPI extends Module {
|
|
|
38
38
|
update: this.update,
|
|
39
39
|
composeBlockData: this.composeBlockData,
|
|
40
40
|
convert: this.convert,
|
|
41
|
+
setBlockParent: (blockId: string, parentId: string | null): void => this.setBlockParent(blockId, parentId),
|
|
41
42
|
stopBlockMutationWatching: (index: number): void => this.stopBlockMutationWatching(index),
|
|
42
43
|
splitBlock: this.splitBlock,
|
|
43
44
|
};
|
|
@@ -376,6 +377,23 @@ export class BlocksAPI extends Module {
|
|
|
376
377
|
return blocksToInsert.map((block) => new BlockAPI(block));
|
|
377
378
|
};
|
|
378
379
|
|
|
380
|
+
/**
|
|
381
|
+
* Sets the parent of a block, updating both the block's parentId and the parent's contentIds.
|
|
382
|
+
* @param blockId - id of the block to reparent
|
|
383
|
+
* @param parentId - id of the new parent block, or null for root level
|
|
384
|
+
*/
|
|
385
|
+
private setBlockParent(blockId: string, parentId: string | null): void {
|
|
386
|
+
const block = this.Blok.BlockManager.getBlockById(blockId);
|
|
387
|
+
|
|
388
|
+
if (block === undefined) {
|
|
389
|
+
logLabeled('There is no block with id `' + blockId + '`', 'warn');
|
|
390
|
+
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
this.Blok.BlockManager.setBlockParent(block, parentId);
|
|
395
|
+
}
|
|
396
|
+
|
|
379
397
|
/**
|
|
380
398
|
* Stops mutation watching on a block at the specified index.
|
|
381
399
|
* This is used to prevent spurious block-changed events during block replacement.
|
|
@@ -143,11 +143,10 @@ export class RectangleSelection extends Module {
|
|
|
143
143
|
* Check if pointer is within the content area's horizontal bounds.
|
|
144
144
|
* This determines whether we should close the toolbar when starting selection.
|
|
145
145
|
* Clicks outside the content area (to the left or right, in the margin/toolbar zone)
|
|
146
|
-
* should NOT close the toolbar.
|
|
147
|
-
*
|
|
146
|
+
* should NOT close the toolbar. Uses UI.contentRect which queries the first block's
|
|
147
|
+
* content element and caches the result.
|
|
148
148
|
*/
|
|
149
|
-
const
|
|
150
|
-
const contentRect = contentElement ? contentElement.getBoundingClientRect() : editorRect;
|
|
149
|
+
const contentRect = this.Blok.UI.contentRect;
|
|
151
150
|
const withinEditorHorizontally = pointerX >= contentRect.left && pointerX <= contentRect.right;
|
|
152
151
|
|
|
153
152
|
const elemWhereSelectionStart = document.elementFromPoint(pageX - scrollLeft, pointerY);
|
|
@@ -335,14 +335,14 @@ export class Toolbar extends Module<ToolbarNodes> {
|
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
const targetBlock = this.resolveTableCellBlock(unresolvedBlock);
|
|
339
|
-
|
|
340
338
|
/**
|
|
341
|
-
* Track whether the original block
|
|
342
|
-
*
|
|
343
|
-
*
|
|
339
|
+
* Track whether the original block is inside a table cell.
|
|
340
|
+
* Check the DOM directly rather than relying on resolution success,
|
|
341
|
+
* so that the flag is correct even when resolution falls back to the original block.
|
|
344
342
|
*/
|
|
345
|
-
this.hoveredBlockIsFromTableCell =
|
|
343
|
+
this.hoveredBlockIsFromTableCell = unresolvedBlock.holder.closest('[data-blok-table-cell-blocks]') !== null;
|
|
344
|
+
|
|
345
|
+
const targetBlock = this.resolveTableCellBlock(unresolvedBlock);
|
|
346
346
|
|
|
347
347
|
/** Clean up draggable on previous block if any */
|
|
348
348
|
if (this.hoveredBlock && this.hoveredBlock !== targetBlock) {
|
|
@@ -366,18 +366,12 @@ export class Toolbar extends Module<ToolbarNodes> {
|
|
|
366
366
|
* The toolbar still positions itself for toolbox/slash-search purposes,
|
|
367
367
|
* but plus button and settings toggler remain hidden.
|
|
368
368
|
*/
|
|
369
|
-
|
|
370
|
-
plusButton.style.display = 'none';
|
|
369
|
+
const displayValue = this.hoveredBlockIsFromTableCell ? 'none' : '';
|
|
371
370
|
|
|
372
|
-
|
|
373
|
-
settingsToggler.style.display = 'none';
|
|
374
|
-
}
|
|
375
|
-
} else {
|
|
376
|
-
plusButton.style.display = '';
|
|
371
|
+
plusButton.style.display = displayValue;
|
|
377
372
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
373
|
+
if (settingsToggler) {
|
|
374
|
+
settingsToggler.style.display = displayValue;
|
|
381
375
|
}
|
|
382
376
|
|
|
383
377
|
const targetBlockHolder = targetBlock.holder;
|
|
@@ -485,12 +479,22 @@ export class Toolbar extends Module<ToolbarNodes> {
|
|
|
485
479
|
this.positioner.setHoveredTarget(null); // No target for multi-block selection
|
|
486
480
|
this.positioner.resetCachedPosition(); // Reset cached position when moving to a new block
|
|
487
481
|
|
|
488
|
-
const { wrapper, plusButton } = this.nodes;
|
|
482
|
+
const { wrapper, plusButton, settingsToggler } = this.nodes;
|
|
489
483
|
|
|
490
484
|
if (!wrapper || !plusButton) {
|
|
491
485
|
return;
|
|
492
486
|
}
|
|
493
487
|
|
|
488
|
+
/**
|
|
489
|
+
* Restore plus button and settings toggler visibility for multi-block selection,
|
|
490
|
+
* in case they were hidden for table cell blocks.
|
|
491
|
+
*/
|
|
492
|
+
plusButton.style.display = '';
|
|
493
|
+
|
|
494
|
+
if (settingsToggler) {
|
|
495
|
+
settingsToggler.style.display = '';
|
|
496
|
+
}
|
|
497
|
+
|
|
494
498
|
const targetBlockHolder = targetBlock.holder;
|
|
495
499
|
|
|
496
500
|
const toolbarY = this.positioner.calculateToolbarY(
|
|
@@ -505,9 +509,6 @@ export class Toolbar extends Module<ToolbarNodes> {
|
|
|
505
509
|
this.positioner.moveToY(this.nodes, toolbarY);
|
|
506
510
|
targetBlockHolder.appendChild(wrapper);
|
|
507
511
|
|
|
508
|
-
/** Set up draggable on the target block using the settings toggler as drag handle */
|
|
509
|
-
const { settingsToggler } = this.nodes;
|
|
510
|
-
|
|
511
512
|
if (settingsToggler && !this.Blok.ReadOnly.isEnabled) {
|
|
512
513
|
targetBlock.setupDraggable(settingsToggler, this.Blok.DragManager);
|
|
513
514
|
}
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
PasteEvent,
|
|
14
14
|
ToolboxConfig,
|
|
15
15
|
ConversionConfig,
|
|
16
|
-
|
|
16
|
+
ToolSanitizerConfig,
|
|
17
17
|
PasteConfig,
|
|
18
18
|
} from '../../../types';
|
|
19
19
|
import { DATA_ATTR } from '../../components/constants';
|
|
@@ -369,10 +369,14 @@ export class Paragraph implements BlockTool {
|
|
|
369
369
|
*
|
|
370
370
|
* @returns SanitizerConfig
|
|
371
371
|
*/
|
|
372
|
-
public static get sanitize():
|
|
372
|
+
public static get sanitize(): ToolSanitizerConfig {
|
|
373
373
|
return {
|
|
374
374
|
text: {
|
|
375
375
|
br: true,
|
|
376
|
+
img: {
|
|
377
|
+
src: true,
|
|
378
|
+
style: true,
|
|
379
|
+
},
|
|
376
380
|
},
|
|
377
381
|
};
|
|
378
382
|
}
|
|
@@ -45,6 +45,7 @@ interface TableCellBlocksOptions {
|
|
|
45
45
|
export class TableCellBlocks {
|
|
46
46
|
private api: API;
|
|
47
47
|
private gridElement: HTMLElement;
|
|
48
|
+
private tableBlockId: string;
|
|
48
49
|
private _activeCellWithBlocks: CellPosition | null = null;
|
|
49
50
|
private onNavigateToCell?: CellNavigationCallback;
|
|
50
51
|
|
|
@@ -68,6 +69,7 @@ export class TableCellBlocks {
|
|
|
68
69
|
constructor(options: TableCellBlocksOptions) {
|
|
69
70
|
this.api = options.api;
|
|
70
71
|
this.gridElement = options.gridElement;
|
|
72
|
+
this.tableBlockId = options.tableBlockId;
|
|
71
73
|
this.onNavigateToCell = options.onNavigateToCell;
|
|
72
74
|
|
|
73
75
|
this.api.events.on('block changed', this.handleBlockMutation);
|
|
@@ -269,6 +271,7 @@ export class TableCellBlocks {
|
|
|
269
271
|
const block = this.api.blocks.insert('paragraph', { text }, {}, this.api.blocks.getBlocksCount(), false);
|
|
270
272
|
|
|
271
273
|
container.appendChild(block.holder);
|
|
274
|
+
this.api.blocks.setBlockParent(block.id, this.tableBlockId);
|
|
272
275
|
normalizedRow.push({ blocks: [block.id] });
|
|
273
276
|
}
|
|
274
277
|
|
|
@@ -315,6 +318,7 @@ export class TableCellBlocks {
|
|
|
315
318
|
}
|
|
316
319
|
|
|
317
320
|
container.appendChild(block.holder);
|
|
321
|
+
this.api.blocks.setBlockParent(blockId, this.tableBlockId);
|
|
318
322
|
mountedIds.push(blockId);
|
|
319
323
|
}
|
|
320
324
|
|
|
@@ -344,6 +348,7 @@ export class TableCellBlocks {
|
|
|
344
348
|
}
|
|
345
349
|
|
|
346
350
|
container.appendChild(block.holder);
|
|
351
|
+
this.api.blocks.setBlockParent(blockId, this.tableBlockId);
|
|
347
352
|
this.stripPlaceholders(container);
|
|
348
353
|
}
|
|
349
354
|
|
|
@@ -402,6 +407,7 @@ export class TableCellBlocks {
|
|
|
402
407
|
const block = this.api.blocks.insert('paragraph', { text: '' }, {}, this.api.blocks.getBlocksCount(), true);
|
|
403
408
|
|
|
404
409
|
container.appendChild(block.holder);
|
|
410
|
+
this.api.blocks.setBlockParent(block.id, this.tableBlockId);
|
|
405
411
|
this.stripPlaceholders(container);
|
|
406
412
|
}
|
|
407
413
|
|
package/types/api/blocks.d.ts
CHANGED
|
@@ -78,6 +78,14 @@ export interface Blocks {
|
|
|
78
78
|
*/
|
|
79
79
|
getChildren(parentId: string): BlockAPI[];
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Sets the parent of a block, updating both the block's parentId and the parent's contentIds.
|
|
83
|
+
*
|
|
84
|
+
* @param blockId - id of the block to reparent
|
|
85
|
+
* @param parentId - id of the new parent block, or null for root level
|
|
86
|
+
*/
|
|
87
|
+
setBlockParent(blockId: string, parentId: string | null): void;
|
|
88
|
+
|
|
81
89
|
/**
|
|
82
90
|
* Returns Blocks count
|
|
83
91
|
* @return {number}
|