@jackuait/blok 0.6.0-beta.5 → 0.6.0-beta.7

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.
Files changed (75) hide show
  1. package/README.md +16 -169
  2. package/bin/blok.mjs +10 -0
  3. package/dist/blok.mjs +2 -2
  4. package/dist/chunks/{blok-XA2L0_-K.mjs → blok-Bjkxis7j.mjs} +1029 -934
  5. package/dist/chunks/{i18next-loader-Ci2zhA-n.mjs → i18next-loader-D-sjerXt.mjs} +1 -1
  6. package/dist/chunks/{index-R38OiQ_d.mjs → index-CJfN4Vuv.mjs} +1 -1
  7. package/dist/chunks/{inline-tool-convert-e3PyuxB6.mjs → inline-tool-convert-5DE7c2fi.mjs} +1 -1
  8. package/dist/{messages-BGxiFoZf.mjs → chunks/messages-7QoX8DkW.mjs} +14 -14
  9. package/dist/{messages-UX4gkere.mjs → chunks/messages-BMXCuEKO.mjs} +5 -5
  10. package/dist/{messages-wp_1b1hD.mjs → chunks/messages-BSbjsyHY.mjs} +16 -16
  11. package/dist/chunks/{messages-DChXyvh2.mjs → messages-BdeLo0N9.mjs} +14 -14
  12. package/dist/chunks/{messages-B9fe4dQJ.mjs → messages-C2htQ_3F.mjs} +12 -12
  13. package/dist/{messages-BNe6LuHW.mjs → chunks/messages-C9eaarcK.mjs} +7 -7
  14. package/dist/chunks/messages-CKI54h6O.mjs +62 -0
  15. package/dist/{messages-DjvaFRqx.mjs → chunks/messages-CQwpzUFp.mjs} +6 -6
  16. package/dist/{messages-EL5ARzmK.mjs → chunks/messages-CVw84KdI.mjs} +7 -7
  17. package/dist/chunks/{messages-49thXXGz.mjs → messages-Diu6jAaR.mjs} +6 -6
  18. package/dist/{messages-Bfiw5w_W.mjs → chunks/messages-DvFLX36Q.mjs} +10 -10
  19. package/dist/chunks/{messages-QtoE8uEv.mjs → messages-Dzwxv9v1.mjs} +8 -8
  20. package/dist/cli.mjs +50 -0
  21. package/dist/full.mjs +15 -15
  22. package/dist/locales.mjs +12 -12
  23. package/dist/{chunks/messages-BGxiFoZf.mjs → messages-7QoX8DkW.mjs} +14 -14
  24. package/dist/{chunks/messages-UX4gkere.mjs → messages-BMXCuEKO.mjs} +5 -5
  25. package/dist/{chunks/messages-wp_1b1hD.mjs → messages-BSbjsyHY.mjs} +16 -16
  26. package/dist/{messages-DChXyvh2.mjs → messages-BdeLo0N9.mjs} +14 -14
  27. package/dist/{messages-B9fe4dQJ.mjs → messages-C2htQ_3F.mjs} +12 -12
  28. package/dist/{chunks/messages-BNe6LuHW.mjs → messages-C9eaarcK.mjs} +7 -7
  29. package/dist/messages-CKI54h6O.mjs +62 -0
  30. package/dist/{chunks/messages-DjvaFRqx.mjs → messages-CQwpzUFp.mjs} +6 -6
  31. package/dist/{chunks/messages-EL5ARzmK.mjs → messages-CVw84KdI.mjs} +7 -7
  32. package/dist/{messages-49thXXGz.mjs → messages-Diu6jAaR.mjs} +6 -6
  33. package/dist/{chunks/messages-Bfiw5w_W.mjs → messages-DvFLX36Q.mjs} +10 -10
  34. package/dist/{messages-QtoE8uEv.mjs → messages-Dzwxv9v1.mjs} +8 -8
  35. package/dist/tools.mjs +222 -207
  36. package/dist/vendor.LICENSE.txt +1 -1
  37. package/package.json +13 -8
  38. package/src/cli/commands/migration.ts +16 -0
  39. package/src/cli/commands/migrationContent.ts +6 -0
  40. package/src/cli/index.ts +47 -0
  41. package/src/cli/utils/output.ts +10 -0
  42. package/src/components/i18n/locales/bn/messages.json +16 -16
  43. package/src/components/i18n/locales/fil/messages.json +7 -7
  44. package/src/components/i18n/locales/hi/messages.json +14 -14
  45. package/src/components/i18n/locales/id/messages.json +6 -6
  46. package/src/components/i18n/locales/mr/messages.json +14 -14
  47. package/src/components/i18n/locales/ms/messages.json +6 -6
  48. package/src/components/i18n/locales/ne/messages.json +12 -12
  49. package/src/components/i18n/locales/si/messages.json +8 -8
  50. package/src/components/i18n/locales/ta/messages.json +7 -7
  51. package/src/components/i18n/locales/te/messages.json +35 -35
  52. package/src/components/i18n/locales/th/messages.json +5 -5
  53. package/src/components/i18n/locales/vi/messages.json +10 -10
  54. package/src/components/modules/api/history.ts +64 -0
  55. package/src/components/modules/api/index.ts +1 -0
  56. package/src/components/modules/api/readonly.ts +11 -1
  57. package/src/components/modules/blockManager/blockManager.ts +7 -0
  58. package/src/components/modules/blockManager/yjs-sync.ts +12 -2
  59. package/src/components/modules/index.ts +3 -0
  60. package/src/components/modules/readonly.ts +11 -0
  61. package/src/components/modules/rectangleSelection.ts +7 -3
  62. package/src/components/modules/saver.ts +3 -2
  63. package/src/components/modules/toolbar/index.ts +46 -11
  64. package/src/components/modules/toolbar/plus-button.ts +22 -1
  65. package/src/components/modules/yjs/index.ts +23 -0
  66. package/src/tools/table/index.ts +20 -0
  67. package/src/tools/table/table-add-controls.ts +8 -0
  68. package/src/tools/table/table-cell-blocks.ts +15 -5
  69. package/src/types-internal/blok-modules.d.ts +2 -0
  70. package/types/api/history.d.ts +33 -0
  71. package/types/api/index.d.ts +1 -0
  72. package/types/api/readonly.d.ts +12 -2
  73. package/types/index.d.ts +3 -0
  74. package/dist/chunks/messages-DsVNtdgM.mjs +0 -62
  75. package/dist/messages-DsVNtdgM.mjs +0 -62
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  <p align="center">
2
- <img width="40%" alt="Blok logotype" src="./static/blok.webp">
2
+ <a href="https://blokeditor.com" target="_blank" rel="noopener noreferrer">
3
+ <img width="40%" alt="Blok logotype" src="./static/blok.png">
4
+ </a>
3
5
  </p>
