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.
@@ -0,0 +1,2 @@
1
+ import { BoxComponent } from '../types/box';
2
+ export declare const fileBox: BoxComponent;
@@ -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';
@@ -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
- * U​n​d​o​ ​(​Ctr​l​+​Z​)
10
+ * U​n​d​o​ ​(​mod​+​Z​)
11
11
  */
12
12
  undo: string;
13
13
  /**
14
- * R​e​d​o​ ​(​Ctr​l​+​Y​)
14
+ * R​e​d​o​ ​(​mod​+​Y​)
15
15
  */
16
16
  redo: string;
17
17
  /**
18
- * S​e​l​e​c​t​ ​a​l​l​ ​(​Ctr​l​+​A​)
18
+ * S​e​l​e​c​t​ ​a​l​l​ ​(​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
- * B​o​l​d​ ​(​Ctr​l​+​B​)
66
+ * B​o​l​d​ ​(​mod​+​B​)
67
67
  */
68
68
  bold: string;
69
69
  /**
70
- * I​t​a​l​i​c​ ​(​Ctr​l​+​I​)
70
+ * I​t​a​l​i​c​ ​(​mod​+​I​)
71
71
  */
72
72
  italic: string;
73
73
  /**
74
- * U​n​d​e​r​l​i​n​e​ ​(​Ctr​l​+​U​)
74
+ * U​n​d​e​r​l​i​n​e​ ​(​mod​+​U​)
75
75
  */
76
76
  underline: string;
77
77
  /**
@@ -174,6 +174,10 @@ type RootTranslation = {
174
174
  * I​m​a​g​e
175
175
  */
176
176
  image: string;
177
+ /**
178
+ * F​i​l​e
179
+ */
180
+ file: string;
177
181
  /**
178
182
  * R​e​m​o​v​e​ ​c​o​l​o​r
179
183
  */
@@ -243,6 +247,16 @@ type RootTranslation = {
243
247
  */
244
248
  zoomIn: string;
245
249
  };
250
+ file: {
251
+ /**
252
+ * D​o​w​n​l​o​a​d
253
+ */
254
+ download: string;
255
+ /**
256
+ * D​e​l​e​t​e
257
+ */
258
+ remove: string;
259
+ };
246
260
  codeBlock: {
247
261
  /**
248
262
  * S​e​l​e​c​t​ ​l​a​n​g​u​a​g​e
@@ -253,15 +267,15 @@ type RootTranslation = {
253
267
  export type TranslationFunctions = {
254
268
  toolbar: {
255
269
  /**
256
- * Undo (Ctrl+Z)
270
+ * Undo (mod+Z)
257
271
  */
258
272
  undo: () => LocalizedString;
259
273
  /**
260
- * Redo (Ctrl+Y)
274
+ * Redo (mod+Y)
261
275
  */
262
276
  redo: () => LocalizedString;
263
277
  /**
264
- * Select all (Ctrl+A)
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 (Ctrl+B)
326
+ * Bold (mod+B)
313
327
  */
314
328
  bold: () => LocalizedString;
315
329
  /**
316
- * Italic (Ctrl+I)
330
+ * Italic (mod+I)
317
331
  */
318
332
  italic: () => LocalizedString;
319
333
  /**
320
- * Underline (Ctrl+U)
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(editor: Editor): Map<number, Box>;
10
- rectifyInstances(editor: Editor): void;
11
- findAll(editor: Editor): Nodes;
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
- addRangeToNativeSelection(): void;
24
- syncByRange(): void;
25
- synByBookmark(): void;
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,3 @@
1
+ import type { Editor } from '..';
2
+ declare const _default: (editor: Editor) => void;
3
+ export default _default;
@@ -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 {};
@@ -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 uploadImage(config: UploadConfig): Box;
10
+ export declare function uploadFile(config: UploadConfig): Box;
10
11
  export {};
@@ -0,0 +1 @@
1
+ export declare function fileSize(size: number): string;
@@ -0,0 +1,4 @@
1
+ import { NativeNode } from '../types/native';
2
+ import { Nodes } from '../models/nodes';
3
+ import { Box } from '../models/box';
4
+ export declare function getBox(boxNode: string | Nodes | NativeNode): Box;
@@ -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';
@@ -0,0 +1,9 @@
1
+ import { Nodes } from '../models/nodes';
2
+ type NodePosition = {
3
+ left: number;
4
+ right: number;
5
+ top: number;
6
+ bottom: number;
7
+ };
8
+ export declare function nodeAndView(node: Nodes): NodePosition;
9
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lakelib",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Rich text editor based on the browser",
5
5
  "keywords": [
6
6
  "rich text",