oneuxi-editor 1.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/dist/index.d.mts +382 -0
- package/dist/index.d.ts +382 -0
- package/dist/index.js +2270 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2243 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +518 -0
- package/package.json +86 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import React$1, { ComponentType } from 'react';
|
|
2
|
+
import { LexicalEditor } from 'lexical';
|
|
3
|
+
|
|
4
|
+
type EditorOutput = "html" | "json" | "text";
|
|
5
|
+
interface EditorJSON {
|
|
6
|
+
root: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
interface EditorUpdate {
|
|
9
|
+
html: string;
|
|
10
|
+
text: string;
|
|
11
|
+
json: EditorJSON;
|
|
12
|
+
isEmpty: boolean;
|
|
13
|
+
}
|
|
14
|
+
type ThemeMode = "light" | "dark" | "system";
|
|
15
|
+
interface EditorThemeObject {
|
|
16
|
+
mode?: ThemeMode;
|
|
17
|
+
primary?: string;
|
|
18
|
+
primaryForeground?: string;
|
|
19
|
+
background?: string;
|
|
20
|
+
surface?: string;
|
|
21
|
+
text?: string;
|
|
22
|
+
textMuted?: string;
|
|
23
|
+
border?: string;
|
|
24
|
+
hover?: string;
|
|
25
|
+
active?: string;
|
|
26
|
+
selection?: string;
|
|
27
|
+
codeBg?: string;
|
|
28
|
+
toolbarBg?: string;
|
|
29
|
+
toolbarBorder?: string;
|
|
30
|
+
popupBg?: string;
|
|
31
|
+
radius?: string;
|
|
32
|
+
shadow?: string;
|
|
33
|
+
fontFamily?: string;
|
|
34
|
+
fontSize?: string;
|
|
35
|
+
}
|
|
36
|
+
type EditorTheme = ThemeMode | EditorThemeObject;
|
|
37
|
+
interface EditorRef {
|
|
38
|
+
focus(): void;
|
|
39
|
+
blur(): void;
|
|
40
|
+
clear(): void;
|
|
41
|
+
getHTML(): string;
|
|
42
|
+
setHTML(html: string): void;
|
|
43
|
+
getText(): string;
|
|
44
|
+
getJSON(): EditorJSON;
|
|
45
|
+
setJSON(json: EditorJSON): void;
|
|
46
|
+
isEmpty(): boolean;
|
|
47
|
+
isDirty(): boolean;
|
|
48
|
+
markClean(): void;
|
|
49
|
+
undo(): void;
|
|
50
|
+
redo(): void;
|
|
51
|
+
}
|
|
52
|
+
type BuiltInToolbarItem = "undo" | "redo" | "|" | "heading" | "bold" | "italic" | "underline" | "strike" | "code" | "subscript" | "superscript" | "clearFormatting" | "align" | "bulletList" | "orderedList" | "checkList" | "indent" | "outdent" | "link" | "image" | "table" | "media" | "file" | "codeBlock" | "blockquote" | "hr" | "sourceMode" | "findReplace" | "fullscreen";
|
|
53
|
+
type ToolbarItem = BuiltInToolbarItem | ComponentType;
|
|
54
|
+
type ToolbarConfig = ToolbarItem[] | false;
|
|
55
|
+
interface CustomIconMap {
|
|
56
|
+
bold?: ComponentType;
|
|
57
|
+
italic?: ComponentType;
|
|
58
|
+
underline?: ComponentType;
|
|
59
|
+
strike?: ComponentType;
|
|
60
|
+
code?: ComponentType;
|
|
61
|
+
subscript?: ComponentType;
|
|
62
|
+
superscript?: ComponentType;
|
|
63
|
+
clearFormatting?: ComponentType;
|
|
64
|
+
heading?: ComponentType;
|
|
65
|
+
paragraph?: ComponentType;
|
|
66
|
+
bulletList?: ComponentType;
|
|
67
|
+
orderedList?: ComponentType;
|
|
68
|
+
checkList?: ComponentType;
|
|
69
|
+
indent?: ComponentType;
|
|
70
|
+
outdent?: ComponentType;
|
|
71
|
+
alignLeft?: ComponentType;
|
|
72
|
+
alignCenter?: ComponentType;
|
|
73
|
+
alignRight?: ComponentType;
|
|
74
|
+
alignJustify?: ComponentType;
|
|
75
|
+
link?: ComponentType;
|
|
76
|
+
image?: ComponentType;
|
|
77
|
+
table?: ComponentType;
|
|
78
|
+
media?: ComponentType;
|
|
79
|
+
file?: ComponentType;
|
|
80
|
+
codeBlock?: ComponentType;
|
|
81
|
+
blockquote?: ComponentType;
|
|
82
|
+
hr?: ComponentType;
|
|
83
|
+
undo?: ComponentType;
|
|
84
|
+
redo?: ComponentType;
|
|
85
|
+
sourceMode?: ComponentType;
|
|
86
|
+
findReplace?: ComponentType;
|
|
87
|
+
fullscreen?: ComponentType;
|
|
88
|
+
}
|
|
89
|
+
interface HTMLPolicy {
|
|
90
|
+
allowedTags?: string[];
|
|
91
|
+
allowedAttributes?: Record<string, string[]>;
|
|
92
|
+
}
|
|
93
|
+
interface AutosaveConfig {
|
|
94
|
+
delay?: number;
|
|
95
|
+
onSave: (data: {
|
|
96
|
+
html: string;
|
|
97
|
+
json: EditorJSON;
|
|
98
|
+
text: string;
|
|
99
|
+
}) => Promise<void> | void;
|
|
100
|
+
}
|
|
101
|
+
interface ImageUploadResult {
|
|
102
|
+
src: string;
|
|
103
|
+
alt?: string;
|
|
104
|
+
width?: number;
|
|
105
|
+
height?: number;
|
|
106
|
+
}
|
|
107
|
+
type ImageUploadHandler = (file: File) => Promise<ImageUploadResult>;
|
|
108
|
+
interface FileUploadResult {
|
|
109
|
+
url: string;
|
|
110
|
+
name: string;
|
|
111
|
+
size?: number;
|
|
112
|
+
}
|
|
113
|
+
type FileUploadHandler = (file: File) => Promise<FileUploadResult>;
|
|
114
|
+
interface EditorExtension {
|
|
115
|
+
name: string;
|
|
116
|
+
nodes?: Array<unknown>;
|
|
117
|
+
plugins?: Array<ComponentType>;
|
|
118
|
+
commands?: Array<{
|
|
119
|
+
name: string;
|
|
120
|
+
action: (editor: unknown) => void;
|
|
121
|
+
}>;
|
|
122
|
+
toolbarItems?: ToolbarItem[];
|
|
123
|
+
options?: Record<string, any>;
|
|
124
|
+
}
|
|
125
|
+
interface EditorProps {
|
|
126
|
+
id?: string;
|
|
127
|
+
className?: string;
|
|
128
|
+
style?: React.CSSProperties;
|
|
129
|
+
"data-testid"?: string;
|
|
130
|
+
value?: string;
|
|
131
|
+
defaultValue?: string;
|
|
132
|
+
output?: EditorOutput;
|
|
133
|
+
placeholder?: string;
|
|
134
|
+
readOnly?: boolean;
|
|
135
|
+
disabled?: boolean;
|
|
136
|
+
theme?: EditorTheme;
|
|
137
|
+
toolbar?: ToolbarConfig;
|
|
138
|
+
bubbleToolbar?: ToolbarConfig;
|
|
139
|
+
icons?: CustomIconMap;
|
|
140
|
+
extensions?: EditorExtension[];
|
|
141
|
+
preset?: "basic" | "full";
|
|
142
|
+
sourceMode?: boolean;
|
|
143
|
+
fullscreen?: boolean;
|
|
144
|
+
characterCount?: boolean;
|
|
145
|
+
wordCount?: boolean;
|
|
146
|
+
maxLength?: number;
|
|
147
|
+
html?: HTMLPolicy;
|
|
148
|
+
autosave?: AutosaveConfig;
|
|
149
|
+
onChange?: (output: string) => void;
|
|
150
|
+
onUpdate?: (update: EditorUpdate) => void;
|
|
151
|
+
onFocus?: () => void;
|
|
152
|
+
onBlur?: () => void;
|
|
153
|
+
onReady?: () => void;
|
|
154
|
+
onError?: (error: Error) => void;
|
|
155
|
+
onDirtyChange?: (isDirty: boolean) => void;
|
|
156
|
+
onCharacterCountChange?: (count: number) => void;
|
|
157
|
+
onUploadStart?: () => void;
|
|
158
|
+
onUploadSuccess?: (result: ImageUploadResult | FileUploadResult) => void;
|
|
159
|
+
onUploadError?: (error: Error) => void;
|
|
160
|
+
}
|
|
161
|
+
interface SlashCommandItem {
|
|
162
|
+
id: string;
|
|
163
|
+
title: string;
|
|
164
|
+
description?: string;
|
|
165
|
+
icon?: ComponentType;
|
|
166
|
+
action: (editor: any) => void;
|
|
167
|
+
}
|
|
168
|
+
interface MentionUser {
|
|
169
|
+
id: string;
|
|
170
|
+
name: string;
|
|
171
|
+
username?: string;
|
|
172
|
+
avatar?: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
declare const Editor: React$1.ForwardRefExoticComponent<EditorProps & React$1.RefAttributes<EditorRef>>;
|
|
176
|
+
|
|
177
|
+
interface EditorActiveStates {
|
|
178
|
+
isBold: boolean;
|
|
179
|
+
isItalic: boolean;
|
|
180
|
+
isUnderline: boolean;
|
|
181
|
+
isStrikethrough: boolean;
|
|
182
|
+
isCode: boolean;
|
|
183
|
+
isSubscript: boolean;
|
|
184
|
+
isSuperscript: boolean;
|
|
185
|
+
isLink: boolean;
|
|
186
|
+
isH1: boolean;
|
|
187
|
+
isH2: boolean;
|
|
188
|
+
isH3: boolean;
|
|
189
|
+
isH4: boolean;
|
|
190
|
+
isH5: boolean;
|
|
191
|
+
isH6: boolean;
|
|
192
|
+
isParagraph: boolean;
|
|
193
|
+
isBulletList: boolean;
|
|
194
|
+
isOrderedList: boolean;
|
|
195
|
+
isCheckList: boolean;
|
|
196
|
+
isBlockquote: boolean;
|
|
197
|
+
isCodeBlock: boolean;
|
|
198
|
+
isAlignLeft: boolean;
|
|
199
|
+
isAlignCenter: boolean;
|
|
200
|
+
isAlignRight: boolean;
|
|
201
|
+
isAlignJustify: boolean;
|
|
202
|
+
canUndo: boolean;
|
|
203
|
+
canRedo: boolean;
|
|
204
|
+
}
|
|
205
|
+
interface EditorContextValue {
|
|
206
|
+
editor: LexicalEditor | null;
|
|
207
|
+
activeStates: EditorActiveStates;
|
|
208
|
+
icons?: CustomIconMap;
|
|
209
|
+
toggleBold: () => void;
|
|
210
|
+
toggleItalic: () => void;
|
|
211
|
+
toggleUnderline: () => void;
|
|
212
|
+
toggleStrikethrough: () => void;
|
|
213
|
+
toggleCode: () => void;
|
|
214
|
+
toggleSubscript: () => void;
|
|
215
|
+
toggleSuperscript: () => void;
|
|
216
|
+
clearFormatting: () => void;
|
|
217
|
+
setHeading: (heading: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p") => void;
|
|
218
|
+
toggleBlockquote: () => void;
|
|
219
|
+
insertHR: () => void;
|
|
220
|
+
toggleBulletList: () => void;
|
|
221
|
+
toggleOrderedList: () => void;
|
|
222
|
+
toggleCheckList: () => void;
|
|
223
|
+
indent: () => void;
|
|
224
|
+
outdent: () => void;
|
|
225
|
+
setAlignment: (align: "left" | "center" | "right" | "justify") => void;
|
|
226
|
+
insertLink: (url: string, target?: string, title?: string) => void;
|
|
227
|
+
removeLink: () => void;
|
|
228
|
+
insertTable: (rows?: number, cols?: number) => void;
|
|
229
|
+
insertImage: (src: string, alt?: string, width?: number, height?: number) => void;
|
|
230
|
+
insertCodeBlock: (language?: string) => void;
|
|
231
|
+
undo: () => void;
|
|
232
|
+
redo: () => void;
|
|
233
|
+
focus: () => void;
|
|
234
|
+
blur: () => void;
|
|
235
|
+
clear: () => void;
|
|
236
|
+
getHTML: () => string;
|
|
237
|
+
setHTML: (html: string) => void;
|
|
238
|
+
getText: () => string;
|
|
239
|
+
getJSON: () => EditorJSON;
|
|
240
|
+
setJSON: (json: EditorJSON) => void;
|
|
241
|
+
isEmpty: () => boolean;
|
|
242
|
+
isDirty: () => boolean;
|
|
243
|
+
markClean: () => void;
|
|
244
|
+
isFullscreen: boolean;
|
|
245
|
+
toggleFullscreen: () => void;
|
|
246
|
+
isSourceMode: boolean;
|
|
247
|
+
toggleSourceMode: () => void;
|
|
248
|
+
}
|
|
249
|
+
declare function useEditor(): EditorContextValue;
|
|
250
|
+
|
|
251
|
+
interface ExtensionConfig<Options = Record<string, unknown>> {
|
|
252
|
+
name: string;
|
|
253
|
+
nodes?: Array<unknown>;
|
|
254
|
+
plugins?: Array<ComponentType>;
|
|
255
|
+
commands?: Array<{
|
|
256
|
+
name: string;
|
|
257
|
+
action: (editor: unknown) => void;
|
|
258
|
+
}>;
|
|
259
|
+
toolbarItems?: ToolbarItem[];
|
|
260
|
+
configure?: (options?: Options) => EditorExtension;
|
|
261
|
+
}
|
|
262
|
+
declare function createExtension<Options = Record<string, unknown>>(config: ExtensionConfig<Options>): EditorExtension & {
|
|
263
|
+
configure: (options?: Options) => EditorExtension;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
interface ToolbarProps {
|
|
267
|
+
config?: ToolbarConfig;
|
|
268
|
+
imageUploader?: ImageUploadHandler;
|
|
269
|
+
}
|
|
270
|
+
declare function Toolbar({ config, imageUploader }: ToolbarProps): React$1.JSX.Element | null;
|
|
271
|
+
|
|
272
|
+
interface BubbleToolbarProps {
|
|
273
|
+
config?: ToolbarConfig;
|
|
274
|
+
}
|
|
275
|
+
declare function BubbleToolbar({ config }: BubbleToolbarProps): React$1.JSX.Element | null;
|
|
276
|
+
|
|
277
|
+
declare const DefaultIcons: {
|
|
278
|
+
bold: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
279
|
+
italic: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
280
|
+
underline: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
281
|
+
strike: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
282
|
+
code: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
283
|
+
subscript: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
284
|
+
superscript: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
285
|
+
clearFormatting: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
286
|
+
heading: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
287
|
+
paragraph: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
288
|
+
bulletList: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
289
|
+
orderedList: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
290
|
+
checkList: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
291
|
+
indent: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
292
|
+
outdent: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
293
|
+
alignLeft: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
294
|
+
alignCenter: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
295
|
+
alignRight: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
296
|
+
alignJustify: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
297
|
+
link: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
298
|
+
image: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
299
|
+
table: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
300
|
+
media: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
301
|
+
file: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
302
|
+
codeBlock: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
303
|
+
blockquote: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
304
|
+
hr: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
305
|
+
undo: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
306
|
+
redo: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
307
|
+
sourceMode: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
308
|
+
findReplace: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
309
|
+
fullscreen: (props: React$1.SVGProps<SVGSVGElement>) => React$1.JSX.Element;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
interface ImageExtensionOptions {
|
|
313
|
+
upload?: ImageUploadHandler;
|
|
314
|
+
maxSize?: number;
|
|
315
|
+
allowedTypes?: string[];
|
|
316
|
+
}
|
|
317
|
+
declare const ImageExtension: EditorExtension & {
|
|
318
|
+
configure: (options?: ImageExtensionOptions | undefined) => EditorExtension;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
declare const TableExtension: EditorExtension & {
|
|
322
|
+
configure: (options?: Record<string, unknown> | undefined) => EditorExtension;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
declare const CodeExtension: EditorExtension & {
|
|
326
|
+
configure: (options?: Record<string, unknown> | undefined) => EditorExtension;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
interface MediaExtensionOptions {
|
|
330
|
+
youtube?: boolean;
|
|
331
|
+
allowedDomains?: string[];
|
|
332
|
+
}
|
|
333
|
+
declare const MediaExtension: EditorExtension & {
|
|
334
|
+
configure: (options?: MediaExtensionOptions | undefined) => EditorExtension;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
interface FileExtensionOptions {
|
|
338
|
+
upload?: FileUploadHandler;
|
|
339
|
+
}
|
|
340
|
+
declare const FileExtension: EditorExtension & {
|
|
341
|
+
configure: (options?: FileExtensionOptions | undefined) => EditorExtension;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
interface MentionExtensionOptions {
|
|
345
|
+
trigger?: string;
|
|
346
|
+
search?: (query: string) => Promise<MentionUser[]> | MentionUser[];
|
|
347
|
+
}
|
|
348
|
+
declare const MentionExtension: EditorExtension & {
|
|
349
|
+
configure: (options?: MentionExtensionOptions | undefined) => EditorExtension;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
declare const EmojiExtension: EditorExtension & {
|
|
353
|
+
configure: (options?: Record<string, unknown> | undefined) => EditorExtension;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
interface SlashCommandExtensionOptions {
|
|
357
|
+
commands?: SlashCommandItem[];
|
|
358
|
+
}
|
|
359
|
+
declare const SlashCommandExtension: EditorExtension & {
|
|
360
|
+
configure: (options?: SlashCommandExtensionOptions | undefined) => EditorExtension;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
declare const basicPreset: never[];
|
|
364
|
+
declare const fullPreset: ((EditorExtension & {
|
|
365
|
+
configure: (options?: ImageExtensionOptions | undefined) => EditorExtension;
|
|
366
|
+
}) | (EditorExtension & {
|
|
367
|
+
configure: (options?: Record<string, unknown> | undefined) => EditorExtension;
|
|
368
|
+
}) | (EditorExtension & {
|
|
369
|
+
configure: (options?: MediaExtensionOptions | undefined) => EditorExtension;
|
|
370
|
+
}) | (EditorExtension & {
|
|
371
|
+
configure: (options?: FileExtensionOptions | undefined) => EditorExtension;
|
|
372
|
+
}) | (EditorExtension & {
|
|
373
|
+
configure: (options?: MentionExtensionOptions | undefined) => EditorExtension;
|
|
374
|
+
}) | (EditorExtension & {
|
|
375
|
+
configure: (options?: SlashCommandExtensionOptions | undefined) => EditorExtension;
|
|
376
|
+
}))[];
|
|
377
|
+
|
|
378
|
+
declare function sanitizeHTML(html: string, policy?: HTMLPolicy): string;
|
|
379
|
+
|
|
380
|
+
declare function cleanPastedHTML(rawHtml: string): string;
|
|
381
|
+
|
|
382
|
+
export { type AutosaveConfig, BubbleToolbar, CodeExtension, type CustomIconMap, DefaultIcons, Editor, type EditorExtension, type EditorJSON, type EditorOutput, type EditorProps, type EditorRef, type EditorTheme, type EditorThemeObject, type EditorUpdate, EmojiExtension, FileExtension, type FileUploadHandler, type FileUploadResult, type HTMLPolicy, ImageExtension, type ImageUploadHandler, type ImageUploadResult, MediaExtension, MentionExtension, type MentionUser, SlashCommandExtension, type SlashCommandItem, TableExtension, type ThemeMode, Toolbar, type ToolbarConfig, type ToolbarItem, basicPreset, cleanPastedHTML, createExtension, fullPreset, sanitizeHTML, useEditor };
|