4
6
 
5
- ## Introducing Blok
7
+ ## It's Blok!
6
8
 
7
9
  **Blok** is a 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.
8
10
 
@@ -12,179 +14,24 @@ Unlike traditional `contenteditable` solutions that treat text as a single HTML
12
14
 
13
15
  **🧱 Block Architecture**: Content is structured as JSON data, not raw HTML, making it easy to parse, store, and render anywhere.
14
16
 
15
- **⚡ Slash Commands**: Includes a built-in, customizable "Slash Menu" (/) for quick formatting and inserting media.
16
-
17
- **🎨 Headless & Stylable**: Blok gives you the logic; you bring the UI. Fully compatible with Tailwind, Styled Components, or raw CSS.
17
+ **⚡ Slash Commands**: Includes a built-in "Slash Menu" (/) for quick formatting and inserting media.
18
18
 
19
19
  **🖱️ Drag & Drop**: Native support for rearranging blocks with intuitive handles.
20
20
 
21
- **🔌 Extensible Plugin System**: Easily create custom blocks (e.g., Kanbans, Embeds, Code Blocks) to fit your specific use case.
22
-
23
- ## Installation
24
-
25
- Install the package via NPM or Yarn:
26
-
27
- ```bash
28
- npm install @jackuait/blok
29
- ```
30
-
31
- or
32
-
33
- ```bash
34
- yarn add @jackuait/blok
35
- ```
36
-
37
- ## Quick Start
38
-
39
- Blok uses a modular architecture for optimal bundle size. Import tools separately from the core:
40
-
41
- ```typescript
42
- import { Blok } from '@jackuait/blok';
43
- import { Header, Paragraph, List, Bold, Italic, Link } from '@jackuait/blok/tools';
44
-
45
- const editor = new Blok({
46
- holder: 'editor',
47
- tools: {
48
- // Block tools - inlineToolbar is enabled by default
49
- paragraph: Paragraph,
50
- header: { class: Header, placeholder: 'Enter a heading' },
51
- list: List,
52
- // Inline tools
53
- bold: Bold,
54
- italic: Italic,
55
- link: Link,
56
- },
57
- });
58
-
59
- // Save content as JSON
60
- const data = await editor.save();
61
- ```
62
-
63
- Tool configuration is flat—no need for nested `config: {}`. Blok automatically extracts known settings (`class`, `inlineToolbar`, `shortcut`, etc.) and passes the rest to the tool.
64
-
65
- ### Entry Points
66
-
67
- | Entry Point | Description |
68
- |-------------|-------------|
69
- | `@jackuait/blok` | Core editor (no tools included) |
70
- | `@jackuait/blok/tools` | Built-in tools: Header, Paragraph, List, Bold, Italic, Link, Convert |
71
- | `@jackuait/blok/locales` | Locale loading utilities |
72
-
73
- This modular approach means you only bundle the tools you use, resulting in smaller bundles for your users.
74
-
75
- ## Migrating from EditorJS
76
-
77
- Blok is designed as a drop-in replacement for EditorJS. The included codemod automatically transforms your imports, selectors, and configuration—so you can switch over in minutes, not hours.
78
-
79
- ### Quick Start
80
-
81
- ```bash
82
- # 1. Preview what will change (recommended first)
83
- npx -p @jackuait/blok migrate-from-editorjs ./src --dry-run
84
-
85
- # 2. Apply the changes
86
- npx -p @jackuait/blok migrate-from-editorjs ./src
87
- ```
88
-
89
- ### Options
90
-
91
- | Flag | Description |
92
- |------|-------------|
93
- | `--dry-run` | Preview changes without modifying files |
94
- | `--verbose` | Show detailed output for each file processed |
95
- | `--use-library-i18n` | Use Blok's built-in translations (36 languages) instead of custom i18n |
96
-
97
- ### Supported Files
21
+ **🔌 Extensible Plugin System**: Easily create custom blocks to fit your specific use case.
98
22
 
