@mahe_pkm/buzl-html-editor 0.1.0 → 0.2.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/HANDBOOK.md ADDED
@@ -0,0 +1,268 @@
1
+ # Buzl HTML Editor Handbook
2
+
3
+ This handbook explains how to install and run Buzl HTML Editor in the root of an ordinary static HTML website. It is for Windows, macOS, and Linux users.
4
+
5
+ ## What Buzl does
6
+
7
+ `buzl-editor` starts one local server with two ways to work:
8
+
9
+ | Address | Use it for |
10
+ | --- | --- |
11
+ | `http://localhost:4000/` | Normal website preview with the floating **Edit Text** toolbar |
12
+ | `http://localhost:4000/admin/` | The full visual editor, page controls, and image upload tools |
13
+
14
+ `buzl-site` starts a clean website-only preview. It has no editor, edit toolbar, or editor API routes.
15
+
16
+ ## Before you start
17
+
18
+ You need Node.js 18 or newer. Node.js 20 LTS or newer is recommended.
19
+
20
+ ```powershell
21
+ node --version
22
+ npm --version
23
+ ```
24
+
25
+ Your website root is the folder that contains `index.html`. It normally also contains folders such as `assets`, `images`, `css`, or `js`.
26
+
27
+ ```text
28
+ client-website/
29
+ ├── index.html
30
+ ├── about.html
31
+ ├── assets/
32
+ ├── images/
33
+ └── css/
34
+ ```
35
+
36
+ Before editing, make a copy of the complete website folder or commit the current work to Git. Buzl makes page backups on save, but a full-site backup is still the simplest recovery point.
37
+
38
+ ## Install Buzl
39
+
40
+ ### Recommended: install for one website
41
+
42
+ Open a terminal in the website root, then run:
43
+
44
+ ```powershell
45
+ npm install --save-dev @mahe_pkm/buzl-html-editor
46
+ ```
47
+
48
+ Run it with `npx`, which always uses the version installed for this website:
49
+
50
+ ```powershell
51
+ npx buzl-editor
52
+ ```
53
+
54
+ ### Optional: install globally
55
+
56
+ Use this only when you want one command available for many websites on the same computer:
57
+
58
+ ```powershell
59
+ npm install -g @mahe_pkm/buzl-html-editor
60
+ ```
61
+
62
+ Then use `buzl-editor` and `buzl-site` directly instead of `npx buzl-editor` and `npx buzl-site`.
63
+
64
+ ## First-time checks
65
+
66
+ From the website root, create Buzl's optional local configuration and run diagnostics:
67
+
68
+ ```powershell
69
+ npx buzl-editor init
70
+ npx buzl-editor doctor
71
+ ```
72
+
73
+ `init` creates `.buzl/config.json`, `.env.example`, and safe Git-ignore rules only when they are missing. It does not replace website HTML. `doctor` checks that Buzl can find HTML pages and start safely.
74
+
75
+ ## Start the website and editor
76
+
77
+ ```powershell
78
+ npx buzl-editor
79
+ ```
80
+
81
+ The default addresses are:
82
+
83
+ ```text
84
+ Website preview: http://localhost:4000/
85
+ Advanced editor: http://localhost:4000/admin/
86
+ ```
87
+
88
+ Use a different port when `4000` is already in use:
89
+
90
+ ```powershell
91
+ npx buzl-editor --port 4173
92
+ ```
93
+
94
+ Then open:
95
+
96
+ ```text
97
+ http://localhost:4173/
98
+ http://localhost:4173/admin/
99
+ ```
100
+
101
+ To run a site while your terminal is in another folder, provide its root explicitly:
102
+
103
+ ```powershell
104
+ npx buzl-editor --root "C:\Websites\client-website" --port 4000
105
+ ```
106
+
107
+ By default, Buzl opens the normal website preview. To open the advanced editor instead:
108
+
109
+ ```powershell
110
+ npx buzl-editor --open-admin
111
+ ```
112
+
113
+ To prevent a browser tab opening automatically:
114
+
115
+ ```powershell
116
+ npx buzl-editor --no-open
117
+ ```
118
+
119
+ Press `Ctrl+C` in the same terminal window to stop the server.
120
+
121
+ ## Edit text from the normal website preview
122
+
123
+ 1. Open the normal preview URL, such as `http://localhost:4000/`.
124
+ 2. Select the small floating pencil button in the lower-right corner.
125
+ 3. In the compact Buzl menu, select **Edit Text**.
126
+ 4. Click highlighted text, type your change, and inspect the result.
127
+ 5. Select **Undo** to reverse the latest edit, or **Cancel** to discard all unsaved edits.
128
+ 6. Select **Save** only when the page is correct.
129
+
130
+ The pencil opens a compact vertical menu containing Edit Text, Save, Undo, Cancel, and Advanced Editor. The toolbar is available only from `buzl-editor` while it is bound to your local machine. Simply opening the preview or turning on Edit Text does not write the toolbar into your website files. Saving writes only the approved page content and creates a recoverable backup under `.buzl/backups/`.
131
+
132
+ Use the advanced editor when you need image upload, optimization, page controls, or richer editing tools.
133
+
134
+ ## Use the advanced editor
135
+
136
+ Open `http://localhost:4000/admin/`.
137
+
138
+ Use the page list to choose an HTML page. Make changes, preview the page, and save only after checking text, links, mobile layout, and images. Uploaded raster images are optimized to AVIF and saved under `assets/images/`; safe SVG images remain SVG.
139
+
140
+ ## Run a clean website-only preview
141
+
142
+ Use this when you want to show or test the local website without any editing controls:
143
+
144
+ ```powershell
145
+ npx buzl-site
146
+ ```
147
+
148
+ For a different port:
149
+
150
+ ```powershell
151
+ npx buzl-site --port 4173
152
+ ```
153
+
154
+ Website-only mode deliberately blocks `/admin/`, editor APIs, local configuration, dependencies, package files, and the Preview Live Edit toolbar.
155
+
156
+ ## macOS and Linux
157
+
158
+ The commands are the same in Terminal. Change into the website root first:
159
+
160
+ ```bash
161
+ cd "/path/to/client-website"
162
+ npm install --save-dev @mahe_pkm/buzl-html-editor
163
+ npx buzl-editor
164
+ ```
165
+
166
+ Stop the server with `Ctrl+C`.
167
+
168
+ ## Backups and rollback
169
+
170
+ Every saved HTML change gets a timestamped backup in `.buzl/backups/`. To recover, stop the editor, copy the required backup over the affected HTML file, then restart and check the page in a browser.
171
+
172
+ For an entire website rollback, restore the full copy or Git commit made before editing. Do not delete current work until the restored copy has been checked.
173
+
174
+ ## Troubleshooting
175
+
176
+ ### `buzl-editor` is not recognized
177
+
178
+ Use the project-local command:
179
+
180
+ ```powershell
181
+ npx buzl-editor
182
+ ```
183
+
184
+ Or reinstall the global package and reopen the terminal:
185
+
186
+ ```powershell
187
+ npm install -g @mahe_pkm/buzl-html-editor
188
+ ```
189
+
190
+ ### The browser shows `Cannot GET /`
191
+
192
+ Confirm you started Buzl from the folder containing `index.html`. If the website has no root `index.html`, open the actual page URL or add the correct entry page before starting.
193
+
194
+ ### Port already in use
195
+
196
+ Stop the earlier server with `Ctrl+C`, or choose another port:
197
+
198
+ ```powershell
199
+ npx buzl-editor --port 4173
200
+ ```
201
+
202
+ ### The Edit Text toolbar is missing
203
+
204
+ Use `buzl-editor`, not `buzl-site`, and open the local website URL from the terminal output. The toolbar is intentionally disabled on a network-bound server.
205
+
206
+ ### Images or styles are missing
207
+
208
+ Start from the true website root and use the local HTTP address. Do not open pages directly with `file://`, because relative asset paths and scripts can behave differently.
209
+
210
+ ## Update Buzl
211
+
212
+ For a website-local installation:
213
+
214
+ ```powershell
215
+ npm update @mahe_pkm/buzl-html-editor
216
+ ```
217
+
218
+ For a global installation:
219
+
220
+ ```powershell
221
+ npm update -g @mahe_pkm/buzl-html-editor
222
+ ```
223
+
224
+ Back up the website, run `doctor`, start the editor, and test the website preview and `/admin/` after every update.
225
+
226
+ ## Advanced users: global AI API keys
227
+
228
+ Buzl's normal Live Edit and image optimization do not need an AI key. AI text and AI image actions can use an Anthropic or OpenRouter key.
229
+
230
+ To make a key available to every website you run with the global `buzl-editor` command, store it as an operating-system environment variable. Do not place a key in HTML, browser JavaScript, Git, or a deployed website.
231
+
232
+ ### Windows PowerShell
233
+
234
+ ```powershell
235
+ setx ANTHROPIC_API_KEY "your_anthropic_key"
236
+ setx OPENROUTER_API_KEY "your_openrouter_key"
237
+ ```
238
+
239
+ Close PowerShell completely and open a new window before starting Buzl. `setx` stores the value for your Windows user account, so treat the computer account as sensitive.
240
+
241
+ ### macOS and Linux
242
+
243
+ Add the required key to your shell profile. Use `~/.zshrc` for the usual macOS shell or `~/.bashrc` for Bash:
244
+
245
+ ```bash
246
+ export ANTHROPIC_API_KEY="your_anthropic_key"
247
+ export OPENROUTER_API_KEY="your_openrouter_key"
248
+ ```
249
+
250
+ Reload the relevant profile before starting Buzl:
251
+
252
+ ```bash
253
+ source ~/.zshrc
254
+ # or
255
+ source ~/.bashrc
256
+ ```
257
+
258
+ Global operating-system variables take priority over a website's `.env` file. Use a website-root `.env` only when a specific client requires a separate key. Keep `.env` out of Git and hosting uploads.
259
+
260
+ ## Safety checklist before deployment
261
+
262
+ - Confirm every changed page in a browser.
263
+ - Test navigation, forms, images, and mobile layout.
264
+ - Keep a dated full-site backup.
265
+ - Deploy with your existing hosting or Git workflow only after local review.
266
+ - Never upload `.env` files or API keys.
267
+
268
+ This version supports ordinary static HTML, CSS, JavaScript, and multi-page websites. Server-rendered and build-system websites require a separate integration workflow.
package/README.md CHANGED
@@ -1,12 +1,17 @@
1
1
  # Buzl HTML Editor
