lakelib 0.0.4 → 0.0.6
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/README.md +2 -2
- package/dist/lake.css +3 -4
- package/dist/lake.min.js +20 -20
- package/dist/lake.min.js.map +1 -1
- package/lib/lake.css +3 -4
- package/lib/lake.js +411 -291
- package/lib/lake.js.map +1 -1
- package/lib/types/editor.d.ts +4 -0
- package/lib/types/managers/command.d.ts +3 -1
- package/lib/types/managers/history.d.ts +1 -1
- package/lib/types/models/range.d.ts +6 -6
- package/lib/types/plugins/escape-key.d.ts +3 -0
- package/lib/types/types/object.d.ts +8 -2
- package/lib/types/ui/toolbar.d.ts +6 -3
- package/lib/types/utils/split-nodes.d.ts +2 -2
- package/package.json +18 -13
package/lib/types/editor.d.ts
CHANGED
|
@@ -11,8 +11,10 @@ import { History } from './managers/history';
|
|
|
11
11
|
import { Keystroke } from './managers/keystroke';
|
|
12
12
|
import { BoxManager } from './managers/box-manager';
|
|
13
13
|
import { Plugin } from './managers/plugin';
|
|
14
|
+
import { Toolbar } from './ui/toolbar';
|
|
14
15
|
type EditorConfig = {
|
|
15
16
|
root: string | Nodes | NativeNode;
|
|
17
|
+
toolbar?: Toolbar;
|
|
16
18
|
value?: string;
|
|
17
19
|
readonly?: boolean;
|
|
18
20
|
spellcheck?: boolean;
|
|
@@ -39,7 +41,9 @@ export declare class Editor {
|
|
|
39
41
|
static box: BoxManager;
|
|
40
42
|
static plugin: Plugin;
|
|
41
43
|
private unsavedInputData;
|
|
44
|
+
private stateData;
|
|
42
45
|
root: Nodes;
|
|
46
|
+
toolbar: Toolbar | undefined;
|
|
43
47
|
config: typeof defaultConfig;
|
|
44
48
|
containerWrapper: Nodes;
|
|
45
49
|
container: Nodes;
|
|
@@ -12,8 +12,10 @@ export declare class Command {
|
|
|
12
12
|
private commandMap;
|
|
13
13
|
event: EventEmitter;
|
|
14
14
|
constructor(selection: Selection);
|
|
15
|
-
add(name: string,
|
|
15
|
+
add(name: string, commandItem: CommmandItem): void;
|
|
16
|
+
delete(name: string): void;
|
|
16
17
|
getNames(): string[];
|
|
18
|
+
has(name: string): boolean;
|
|
17
19
|
getItem(name: string): CommmandItem;
|
|
18
20
|
isDisabled(name: string): boolean;
|
|
19
21
|
isSelected(name: string): boolean;
|
|
@@ -10,9 +10,9 @@ export declare class Range {
|
|
|
10
10
|
get commonAncestor(): Nodes;
|
|
11
11
|
get isCollapsed(): boolean;
|
|
12
12
|
get isBox(): boolean;
|
|
13
|
-
get
|
|
13
|
+
get isBoxStart(): boolean;
|
|
14
14
|
get isBoxCenter(): boolean;
|
|
15
|
-
get
|
|
15
|
+
get isBoxEnd(): boolean;
|
|
16
16
|
get isInsideBox(): boolean;
|
|
17
17
|
get isInoperative(): boolean;
|
|
18
18
|
get(): NativeRange;
|
|
@@ -31,8 +31,8 @@ export declare class Range {
|
|
|
31
31
|
selectNode(node: Nodes): void;
|
|
32
32
|
selectNodeContents(node: Nodes): void;
|
|
33
33
|
selectBox(boxNode: Nodes): void;
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
selectBoxStart(boxNode: Nodes): void;
|
|
35
|
+
selectBoxEnd(boxNode: Nodes): void;
|
|
36
36
|
shrinkBefore(node: Nodes): void;
|
|
37
37
|
shrinkAfter(node: Nodes): void;
|
|
38
38
|
shrink(): void;
|
|
@@ -45,8 +45,8 @@ export declare class Range {
|
|
|
45
45
|
getBoxes(): Nodes[];
|
|
46
46
|
getBlocks(): Nodes[];
|
|
47
47
|
getMarks(hasText?: boolean): Nodes[];
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
getStartText(): string;
|
|
49
|
+
getEndText(): string;
|
|
50
50
|
clone(): Range;
|
|
51
51
|
cloneContents(): DocumentFragment;
|
|
52
52
|
debug(): void;
|
|
@@ -3,8 +3,8 @@ export type KeyValue = {
|
|
|
3
3
|
[key: string]: string;
|
|
4
4
|
};
|
|
5
5
|
export type TwoParts = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
start: Nodes | null;
|
|
7
|
+
end: Nodes | null;
|
|
8
8
|
};
|
|
9
9
|
export type ThreeParts = TwoParts & {
|
|
10
10
|
center: Nodes | null;
|
|
@@ -19,3 +19,9 @@ export type AppliedItem = {
|
|
|
19
19
|
attributes: KeyValue;
|
|
20
20
|
styles: KeyValue;
|
|
21
21
|
};
|
|
22
|
+
export type StateData = {
|
|
23
|
+
appliedItems: AppliedItem[];
|
|
24
|
+
disabledNameMap: Map<string, boolean>;
|
|
25
|
+
selectedNameMap: Map<string, boolean>;
|
|
26
|
+
selectedValuesMap: Map<string, string[]>;
|
|
27
|
+
};
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import type { Editor } from '../editor';
|
|
2
2
|
import { NativeNode } from '../types/native';
|
|
3
|
+
import { StateData } from '../types/object';
|
|
3
4
|
import { ToolbarItem } from '../types/toolbar';
|
|
4
5
|
import { Nodes } from '../models/nodes';
|
|
5
6
|
type ToolbarConfig = {
|
|
6
|
-
editor: Editor;
|
|
7
7
|
root: string | Nodes | NativeNode;
|
|
8
8
|
items?: (string | ToolbarItem)[];
|
|
9
9
|
};
|
|
10
10
|
export declare class Toolbar {
|
|
11
11
|
private items;
|
|
12
|
-
private editor;
|
|
13
12
|
private root;
|
|
13
|
+
private allMenuMap;
|
|
14
|
+
private buttonItemList;
|
|
15
|
+
private dropdownItemList;
|
|
14
16
|
container: Nodes;
|
|
15
17
|
constructor(config: ToolbarConfig);
|
|
16
18
|
private appendDivider;
|
|
17
19
|
private appendButton;
|
|
18
20
|
private appendDropdown;
|
|
19
21
|
private appendUpload;
|
|
20
|
-
|
|
22
|
+
updateState(stateData: StateData): void;
|
|
23
|
+
render(editor: Editor): void;
|
|
21
24
|
}
|
|
22
25
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lakelib",
|
|
3
3
|
"description": "Rich text editor based on the browser",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"author": "Luo Longhao <luolonghao@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "http://lakejs.com",
|
|
@@ -68,33 +68,38 @@
|
|
|
68
68
|
"eslint": "^8.57.0",
|
|
69
69
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
70
70
|
"eslint-config-prettier": "^9.1.0",
|
|
71
|
+
"execa": "^8.0.1",
|
|
71
72
|
"express": "^4.19.2",
|
|
72
73
|
"mocha": "^10.4.0",
|
|
73
74
|
"multer": "1.4.5-lts.1",
|
|
74
75
|
"npm-run-all": "^4.1.5",
|
|
76
|
+
"picocolors": "^1.0.0",
|
|
77
|
+
"prompts": "^2.4.2",
|
|
75
78
|
"puppeteer": "^22.6.2",
|
|
76
79
|
"rimraf": "^5.0.5",
|
|
77
80
|
"rollup": "^4.14.0",
|
|
78
81
|
"rollup-plugin-import-css": "^3.5.0",
|
|
79
82
|
"rollup-plugin-svg-import": "^3.0.0",
|
|
83
|
+
"semver": "^7.6.0",
|
|
80
84
|
"simple-git-hooks": "^2.11.1",
|
|
81
85
|
"sinon": "^17.0.1",
|
|
82
86
|
"tslib": "^2.6.2",
|
|
83
87
|
"typescript": "^5.4.4"
|
|
84
88
|
},
|
|
89
|
+
"simple-git-hooks": {
|
|
90
|
+
"pre-commit": "pnpm lint"
|
|
91
|
+
},
|
|
92
|
+
"packageManager": "pnpm@8.15.6",
|
|
85
93
|
"scripts": {
|
|
86
|
-
"
|
|
87
|
-
"express": "node ./scripts/start-server.mjs",
|
|
88
|
-
"
|
|
89
|
-
"build": "rimraf ./lib
|
|
90
|
-
"
|
|
94
|
+
"dev": "npm-run-all --parallel --print-label dev:express dev:rollup",
|
|
95
|
+
"dev:express": "node ./scripts/start-server.mjs",
|
|
96
|
+
"dev:rollup": "rollup --watch --config rollup.config.mjs",
|
|
97
|
+
"build": "rimraf ./dist ./lib && pnpm build:lake && pnpm build:codemirror",
|
|
98
|
+
"build:lake": "rollup --config rollup.config.mjs",
|
|
99
|
+
"build:codemirror": "rollup --config rollup.config.mjs --codemirror",
|
|
91
100
|
"i18n": "typesafe-i18n --no-watch",
|
|
92
101
|
"lint": "eslint . --config .eslintrc.cjs --ext \".ts,.js,.cjs,.mjs\"",
|
|
93
102
|
"test": "node ./scripts/run-tests.mjs",
|
|
94
|
-
"
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
"pre-commit": "pnpm lint"
|
|
98
|
-
},
|
|
99
|
-
"packageManager": "pnpm@8.15.6"
|
|
100
|
-
}
|
|
103
|
+
"release": "node ./scripts/release.mjs"
|
|
104
|
+
}
|
|
105
|
+
}
|