99
- The codemod processes: `.js`, `.jsx`, `.ts`, `.tsx`, `.vue`, `.svelte`, `.html`, `.css`, `.scss`, `.less`
100
-
101
- ### What Gets Transformed
102
-
103
- - **Imports** — `@editorjs/editorjs` → `@jackuait/blok`
104
- - **Tool imports** — `@editorjs/header` → `@jackuait/blok/tools`
105
- - **Types** — `EditorConfig` → `BlokConfig`
106
- - **CSS selectors** — `.ce-block`, `.ce-toolbar` → `[data-blok-*]` attributes
107
- - **Data attributes** — `data-id` → `data-blok-id`
108
- - **Default holder** — `#editorjs` → `#blok`
109
-
110
- The codemod also handles **existing Blok users** upgrading to the modular architecture:
111
- - Splits combined imports: `{ Blok, Header }` from `@jackuait/blok` → separate imports
112
- - Updates static property access: `Blok.Header` → `Header`
113
-
114
- ### Limitations
115
-
116
- Some patterns require manual attention:
117
- - Dynamic imports with variable paths
118
- - Complex nested CSS selectors
119
- - Custom EditorJS plugins (need API adaptation)
120
-
121
- ### Learn More
122
-
123
- - [MIGRATION.md](./MIGRATION.md) — Full list of breaking changes and manual steps
124
- - [codemod/README.md](./codemod/README.md) — Programmatic usage and detailed examples
125
-
126
- ## Localization
127
-
128
- Blok supports 68 languages with lazy loading—only English is bundled by default (~3KB). Additional locales are loaded on-demand, keeping your initial bundle small.
129
-
130
- ### Default Behavior
131
-
132
- Out of the box, Blok uses English and auto-detects the user's browser language:
133
-
134
- ```typescript
135
- import { Blok } from '@jackuait/blok';
136
-
137
- new Blok({
138
- holder: 'editor',
139
- // Uses English by default, auto-detects browser language
140
- });
141
- ```
142
-
143
-
144
- ### Preloading Locales
145
-
146
- By default, locales are loaded on-demand. If you need to ensure locales are available before initializing the editor—for example, to avoid any loading delay or to support offline usage—you can preload them:
147
-
148
- ```typescript
149
- import { Blok } from '@jackuait/blok';
150
- import { preloadLocales, buildRegistry } from '@jackuait/blok/locales';
151
-
152
- // Preload during app startup (triggers network requests and caches the locales)
153
- await preloadLocales(['en', 'fr', 'de']);
154
-
155
- // Build registry from preloaded locales (instant, no network request)
156
- const locales = await buildRegistry(['en', 'fr', 'de']);
157
-
158
- new Blok({
159
- holder: 'editor',
160
- i18n: {
161
- locales,
162
- locale: 'auto',
163
- }
164
- });
165
- ```
166
-
167
- **When to preload:**
168
- - Offline support (preload all needed locales before going offline)
169
- - Eliminating any loading delay during editor initialization
170
- - Progressive web apps that cache resources upfront
23
+ ## Documentation
171
24
 
