@lobehub/editor 1.5.3 → 1.5.4

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
@@ -8,17 +8,17 @@
8
8
 
9
9
  A modern, extensible rich text editor built on Meta's Lexical framework with dual-architecture design, featuring both a powerful kernel and React integration. Optimized for AI applications and chat interfaces.
10
10
 
11
- [![][npm-release-shield]][npm-release-link]
12
- [![][github-releasedate-shield]][github-releasedate-link]
13
- [![][github-action-test-shield]][github-action-test-link]
14
- [![][github-action-release-shield]][github-action-release-link]<br/>
15
- [![][github-contributors-shield]][github-contributors-link]
16
- [![][github-forks-shield]][github-forks-link]
17
- [![][github-stars-shield]][github-stars-link]
18
- [![][github-issues-shield]][github-issues-link]
19
- [![][github-license-shield]][github-license-link]
20
-
21
- [Changelog](./CHANGELOG.md) · [Report Bug][github-issues-link] · [Request Feature][github-issues-link]
11
+ \[!\[]\[npm-release-shield]]\[npm-release-link]
12
+ \[!\[]\[github-releasedate-shield]]\[github-releasedate-link]
13
+ \[!\[]\[github-action-test-shield]]\[github-action-test-link]
14
+ \[!\[]\[github-action-release-shield]]\[github-action-release-link]<br/>
15
+ \[!\[]\[github-contributors-shield]]\[github-contributors-link]
16
+ \[!\[]\[github-forks-shield]]\[github-forks-link]
17
+ \[!\[]\[github-stars-shield]]\[github-stars-link]
18
+ \[!\[]\[github-issues-shield]]\[github-issues-link]
19
+ \[!\[]\[github-license-shield]]\[github-license-link]
20
+
21
+ [Changelog](./CHANGELOG.md) · \[Report Bug]\[github-issues-link] · \[Request Feature]\[github-issues-link]
22
22
 