2
2
 
3
3
  A local visual editor and static-site server for ordinary multi-page HTML, CSS,
4
- and JavaScript websites. It includes Live Edit, image uploads, AVIF image
4
+ and JavaScript websites. It includes on-page Live Edit, image uploads, AVIF image
5
5
  optimization, AI-assisted text, and AI image generation.
6
6
 
7
7
  The server is local-only by default. It edits the website folder from which it
8
8
  is started; the editor's own files stay inside the npm package.
9
9
 
10
+ ## Documentation
11
+
12
+ - Full setup handbook: [HANDBOOK.md](./HANDBOOK.md)
13
+ - Printable handbook: [docs/Buzl-HTML-Editor-Handbook-Advanced.pdf](./docs/Buzl-HTML-Editor-Handbook-Advanced.pdf)
14
+
10
15
  ## Requirements
11
16
 
12
17
  - Node.js 18 or newer
@@ -29,8 +34,20 @@ npx buzl-editor
29
34
 
30
35
  Default addresses:
31
36
 
32
- - Website: `http://localhost:4000/`
33
- - Editor: `http://localhost:4000/admin/`
37
+ - Website with a floating **Edit Text** toolbar: `http://localhost:4000/`
38
+ - Advanced editor: `http://localhost:4000/admin/`
39
+
40
+ `buzl-editor` opens the website preview by default. Select the small floating
41
+ **pencil** button to open the Buzl menu, then select **Edit Text** to edit
42
+ visible text directly on any page. Use **Save**, **Undo**, or **Cancel** from
43
+ the compact menu. The toolbar is injected only while the local editor server is
44
+ running and is never added to the saved website.
45
+
46
+ Open the advanced editor by default when needed:
47
+
48
+ ```bash
49
+ npx buzl-editor --open-admin
50
+ ```
34
51
 
