@jackuait/blok 0.10.0-beta.8 → 0.10.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-CRvF-xVm.mjs → blok-DDu252IK.mjs} +1 -1
- package/dist/chunks/{constants-BOZ5plBi.mjs → constants-DMW9a31I.mjs} +1 -1
- package/dist/chunks/{tools-CnqCfv2L.mjs → tools-XmzH2rgQ.mjs} +10 -2
- 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/tools/table/table-cell-blocks.ts +30 -0
- package/src/tools/table/table-operations.ts +9 -0
package/dist/blok.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as e, t } from "./chunks/blok-
|
|
2
|
-
import { $n as n } from "./chunks/constants-
|
|
1
|
+
import { n as e, t } from "./chunks/blok-DDu252IK.mjs";
|
|
2
|
+
import { $n as n } from "./chunks/constants-DMW9a31I.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, At as i, Bn as a, Bt as o, C as s, Dn as c, E as l, En as u, Fn as d, Gn as f, Gt as p, Hn as m, In as h, It as g, Jn as _, Jt as v, Kn as ee, Kt as y, Ln as te, Mn as ne, Nn as re, On as ie, Ot as ae, Pn as oe, Qn as se, Qt as ce, Rn as le, S as ue, Sn as de, T as fe, Tn as pe, Un as b, Vn as me, Wn as he, Wt as ge, Xn as _e, Xt as ve, Yn as ye, Yt as be, Zn as x, Zt as xe, _ as Se, _n as Ce, an as we, b as S, bn as Te, dn as Ee, en as De, er as C, fn as Oe, ft as ke, g as Ae, gn as je, gt as Me, h as Ne, hn as Pe, in as w, jn as Fe, k as Ie, kn as Le, ln as Re, m as ze, mn as Be, nn as Ve, p as He, pn as Ue, qn as T, qt as We, rn as E, sn as Ge, tn as Ke, u as qe, un as Je, v as Ye, vn as Xe, vt as Ze, w as Qe, wn as D, x as $e, xn as et, y as tt, yn as nt, zn as rt, zt as it } from "./constants-
|
|
2
|
+
import { $n as t, $t as n, An as r, At as i, Bn as a, Bt as o, C as s, Dn as c, E as l, En as u, Fn as d, Gn as f, Gt as p, Hn as m, In as h, It as g, Jn as _, Jt as v, Kn as ee, Kt as y, Ln as te, Mn as ne, Nn as re, On as ie, Ot as ae, Pn as oe, Qn as se, Qt as ce, Rn as le, S as ue, Sn as de, T as fe, Tn as pe, Un as b, Vn as me, Wn as he, Wt as ge, Xn as _e, Xt as ve, Yn as ye, Yt as be, Zn as x, Zt as xe, _ as Se, _n as Ce, an as we, b as S, bn as Te, dn as Ee, en as De, er as C, fn as Oe, ft as ke, g as Ae, gn as je, gt as Me, h as Ne, hn as Pe, in as w, jn as Fe, k as Ie, kn as Le, ln as Re, m as ze, mn as Be, nn as Ve, p as He, pn as Ue, qn as T, qt as We, rn as E, sn as Ge, tn as Ke, u as qe, un as Je, v as Ye, vn as Xe, vt as Ze, w as Qe, wn as D, x as $e, xn as et, y as tt, yn as nt, zn as rt, zt as it } from "./constants-DMW9a31I.mjs";
|
|
3
3
|
import { n as at, t as O } from "./objectSpread2-CWwMYL_U.mjs";
|
|
4
4
|
import { n as k, t as ot } from "./tw-CqxBf-1Y.mjs";
|
|
5
5
|
import { r as st, t as ct } from "./lightweight-i18n-Cvv8CWh4.mjs";
|
|
@@ -129,7 +129,7 @@ var a = {
|
|
|
129
129
|
RIGHT: 2,
|
|
130
130
|
BACKWARD: 3,
|
|
131
131
|
FORWARD: 4
|
|
132
|
-
}, l = () => "0.10.0-beta.
|
|
132
|
+
}, l = () => "0.10.0-beta.9", u = /* @__PURE__ */ function(e) {
|
|
133
133
|
return e.VERBOSE = "VERBOSE", e.INFO = "INFO", e.WARN = "WARN", e.ERROR = "ERROR", e;
|
|
134
134
|
}({}), d = (e, t, n = "log", r, i = "color: inherit") => {
|
|
135
135
|
let a = typeof console > "u" ? void 0 : console;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as e, $n as t, A as n, B as r, Bt as i, Cn as a, Ct as o, D as s, Dt as c, Et as l, F as u, Ft as d, G as f, H as p, Ht as m, I as h, It as g, J as _, K as v, L as y, Lt as b, M as ee, Mt as x, N as te, Nt as ne, O as re, Ot as ie, P as ae, Pt as oe, Q as se, Qt as S, 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, Y as ye, Z as be, Zt as xe, _t as Se, a as Ce, at as we, bt as Te, c as Ee, cn as De, ct as Oe, d as ke, dt as Ae, en as je, er as C, et as Me, f as Ne, g as Pe, gt as Fe, h as Ie, ht as Le, i as Re, in as ze, it as Be, j as Ve, jt as He, kt as Ue, l as We, lt as Ge, mt as Ke, n as qe, nt as Je, o as Ye, ot as Xe, p as Ze, pt as Qe, q as $e, qn as et, qt as tt, r as nt, rn as w, rt, s as it, sn as at, st as ot, t as st, tt as ct, u as T, ut as lt, v as ut, wt as dt, xt as ft, yt as pt, z as mt, zt as ht } from "./constants-
|
|
1
|
+
import { $ as e, $n as t, A as n, B as r, Bt as i, Cn as a, Ct as o, D as s, Dt as c, Et as l, F as u, Ft as d, G as f, H as p, Ht as m, I as h, It as g, J as _, K as v, L as y, Lt as b, M as ee, Mt as x, N as te, Nt as ne, O as re, Ot as ie, P as ae, Pt as oe, Q as se, Qt as S, 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, Y as ye, Z as be, Zt as xe, _t as Se, a as Ce, at as we, bt as Te, c as Ee, cn as De, ct as Oe, d as ke, dt as Ae, en as je, er as C, et as Me, f as Ne, g as Pe, gt as Fe, h as Ie, ht as Le, i as Re, in as ze, it as Be, j as Ve, jt as He, kt as Ue, l as We, lt as Ge, mt as Ke, n as qe, nt as Je, o as Ye, ot as Xe, p as Ze, pt as Qe, q as $e, qn as et, qt as tt, r as nt, rn as w, rt, s as it, sn as at, st as ot, t as st, tt as ct, u as T, ut as lt, v as ut, wt as dt, xt as ft, yt as pt, z as mt, zt as ht } from "./constants-DMW9a31I.mjs";
|
|
2
2
|
import { t as E } from "./objectSpread2-CWwMYL_U.mjs";
|
|
3
3
|
import { n as D } from "./tw-CqxBf-1Y.mjs";
|
|
4
4
|
//#region src/components/utils/html.ts
|
|
@@ -2021,6 +2021,10 @@ var Ht = "outline-hidden py-[7px] mt-[2px] mb-px", Ut = "outline-hidden pl-0.5 l
|
|
|
2021
2021
|
this.handleBlockRemoved(n);
|
|
2022
2022
|
return;
|
|
2023
2023
|
}
|
|
2024
|
+
if (t === "block-moved") {
|
|
2025
|
+
this.handleBlockMoved(n);
|
|
2026
|
+
return;
|
|
2027
|
+
}
|
|
2024
2028
|
if (t !== "block-added" || n.target.id === this.tableBlockId) return;
|
|
2025
2029
|
let r = n.index;
|
|
2026
2030
|
if (r === void 0) return;
|
|
@@ -2250,6 +2254,10 @@ var Ht = "outline-hidden py-[7px] mt-[2px] mb-px", Ut = "outline-hidden pl-0.5 l
|
|
|
2250
2254
|
let r = this.getCell(n.row, n.col);
|
|
2251
2255
|
r && this.cellsPendingCheck.add(r), this.schedulePendingCellCheck();
|
|
2252
2256
|
}
|
|
2257
|
+
handleBlockMoved(e) {
|
|
2258
|
+
let t = e.target.id, n = this.model.findCellForBlock(t);
|
|
2259
|
+
n && (this.gridElement.contains(e.target.holder) || this.model.removeBlockFromCell(n.row, n.col, t));
|
|
2260
|
+
}
|
|
2253
2261
|
syncBlockToModel(e, t) {
|
|
2254
2262
|
let n = this.getCellPosition(e);
|
|
2255
2263
|
n && this.model.addBlockToCell(n.row, n.col, t);
|
|
@@ -2961,7 +2969,7 @@ var wr = (e) => {
|
|
|
2961
2969
|
let e = n.blocks.getBlockIndex(t);
|
|
2962
2970
|
if (e === void 0) continue;
|
|
2963
2971
|
let r = n.blocks.getBlockByIndex(e);
|
|
2964
|
-
r && o.appendChild(r.holder);
|
|
2972
|
+
r && (r.holder.closest("[data-blok-table-cell-blocks]") || o.appendChild(r.holder));
|
|
2965
2973
|
}
|
|
2966
2974
|
o.querySelectorAll("[data-blok-placeholder-active]").forEach((e) => {
|
|
2967
2975
|
e.removeAttribute("data-blok-placeholder-active");
|
package/dist/full.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as e, t } from "./chunks/blok-
|
|
2
|
-
import { $n as n } from "./chunks/constants-
|
|
1
|
+
import { n as e, t } from "./chunks/blok-DDu252IK.mjs";
|
|
2
|
+
import { $n as n } from "./chunks/constants-DMW9a31I.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-XmzH2rgQ.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-DDu252IK.mjs";
|
|
2
|
+
import "./chunks/constants-DMW9a31I.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-DMW9a31I.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-XmzH2rgQ.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.0-beta.
|
|
3
|
+
"version": "0.10.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",
|
|
@@ -618,6 +618,12 @@ export class TableCellBlocks {
|
|
|
618
618
|
return;
|
|
619
619
|
}
|
|
620
620
|
|
|
621
|
+
if (type === 'block-moved') {
|
|
622
|
+
this.handleBlockMoved(detail);
|
|
623
|
+
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
|
|
621
627
|
if (type !== 'block-added') {
|
|
622
628
|
return;
|
|
623
629
|
}
|
|
@@ -756,6 +762,30 @@ export class TableCellBlocks {
|
|
|
756
762
|
this.schedulePendingCellCheck();
|
|
757
763
|
}
|
|
758
764
|
|
|
765
|
+
/**
|
|
766
|
+
* Handle a block-moved event: if the block left this table (its holder is
|
|
767
|
+
* no longer inside our grid), remove the stale reference from the model.
|
|
768
|
+
*
|
|
769
|
+
* Without this, cross-table moves leave ghost entries in the source table's
|
|
770
|
+
* model, causing the same block ID to appear in two tables' saved data.
|
|
771
|
+
*/
|
|
772
|
+
private handleBlockMoved(detail: { target: { id: string; holder: HTMLElement } }): void {
|
|
773
|
+
const blockId = detail.target.id;
|
|
774
|
+
const cellPos = this.model.findCellForBlock(blockId);
|
|
775
|
+
|
|
776
|
+
if (!cellPos) {
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
// If the holder is still inside our grid, the block was moved within
|
|
781
|
+
// this table — nothing to clean up.
|
|
782
|
+
if (this.gridElement.contains(detail.target.holder)) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
this.model.removeBlockFromCell(cellPos.row, cellPos.col, blockId);
|
|
787
|
+
}
|
|
788
|
+
|
|
759
789
|
/**
|
|
760
790
|
* Find the DOM cell's row/col position and add the block to the model.
|
|
761
791
|
*/
|
|
@@ -313,6 +313,15 @@ export const mountCellBlocksReadOnly = (
|
|
|
313
313
|
continue;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
// Guard: if the block holder is already inside another table cell's
|
|
317
|
+
// blocks container, skip it. Without this check, appendChild would
|
|
318
|
+
// move (steal) the DOM node from the first table, leaving its cell
|
|
319
|
+
// empty. This can happen when corrupted data references the same
|
|
320
|
+
// block in multiple tables.
|
|
321
|
+
if (block.holder.closest(`[${CELL_BLOCKS_ATTR}]`)) {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
|
|
316
325
|
container.appendChild(block.holder);
|
|
317
326
|
}
|
|
318
327
|
|