@zencemarketing/text-editor-sdk 0.1.0-alpha.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.
Files changed (38) hide show
  1. package/README.md +666 -0
  2. package/dist/App.d.ts +4 -0
  3. package/dist/App.d.ts.map +1 -0
  4. package/dist/components/ColorPicker.d.ts +10 -0
  5. package/dist/components/ColorPicker.d.ts.map +1 -0
  6. package/dist/components/EditorElement.d.ts +4 -0
  7. package/dist/components/EditorElement.d.ts.map +1 -0
  8. package/dist/components/EditorLeaf.d.ts +4 -0
  9. package/dist/components/EditorLeaf.d.ts.map +1 -0
  10. package/dist/components/EmojiPicker.d.ts +7 -0
  11. package/dist/components/EmojiPicker.d.ts.map +1 -0
  12. package/dist/components/PasteOptionsMenu.d.ts +13 -0
  13. package/dist/components/PasteOptionsMenu.d.ts.map +1 -0
  14. package/dist/components/Resizable.d.ts +17 -0
  15. package/dist/components/Resizable.d.ts.map +1 -0
  16. package/dist/components/RichTextEditor.d.ts +6 -0
  17. package/dist/components/RichTextEditor.d.ts.map +1 -0
  18. package/dist/components/Toolbar.d.ts +24 -0
  19. package/dist/components/Toolbar.d.ts.map +1 -0
  20. package/dist/index.css +1 -0
  21. package/dist/index.d.ts +12 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.esm.css +1 -0
  24. package/dist/index.esm.js +37225 -0
  25. package/dist/index.esm.js.map +1 -0
  26. package/dist/index.js +37230 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/main.d.ts +2 -0
  29. package/dist/main.d.ts.map +1 -0
  30. package/dist/types/index.d.ts +390 -0
  31. package/dist/types/index.d.ts.map +1 -0
  32. package/dist/types/slate.d.ts +82 -0
  33. package/dist/types/slate.d.ts.map +1 -0
  34. package/dist/utils/pasteHelpers.d.ts +5 -0
  35. package/dist/utils/pasteHelpers.d.ts.map +1 -0
  36. package/dist/utils/slateHelpers.d.ts +25 -0
  37. package/dist/utils/slateHelpers.d.ts.map +1 -0
  38. package/package.json +67 -0
