@lobehub/editor 4.14.0 → 4.15.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/es/{ReactSlashPlugin-DDlIT9Qd.js → ReactSlashPlugin-BiVy_Iwf.js} +7 -6
- package/es/codemirror-3POv7f__.js +923 -0
- package/es/codemirror.d.ts +264 -0
- package/es/codemirror.js +2 -0
- package/es/debug-CIvbNHJu.js +270 -0
- package/es/headless.d.ts +20 -2
- package/es/headless.js +49 -2
- package/es/{index-DJq7pYS0.d.ts → index-DHGp94p0.d.ts} +3 -4
- package/es/index.d.ts +22 -22
- package/es/index.js +149 -1064
- package/es/react.d.ts +3 -3
- package/es/react.js +8 -8
- package/es/renderer.d.ts +2 -2
- package/es/renderer.js +6 -6
- package/es/{style-DjwW7ClE.js → style-DADgHVA1.js} +3 -272
- package/es/{style-DejqW6OX.js → style-DMdPzCo-.js} +2 -2
- package/package.json +5 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/codemirror/types.d.ts
|
|
4
|
+
interface CodeMirrorMode {
|
|
5
|
+
ext?: string[];
|
|
6
|
+
name: string;
|
|
7
|
+
syntax: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}
|
|
10
|
+
interface CodeMirrorLabels {
|
|
11
|
+
copy?: string;
|
|
12
|
+
selectLanguage?: string;
|
|
13
|
+
showLineNumbers?: string;
|
|
14
|
+
tabSize?: string;
|
|
15
|
+
useTabs?: string;
|
|
16
|
+
}
|
|
17
|
+
interface CopyButtonProps {
|
|
18
|
+
className?: string;
|
|
19
|
+
labels?: Pick<CodeMirrorLabels, 'copy'>;
|
|
20
|
+
onCopy: () => void;
|
|
21
|
+
}
|
|
22
|
+
interface LanguageSelectProps {
|
|
23
|
+
className?: string;
|
|
24
|
+
labels?: Pick<CodeMirrorLabels, 'selectLanguage'>;
|
|
25
|
+
onLanguageChange: (value: string) => void;
|
|
26
|
+
options?: CodeMirrorMode[];
|
|
27
|
+
selectedLang: string;
|
|
28
|
+
}
|
|
29
|
+
interface MoreOptionsProps {
|
|
30
|
+
labels?: Pick<CodeMirrorLabels, 'showLineNumbers' | 'tabSize' | 'useTabs'>;
|
|
31
|
+
onShowLineNumbersChange: (checked: boolean) => void;
|
|
32
|
+
onTabSizeChange: (value: number | null) => void;
|
|
33
|
+
onUseTabsChange: (checked: boolean) => void;
|
|
34
|
+
showLineNumbers: boolean;
|
|
35
|
+
tabSize: number;
|
|
36
|
+
useTabs: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface ToolbarProps {
|
|
39
|
+
expand?: boolean;
|
|
40
|
+
labels?: CodeMirrorLabels;
|
|
41
|
+
languageOptions?: CodeMirrorMode[];
|
|
42
|
+
onClick?: () => void;
|
|
43
|
+
onCopy: () => void;
|
|
44
|
+
onLanguageChange: (value: string) => void;
|
|
45
|
+
onShowLineNumbersChange: (checked: boolean) => void;
|
|
46
|
+
onTabSizeChange: (value: number | null) => void;
|
|
47
|
+
onUseTabsChange: (checked: boolean) => void;
|
|
48
|
+
selectedLang: string;
|
|
49
|
+
showLineNumbers: boolean;
|
|
50
|
+
tabSize: number;
|
|
51
|
+
toggleExpand?: () => void;
|
|
52
|
+
useTabs: boolean;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/codemirror/components/CopyButton.d.ts
|
|
56
|
+
declare const CopyButton: FC<CopyButtonProps>;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/codemirror/components/LanguageSelect.d.ts
|
|
59
|
+
declare const LanguageSelect: FC<LanguageSelectProps>;
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/codemirror/components/MoreOptions.d.ts
|
|
62
|
+
declare const MoreOptions: FC<MoreOptionsProps>;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/codemirror/components/Toolbar.d.ts
|
|
65
|
+
declare const Toolbar: FC<ToolbarProps>;
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/codemirror/constants.d.ts
|
|
68
|
+
declare const LANGUAGES: CodeMirrorMode[];
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/codemirror/loader.d.ts
|
|
71
|
+
interface CodeMirrorOptions {
|
|
72
|
+
className?: string;
|
|
73
|
+
foldGutter?: boolean;
|
|
74
|
+
history?: any;
|
|
75
|
+
indentWithTabs?: boolean;
|
|
76
|
+
lineNumbers?: boolean;
|
|
77
|
+
lineWrapping?: boolean;
|
|
78
|
+
mode?: string;
|
|
79
|
+
preventCopy?: boolean;
|
|
80
|
+
readOnly?: boolean;
|
|
81
|
+
tabSize?: number;
|
|
82
|
+
theme?: 'default';
|
|
83
|
+
value?: string;
|
|
84
|
+
}
|
|
85
|
+
interface ICodeMirrorInstance {
|
|
86
|
+
blur(): void;
|
|
87
|
+
clearHistory(): void;
|
|
88
|
+
destroy(): void;
|
|
89
|
+
focus(): void;
|
|
90
|
+
foldGutter?: boolean;
|
|
91
|
+
foldLines(): number[];
|
|
92
|
+
foldLines(lines: number[]): void;
|
|
93
|
+
formatAll(): void;
|
|
94
|
+
getHistory(): any;
|
|
95
|
+
getLine(line: number): string;
|
|
96
|
+
getSelection(): string;
|
|
97
|
+
getValue: () => string;
|
|
98
|
+
historyRedoDepth(): number;
|
|
99
|
+
historyUndoDepth(): number;
|
|
100
|
+
lineCount(): number;
|
|
101
|
+
on(event: 'change' | 'blur' | 'focus' | 'keyup' | 'fold' | 'unfold' | 'keydown' | 'rightOut' | 'leftOut', handler: (...args: any[]) => void): void;
|
|
102
|
+
optionHelper: {
|
|
103
|
+
theme: {
|
|
104
|
+
reconfigure: (theme: any) => void;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
redoSelection(): void;
|
|
108
|
+
replaceSelection(text: string): void;
|
|
109
|
+
setOption(option: keyof CodeMirrorOptions, value: any): void;
|
|
110
|
+
setSelection(anchor: number, header: number): void;
|
|
111
|
+
setSelectionToEnd(): void;
|
|
112
|
+
setSelectionToStart(): void;
|
|
113
|
+
setValue(value: string): void;
|
|
114
|
+
undoSelection(): void;
|
|
115
|
+
view: {
|
|
116
|
+
constructor: {
|
|
117
|
+
theme: (options: any, settings: any) => any;
|
|
118
|
+
};
|
|
119
|
+
dispatch: (params: {
|
|
120
|
+
effects: any;
|
|
121
|
+
}) => void;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
interface ICodeMirror {
|
|
125
|
+
fromTextArea: (textarea: HTMLTextAreaElement, options?: CodeMirrorOptions) => ICodeMirrorInstance;
|
|
126
|
+
new (dom: HTMLElement, options?: CodeMirrorOptions): ICodeMirrorInstance;
|
|
127
|
+
}
|
|
128
|
+
declare function loadCodeMirror(cdnUrl?: string): Promise<ICodeMirror>;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/codemirror/style.d.ts
|
|
131
|
+
declare const styles: string;
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/codemirror/theme.d.ts
|
|
134
|
+
declare const lobeTheme: {
|
|
135
|
+
'&': {
|
|
136
|
+
'& .cm-cursor': {
|
|
137
|
+
'border-left-color': string;
|
|
138
|
+
};
|
|
139
|
+
'& .cm-cursor.cm-cursor-primary': {
|
|
140
|
+
'border-inline-start': string;
|
|
141
|
+
};
|
|
142
|
+
'& .cm-gutters': {
|
|
143
|
+
'background-color': string;
|
|
144
|
+
border: string;
|
|
145
|
+
color: string;
|
|
146
|
+
cursor: string;
|
|
147
|
+
};
|
|
148
|
+
'& .cm-line': {
|
|
149
|
+
'& .cm-atom': {
|
|
150
|
+
color: string;
|
|
151
|
+
};
|
|
152
|
+
'& .cm-attribute': {
|
|
153
|
+
color: string;
|
|
154
|
+
};
|
|
155
|
+
'& .cm-builtin': {
|
|
156
|
+
color: string;
|
|
157
|
+
fontStyle: string;
|
|
158
|
+
};
|
|
159
|
+
'& .cm-comment': {
|
|
160
|
+
color: string;
|
|
161
|
+
fontStyle: string;
|
|
162
|
+
};
|
|
163
|
+
'& .cm-foldPlaceholder': {
|
|
164
|
+
background: string;
|
|
165
|
+
border: string;
|
|
166
|
+
color: string;
|
|
167
|
+
display: string;
|
|
168
|
+
height: string;
|
|
169
|
+
padding: number;
|
|
170
|
+
'vertical-align': string;
|
|
171
|
+
width: string;
|
|
172
|
+
};
|
|
173
|
+
'& .cm-function': {
|
|
174
|
+
color: string;
|
|
175
|
+
};
|
|
176
|
+
'& .cm-header': {
|
|
177
|
+
color: string;
|
|
178
|
+
};
|
|
179
|
+
'& .cm-keyword': {
|
|
180
|
+
color: string;
|
|
181
|
+
};
|
|
182
|
+
'& .cm-meta': {
|
|
183
|
+
color: string;
|
|
184
|
+
};
|
|
185
|
+
'& .cm-modifier': {
|
|
186
|
+
color: string;
|
|
187
|
+
};
|
|
188
|
+
'& .cm-number': {
|
|
189
|
+
color: string;
|
|
190
|
+
};
|
|
191
|
+
'& .cm-operator': {
|
|
192
|
+
color: string;
|
|
193
|
+
};
|
|
194
|
+
'& .cm-property': {
|
|
195
|
+
color: string;
|
|
196
|
+
};
|
|
197
|
+
'& .cm-punctuation': {
|
|
198
|
+
color: string;
|
|
199
|
+
};
|
|
200
|
+
'& .cm-qualifier': {
|
|
201
|
+
color: string;
|
|
202
|
+
};
|
|
203
|
+
'& .cm-string': {
|
|
204
|
+
color: string;
|
|
205
|
+
};
|
|
206
|
+
'& .cm-string-2': {
|
|
207
|
+
color: string;
|
|
208
|
+
};
|
|
209
|
+
'& .cm-tag': {
|
|
210
|
+
color: string;
|
|
211
|
+
};
|
|
212
|
+
'& .cm-tag.cm-bracket': {
|
|
213
|
+
color: string;
|
|
214
|
+
};
|
|
215
|
+
'& .cm-type': {
|
|
216
|
+
color: string;
|
|
217
|
+
};
|
|
218
|
+
'& .cm-variable': {
|
|
219
|
+
color: string;
|
|
220
|
+
};
|
|
221
|
+
'& .cm-variable-2': {
|
|
222
|
+
color: string;
|
|
223
|
+
};
|
|
224
|
+
'& .cm-variable-3': {
|
|
225
|
+
color: string;
|
|
226
|
+
};
|
|
227
|
+
'& .cm-variable.cm-callee': {
|
|
228
|
+
color: string;
|
|
229
|
+
};
|
|
230
|
+
'& .cm-variable.cm-def': {
|
|
231
|
+
color: string;
|
|
232
|
+
};
|
|
233
|
+
color: string;
|
|
234
|
+
'padding-inline': string;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
'& .cm-selectionBackground': {
|
|
238
|
+
background: string;
|
|
239
|
+
};
|
|
240
|
+
'& .cm-selectionMatch': {
|
|
241
|
+
background: string;
|
|
242
|
+
};
|
|
243
|
+
'&.cm-editor': {
|
|
244
|
+
background: string;
|
|
245
|
+
cursor: string;
|
|
246
|
+
'padding-block': string;
|
|
247
|
+
width: string;
|
|
248
|
+
};
|
|
249
|
+
'&.cm-editor span': {
|
|
250
|
+
'font-family': string;
|
|
251
|
+
'font-size': string;
|
|
252
|
+
};
|
|
253
|
+
'&.cm-editor.cm-focused .cm-selectionBackground': {
|
|
254
|
+
background: string;
|
|
255
|
+
};
|
|
256
|
+
'&.cm-editor.cm-focused .cm-selectionLineGutter': {
|
|
257
|
+
color: string;
|
|
258
|
+
};
|
|
259
|
+
'&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground': {
|
|
260
|
+
background: string;
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
//#endregion
|
|
264
|
+
export { type CodeMirrorLabels, type CodeMirrorMode, type CodeMirrorOptions, CopyButton, type CopyButtonProps, type ICodeMirror, type ICodeMirrorInstance, LANGUAGES, LanguageSelect, type LanguageSelectProps, MoreOptions, type MoreOptionsProps, Toolbar, type ToolbarProps, loadCodeMirror, lobeTheme, styles };
|
package/es/codemirror.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as MoreOptions, c as CopyButton, i as Toolbar, n as styles, o as LanguageSelect, r as loadCodeMirror, s as LANGUAGES, t as lobeTheme } from "./codemirror-3POv7f__.js";
|
|
2
|
+
export { CopyButton, LANGUAGES, LanguageSelect, MoreOptions, Toolbar, loadCodeMirror, lobeTheme, styles };
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import createDebug from "debug";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
10
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
11
|
+
var __exportAll = (all, no_symbols) => {
|
|
12
|
+
let target = {};
|
|
13
|
+
for (var name in all) __defProp(target, name, {
|
|
14
|
+
get: all[name],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
|
+
key = keys[i];
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
24
|
+
get: ((k) => from[k]).bind(null, key),
|
|
25
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
31
|
+
value: mod,
|
|
32
|
+
enumerable: true
|
|
33
|
+
}) : target, mod));
|
|
34
|
+
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/utils/debug.ts
|
|
37
|
+
var debug_exports = /* @__PURE__ */ __exportAll({
|
|
38
|
+
DebugLogger: () => DebugLogger,
|
|
39
|
+
browserDebug: () => browserDebug,
|
|
40
|
+
createDebugLogger: () => createDebugLogger,
|
|
41
|
+
debugLogger: () => debugLogger,
|
|
42
|
+
debugLoggers: () => debugLoggers,
|
|
43
|
+
devConsole: () => devConsole,
|
|
44
|
+
isDev: () => true,
|
|
45
|
+
prodSafeLogger: () => prodSafeLogger
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Convenience function to create a debug logger for a specific category
|
|
49
|
+
* @param category - Main category (e.g., 'kernel', 'plugin', 'upload')
|
|
50
|
+
* @param subcategory - Optional subcategory
|
|
51
|
+
* @returns Logger object with debug methods
|
|
52
|
+
*/
|
|
53
|
+
function createDebugLogger(category, subcategory) {
|
|
54
|
+
return debugLogger.createLogger(category, subcategory);
|
|
55
|
+
}
|
|
56
|
+
var BASE_NAMESPACE, DebugLogger, debugLogger, debugLoggers, devConsole, prodSafeLogger, browserDebug;
|
|
57
|
+
var init_debug = __esmMin((() => {
|
|
58
|
+
BASE_NAMESPACE = "lobe-editor";
|
|
59
|
+
DebugLogger = class {
|
|
60
|
+
constructor() {
|
|
61
|
+
this.debuggers = /* @__PURE__ */ new Map();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get or create a debug function for a specific namespace
|
|
65
|
+
* @param category - The debug category (e.g., 'kernel', 'plugin', 'upload')
|
|
66
|
+
* @param subcategory - Optional subcategory for more specific debugging
|
|
67
|
+
* @returns Debug function
|
|
68
|
+
*/
|
|
69
|
+
getDebugger(category, subcategory) {
|
|
70
|
+
const namespace = subcategory ? `${BASE_NAMESPACE}:${category}:${subcategory}` : `${BASE_NAMESPACE}:${category}`;
|
|
71
|
+
if (!this.debuggers.has(namespace)) this.debuggers.set(namespace, createDebug(namespace));
|
|
72
|
+
return this.debuggers.get(namespace);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Create a scoped debug logger for a specific component/service
|
|
76
|
+
* @param category - Main category
|
|
77
|
+
* @param subcategory - Optional subcategory
|
|
78
|
+
* @returns Object with debug methods
|
|
79
|
+
*/
|
|
80
|
+
createLogger(category, subcategory) {
|
|
81
|
+
const debug = this.getDebugger(category, subcategory);
|
|
82
|
+
const warnDebugger = this.getDebugger(category, subcategory ? `${subcategory}:warn` : "warn");
|
|
83
|
+
const errorDebugger = this.getDebugger(category, subcategory ? `${subcategory}:error` : "error");
|
|
84
|
+
const info = this.getDebugger(category, subcategory ? `${subcategory}:info` : "info");
|
|
85
|
+
const warn = (...args) => {
|
|
86
|
+
if (warnDebugger.enabled) {
|
|
87
|
+
const prefix = warnDebugger.namespace;
|
|
88
|
+
console.warn(`${prefix}`, ...args);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const error = (...args) => {
|
|
92
|
+
if (errorDebugger.enabled) {
|
|
93
|
+
const prefix = errorDebugger.namespace;
|
|
94
|
+
console.error(`${prefix}`, ...args);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
/**
|
|
99
|
+
* General debug logging
|
|
100
|
+
*/
|
|
101
|
+
debug,
|
|
102
|
+
/**
|
|
103
|
+
* Error level logging - uses console.error for proper browser dev tool support
|
|
104
|
+
*/
|
|
105
|
+
error,
|
|
106
|
+
/**
|
|
107
|
+
* Info level logging
|
|
108
|
+
*/
|
|
109
|
+
info,
|
|
110
|
+
/**
|
|
111
|
+
* Log function - alias for debug for compatibility
|
|
112
|
+
*/
|
|
113
|
+
log: debug,
|
|
114
|
+
/**
|
|
115
|
+
* Warning level logging - uses console.warn for proper browser dev tool support
|
|
116
|
+
*/
|
|
117
|
+
warn
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Enable debug for specific namespaces
|
|
122
|
+
* @param namespaces - Comma-separated list of namespaces to enable
|
|
123
|
+
*/
|
|
124
|
+
enable(namespaces) {
|
|
125
|
+
createDebug.enable(namespaces);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Disable all debug output
|
|
129
|
+
*/
|
|
130
|
+
disable() {
|
|
131
|
+
createDebug.disable();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Check if a namespace is enabled
|
|
135
|
+
* @param namespace - The namespace to check
|
|
136
|
+
* @returns Whether the namespace is enabled
|
|
137
|
+
*/
|
|
138
|
+
enabled(namespace) {
|
|
139
|
+
return createDebug.enabled(namespace);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
debugLogger = new DebugLogger();
|
|
143
|
+
debugLoggers = {
|
|
144
|
+
demo: createDebugLogger("demo"),
|
|
145
|
+
file: createDebugLogger("file"),
|
|
146
|
+
image: createDebugLogger("image"),
|
|
147
|
+
kernel: createDebugLogger("kernel"),
|
|
148
|
+
markdown: createDebugLogger("markdown"),
|
|
149
|
+
math: createDebugLogger("math"),
|
|
150
|
+
mention: createDebugLogger("mention"),
|
|
151
|
+
plugin: createDebugLogger("plugin"),
|
|
152
|
+
react: createDebugLogger("react"),
|
|
153
|
+
service: createDebugLogger("service"),
|
|
154
|
+
slash: createDebugLogger("slash"),
|
|
155
|
+
upload: createDebugLogger("upload")
|
|
156
|
+
};
|
|
157
|
+
devConsole = {
|
|
158
|
+
error: (...args) => {
|
|
159
|
+
console.error(...args);
|
|
160
|
+
},
|
|
161
|
+
info: (...args) => {
|
|
162
|
+
console.info(...args);
|
|
163
|
+
},
|
|
164
|
+
log: (...args) => {
|
|
165
|
+
console.log(...args);
|
|
166
|
+
},
|
|
167
|
+
warn: (...args) => {
|
|
168
|
+
console.warn(...args);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
prodSafeLogger = {
|
|
172
|
+
/**
|
|
173
|
+
* Debug info - only shown when debug is enabled
|
|
174
|
+
*/
|
|
175
|
+
debug: debugLoggers.kernel.debug,
|
|
176
|
+
/**
|
|
177
|
+
* Log critical errors that should always be visible (uses console.error)
|
|
178
|
+
*/
|
|
179
|
+
error: (...args) => {
|
|
180
|
+
console.error(...args);
|
|
181
|
+
},
|
|
182
|
+
/**
|
|
183
|
+
* Info logging - only shown when debug is enabled
|
|
184
|
+
*/
|
|
185
|
+
info: debugLoggers.kernel.info,
|
|
186
|
+
/**
|
|
187
|
+
* Log warnings that should always be visible (uses console.warn)
|
|
188
|
+
*/
|
|
189
|
+
warn: (...args) => {
|
|
190
|
+
console.warn(...args);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
browserDebug = {
|
|
194
|
+
/**
|
|
195
|
+
* Disable debug logging in browser environment
|
|
196
|
+
*/
|
|
197
|
+
disable: () => {
|
|
198
|
+
if (typeof window !== "undefined") {
|
|
199
|
+
localStorage.removeItem("debug");
|
|
200
|
+
createDebug.disable();
|
|
201
|
+
console.info("Debug disabled.");
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
/**
|
|
205
|
+
* Enable debug logging in browser environment
|
|
206
|
+
* @param namespaces - Debug namespaces to enable (e.g., 'lobe-editor:*')
|
|
207
|
+
*/
|
|
208
|
+
enable: (namespaces = "lobe-editor:*") => {
|
|
209
|
+
if (typeof window !== "undefined") {
|
|
210
|
+
localStorage.debug = namespaces;
|
|
211
|
+
createDebug.enable(namespaces);
|
|
212
|
+
console.info(`Debug enabled: ${namespaces}`);
|
|
213
|
+
console.info("Refresh the page to see debug logs from initialization.");
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
/**
|
|
217
|
+
* Get current debug configuration
|
|
218
|
+
*/
|
|
219
|
+
getConfig: () => {
|
|
220
|
+
if (typeof window !== "undefined") {
|
|
221
|
+
const envDebug = typeof process !== "undefined" ? process.env.DEBUG : void 0;
|
|
222
|
+
const currentDebug = localStorage.getItem("debug");
|
|
223
|
+
if (envDebug) return {
|
|
224
|
+
enabled: envDebug,
|
|
225
|
+
source: "environment variable (auto-applied)"
|
|
226
|
+
};
|
|
227
|
+
else if (currentDebug) return {
|
|
228
|
+
enabled: currentDebug,
|
|
229
|
+
source: "development mode (auto-applied)"
|
|
230
|
+
};
|
|
231
|
+
else return {
|
|
232
|
+
enabled: false,
|
|
233
|
+
source: "disabled"
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
enabled: (typeof process !== "undefined" ? process.env.DEBUG : void 0) || false,
|
|
238
|
+
source: "server-side"
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
/**
|
|
242
|
+
* Show available debug categories
|
|
243
|
+
*/
|
|
244
|
+
showCategories: () => {
|
|
245
|
+
console.group("Available debug categories:");
|
|
246
|
+
console.log("� lobe-editor:kernel - Core editor functionality");
|
|
247
|
+
console.log("🔌 lobe-editor:plugin:* - All plugins");
|
|
248
|
+
console.log("🔍 lobe-editor:service:* - All services");
|
|
249
|
+
console.log("💬 lobe-editor:*:info - Info level messages");
|
|
250
|
+
console.log("⚠️ lobe-editor:*:warn - Warning messages");
|
|
251
|
+
console.log("❌ lobe-editor:*:error - Error messages");
|
|
252
|
+
console.groupEnd();
|
|
253
|
+
console.info("Usage: browserDebug.enable(\"lobe-editor:kernel,lobe-editor:plugin:*\")");
|
|
254
|
+
},
|
|
255
|
+
/**
|
|
256
|
+
* Show current debug status and configuration
|
|
257
|
+
*/
|
|
258
|
+
showStatus: () => {
|
|
259
|
+
const config = browserDebug.getConfig();
|
|
260
|
+
console.group("� LobeHub Editor Debug Status");
|
|
261
|
+
console.log(`Status: ${config.enabled ? "✅ Enabled" : "❌ Disabled"}`);
|
|
262
|
+
console.log(`Configuration: ${config.enabled || "none"}`);
|
|
263
|
+
console.log(`Source: ${config.source}`);
|
|
264
|
+
console.groupEnd();
|
|
265
|
+
if (!config.enabled) console.info("💡 Zero-config setup: Set DEBUG=lobe-editor:* in your environment");
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}));
|
|
269
|
+
//#endregion
|
|
270
|
+
export { debug_exports as a, prodSafeLogger as c, __exportAll as d, __toCommonJS as f, debugLoggers as i, __commonJSMin as l, createDebugLogger as n, devConsole as o, __toESM as p, debugLogger as r, init_debug as s, browserDebug as t, __esmMin as u };
|
package/es/headless.d.ts
CHANGED
|
@@ -59,7 +59,6 @@ declare const _default: {
|
|
|
59
59
|
};
|
|
60
60
|
cancel: string;
|
|
61
61
|
codemirror: {
|
|
62
|
-
copyFailed: string;
|
|
63
62
|
copySuccess: string;
|
|
64
63
|
selectLanguage: string;
|
|
65
64
|
selectTheme: string;
|
|
@@ -489,6 +488,25 @@ declare const LITEXML_MODIFY_COMMAND: _$lexical.LexicalCommand<({
|
|
|
489
488
|
litexml: string | string[];
|
|
490
489
|
})[]>;
|
|
491
490
|
//#endregion
|
|
491
|
+
//#region src/headless/extract-media-from-editor-state.d.ts
|
|
492
|
+
interface ImageListItem {
|
|
493
|
+
alt: string;
|
|
494
|
+
id: string;
|
|
495
|
+
url: string;
|
|
496
|
+
}
|
|
497
|
+
interface FileListItem {
|
|
498
|
+
fileType: string;
|
|
499
|
+
id: string;
|
|
500
|
+
name: string;
|
|
501
|
+
size: number;
|
|
502
|
+
url: string;
|
|
503
|
+
}
|
|
504
|
+
interface MediaLists {
|
|
505
|
+
fileList: FileListItem[];
|
|
506
|
+
imageList: ImageListItem[];
|
|
507
|
+
}
|
|
508
|
+
declare const extractMediaFromEditorState: (state: SerializedEditorState | null | undefined) => MediaLists;
|
|
509
|
+
//#endregion
|
|
492
510
|
//#region src/headless/index.d.ts
|
|
493
511
|
type HeadlessDocumentType = 'json' | 'litexml' | 'markdown' | (string & object);
|
|
494
512
|
interface HeadlessEditorHydrationInput {
|
|
@@ -552,4 +570,4 @@ declare class HeadlessEditor {
|
|
|
552
570
|
}
|
|
553
571
|
declare function createHeadlessEditor(options?: HeadlessEditorOptions): HeadlessEditor;
|
|
554
572
|
//#endregion
|
|
555
|
-
export { DEFAULT_HEADLESS_EDITOR_PLUGINS, HeadlessDocumentType, HeadlessEditor, HeadlessEditorExport, HeadlessEditorExportOptions, HeadlessEditorHydrationInput, HeadlessEditorOptions, HeadlessLiteXMLBatchOperation, HeadlessLiteXMLInsertOperation, HeadlessLiteXMLOperation, HeadlessLiteXMLRemoveOperation, HeadlessLiteXMLReplaceOperation, createHeadlessEditor };
|
|
573
|
+
export { DEFAULT_HEADLESS_EDITOR_PLUGINS, type FileListItem, HeadlessDocumentType, HeadlessEditor, HeadlessEditorExport, HeadlessEditorExportOptions, HeadlessEditorHydrationInput, HeadlessEditorOptions, HeadlessLiteXMLBatchOperation, HeadlessLiteXMLInsertOperation, HeadlessLiteXMLOperation, HeadlessLiteXMLRemoveOperation, HeadlessLiteXMLReplaceOperation, type ImageListItem, type MediaLists, createHeadlessEditor, extractMediaFromEditorState };
|
package/es/headless.js
CHANGED
|
@@ -55,7 +55,6 @@ var locale_default = {
|
|
|
55
55
|
block: { delete: "Delete block" },
|
|
56
56
|
cancel: "Cancel",
|
|
57
57
|
codemirror: {
|
|
58
|
-
copyFailed: "Copy failed",
|
|
59
58
|
copySuccess: "Code copied to clipboard",
|
|
60
59
|
selectLanguage: "Select language",
|
|
61
60
|
selectTheme: "Select theme",
|
|
@@ -26841,6 +26840,54 @@ const HeadlessCodeblockPlugin = class extends KernelPlugin {
|
|
|
26841
26840
|
}
|
|
26842
26841
|
};
|
|
26843
26842
|
//#endregion
|
|
26843
|
+
//#region src/headless/extract-media-from-editor-state.ts
|
|
26844
|
+
const IMAGE_TYPES = new Set(["image", "block-image"]);
|
|
26845
|
+
const FILE_TYPE = "file";
|
|
26846
|
+
const generateId = () => {
|
|
26847
|
+
if (typeof globalThis.crypto?.randomUUID === "function") return globalThis.crypto.randomUUID();
|
|
26848
|
+
return `id-${Math.random().toString(36).slice(2)}-${Date.now().toString(36)}`;
|
|
26849
|
+
};
|
|
26850
|
+
const inferFileType = (name) => {
|
|
26851
|
+
const dotIndex = name.lastIndexOf(".");
|
|
26852
|
+
if (dotIndex < 0 || dotIndex === name.length - 1) return "unknown";
|
|
26853
|
+
return name.slice(dotIndex + 1).toLowerCase() || "unknown";
|
|
26854
|
+
};
|
|
26855
|
+
const extractMediaFromEditorState = (state) => {
|
|
26856
|
+
const imageList = [];
|
|
26857
|
+
const fileList = [];
|
|
26858
|
+
const visit = (node) => {
|
|
26859
|
+
const type = node.type;
|
|
26860
|
+
if (IMAGE_TYPES.has(type)) {
|
|
26861
|
+
if (node.status === "uploaded" && typeof node.src === "string" && node.src) imageList.push({
|
|
26862
|
+
alt: typeof node.altText === "string" ? node.altText : "",
|
|
26863
|
+
id: generateId(),
|
|
26864
|
+
url: node.src
|
|
26865
|
+
});
|
|
26866
|
+
return;
|
|
26867
|
+
}
|
|
26868
|
+
if (type === FILE_TYPE) {
|
|
26869
|
+
if (node.status === "uploaded" && typeof node.fileUrl === "string" && node.fileUrl) {
|
|
26870
|
+
const name = typeof node.name === "string" ? node.name : "unknown";
|
|
26871
|
+
fileList.push({
|
|
26872
|
+
fileType: inferFileType(name),
|
|
26873
|
+
id: generateId(),
|
|
26874
|
+
name,
|
|
26875
|
+
size: typeof node.size === "number" ? node.size : 0,
|
|
26876
|
+
url: node.fileUrl
|
|
26877
|
+
});
|
|
26878
|
+
}
|
|
26879
|
+
return;
|
|
26880
|
+
}
|
|
26881
|
+
if (Array.isArray(node.children)) for (const child of node.children) visit(child);
|
|
26882
|
+
};
|
|
26883
|
+
const root = state?.root;
|
|
26884
|
+
if (root && Array.isArray(root.children)) for (const child of root.children) visit(child);
|
|
26885
|
+
return {
|
|
26886
|
+
fileList,
|
|
26887
|
+
imageList
|
|
26888
|
+
};
|
|
26889
|
+
};
|
|
26890
|
+
//#endregion
|
|
26844
26891
|
//#region src/headless/index.ts
|
|
26845
26892
|
const getNumericId = (id) => {
|
|
26846
26893
|
if (typeof id !== "number" && typeof id !== "string") return null;
|
|
@@ -27016,4 +27063,4 @@ function createHeadlessEditor(options) {
|
|
|
27016
27063
|
return new HeadlessEditor(options);
|
|
27017
27064
|
}
|
|
27018
27065
|
//#endregion
|
|
27019
|
-
export { DEFAULT_HEADLESS_EDITOR_PLUGINS, HeadlessEditor, createHeadlessEditor };
|
|
27066
|
+
export { DEFAULT_HEADLESS_EDITOR_PLUGINS, HeadlessEditor, createHeadlessEditor, extractMediaFromEditorState };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { DropdownMenuItemType } from "@lobehub/ui";
|
|
2
|
+
import * as _$react from "react";
|
|
3
|
+
import { CSSProperties, CompositionEvent, FC, FocusEvent, MouseEvent, ReactElement, ReactNode } from "react";
|
|
1
4
|
import { HistoryState, HistoryStateEntry } from "@lexical/history";
|
|
2
5
|
import * as _$lexical from "lexical";
|
|
3
6
|
import { CommandListener, CommandListenerPriority, CommandPayloadType, DOMConversionMap, DOMExportOutput, DecoratorNode, EditorConfig, EditorState, ElementNode, LexicalCommand, LexicalEditor, LexicalNode, LexicalNodeConfig, LexicalUpdateJSON, RangeSelection, SerializedLexicalNode, Spread, TextNode } from "lexical";
|
|
4
7
|
import { HeadingTagType } from "@lexical/rich-text";
|
|
5
|
-
import * as _$react from "react";
|
|
6
|
-
import { CSSProperties, CompositionEvent, FC, FocusEvent, MouseEvent, ReactElement, ReactNode } from "react";
|
|
7
|
-
import { DropdownMenuItemType } from "@lobehub/ui";
|
|
8
8
|
import Fuse, { IFuseOptions } from "fuse.js";
|
|
9
9
|
|
|
10
10
|
//#region src/editor-kernel/data-source.d.ts
|
|
@@ -114,7 +114,6 @@ declare const _default: {
|
|
|
114
114
|
};
|
|
115
115
|
cancel: string;
|
|
116
116
|
codemirror: {
|
|
117
|
-
copyFailed: string;
|
|
118
117
|
copySuccess: string;
|
|
119
118
|
selectLanguage: string;
|
|
120
119
|
selectTheme: string;
|