172
- **When not to preload:**
173
- - Most apps—just use `buildRegistry()` directly and accept the ~50-100ms loading time
174
- - The on-demand loading is usually imperceptible
25
+ 📚 **Full documentation is available at [blokeditor.com](https://blokeditor.com)**
175
26
 
176
- ### Setting a Specific Locale
27
+ Visit the documentation site for:
28
+ - Complete API reference
29
+ - Interactive demo
30
+ - Usage guides and examples
31
+ - Migration guide from Editor.js
177
32
 
178
- ```typescript
179
- new Blok({
180
- holder: 'editor',
181
- i18n: {
182
- locale: 'fr', // Use French
183
- defaultLocale: 'en', // Fallback if 'fr' unavailable
184
- }
185
- });
186
- ```
33
+ ## Community
187
34
 
188
- ## Documentation
35
+ 💬 **Join the Telegram channel**: [t.me/that_ai_guy](https://t.me/that_ai_guy)
189
36
 
190
- 📚 **Complete Documentation is coming soon!** We're working hard to provide comprehensive guides, API references, and examples. Stay tuned for updates.
37
+ Follow for updates, discussions, and insights about Blok and other projects.
package/bin/blok.mjs ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readFileSync } from 'node:fs';
4
+ import { run } from '../dist/cli.mjs';
5
+
6
+ const version = process.env.npm_package_version
7
+ || JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8')).version;
8
+ const args = process.argv.slice(2);
9
+
10
+ run(args, version);
package/dist/blok.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { B as s, v as a } from "./chunks/blok-XA2L0_-K.mjs";
2
- import { D as A } from "./chunks/inline-tool-convert-e3PyuxB6.mjs";
1
+ import { B as s, v as a } from "./chunks/blok-Bjkxis7j.mjs";
2
+ import { D as A } from "./chunks/inline-tool-convert-5DE7c2fi.mjs";
3
3
  export {
4
4
  s as Blok,
5
5
  A as DATA_ATTR,