@jackuait/blok 0.14.0 → 0.14.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/full.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunks/chunk-CZKdLM9-.cjs`);const e=require(`./chunks/blok-Da-GaWJ8.cjs`),t=require(`./chunks/constants-C-OQpSwB.cjs`),n=require(`./chunks/objectSpread2-iNkE6aJh.cjs`),r=require(`./chunks/tools-DeTgjuIK.cjs`);var i={paragraph:{class:r.C,inlineToolbar:!0,config:{preserveBlank:!0}},header:{class:r.S,inlineToolbar:!0},list:{class:r.x,inlineToolbar:!0}},a=n.t(n.t({},i),{},{bold:{class:r.l},italic:{class:r.c},marker:{class:r.o},underline:{class:r.a},strikethrough:{class:r.i},link:{class:r.s}});exports.Blok=e.t,exports.Bold=r.l,exports.DATA_ATTR=t.Yr,exports.Header=r.S,exports.Italic=r.c,exports.Link=r.s,exports.List=r.x,exports.Marker=r.o,exports.Paragraph=r.C,exports.Strikethrough=r.i,exports.Toggle=r.y,exports.Underline=r.a,exports.allTools=a,exports.defaultBlockTools=r.t,exports.defaultInlineTools=r.n,exports.defaultTools=i,exports.version=e.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunks/chunk-CZKdLM9-.cjs`);const e=require(`./chunks/blok-DbYIZS7_.cjs`),t=require(`./chunks/constants-DPty7Dc7.cjs`),n=require(`./chunks/objectSpread2-iNkE6aJh.cjs`),r=require(`./chunks/tools-BuCT1-J0.cjs`);var i={paragraph:{class:r.w,inlineToolbar:!0,config:{preserveBlank:!0}},header:{class:r.C,inlineToolbar:!0},list:{class:r.S,inlineToolbar:!0}},a=n.t(n.t({},i),{},{bold:{class:r.l},italic:{class:r.c},marker:{class:r.o},underline:{class:r.a},strikethrough:{class:r.i},link:{class:r.s}});exports.Blok=e.t,exports.Bold=r.l,exports.DATA_ATTR=t.Yr,exports.Header=r.C,exports.Italic=r.c,exports.Link=r.s,exports.List=r.S,exports.Marker=r.o,exports.Paragraph=r.w,exports.Strikethrough=r.i,exports.Toggle=r.b,exports.Underline=r.a,exports.allTools=a,exports.defaultBlockTools=r.t,exports.defaultInlineTools=r.n,exports.defaultTools=i,exports.version=e.n;
package/dist/full.mjs CHANGED
@@ -1,29 +1,29 @@
1
- import { n as e, t } from "./chunks/blok-PpFnlqXZ.mjs";
2
- import { Yr as n } from "./chunks/constants-DdfiMdC1.mjs";
1
+ import { n as e, t } from "./chunks/blok-DuYqYpF7.mjs";
2
+ import { Yr as n } from "./chunks/constants-DMVxzgHf.mjs";
3
3
  import { t as r } from "./chunks/objectSpread2-jlBcdYeb.mjs";
4
- import { C as i, S as a, a as o, c as s, i as c, l, n as u, o as d, s as f, t as p, x as m, y as h } from "./chunks/tools-omGeunql.mjs";
4
+ import { C as i, S as a, a as o, b as s, c, i as l, l as u, n as d, o as f, s as p, t as m, w as h } from "./chunks/tools-BwY9bTlg.mjs";
5
5
  //#region src/full.ts
6
6
  var g = {
7
7
  paragraph: {
8
- class: i,
8
+ class: h,
9
9
  inlineToolbar: !0,
10
10
  config: { preserveBlank: !0 }
11
11
  },
12
12
  header: {
13
- class: a,
13
+ class: i,
14
14
  inlineToolbar: !0
15
15
  },
16
16
  list: {
17
- class: m,
17
+ class: a,
18
18
  inlineToolbar: !0
19
19
  }
20
20
  }, _ = r(r({}, g), {}, {
21
- bold: { class: l },
22
- italic: { class: s },
23
- marker: { class: d },
21
+ bold: { class: u },
22
+ italic: { class: c },
23
+ marker: { class: f },
24
24
  underline: { class: o },
25
- strikethrough: { class: c },
26
- link: { class: f }
25
+ strikethrough: { class: l },
26
+ link: { class: p }
27
27
  });
