lakelib 0.1.8 → 0.1.9
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/dist/lake.css +93 -8
- package/dist/lake.min.js +26 -17
- package/dist/lake.min.js.map +1 -1
- package/lib/lake.css +93 -8
- package/lib/lake.js +708 -294
- package/lib/lake.js.map +1 -1
- package/lib/types/boxes/file.d.ts +2 -0
- package/lib/types/css/index.d.ts +3 -0
- package/lib/types/editor.d.ts +5 -1
- package/lib/types/i18n/en-US/index.d.ts +5 -0
- package/lib/types/i18n/ja/index.d.ts +5 -0
- package/lib/types/i18n/ko/index.d.ts +5 -0
- package/lib/types/i18n/types.d.ts +40 -12
- package/lib/types/i18n/zh-CN/index.d.ts +5 -0
- package/lib/types/managers/box-manager.d.ts +3 -5
- package/lib/types/managers/selection.d.ts +3 -3
- package/lib/types/plugins/file.d.ts +3 -0
- package/lib/types/types/box-toolbar.d.ts +21 -0
- package/lib/types/ui/box-toolbar.d.ts +31 -0
- package/lib/types/ui/upload.d.ts +3 -2
- package/lib/types/utils/file-size.d.ts +1 -0
- package/lib/types/utils/get-box.d.ts +4 -0
- package/lib/types/utils/index.d.ts +3 -0
- package/lib/types/utils/node-and-view.d.ts +9 -0
- package/package.json +1 -1
package/lib/types/css/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import './custom-properties.css';
|
|
2
|
+
import './keyframes.css';
|
|
2
3
|
import './core.css';
|
|
3
4
|
import './mark.css';
|
|
4
5
|
import './button.css';
|
|
@@ -12,6 +13,8 @@ import './table.css';
|
|
|
12
13
|
import './box.css';
|
|
13
14
|
import './hr.css';
|
|
14
15
|
import './image.css';
|
|
16
|
+
import './file.css';
|
|
15
17
|
import './code-block.css';
|
|
16
18
|
import './link-popup.css';
|
|
17
19
|
import './toolbar.css';
|
|
20
|
+
import './box-toolbar.css';
|
package/lib/types/editor.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { Keystroke } from './managers/keystroke';
|
|
|
12
12
|
import { BoxManager } from './managers/box-manager';
|
|
13
13
|
import { Plugin } from './managers/plugin';
|
|
14
14
|
import { Toolbar } from './ui/toolbar';
|
|
15
|
+
type OnMessage = (type: 'success' | 'error' | 'warning', message: string) => void;
|
|
15
16
|
type Config = {
|
|
16
17
|
value: string;
|
|
17
18
|
readonly: boolean;
|
|
@@ -21,6 +22,7 @@ type Config = {
|
|
|
21
22
|
indentWithTab: boolean;
|
|
22
23
|
lang: string;
|
|
23
24
|
minChangeSize: number;
|
|
25
|
+
onMessage: OnMessage;
|
|
24
26
|
[name: string]: any;
|
|
25
27
|
};
|
|
26
28
|
type EditorConfig = {
|
|
@@ -34,6 +36,7 @@ type EditorConfig = {
|
|
|
34
36
|
indentWithTab?: boolean;
|
|
35
37
|
lang?: string;
|
|
36
38
|
minChangeSize?: number;
|
|
39
|
+
onMessage?: OnMessage;
|
|
37
40
|
[name: string]: any;
|
|
38
41
|
};
|
|
39
42
|
export declare class Editor {
|
|
@@ -86,8 +89,9 @@ export declare class Editor {
|
|
|
86
89
|
scrollToCaret(): void;
|
|
87
90
|
setValue(value: string): void;
|
|
88
91
|
getValue(): string;
|
|
92
|
+
selectBox(box: Box | Nodes): void;
|
|
89
93
|
insertBox(boxName: Parameters<typeof insertBox>[1], boxValue?: Parameters<typeof insertBox>[2]): Box;
|
|
90
|
-
removeBox(): ReturnType<typeof removeBox>;
|
|
94
|
+
removeBox(box?: Box | Nodes | null): ReturnType<typeof removeBox>;
|
|
91
95
|
render(): void;
|
|
92
96
|
unmount(): void;
|
|
93
97
|
}
|
|
@@ -42,6 +42,7 @@ declare const _default: {
|
|
|
42
42
|
fontColor: string;
|
|
43
43
|
highlight: string;
|
|
44
44
|
image: string;
|
|
45
|
+
file: string;
|
|
45
46
|
removeColor: string;
|
|
46
47
|
};
|
|
47
48
|
link: {
|
|
@@ -63,6 +64,10 @@ declare const _default: {
|
|
|
63
64
|
zoomOut: string;
|
|
64
65
|
zoomIn: string;
|
|
65
66
|
};
|
|
67
|
+
file: {
|
|
68
|
+
download: string;
|
|
69
|
+
remove: string;
|
|
70
|
+
};
|
|
66
71
|
codeBlock: {
|
|
67
72
|
langType: string;
|
|
68
73
|
};
|
|
@@ -42,6 +42,7 @@ declare const _default: {
|
|
|
42
42
|
fontColor: string;
|
|
43
43
|
highlight: string;
|
|
44
44
|
image: string;
|
|
45
|
+
file: string;
|
|
45
46
|
removeColor: string;
|
|
46
47
|
};
|
|
47
48
|
link: {
|
|
@@ -63,6 +64,10 @@ declare const _default: {
|
|
|
63
64
|
zoomOut: string;
|
|
64
65
|
zoomIn: string;
|
|
65
66
|
};
|
|
67
|
+
file: {
|
|
68
|
+
download: string;
|
|
69
|
+
remove: string;
|
|
70
|
+
};
|
|
66
71
|
codeBlock: {
|
|
67
72
|
langType: string;
|
|
68
73
|
};
|
|
@@ -42,6 +42,7 @@ declare const _default: {
|
|
|
42
42
|
fontColor: string;
|
|
43
43
|
highlight: string;
|
|
44
44
|
image: string;
|
|
45
|
+
file: string;
|
|
45
46
|
removeColor: string;
|
|
46
47
|
};
|
|
47
48
|
link: {
|
|
@@ -63,6 +64,10 @@ declare const _default: {
|
|
|
63
64
|
zoomOut: string;
|
|
64
65
|
zoomIn: string;
|
|
65
66
|
};
|
|
67
|
+
file: {
|
|
68
|
+
download: string;
|
|
69
|
+
remove: string;
|
|
70
|
+
};
|
|
66
71
|
codeBlock: {
|
|
67
72
|
langType: string;
|
|
68
73
|
};
|
|
@@ -7,15 +7,15 @@ export type Translations = RootTranslation;
|
|
|
7
7
|
type RootTranslation = {
|
|
8
8
|
toolbar: {
|
|
9
9
|
/**
|
|
10
|
-
* Undo (
|
|
10
|
+
* Undo (mod+Z)
|
|
11
11
|
*/
|
|
12
12
|
undo: string;
|
|
13
13
|
/**
|
|
14
|
-
* Redo (
|
|
14
|
+
* Redo (mod+Y)
|
|
15
15
|
*/
|
|
16
16
|
redo: string;
|
|
17
17
|
/**
|
|
18
|
-
* Select all (
|
|
18
|
+
* Select all (mod+A)
|
|
19
19
|
*/
|
|
20
20
|
selectAll: string;
|
|
21
21
|
/**
|
|
@@ -63,15 +63,15 @@ type RootTranslation = {
|
|
|
63
63
|
*/
|
|
64
64
|
decreaseIndent: string;
|
|
65
65
|
/**
|
|
66
|
-
* Bold (
|
|
66
|
+
* Bold (mod+B)
|
|
67
67
|
*/
|
|
68
68
|
bold: string;
|
|
69
69
|
/**
|
|
70
|
-
* Italic (
|
|
70
|
+
* Italic (mod+I)
|
|
71
71
|
*/
|
|
72
72
|
italic: string;
|
|
73
73
|
/**
|
|
74
|
-
* Underline (
|
|
74
|
+
* Underline (mod+U)
|
|
75
75
|
*/
|
|
76
76
|
underline: string;
|
|
77
77
|
/**
|
|
@@ -174,6 +174,10 @@ type RootTranslation = {
|
|
|
174
174
|
* Image
|
|
175
175
|
*/
|
|
176
176
|
image: string;
|
|
177
|
+
/**
|
|
178
|
+
* File
|
|
179
|
+
*/
|
|
180
|
+
file: string;
|
|
177
181
|
/**
|
|
178
182
|
* Remove color
|
|
179
183
|
*/
|
|
@@ -243,6 +247,16 @@ type RootTranslation = {
|
|
|
243
247
|
*/
|
|
244
248
|
zoomIn: string;
|
|
245
249
|
};
|
|
250
|
+
file: {
|
|
251
|
+
/**
|
|
252
|
+
* Download
|
|
253
|
+
*/
|
|
254
|
+
download: string;
|
|
255
|
+
/**
|
|
256
|
+
* Delete
|
|
257
|
+
*/
|
|
258
|
+
remove: string;
|
|
259
|
+
};
|
|
246
260
|
codeBlock: {
|
|
247
261
|
/**
|
|
248
262
|
* Select language
|
|
@@ -253,15 +267,15 @@ type RootTranslation = {
|
|
|
253
267
|
export type TranslationFunctions = {
|
|
254
268
|
toolbar: {
|
|
255
269
|
/**
|
|
256
|
-
* Undo (
|
|
270
|
+
* Undo (mod+Z)
|
|
257
271
|
*/
|
|
258
272
|
undo: () => LocalizedString;
|
|
259
273
|
/**
|
|
260
|
-
* Redo (
|
|
274
|
+
* Redo (mod+Y)
|
|
261
275
|
*/
|
|
262
276
|
redo: () => LocalizedString;
|
|
263
277
|
/**
|
|
264
|
-
* Select all (
|
|
278
|
+
* Select all (mod+A)
|
|
265
279
|
*/
|
|
266
280
|
selectAll: () => LocalizedString;
|
|
267
281
|
/**
|
|
@@ -309,15 +323,15 @@ export type TranslationFunctions = {
|
|
|
309
323
|
*/
|
|
310
324
|
decreaseIndent: () => LocalizedString;
|
|
311
325
|
/**
|
|
312
|
-
* Bold (
|
|
326
|
+
* Bold (mod+B)
|
|
313
327
|
*/
|
|
314
328
|
bold: () => LocalizedString;
|
|
315
329
|
/**
|
|
316
|
-
* Italic (
|
|
330
|
+
* Italic (mod+I)
|
|
317
331
|
*/
|
|
318
332
|
italic: () => LocalizedString;
|
|
319
333
|
/**
|
|
320
|
-
* Underline (
|
|
334
|
+
* Underline (mod+U)
|
|
321
335
|
*/
|
|
322
336
|
underline: () => LocalizedString;
|
|
323
337
|
/**
|
|
@@ -420,6 +434,10 @@ export type TranslationFunctions = {
|
|
|
420
434
|
* Image
|
|
421
435
|
*/
|
|
422
436
|
image: () => LocalizedString;
|
|
437
|
+
/**
|
|
438
|
+
* File
|
|
439
|
+
*/
|
|
440
|
+
file: () => LocalizedString;
|
|
423
441
|
/**
|
|
424
442
|
* Remove color
|
|
425
443
|
*/
|
|
@@ -489,6 +507,16 @@ export type TranslationFunctions = {
|
|
|
489
507
|
*/
|
|
490
508
|
zoomIn: () => LocalizedString;
|
|
491
509
|
};
|
|
510
|
+
file: {
|
|
511
|
+
/**
|
|
512
|
+
* Download
|
|
513
|
+
*/
|
|
514
|
+
download: () => LocalizedString;
|
|
515
|
+
/**
|
|
516
|
+
* Delete
|
|
517
|
+
*/
|
|
518
|
+
remove: () => LocalizedString;
|
|
519
|
+
};
|
|
492
520
|
codeBlock: {
|
|
493
521
|
/**
|
|
494
522
|
* Select language
|
|
@@ -42,6 +42,7 @@ declare const _default: {
|
|
|
42
42
|
fontColor: string;
|
|
43
43
|
highlight: string;
|
|
44
44
|
image: string;
|
|
45
|
+
file: string;
|
|
45
46
|
removeColor: string;
|
|
46
47
|
};
|
|
47
48
|
link: {
|
|
@@ -63,6 +64,10 @@ declare const _default: {
|
|
|
63
64
|
zoomOut: string;
|
|
64
65
|
zoomIn: string;
|
|
65
66
|
};
|
|
67
|
+
file: {
|
|
68
|
+
download: string;
|
|
69
|
+
remove: string;
|
|
70
|
+
};
|
|
66
71
|
codeBlock: {
|
|
67
72
|
langType: string;
|
|
68
73
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Editor } from '../editor';
|
|
2
1
|
import { BoxComponent } from '../types/box';
|
|
3
2
|
import { Nodes } from '../models/nodes';
|
|
4
3
|
import { Box } from '../models/box';
|
|
@@ -6,8 +5,7 @@ export declare class BoxManager {
|
|
|
6
5
|
add(component: BoxComponent): void;
|
|
7
6
|
remove(name: string): void;
|
|
8
7
|
getNames(): string[];
|
|
9
|
-
getInstances(
|
|
10
|
-
rectifyInstances(
|
|
11
|
-
|
|
12
|
-
renderAll(editor: Editor): void;
|
|
8
|
+
getInstances(container: Nodes): Map<number, Box>;
|
|
9
|
+
rectifyInstances(container: Nodes): void;
|
|
10
|
+
renderAll(container: Nodes): void;
|
|
13
11
|
}
|
|
@@ -20,9 +20,9 @@ export declare class Selection {
|
|
|
20
20
|
range: Range;
|
|
21
21
|
constructor(container: Nodes);
|
|
22
22
|
private getRangeFromNativeSelection;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
sync(): void;
|
|
24
|
+
updateByRange(): void;
|
|
25
|
+
updateByBookmark(): void;
|
|
26
26
|
getAppliedItems(): AppliedItem[];
|
|
27
27
|
insertBookmark(): ReturnType<typeof insertBookmark>;
|
|
28
28
|
toBookmark(bookmark: Parameters<typeof toBookmark>[1]): ReturnType<typeof toBookmark>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Box } from '../models/box';
|
|
2
|
+
import { TranslationFunctions } from '../i18n/types';
|
|
3
|
+
import { DropdownItem } from './dropdown';
|
|
4
|
+
import { AppliedItem } from './object';
|
|
5
|
+
export type BoxToolbarButtonItem = {
|
|
6
|
+
name: string;
|
|
7
|
+
type: 'button';
|
|
8
|
+
icon?: string;
|
|
9
|
+
tooltip: string | ((locale: TranslationFunctions) => string);
|
|
10
|
+
isSelected?: (appliedItems: AppliedItem[]) => boolean;
|
|
11
|
+
isDisabled?: (appliedItems: AppliedItem[]) => boolean;
|
|
12
|
+
onClick: (box: Box, value: string) => void;
|
|
13
|
+
};
|
|
14
|
+
export type BoxToolbarDropdownItem = DropdownItem & {
|
|
15
|
+
name: string;
|
|
16
|
+
type: 'dropdown';
|
|
17
|
+
selectedValues?: (appliedItems: AppliedItem[]) => string[];
|
|
18
|
+
isDisabled?: (appliedItems: AppliedItem[]) => boolean;
|
|
19
|
+
onSelect: (box: Box, value: string) => void;
|
|
20
|
+
};
|
|
21
|
+
export type BoxToolbarItem = BoxToolbarButtonItem | BoxToolbarDropdownItem;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Editor } from '../editor';
|
|
2
|
+
import { NativeNode } from '../types/native';
|
|
3
|
+
import { BoxToolbarItem } from '../types/box-toolbar';
|
|
4
|
+
import { Nodes } from '../models/nodes';
|
|
5
|
+
import { Box } from '../models/box';
|
|
6
|
+
type ToolbarPlacement = 'top' | 'bottom';
|
|
7
|
+
type ToolbarConfig = {
|
|
8
|
+
root: string | Nodes | NativeNode;
|
|
9
|
+
editor: Editor;
|
|
10
|
+
box: Box;
|
|
11
|
+
items: (string | BoxToolbarItem)[];
|
|
12
|
+
placement?: ToolbarPlacement;
|
|
13
|
+
};
|
|
14
|
+
export declare class BoxToolbar {
|
|
15
|
+
private root;
|
|
16
|
+
private editor;
|
|
17
|
+
private box;
|
|
18
|
+
private items;
|
|
19
|
+
private placement;
|
|
20
|
+
private buttonItemList;
|
|
21
|
+
private dropdownItemList;
|
|
22
|
+
container: Nodes;
|
|
23
|
+
constructor(config: ToolbarConfig);
|
|
24
|
+
private appendDivider;
|
|
25
|
+
private appendButton;
|
|
26
|
+
private appendDropdown;
|
|
27
|
+
updatePosition(): void;
|
|
28
|
+
render(): void;
|
|
29
|
+
unmount(): void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
package/lib/types/ui/upload.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import type { Editor } from '../editor';
|
|
|
2
2
|
import { Box } from '../models/box';
|
|
3
3
|
type UploadConfig = {
|
|
4
4
|
editor: Editor;
|
|
5
|
+
name: string;
|
|
5
6
|
file: File;
|
|
6
|
-
onError?: () => void;
|
|
7
|
+
onError?: (error: string) => void;
|
|
7
8
|
onSuccess?: () => void;
|
|
8
9
|
};
|
|
9
|
-
export declare function
|
|
10
|
+
export declare function uploadFile(config: UploadConfig): Box;
|
|
10
11
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fileSize(size: number): string;
|
|
@@ -8,6 +8,7 @@ export * from './parse-style';
|
|
|
8
8
|
export * from './normalize-value';
|
|
9
9
|
export * from './denormalize-value';
|
|
10
10
|
export * from './modifier-text';
|
|
11
|
+
export * from './file-size';
|
|
11
12
|
export * from './get-css';
|
|
12
13
|
export * from './to-node-list';
|
|
13
14
|
export * from './query';
|
|
@@ -22,5 +23,7 @@ export * from './fix-numbered-list';
|
|
|
22
23
|
export * from './remove-br';
|
|
23
24
|
export * from './set-block-indent';
|
|
24
25
|
export * from './morph';
|
|
26
|
+
export * from './node-and-view';
|
|
27
|
+
export * from './get-box';
|
|
25
28
|
export * from './request';
|
|
26
29
|
export * from './debug';
|