lakelib 0.0.2 → 0.0.4

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,500 @@
1
+ import type { BaseTranslation as BaseTranslationType, LocalizedString } from 'typesafe-i18n';
2
+ export type BaseTranslation = BaseTranslationType;
3
+ export type BaseLocale = 'en-US';
4
+ export type Locales = 'en-US' | 'ja' | 'ko' | 'zh-CN';
5
+ export type Translation = RootTranslation;
6
+ export type Translations = RootTranslation;
7
+ type RootTranslation = {
8
+ toolbar: {
9
+ /**
10
+ * U​n​d​o​ ​(​C​t​r​l​+​Z​)
11
+ */
12
+ undo: string;
13
+ /**
14
+ * R​e​d​o​ ​(​C​t​r​l​+​Y​)
15
+ */
16
+ redo: string;
17
+ /**
18
+ * S​e​l​e​c​t​ ​a​l​l​ ​(​C​t​r​l​+​A​)
19
+ */
20
+ selectAll: string;
21
+ /**
22
+ * P​a​r​a​g​r​a​p​h
23
+ */
24
+ paragraph: string;
25
+ /**
26
+ * B​l​o​c​k​ ​q​u​o​t​a​t​i​o​n
27
+ */
28
+ blockQuote: string;
29
+ /**
30
+ * N​u​m​b​e​r​e​d​ ​l​i​s​t
31
+ */
32
+ numberedList: string;
33
+ /**
34
+ * B​u​l​l​e​t​e​d​ ​l​i​s​t
35
+ */
36
+ bulletedList: string;
37
+ /**
38
+ * C​h​e​c​k​l​i​s​t
39
+ */
40
+ checklist: string;
41
+ /**
42
+ * A​l​i​g​n​ ​l​e​f​t
43
+ */
44
+ alignLeft: string;
45
+ /**
46
+ * A​l​i​g​n​ ​c​e​n​t​e​r
47
+ */
48
+ alignCenter: string;
49
+ /**
50
+ * A​l​i​g​n​ ​r​i​g​h​t
51
+ */
52
+ alignRight: string;
53
+ /**
54
+ * A​l​i​g​n​ ​j​u​s​t​i​f​y
55
+ */
56
+ alignJustify: string;
57
+ /**
58
+ * I​n​c​r​e​a​s​e​ ​i​n​d​e​n​t
59
+ */
60
+ increaseIndent: string;
61
+ /**
62
+ * D​e​c​r​e​a​s​e​ ​i​n​d​e​n​t
63
+ */
64
+ decreaseIndent: string;
65
+ /**
66
+ * B​o​l​d​ ​(​C​t​r​l​+​B​)
67
+ */
68
+ bold: string;
69
+ /**
70
+ * I​t​a​l​i​c​ ​(​C​t​r​l​+​I​)
71
+ */
72
+ italic: string;
73
+ /**
74
+ * U​n​d​e​r​l​i​n​e​ ​(​C​t​r​l​+​U​)
75
+ */
76
+ underline: string;
77
+ /**
78
+ * S​t​r​i​k​e​t​h​r​o​u​g​h
79
+ */
80
+ strikethrough: string;
81
+ /**
82
+ * S​u​p​e​r​s​c​r​i​p​t
83
+ */
84
+ superscript: string;
85
+ /**
86
+ * S​u​b​s​c​r​i​p​t
87
+ */
88
+ subscript: string;
89
+ /**
90
+ * I​n​l​i​n​e​ ​c​o​d​e
91
+ */
92
+ code: string;
93
+ /**
94
+ * R​e​m​o​v​e​ ​f​o​r​m​a​t
95
+ */
96
+ removeFormat: string;
97
+ /**
98
+ * F​o​r​m​a​t​ ​p​a​i​n​t​e​r
99
+ */
100
+ formatPainter: string;
101
+ /**
102
+ * L​i​n​k
103
+ */
104
+ link: string;
105
+ /**
106
+ * H​o​r​i​z​o​n​t​a​l​ ​l​i​n​e
107
+ */
108
+ hr: string;
109
+ /**
110
+ * C​o​d​e​ ​b​l​o​c​k
111
+ */
112
+ codeBlock: string;
113
+ /**
114
+ * H​e​a​d​i​n​g
115
+ */
116
+ heading: string;
117
+ /**
118
+ * H​e​a​d​i​n​g​ ​1
119
+ */
120
+ heading1: string;
121
+ /**
122
+ * H​e​a​d​i​n​g​ ​2
123
+ */
124
+ heading2: string;
125
+ /**
126
+ * H​e​a​d​i​n​g​ ​3
127
+ */
128
+ heading3: string;
129
+ /**
130
+ * H​e​a​d​i​n​g​ ​4
131
+ */
132
+ heading4: string;
133
+ /**
134
+ * H​e​a​d​i​n​g​ ​5
135
+ */
136
+ heading5: string;
137
+ /**
138
+ * H​e​a​d​i​n​g​ ​6
139
+ */
140
+ heading6: string;
141
+ /**
142
+ * L​i​s​t
143
+ */
144
+ list: string;
145
+ /**
146
+ * A​l​i​g​n​m​e​n​t
147
+ */
148
+ align: string;
149
+ /**
150
+ * I​n​d​e​n​t
151
+ */
152
+ indent: string;
153
+ /**
154
+ * F​o​n​t​ ​f​a​m​i​l​y
155
+ */
156
+ fontFamily: string;
157
+ /**
158
+ * F​o​n​t​ ​s​i​z​e
159
+ */
160
+ fontSize: string;
161
+ /**
162
+ * M​o​r​e​ ​s​t​y​l​e
163
+ */
164
+ moreStyle: string;
165
+ /**
166
+ * F​o​n​t​ ​c​o​l​o​r
167
+ */
168
+ fontColor: string;
169
+ /**
170
+ * H​i​g​h​l​i​g​h​t
171
+ */
172
+ highlight: string;
173
+ /**
174
+ * I​m​a​g​e
175
+ */
176
+ image: string;
177
+ /**
178
+ * R​e​m​o​v​e​ ​c​o​l​o​r
179
+ */
180
+ removeColor: string;
181
+ };
182
+ link: {
183
+ /**
184
+ * N​e​w​ ​l​i​n​k
185
+ */
186
+ newLink: string;
187
+ /**
188
+ * L​i​n​k​ ​U​R​L
189
+ */
190
+ url: string;
191
+ /**
192
+ * L​i​n​k​ ​t​i​t​l​e
193
+ */
194
+ title: string;
195
+ /**
196
+ * C​o​p​y​ ​l​i​n​k​ ​t​o​ ​c​l​i​p​b​o​a​r​d
197
+ */
198
+ copy: string;
199
+ /**
200
+ * O​p​e​n​ ​l​i​n​k​ ​i​n​ ​n​e​w​ ​t​a​b
201
+ */
202
+ open: string;
203
+ /**
204
+ * S​a​v​e
205
+ */
206
+ save: string;
207
+ /**
208
+ * R​e​m​o​v​e​ ​l​i​n​k
209
+ */
210
+ unlink: string;
211
+ };
212
+ image: {
213
+ /**
214
+ * F​u​l​l​ ​s​c​r​e​e​n
215
+ */
216
+ view: string;
217
+ /**
218
+ * D​e​l​e​t​e
219
+ */
220
+ remove: string;
221
+ /**
222
+ * P​r​e​v​i​o​u​s
223
+ */
224
+ previous: string;
225
+ /**
226
+ * N​e​x​t
227
+ */
228
+ next: string;
229
+ /**
230
+ * C​l​o​s​e​ ​(​E​s​c​)
231
+ */
232
+ close: string;
233
+ /**
234
+ * T​h​e​ ​i​m​a​g​e​ ​c​a​n​n​o​t​ ​b​e​ ​l​o​a​d​e​d
235
+ */
236
+ loadingError: string;
237
+ /**
238
+ * Z​o​o​m​ ​o​u​t
239
+ */
240
+ zoomOut: string;
241
+ /**
242
+ * Z​o​o​m​ ​i​n
243
+ */
244
+ zoomIn: string;
245
+ };
246
+ codeBlock: {
247
+ /**
248
+ * S​e​l​e​c​t​ ​l​a​n​g​u​a​g​e
249
+ */
250
+ langType: string;
251
+ };
252
+ };
253
+ export type TranslationFunctions = {
254
+ toolbar: {
255
+ /**
256
+ * Undo (Ctrl+Z)
257
+ */
258
+ undo: () => LocalizedString;
259
+ /**
260
+ * Redo (Ctrl+Y)
261
+ */
262
+ redo: () => LocalizedString;
263
+ /**
264
+ * Select all (Ctrl+A)
265
+ */
266
+ selectAll: () => LocalizedString;
267
+ /**
268
+ * Paragraph
269
+ */
270
+ paragraph: () => LocalizedString;
271
+ /**
272
+ * Block quotation
273
+ */
274
+ blockQuote: () => LocalizedString;
275
+ /**
276
+ * Numbered list
277
+ */
278
+ numberedList: () => LocalizedString;
279
+ /**
280
+ * Bulleted list
281
+ */
282
+ bulletedList: () => LocalizedString;
283
+ /**
284
+ * Checklist
285
+ */
286
+ checklist: () => LocalizedString;
287
+ /**
288
+ * Align left
289
+ */
290
+ alignLeft: () => LocalizedString;
291
+ /**
292
+ * Align center
293
+ */
294
+ alignCenter: () => LocalizedString;
295
+ /**
296
+ * Align right
297
+ */
298
+ alignRight: () => LocalizedString;
299
+ /**
300
+ * Align justify
301
+ */
302
+ alignJustify: () => LocalizedString;
303
+ /**
304
+ * Increase indent
305
+ */
306
+ increaseIndent: () => LocalizedString;
307
+ /**
308
+ * Decrease indent
309
+ */
310
+ decreaseIndent: () => LocalizedString;
311
+ /**
312
+ * Bold (Ctrl+B)
313
+ */
314
+ bold: () => LocalizedString;
315
+ /**
316
+ * Italic (Ctrl+I)
317
+ */
318
+ italic: () => LocalizedString;
319
+ /**
320
+ * Underline (Ctrl+U)
321
+ */
322
+ underline: () => LocalizedString;
323
+ /**
324
+ * Strikethrough
325
+ */
326
+ strikethrough: () => LocalizedString;
327
+ /**
328
+ * Superscript
329
+ */
330
+ superscript: () => LocalizedString;
331
+ /**
332
+ * Subscript
333
+ */
334
+ subscript: () => LocalizedString;
335
+ /**
336
+ * Inline code
337
+ */
338
+ code: () => LocalizedString;
339
+ /**
340
+ * Remove format
341
+ */
342
+ removeFormat: () => LocalizedString;
343
+ /**
344
+ * Format painter
345
+ */
346
+ formatPainter: () => LocalizedString;
347
+ /**
348
+ * Link
349
+ */
350
+ link: () => LocalizedString;
351
+ /**
352
+ * Horizontal line
353
+ */
354
+ hr: () => LocalizedString;
355
+ /**
356
+ * Code block
357
+ */
358
+ codeBlock: () => LocalizedString;
359
+ /**
360
+ * Heading
361
+ */
362
+ heading: () => LocalizedString;
363
+ /**
364
+ * Heading 1
365
+ */
366
+ heading1: () => LocalizedString;
367
+ /**
368
+ * Heading 2
369
+ */
370
+ heading2: () => LocalizedString;
371
+ /**
372
+ * Heading 3
373
+ */
374
+ heading3: () => LocalizedString;
375
+ /**
376
+ * Heading 4
377
+ */
378
+ heading4: () => LocalizedString;
379
+ /**
380
+ * Heading 5
381
+ */
382
+ heading5: () => LocalizedString;
383
+ /**
384
+ * Heading 6
385
+ */
386
+ heading6: () => LocalizedString;
387
+ /**
388
+ * List
389
+ */
390
+ list: () => LocalizedString;
391
+ /**
392
+ * Alignment
393
+ */
394
+ align: () => LocalizedString;
395
+ /**
396
+ * Indent
397
+ */
398
+ indent: () => LocalizedString;
399
+ /**
400
+ * Font family
401
+ */
402
+ fontFamily: () => LocalizedString;
403
+ /**
404
+ * Font size
405
+ */
406
+ fontSize: () => LocalizedString;
407
+ /**
408
+ * More style
409
+ */
410
+ moreStyle: () => LocalizedString;
411
+ /**
412
+ * Font color
413
+ */
414
+ fontColor: () => LocalizedString;
415
+ /**
416
+ * Highlight
417
+ */
418
+ highlight: () => LocalizedString;
419
+ /**
420
+ * Image
421
+ */
422
+ image: () => LocalizedString;
423
+ /**
424
+ * Remove color
425
+ */
426
+ removeColor: () => LocalizedString;
427
+ };
428
+ link: {
429
+ /**
430
+ * New link
431
+ */
432
+ newLink: () => LocalizedString;
433
+ /**
434
+ * Link URL
435
+ */
436
+ url: () => LocalizedString;
437
+ /**
438
+ * Link title
439
+ */
440
+ title: () => LocalizedString;
441
+ /**
442
+ * Copy link to clipboard
443
+ */
444
+ copy: () => LocalizedString;
445
+ /**
446
+ * Open link in new tab
447
+ */
448
+ open: () => LocalizedString;
449
+ /**
450
+ * Save
451
+ */
452
+ save: () => LocalizedString;
453
+ /**
454
+ * Remove link
455
+ */
456
+ unlink: () => LocalizedString;
457
+ };
458
+ image: {
459
+ /**
460
+ * Full screen
461
+ */
462
+ view: () => LocalizedString;
463
+ /**
464
+ * Delete
465
+ */
466
+ remove: () => LocalizedString;
467
+ /**
468
+ * Previous
469
+ */
470
+ previous: () => LocalizedString;
471
+ /**
472
+ * Next
473
+ */
474
+ next: () => LocalizedString;
475
+ /**
476
+ * Close (Esc)
477
+ */
478
+ close: () => LocalizedString;
479
+ /**
480
+ * The image cannot be loaded
481
+ */
482
+ loadingError: () => LocalizedString;
483
+ /**
484
+ * Zoom out
485
+ */
486
+ zoomOut: () => LocalizedString;
487
+ /**
488
+ * Zoom in
489
+ */
490
+ zoomIn: () => LocalizedString;
491
+ };
492
+ codeBlock: {
493
+ /**
494
+ * Select language
495
+ */
496
+ langType: () => LocalizedString;
497
+ };
498
+ };
499
+ export type Formatters = {};
500
+ export {};
@@ -0,0 +1,70 @@
1
+ declare const _default: {
2
+ toolbar: {
3
+ undo: string;
4
+ redo: string;
5
+ selectAll: string;
6
+ paragraph: string;
7
+ blockQuote: string;
8
+ numberedList: string;
9
+ bulletedList: string;
10
+ checklist: string;
11
+ alignLeft: string;
12
+ alignCenter: string;
13
+ alignRight: string;
14
+ alignJustify: string;
15
+ increaseIndent: string;
16
+ decreaseIndent: string;
17
+ bold: string;
18
+ italic: string;
19
+ underline: string;
20
+ strikethrough: string;
21
+ superscript: string;
22
+ subscript: string;
23
+ code: string;
24
+ removeFormat: string;
25
+ formatPainter: string;
26
+ link: string;
27
+ hr: string;
28
+ codeBlock: string;
29
+ heading: string;
30
+ heading1: string;
31
+ heading2: string;
32
+ heading3: string;
33
+ heading4: string;
34
+ heading5: string;
35
+ heading6: string;
36
+ list: string;
37
+ align: string;
38
+ indent: string;
39
+ fontFamily: string;
40
+ fontSize: string;
41
+ moreStyle: string;
42
+ fontColor: string;
43
+ highlight: string;
44
+ image: string;
45
+ removeColor: string;
46
+ };
47
+ link: {
48
+ newLink: string;
49
+ url: string;
50
+ title: string;
51
+ copy: string;
52
+ open: string;
53
+ save: string;
54
+ unlink: string;
55
+ };
56
+ image: {
57
+ view: string;
58
+ remove: string;
59
+ previous: string;
60
+ next: string;
61
+ close: string;
62
+ loadingError: string;
63
+ zoomOut: string;
64
+ zoomIn: string;
65
+ };
66
+ codeBlock: {
67
+ langType: string;
68
+ };
69
+ };
70
+ export default _default;
@@ -2,7 +2,7 @@ import './css';
2
2
  import './elements/box';
