@qarakash/blockwriteai 1.0.22 → 1.1.0

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/README.md CHANGED
@@ -1,256 +1,256 @@
1
- # BlockWriteAI
2
-
3
- BlockWriteAI is a JSON-first block editor for web apps. It works with a script tag, npm, PHP/Composer, and Python static-file workflows.
4
-
5
- Use the free core editor for normal documents. Serve premium tools such as AI, Mermaid, Drawing, Signature, and Signature Flow only through your licensed server endpoint.
6
-
7
- ## Quick Start With CDN
8
-
9
- Add the stylesheet, editor script, and free plugin bundle:
10
-
11
- ```html
12
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.0.22/dist/blockwriteai.min.css">
13
-
14
- <div id="editor"></div>
15
-
16
- <script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.0.22/dist/blockwriteai.min.js"></script>
17
- <script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.0.22/dist/plugins/blockwriteai-code-assist.min.js"></script>
18
- <script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.0.22/dist/plugins/blockwriteai-advanced-blocks.min.js"></script>
19
- <script>
20
- const editor = new BlockWriteAI({
21
- holder: "#editor",
22
- placeholder: "Write something, or press / for blocks",
23
- async onSave(data) {
24
- await fetch("/api/documents", {
25
- method: "POST",
26
- headers: { "Content-Type": "application/json" },
27
- body: JSON.stringify(data)
28
- });
29
- }
30
- });
31
- </script>
32
- ```
33
-
34
- Use these CDN URLs for production:
35
-
36
- ```text
37
- https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.0.22/dist/blockwriteai.min.css
38
- https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.0.22/dist/blockwriteai.min.js
39
- https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.0.22/dist/plugins/blockwriteai-code-assist.min.js
40
- https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.0.22/dist/plugins/blockwriteai-advanced-blocks.min.js
41
- ```
42
-
43
- Optional history plugin:
44
-
45
- ```html
46
- <script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.0.22/dist/plugins/blockwriteai-history.min.js"></script>
47
- ```
48
-
49
- Premium CDN integrations should load licensed plugins and verify usage through the production BlockWriteAI Platform:
50
-
51
- ```js
52
- await BlockWriteAI.loadPremiumPlugins({
53
- licenseKey: "bwai_live_xxxxx",
54
- endpoint: BlockWriteAI.platformEndpoints.premiumPlugins,
55
- features: ["drawing", "mermaid", "signature", "signature_flow", "ai"]
56
- });
57
- ```
58
-
59
- ## Install With Node
60
-
61
- ```bash
62
- npm install @qarakash/blockwriteai
63
- ```
64
-
65
- ```js
66
- import BlockWriteAI from "@qarakash/blockwriteai";
67
- import "@qarakash/blockwriteai/css";
68
- import "@qarakash/blockwriteai/plugins/code-assist/min";
69
- import "@qarakash/blockwriteai/plugins/advanced/min";
70
-
71
- const editor = new BlockWriteAI({
72
- holder: "#editor",
73
- premium: {
74
- licenseKey: "bwai_live_xxxxx",
75
- verifyEndpoint: BlockWriteAI.platformEndpoints.licenseVerify,
76
- usageEndpoint: BlockWriteAI.platformEndpoints.aiUsage,
77
- featureUsageEndpoint: BlockWriteAI.platformEndpoints.premiumUsage,
78
- eventEndpoint: BlockWriteAI.platformEndpoints.premiumEvent,
79
- signatureEventEndpoint: BlockWriteAI.platformEndpoints.signatureEvent
80
- },
81
- async onSave(data) {
82
- await fetch("/api/documents", {
83
- method: "POST",
84
- headers: { "Content-Type": "application/json" },
85
- body: JSON.stringify(data)
86
- });
87
- }
88
- });
89
- ```
90
-
91
- ## Install With PHP
92
-
93
- ```bash
94
- composer require qarakash/blockwriteai
95
- ```
96
-
97
- Publish the package `dist` assets into a public asset directory in your app, then print the tags:
98
-
99
- ```php
100
- <?php
101
-
102
- use QarAkash\BlockWriteAI\BlockWriteAIAssets;
103
-
104
- echo BlockWriteAIAssets::stylesheetTag('/assets/blockwriteai');
105
- echo BlockWriteAIAssets::scriptTags('/assets/blockwriteai');
106
-
107
- $platform = BlockWriteAIAssets::platformEndpoints();
108
- ```
109
-
110
- Create the editor:
111
-
112
- ```html
113
- <div id="editor"></div>
114
- <script>
115
- const editor = new BlockWriteAI({
116
- holder: "#editor",
117
- async onSave(data) {
118
- await fetch("/api/documents/save.php", {
119
- method: "POST",
120
- headers: { "Content-Type": "application/json" },
121
- body: JSON.stringify(data)
122
- });
123
- }
124
- });
125
- </script>
126
- ```
127
-
128
- ## Install With Python
129
-
130
- ```bash
131
- pip install blockwriteai-editor
132
- ```
133
-
134
- Copy the packaged assets into your app static directory:
135
-
136
- ```python
137
- from blockwriteai_editor import copy_static
138
-
139
- copy_static("static/blockwriteai")
140
- ```
141
-
142
- Generate tags in Flask, Django, or any Python web app:
143
-
144
- ```python
145
- from blockwriteai_editor import platform_endpoints, stylesheet_tag, script_tags
146
-
147
- print(stylesheet_tag("/static/blockwriteai"))
148
- print(script_tags("/static/blockwriteai"))
149
-
150
- platform = platform_endpoints()
151
- ```
152
-
153
- Then mount the editor in your template:
154
-
155
- ```html
156
- <div id="editor"></div>
157
- <script>
158
- const editor = new BlockWriteAI({
159
- holder: "#editor",
160
- async onSave(data) {
161
- await fetch("/api/documents", {
162
- method: "POST",
163
- headers: { "Content-Type": "application/json" },
164
- body: JSON.stringify(data)
165
- });
166
- }
167
- });
168
- </script>
169
- ```
170
-
171
- ## Read Saved Documents
172
-
173
- BlockWriteAI saves JSON. Store that JSON in your database, then render it later with a preview container:
174
-
175
- ```html
176
- <link rel="stylesheet" href="/assets/blockwriteai/blockwriteai.min.css">
177
-
178
- <div class="blockwriteai-preview" data-source="/api/documents/123.json"></div>
179
-
180
- <script src="/assets/blockwriteai/blockwriteai.min.js"></script>
181
- <script src="/assets/blockwriteai/plugins/blockwriteai-advanced-blocks.min.js"></script>
182
- <script>
183
- BlockWriteAI.mountPreviews();
184
- </script>
185
- ```
186
-
187
- The JSON endpoint can return a document directly:
188
-
189
- ```json
190
- {
191
- "time": 1779540000000,
192
- "version": "1.0.22",
193
- "blocks": []
194
- }
195
- ```
196
-
197
- It can also return a wrapper:
198
-
199
- ```json
200
- {
201
- "ok": true,
202
- "data": {
203
- "time": 1779540000000,
204
- "version": "1.0.22",
205
- "blocks": []
206
- }
207
- }
208
- ```
209
-
210
- ## Premium Plugins
211
-
212
- Do not expose premium plugin files as normal public scripts. Load them after your server verifies an active license:
213
-
214
- ```html
215
- <script>
216
- async function bootEditor() {
217
- await BlockWriteAI.loadPremiumPlugins({
218
- licenseKey: "bwai_live_xxxxx",
219
- endpoint: "https://blockwriteai.in/api/premium_plugins.php",
220
- features: ["drawing", "mermaid", "signature", "signature_flow", "ai"]
221
- });
222
-
223
- window.editor = new BlockWriteAI({
224
- holder: "#editor",
225
- premium: {
226
- licenseKey: "bwai_live_xxxxx",
227
- verifyEndpoint: "https://blockwriteai.in/api/license_verify.php",
228
- usageEndpoint: "https://blockwriteai.in/api/ai_usage.php"
229
- },
230
- ai: {
231
- endpoint: "https://blockwriteai.in/api/ai_generate.php"
232
- }
233
- });
234
- }
235
-
236
- bootEditor();
237
- </script>
238
- ```
239
-
240
- The browser plugin must never receive private API keys. Keep OpenAI, billing, usage limits, and license checks on your server.
241
-
242
- ## Release Checklist
243
-
244
- 1. Run `npm run build:min`.
245
- 2. Run `npm run check`.
246
- 3. Publish `@qarakash/blockwriteai` to npm.
247
- 4. Publish `qarakash/blockwriteai` to Packagist.
248
- 5. Publish `blockwriteai-editor` to PyPI.
249
- 6. Serve only the public asset directory from your application.
250
-
251
- ## Notes For Production
252
-
253
- - Use the `.min.css` and `.min.js` files in public pages.
254
- - Do not publish source folders, examples, build artifacts, package caches, or private configuration files.
255
- - Browser-delivered CSS and JavaScript can always be downloaded. Protect paid features with server-side license checks and metered premium bundle delivery.
256
- - Keep secret keys in backend environment variables only.
1
+ # BlockWriteAI
2
+
3
+ BlockWriteAI is a JSON-first block editor for web apps. It works with a script tag, npm, PHP/Composer, and Python static-file workflows.
4
+
5
+ Use the free core editor for normal documents. Serve premium tools such as AI, Mermaid, Drawing, Signature, and Signature Flow only through your licensed server endpoint.
6
+
7
+ ## Quick Start With CDN
8
+
9
+ Add the stylesheet, editor script, and free plugin bundle:
10
+
11
+ ```html
12
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/blockwriteai.min.css">
13
+
14
+ <div id="editor"></div>
15
+
16
+ <script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/blockwriteai.min.js"></script>
17
+ <script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/plugins/blockwriteai-code-assist.min.js"></script>
18
+ <script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/plugins/blockwriteai-advanced-blocks.min.js"></script>
19
+ <script>
20
+ const editor = new BlockWriteAI({
21
+ holder: "#editor",
22
+ placeholder: "Write something, or press / for blocks",
23
+ async onSave(data) {
24
+ await fetch("/api/documents", {
25
+ method: "POST",
26
+ headers: { "Content-Type": "application/json" },
27
+ body: JSON.stringify(data)
28
+ });
29
+ }
30
+ });
31
+ </script>
32
+ ```
33
+
34
+ Use these CDN URLs for production:
35
+
36
+ ```text
37
+ https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/blockwriteai.min.css
38
+ https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/blockwriteai.min.js
39
+ https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/plugins/blockwriteai-code-assist.min.js
40
+ https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/plugins/blockwriteai-advanced-blocks.min.js
41
+ ```
42
+
43
+ Optional history plugin:
44
+
45
+ ```html
46
+ <script src="https://cdn.jsdelivr.net/npm/@qarakash/blockwriteai@1.1.0/dist/plugins/blockwriteai-history.min.js"></script>
47
+ ```
48
+
49
+ Premium CDN integrations should load licensed plugins and verify usage through the production BlockWriteAI Platform:
50
+
51
+ ```js
52
+ await BlockWriteAI.loadPremiumPlugins({
53
+ licenseKey: "bwai_live_xxxxx",
54
+ endpoint: BlockWriteAI.platformEndpoints.premiumPlugins,
55
+ features: ["drawing", "mermaid", "signature", "signature_flow", "ai"]
56
+ });
57
+ ```
58
+
59
+ ## Install With Node
60
+
61
+ ```bash
62
+ npm install @qarakash/blockwriteai
63
+ ```
64
+
65
+ ```js
66
+ import BlockWriteAI from "@qarakash/blockwriteai";
67
+ import "@qarakash/blockwriteai/css";
68
+ import "@qarakash/blockwriteai/plugins/code-assist/min";
69
+ import "@qarakash/blockwriteai/plugins/advanced/min";
70
+
71
+ const editor = new BlockWriteAI({
72
+ holder: "#editor",
73
+ premium: {
74
+ licenseKey: "bwai_live_xxxxx",
75
+ verifyEndpoint: BlockWriteAI.platformEndpoints.licenseVerify,
76
+ usageEndpoint: BlockWriteAI.platformEndpoints.aiUsage,
77
+ featureUsageEndpoint: BlockWriteAI.platformEndpoints.premiumUsage,
78
+ eventEndpoint: BlockWriteAI.platformEndpoints.premiumEvent,
79
+ signatureEventEndpoint: BlockWriteAI.platformEndpoints.signatureEvent
80
+ },
81
+ async onSave(data) {
82
+ await fetch("/api/documents", {
83
+ method: "POST",
84
+ headers: { "Content-Type": "application/json" },
85
+ body: JSON.stringify(data)
86
+ });
87
+ }
88
+ });
89
+ ```
90
+
91
+ ## Install With PHP
92
+
93
+ ```bash
94
+ composer require qarakash/blockwriteai
95
+ ```
96
+
97
+ Publish the package `dist` assets into a public asset directory in your app, then print the tags:
98
+
99
+ ```php
100
+ <?php
101
+
102
+ use QarAkash\BlockWriteAI\BlockWriteAIAssets;
103
+
104
+ echo BlockWriteAIAssets::stylesheetTag('/assets/blockwriteai');
105
+ echo BlockWriteAIAssets::scriptTags('/assets/blockwriteai');
106
+
107
+ $platform = BlockWriteAIAssets::platformEndpoints();
108
+ ```
109
+
110
+ Create the editor:
111
+
112
+ ```html
113
+ <div id="editor"></div>
114
+ <script>
115
+ const editor = new BlockWriteAI({
116
+ holder: "#editor",
117
+ async onSave(data) {
118
+ await fetch("/api/documents/save.php", {
119
+ method: "POST",
120
+ headers: { "Content-Type": "application/json" },
121
+ body: JSON.stringify(data)
122
+ });
123
+ }
124
+ });
125
+ </script>
126
+ ```
127
+
128
+ ## Install With Python
129
+
130
+ ```bash
131
+ pip install blockwriteai-editor
132
+ ```
133
+
134
+ Copy the packaged assets into your app static directory:
135
+
136
+ ```python
137
+ from blockwriteai_editor import copy_static
138
+
139
+ copy_static("static/blockwriteai")
140
+ ```
141
+
142
+ Generate tags in Flask, Django, or any Python web app:
143
+
144
+ ```python
145
+ from blockwriteai_editor import platform_endpoints, stylesheet_tag, script_tags
146
+
147
+ print(stylesheet_tag("/static/blockwriteai"))
148
+ print(script_tags("/static/blockwriteai"))
149
+
150
+ platform = platform_endpoints()
151
+ ```
152
+
153
+ Then mount the editor in your template:
154
+
155
+ ```html
156
+ <div id="editor"></div>
157
+ <script>
158
+ const editor = new BlockWriteAI({
159
+ holder: "#editor",
160
+ async onSave(data) {
161
+ await fetch("/api/documents", {
162
+ method: "POST",
163
+ headers: { "Content-Type": "application/json" },
164
+ body: JSON.stringify(data)
165
+ });
166
+ }
167
+ });
168
+ </script>
169
+ ```
170
+
171
+ ## Read Saved Documents
172
+
173
+ BlockWriteAI saves JSON. Store that JSON in your database, then render it later with a preview container:
174
+
175
+ ```html
176
+ <link rel="stylesheet" href="/assets/blockwriteai/blockwriteai.min.css">
177
+
178
+ <div class="blockwriteai-preview" data-source="/api/documents/123.json"></div>
179
+
180
+ <script src="/assets/blockwriteai/blockwriteai.min.js"></script>
181
+ <script src="/assets/blockwriteai/plugins/blockwriteai-advanced-blocks.min.js"></script>
182
+ <script>
183
+ BlockWriteAI.mountPreviews();
184
+ </script>
185
+ ```
186
+
187
+ The JSON endpoint can return a document directly:
188
+
189
+ ```json
190
+ {
191
+ "time": 1779540000000,
192
+ "version": "1.1.0",
193
+ "blocks": []
194
+ }
195
+ ```
196
+
197
+ It can also return a wrapper:
198
+
199
+ ```json
200
+ {
201
+ "ok": true,
202
+ "data": {
203
+ "time": 1779540000000,
204
+ "version": "1.1.0",
205
+ "blocks": []
206
+ }
207
+ }
208
+ ```
209
+
210
+ ## Premium Plugins
211
+
212
+ Do not expose premium plugin files as normal public scripts. Load them after your server verifies an active license:
213
+
214
+ ```html
215
+ <script>
216
+ async function bootEditor() {
217
+ await BlockWriteAI.loadPremiumPlugins({
218
+ licenseKey: "bwai_live_xxxxx",
219
+ endpoint: "https://blockwriteai.in/api/premium_plugins.php",
220
+ features: ["drawing", "mermaid", "signature", "signature_flow", "ai"]
221
+ });
222
+
223
+ window.editor = new BlockWriteAI({
224
+ holder: "#editor",
225
+ premium: {
226
+ licenseKey: "bwai_live_xxxxx",
227
+ verifyEndpoint: "https://blockwriteai.in/api/license_verify.php",
228
+ usageEndpoint: "https://blockwriteai.in/api/ai_usage.php"
229
+ },
230
+ ai: {
231
+ endpoint: "https://blockwriteai.in/api/ai_generate.php"
232
+ }
233
+ });
234
+ }
235
+
236
+ bootEditor();
237
+ </script>
238
+ ```
239
+
240
+ The browser plugin must never receive private API keys. Keep OpenAI, billing, usage limits, and license checks on your server.
241
+
242
+ ## Release Checklist
243
+
244
+ 1. Run `npm run build:min`.
245
+ 2. Run `npm run check`.
246
+ 3. Publish `@qarakash/blockwriteai` to npm.
247
+ 4. Publish `qarakash/blockwriteai` to Packagist.
248
+ 5. Publish `blockwriteai-editor` to PyPI.
249
+ 6. Serve only the public asset directory from your application.
250
+
251
+ ## Notes For Production
252
+
253
+ - Use the `.min.css` and `.min.js` files in public pages.
254
+ - Do not publish source folders, examples, build artifacts, package caches, or private configuration files.
255
+ - Browser-delivered CSS and JavaScript can always be downloaded. Protect paid features with server-side license checks and metered premium bundle delivery.
256
+ - Keep secret keys in backend environment variables only.