@lobehub/editor 3.2.2 → 3.3.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.
Files changed (41) hide show
  1. package/es/editor-kernel/react/useLexicalNodeSelection.d.ts +1 -1
  2. package/es/editor-kernel/react/useLexicalNodeSelection.js +22 -1
  3. package/es/index.d.ts +1 -0
  4. package/es/index.js +1 -0
  5. package/es/locale/index.d.ts +10 -0
  6. package/es/locale/index.js +10 -0
  7. package/es/plugins/codemirror-block/command/index.d.ts +9 -0
  8. package/es/plugins/codemirror-block/command/index.js +46 -0
  9. package/es/plugins/codemirror-block/index.d.ts +2 -0
  10. package/es/plugins/codemirror-block/index.js +2 -0
  11. package/es/plugins/codemirror-block/lib/index.d.ts +58 -0
  12. package/es/plugins/codemirror-block/lib/index.js +40 -0
  13. package/es/plugins/codemirror-block/lib/mode.d.ts +25 -0
  14. package/es/plugins/codemirror-block/lib/mode.js +416 -0
  15. package/es/plugins/codemirror-block/node/CodeMirrorNode.d.ts +46 -0
  16. package/es/plugins/codemirror-block/node/CodeMirrorNode.js +343 -0
  17. package/es/plugins/codemirror-block/plugin/index.d.ts +8 -0
  18. package/es/plugins/codemirror-block/plugin/index.js +113 -0
  19. package/es/plugins/codemirror-block/react/CodemirrorNode.d.ts +10 -0
  20. package/es/plugins/codemirror-block/react/CodemirrorNode.js +323 -0
  21. package/es/plugins/codemirror-block/react/ReactCodemirrorNode.d.ts +4 -0
  22. package/es/plugins/codemirror-block/react/ReactCodemirrorNode.js +34 -0
  23. package/es/plugins/codemirror-block/react/components/CopyButton.d.ts +5 -0
  24. package/es/plugins/codemirror-block/react/components/CopyButton.js +35 -0
  25. package/es/plugins/codemirror-block/react/components/LanguageSelect.d.ts +8 -0
  26. package/es/plugins/codemirror-block/react/components/LanguageSelect.js +77 -0
  27. package/es/plugins/codemirror-block/react/components/MoreOptions.d.ts +16 -0
  28. package/es/plugins/codemirror-block/react/components/MoreOptions.js +79 -0
  29. package/es/plugins/codemirror-block/react/components/Toolbar.d.ts +16 -0
  30. package/es/plugins/codemirror-block/react/components/Toolbar.js +56 -0
  31. package/es/plugins/codemirror-block/react/components/style.d.ts +3 -0
  32. package/es/plugins/codemirror-block/react/components/style.js +9 -0
  33. package/es/plugins/codemirror-block/react/index.d.ts +1 -0
  34. package/es/plugins/codemirror-block/react/index.js +1 -0
  35. package/es/plugins/codemirror-block/react/style.d.ts +1 -0
  36. package/es/plugins/codemirror-block/react/style.js +8 -0
  37. package/es/plugins/codemirror-block/react/theme.d.ts +133 -0
  38. package/es/plugins/codemirror-block/react/theme.js +158 -0
  39. package/es/plugins/codemirror-block/react/type.d.ts +3 -0
  40. package/es/plugins/codemirror-block/react/type.js +1 -0
  41. package/package.json +4 -2