3
3
  import './elements/bookmark';
4
4
  import { BoxComponent } from './types/box';
5
- import { ToolbarItem, ToolbarMenuItem } from './types/toolbar';
5
+ import { ToolbarItem } from './types/toolbar';
6
6
  import { icons } from './icons';
7
7
  import * as Utils from './utils';
8
8
  import { Nodes } from './models/nodes';
@@ -24,6 +24,8 @@ import { addMark } from './operations/add-mark';
24
24
  import { removeMark } from './operations/remove-mark';
25
25
  import { fixList } from './operations/fix-list';
26
26
  import { insertLink } from './operations/insert-link';
27
+ import { Button } from './ui/button';
28
+ import { Dropdown } from './ui/dropdown';
27
29
  import { Editor } from './editor';
28
30
  import { Toolbar } from './ui/toolbar';
29
- export { Editor, Toolbar, ToolbarItem, ToolbarMenuItem, BoxComponent, icons, Utils, Nodes, Fragment, Range, Box, HTMLParser, TextParser, insertBookmark, toBookmark, insertNode, insertFragment, insertContents, deleteContents, setBlocks, splitBlock, splitMarks, addMark, removeMark, fixList, insertLink, };
31
+ export { Editor, Toolbar, ToolbarItem, BoxComponent, icons, Utils, Nodes, Fragment, Range, Box, HTMLParser, TextParser, insertBookmark, toBookmark, insertNode, insertFragment, insertContents, deleteContents, setBlocks, splitBlock, splitMarks, addMark, removeMark, fixList, insertLink, Button, Dropdown, };
@@ -1,11 +1,23 @@
1
1
  import EventEmitter from 'eventemitter3';