28
28
  //#endregion
29
- export { t as Blok, l as Bold, n as DATA_ATTR, a as Header, s as Italic, f as Link, m as List, d as Marker, i as Paragraph, c as Strikethrough, h as Toggle, o as Underline, _ as allTools, p as defaultBlockTools, u as defaultInlineTools, g as defaultTools, e as version };
29
+ export { t as Blok, u as Bold, n as DATA_ATTR, i as Header, c as Italic, p as Link, a as List, f as Marker, h as Paragraph, l as Strikethrough, s as Toggle, o as Underline, _ as allTools, m as defaultBlockTools, d as defaultInlineTools, g as defaultTools, e as version };
package/dist/react.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunks/chunk-CZKdLM9-.cjs`);const e=require(`./chunks/blok-Da-GaWJ8.cjs`),t=require(`./chunks/objectSpread2-iNkE6aJh.cjs`);let n=require(`react`),r=require(`react/jsx-runtime`);var i=new WeakMap;function a(e,t){i.set(e,t)}function o(e){return i.get(e)}function s(e){i.delete(e)}function c(r,i){let[o,c]=(0,n.useState)(null),u=(0,n.useRef)(r);u.current=r;let d=(0,n.useRef)({editor:null,holder:null,destroyTimeout:null,isDestroyed:!1,depsToken:null}),f=(0,n.useMemo)(()=>({}),i==null?[]:i);(0,n.useEffect)(()=>{if(typeof window>`u`)return;let n=d.current;if(n.destroyTimeout!==null&&(clearTimeout(n.destroyTimeout),n.destroyTimeout=null),n.editor!==null&&!n.isDestroyed&&n.depsToken===f)return c(n.editor),()=>{l(n,c)};if(n.editor!==null&&!n.isDestroyed){s(n.editor);try{n.editor.destroy()}catch(e){}n.editor=null,n.holder=null,n.isDestroyed=!0,c(null)}let r=document.createElement(`div`);n.holder=r,n.isDestroyed=!1,n.depsToken=f;let i=u.current,o=new e.t(t.t(t.t({},i),{},{holder:r,onReady:()=>{var e,t;(e=(t=u.current).onReady)==null||e.call(t)},onChange:(...e)=>{var t,n;(t=(n=u.current).onChange)==null||t.call(n,...e)}}));return n.editor=o,a(o,r),o.isReady.then(()=>{n.editor===o&&!n.isDestroyed&&c(o)}).catch(()=>{if(n.editor===o&&!n.isDestroyed){s(o);try{o.destroy()}catch(e){}n.editor=null,n.holder=null,n.isDestroyed=!0,c(null)}}),()=>{l(n,c)}},[f]);let{readOnly:p}=r;(0,n.useEffect)(()=>{o!==null&&o.readOnly.set(p==null?!1:p)},[o,p]);let{autofocus:m}=r;return(0,n.useEffect)(()=>{o===null||!m||o.focus()},[o,m]),o}function l(e,t){e.destroyTimeout=setTimeout(()=>{if(e.editor!==null){s(e.editor);try{e.editor.destroy()}catch(e){}e.editor=null,e.holder=null,e.isDestroyed=!0,e.destroyTimeout=null,t(null)}},0)}var u=[`editor`],d=(0,n.forwardRef)(function(i,a){let{editor:s}=i,c=e.r(i,u),l=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(s===null||l.current===null)return;let e=o(s);if(e!==void 0)return l.current.appendChild(e),()=>{e.remove()}},[s]),(0,r.jsx)(`div`,t.t({ref:e=>{if(l.current=e,typeof a==`function`)a(e);else if(a!=null){let t=a;t.current=e}}},c))});exports.BlokContent=d,exports.useBlok=c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunks/chunk-CZKdLM9-.cjs`);const e=require(`./chunks/blok-DbYIZS7_.cjs`),t=require(`./chunks/objectSpread2-iNkE6aJh.cjs`);let n=require(`react`),r=require(`react/jsx-runtime`);var i=new WeakMap;function a(e,t){i.set(e,t)}function o(e){return i.get(e)}function s(e){i.delete(e)}function c(r,i){let[o,c]=(0,n.useState)(null),u=(0,n.useRef)(r);u.current=r;let d=(0,n.useRef)({editor:null,holder:null,destroyTimeout:null,isDestroyed:!1,depsToken:null}),f=(0,n.useMemo)(()=>({}),i==null?[]:i);(0,n.useEffect)(()=>{if(typeof window>`u`)return;let n=d.current;if(n.destroyTimeout!==null&&(clearTimeout(n.destroyTimeout),n.destroyTimeout=null),n.editor!==null&&!n.isDestroyed&&n.depsToken===f)return c(n.editor),()=>{l(n,c)};if(n.editor!==null&&!n.isDestroyed){s(n.editor);try{n.editor.destroy()}catch(e){}n.editor=null,n.holder=null,n.isDestroyed=!0,c(null)}let r=document.createElement(`div`);n.holder=r,n.isDestroyed=!1,n.depsToken=f;let i=u.current,o=new e.t(t.t(t.t({},i),{},{holder:r,onReady:()=>{var e,t;(e=(t=u.current).onReady)==null||e.call(t)},onChange:(...e)=>{var t,n;(t=(n=u.current).onChange)==null||t.call(n,...e)}}));return n.editor=o,a(o,r),o.isReady.then(()=>{n.editor===o&&!n.isDestroyed&&c(o)}).catch(()=>{if(n.editor===o&&!n.isDestroyed){s(o);try{o.destroy()}catch(e){}n.editor=null,n.holder=null,n.isDestroyed=!0,c(null)}}),()=>{l(n,c)}},[f]);let{readOnly:p}=r;(0,n.useEffect)(()=>{o!==null&&o.readOnly.set(p==null?!1:p)},[o,p]);let{autofocus:m}=r;return(0,n.useEffect)(()=>{o===null||!m||o.focus()},[o,m]),o}function l(e,t){e.destroyTimeout=setTimeout(()=>{if(e.editor!==null){s(e.editor);try{e.editor.destroy()}catch(e){}e.editor=null,e.holder=null,e.isDestroyed=!0,e.destroyTimeout=null,t(null)}},0)}var u=[`editor`],d=(0,n.forwardRef)(function(i,a){let{editor:s}=i,c=e.r(i,u),l=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(s===null||l.current===null)return;let e=o(s);if(e!==void 0)return l.current.appendChild(e),()=>{e.remove()}},[s]),(0,r.jsx)(`div`,t.t({ref:e=>{if(l.current=e,typeof a==`function`)a(e);else if(a!=null){let t=a;t.current=e}}},c))});exports.BlokContent=d,exports.useBlok=c;
package/dist/react.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { r as e, t } from "./chunks/blok-PpFnlqXZ.mjs";
1
+ import { r as e, t } from "./chunks/blok-DuYqYpF7.mjs";
2
2
  import { t as n } from "./chunks/objectSpread2-jlBcdYeb.mjs";