@@ -0,0 +1,416 @@
1
+ export var MODES = [{
2
+ ext: ['agda'],
3
+ name: 'Agda',
4
+ syntax: 'text/x-agda',
5
+ value: 'agda'
6
+ }, {
7
+ ext: ['ets', 'arkts'],
8
+ name: 'ArkTS',
9
+ syntax: 'text/x-arkts',
10
+ value: 'arkts'
11
+ }, {
12
+ ext: ['bash'],
13
+ name: 'Bash',
14
+ syntax: 'shell',
15
+ value: 'bash'
16
+ }, {
17
+ ext: ['vbs'],
18
+ name: 'Basic',
19
+ syntax: 'vbscript',
20
+ value: 'basic'
21
+ }, {
22
+ ext: ['c', 'h', 'ino'],
23
+ name: 'C',
24
+ syntax: 'text/x-csrc',
25
+ value: 'c'
26
+ }, {
27
+ ext: ['cpp', 'c++', 'cc', 'cxx', 'hpp', 'h++', 'hh', 'hxx'],
28
+ name: 'C++',
29
+ syntax: 'text/x-c++src',
30
+ value: 'cpp'
31
+ }, {
32
+ ext: ['cs'],
33
+ name: 'C#',
34
+ syntax: 'text/x-csharp',
35
+ value: 'csharp'
36
+ }, {
37
+ ext: ['css'],
38
+ name: 'CSS',
39
+ syntax: 'css',
40
+ value: 'css'
41
+ }, {
42
+ ext: ['dart'],
43
+ name: 'Dart',
44
+ syntax: 'dart',
45
+ value: 'dart'
46
+ }, {
47
+ ext: ['diff', 'patch'],
48
+ name: 'Diff',
49
+ syntax: 'diff',
50
+ value: 'diff'
51
+ }, {
52
+ name: 'Dockerfile',
53
+ syntax: 'dockerfile',
54
+ value: 'dockerfile'
55
+ }, {
56
+ ext: ['erl'],
57
+ name: 'Erlang',
58
+ syntax: 'erlang',
59
+ value: 'erlang'
60
+ }, {
61
+ ext: ['glsl'],
62
+ name: 'Glsl',
63
+ syntax: 'x-shader/x-vertex',
64
+ value: 'glsl'
65
+ }, {
66
+ name: 'Git',
67
+ syntax: 'shell',
68
+ value: 'git'
69
+ }, {
70
+ ext: ['go'],
71
+ name: 'Go',
72
+ syntax: 'go',
73
+ value: 'go'
74
+ }, {
75
+ name: 'GraphQL',
76
+ syntax: 'graphql',
77
+ value: 'graphql'
78
+ }, {
79
+ ext: ['groovy', 'gradle'],
80
+ name: 'Groovy',
81
+ syntax: 'groovy',
82
+ value: 'groovy'
83
+ }, {
84
+ ext: ['html', 'htm', 'handlebars', 'hbs'],
85
+ name: 'HTML',
86
+ syntax: 'htmlmixed',
87
+ value: 'html'
88
+ }, {
89
+ name: 'HTTP',
90
+ syntax: 'http',
91
+ value: 'http'
92
+ }, {
93
+ ext: ['java'],
94
+ name: 'Java',
95
+ syntax: 'text/x-java',
96
+ value: 'java'
97
+ }, {
98
+ ext: ['js'],
99
+ name: 'JavaScript',
100
+ syntax: 'text/javascript',
101
+ value: 'javascript'
102
+ }, {
103
+ ext: ['json', 'map'],
104
+ name: 'JSON',
105
+ syntax: 'application/json',
106
+ value: 'json'
107
+ }, {
108
+ ext: ['jsx'],
109
+ name: 'JSX',
110
+ syntax: 'jsx',
111
+ value: 'jsx'
112
+ }, {
113
+ name: 'KaTeX',
114
+ syntax: 'simplemode',
115
+ value: 'katex'
116
+ }, {
117
+ ext: ['kt'],
118
+ name: 'Kotlin',
119
+ syntax: 'text/x-kotlin',
120
+ value: 'kotlin'
121
+ }, {
122
+ ext: ['less'],
123
+ name: 'Less',
124
+ syntax: 'css',
125
+ value: 'less'
126
+ }, {
127
+ name: 'Makefile',
128
+ syntax: 'cmake',
129
+ value: 'makefile'
130
+ }, {
131
+ ext: ['markdown', 'md', 'mkd'],
132
+ name: 'Markdown',
133
+ syntax: 'markdown',
134
+ value: 'markdown'
135
+ }, {
136
+ name: 'MATLAB',
137
+ syntax: 'octave',
138
+ value: 'matlab'
139
+ }, {
140
+ ext: ['conf'],
141
+ name: 'Nginx',
142
+ syntax: 'nginx',
143
+ value: 'nginx'
144
+ }, {
145
+ ext: ['m'],
146
+ name: 'Objective-C',
147
+ syntax: 'text/x-objectivec',
148
+ value: 'objectivec'
149
+ }, {
150
+ ext: ['p', 'pas'],
151
+ name: 'Pascal',
152
+ syntax: 'pascal',
153
+ value: 'pascal'
154
+ }, {
155
+ ext: ['pl', 'pm'],
156
+ name: 'Perl',
157
+ syntax: 'perl',
158
+ value: 'perl'
159
+ },
160
+ // syntax 从 'php' 改为 'text/x-php'
161
+ // 解决 php 必须带有 <?php 标签才会高亮的问题
162
+ {
163
+ ext: ['php', 'php3', 'php4', 'php5', 'php7', 'phtml'],
164
+ name: 'PHP',
165
+ syntax: 'text/x-php',
166
+ value: 'php'
167
+ },
168
+ // { value: 'plantuml', syntax: 'plantuml', name: 'PlantUML' }, // 和文本图容易冲突,不再支持
169
+ {
170
+ ext: ['ps1', 'psd1', 'psm1'],
171
+ name: 'PowerShell',
172
+ syntax: 'powershell',
173
+ value: 'powershell'
174
+ }, {
175
+ ext: ['proto'],
176
+ name: 'Protobuf',
177
+ syntax: 'protobuf',
178
+ value: 'protobuf'
179
+ }, {
180
+ ext: ['build', 'bzl', 'py', 'pyw'],
181
+ name: 'Python',
182
+ syntax: 'python',
183
+ value: 'python'
184
+ }, {
185
+ ext: ['r', 'R'],
186
+ name: 'R',
187
+ syntax: 'r',
188
+ value: 'r'
189
+ }, {
190
+ ext: ['rb'],
191
+ name: 'Ruby',
192
+ syntax: 'ruby',
193
+ value: 'ruby'
194
+ }, {
195
+ ext: ['rs'],
196
+ name: 'Rust',
197
+ syntax: 'rust',
198
+ value: 'rust'
199
+ }, {
200
+ ext: ['scala'],
201
+ name: 'Scala',
202
+ syntax: 'text/x-scala',
203
+ value: 'scala'
204
+ }, {
205
+ ext: ['sh', 'ksh'],
206
+ name: 'Shell',
207
+ syntax: 'shell',
208
+ value: 'shell'
209
+ }, {
210
+ ext: ['sql'],
211
+ name: 'SQL',
212
+ syntax: 'text/x-sql',
213
+ value: 'sql'
214
+ }, {
215
+ name: 'PL/SQL',
216
+ syntax: 'text/x-plsql',
217
+ value: 'plsql'
218
+ }, {
219
+ ext: ['swift'],
220
+ name: 'Swift',
221
+ syntax: 'swift',
222
+ value: 'swift'
223
+ }, {
224
+ ext: ['ts'],
225
+ name: 'TypeScript',
226
+ syntax: 'text/typescript',
227
+ value: 'typescript'
228
+ }, {
229
+ ext: ['vb'],
230
+ name: 'VB.net',
231
+ syntax: 'vb',
232
+ value: 'vbnet'
233
+ }, {
234
+ ext: ['vtl'],
235
+ name: 'Velocity',
236
+ syntax: 'velocity',
237
+ value: 'velocity'
238
+ }, {
239
+ ext: ['xml', 'xsl', 'xsd', 'svg'],
240
+ name: 'XML',
241
+ syntax: 'xml',
242
+ value: 'xml'
243
+ }, {
244
+ ext: ['yaml', 'yml'],
245
+ name: 'YAML',
246
+ syntax: 'yaml',
247
+ value: 'yaml'
248
+ }, {
249
+ name: 'sTeX',
250
+ syntax: 'text/x-stex',
251
+ value: 'stex'
252
+ }, {
253
+ ext: ['text', 'ltx', 'tex'],
254
+ name: 'LaTeX',
255
+ syntax: 'text/x-latex',
256
+ value: 'latex'
257
+ }, {
258
+ ext: ['sv', 'svh'],
259
+ name: 'SystemVerilog',
260
+ syntax: 'text/x-systemverilog',
261
+ value: 'systemverilog'
262
+ }, {
263
+ ext: ['sass', 'scss'],
264
+ name: 'Sass',
265
+ syntax: 'text/x-sass',
266
+ value: 'sass'
267
+ }, {
268
+ ext: ['tcl'],
269
+ name: 'Tcl',
270
+ syntax: 'text/x-tcl',
271
+ value: 'tcl'
272
+ }, {
273
+ ext: ['v'],
274
+ name: 'Verilog',
275
+ syntax: 'text/x-verilog',
276
+ value: 'verilog'
277
+ }, {
278
+ name: 'Vue',
279
+ syntax: 'text/x-vue',
280
+ value: 'vue'
281
+ }, {
282
+ ext: ['lua'],
283
+ name: 'Lua',
284
+ syntax: 'text/x-lua',
285
+ value: 'lua'
286
+ }, {
287
+ ext: ['hs'],
288
+ name: 'Haskell',
289
+ syntax: 'haskell',
290
+ value: 'haskell'
291
+ }, {
292
+ ext: ['properties', 'ini', 'in'],
293
+ name: 'Properties',
294
+ syntax: 'properties',
295
+ value: 'properties'
296
+ }, {
297
+ ext: ['toml'],
298
+ name: 'TOML',
299
+ syntax: 'toml',
300
+ value: 'toml'
301
+ }, {
302
+ ext: ['cyp', 'cypher'],
303
+ name: 'Cypher',
304
+ syntax: 'cypher',
305
+ value: 'cypher'
306
+ }, {
307
+ ext: ['tsx'],
308
+ name: 'TSX',
309
+ syntax: 'jsx',
310
+ value: 'tsx'
311
+ }, {
312
+ ext: ['fs'],
313
+ name: 'F#',
314
+ syntax: 'mllike',
315
+ value: 'f#'
316
+ }, {
317
+ ext: ['ml', 'mli', 'mll', 'mly'],
318
+ name: 'OCaml',
319
+ syntax: 'mllike',
320
+ value: 'ocaml'
321
+ }, {
322
+ ext: ['clj', 'cljc', 'cljx'],
323
+ name: 'Clojure',
324
+ syntax: 'clojure',
325
+ value: 'clojure'
326
+ }, {
327
+ name: 'ABAP',
328
+ syntax: 'abap',
329
+ value: 'abap'
330
+ }, {
331
+ ext: ['jl'],
332
+ name: 'Julia',
333
+ syntax: 'julia',
334
+ value: 'julia'
335
+ }, {
336
+ ext: ['cmake'],
337
+ name: 'CMake',
338
+ syntax: 'cmake',
339
+ value: 'cmake'
340
+ }, {
341
+ ext: ['scm', 'ss'],
342
+ name: 'Scheme',
343
+ syntax: 'scheme',
344
+ value: 'scheme'
345
+ }, {
346
+ ext: ['cl', 'lisp', 'el'],
347
+ name: 'Lisp',
348
+ syntax: 'commonlisp',
349
+ value: 'commonlisp'
350
+ }, {
351
+ ext: ['f90', 'f95', 'f03'],
352
+ name: 'Fortran',
353
+ syntax: 'fortran',
354
+ value: 'fortran'
355
+ }, {
356
+ ext: ['sol'],
357
+ name: 'Solidity',
358
+ syntax: 'solidity',
359
+ value: 'solidity'
360
+ }];
361
+
362
+ // 不支持格式化的语言
363
+ export var DISABLE_FORMAT_MODE = ['yaml'];
364
+ MODES.sort(function (modeA, modeB) {
365
+ var nameA = modeA.name.toLowerCase();
366
+ var nameB = modeB.name.toLowerCase();
367
+ if (nameA === nameB) {
368
+ return 0;
369
+ }
370
+ if (nameA < nameB) {
371
+ return -1;
372
+ }
373
+ return 1;
374
+ });
375
+
376
+ // 保证 plain text 是第一个
377
+ MODES.unshift({
378
+ name: 'Plain Text',
379
+ syntax: 'simplemode',
380
+ value: 'plain'
381
+ });
382
+ export function modeMatch() {
383
+ var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
384
+ // eslint-disable-next-line no-param-reassign
385
+ mode = mode.toLocaleLowerCase() || 'plain';
386
+ var findMode = MODES.find(function (m) {
387
+ var _m$ext;
388
+ return m.value === mode || ((_m$ext = m.ext) === null || _m$ext === void 0 ? void 0 : _m$ext.includes(mode));
389
+ });
390
+ return (findMode === null || findMode === void 0 ? void 0 : findMode.value) || 'plain';
391
+ }
392
+ export var LOBE_THEME = 'default';
393
+ export var CODE_THEME_ENUM = /*#__PURE__*/function (CODE_THEME_ENUM) {
394
+ CODE_THEME_ENUM["LOBE"] = "default";
395
+ return CODE_THEME_ENUM;
396
+ }({});
397
+ export var THEMES = [{
398
+ isDark: false,
399
+ name: CODE_THEME_ENUM.LOBE,
400
+ value: CODE_THEME_ENUM.LOBE
401
+ }];
402
+
403
+ // 默认主题下 codeblock 首选风格名
404
+ export var DEFAULT_CODEBLOCK_THEME_NAME = CODE_THEME_ENUM.LOBE;
405
+
406
+ // dark主题下 codeblock 首选风格名
407
+ export var DARK_CODEBLOCK_THEME_NAME = CODE_THEME_ENUM.LOBE;
408
+ export function getValidTheme(theme) {
409
+ var find = THEMES.find(function (v) {
410
+ return v.value === theme || v.name === theme;
411
+ });
412
+ if (find) {
413
+ return find.value;
414
+ }
415
+ return DEFAULT_CODEBLOCK_THEME_NAME;
416
+ }
@@ -0,0 +1,46 @@
1
+ import { DOMConversionMap, DOMExportOutput, DecoratorNode, EditorConfig, LexicalEditor, LexicalNode, SerializedLexicalNode, Spread } from 'lexical';
2
+ export interface CodeMirrorOptions {
3
+ indentWithTabs: boolean;
4
+ lineNumbers: boolean;
5
+ tabSize: number;
6
+ }
7
+ export type SerializedCodeMirrorNode = Spread<{
8
+ code: string;
9
+ codeTheme: string;
10
+ language: string;
11
+ options: {
12
+ indentWithTabs: boolean;
13
+ lineNumbers: boolean;
14
+ tabSize: number;
15
+ };
16
+ }, SerializedLexicalNode>;
17
+ export declare class CodeMirrorNode extends DecoratorNode<any> {
18
+ private __lang;
19
+ private __code;
20
+ private __codeTheme;
21
+ private __options;
22
+ static getType(): string;
23
+ static clone(node: CodeMirrorNode): CodeMirrorNode;
24
+ static importJSON(serializedNode: SerializedCodeMirrorNode): CodeMirrorNode;
25
+ static importDOM(): DOMConversionMap | null;
26
+ constructor(lang: string, code: string, codeTheme: string, options: CodeMirrorOptions, key?: string);
27
+ get lang(): string;
28
+ get code(): string;
29
+ get codeTheme(): string;
30
+ get options(): CodeMirrorOptions;
31
+ exportDOM(editor: LexicalEditor): DOMExportOutput;
32
+ exportJSON(): SerializedCodeMirrorNode;
33
+ setLang(lang: string): this;
34
+ setCode(code: string): this;
35
+ setCodeTheme(codeTheme: string): this;
36
+ setTabSize(tabSize: number): this;
37
+ setIndentWithTabs(indentWithTabs: boolean): this;
38
+ setLineNumbers(lineNumbers: boolean): this;
39
+ createDOM(config: EditorConfig): HTMLElement;
40
+ getTextContent(): string;
41
+ isInline(): false;
42
+ updateDOM(): boolean;
43
+ decorate(editor: LexicalEditor): any;
44
+ }
45
+ export declare function $createCodeMirrorNode(lang: string, code?: string, codeTheme?: string, options?: CodeMirrorOptions): CodeMirrorNode;
46
+ export declare function $isCodeMirrorNode(node: LexicalNode): node is CodeMirrorNode;