2
- type CommandHandler = (...data: any[]) => void;
2
+ import { AppliedItem } from '../types/object';
3
+ import { Selection } from './selection';
4
+ type CommmandItem = {
5
+ isDisabled?: (AppliedItems: AppliedItem[]) => boolean;
6
+ isSelected?: (appliedItems: AppliedItem[]) => boolean;
7
+ selectedValues?: (AppliedItems: AppliedItem[]) => string[];
8
+ execute: (...data: any[]) => void;
9
+ };
3
10
  export declare class Command {
11
+ private selection;
4
12
  private commandMap;
5
13
  event: EventEmitter;
6
- constructor();
7
- add(name: string, handler: CommandHandler): void;
14
+ constructor(selection: Selection);
15
+ add(name: string, handler: CommmandItem): void;
8
16
  getNames(): string[];
17
+ getItem(name: string): CommmandItem;
18
+ isDisabled(name: string): boolean;
19
+ isSelected(name: string): boolean;
20
+ selectedValues(name: string): string[];
9
21
  execute(name: string, ...data: any[]): void;
10
22
  }
11
23
  export {};
@@ -2,7 +2,6 @@ import type { Editor } from '../editor';
2
2
  type PluginFunction = (editor: Editor) => void;
3
3
  export declare class Plugin {
4
4
  private pluginList;
5
- constructor();
6
5
  add(plugin: PluginFunction): void;
7
6
  loadAll(editor: Editor): void;
8
7
  }
