@jackuait/blok 0.10.1 → 0.10.2
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-u_68bnlk.mjs → blok-D-T1XZ92.mjs} +8 -8
- package/dist/chunks/{constants-VDhCUk4c.mjs → constants-CaB-mlB5.mjs} +1 -1
- package/dist/chunks/{tools-1ZFajlGN.mjs → tools-BFK2MvVI.mjs} +3 -3
- package/dist/full.mjs +3 -3
- package/dist/react.mjs +2 -2
- package/dist/tools.mjs +2 -2
- package/package.json +1 -1
- package/src/components/modules/toolbar/index.ts +21 -9
- package/src/tools/code/index.ts +4 -0
package/dist/blok.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as e, t } from "./chunks/blok-
|
|
2
|
-
import { nr as n } from "./chunks/constants-
|
|
1
|
+
import { n as e, t } from "./chunks/blok-D-T1XZ92.mjs";
|
|
2
|
+
import { nr as n } from "./chunks/constants-CaB-mlB5.mjs";
|
|
3
3
|
export { t as Blok, n as DATA_ATTR, e as version };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./chunk-D6kmoKXy.mjs";
|
|
2
|
-
import { $n as t, $t as n, An as r, Bn as i, C as a, Cn as o, Dn as s, E as c, Fn as l, Gn as u, Hn as d, Ht as f, In as p, Jn as m, Jt as h, Kn as g, Ln as _, Mn as ee, Nn as te, On as v, Pn as ne, Pt as re, Qn as ie, Qt as ae, Rn as oe, S as se, Sn as ce, T as le, Tn as ue, Un as de, Ut as fe, Vn as pe, Wn as me, Xn as y, Xt as he, Yn as ge, Yt as _e, Zn as b, Zt as ve, _ as ye, _n as be, _t as xe, an as Se, b as x, bn as Ce, bt as we, cn as Te, en as Ee, er as S, fn as De, g as Oe, gn as ke, h as Ae, hn as je, in as Me, j as Ne, jn as Pe, jt as Fe, kn as Ie, m as Le, mn as Re, nn as ze, nr as C, on as w, p as Be, pn as Ve, pt as He, qn as Ue, qt as We, rn as Ge, rr as T, sn as E, tn as Ke, tr as qe, u as Je, un as Ye, v as Xe, vn as Ze, w as Qe, wn as $e, x as et, xn as tt, y as nt, yn as rt, zn as it, zt as at } from "./constants-
|
|
2
|
+
import { $n as t, $t as n, An as r, Bn as i, C as a, Cn as o, Dn as s, E as c, Fn as l, Gn as u, Hn as d, Ht as f, In as p, Jn as m, Jt as h, Kn as g, Ln as _, Mn as ee, Nn as te, On as v, Pn as ne, Pt as re, Qn as ie, Qt as ae, Rn as oe, S as se, Sn as ce, T as le, Tn as ue, Un as de, Ut as fe, Vn as pe, Wn as me, Xn as y, Xt as he, Yn as ge, Yt as _e, Zn as b, Zt as ve, _ as ye, _n as be, _t as xe, an as Se, b as x, bn as Ce, bt as we, cn as Te, en as Ee, er as S, fn as De, g as Oe, gn as ke, h as Ae, hn as je, in as Me, j as Ne, jn as Pe, jt as Fe, kn as Ie, m as Le, mn as Re, nn as ze, nr as C, on as w, p as Be, pn as Ve, pt as He, qn as Ue, qt as We, rn as Ge, rr as T, sn as E, tn as Ke, tr as qe, u as Je, un as Ye, v as Xe, vn as Ze, w as Qe, wn as $e, x as et, xn as tt, y as nt, yn as rt, zn as it, zt as at } from "./constants-CaB-mlB5.mjs";
|
|
3
3
|
import { n as ot, t as D } from "./objectSpread2-CWwMYL_U.mjs";
|
|
4
4
|
import { n as O, t as st } from "./tw-CqxBf-1Y.mjs";
|
|
5
5
|
import { r as ct, t as lt } from "./lightweight-i18n-DZmo8dAI.mjs";
|
|
@@ -10802,9 +10802,9 @@ var Dd = {
|
|
|
10802
10802
|
this.Blok.BlockManager.blocks.length === 1 && a.isEmpty && !ee ? this.blockTunesToggler.hide() : this.blockTunesToggler.show(), this.open();
|
|
10803
10803
|
let te = a.name === "header" && a.holder.querySelector("[data-blok-toggle-arrow]") !== null;
|
|
10804
10804
|
if ((a.name === "callout" || a.name === "toggle" || te) && this.nodes.actions && (this.nodes.actions.style.pointerEvents = "none", this.restoreSettingsTogglerForLeftEdgeBlock(a)), g && this.nodes.content) {
|
|
10805
|
-
var v, ne;
|
|
10806
|
-
let e =
|
|
10807
|
-
this.nodes.content.style.marginLeft = `${Math.max(
|
|
10805
|
+
var v, ne, re;
|
|
10806
|
+
let e = (v = this.nodes.wrapper) == null ? void 0 : v.getBoundingClientRect(), t = g.getBoundingClientRect(), n = e ? Math.max(0, t.left - e.left) : 0, r = (ne = (re = this.nodes.actions) == null ? void 0 : re.offsetWidth) == null ? 0 : ne;
|
|
10807
|
+
this.nodes.content.style.marginLeft = `${Math.max(n, r)}px`, this.nodes.content.style.maxWidth = `${t.width}px`;
|
|
10808
10808
|
}
|
|
10809
10809
|
}
|
|
10810
10810
|
moveAndOpenForMultipleBlocks(e) {
|
|
@@ -10830,14 +10830,14 @@ var Dd = {
|
|
|
10830
10830
|
this.positioner.moveToY(this.nodes, s), o.appendChild(r), a && !this.Blok.ReadOnly.isEnabled && n.setupDraggable(a, this.Blok.DragManager);
|
|
10831
10831
|
let c = o.querySelector(`[${C.elementContent}]`);
|
|
10832
10832
|
if (c && this.toolboxInstance.updateLeftAlignElement(c), this.positioner.applyContentOffset(this.nodes, n), this.blockTunesToggler.show(), this.open(), c && this.nodes.content) {
|
|
10833
|
-
var l, u;
|
|
10834
|
-
let e =
|
|
10835
|
-
this.nodes.content.style.marginLeft = `${Math.max(
|
|
10833
|
+
var l, u, d;
|
|
10834
|
+
let e = (l = this.nodes.wrapper) == null ? void 0 : l.getBoundingClientRect(), t = c.getBoundingClientRect(), n = e ? Math.max(0, t.left - e.left) : 0, r = (u = (d = this.nodes.actions) == null ? void 0 : d.offsetWidth) == null ? 0 : u;
|
|
10835
|
+
this.nodes.content.style.marginLeft = `${Math.max(n, r)}px`, this.nodes.content.style.maxWidth = `${t.width}px`;
|
|
10836
10836
|
}
|
|
10837
10837
|
}
|
|
10838
10838
|
close(e) {
|
|
10839
10839
|
var t, n, r, i;
|
|
10840
|
-
this.Blok.ReadOnly.isEnabled || ((t = this.nodes.wrapper) == null || t.classList.remove(this.CSS.toolbarOpened), (n = this.nodes.wrapper) == null || n.classList.add(this.CSS.toolbarClosed), (r = this.nodes.wrapper) == null || r.removeAttribute("data-blok-opened"), this.blockActions.hide(), (i = this.toolboxInstance) == null || i.close(), this.Blok.BlockSettings.close(), this.hoveredBlock = null, this.hoveredBlockIsFromTableCell = !1, (e == null ? void 0 : e.setExplicitlyClosed) !== !1 && (this.explicitlyClosed = !0, this.Blok.UI.resetBlockHoverState()), this.nodes.plusButton && (this.nodes.plusButton.style.display = "", this.nodes.plusButton.style.color = ""), this.nodes.settingsToggler && (this.nodes.settingsToggler.style.display = "", this.nodes.settingsToggler.style.color = ""), this.nodes.actions && (this.nodes.actions.style.transform = ""), this.nodes.content && (this.nodes.content.style.marginLeft = ""), this.positioner.setHoveredTarget(null), this.reset());
|
|
10840
|
+
this.Blok.ReadOnly.isEnabled || ((t = this.nodes.wrapper) == null || t.classList.remove(this.CSS.toolbarOpened), (n = this.nodes.wrapper) == null || n.classList.add(this.CSS.toolbarClosed), (r = this.nodes.wrapper) == null || r.removeAttribute("data-blok-opened"), this.blockActions.hide(), (i = this.toolboxInstance) == null || i.close(), this.Blok.BlockSettings.close(), this.hoveredBlock = null, this.hoveredBlockIsFromTableCell = !1, (e == null ? void 0 : e.setExplicitlyClosed) !== !1 && (this.explicitlyClosed = !0, this.Blok.UI.resetBlockHoverState()), this.nodes.plusButton && (this.nodes.plusButton.style.display = "", this.nodes.plusButton.style.color = ""), this.nodes.settingsToggler && (this.nodes.settingsToggler.style.display = "", this.nodes.settingsToggler.style.color = ""), this.nodes.actions && (this.nodes.actions.style.transform = ""), this.nodes.content && (this.nodes.content.style.marginLeft = "", this.nodes.content.style.maxWidth = ""), this.positioner.setHoveredTarget(null), this.reset());
|
|
10841
10841
|
}
|
|
10842
10842
|
skipNextSettingsToggle() {
|
|
10843
10843
|
this.settingsTogglerHandler.skipNextToggle();
|
|
@@ -130,7 +130,7 @@ var a = {
|
|
|
130
130
|
RIGHT: 2,
|
|
131
131
|
BACKWARD: 3,
|
|
132
132
|
FORWARD: 4
|
|
133
|
-
}, l = () => "0.10.
|
|
133
|
+
}, l = () => "0.10.2", u = /* @__PURE__ */ function(e) {
|
|
134
134
|
return e.VERBOSE = "VERBOSE", e.INFO = "INFO", e.WARN = "WARN", e.ERROR = "ERROR", e;
|
|
135
135
|
}({}), d = (e, t, n = "log", r, i = "color: inherit") => {
|
|
136
136
|
let a = typeof console > "u" ? void 0 : console;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as e, A as t, At as n, B as r, Bt as i, Ct as a, D as o, Dt as s, En as c, Et as l, F as u, Ft as d, G as f, Gt as p, H as m, Ht as h, I as g, It as _, J as v, K as ee, Kt as y, L as b, Lt as x, M as S, Mt as te, N as ne, Nt as re, O as ie, Ot as ae, P as oe, Q as se, R as ce, Rt as le, St as ue, Tt as de, U as fe, Ut as pe, V as me, Vt as he, W as ge, Wt as _e, X as ve, Xn as ye, Xt as be, Y as xe, Z as Se, _t as Ce, a as we, at as Te, c as Ee, ct as De, d as Oe, dn as ke, dt as Ae, en as je, et as Me, f as Ne, ft as Pe, g as Fe, gt as Ie, h as Le, ht as Re, i as ze, it as Be, jt as Ve, k as He, kt as Ue, l as We, lt as Ge, mt as Ke, n as qe, nn as Je, nr as C, nt as Ye, o as Xe, on as w, ot as Ze, p as Qe, q as $e, qt as et, r as tt, rn as nt, rr as T, rt, s as it, sn as at, st as ot, t as st, tn as E, tt as ct, u as D, un as lt, ut, v as dt, vt as ft, wt as pt, xt as mt, yt as ht, z as gt, zt as _t } from "./constants-
|
|
1
|
+
import { $ as e, A as t, At as n, B as r, Bt as i, Ct as a, D as o, Dt as s, En as c, Et as l, F as u, Ft as d, G as f, Gt as p, H as m, Ht as h, I as g, It as _, J as v, K as ee, Kt as y, L as b, Lt as x, M as S, Mt as te, N as ne, Nt as re, O as ie, Ot as ae, P as oe, Q as se, R as ce, Rt as le, St as ue, Tt as de, U as fe, Ut as pe, V as me, Vt as he, W as ge, Wt as _e, X as ve, Xn as ye, Xt as be, Y as xe, Z as Se, _t as Ce, a as we, at as Te, c as Ee, ct as De, d as Oe, dn as ke, dt as Ae, en as je, et as Me, f as Ne, ft as Pe, g as Fe, gt as Ie, h as Le, ht as Re, i as ze, it as Be, jt as Ve, k as He, kt as Ue, l as We, lt as Ge, mt as Ke, n as qe, nn as Je, nr as C, nt as Ye, o as Xe, on as w, ot as Ze, p as Qe, q as $e, qt as et, r as tt, rn as nt, rr as T, rt, s as it, sn as at, st as ot, t as st, tn as E, tt as ct, u as D, un as lt, ut, v as dt, vt as ft, wt as pt, xt as mt, yt as ht, z as gt, zt as _t } from "./constants-CaB-mlB5.mjs";
|
|
2
2
|
import { t as O } from "./objectSpread2-CWwMYL_U.mjs";
|
|
3
3
|
import { n as k } from "./tw-CqxBf-1Y.mjs";
|
|
4
4
|
//#region src/components/utils/html.ts
|
|
@@ -7257,7 +7257,7 @@ var Ls = 1500, Rs = class {
|
|
|
7257
7257
|
return e.code.trim() !== "";
|
|
7258
7258
|
}
|
|
7259
7259
|
merge(e) {
|
|
7260
|
-
this._data.code += "\n" + e.code, this._dom && (this._dom.codeElement.textContent = this._data.code), this.highlightCode();
|
|
7260
|
+
this._data.code += "\n" + e.code, this._dom && (this._dom.codeElement.textContent = this._data.code, this.syncTrailingBr(), this.updateGutter()), this.highlightCode();
|
|
7261
7261
|
}
|
|
7262
7262
|
renderSettings() {
|
|
7263
7263
|
let e = this._data.language, t = this._detectedLanguage, n = t !== null && t !== e, r = [];
|
|
@@ -7296,7 +7296,7 @@ var Ls = 1500, Rs = class {
|
|
|
7296
7296
|
this._data.code = t;
|
|
7297
7297
|
}
|
|
7298
7298
|
}
|
|
7299
|
-
this._dom && (this._dom.codeElement.textContent = this._data.code), this.highlightCode();
|
|
7299
|
+
this._dom && (this._dom.codeElement.textContent = this._data.code, this.syncTrailingBr(), this.updateGutter()), this.highlightCode();
|
|
7300
7300
|
}
|
|
7301
7301
|
setLanguage(e) {
|
|
7302
7302
|
this._data.language = e;
|
package/dist/full.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as e, t } from "./chunks/blok-
|
|
2
|
-
import { nr as n } from "./chunks/constants-
|
|
1
|
+
import { n as e, t } from "./chunks/blok-D-T1XZ92.mjs";
|
|
2
|
+
import { nr as n } from "./chunks/constants-CaB-mlB5.mjs";
|
|
3
3
|
import { t as r } from "./chunks/objectSpread2-CWwMYL_U.mjs";
|
|
4
|
-
import { _ as i, a, c as o, g as s, i as c, l, m as u, n as d, o as f, s as p, t as m, v as h } from "./chunks/tools-
|
|
4
|
+
import { _ as i, a, c as o, g as s, i as c, l, m as u, n as d, o as f, s as p, t as m, v as h } from "./chunks/tools-BFK2MvVI.mjs";
|
|
5
5
|
//#region src/full.ts
|
|
6
6
|
var g = {
|
|
7
7
|
paragraph: {
|
package/dist/react.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as e } from "./chunks/blok-
|
|
2
|
-
import "./chunks/constants-
|
|
1
|
+
import { t as e } from "./chunks/blok-D-T1XZ92.mjs";
|
|
2
|
+
import "./chunks/constants-CaB-mlB5.mjs";
|
|
3
3
|
import { t } from "./chunks/objectSpread2-CWwMYL_U.mjs";
|
|
4
4
|
import { t as n } from "./chunks/objectWithoutProperties-D0XxKB4n.mjs";
|
|
5
5
|
import { forwardRef as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
|
package/dist/tools.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { m as e } from "./chunks/constants-
|
|
2
|
-
import { _ as t, a as n, c as r, d as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as g, u as _, v } from "./chunks/tools-
|
|
1
|
+
import { m as e } from "./chunks/constants-CaB-mlB5.mjs";
|
|
2
|
+
import { _ as t, a as n, c as r, d as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as g, u as _, v } from "./chunks/tools-BFK2MvVI.mjs";
|
|
3
3
|
export { l as Bold, p as Callout, _ as Code, e as Convert, a as Divider, t as Header, m as InlineCode, r as Italic, h as Link, o as List, f as Marker, v as Paragraph, i as Quote, c as Strikethrough, s as Table, u as Toggle, n as Underline, g as defaultBlockTools, d as defaultInlineTools };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jackuait/blok",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
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",
|
|
@@ -526,19 +526,26 @@ export class Toolbar extends Module<ToolbarNodes> {
|
|
|
526
526
|
}
|
|
527
527
|
|
|
528
528
|
/**
|
|
529
|
-
* Sync toolbar content wrapper's
|
|
530
|
-
* so toolbar buttons align with the block content edge
|
|
531
|
-
* consumer CSS
|
|
529
|
+
* Sync toolbar content wrapper's position and width with the block content element
|
|
530
|
+
* so toolbar buttons align with the block content edge regardless of whether
|
|
531
|
+
* the consumer uses CSS margin or overrides max-width (e.g. wide-mode).
|
|
532
|
+
*
|
|
533
|
+
* Uses getBoundingClientRect to get the actual visual offset rather than reading
|
|
534
|
+
* CSS marginLeft, which does not account for cases where max-width is removed
|
|
535
|
+
* and the content fills the full container width.
|
|
532
536
|
*
|
|
533
537
|
* Uses Math.max to guarantee the actions container (positioned via right:100%)
|
|
534
538
|
* never extends beyond the left edge of the viewport, which would make the
|
|
535
|
-
|
|
539
|
+
* drag handle unreachable by pointer events.
|
|
536
540
|
*/
|
|
537
541
|
if (blockContentElement && this.nodes.content) {
|
|
538
|
-
const
|
|
542
|
+
const holderRect = this.nodes.wrapper?.getBoundingClientRect();
|
|
543
|
+
const contentRect = blockContentElement.getBoundingClientRect();
|
|
544
|
+
const visualOffset = holderRect ? Math.max(0, contentRect.left - holderRect.left) : 0;
|
|
539
545
|
const actionsWidth = this.nodes.actions?.offsetWidth ?? 0;
|
|
540
546
|
|
|
541
|
-
this.nodes.content.style.marginLeft = `${Math.max(
|
|
547
|
+
this.nodes.content.style.marginLeft = `${Math.max(visualOffset, actionsWidth)}px`;
|
|
548
|
+
this.nodes.content.style.maxWidth = `${contentRect.width}px`;
|
|
542
549
|
}
|
|
543
550
|
}
|
|
544
551
|
|
|
@@ -659,14 +666,18 @@ export class Toolbar extends Module<ToolbarNodes> {
|
|
|
659
666
|
this.open();
|
|
660
667
|
|
|
661
668
|
/**
|
|
662
|
-
* Sync toolbar content wrapper's
|
|
669
|
+
* Sync toolbar content wrapper's position and width with the block content element.
|
|
670
|
+
* Uses getBoundingClientRect so wide-mode content (max-width: none) is handled correctly.
|
|
663
671
|
* Clamp to actionsWidth so actions never extend beyond the left viewport edge.
|
|
664
672
|
*/
|
|
665
673
|
if (blockContentElement && this.nodes.content) {
|
|
666
|
-
const
|
|
674
|
+
const holderRect = this.nodes.wrapper?.getBoundingClientRect();
|
|
675
|
+
const contentRect = blockContentElement.getBoundingClientRect();
|
|
676
|
+
const visualOffset = holderRect ? Math.max(0, contentRect.left - holderRect.left) : 0;
|
|
667
677
|
const actionsWidth = this.nodes.actions?.offsetWidth ?? 0;
|
|
668
678
|
|
|
669
|
-
this.nodes.content.style.marginLeft = `${Math.max(
|
|
679
|
+
this.nodes.content.style.marginLeft = `${Math.max(visualOffset, actionsWidth)}px`;
|
|
680
|
+
this.nodes.content.style.maxWidth = `${contentRect.width}px`;
|
|
670
681
|
}
|
|
671
682
|
}
|
|
672
683
|
|
|
@@ -732,6 +743,7 @@ export class Toolbar extends Module<ToolbarNodes> {
|
|
|
732
743
|
}
|
|
733
744
|
if (this.nodes.content) {
|
|
734
745
|
this.nodes.content.style.marginLeft = '';
|
|
746
|
+
this.nodes.content.style.maxWidth = '';
|
|
735
747
|
}
|
|
736
748
|
this.positioner.setHoveredTarget(null);
|
|
737
749
|
|
package/src/tools/code/index.ts
CHANGED
|
@@ -286,6 +286,8 @@ export class CodeTool implements BlockTool {
|
|
|
286
286
|
|
|
287
287
|
if (this._dom) {
|
|
288
288
|
this._dom.codeElement.textContent = this._data.code;
|
|
289
|
+
this.syncTrailingBr();
|
|
290
|
+
this.updateGutter();
|
|
289
291
|
}
|
|
290
292
|
|
|
291
293
|
void this.highlightCode();
|
|
@@ -348,6 +350,8 @@ export class CodeTool implements BlockTool {
|
|
|
348
350
|
|
|
349
351
|
if (this._dom) {
|
|
350
352
|
this._dom.codeElement.textContent = this._data.code;
|
|
353
|
+
this.syncTrailingBr();
|
|
354
|
+
this.updateGutter();
|
|
351
355
|
}
|
|
352
356
|
|
|
353
357
|
void this.highlightCode();
|