package/dist/main.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,390 @@
1
+ import { CSSProperties } from 'react';
2
+ /**
3
+ * User interface for mentions functionality
4
+ */
5
+ export interface User {
6
+ /** Unique identifier for the user */
7
+ id: string;
8
+ /** Display name of the user */
9
+ name: string;
10
+ /** Optional avatar URL */
11
+ avatar?: string;
12
+ /** Optional email address */
13
+ email?: string;
14
+ }
15
+ /**
16
+ * Tag/Variable interface for dynamic content replacement
17
+ * Tags are used to insert placeholders that can be replaced with actual values
18
+ * @example
19
+ * ```ts
20
+ * const tag: Tag = {
21
+ * id: '1',
22
+ * label: 'User Name',
23
+ * value: '{{userName}}',
24
+ * description: 'Current user\'s name',
25
+ * backgroundColor: '#fff3cd',
26
+ * color: '#856404'
27
+ * };
28
+ * ```
29
+ */
30
+ export interface Tag {
31
+ /** Unique identifier for the tag */
32
+ id: string;
33
+ /** Human-readable label shown in the tag picker */
34
+ label: string;
35
+ /** The actual tag/variable syntax (e.g., "{{name}}", "${userName}") */
36
+ value: string;
37
+ /** Optional description shown in the tag picker */
38
+ description?: string;
39
+ /** Text color for the tag display */
40
+ color?: string;
41
+ /** Background color for the tag display */
42
+ backgroundColor?: string;
43
+ }
44
+ /**
45
+ * Configuration for action buttons (Cancel/Submit)
46
+ */
47
+ export interface ActionButtonConfig {
48
+ /** Whether to show this button */
49
+ show?: boolean;
50
+ /** Button label text (max 15 characters, will be truncated) */
51
+ label?: string;
52
+ /** Button position order (1 = first/left, 2 = second/right) */
53
+ position?: 1 | 2;
54
+ /** Custom CSS styles for the button */
55
+ style?: CSSProperties;
56
+ }
57
+ /**
58
+ * Cancel button configuration
59
+ * @extends ActionButtonConfig
60
+ */
61
+ export interface CancelButtonConfig extends ActionButtonConfig {
62
+ /** Callback fired when cancel button is clicked. Editor content will be cleared automatically. */
63
+ onClick?: () => void;
64
+ }
65
+ /**
66
+ * Submit button configuration
67
+ * @extends ActionButtonConfig
68
+ */
69
+ export interface SubmitButtonConfig extends ActionButtonConfig {
70
+ /**
71
+ * Callback fired when submit button is clicked. Receives editor content as JSON string.
72
+ * Editor content will be cleared automatically after submission.
73
+ */
74
+ onClick?: (content: string) => void;
75
+ }
76
+ /**
77
+ * Feature flags to enable/disable editor capabilities
78
+ * All features are optional and default to false if not specified
79
+ */
80
+ export interface EditorFeatures {
81
+ /** Enable all text formatting options */
82
+ textFormatting?: boolean;
83
+ /** Enable heading styles (H1, H2, H3) */
84
+ headings?: boolean;
85
+ /** Enable bold text formatting */
86
+ bold?: boolean;
87
+ /** Enable italic text formatting */
88
+ italic?: boolean;
89
+ /** Enable underline text formatting */
90
+ underline?: boolean;
91
+ /** Enable strikethrough text formatting */
92
+ strikethrough?: boolean;
93
+ /** Enable text color picker */
94
+ textColor?: boolean;
95
+ /** Enable text highlight color */
96
+ highlightColor?: boolean;
97
+ /** Enable bulleted lists */
98
+ bulletList?: boolean;
99
+ /** Enable numbered lists */
100
+ numberedList?: boolean;
101
+ /** Enable attachments functionality */
102
+ attachments?: boolean;
103
+ /** Enable link insertion */
104
+ links?: boolean;
105
+ /** Enable media (image/video) upload */
106
+ mediaUpload?: boolean;
107
+ /** Enable user mentions (@mentions) */
108
+ mentions?: boolean;
109
+ /** Enable emoji picker */
110
+ emoji?: boolean;
111
+ /** Enable code block insertion */
112
+ codeBlock?: boolean;
113
+ /** Enable table creation (future feature) */
114
+ table?: boolean;
115
+ }
116
+ /**
117
+ * Main props interface for the RichTextEditor component
118
+ * @example
119
+ * ```tsx
120
+ * import RichTextEditor from '@zencemarketing/rich-text-editor';
121
+ *
122
+ * function MyComponent() {
123
+ * const [content, setContent] = useState('');
124
+ *
125
+ * return (
126
+ * <RichTextEditor
127
+ * value={content}
128
+ * onChange={setContent}
129
+ * placeholder="Start typing..."
130
+ * minHeight="200px"
131
+ * maxHeight="400px"
132
+ * features={{
133
+ * bold: true,
134
+ * italic: true,
135
+ * mentions: true,
136
+ * emoji: true
137
+ * }}
138
+ * />
139
+ * );
140
+ * }
141
+ * ```
142
+ */
143
+ export interface RichTextEditorProps {
144
+ /**
145
+ * Controlled value (JSON string of Slate nodes). Use with onChange for controlled component.
146
+ * @example '[]' for empty, '[{"type":"paragraph","children":[{"text":"Hello"}]}]' for content
147
+ */
148
+ value?: string;
149
+ /**
150
+ * Default initial value (JSON string of Slate nodes). Use for uncontrolled component.
151
+ * @default '[]'
152
+ */
153
+ defaultValue?: string;
154
+ /**
155
+ * Callback fired when editor content changes. Receives JSON string of Slate nodes.
156
+ * @param value - JSON string representation of editor content
157
+ */
158
+ onChange?: (value: string) => void;
159
+ /**
160
+ * Placeholder text shown when editor is empty
161
+ * @default "Start typing..."
162
+ */
163
+ placeholder?: string;
164
+ /**
165
+ * Fixed height of the editor. Note: Use minHeight/maxHeight for flexible height.
166
+ * @example "400px" | 400 | "50vh"
167
+ */
168
+ height?: string | number;
169
+ /**
170
+ * Width of the editor container
171
+ * @default "100%"
172
+ * @example "100%" | "600px" | 600
173
+ */
174
+ width?: string | number;
175
+ /**
176
+ * Border color of the editor container
177
+ * @default "#ddd"
178
+ * @example "#cccccc" | "rgb(200,200,200)"
179
+ */
180
+ borderColor?: string;
181
+ /**
182
+ * Border width of the editor container
183
+ * @default "1px"
184
+ */
185
+ borderWidth?: string | number;
186
+ /**
187
+ * Border radius for rounded corners
188
+ * @default "4px"
189
+ * @example "8px" | "0" | "12px"
190
+ */
191
+ borderRadius?: string | number;
192
+ /**
193
+ * Background color of the editor content area
194
+ * @default "#ffffff"
195
+ */
196
+ backgroundColor?: string;
197
+ /**
198
+ * Text color for editor content
199
+ * @default "inherit"
200
+ */
201
+ textColor?: string;
202
+ /**
203
+ * Background color for the toolbar
204
+ * @default "#f8f9fa"
205
+ */
206
+ toolbarBackgroundColor?: string;
207
+ /**
208
+ * Alternative background color for toolbar header (overrides toolbarBackgroundColor)
209
+ */
210
+ headerBackgroundColor?: string;
211
+ /**
212
+ * Background image URL for toolbar header
213
+ * @example "https://example.com/header-bg.jpg"
214
+ */
215
+ headerBackgroundImage?: string;
216
+ /**
217
+ * Object to enable/disable specific editor features
218
+ * @default All features disabled (false)
219
+ * @example { bold: true, italic: true, links: true }
220
+ */
221
+ features?: EditorFeatures;
222
+ /**
223
+ * Array of users available for @mentions
224
+ * Users will appear in the mentions dropdown when typing '@'
225
+ */
226
+ mentionUsers?: User[];
227
+ /**
228
+ * Callback fired when a user is mentioned
229
+ * @param user - The selected user object
230
+ */
231
+ onMentionSelect?: (user: User) => void;
232
+ /**
233
+ * Callback fired when a link is added
234
+ * @param url - The URL that was added
235
+ */
236
+ onLinkAdd?: (url: string) => void;
237
+ /**
238
+ * Async callback for handling media uploads (images/videos)
239
+ * Should upload the file and return the URL where it's hosted
240
+ * @param file - The File object to upload
241
+ * @returns Promise resolving to the hosted file URL, or void if upload fails
242
+ * @example
243
+ * ```ts
244
+ * async (file) => {
245
+ * const formData = new FormData();
246
+ * formData.append('file', file);
247
+ * const response = await fetch('/api/upload', {
248
+ * method: 'POST',
249
+ * body: formData
250
+ * });
251
+ * const { url } = await response.json();
252
+ * return url;
253
+ * }
254
+ * ```
255
+ */
256
+ onMediaUpload?: (file: File) => Promise<string | void>;
257
+ /**
258
+ * Array of tags/variables available for insertion
259
+ * Tags appear in the dropdown when clicking the # button
260
+ */
261
+ tags?: Tag[];
262
+ /**
263
+ * Callback fired when a tag is selected and inserted
264
+ * @param tag - The selected tag object
265
+ */
266
+ onTagSelect?: (tag: Tag) => void;
267
+ /**
268
+ * Placeholder text for the tag search input
269
+ * @default "Search variables..."
270
+ */
271
+ tagPlaceholder?: string;
272
+ /**
273
+ * Show character count indicator
274
+ * @default false
275
+ */
276
+ showCharCount?: boolean;
277
+ /**
278
+ * Maximum number of characters allowed. Prevents typing when reached.
279
+ * @default undefined (no limit)
280
+ * @example 1000
281
+ */
282
+ maxCharCount?: number;
283
+ /**
284
+ * Position of the character count display
285
+ * @default "bottom-right"
286
+ */
287
+ charCountPosition?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
288
+ /**
289
+ * Allow users to resize the editor by dragging
290
+ * @default false
291
+ */
292
+ resizable?: boolean;
293
+ /**
294
+ * Minimum height constraint (also used as initial height when no fixed height set)
295
+ * @default "200px"
296
+ * @example "150px" | 150
297
+ */
298
+ minHeight?: string | number;
299
+ /**
300
+ * Maximum height constraint. Scrolling enabled when content exceeds this.
301
+ * @default "400px"
302
+ * @example "600px" | "80vh"
303
+ */
304
+ maxHeight?: string | number;
305
+ /**
306
+ * Minimum width constraint (used when resizable=true)
307
+ * @default "300px"
308
+ */
309
+ minWidth?: string | number;
310
+ /**
311
+ * Maximum width constraint (used when resizable=true)
312
+ * @default "100%"
313
+ */
314
+ maxWidth?: string | number;
315
+ /**
316
+ * Position of the toolbar(s)
317
+ * @default "top"
318
+ * - "top" - Toolbar at the top only
319
+ * - "bottom" - Toolbar at the bottom only
320
+ * - "both" - Toolbars at both top and bottom
321
+ */
322
+ toolbarPosition?: 'top' | 'bottom' | 'both';
323
+ /**
324
+ * Array of button names to show in the top toolbar
325
+ * If empty/undefined, all enabled features will be shown
326
+ * @default []
327
+ * @example ['headings', 'bold', 'italic', 'link']
328
+ *
329
+ * Available buttons: 'headings', 'bold', 'italic', 'underline', 'strikethrough',
330
+ * 'bulletList', 'numberedList', 'link', 'mediaUpload', 'mentions', 'tags',
331
+ * 'emoji', 'codeBlock', 'more'
332
+ */
333
+ topToolbarButtons?: string[];
334
+ /**
335
+ * Array of button names to show in the bottom toolbar
336
+ * If empty/undefined, all enabled features will be shown
337
+ * @default []
338
+ * @example ['emoji', 'mentions', 'mediaUpload']
339
+ */
340
+ bottomToolbarButtons?: string[];
341
+ /**
342
+ * Position of action buttons (Cancel/Submit)
343
+ * @default "none"
344
+ * - "none" - Don't show action buttons
345
+ * - "top-right" - Show in top toolbar on the right
346
+ * - "bottom-right" - Show in bottom toolbar on the right
347
+ */
348
+ actionButtonsPosition?: 'top-right' | 'bottom-right' | 'none';
349
+ /**
350
+ * Cancel button configuration
351
+ * Clicking cancel will clear the editor and call onClick callback
352
+ */
353
+ cancelButton?: CancelButtonConfig;
354
+ /**
355
+ * Submit button configuration
356
+ * Clicking submit will call onClick with editor content and clear the editor
357
+ */
358
+ submitButton?: SubmitButtonConfig;
359
+ /**
360
+ * Disable all editor interactions
361
+ * @default false
362
+ */
363
+ disabled?: boolean;
364
+ /**
365
+ * Make editor read-only (view-only mode)
366
+ * @default false
367
+ */
368
+ readOnly?: boolean;
369
+ /**
370
+ * Additional CSS class name for the editor container
371
+ */
372
+ className?: string;
373
+ /**
374
+ * Inline CSS styles for the editor container
375
+ */
376
+ style?: CSSProperties;
377
+ }
378
+ /**
379
+ * Props for toolbar button components (internal use)
380
+ * @internal
381
+ */
382
+ export interface ToolbarButtonProps {
383
+ active?: boolean;
384
+ disabled?: boolean;
385
+ onClick: () => void;
386
+ icon?: React.ReactNode;
387
+ label: string;
388
+ tooltip?: string;
389
+ }
390
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,GAAG;IAClB,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;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E,MAAM,EAAE,CAAC;IAE7B;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAIhC;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,WAAW,GAAG,cAAc,GAAG,MAAM,CAAC;IAE9D;;;OAGG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAElC;;;OAGG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAIlC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,82 @@
1
+ import { BaseEditor } from 'slate';
2
+ import { ReactEditor } from 'slate-react';
3
+ import { HistoryEditor } from 'slate-history';
4
+ export type CustomEditor = BaseEditor & ReactEditor & HistoryEditor;
5
+ export type ParagraphElement = {
6
+ type: 'paragraph';
7
+ children: CustomText[];
8
+ };
9
+ export type HeadingElement = {
10
+ type: 'heading-1' | 'heading-2' | 'heading-3';
11
+ children: CustomText[];
12
+ };
13
+ export type ListElement = {
14
+ type: 'bulleted-list' | 'numbered-list';
15
+ children: CustomElement[];
16
+ };
17
+ export type ListItemElement = {
18
+ type: 'list-item';
19
+ parent?: 'bulleted-list' | 'numbered-list';
20
+ children: CustomText[];
21
+ };
22
+ export type LinkElement = {
23
+ type: 'link';
24
+ url: string;
25
+ children: CustomText[];
26
+ };
27
+ export type CodeBlockElement = {
28
+ type: 'code-block';
29
+ width?: string | number;
30
+ height?: string | number;
31
+ children: CustomText[];
32
+ };
33
+ export type MentionElement = {
34
+ type: 'mention';
35
+ character: string;
36
+ userId: string;
37
+ children: CustomText[];
38
+ };
39
+ export type ImageElement = {
40
+ type: 'image';
41
+ url: string;
42
+ width?: string | number;
43
+ height?: string | number;
44
+ children: CustomText[];
45
+ };
46
+ export type HorizontalRuleElement = {
47
+ type: 'horizontal-rule';
48
+ children: CustomText[];
49
+ };
50
+ export type IndentElement = {
51
+ type: 'indent';
52
+ children: CustomElement[];
53
+ };
54
+ export type TagElement = {
55
+ type: 'tag';
56
+ tagId: string;
57
+ tagValue: string;
58
+ tagLabel: string;
59
+ color?: string;
60
+ backgroundColor?: string;
61
+ children: CustomText[];
62
+ };
63
+ export type CustomElement = ParagraphElement | HeadingElement | ListElement | ListItemElement | LinkElement | CodeBlockElement | MentionElement | ImageElement | HorizontalRuleElement | IndentElement | TagElement;
64
+ export type CustomText = {
65
+ text: string;
66
+ bold?: boolean;
67
+ italic?: boolean;
68
+ underline?: boolean;
69
+ strikethrough?: boolean;
70
+ code?: boolean;
71
+ color?: string;
72
+ backgroundColor?: string;
73
+ };
74
+ export type SlateElement = CustomElement;
75
+ declare module 'slate' {
76
+ interface CustomTypes {
77
+ Editor: CustomEditor;
78
+ Element: CustomElement;
79
+ Text: CustomText;
80
+ }
81
+ }
82
+ //# sourceMappingURL=slate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slate.d.ts","sourceRoot":"","sources":["../../src/types/slate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,aAAa,CAAC;AAEpE,MA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1,5 @@
1
+ import { Editor, Descendant } from 'slate';
2
+ export declare const deserializeHTML: (html: string) => Descendant[];
3
+ export declare const deserializePlainText: (text: string) => Descendant[];
4
+ export declare const handlePaste: (editor: Editor, event: React.ClipboardEvent, pasteMode?: "rich" | "plain" | "ask") => void;
5
+ //# sourceMappingURL=pasteHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pasteHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/pasteHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,UAAU,EAAE,MAAM,OAAO,CAAC;AAGvD,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,UAAU,EAwPxD,CAAC;AAGF,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,KAAG,UAAU,EAM7D,CAAC;AAGF,eAAO,MAAM,WAAW,GACtB,QAAQ,MAAM,EACd,OAAO,KAAK,CAAC,cAAc,EAC3B,YAAW,MAAM,GAAG,OAAO,GAAG,KAAa,KAC1C,IAiCF,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { Editor } from 'slate';
2
+ export declare const isMarkActive: (editor: Editor, format: string) => boolean;
3
+ export declare const toggleMark: (editor: Editor, format: string) => void;
4
+ export declare const isBlockActive: (editor: Editor, format: string) => boolean;
5
+ export declare const toggleBlock: (editor: Editor, format: string) => void;
6
+ export declare const insertLink: (editor: Editor, url: string) => void;
7
+ export declare const isLinkActive: (editor: Editor) => boolean;
8
+ export declare const insertCodeBlock: (editor: Editor) => void;
9
+ export declare const insertMention: (editor: Editor, user: {
10
+ id: string;
11
+ name: string;
12
+ }) => void;
13
+ export declare const insertTag: (editor: Editor, tag: {
14
+ id: string;
15
+ value: string;
16
+ label: string;
17
+ color?: string;
18
+ backgroundColor?: string;
19
+ }) => void;
20
+ export declare const clearFormatting: (editor: Editor) => void;
21
+ export declare const increaseIndent: (editor: Editor) => void;
22
+ export declare const decreaseIndent: (editor: Editor) => void;
23
+ export declare const insertHorizontalRule: (editor: Editor) => void;
24
+ export declare const removeCodeBlock: (editor: Editor, path: any[]) => void;
25
+ //# sourceMappingURL=slateHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slateHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/slateHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA8C,MAAM,OAAO,CAAC;AAE3E,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,YAe1D,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,SAaxD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,YAe3D,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,SA8BzD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,KAAK,MAAM,SAIrD,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,YAQ1C,CAAC;AAgCF,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,SAK7C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,EAAE,MAAM;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,SAS/E,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,EAAE,KAAK;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,SAoBpI,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,SAS7C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,SAE5C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,SAI5C,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,SASlD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,MAAM,GAAG,EAAE,SAO1D,CAAC"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@zencemarketing/text-editor-sdk",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "A highly customizable rich text editor React component built with Slate.js - Features include mentions, tags, emoji picker, code blocks, image uploads, paste formatting, character limits, and fully configurable toolbars",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md"
11
+ ],
12
+ "scripts": {
13
+ "build": "rollup -c && tsc --emitDeclarationOnly",
14
+ "dev": "vite",
15
+ "preview": "vite preview",
16
+ "type-check": "tsc --noEmit",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "keywords": [
23
+ "zencemarketing",
24
+ "react",
25
+ "rich-text-editor",
26
+ "slate",
27
+ "slate-react",
28
+ "wysiwyg",
29
+ "editor",
30
+ "mentions",
31
+ "tags",
32
+ "emoji",
33
+ "code-blocks",
34
+ "customizable",
35
+ "typescript"
36
+ ],
37
+ "author": "ZenceMarketing",
38
+ "license": "MIT",
39
+ "type": "module",
40
+ "peerDependencies": {
41
+ "react": "^18.0.0",
42
+ "react-dom": "^18.0.0"
43
+ },
44
+ "dependencies": {
45
+ "emoji-picker-react": "^4.7.1",
46
+ "slate": "^0.123.0",
47
+ "slate-history": "^0.113.1",
48
+ "slate-react": "^0.123.0"
49
+ },
50
+ "devDependencies": {
51
+ "@rollup/plugin-commonjs": "^25.0.7",
52
+ "@rollup/plugin-node-resolve": "^15.2.3",
53
+ "@rollup/plugin-typescript": "^11.1.5",
54
+ "@types/react": "^18.2.43",
55
+ "@types/react-dom": "^18.2.17",
56
+ "@vitejs/plugin-react": "^4.2.1",
57
+ "autoprefixer": "^10.4.16",
58
+ "react": "^18.2.0",
59
+ "react-dom": "^18.2.0",
60
+ "rollup": "^4.6.1",
61
+ "rollup-plugin-peer-deps-external": "^2.2.4",
62
+ "rollup-plugin-postcss": "^4.0.2",
63
+ "tslib": "^2.8.1",
64
+ "typescript": "^5.3.3",
65
+ "vite": "^5.0.8"
66
+ }
67
+ }