@@ -18,7 +18,6 @@ export declare class Selection {
18
18
  private selection;
19
19
  container: Nodes;
20
20
  range: Range;
21
- appliedItems: AppliedItem[];
22
21
  constructor(container: Nodes);
23
22
  private getRangeFromNativeSelection;
24
23
  addRangeToNativeSelection(): void;
@@ -74,6 +74,7 @@ export declare class Nodes {
74
74
  css(propertyName: KeyValue): this;
75
75
  css(propertyName: string, value: string): this;
76
76
  width(): number;
77
+ innerWidth(): number;
77
78
  height(): number;
78
79
  show(displayType?: string): this;
79
80
  hide(): this;
@@ -0,0 +1,16 @@
1
+ export type DropdownMenuItem = {
2
+ value: string;
3
+ icon?: string;
4
+ text: string;
5
+ };
6
+ export type DropdownItem = {
7
+ name: string;
8
+ icon?: string;
9
+ accentIcon?: string;
10
+ downIcon?: string;
11
+ defaultValue: string;
12
+ tooltip: string;
13
+ width: string;
14
+ menuType: 'list' | 'color';
15
+ menuItems: DropdownMenuItem[];
16
+ };
@@ -1,35 +1,23 @@
1
1
  import type { Editor } from '../editor';
2
+ import { DropdownItem } from './dropdown';
2
3
  import { AppliedItem } from './object';
3
- export type ToolbarMenuItem = {
4
- value: string;
5
- icon?: string;
6
- text: string;
7
- };
8
- export type ButtonItem = {
4
+ export type ToolbarButtonItem = {
9
5
  name: string;
10
6
  type: 'button';
11
7
  icon?: string;
12
8
  tooltip: string;
13
- isSelected?: (appliedItems: AppliedItem[], editor: Editor) => boolean;
14
- isDisabled?: (AppliedItems: AppliedItem[], editor: Editor) => boolean;
9
+ isSelected?: (appliedItems: AppliedItem[]) => boolean;
10
+ isDisabled?: (AppliedItems: AppliedItem[]) => boolean;
15
11
  onClick: (editor: Editor, value: string) => void;
16
12
  };
17
- export type DropdownItem = {
13
+ export type ToolbarDropdownItem = DropdownItem & {
18
14
  name: string;
19
15
  type: 'dropdown';
20
- icon?: string;
21
- accentIcon?: string;
22
- downIcon?: string;
23
- defaultValue: string;
24
- tooltip: string;
25
- width: string;
26
- menuType: 'list' | 'color';
27
- menuItems: ToolbarMenuItem[];
28
- selectedValues?: (appliedItems: AppliedItem[], editor: Editor) => string[];
29
- isDisabled?: (AppliedItems: AppliedItem[], editor: Editor) => boolean;
16
+ selectedValues?: (appliedItems: AppliedItem[]) => string[];
17
+ isDisabled?: (AppliedItems: AppliedItem[]) => boolean;
30
18
  onSelect: (editor: Editor, value: string) => void;
31
19
  };
32
- export type UploadItem = {
20
+ export type ToolbarUploadItem = {
33
21
  name: string;
34
22
  type: 'upload';
35
23
  icon?: string;
@@ -37,4 +25,4 @@ export type UploadItem = {
37
25
  accept?: string;
38
26
  multiple?: boolean;
39
27
  };
40
- export type ToolbarItem = ButtonItem | DropdownItem | UploadItem;
28
+ export type ToolbarItem = ToolbarButtonItem | ToolbarDropdownItem | ToolbarUploadItem;