35
52
  Use another port or website folder when needed:
36
53
 
@@ -52,8 +69,8 @@ npx buzl-site
52
69
  npx buzl-site --port 3500
53
70
  ```
54
71
 
55
- Website-only mode blocks the editor, APIs, dependencies, configuration,
56
- development files, and local secrets.
72
+ Website-only mode does not inject the editing toolbar and blocks the editor,
73
+ APIs, dependencies, configuration, development files, and local secrets.
57
74
 
58
75
  ## Setup and diagnostics
59
76
 
@@ -106,6 +123,8 @@ actions require them.
106
123
  - Non-local binding requires both `--host` and `--allow-network`.
107
124
  - The editor can only load and save HTML files inside the selected website.
108
125
  - Each save creates a recoverable copy under `.buzl/backups/`.
126
+ - Preview Live Edit uses short-lived page tokens, rejects stale-page saves, and
127
+ is disabled when the editor binds to a non-local network address.
109
128
  - Uploaded raster images are optimized to AVIF under `assets/images/`.
110
129
  - `.env`, `.git`, `.buzl`, `node_modules`, tests, package metadata, and server
111
130
  source are not publicly served.
@@ -31,7 +31,8 @@ Options:
31
31
  --port, -p Local port (default: 4000)
32
32
  --host <address> Bind address (default: 127.0.0.1)
33
33
  --allow-network Required for a non-local bind address
34
- --open Open the editor in the default browser
34
+ --open Open the website preview in the default browser
35
+ --open-admin Open the advanced /admin editor instead
35
36
  --no-open Do not open a browser
36
37
  --version, -v Show package version
37
38
  --help, -h Show this help
@@ -87,7 +88,7 @@ async function main() {
87
88
  console.log(`Editor: ${editorUrl}`);
88
89
  console.log(`Root: ${options.root}`);
89
90
  console.log('Press Ctrl+C to stop.\n');
90
- if (options.open) openBrowser(editorUrl);
91
+ if (options.open) openBrowser(options.openAdmin ? editorUrl : siteUrl);
91
92
  });
92
93
 
93
94
  const stop = () => server.close(() => process.exit(0));
@@ -0,0 +1,189 @@
1
+ :host {
2
+ all: initial;
3
+ }
4
+
5
+ .buzl-toolbar {
6
+ align-items: flex-end;
7
+ background: #211717;
8
+ border: 1px solid rgba(212, 175, 55, 0.55);
9
+ border-radius: 14px;
10
+ bottom: 18px;
11
+ box-shadow: 0 14px 42px rgba(0, 0, 0, 0.35);
12
+ color: #f8f4eb;
13
+ display: flex;
14
+ flex-direction: column-reverse;
15
+ font: 600 13px/1.2 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
16
+ gap: 0;
17
+ max-width: calc(100vw - 32px);
18
+ padding: 7px;
19
+ position: fixed;
20
+ right: 18px;
21
+ transition: width 210ms ease;
22
+ width: 56px;
23
+ z-index: 2147483647;
24
+ }
25
+
26
+ .buzl-toolbar[data-expanded="true"] {
27
+ width: min(242px, calc(100vw - 32px));
28
+ }
29
+
30
+ .buzl-toolbar .buzl-launcher {
31
+ align-items: center;
32
+ background: #d4af37;
33
+ border-color: #d4af37;
34
+ color: #211717;
35
+ font-size: 22px;
36
+ font-weight: 700;
37
+ height: 42px;
38
+ justify-content: center;
39
+ min-height: 42px;
40
+ padding: 0;
41
+ transition: background 160ms ease, color 160ms ease, transform 180ms ease;
42
+ width: 42px;
43
+ }
44
+
45
+ .buzl-toolbar .buzl-launcher:hover {
46
+ background: #ebca5b;
47
+ color: #211717;
48
+ }
49
+
50
+ .buzl-toolbar[data-expanded="true"] .buzl-launcher {
51
+ transform: rotate(-12deg);
52
+ }
53
+
54
+ .buzl-toolbar .buzl-menu {
55
+ align-items: stretch;
56
+ box-sizing: border-box;
57
+ display: flex;
58
+ flex-direction: column;
59
+ flex-wrap: nowrap;
60
+ gap: 8px;
61
+ max-height: 0;
62
+ opacity: 0;
63
+ overflow: hidden;
64
+ pointer-events: none;
65
+ transform: translateY(8px) scale(0.98);
66
+ transform-origin: bottom right;
67
+ transition: max-height 210ms ease, opacity 170ms ease, padding-top 210ms ease, transform 210ms ease;
68
+ width: 100%;
69
+ }
70
+
71
+ .buzl-toolbar[data-expanded="true"] .buzl-menu {
72
+ max-height: 300px;
73
+ opacity: 1;
74
+ padding-top: 8px;
75
+ pointer-events: auto;
76
+ transform: translateY(0) scale(1);
77
+ }
78
+
79
+ .buzl-toolbar button,
80
+ .buzl-toolbar a {
81
+ align-items: center;
82
+ background: transparent;
83
+ border: 1px solid rgba(255, 255, 255, 0.2);
84
+ border-radius: 9px;
85
+ box-sizing: border-box;
86
+ color: inherit;
87
+ cursor: pointer;
88
+ display: inline-flex;
89
+ font: inherit;
90
+ min-height: 36px;
91
+ padding: 8px 12px;
92
+ text-decoration: none;
93
+ }
94
+
95
+ .buzl-toolbar .buzl-menu button,
96
+ .buzl-toolbar .buzl-menu a {
97
+ justify-content: center;
98
+ width: 100%;
99
+ }
100
+
101
+ .buzl-toolbar button:hover,
102
+ .buzl-toolbar a:hover {
103
+ border-color: #d4af37;
104
+ color: #f5d975;
105
+ }
106
+
107
+ .buzl-toolbar button:focus-visible,
108
+ .buzl-toolbar a:focus-visible {
109
+ outline: 3px solid rgba(212, 175, 55, 0.35);
110
+ outline-offset: 2px;
111
+ }
112
+
113
+ .buzl-toolbar button:disabled {
114
+ cursor: not-allowed;
115
+ opacity: 0.45;
116
+ }
117
+
118
+ .buzl-toolbar .buzl-primary {
119
+ background: #d4af37;
120
+ border-color: #d4af37;
121
+ color: #211717;
122
+ }
123
+
124
+ .buzl-toolbar .buzl-primary:hover {
125
+ background: #ebca5b;
126
+ color: #211717;
127
+ }
128
+
129
+ .buzl-toolbar .buzl-status {
130
+ color: #d9d0c7;
131
+ font-weight: 500;
132
+ box-sizing: border-box;
133
+ max-width: none;
134
+ overflow: hidden;
135
+ padding: 0 5px;
136
+ text-overflow: ellipsis;
137
+ text-align: center;
138
+ white-space: normal;
139
+ width: 100%;
140
+ }
141
+
142
+ .buzl-toolbar .buzl-status[data-tone="success"] {
143
+ color: #89e6aa;
144
+ }
145
+
146
+ .buzl-toolbar .buzl-status[data-tone="warning"] {
147
+ color: #f5d975;
148
+ }
149
+
150
+ .buzl-toolbar .buzl-status[data-tone="error"] {
151
+ color: #ff9c9c;
152
+ }
153
+
154
+ @media (max-width: 680px) {
155
+ .buzl-toolbar {
156
+ bottom: 10px;
157
+ left: auto;
158
+ right: 10px;
159
+ }
160
+
161
+ .buzl-toolbar[data-expanded="true"] {
162
+ left: 10px;
163
+ width: min(242px, calc(100vw - 20px));
164
+ }
165
+
166
+ .buzl-toolbar .buzl-status {
167
+ flex: 1 1 100%;
168
+ max-width: none;
169
+ order: -1;
170
+ }
171
+ }
172
+
173
+ body.buzl-public-editing [data-buzl-public-edit="true"] {
174
+ cursor: text !important;
175
+ outline: 2px dashed rgba(212, 175, 55, 0.85) !important;
176
+ outline-offset: 3px !important;
177
+ }
178
+
179
+ body.buzl-public-editing [data-buzl-public-edit="true"]:focus {
180
+ background: rgba(212, 175, 55, 0.13) !important;
181
+ outline-style: solid !important;
182
+ }
183
+
184
+ @media (prefers-reduced-motion: reduce) {
185
+ .buzl-toolbar .buzl-launcher,
186
+ .buzl-toolbar .buzl-menu {
187
+ transition: none;
188
+ }
189
+ }