lakelib 0.2.1 → 0.2.2

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,3 @@
1
+ import { BoxComponent } from '../types/box';
2
+ declare const _default: BoxComponent;
3
+ export default _default;
@@ -6,6 +6,7 @@ import './box.css';
6
6
  import './button.css';
7
7
  import './dropdown.css';
8
8
  import './popup.css';
9
+ import './menu.css';
9
10
  import './resizer.css';
10
11
  import './format-painter.css';
11
12
  import './heading.css';
@@ -20,5 +21,6 @@ import './video.css';
20
21
  import './file.css';
21
22
  import './emoji.css';
22
23
  import './equation.css';
23
- import './toolbar.css';
24
+ import './mention.css';
24
25
  import './slash.css';
26
+ import './toolbar.css';
@@ -50,7 +50,6 @@ export declare class Editor {
50
50
  containerWrapper: Nodes;
51
51
  container: Nodes;
52
52
  overlayContainer: Nodes;
53
- popupContainer: Nodes;
54
53
  isComposing: boolean;
55
54
  readonly: boolean;
56
55
  event: EventEmitter;
@@ -59,14 +58,13 @@ export declare class Editor {
59
58
  history: History;
60
59
  keystroke: Keystroke;
61
60
  box: BoxManager;
61
+ popup: any;
62
62
  constructor(config: EditorConfig);
63
63
  private copyListener;
64
64
  private cutListener;
65
65
  private pasteListener;
66
66
  private selectionchangeListener;
67
67
  private clickListener;
68
- private resizeListener;
69
- private scrollListener;
70
68
  private updateSelectionRange;
71
69
  private updateBoxSelectionStyle;
72
70
  private emitStateChangeEvent;
@@ -4,6 +4,7 @@ import './elements/bookmark';
4
4
  import { BoxComponent, BoxValue } from './types/box';
5
5
  import { ToolbarItem } from './types/toolbar';
6
6
  import { DropdownMenuItem } from './types/dropdown';
7
+ import { MentionItem } from './types/mention';
7
8
  import { SlashItem } from './types/slash';
8
9
  import { icons } from './icons';
9
10
  import * as Utils from './utils';
@@ -31,4 +32,4 @@ import { Button } from './ui/button';
31
32
  import { Dropdown } from './ui/dropdown';
32
33
  import { Editor } from './editor';
33
34
  import { Toolbar } from './ui/toolbar';
34
- export { Editor, Toolbar, ToolbarItem, DropdownMenuItem, SlashItem, BoxComponent, BoxValue, Button, Dropdown, icons, Utils, Nodes, Fragment, Range, Box, HTMLParser, TextParser, insertBookmark, toBookmark, insertNode, insertFragment, deleteContents, setBlocks, splitBlock, splitMarks, addMark, removeMark, fixList, insertLink, insertBox, removeBox, };
35
+ export { Editor, Toolbar, ToolbarItem, DropdownMenuItem, MentionItem, SlashItem, BoxComponent, BoxValue, Button, Dropdown, icons, Utils, Nodes, Fragment, Range, Box, HTMLParser, TextParser, insertBookmark, toBookmark, insertNode, insertFragment, deleteContents, setBlocks, splitBlock, splitMarks, addMark, removeMark, fixList, insertLink, insertBox, removeBox, };
@@ -49,6 +49,7 @@ export declare class Range {
49
49
  getMarks(hasText?: boolean): Nodes[];
50
50
  getStartText(): string;
51
51
  getEndText(): string;
52
+ getCharacterRange(character: string): Range | null;
52
53
  clone(): Range;
53
54
  cloneContents(): DocumentFragment;
54
55
  info(): void;
@@ -1,3 +1,3 @@
1
1
  import { type Editor } from '..';
2
- declare const _default: (editor: Editor) => void;
2
+ declare const _default: (editor: Editor) => (() => void) | undefined;
3
3
  export default _default;
@@ -0,0 +1,3 @@
1
+ import type { Editor } from '..';
2
+ declare const _default: (editor: Editor) => (() => void) | undefined;
3
+ export default _default;
@@ -1,4 +1,3 @@
1
- import type { Nodes } from '../models/nodes';
2
1
  import type { Box } from '../models/box';
3
2
  import { TranslationFunctions } from '../i18n/types';
4
3
  import { DropdownItem } from './dropdown';
@@ -21,10 +20,3 @@ export type BoxToolbarDropdownItem = DropdownItem & {
21
20
  };
22
21
  export type BoxToolbarItem = BoxToolbarButtonItem | BoxToolbarDropdownItem;
23
22
  export type BoxToolbarPlacement = 'top' | 'bottom';
24
- export type BoxToolbarConfig = {
25
- root: Nodes;
26
- box: Box;
27
- items: ('|' | BoxToolbarItem)[];
28
- locale?: TranslationFunctions;
29
- placement?: BoxToolbarPlacement;
30
- };
@@ -1,4 +1,7 @@
1
1
  import { TranslationFunctions } from '../i18n/types';
2
+ export type DropdownLocation = 'local' | 'global';
3
+ export type DropdownDirection = 'top' | 'bottom' | 'auto';
4
+ export type DropdownMenuType = 'list' | 'icon' | 'character' | 'color';
2
5
  export type DropdownMenuItem = {
3
6
  value: string;
4
7
  icon?: string;
@@ -12,7 +15,7 @@ export type DropdownItem = {
12
15
  defaultValue?: string;
13
16
  tooltip: string | ((locale: TranslationFunctions) => string);
14
17
  width?: string;
15
- menuType: 'list' | 'icon' | 'character' | 'color';
18
+ menuType: DropdownMenuType;
16
19
  menuItems: DropdownMenuItem[];
17
20
  menuWidth?: string;
18
21
  menuHeight?: string;
@@ -0,0 +1,6 @@
1
+ export type MentionItem = {
2
+ id: string;
3
+ name: string;
4
+ nickname?: string;
5
+ avatar?: string;
6
+ };
@@ -1,5 +1,5 @@
1
1
  export type BeforeUploadFileType = File | Blob | boolean | string;
2
- export type UploadRequestMethod = 'POST' | 'PUT' | 'PATCH' | 'post' | 'put' | 'patch';
2
+ export type UploadRequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH';
3
3
  export type UploadRequestHeader = Record<string, string>;
4
4
  export interface UploadRequestError extends Error {
5
5
  status?: number;
@@ -9,7 +9,7 @@ export interface UploadRequestError extends Error {
9
9
  export interface UploadRequestOption<T = any> {
10
10
  method: UploadRequestMethod;
11
11
  action: string;
12
- file: Exclude<BeforeUploadFileType, File | boolean> | File;
12
+ file?: Exclude<BeforeUploadFileType, File | boolean> | File;
13
13
  onSuccess?: (body: T, xhr?: XMLHttpRequest) => void;
14
14
  onProgress?: (event: ProgressEvent) => void;
15
15
  onError?: (event: UploadRequestError | ProgressEvent, body?: T) => void;
@@ -1,7 +1,14 @@
1
- import { BoxToolbarConfig } from '../types/box-toolbar';
1
+ import { TranslationFunctions } from '../i18n/types';
2
+ import { BoxToolbarItem, BoxToolbarPlacement } from '../types/box-toolbar';
2
3
  import { Nodes } from '../models/nodes';
4
+ import { Box } from '../models/box';
5
+ type BoxToolbarConfig = {
6
+ box: Box;
7
+ items: ('|' | BoxToolbarItem)[];
8
+ locale?: TranslationFunctions;
9
+ placement?: BoxToolbarPlacement;
10
+ };
3
11
  export declare class BoxToolbar {
4
- private root;
5
12
  private box;
6
13
  private items;
7
14
  private locale;
@@ -14,7 +21,10 @@ export declare class BoxToolbar {
14
21
  private appendDivider;
15
22
  private appendButton;
16
23
  private appendDropdown;
17
- position(): void;
24
+ private scrollListener;
25
+ private resizeListener;
26
+ updatePosition(): void;
18
27
  render(): void;
19
28
  unmount(): void;
20
29
  }
30
+ export {};
@@ -1,17 +1,21 @@
1
1
  import { TranslationFunctions } from '../i18n/types';
2
- import { DropdownItem, DropdownMenuItem } from '../types/dropdown';
2
+ import { DropdownLocation, DropdownDirection, DropdownItem, DropdownMenuItem } from '../types/dropdown';
3
3
  import { Nodes } from '../models/nodes';
4
4
  type DropdownConfig = DropdownItem & {
5
5
  root: Nodes;
6
6
  locale?: TranslationFunctions;
7
7
  tabIndex?: number;
8
- placement?: 'top' | 'bottom';
8
+ location?: DropdownLocation;
9
+ direction?: DropdownDirection;
9
10
  onSelect: (value: string) => void;
10
11
  };
11
12
  export declare class Dropdown {
12
13
  private config;
13
14
  private root;
14
15
  private locale;
16
+ private location;
17
+ private direction;
18
+ private menuNode;
15
19
  node: Nodes;
16
20
  constructor(config: DropdownConfig);
17
21
  static getValue(node: Nodes): string[];
@@ -19,10 +23,13 @@ export declare class Dropdown {
19
23
  static getMenuMap(menuItems: DropdownMenuItem[], locale: TranslationFunctions): Map<string, string>;
20
24
  private updateColorAccent;
21
25
  private apppendMenuItems;
22
- private documentClickListener;
26
+ private clickListener;
27
+ private scrollListener;
28
+ private resizeListener;
29
+ private appendMenu;
30
+ private updatePosition;
23
31
  private showMenu;
24
32
  private hideMenu;
25
- private bindEvents;
26
33
  render(): void;
27
34
  unmount(): void;
28
35
  }
@@ -1,29 +1,31 @@
1
1
  import { TranslationFunctions } from '../i18n/types';
2
2
  import { Nodes } from '../models/nodes';
3
3
  type LinkPopupConfig = {
4
- root: Nodes;
5
4
  locale?: TranslationFunctions;
6
5
  onCopy?: (error: boolean) => void;
7
6
  onSave?: (node: Nodes) => void;
8
7
  onRemove?: (node: Nodes) => void;
8
+ onShow?: () => void;
9
+ onHide?: () => void;
9
10
  };
10
11
  export declare class LinkPopup {
11
12
  private config;
12
- private root;
13
13
  private locale;
14
14
  private linkNode;
15
15
  container: Nodes;
16
- constructor(config: LinkPopupConfig);
16
+ constructor(config?: LinkPopupConfig);
17
17
  private writeClipboardText;
18
18
  private appendCopyButton;
19
19
  private appendOpenButton;
20
20
  private appendSaveButton;
21
21
  private appendUnlinkButton;
22
+ private scrollListener;
23
+ private resizeListener;
22
24
  get visible(): boolean;
23
25
  save(): void;
24
26
  position(): void;
25
- render(): void;
26
27
  show(linkNode: Nodes): void;
27
28
  hide(): void;
29
+ unmount(): void;
28
30
  }
29
31
  export {};
@@ -0,0 +1,14 @@
1
+ import { MentionItem } from '../types/mention';
2
+ import { Nodes } from '../models/nodes';
3
+ import { Menu, MenuConfig } from './menu';
4
+ type OnSelect = (event: Event, item: MentionItem) => void;
5
+ type MentionMenuConfig = MenuConfig<MentionItem> & {
6
+ onSelect?: OnSelect;
7
+ };
8
+ export declare class MentionMenu extends Menu<MentionItem> {
9
+ private onSelect;
10
+ constructor(config: MentionMenuConfig);
11
+ protected getItemNode(item: MentionItem): Nodes;
12
+ protected search(keyword: string): MentionItem[];
13
+ }
14
+ export {};
@@ -0,0 +1,33 @@
1
+ import { Nodes } from '../models/nodes';
2
+ import { Range } from '../models/range';
3
+ export type MenuConfig<Item> = {
4
+ items: Item[];
5
+ onShow?: () => void;
6
+ onHide?: () => void;
7
+ };
8
+ export declare abstract class Menu<Item> {
9
+ private horizontalDirection;
10
+ private verticalDirection;
11
+ private onShow;
12
+ private onHide;
13
+ protected items: Item[];
14
+ protected range: Range | null;
15
+ protected noMouseEvent: boolean;
16
+ container: Nodes;
17
+ constructor(config: MenuConfig<Item>);
18
+ protected abstract getItemNode(item: Item): Nodes;
19
+ protected abstract search(keyword: string): Item[];
20
+ private appendItemNode;
21
+ private appendItems;
22
+ private selectFirstItemNodeIfNeeded;
23
+ private keydownListener;
24
+ private clickListener;
25
+ private scrollListener;
26
+ private resizeListener;
27
+ private updatePosition;
28
+ get visible(): boolean;
29
+ update(keyword: string): void;
30
+ show(range: Range, keyword?: string): void;
31
+ hide(): void;
32
+ unmount(): void;
33
+ }
@@ -0,0 +1,18 @@
1
+ import { TranslationFunctions } from '../i18n/types';
2
+ import { SlashItem } from '../types/slash';
3
+ import { Nodes } from '../models/nodes';
4
+ import { Menu, MenuConfig } from './menu';
5
+ type OnSelect = (event: Event, item: SlashItem, fileNode?: Nodes) => void;
6
+ type SlashMenuConfig = MenuConfig<string | SlashItem> & {
7
+ locale?: TranslationFunctions;
8
+ onSelect?: OnSelect;
9
+ };
10
+ export declare class SlashMenu extends Menu<string | SlashItem> {
11
+ private locale;
12
+ private onSelect;
13
+ constructor(config: SlashMenuConfig);
14
+ private getItem;
15
+ protected getItemNode(name: string | SlashItem): Nodes;
16
+ protected search(keyword: string): (string | SlashItem)[];
17
+ }
18
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lakelib",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Lake is a browser-based rich text editor designed for creating content such as blogs, comments, and emails.",
5
5
  "keywords": [
6
6
  "rich text",
@@ -1,36 +0,0 @@
1
- import type { Editor } from '../editor';
2
- import { SlashItem } from '../types/slash';
3
- import { Nodes } from '../models/nodes';
4
- import { Range } from '../models/range';
5
- type SlashPopupConfig = {
6
- editor: Editor;
7
- items: (string | SlashItem)[];
8
- };
9
- export declare class SlashPopup {
10
- private editor;
11
- private items;
12
- private root;
13
- private range;
14
- private noMouseEvent;
15
- private keyword;
16
- private horizontalDirection;
17
- private verticalDirection;
18
- container: Nodes;
19
- constructor(config: SlashPopupConfig);
20
- private getItem;
21
- private emptyBlock;
22
- private appendItem;
23
- private keydownListener;
24
- private clickListener;
25
- private scrollListener;
26
- private resizeListener;
27
- get visible(): boolean;
28
- search(keyword: string): (string | SlashItem)[];
29
- position(keepDirection?: boolean): void;
30
- render(): void;
31
- update(keyword?: string | null): void;
32
- show(range: Range, keyword?: string): void;
33
- hide(): void;
34
- unmount(): void;
35
- }
36
- export {};