@jackuait/blok 0.8.0 → 0.8.1

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 CHANGED
@@ -1,3 +1,3 @@
1
- import { Mn as e } from "./chunks/constants-CjWRVOdm.mjs";
2
- import { n as t, t as n } from "./chunks/blok-CdiMFzDz.mjs";
1
+ import { Mn as e } from "./chunks/constants-CuG2mgIj.mjs";
2
+ import { n as t, t as n } from "./chunks/blok-Ddy2vDUq.mjs";
3
3
  export { n as Blok, e as DATA_ATTR, t as version };
@@ -1,4 +1,4 @@
1
- import { $ as e, $t as t, An as n, At as r, Bt as i, C as a, Cn as o, Ct as s, Dn as c, Dt as l, E as u, En as d, Et as f, Ft as p, Gt as m, Ht as h, It as g, Jt as _, Kt as ee, Lt as v, Mn as y, Mt as te, Nn as b, Nt as ne, O as re, On as ie, Ot as ae, Pn as oe, Pt as se, Q as ce, Qt as le, Rt as ue, S as de, Sn as x, T as fe, Tn as pe, Tt as me, Ut as he, Wt as ge, Xt as _e, Yt as ve, Zt as ye, _ as be, _n as xe, an as Se, b as S, bn as Ce, cn as we, ct as Te, dn as Ee, en as De, et as Oe, fn as ke, g as Ae, gn as je, h as Me, hn as Ne, ht as Pe, in as Fe, jn as Ie, jt as Le, kn as Re, kt as ze, ln as Be, m as Ve, mn as He, on as C, p as Ue, pn as We, qt as Ge, rn as w, sn as Ke, tn as qe, u as Je, un as Ye, ut as Xe, v as Ze, vn as Qe, vt as $e, w as et, wn as tt, wt as nt, x as rt, xn as T, y as it, yn as at, yt as ot } from "./constants-CjWRVOdm.mjs";
1
+ import { $ as e, $t as t, An as n, At as r, Bt as i, C as a, Cn as o, Ct as s, Dn as c, Dt as l, E as u, En as d, Et as f, Ft as p, Gt as m, Ht as h, It as g, Jt as _, Kt as ee, Lt as v, Mn as y, Mt as te, Nn as b, Nt as ne, O as re, On as ie, Ot as ae, Pn as oe, Pt as se, Q as ce, Qt as le, Rt as ue, S as de, Sn as x, T as fe, Tn as pe, Tt as me, Ut as he, Wt as ge, Xt as _e, Yt as ve, Zt as ye, _ as be, _n as xe, an as Se, b as S, bn as Ce, cn as we, ct as Te, dn as Ee, en as De, et as Oe, fn as ke, g as Ae, gn as je, h as Me, hn as Ne, ht as Pe, in as Fe, jn as Ie, jt as Le, kn as Re, kt as ze, ln as Be, m as Ve, mn as He, on as C, p as Ue, pn as We, qt as Ge, rn as w, sn as Ke, tn as qe, u as Je, un as Ye, ut as Xe, v as Ze, vn as Qe, vt as $e, w as et, wn as tt, wt as nt, x as rt, xn as T, y as it, yn as at, yt as ot } from "./constants-CuG2mgIj.mjs";
2
2
  import { n as st, t as E } from "./objectSpread2-CyPxu8-u.mjs";
3
3
  import { n as D, t as ct } from "./tw-DmW6-pCY.mjs";
4
4
  import { r as lt, t as ut } from "./lightweight-i18n-BPeH69Dl.mjs";
