leksy-editor 2.6.0 → 3.0.0
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 +58 -3
- package/backend.d.ts +2 -0
- package/dist/backend/index.js +2 -0
- package/dist/backend/index.js.map +1 -0
- package/dist/backend/index.mjs +2 -0
- package/dist/backend/index.mjs.map +1 -0
- package/dist/index.css +2 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +478 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +478 -0
- package/dist/index.mjs.map +1 -0
- package/index.d.ts +2 -0
- package/package.json +30 -4
- package/types/backend.d.ts +89 -0
- package/types/index.d.ts +200 -0
- package/constant.js +0 -967
- package/contribution.md +0 -57
- package/gallery.js +0 -107
- package/index.js +0 -1028
- package/plugin.js +0 -1355
- package/style.css +0 -721
- package/tab.js +0 -709
- package/utilities.js +0 -4359
package/index.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leksy-editor",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Leksy Editor is an alternative to traditional WYSIWYG editors, designed primarily for creating mail templates, blogs, and documents without any content manipulation.",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./backend": {
|
|
14
|
+
"types": "./backend.d.ts",
|
|
15
|
+
"import": "./dist/backend/index.mjs",
|
|
16
|
+
"require": "./dist/backend/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"types",
|
|
22
|
+
"index.d.ts",
|
|
23
|
+
"backend.d.ts",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
6
26
|
"directories": {
|
|
7
27
|
"example": "examples"
|
|
8
28
|
},
|
|
9
29
|
"scripts": {
|
|
10
|
-
"
|
|
30
|
+
"build": "tsup",
|
|
31
|
+
"prepublishOnly": "npm run build"
|
|
11
32
|
},
|
|
12
33
|
"repository": {
|
|
13
34
|
"type": "git",
|
|
@@ -17,10 +38,15 @@
|
|
|
17
38
|
"editor",
|
|
18
39
|
"leksy-editor"
|
|
19
40
|
],
|
|
20
|
-
"author": "Agami Technologies",
|
|
41
|
+
"author": "Agami Technologies Pvt Ltd",
|
|
21
42
|
"license": "MIT",
|
|
22
43
|
"dependencies": {
|
|
23
44
|
"diff-dom": "5.2.0",
|
|
45
|
+
"jsdom": "29.1.1",
|
|
24
46
|
"uuid": "13.0.2"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"tsup": "^8.5.1",
|
|
50
|
+
"typescript": "^6.0.3"
|
|
25
51
|
}
|
|
26
52
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { LeksySyncMessage, LeksyTab } from './index';
|
|
2
|
+
|
|
3
|
+
export interface LeksyBackendOptions {
|
|
4
|
+
autoSaveMs?: number;
|
|
5
|
+
cleanMs?: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface LeksyUserParams {
|
|
9
|
+
documentId: string;
|
|
10
|
+
userId: string | number;
|
|
11
|
+
connectionId: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface LeksyContentState {
|
|
15
|
+
content: LeksyTab[] | null;
|
|
16
|
+
isLoaded: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface LeksySetContentOptions {
|
|
20
|
+
dirty?: boolean;
|
|
21
|
+
isRestore?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface LeksyVersion {
|
|
25
|
+
versionId: string;
|
|
26
|
+
startedAt: number;
|
|
27
|
+
endedAt: number | null;
|
|
28
|
+
fromSequence: number;
|
|
29
|
+
toSequence: number;
|
|
30
|
+
users: Array<string | number>;
|
|
31
|
+
changes: unknown[];
|
|
32
|
+
startSnapshot: LeksyTab[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface LeksyVersionFinalizePayload {
|
|
36
|
+
documentId: string;
|
|
37
|
+
versionId: string;
|
|
38
|
+
startSnapshot: LeksyTab[];
|
|
39
|
+
version: LeksyVersion;
|
|
40
|
+
metadata: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface LeksySavePayload {
|
|
44
|
+
documentId: string;
|
|
45
|
+
content: LeksyTab[];
|
|
46
|
+
updatedBy?: string | number;
|
|
47
|
+
metadata: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface LeksyBackendChange {
|
|
51
|
+
sequence: number;
|
|
52
|
+
userId?: string | number;
|
|
53
|
+
timestamp?: number;
|
|
54
|
+
type: string;
|
|
55
|
+
message?: LeksySyncMessage;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface LeksyEditorBackendInstance {
|
|
59
|
+
user: {
|
|
60
|
+
add(params: LeksyUserParams): Promise<void>;
|
|
61
|
+
remove(params: LeksyUserParams): Promise<{ collabEvents: LeksySyncMessage[] } | void>;
|
|
62
|
+
};
|
|
63
|
+
content: {
|
|
64
|
+
get(documentId: string): LeksyContentState;
|
|
65
|
+
set(
|
|
66
|
+
documentId: string,
|
|
67
|
+
content: LeksyTab[],
|
|
68
|
+
metadata?: Record<string, unknown>,
|
|
69
|
+
options?: LeksySetContentOptions
|
|
70
|
+
): void;
|
|
71
|
+
getRuntimeDoms(documentId: string): Record<string, unknown>;
|
|
72
|
+
};
|
|
73
|
+
changes: {
|
|
74
|
+
apply(documentId: string, userId: string | number, message: LeksySyncMessage): Promise<number | null | void>;
|
|
75
|
+
getSince(documentId: string, sequence: number): LeksyBackendChange[] | null;
|
|
76
|
+
getCurrentSequence(documentId: string): number;
|
|
77
|
+
};
|
|
78
|
+
isActive(documentId: string): boolean;
|
|
79
|
+
save(documentId: string): Promise<void>;
|
|
80
|
+
onSave(fn: (payload: LeksySavePayload) => void | Promise<void>): void;
|
|
81
|
+
onVersionFinalize(fn: (payload: LeksyVersionFinalizePayload) => void | Promise<void>): void;
|
|
82
|
+
restore(documentId: string, snapshot: LeksyTab[], changes?: LeksySyncMessage[]): Promise<LeksyTab[]>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default class LeksyEditorBackend {
|
|
86
|
+
static create(options?: LeksyBackendOptions): LeksyEditorBackendInstance;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function create(options?: LeksyBackendOptions): LeksyEditorBackendInstance;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
export type LeksyPluginName =
|
|
2
|
+
| 'undo'
|
|
3
|
+
| 'redo'
|
|
4
|
+
| 'bold'
|
|
5
|
+
| 'underline'
|
|
6
|
+
| 'italic'
|
|
7
|
+
| 'strike'
|
|
8
|
+
| 'font'
|
|
9
|
+
| 'font-size'
|
|
10
|
+
| 'subscript'
|
|
11
|
+
| 'superscript'
|
|
12
|
+
| 'font_color'
|
|
13
|
+
| 'highlight_color'
|
|
14
|
+
| 'remove_font_color'
|
|
15
|
+
| 'remove_highlight_color'
|
|
16
|
+
| 'align_justify'
|
|
17
|
+
| 'align_left'
|
|
18
|
+
| 'align_center'
|
|
19
|
+
| 'align_right'
|
|
20
|
+
| 'ordered_list'
|
|
21
|
+
| 'unordered_list'
|
|
22
|
+
| 'image'
|
|
23
|
+
| 'video'
|
|
24
|
+
| 'table'
|
|
25
|
+
| 'attachment'
|
|
26
|
+
| 'cut'
|
|
27
|
+
| 'copy'
|
|
28
|
+
| 'paste'
|
|
29
|
+
| 'select_all'
|
|
30
|
+
| 'link'
|
|
31
|
+
| 'unlink'
|
|
32
|
+
| 'embed'
|
|
33
|
+
| 'format-block'
|
|
34
|
+
| 'text_style'
|
|
35
|
+
| 'line_height'
|
|
36
|
+
| 'paragraph_style'
|
|
37
|
+
| 'indent'
|
|
38
|
+
| 'outdent'
|
|
39
|
+
| 'horizontal_rule'
|
|
40
|
+
| 'remove_format'
|
|
41
|
+
| 'emoji'
|
|
42
|
+
| 'mention'
|
|
43
|
+
| 'special_character'
|
|
44
|
+
| 'pexels'
|
|
45
|
+
| 'giphy'
|
|
46
|
+
| 'tenor'
|
|
47
|
+
| 'code_view'
|
|
48
|
+
| 'fullscreen'
|
|
49
|
+
| 'print'
|
|
50
|
+
| 'table_of_content'
|
|
51
|
+
| 'find_and_replace';
|
|
52
|
+
|
|
53
|
+
export type LeksyPluginGroup = LeksyPluginName | string | Array<LeksyPluginName | string>;
|
|
54
|
+
|
|
55
|
+
export interface LeksyTab {
|
|
56
|
+
tabTitle: string;
|
|
57
|
+
tabId: string;
|
|
58
|
+
content: string;
|
|
59
|
+
children: LeksyTab[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface LeksyLabelField {
|
|
63
|
+
name: string;
|
|
64
|
+
value: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface LeksyLabel {
|
|
68
|
+
name: string;
|
|
69
|
+
category: string;
|
|
70
|
+
fields: LeksyLabelField[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface LeksyAdditionalFont {
|
|
74
|
+
name: string;
|
|
75
|
+
fontFamily: string;
|
|
76
|
+
links: string[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface LeksyCssVariables {
|
|
80
|
+
primary?: string;
|
|
81
|
+
baseWhite?: string;
|
|
82
|
+
whiteDark?: string;
|
|
83
|
+
shadow?: string;
|
|
84
|
+
resizer?: string;
|
|
85
|
+
resizerBackground?: string;
|
|
86
|
+
mention?: string;
|
|
87
|
+
mentionHighlight?: string;
|
|
88
|
+
dashedBorder?: string;
|
|
89
|
+
tableResizer?: string;
|
|
90
|
+
tableResizerOutline?: string;
|
|
91
|
+
textColor?: string;
|
|
92
|
+
resizerPosition?: string;
|
|
93
|
+
resizerPositionBackground?: string;
|
|
94
|
+
linkColor?: string;
|
|
95
|
+
scrollbarThumb?: string;
|
|
96
|
+
scrollbarTrack?: string;
|
|
97
|
+
[key: string]: string | undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface LeksyCustomPlugin {
|
|
101
|
+
title?: string;
|
|
102
|
+
icon?: string;
|
|
103
|
+
type?: string;
|
|
104
|
+
event?: string;
|
|
105
|
+
command?: string;
|
|
106
|
+
values?: unknown;
|
|
107
|
+
[key: string]: unknown;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface LeksyEditorOptions {
|
|
111
|
+
classPrefix?: string;
|
|
112
|
+
placeholder?: string;
|
|
113
|
+
plugins?: LeksyPluginGroup[];
|
|
114
|
+
labels?: LeksyLabel[];
|
|
115
|
+
customPlugins?: Record<string, LeksyCustomPlugin>;
|
|
116
|
+
spellcheck?: boolean;
|
|
117
|
+
closePluginOnClick?: boolean;
|
|
118
|
+
value?: string | LeksyTab[];
|
|
119
|
+
hideNavigation?: boolean;
|
|
120
|
+
giphyApiKey?: string;
|
|
121
|
+
pexelsApiKey?: string;
|
|
122
|
+
tenorApiKey?: string;
|
|
123
|
+
cssVariables?: LeksyCssVariables;
|
|
124
|
+
disablePastedColorStyles?: boolean;
|
|
125
|
+
removeColorsWhilePasting?: boolean;
|
|
126
|
+
autoHeight?: boolean;
|
|
127
|
+
height?: string;
|
|
128
|
+
maxHeight?: string;
|
|
129
|
+
minHeight?: string;
|
|
130
|
+
iframeStyle?: string;
|
|
131
|
+
disabled?: boolean;
|
|
132
|
+
showTabs?: boolean;
|
|
133
|
+
enableFindAndReplace?: boolean;
|
|
134
|
+
customTooltip?: Record<string, string>;
|
|
135
|
+
customIcon?: Record<string, string>;
|
|
136
|
+
additionalFonts?: LeksyAdditionalFont[];
|
|
137
|
+
onFullScreen?: (isFullScreen: boolean) => void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface LeksyCursor {
|
|
141
|
+
startIndex: number;
|
|
142
|
+
endIndex: number;
|
|
143
|
+
cursorIndex: number;
|
|
144
|
+
isCollapsed: boolean;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface LeksySyncMessage {
|
|
148
|
+
type: string;
|
|
149
|
+
tabId?: string;
|
|
150
|
+
userId?: string;
|
|
151
|
+
userName?: string;
|
|
152
|
+
sequence?: number;
|
|
153
|
+
cursor?: LeksyCursor;
|
|
154
|
+
diff?: unknown;
|
|
155
|
+
tabs?: LeksyTab[];
|
|
156
|
+
editorHTML?: string;
|
|
157
|
+
[key: string]: unknown;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface LeksyChangeHighlight {
|
|
161
|
+
tabId: string;
|
|
162
|
+
route: number[];
|
|
163
|
+
color: string;
|
|
164
|
+
userName: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface LeksyEditorInstance {
|
|
168
|
+
setContents(content: string | LeksyTab[]): void;
|
|
169
|
+
getContents(): LeksyTab[];
|
|
170
|
+
onChange: (tabs: LeksyTab[]) => void;
|
|
171
|
+
onSave: () => void;
|
|
172
|
+
onBlur: (html: string) => void;
|
|
173
|
+
onAttachment: (files: FileList | File[]) => void;
|
|
174
|
+
onLinkClick: (href: string) => void;
|
|
175
|
+
manuplateImage: (type: string, content: string) => string | Promise<string | undefined> | undefined;
|
|
176
|
+
handleFilePicker: (mimeType: string, type: string) => File | string | null | Promise<File | string | null>;
|
|
177
|
+
uploadVideo: (file: File) => string | Promise<string | undefined> | undefined;
|
|
178
|
+
focus(): void;
|
|
179
|
+
getCore(): unknown;
|
|
180
|
+
updateHeight(height: string): void;
|
|
181
|
+
setDisabled(disabled: boolean): void;
|
|
182
|
+
updateCssVariables(variables: LeksyCssVariables): void;
|
|
183
|
+
updateLabels(labels?: LeksyLabel[]): void;
|
|
184
|
+
getLocalCursor(): LeksyCursor;
|
|
185
|
+
onLocalSyncChanges: (message: LeksySyncMessage) => void;
|
|
186
|
+
applyRemoteSyncChanges(message: LeksySyncMessage): void;
|
|
187
|
+
getCurrentTab(): LeksyTab | null;
|
|
188
|
+
parseTabFromHTML(html: string): LeksyTab;
|
|
189
|
+
compare(tabs1: LeksyTab[], tabs2: LeksyTab[]): boolean;
|
|
190
|
+
initRuntimeDoms(runtimeDoms: Record<string, string>): void;
|
|
191
|
+
reloadRuntimeDom(content: string | LeksyTab[], runtimeDoms?: Record<string, string>): void;
|
|
192
|
+
showChangeHighlight(highlights: LeksyChangeHighlight[]): void;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export default class LeksyEditor {
|
|
196
|
+
static create(baseElement: HTMLElement, options?: LeksyEditorOptions): LeksyEditorInstance;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function convertHtmlToText(html: string): string | null;
|
|
200
|
+
export function isHTMLEmpty(html: string): boolean;
|