3
3
  import { forwardRef as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
4
4
  import { jsx as c } from "react/jsx-runtime";
package/dist/tools.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunks/chunk-CZKdLM9-.cjs`);const e=require(`./chunks/constants-C-OQpSwB.cjs`),t=require(`./chunks/tools-DeTgjuIK.cjs`);exports.Bold=t.l,exports.Callout=t.v,exports.Code=t.p,exports.Column=t.u,exports.ColumnList=t.d,exports.Convert=e.m,exports.Database=t._,exports.DatabaseRow=t.g,exports.Divider=t.h,exports.Header=t.S,exports.Image=t.f,exports.InlineCode=t.r,exports.Italic=t.c,exports.Link=t.s,exports.List=t.x,exports.Marker=t.o,exports.Paragraph=t.C,exports.Quote=t.m,exports.Strikethrough=t.i,exports.Table=t.b,exports.Toggle=t.y,exports.Underline=t.a,exports.defaultBlockTools=t.t,exports.defaultInlineTools=t.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunks/chunk-CZKdLM9-.cjs`);const e=require(`./chunks/constants-DPty7Dc7.cjs`),t=require(`./chunks/tools-BuCT1-J0.cjs`);exports.Bold=t.l,exports.Callout=t.y,exports.Code=t.m,exports.Column=t.d,exports.ColumnList=t.f,exports.Columns=t.u,exports.Convert=e.m,exports.Database=t.v,exports.DatabaseRow=t._,exports.Divider=t.g,exports.Header=t.C,exports.Image=t.p,exports.InlineCode=t.r,exports.Italic=t.c,exports.Link=t.s,exports.List=t.S,exports.Marker=t.o,exports.Paragraph=t.w,exports.Quote=t.h,exports.Strikethrough=t.i,exports.Table=t.x,exports.Toggle=t.b,exports.Underline=t.a,exports.defaultBlockTools=t.t,exports.defaultInlineTools=t.n;
package/dist/tools.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { m as e } from "./chunks/constants-DdfiMdC1.mjs";
2
- import { C as t, S as n, _ as r, a as i, b as a, c as o, d as s, f as c, g as l, h as u, i as d, l as f, m as p, n as m, o as h, p as g, r as _, s as v, t as y, u as b, v as x, x as S, y as C } from "./chunks/tools-omGeunql.mjs";
3
- export { f as Bold, x as Callout, g as Code, b as Column, s as ColumnList, e as Convert, r as Database, l as DatabaseRow, u as Divider, n as Header, c as Image, _ as InlineCode, o as Italic, v as Link, S as List, h as Marker, t as Paragraph, p as Quote, d as Strikethrough, a as Table, C as Toggle, i as Underline, y as defaultBlockTools, m as defaultInlineTools };
1
+ import { m as e } from "./chunks/constants-DMVxzgHf.mjs";
2
+ import { C as t, S as n, _ as r, a as i, b as a, c as o, d as s, f as c, g as l, h as u, i as d, l as f, m as p, n as m, o as h, p as g, r as _, s as v, t as y, u as b, v as x, w as S, x as C, y as w } from "./chunks/tools-BwY9bTlg.mjs";
3
+ export { f as Bold, w as Callout, p as Code, s as Column, c as ColumnList, b as Columns, e as Convert, x as Database, r as DatabaseRow, l as Divider, t as Header, g as Image, _ as InlineCode, o as Italic, v as Link, n as List, h as Marker, S as Paragraph, u as Quote, d as Strikethrough, C as Table, a as Toggle, i as Underline, y as defaultBlockTools, m as defaultInlineTools };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jackuait/blok",
3
- "version": "0.14.0",
3
+ "version": "0.14.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
  "main": "./dist/blok.cjs",
