@lobehub/editor 1.5.1 → 1.5.3
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 +72 -0
- package/es/editor-kernel/kernel.d.ts +10 -0
- package/es/editor-kernel/kernel.js +128 -20
- package/es/editor-kernel/plugin.d.ts +14 -0
- package/es/editor-kernel/plugin.js +36 -0
- package/es/editor-kernel/react/useDecorators.js +14 -4
- package/es/index.d.ts +1 -0
- package/es/index.js +11 -4
- package/es/plugins/common/node/cursor.js +5 -3
- package/es/plugins/file/command/index.js +3 -1
- package/es/plugins/file/plugin/index.js +4 -2
- package/es/plugins/hr/plugin/index.js +1 -1
- package/es/plugins/image/command/index.js +3 -1
- package/es/plugins/markdown/service/shortcut.d.ts +1 -0
- package/es/plugins/markdown/service/shortcut.js +3 -1
- package/es/plugins/math/plugin/index.js +5 -3
- package/es/plugins/math/react/component/MathInline.js +3 -1
- package/es/plugins/math/react/index.js +1 -1
- package/es/plugins/mention/plugin/index.js +1 -1
- package/es/plugins/mention/react/ReactMentionPlugin.js +1 -1
- package/es/plugins/slash/service/i-slash-service.d.ts +1 -0
- package/es/plugins/slash/service/i-slash-service.js +4 -1
- package/es/plugins/upload/plugin/index.js +4 -2
- package/es/react/Editor/Editor.js +2 -1
- package/es/types/kernel.d.ts +9 -0
- package/es/utils/debug.d.ts +396 -0
- package/es/utils/debug.js +231 -0
- package/package.json +2 -1
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import createDebug from 'debug';
|
|
2
|
+
/**
|
|
3
|
+
* Debug utility factory for LobeHub Editor
|
|
4
|
+
* Creates namespaced debug functions following the pattern: lobe-editor:category
|
|
5
|
+
*/
|
|
6
|
+
export declare class DebugLogger {
|
|
7
|
+
private debuggers;
|
|
8
|
+
/**
|
|
9
|
+
* Get or create a debug function for a specific namespace
|
|
10
|
+
* @param category - The debug category (e.g., 'kernel', 'plugin', 'upload')
|
|
11
|
+
* @param subcategory - Optional subcategory for more specific debugging
|
|
12
|
+
* @returns Debug function
|
|
13
|
+
*/
|
|
14
|
+
getDebugger(category: string, subcategory?: string): createDebug.Debugger;
|
|
15
|
+
/**
|
|
16
|
+
* Create a scoped debug logger for a specific component/service
|
|
17
|
+
* @param category - Main category
|
|
18
|
+
* @param subcategory - Optional subcategory
|
|
19
|
+
* @returns Object with debug methods
|
|
20
|
+
*/
|
|
21
|
+
createLogger(category: string, subcategory?: string): {
|
|
22
|
+
/**
|
|
23
|
+
* General debug logging
|
|
24
|
+
*/
|
|
25
|
+
debug: createDebug.Debugger;
|
|
26
|
+
/**
|
|
27
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
28
|
+
*/
|
|
29
|
+
error: (...args: any[]) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Info level logging
|
|
32
|
+
*/
|
|
33
|
+
info: createDebug.Debugger;
|
|
34
|
+
/**
|
|
35
|
+
* Log function - alias for debug for compatibility
|
|
36
|
+
*/
|
|
37
|
+
log: createDebug.Debugger;
|
|
38
|
+
/**
|
|
39
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
40
|
+
*/
|
|
41
|
+
warn: (...args: any[]) => void;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Enable debug for specific namespaces
|
|
45
|
+
* @param namespaces - Comma-separated list of namespaces to enable
|
|
46
|
+
*/
|
|
47
|
+
enable(namespaces: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Disable all debug output
|
|
50
|
+
*/
|
|
51
|
+
disable(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a namespace is enabled
|
|
54
|
+
* @param namespace - The namespace to check
|
|
55
|
+
* @returns Whether the namespace is enabled
|
|
56
|
+
*/
|
|
57
|
+
enabled(namespace: string): boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Global debug logger instance
|
|
61
|
+
*/
|
|
62
|
+
export declare const debugLogger: DebugLogger;
|
|
63
|
+
/**
|
|
64
|
+
* Convenience function to create a debug logger for a specific category
|
|
65
|
+
* @param category - Main category (e.g., 'kernel', 'plugin', 'upload')
|
|
66
|
+
* @param subcategory - Optional subcategory
|
|
67
|
+
* @returns Logger object with debug methods
|
|
68
|
+
*/
|
|
69
|
+
export declare function createDebugLogger(category: string, subcategory?: string): {
|
|
70
|
+
/**
|
|
71
|
+
* General debug logging
|
|
72
|
+
*/
|
|
73
|
+
debug: createDebug.Debugger;
|
|
74
|
+
/**
|
|
75
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
76
|
+
*/
|
|
77
|
+
error: (...args: any[]) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Info level logging
|
|
80
|
+
*/
|
|
81
|
+
info: createDebug.Debugger;
|
|
82
|
+
/**
|
|
83
|
+
* Log function - alias for debug for compatibility
|
|
84
|
+
*/
|
|
85
|
+
log: createDebug.Debugger;
|
|
86
|
+
/**
|
|
87
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
88
|
+
*/
|
|
89
|
+
warn: (...args: any[]) => void;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Pre-configured debug loggers for common categories
|
|
93
|
+
*/
|
|
94
|
+
export declare const debugLoggers: {
|
|
95
|
+
demo: {
|
|
96
|
+
/**
|
|
97
|
+
* General debug logging
|
|
98
|
+
*/
|
|
99
|
+
debug: createDebug.Debugger;
|
|
100
|
+
/**
|
|
101
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
102
|
+
*/
|
|
103
|
+
error: (...args: any[]) => void;
|
|
104
|
+
/**
|
|
105
|
+
* Info level logging
|
|
106
|
+
*/
|
|
107
|
+
info: createDebug.Debugger;
|
|
108
|
+
/**
|
|
109
|
+
* Log function - alias for debug for compatibility
|
|
110
|
+
*/
|
|
111
|
+
log: createDebug.Debugger;
|
|
112
|
+
/**
|
|
113
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
114
|
+
*/
|
|
115
|
+
warn: (...args: any[]) => void;
|
|
116
|
+
};
|
|
117
|
+
file: {
|
|
118
|
+
/**
|
|
119
|
+
* General debug logging
|
|
120
|
+
*/
|
|
121
|
+
debug: createDebug.Debugger;
|
|
122
|
+
/**
|
|
123
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
124
|
+
*/
|
|
125
|
+
error: (...args: any[]) => void;
|
|
126
|
+
/**
|
|
127
|
+
* Info level logging
|
|
128
|
+
*/
|
|
129
|
+
info: createDebug.Debugger;
|
|
130
|
+
/**
|
|
131
|
+
* Log function - alias for debug for compatibility
|
|
132
|
+
*/
|
|
133
|
+
log: createDebug.Debugger;
|
|
134
|
+
/**
|
|
135
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
136
|
+
*/
|
|
137
|
+
warn: (...args: any[]) => void;
|
|
138
|
+
};
|
|
139
|
+
image: {
|
|
140
|
+
/**
|
|
141
|
+
* General debug logging
|
|
142
|
+
*/
|
|
143
|
+
debug: createDebug.Debugger;
|
|
144
|
+
/**
|
|
145
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
146
|
+
*/
|
|
147
|
+
error: (...args: any[]) => void;
|
|
148
|
+
/**
|
|
149
|
+
* Info level logging
|
|
150
|
+
*/
|
|
151
|
+
info: createDebug.Debugger;
|
|
152
|
+
/**
|
|
153
|
+
* Log function - alias for debug for compatibility
|
|
154
|
+
*/
|
|
155
|
+
log: createDebug.Debugger;
|
|
156
|
+
/**
|
|
157
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
158
|
+
*/
|
|
159
|
+
warn: (...args: any[]) => void;
|
|
160
|
+
};
|
|
161
|
+
kernel: {
|
|
162
|
+
/**
|
|
163
|
+
* General debug logging
|
|
164
|
+
*/
|
|
165
|
+
debug: createDebug.Debugger;
|
|
166
|
+
/**
|
|
167
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
168
|
+
*/
|
|
169
|
+
error: (...args: any[]) => void;
|
|
170
|
+
/**
|
|
171
|
+
* Info level logging
|
|
172
|
+
*/
|
|
173
|
+
info: createDebug.Debugger;
|
|
174
|
+
/**
|
|
175
|
+
* Log function - alias for debug for compatibility
|
|
176
|
+
*/
|
|
177
|
+
log: createDebug.Debugger;
|
|
178
|
+
/**
|
|
179
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
180
|
+
*/
|
|
181
|
+
warn: (...args: any[]) => void;
|
|
182
|
+
};
|
|
183
|
+
markdown: {
|
|
184
|
+
/**
|
|
185
|
+
* General debug logging
|
|
186
|
+
*/
|
|
187
|
+
debug: createDebug.Debugger;
|
|
188
|
+
/**
|
|
189
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
190
|
+
*/
|
|
191
|
+
error: (...args: any[]) => void;
|
|
192
|
+
/**
|
|
193
|
+
* Info level logging
|
|
194
|
+
*/
|
|
195
|
+
info: createDebug.Debugger;
|
|
196
|
+
/**
|
|
197
|
+
* Log function - alias for debug for compatibility
|
|
198
|
+
*/
|
|
199
|
+
log: createDebug.Debugger;
|
|
200
|
+
/**
|
|
201
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
202
|
+
*/
|
|
203
|
+
warn: (...args: any[]) => void;
|
|
204
|
+
};
|
|
205
|
+
math: {
|
|
206
|
+
/**
|
|
207
|
+
* General debug logging
|
|
208
|
+
*/
|
|
209
|
+
debug: createDebug.Debugger;
|
|
210
|
+
/**
|
|
211
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
212
|
+
*/
|
|
213
|
+
error: (...args: any[]) => void;
|
|
214
|
+
/**
|
|
215
|
+
* Info level logging
|
|
216
|
+
*/
|
|
217
|
+
info: createDebug.Debugger;
|
|
218
|
+
/**
|
|
219
|
+
* Log function - alias for debug for compatibility
|
|
220
|
+
*/
|
|
221
|
+
log: createDebug.Debugger;
|
|
222
|
+
/**
|
|
223
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
224
|
+
*/
|
|
225
|
+
warn: (...args: any[]) => void;
|
|
226
|
+
};
|
|
227
|
+
mention: {
|
|
228
|
+
/**
|
|
229
|
+
* General debug logging
|
|
230
|
+
*/
|
|
231
|
+
debug: createDebug.Debugger;
|
|
232
|
+
/**
|
|
233
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
234
|
+
*/
|
|
235
|
+
error: (...args: any[]) => void;
|
|
236
|
+
/**
|
|
237
|
+
* Info level logging
|
|
238
|
+
*/
|
|
239
|
+
info: createDebug.Debugger;
|
|
240
|
+
/**
|
|
241
|
+
* Log function - alias for debug for compatibility
|
|
242
|
+
*/
|
|
243
|
+
log: createDebug.Debugger;
|
|
244
|
+
/**
|
|
245
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
246
|
+
*/
|
|
247
|
+
warn: (...args: any[]) => void;
|
|
248
|
+
};
|
|
249
|
+
plugin: {
|
|
250
|
+
/**
|
|
251
|
+
* General debug logging
|
|
252
|
+
*/
|
|
253
|
+
debug: createDebug.Debugger;
|
|
254
|
+
/**
|
|
255
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
256
|
+
*/
|
|
257
|
+
error: (...args: any[]) => void;
|
|
258
|
+
/**
|
|
259
|
+
* Info level logging
|
|
260
|
+
*/
|
|
261
|
+
info: createDebug.Debugger;
|
|
262
|
+
/**
|
|
263
|
+
* Log function - alias for debug for compatibility
|
|
264
|
+
*/
|
|
265
|
+
log: createDebug.Debugger;
|
|
266
|
+
/**
|
|
267
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
268
|
+
*/
|
|
269
|
+
warn: (...args: any[]) => void;
|
|
270
|
+
};
|
|
271
|
+
react: {
|
|
272
|
+
/**
|
|
273
|
+
* General debug logging
|
|
274
|
+
*/
|
|
275
|
+
debug: createDebug.Debugger;
|
|
276
|
+
/**
|
|
277
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
278
|
+
*/
|
|
279
|
+
error: (...args: any[]) => void;
|
|
280
|
+
/**
|
|
281
|
+
* Info level logging
|
|
282
|
+
*/
|
|
283
|
+
info: createDebug.Debugger;
|
|
284
|
+
/**
|
|
285
|
+
* Log function - alias for debug for compatibility
|
|
286
|
+
*/
|
|
287
|
+
log: createDebug.Debugger;
|
|
288
|
+
/**
|
|
289
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
290
|
+
*/
|
|
291
|
+
warn: (...args: any[]) => void;
|
|
292
|
+
};
|
|
293
|
+
service: {
|
|
294
|
+
/**
|
|
295
|
+
* General debug logging
|
|
296
|
+
*/
|
|
297
|
+
debug: createDebug.Debugger;
|
|
298
|
+
/**
|
|
299
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
300
|
+
*/
|
|
301
|
+
error: (...args: any[]) => void;
|
|
302
|
+
/**
|
|
303
|
+
* Info level logging
|
|
304
|
+
*/
|
|
305
|
+
info: createDebug.Debugger;
|
|
306
|
+
/**
|
|
307
|
+
* Log function - alias for debug for compatibility
|
|
308
|
+
*/
|
|
309
|
+
log: createDebug.Debugger;
|
|
310
|
+
/**
|
|
311
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
312
|
+
*/
|
|
313
|
+
warn: (...args: any[]) => void;
|
|
314
|
+
};
|
|
315
|
+
slash: {
|
|
316
|
+
/**
|
|
317
|
+
* General debug logging
|
|
318
|
+
*/
|
|
319
|
+
debug: createDebug.Debugger;
|
|
320
|
+
/**
|
|
321
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
322
|
+
*/
|
|
323
|
+
error: (...args: any[]) => void;
|
|
324
|
+
/**
|
|
325
|
+
* Info level logging
|
|
326
|
+
*/
|
|
327
|
+
info: createDebug.Debugger;
|
|
328
|
+
/**
|
|
329
|
+
* Log function - alias for debug for compatibility
|
|
330
|
+
*/
|
|
331
|
+
log: createDebug.Debugger;
|
|
332
|
+
/**
|
|
333
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
334
|
+
*/
|
|
335
|
+
warn: (...args: any[]) => void;
|
|
336
|
+
};
|
|
337
|
+
upload: {
|
|
338
|
+
/**
|
|
339
|
+
* General debug logging
|
|
340
|
+
*/
|
|
341
|
+
debug: createDebug.Debugger;
|
|
342
|
+
/**
|
|
343
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
344
|
+
*/
|
|
345
|
+
error: (...args: any[]) => void;
|
|
346
|
+
/**
|
|
347
|
+
* Info level logging
|
|
348
|
+
*/
|
|
349
|
+
info: createDebug.Debugger;
|
|
350
|
+
/**
|
|
351
|
+
* Log function - alias for debug for compatibility
|
|
352
|
+
*/
|
|
353
|
+
log: createDebug.Debugger;
|
|
354
|
+
/**
|
|
355
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
356
|
+
*/
|
|
357
|
+
warn: (...args: any[]) => void;
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* Development mode utilities
|
|
362
|
+
*/
|
|
363
|
+
export declare const isDev: boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Conditional console logging - only logs in development mode
|
|
366
|
+
* Use this for demo files and development-only logging
|
|
367
|
+
*/
|
|
368
|
+
export declare const devConsole: {
|
|
369
|
+
error: (...args: any[]) => void;
|
|
370
|
+
info: (...args: any[]) => void;
|
|
371
|
+
log: (...args: any[]) => void;
|
|
372
|
+
warn: (...args: any[]) => void;
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* Production-safe error logging
|
|
376
|
+
* Always logs errors and warnings regardless of environment using native console methods
|
|
377
|
+
* for proper browser dev tool support. Debug/info uses debug package.
|
|
378
|
+
*/
|
|
379
|
+
export declare const prodSafeLogger: {
|
|
380
|
+
/**
|
|
381
|
+
* Debug info - only shown when debug is enabled
|
|
382
|
+
*/
|
|
383
|
+
debug: createDebug.Debugger;
|
|
384
|
+
/**
|
|
385
|
+
* Log critical errors that should always be visible (uses console.error)
|
|
386
|
+
*/
|
|
387
|
+
error: (...args: any[]) => void;
|
|
388
|
+
/**
|
|
389
|
+
* Info logging - only shown when debug is enabled
|
|
390
|
+
*/
|
|
391
|
+
info: createDebug.Debugger;
|
|
392
|
+
/**
|
|
393
|
+
* Log warnings that should always be visible (uses console.warn)
|
|
394
|
+
*/
|
|
395
|
+
warn: (...args: any[]) => void;
|
|
396
|
+
};
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
// @ts-ignore - debug package types
|
|
9
|
+
import createDebug from 'debug';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Base namespace for all LobeHub Editor debug messages
|
|
13
|
+
*/
|
|
14
|
+
var BASE_NAMESPACE = 'lobe-editor';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Debug utility factory for LobeHub Editor
|
|
18
|
+
* Creates namespaced debug functions following the pattern: lobe-editor:category
|
|
19
|
+
*/
|
|
20
|
+
export var DebugLogger = /*#__PURE__*/function () {
|
|
21
|
+
function DebugLogger() {
|
|
22
|
+
_classCallCheck(this, DebugLogger);
|
|
23
|
+
_defineProperty(this, "debuggers", new Map());
|
|
24
|
+
}
|
|
25
|
+
_createClass(DebugLogger, [{
|
|
26
|
+
key: "getDebugger",
|
|
27
|
+
value:
|
|
28
|
+
/**
|
|
29
|
+
* Get or create a debug function for a specific namespace
|
|
30
|
+
* @param category - The debug category (e.g., 'kernel', 'plugin', 'upload')
|
|
31
|
+
* @param subcategory - Optional subcategory for more specific debugging
|
|
32
|
+
* @returns Debug function
|
|
33
|
+
*/
|
|
34
|
+
function getDebugger(category, subcategory) {
|
|
35
|
+
var namespace = subcategory ? "".concat(BASE_NAMESPACE, ":").concat(category, ":").concat(subcategory) : "".concat(BASE_NAMESPACE, ":").concat(category);
|
|
36
|
+
if (!this.debuggers.has(namespace)) {
|
|
37
|
+
this.debuggers.set(namespace, createDebug(namespace));
|
|
38
|
+
}
|
|
39
|
+
return this.debuggers.get(namespace);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create a scoped debug logger for a specific component/service
|
|
44
|
+
* @param category - Main category
|
|
45
|
+
* @param subcategory - Optional subcategory
|
|
46
|
+
* @returns Object with debug methods
|
|
47
|
+
*/
|
|
48
|
+
}, {
|
|
49
|
+
key: "createLogger",
|
|
50
|
+
value: function createLogger(category, subcategory) {
|
|
51
|
+
var debug = this.getDebugger(category, subcategory);
|
|
52
|
+
var warnDebugger = this.getDebugger(category, subcategory ? "".concat(subcategory, ":warn") : 'warn');
|
|
53
|
+
var errorDebugger = this.getDebugger(category, subcategory ? "".concat(subcategory, ":error") : 'error');
|
|
54
|
+
var info = this.getDebugger(category, subcategory ? "".concat(subcategory, ":info") : 'info');
|
|
55
|
+
|
|
56
|
+
// Create wrapper functions that use native console methods for proper browser dev tool support
|
|
57
|
+
var warn = function warn() {
|
|
58
|
+
if (warnDebugger.enabled) {
|
|
59
|
+
var _console;
|
|
60
|
+
var prefix = warnDebugger.namespace;
|
|
61
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
62
|
+
args[_key] = arguments[_key];
|
|
63
|
+
}
|
|
64
|
+
(_console = console).warn.apply(_console, ["".concat(prefix)].concat(args));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var error = function error() {
|
|
68
|
+
if (errorDebugger.enabled) {
|
|
69
|
+
var _console2;
|
|
70
|
+
var prefix = errorDebugger.namespace;
|
|
71
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
72
|
+
args[_key2] = arguments[_key2];
|
|
73
|
+
}
|
|
74
|
+
(_console2 = console).error.apply(_console2, ["".concat(prefix)].concat(args));
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
/**
|
|
79
|
+
* General debug logging
|
|
80
|
+
*/
|
|
81
|
+
debug: debug,
|
|
82
|
+
/**
|
|
83
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
84
|
+
*/
|
|
85
|
+
error: error,
|
|
86
|
+
/**
|
|
87
|
+
* Info level logging
|
|
88
|
+
*/
|
|
89
|
+
info: info,
|
|
90
|
+
/**
|
|
91
|
+
* Log function - alias for debug for compatibility
|
|
92
|
+
*/
|
|
93
|
+
log: debug,
|
|
94
|
+
/**
|
|
95
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
96
|
+
*/
|
|
97
|
+
warn: warn
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Enable debug for specific namespaces
|
|
103
|
+
* @param namespaces - Comma-separated list of namespaces to enable
|
|
104
|
+
*/
|
|
105
|
+
}, {
|
|
106
|
+
key: "enable",
|
|
107
|
+
value: function enable(namespaces) {
|
|
108
|
+
createDebug.enable(namespaces);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Disable all debug output
|
|
113
|
+
*/
|
|
114
|
+
}, {
|
|
115
|
+
key: "disable",
|
|
116
|
+
value: function disable() {
|
|
117
|
+
createDebug.disable();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Check if a namespace is enabled
|
|
122
|
+
* @param namespace - The namespace to check
|
|
123
|
+
* @returns Whether the namespace is enabled
|
|
124
|
+
*/
|
|
125
|
+
}, {
|
|
126
|
+
key: "enabled",
|
|
127
|
+
value: function enabled(namespace) {
|
|
128
|
+
return createDebug.enabled(namespace);
|
|
129
|
+
}
|
|
130
|
+
}]);
|
|
131
|
+
return DebugLogger;
|
|
132
|
+
}();
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Global debug logger instance
|
|
136
|
+
*/
|
|
137
|
+
export var debugLogger = new DebugLogger();
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Convenience function to create a debug logger for a specific category
|
|
141
|
+
* @param category - Main category (e.g., 'kernel', 'plugin', 'upload')
|
|
142
|
+
* @param subcategory - Optional subcategory
|
|
143
|
+
* @returns Logger object with debug methods
|
|
144
|
+
*/
|
|
145
|
+
export function createDebugLogger(category, subcategory) {
|
|
146
|
+
return debugLogger.createLogger(category, subcategory);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Pre-configured debug loggers for common categories
|
|
151
|
+
*/
|
|
152
|
+
export var debugLoggers = {
|
|
153
|
+
demo: createDebugLogger('demo'),
|
|
154
|
+
file: createDebugLogger('file'),
|
|
155
|
+
image: createDebugLogger('image'),
|
|
156
|
+
kernel: createDebugLogger('kernel'),
|
|
157
|
+
markdown: createDebugLogger('markdown'),
|
|
158
|
+
math: createDebugLogger('math'),
|
|
159
|
+
mention: createDebugLogger('mention'),
|
|
160
|
+
plugin: createDebugLogger('plugin'),
|
|
161
|
+
react: createDebugLogger('react'),
|
|
162
|
+
service: createDebugLogger('service'),
|
|
163
|
+
slash: createDebugLogger('slash'),
|
|
164
|
+
upload: createDebugLogger('upload')
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Development mode utilities
|
|
169
|
+
*/
|
|
170
|
+
export var isDev = process.env.NODE_ENV === 'development';
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Conditional console logging - only logs in development mode
|
|
174
|
+
* Use this for demo files and development-only logging
|
|
175
|
+
*/
|
|
176
|
+
export var devConsole = {
|
|
177
|
+
error: function error() {
|
|
178
|
+
if (isDev) {
|
|
179
|
+
var _console3;
|
|
180
|
+
(_console3 = console).error.apply(_console3, arguments);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
info: function info() {
|
|
184
|
+
if (isDev) {
|
|
185
|
+
var _console4;
|
|
186
|
+
(_console4 = console).info.apply(_console4, arguments);
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
log: function log() {
|
|
190
|
+
if (isDev) {
|
|
191
|
+
var _console5;
|
|
192
|
+
(_console5 = console).log.apply(_console5, arguments);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
warn: function warn() {
|
|
196
|
+
if (isDev) {
|
|
197
|
+
var _console6;
|
|
198
|
+
(_console6 = console).warn.apply(_console6, arguments);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Production-safe error logging
|
|
205
|
+
* Always logs errors and warnings regardless of environment using native console methods
|
|
206
|
+
* for proper browser dev tool support. Debug/info uses debug package.
|
|
207
|
+
*/
|
|
208
|
+
export var prodSafeLogger = {
|
|
209
|
+
/**
|
|
210
|
+
* Debug info - only shown when debug is enabled
|
|
211
|
+
*/
|
|
212
|
+
debug: debugLoggers.kernel.debug,
|
|
213
|
+
/**
|
|
214
|
+
* Log critical errors that should always be visible (uses console.error)
|
|
215
|
+
*/
|
|
216
|
+
error: function error() {
|
|
217
|
+
var _console7;
|
|
218
|
+
(_console7 = console).error.apply(_console7, arguments);
|
|
219
|
+
},
|
|
220
|
+
/**
|
|
221
|
+
* Info logging - only shown when debug is enabled
|
|
222
|
+
*/
|
|
223
|
+
info: debugLoggers.kernel.info,
|
|
224
|
+
/**
|
|
225
|
+
* Log warnings that should always be visible (uses console.warn)
|
|
226
|
+
*/
|
|
227
|
+
warn: function warn() {
|
|
228
|
+
var _console8;
|
|
229
|
+
(_console8 = console).warn.apply(_console8, arguments);
|
|
230
|
+
}
|
|
231
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/editor",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
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",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@shikijs/engine-javascript": "^3.9.2",
|
|
44
44
|
"ahooks": "^3.9.3",
|
|
45
45
|
"antd-style": "^3.7.1",
|
|
46
|
+
"debug": "^4.4.1",
|
|
46
47
|
"eventemitter3": "^5.0.1",
|
|
47
48
|
"framer-motion": "^12.23.12",
|
|
48
49
|
"fuse.js": "^7.1.0",
|