23
23
  ![](https://github.com/user-attachments/assets/98c9a810-1c7d-4c33-acd7-ae9d4c0695da)
24
24
 
@@ -48,12 +48,6 @@ A modern, extensible rich text editor built on Meta's Lexical framework with dua
48
48
  - [Setup](#setup)
49
49
  - [Available Scripts](#available-scripts)
50
50
  - [Debug Environment Variables](#debug-environment-variables)
51
- - [Project Architecture](#project-architecture)
52
- - [🤝 Contributing](#-contributing)
53
- - [🔗 Links](#-links)
54
- - [More Products](#more-products)
55
- - [Design Resources](#design-resources)
56
- - [Development Resources](#development-resources)
57
51
 
58
52
  ####
59
53
 
@@ -76,7 +70,7 @@ A modern, extensible rich text editor built on Meta's Lexical framework with dua
76
70
 
77
71
  To install `@lobehub/editor`, run the following command:
78
72
 
79
- [![][bun-shield]][bun-link]
73
+ \[!\[]\[bun-shield]]\[bun-link]
80
74
 
81
75
  ```bash
82
76
  $ bun add @lobehub/editor
@@ -88,7 +82,7 @@ $ pnpm add @lobehub/editor
88
82
 
89
83
  <div align="right">
90
84
 
91
- [![][back-to-top]](#readme-top)
85
+ [!\[\]\[back-to-top\]](#readme-top)
92
86
 
93
87
  </div>
94
88
 
@@ -237,7 +231,7 @@ editor.dispatchCommand(INSERT_HEADING_COMMAND, { tag: 'h2' });
237
231
 
238
232
  <div align="right">
239
233
 
240
- [![][back-to-top]](#readme-top)
234
+ [!\[\]\[back-to-top\]](#readme-top)
241
235
 
242
236
  </div>
243
237
 
@@ -396,7 +390,7 @@ CLEAR_FORMAT_COMMAND;
396
390
 
397
391
  <div align="right">
398
392
 
399
- [![][back-to-top]](#readme-top)
393
+ [!\[\]\[back-to-top\]](#readme-top)
400
394
 
401
395
  </div>
402
396
 
@@ -406,11 +400,11 @@ CLEAR_FORMAT_COMMAND;
406
400
 
407
401
  You can use Github Codespaces for online development:
408
402
 
409
- [![][github-codespace-shield]][github-codespace-link]
403
+ \[!\[]\[github-codespace-shield]]\[github-codespace-link]
410
404
 
411
405
  Or clone it for local development:
412
406
 
413
- [![][bun-shield]][bun-link]
407
+ \[!\[]\[bun-shield]]\[bun-link]
414
408
 
415
409
  ```bash
416
410
  $ git clone https://github.com/lobehub/lobe-editor.git
@@ -477,34 +471,18 @@ DEBUG=lobe-editor:kernel,lobe-editor:plugin:*
477
471
 
478
472
  #### Development Usage
479
473
 
480
- ```bash
474
+ ````bash
481
475
  # Full debug during development
482
- DEBUG=lobe-editor:* pnpm dev
476
+ DEBUG=lobe-editor:*
483
477
 
484
478
  # Only critical logs
485
- DEBUG=lobe-editor:*:error,lobe-editor:*:warn pnpm dev
486
-
479
+ DEBUG=lobe-editor:*:error,lobe-editor:*:warn
487
480
  # Plugin debugging
488
- DEBUG=lobe-editor:plugin:* pnpm dev
489
-
481
+ DEBUG=lobe-editor:plugin:*
490
482
  # Service debugging
491
- DEBUG=lobe-editor:service:* pnpm dev
483
+ DEBUG=lobe-editor:service:*
492
484
  ```
493
485
 
494
- #### Browser Configuration
495
-
496
- In browser environment, you can also enable debug logging via localStorage:
497
-
498
- ```javascript
499
- // Enable all debug output
500
- localStorage.debug = 'lobe-editor:*';
501
-
502
- // Enable specific categories
503
- localStorage.debug = 'lobe-editor:kernel,lobe-editor:plugin:*';
504
-
505
- // Disable debug output
506
- localStorage.removeItem('debug');
507
- ```
508
486
 
509
487
  ### Project Architecture
510
488
 
@@ -707,3 +685,4 @@ This project is [MIT](./LICENSE) licensed.
707
685
  [pr-welcome-link]: https://github.com/lobehub/lobe-editor/pulls
708
686
  [pr-welcome-shield]: https://img.shields.io/badge/%F0%9F%A4%AF%20PR%20WELCOME-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
709
687
  [profile-link]: https://github.com/lobehub
688
+ ````
package/es/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export * from './plugins/slash';
14
14
  export * from './plugins/table';
15
15
  export * from './plugins/upload';
16
16
  export type { IEditor } from './types';
17
- export { createDebugLogger, debugLogger, debugLoggers, devConsole, prodSafeLogger, } from './utils/debug';
17
+ export { browserDebug, createDebugLogger, debugLogger, debugLoggers, devConsole, prodSafeLogger, } from './utils/debug';
18
18
  export { Kernel } from './editor-kernel/kernel';
19
19
  /**
20
20
  * Enable hot reload mode globally for all editor instances
package/es/index.js CHANGED
@@ -14,7 +14,7 @@ export * from "./plugins/slash";
14
14
  export * from "./plugins/table";
15
15
  export * from "./plugins/upload";
16
16
  // Debug utilities
17
- export { createDebugLogger, debugLogger, debugLoggers, devConsole, prodSafeLogger } from "./utils/debug";
17
+ export { browserDebug, createDebugLogger, debugLogger, debugLoggers, devConsole, prodSafeLogger } from "./utils/debug";
18
18
 
19
19
  // Hot reload utilities
20
20
  export { Kernel } from "./editor-kernel/kernel";
@@ -71,4 +71,4 @@ export var ImagePlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
71
71
  }
72
72
  }]);
73
73
  return ImagePlugin;
74
- }(KernelPlugin), _defineProperty(_class, "pluginName", 'image'), _class);
74
+ }(KernelPlugin), _defineProperty(_class, "pluginName", 'ImagePlugin'), _class);
@@ -129,4 +129,4 @@ export var SlashPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
129
129
  }
130
130
  }]);
131
131
  return SlashPlugin;
132
- }(KernelPlugin), _defineProperty(_class, "pluginName", 'slash'), _class);
132
+ }(KernelPlugin), _defineProperty(_class, "pluginName", 'SlashPlugin'), _class);
@@ -81,4 +81,4 @@ export var UploadPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
81
81
  }
82
82
  }]);
83
83
  return UploadPlugin;
84
- }(KernelPlugin), _defineProperty(_class, "pluginName", 'upload'), _class);
84
+ }(KernelPlugin), _defineProperty(_class, "pluginName", 'UploadPlugin'), _class);
@@ -1,4 +1,8 @@
1
1
  import createDebug from 'debug';
2
+ /**
3
+ * Development mode check
4
+ */
5
+ declare const isDev: boolean;
2
6
  /**
3
7
  * Debug utility factory for LobeHub Editor
4
8
  * Creates namespaced debug functions following the pattern: lobe-editor:category
@@ -360,7 +364,7 @@ export declare const debugLoggers: {
360
364
  /**
361
365
  * Development mode utilities
362
366
  */
363
- export declare const isDev: boolean;
367
+ export { isDev };
364
368
  /**
365
369
  * Conditional console logging - only logs in development mode
366
370
  * Use this for demo files and development-only logging
@@ -394,3 +398,32 @@ export declare const prodSafeLogger: {
394
398
  */
395
399
  warn: (...args: any[]) => void;
396
400
  };
401
+ /**
402
+ * Browser debug utilities for Next.js and other client-side frameworks
403
+ */
404
+ export declare const browserDebug: {
405
+ /**
406
+ * Disable debug logging in browser environment
407
+ */
408
+ disable: () => void;
409
+ /**
410
+ * Enable debug logging in browser environment
411
+ * @param namespaces - Debug namespaces to enable (e.g., 'lobe-editor:*')
412
+ */
413
+ enable: (namespaces?: string) => void;
414
+ /**
415
+ * Get current debug configuration
416
+ */
417
+ getConfig: () => {
418
+ enabled: string | boolean;
419
+ source: string;
420
+ };
421
+ /**
422
+ * Show available debug categories
423
+ */
424
+ showCategories: () => void;
425
+ /**
426
+ * Show current debug status and configuration
427
+ */
428
+ showStatus: () => void;
429
+ };
package/es/utils/debug.js CHANGED
@@ -13,6 +13,11 @@ import createDebug from 'debug';
13
13
  */
14
14
  var BASE_NAMESPACE = 'lobe-editor';
15
15
 
16
+ /**
17
+ * Development mode check
18
+ */
19
+ var isDev = process.env.NODE_ENV === 'development';
20
+
16
21
  /**
17
22
  * Debug utility factory for LobeHub Editor
18
23
  * Creates namespaced debug functions following the pattern: lobe-editor:category
@@ -136,6 +141,32 @@ export var DebugLogger = /*#__PURE__*/function () {
136
141
  */
137
142
  export var debugLogger = new DebugLogger();
138
143
 
144
+ /**
145
+ * Browser environment debug initialization - Zero configuration approach
146
+ * Automatically enables debug based on environment variables or development mode
147
+ */
148
+ if (typeof window !== 'undefined') {
149
+ // Check for server-side DEBUG environment variable (passed through build process)
150
+ var envDebug = process.env.DEBUG;
151
+
152
+ // Simple logic: Environment variable takes precedence, then development mode
153
+ var debugConfig = null;
154
+ if (envDebug) {
155
+ // Environment variable exists - use it directly
156
+ debugConfig = envDebug;
157
+ localStorage.debug = envDebug;
158
+ } else if (isDev) {
159
+ // Development mode - auto-enable all lobe-editor debug
160
+ debugConfig = 'lobe-editor:*';
161
+ localStorage.debug = debugConfig;
162
+ }
163
+
164
+ // Apply debug configuration
165
+ if (debugConfig) {
166
+ createDebug.enable(debugConfig);
167
+ }
168
+ }
169
+
139
170
  /**
140
171
  * Convenience function to create a debug logger for a specific category
141
172
  * @param category - Main category (e.g., 'kernel', 'plugin', 'upload')
@@ -167,7 +198,7 @@ export var debugLoggers = {
167
198
  /**
168
199
  * Development mode utilities
169
200
  */
170
- export var isDev = process.env.NODE_ENV === 'development';
201
+ export { isDev };
171
202
 
172
203
  /**
173
204
  * Conditional console logging - only logs in development mode
@@ -228,4 +259,90 @@ export var prodSafeLogger = {
228
259
  var _console8;
229
260
  (_console8 = console).warn.apply(_console8, arguments);
230
261
  }
262
+ };
263
+
264
+ /**
265
+ * Browser debug utilities for Next.js and other client-side frameworks
266
+ */
267
+ export var browserDebug = {
268
+ /**
269
+ * Disable debug logging in browser environment
270
+ */
271
+ disable: function disable() {
272
+ if (typeof window !== 'undefined') {
273
+ localStorage.removeItem('debug');
274
+ createDebug.disable();
275
+ console.info('Debug disabled.');
276
+ }
277
+ },
278
+ /**
279
+ * Enable debug logging in browser environment
280
+ * @param namespaces - Debug namespaces to enable (e.g., 'lobe-editor:*')
281
+ */
282
+ enable: function enable() {
283
+ var namespaces = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'lobe-editor:*';
284
+ if (typeof window !== 'undefined') {
285
+ localStorage.debug = namespaces;
286
+ createDebug.enable(namespaces);
287
+ console.info("Debug enabled: ".concat(namespaces));
288
+ console.info('Refresh the page to see debug logs from initialization.');
289
+ }
290
+ },
291
+ /**
292
+ * Get current debug configuration
293
+ */
294
+ getConfig: function getConfig() {
295
+ if (typeof window !== 'undefined') {
296
+ var _envDebug = process.env.DEBUG;
297
+ var currentDebug = localStorage.getItem('debug');
298
+ if (_envDebug) {
299
+ return {
300
+ enabled: _envDebug,
301
+ source: 'environment variable (auto-applied)'
302
+ };
303
+ } else if (isDev && currentDebug) {
304
+ return {
305
+ enabled: currentDebug,
306
+ source: 'development mode (auto-applied)'
307
+ };
308
+ } else {
309
+ return {
310
+ enabled: false,
311
+ source: 'disabled'
312
+ };
313
+ }
314
+ }
315
+ return {
316
+ enabled: process.env.DEBUG || false,
317
+ source: 'server-side'
318
+ };
319
+ },
320
+ /**
321
+ * Show available debug categories
322
+ */
323
+ showCategories: function showCategories() {
324
+ console.group('Available debug categories:');
325
+ console.log('� lobe-editor:kernel - Core editor functionality');
326
+ console.log('🔌 lobe-editor:plugin:* - All plugins');
327
+ console.log('🔍 lobe-editor:service:* - All services');
328
+ console.log('💬 lobe-editor:*:info - Info level messages');
329
+ console.log('⚠️ lobe-editor:*:warn - Warning messages');
330
+ console.log('❌ lobe-editor:*:error - Error messages');
331
+ console.groupEnd();
332
+ console.info('Usage: browserDebug.enable("lobe-editor:kernel,lobe-editor:plugin:*")');
333
+ },
334
+ /**
335
+ * Show current debug status and configuration
336
+ */
337
+ showStatus: function showStatus() {
338
+ var config = browserDebug.getConfig();
339
+ console.group('� LobeHub Editor Debug Status');
340
+ console.log("Status: ".concat(config.enabled ? '✅ Enabled' : '❌ Disabled'));
341
+ console.log("Configuration: ".concat(config.enabled || 'none'));
342
+ console.log("Source: ".concat(config.source));
343
+ console.groupEnd();
344
+ if (!config.enabled) {
345
+ console.info('💡 Zero-config setup: Set DEBUG=lobe-editor:* in your environment');
346
+ }
347
+ }
231
348
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.",
5
5
  "keywords": [
6
6
  "lobehub",