@@ -148,7 +148,9 @@ export class Tools extends Module {
148
148
  */
149
149
  const userTools = this.config.tools ?? {};
150
150
 
151
- this.config.tools = deepMerge({}, this.internalTools, userTools);
151
+ this.config.tools = this.expandToolGroups(
152
+ deepMerge({}, this.internalTools, userTools)
153
+ );
152
154
 
153
155
  this.validateTools();
154
156
 
@@ -284,6 +286,60 @@ export class Tools extends Module {
284
286
  };
285
287
  }
286
288
 
289
+ /**
290
+ * Expand any registered tool "group" into the real block tools it provides.
291
+ *
292
+ * A tool class may expose a static `provides` map of `{ blockType: ToolClass }`.
293
+ * Registering such a class under any key (e.g. `columns: Columns`) registers
294
+ * the provided block tools (`column_list`, `column`) instead, and drops the
295
+ * group handle key — no block ever has the handle's type. Settings on the
296
+ * group entry forward to each provided sub-tool.
297
+ *
298
+ * Explicit entries always win over group-provided entries regardless of order.
299
+ * If two groups provide the same block type, the first-registered group wins.
300
+ */
301
+ private expandToolGroups(
302
+ tools: Record<string, ToolConstructable | ToolSettings>
303
+ ): Record<string, ToolConstructable | ToolSettings> {
304
+ const out: Record<string, ToolConstructable | ToolSettings> = {};
305
+
306
+ for (const name in tools) {
307
+ if (!Object.prototype.hasOwnProperty.call(tools, name)) {
308
+ continue;
309
+ }
310
+
311
+ const entry = tools[name];
312
+ const toolClass = isObject(entry) ? (entry as ToolSettings).class : entry;
313
+ const provides = (toolClass as { provides?: Record<string, ToolConstructable> } | undefined)?.provides;
314
+
315
+ if (!provides) {
316
+ out[name] = entry;
317
+ continue;
318
+ }
319
+
320
+ const groupSettings: Record<string, unknown> = isObject(entry)
321
+ ? Object.fromEntries(
322
+ // never forward the class ref or the internal-tool flag to sub-tools
323
+ Object.entries(entry).filter(([key]) => key !== 'class' && key !== 'isInternal')
324
+ )
325
+ : {};
326
+
327
+ const hasGroupSettings = Object.keys(groupSettings).length > 0;
328
+
329
+ Object.entries(provides).forEach(([blockType, providedClass]) => {
330
+ // Never clobber an entry already present — explicit registration wins.
331
+ if (blockType in out) {
332
+ return;
333
+ }
334
+
335
+ out[blockType] = hasGroupSettings ? { class: providedClass, ...groupSettings } : providedClass;
336
+ });
337
+ // The group handle key (`name`) is intentionally dropped: not a block type.
338
+ }
339
+
340
+ return out;
341
+ }
342
+
287
343
  /**
288
344
  * Tool prepare method success callback
289
345
  * @param {object} data - append tool to available list
@@ -0,0 +1,21 @@
1
+ import type { BaseToolConstructable } from '../../../types/tools';
2
+ import { Column } from '../column';
3
+ import { ColumnList } from '../column-list';
4
+
5
+ /**
6
+ * Registration handle for the columns feature. Registering `Columns` under a
7
+ * single tool key (e.g. `columns`) expands to the two real block tools that
8
+ * back columns — `column_list` (the row container) and `column` (one slot).
9
+ *
10
+ * `Columns` is never instantiated as a block: no block has `type: 'columns'`.
11
+ * Saved JSON still contains `column_list` and `column` blocks. See
12
+ * docs/superpowers/specs/2026-06-08-single-key-columns-registration-design.md.
13
+ */
14
+ export class Columns {
15
+ public static get provides(): { [blockType: string]: BaseToolConstructable } {
16
+ return {
17
+ column_list: ColumnList as unknown as BaseToolConstructable,
18
+ column: Column as unknown as BaseToolConstructable,
19
+ };
20
+ }
21
+ }
@@ -34,6 +34,7 @@ export { CodeTool as Code } from './code';
34
34
  export { ImageTool as Image } from './image';