@@ -8374,29 +8374,30 @@ var cu = class {
8374
8374
  let { BlockManager: r, Caret: i } = n.Blok;
8375
8375
  if (!e.length) return;
8376
8376
  if (e.length > 1) {
8377
+ var a, o, s, c, l;
8377
8378
  n.redirectToTableParentIfNeeded(e, r);
8378
- let o = [];
8379
- for (let [s, c] of e.entries()) {
8380
- var a;
8379
+ let d = r.currentBlock, f = (a = d == null || (o = d.holder) == null ? void 0 : o.querySelector("[data-blok-toggle-children]")) == null ? null : a, p = f !== null && !f.contains((s = d == null ? void 0 : d.currentInput) == null ? null : s) ? (c = d == null ? void 0 : d.id) == null ? null : c : (l = d == null ? void 0 : d.parentId) == null ? null : l, m = [];
8380
+ for (let [a, o] of e.entries()) {
8381
+ var u;
8381
8382
  n.Blok.YjsManager.stopCapturing();
8382
- let e = s === 0 && t && ((a = r.currentBlock) == null ? void 0 : a.isEmpty) === !0 ? await r.paste(c.tool, c.event, !0) : await r.paste(c.tool, c.event);
8383
- i.setToBlock(e, i.positions.END), o.push(e), n.applyPastedBlockParent(e, c, o, r);
8383
+ let e = a === 0 && t && ((u = r.currentBlock) == null ? void 0 : u.isEmpty) === !0 ? await r.paste(o.tool, o.event, !0) : await r.paste(o.tool, o.event);
8384
+ i.setToBlock(e, i.positions.END), m.push(e), n.applyPastedBlockParent(e, o, m, r, p);
8384
8385
  }
8385
8386
  r.currentBlock && i.setToBlock(r.currentBlock, i.positions.END);
8386
8387
  return;
8387
8388
  }
8388
- let [o] = e;
8389
- if (o.isBlock) {
8390
- await n.processSingleBlock(o, t);
8389
+ let [d] = e;
8390
+ if (d.isBlock) {
8391
+ await n.processSingleBlock(d, t);
8391
8392
  return;
8392
8393
  }
8393
- await n.processInlinePaste(o, t);
8394
+ await n.processInlinePaste(d, t);
8394
8395
  }
8395
- applyPastedBlockParent(e, t, n, r) {
8396
+ applyPastedBlockParent(e, t, n, r, i) {
8396
8397
  if (t.parentPasteIndex !== void 0) {
8397
8398
  let i = n[t.parentPasteIndex];
8398
8399
  i && r.setBlockParent(e, i.id);
8399
- } else e.parentId != null && r.setBlockParent(e, null);
8400
+ } else i === null ? e.parentId != null && r.setBlockParent(e, null) : r.setBlockParent(e, i);
8400
8401
  }
8401
8402
  async insertBlock(e, t = !1) {
8402
8403
  let { BlockManager: n, Caret: r } = this.Blok, { currentBlock: i } = n;
@@ -11076,8 +11077,9 @@ var gd = {
11076
11077
  n !== t && (this.isShortcutTakenByAnotherTool(e, t) || (n !== void 0 && (Z.remove(document, n), this.registeredShortcuts.delete(e)), Z.add({
11077
11078
  name: t,
11078
11079
  handler: (t) => {
11079
- let { BlockManager: n } = this.getBlok(), { currentBlock: r } = n;
11080
- r && r.tool.enabledInlineTools !== !1 && (t.preventDefault(), this.onShortcutPressed(e));
11080
+ var n, r;
11081
+ let { BlockManager: i } = this.getBlok(), a = (n = i.currentBlock) == null ? i.getBlockByChildNode((r = window.getSelection()) == null ? void 0 : r.anchorNode) : n;
11082
+ a && a.tool.enabledInlineTools !== !1 && (t.preventDefault(), this.onShortcutPressed(e));
11081
11083
  },
11082
11084
  on: document
11083
11085
  }), this.registeredShortcuts.set(e, t)));
@@ -137,7 +137,7 @@ var r = Object.create, i = Object.defineProperty, a = Object.getOwnPropertyDescr
137
137
  RIGHT: 2,
138
138
  BACKWARD: 3,
139
139
  FORWARD: 4
140
- }, g = () => "0.8.0", _ = /* @__PURE__ */ function(e) {
140
+ }, g = () => "0.8.1", _ = /* @__PURE__ */ function(e) {
141
141
  return e.VERBOSE = "VERBOSE", e.INFO = "INFO", e.WARN = "WARN", e.ERROR = "ERROR", e;
142
142
  }({}), v = (e, t, n = "log", r, i = "color: inherit") => {
143
143
  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, En as s, Et as c, F as l, G as u, H as d, I as f, It as p, J as m, K as h, L as g, Lt as _, M as ee, Mn as v, N as te, Nn as y, Nt as ne, P as re, R as ie, St as ae, U as oe, V as se, Vt as ce, W as le, X as ue, Y as de, Z as fe, _t as pe, a as me, at as he, bt as ge, c as _e, ct as ve, d as ye, dt as be, f as xe, ft as Se, g as Ce, gt as we, h as Te, ht as Ee, i as De, it as Oe, j as ke, jt as Ae, k as je, l as Me, lt as Ne, mt as Pe, n as Fe, nn as Ie, nt as Le, o as Re, ot as ze, p as Be, pt as Ve, q as He, r as Ue, rt as We, s as Ge, st as Ke, t as qe, tt as Je, u as b, v as Ye, vt as Xe, xt as Ze, yt as Qe, z as $e } from "./constants-CjWRVOdm.mjs";
1
+ import { $ as e, A as t, At as n, B as r, Bt as i, Ct as a, D as o, En as s, Et as c, F as l, G as u, H as d, I as f, It as p, J as m, K as h, L as g, Lt as _, M as ee, Mn as v, N as te, Nn as y, Nt as ne, P as re, R as ie, St as ae, U as oe, V as se, Vt as ce, W as le, X as ue, Y as de, Z as fe, _t as pe, a as me, at as he, bt as ge, c as _e, ct as ve, d as ye, dt as be, f as xe, ft as Se, g as Ce, gt as we, h as Te, ht as Ee, i as De, it as Oe, j as ke, jt as Ae, k as je, l as Me, lt as Ne, mt as Pe, n as Fe, nn as Ie, nt as Le, o as Re, ot as ze, p as Be, pt as Ve, q as He, r as Ue, rt as We, s as Ge, st as Ke, t as qe, tt as Je, u as b, v as Ye, vt as Xe, xt as Ze, yt as Qe, z as $e } from "./constants-CuG2mgIj.mjs";
2
2
  import { t as x } from "./objectSpread2-CyPxu8-u.mjs";
3
3
  import { n as S } from "./tw-DmW6-pCY.mjs";
4
4
  //#region src/components/utils/html.ts
package/dist/full.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { Mn as e } from "./chunks/constants-CjWRVOdm.mjs";
2
- import { n as t, t as n } from "./chunks/blok-CdiMFzDz.mjs";
1
+ import { Mn as e } from "./chunks/constants-CuG2mgIj.mjs";
2
+ import { n as t, t as n } from "./chunks/blok-Ddy2vDUq.mjs";
3
3
  import { t as r } from "./chunks/objectSpread2-CyPxu8-u.mjs";
4
- import { a as i, c as a, d as o, f as s, i as c, l, n as u, o as d, p as f, r as p, s as m, t as h } from "./chunks/tools-B5yNeTZh.mjs";
4
+ import { a as i, c as a, d as o, f as s, i as c, l, n as u, o as d, p as f, r as p, s as m, t as h } from "./chunks/tools-F4UyWgGo.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 "./chunks/constants-CjWRVOdm.mjs";
2
- import { r as e, t } from "./chunks/blok-CdiMFzDz.mjs";
1
+ import "./chunks/constants-CuG2mgIj.mjs";
2
+ import { r as e, t } from "./chunks/blok-Ddy2vDUq.mjs";
3
3
  import { t as n } from "./chunks/objectSpread2-CyPxu8-u.mjs";
4
4
  import { forwardRef as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
5
5
  import { jsx as c } from "react/jsx-runtime";
package/dist/tools.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { m as e } from "./chunks/constants-CjWRVOdm.mjs";
2
- import { a as t, c as n, d as r, f as i, i as a, l as o, n as s, o as c, p as l, r as u, s as d, t as f, u as p } from "./chunks/tools-B5yNeTZh.mjs";
1
+ import { m as e } from "./chunks/constants-CuG2mgIj.mjs";
2
+ import { a as t, c as n, d as r, f as i, i as a, l as o, n as s, o as c, p as l, r as u, s as d, t as f, u as p } from "./chunks/tools-F4UyWgGo.mjs";
3
3
  export { n as Bold, e as Convert, i as Header, d as Italic, c as Link, r as List, t as Marker, l as Paragraph, u as Strikethrough, p as Table, o as Toggle, a as Underline, f as defaultBlockTools, s as defaultInlineTools };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jackuait/blok",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
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",
@@ -115,6 +115,13 @@ export abstract class BasePasteHandler implements PasteHandler {
115
115
  if (isMultipleItems) {
116
116
  this.redirectToTableParentIfNeeded(data, BlockManager);
117
117
 
118
+ const currentBlock = BlockManager.currentBlock;
119
+ const childContainer = currentBlock?.holder?.querySelector('[data-blok-toggle-children]') ?? null;
120
+ const isInContainerTitle = childContainer !== null &&
121
+ !childContainer.contains(currentBlock?.currentInput ?? null);
122
+ const contextParentId = isInContainerTitle
123
+ ? (currentBlock?.id ?? null)
124
+ : (currentBlock?.parentId ?? null);
118
125
  const insertedByIndex: Array<Awaited<ReturnType<BlokModules['BlockManager']['paste']>>> = [];
119
126
 
120
127
  for (const [index, pasteData] of data.entries()) {
@@ -136,7 +143,7 @@ export abstract class BasePasteHandler implements PasteHandler {
136
143
  Caret.setToBlock(block, Caret.positions.END);
137
144
  insertedByIndex.push(block);
138
145
 
139
- this.applyPastedBlockParent(block, pasteData, insertedByIndex, BlockManager);
146
+ this.applyPastedBlockParent(block, pasteData, insertedByIndex, BlockManager, contextParentId);
140
147
  }
141
148
 
142
149
  BlockManager.currentBlock && Caret.setToBlock(BlockManager.currentBlock, Caret.positions.END);
@@ -163,7 +170,8 @@ export abstract class BasePasteHandler implements PasteHandler {
163
170
  block: Awaited<ReturnType<BlokModules['BlockManager']['paste']>>,
164
171
  pasteData: PasteData,
165
172
  insertedByIndex: Array<Awaited<ReturnType<BlokModules['BlockManager']['paste']>>>,
166
- BlockManager: BlokModules['BlockManager']
173
+ BlockManager: BlokModules['BlockManager'],
174
+ contextParentId: string | null
167
175
  ): void {
168
176
  if (pasteData.parentPasteIndex !== undefined) {
169
177
  const parentBlock = insertedByIndex[pasteData.parentPasteIndex];
@@ -171,9 +179,11 @@ export abstract class BasePasteHandler implements PasteHandler {
171
179
  if (parentBlock) {
172
180
  BlockManager.setBlockParent(block, parentBlock.id);
173
181
  }
182
+ } else if (contextParentId !== null) {
183
+ // Container-title paste context: assign all flat blocks to the container
184
+ BlockManager.setBlockParent(block, contextParentId);
174
185
  } else if (block.parentId != null) {
175
- // Root-level pasted block: clear any parent that was inherited from
176
- // the predecessor (e.g. the previous child block that had a parent).
186
+ // Root-level paste context: clear any parent inherited from predecessor
177
187
  BlockManager.setBlockParent(block, null);
178
188
  }
179
189
  }
@@ -172,13 +172,14 @@ export class InlineShortcutManager {
172
172
  name: shortcut,
173
173
  handler: (event) => {
174
174
  const { BlockManager } = this.getBlok();
175
- const { currentBlock } = BlockManager;
175
+ const block = BlockManager.currentBlock
176
+ ?? BlockManager.getBlockByChildNode(window.getSelection()?.anchorNode as Node);
176
177
 
177
- if (!currentBlock) {
178
+ if (!block) {
178
179
  return;
179
180
  }
180
181
 
181
- if (currentBlock.tool.enabledInlineTools === false) {
182
+ if (block.tool.enabledInlineTools === false) {
182
183
  return;
183
184
  }
184
185