35
35
  export { ColumnList } from './column-list';
36
36
  export { Column } from './column';
37
+ export { Columns } from './columns';
37
38
 
38
39
  // Inline tools
39
40
  export { BoldInlineTool as Bold } from '../components/inline-tools/inline-tool-bold';
@@ -57,6 +57,18 @@ export interface BaseToolConstructable {
57
57
  */
58
58
  titleKey?: string;
59
59
 
60
+ /**
61
+ * Optional manifest declaring the block types this class supplies. A class
62
+ * with `provides` is a registration group/handle, not a renderable block:
63
+ * registering it under any key expands to the listed block tools, and the
64
+ * handle key itself is dropped (it is not a block type). Used to register a
65
+ * multi-block feature (e.g. columns -> column_list + column) under one key.
66
+ *
67
+ * Typed as BaseToolConstructable to avoid a circular import with
68
+ * BlockToolConstructable; the provided classes are block tools at runtime.
69
+ */
70
+ provides?: { [blockType: string]: BaseToolConstructable };
71
+
60
72
  /**
61
73
  * Tool`s prepare method. Can be async
62
74
  * @param data
@@ -34,6 +34,13 @@ export const Image: BlockToolConstructable;
34
34
  export const Code: BlockToolConstructable;
35
35
  export const ColumnList: ColumnListConstructable;
36
36
  export const Column: ColumnConstructable;
37
+ /**
38
+ * Columns group manifest: a single registration handle that expands to the
39
+ * `column_list` and `column` block tools. Register as `tools: { columns: Columns }`.
40
+ */
41
+ export const Columns: BlockToolConstructable & {
42
+ readonly provides: { readonly [blockType: string]: BlockToolConstructable };
43
+ };
37
44
 
38
45
  // Re-export data and config types for convenience
39
46
  export { HeaderData, HeaderConfig } from './tools/header';