@editorcn/editor 0.1.2 → 0.3.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.cts CHANGED
@@ -1,9 +1,44 @@
1
+ import { Editor } from '@tiptap/react';
1
2
  import * as react from 'react';
2
3
  import react__default from 'react';
3
- import { Editor } from '@tiptap/react';
4
4
  import * as _tiptap_core from '@tiptap/core';
5
5
  import { Node } from '@tiptap/core';
6
6
  import * as _tiptap_extension_link from '@tiptap/extension-link';
7
+ import * as _tiptap_extension_code_block_lowlight from '@tiptap/extension-code-block-lowlight';
8
+
9
+ interface RichTextEditorIcons {
10
+ boldControlIcon: react__default.ReactNode;
11
+ italicControlIcon: react__default.ReactNode;
12
+ underlineControlIcon: react__default.ReactNode;
13
+ strikeControlIcon: react__default.ReactNode;
14
+ clearFormattingControlIcon: react__default.ReactNode;
15
+ codeControlIcon: react__default.ReactNode;
16
+ codeBlockControlIcon: react__default.ReactNode;
17
+ h1ControlIcon: react__default.ReactNode;
18
+ h2ControlIcon: react__default.ReactNode;
19
+ h3ControlIcon: react__default.ReactNode;
20
+ h4ControlIcon: react__default.ReactNode;
21
+ h5ControlIcon: react__default.ReactNode;
22
+ h6ControlIcon: react__default.ReactNode;
23
+ bulletListControlIcon: react__default.ReactNode;
24
+ orderedListControlIcon: react__default.ReactNode;
25
+ blockquoteControlIcon: react__default.ReactNode;
26
+ hrControlIcon: react__default.ReactNode;
27
+ linkControlIcon: react__default.ReactNode;
28
+ unlinkControlIcon: react__default.ReactNode;
29
+ undoControlIcon: react__default.ReactNode;
30
+ redoControlIcon: react__default.ReactNode;
31
+ alignLeftControlIcon: react__default.ReactNode;
32
+ alignCenterControlIcon: react__default.ReactNode;
33
+ alignRightControlIcon: react__default.ReactNode;
34
+ alignJustifyControlIcon: react__default.ReactNode;
35
+ highlightControlIcon: react__default.ReactNode;
36
+ subscriptControlIcon: react__default.ReactNode;
37
+ superscriptControlIcon: react__default.ReactNode;
38
+ languageIcons: Record<string, react__default.ReactNode>;
39
+ }
40
+ declare const DEFAULT_LANGUAGE_ICONS: Record<string, react__default.ReactNode>;
41
+ declare const DEFAULT_ICONS: RichTextEditorIcons;
7
42
 
8
43
  interface RichTextEditorLabels {
9
44
  boldControlLabel: string;
@@ -46,38 +81,6 @@ interface RichTextEditorLabels {
46
81
  }
47
82
  declare const DEFAULT_LABELS: RichTextEditorLabels;
48
83
 
49
- interface RichTextEditorIcons {
50
- boldControlIcon: react__default.ReactNode;
51
- italicControlIcon: react__default.ReactNode;
52
- underlineControlIcon: react__default.ReactNode;
53
- strikeControlIcon: react__default.ReactNode;
54
- clearFormattingControlIcon: react__default.ReactNode;
55
- codeControlIcon: react__default.ReactNode;
56
- codeBlockControlIcon: react__default.ReactNode;
57
- h1ControlIcon: react__default.ReactNode;
58
- h2ControlIcon: react__default.ReactNode;
59
- h3ControlIcon: react__default.ReactNode;
60
- h4ControlIcon: react__default.ReactNode;
61
- h5ControlIcon: react__default.ReactNode;
62
- h6ControlIcon: react__default.ReactNode;
63
- bulletListControlIcon: react__default.ReactNode;
64
- orderedListControlIcon: react__default.ReactNode;
65
- blockquoteControlIcon: react__default.ReactNode;
66
- hrControlIcon: react__default.ReactNode;
67
- linkControlIcon: react__default.ReactNode;
68
- unlinkControlIcon: react__default.ReactNode;
69
- undoControlIcon: react__default.ReactNode;
70
- redoControlIcon: react__default.ReactNode;
71
- alignLeftControlIcon: react__default.ReactNode;
72
- alignCenterControlIcon: react__default.ReactNode;
73
- alignRightControlIcon: react__default.ReactNode;
74
- alignJustifyControlIcon: react__default.ReactNode;
75
- highlightControlIcon: react__default.ReactNode;
76
- subscriptControlIcon: react__default.ReactNode;
77
- superscriptControlIcon: react__default.ReactNode;
78
- }
79
- declare const DEFAULT_ICONS: RichTextEditorIcons;
80
-
81
84
  type RichTextEditorVariant = "default" | "subtle" | "compact";
82
85
  interface RichTextEditorProps {
83
86
  editor: Editor | null;
@@ -120,200 +123,187 @@ interface RichTextEditorFooterProps {
120
123
  wordCountFormatter?: (info: WordCountInfo) => string;
121
124
  }
122
125
 
123
- declare function Toolbar({ children, className, sticky, stickyOffset, }: RichTextEditorToolbarProps): react.JSX.Element | null;
124
-
125
- declare function Footer({ children, className, sticky, stickyOffset, showWordCount, wordCountClassName, wordCountFormatter, }: RichTextEditorFooterProps): react.JSX.Element | null;
126
-
127
- declare function ControlsGroup({ children, className, }: RichTextEditorControlsGroupProps): react.JSX.Element;
128
-
129
- declare function Content({ children, className }: RichTextEditorContentProps): react.JSX.Element;
130
-
131
- declare function RichTextEditorControl({ active, interactive, className, children, onMouseDown, onClick, disabled, ...props }: RichTextEditorControlProps): react__default.JSX.Element;
132
-
133
- declare function LinkControl(): react.JSX.Element;
134
-
135
- declare const YouTubeEmbed: Node<any, any>;
136
- declare function YouTubeEmbedControl({ className }: {
137
- className?: string;
138
- }): react.JSX.Element;
139
-
140
- declare const TwitterEmbed: Node<any, any>;
141
- declare function TwitterEmbedControl({ className }: {
142
- className?: string;
143
- }): react.JSX.Element;
126
+ interface BubbleMenuProps {
127
+ editor: Editor | null;
128
+ }
129
+ declare const BubbleMenu: ({ editor }: BubbleMenuProps) => react.JSX.Element | null;
144
130
 
145
- declare function RichTextEditorRoot({ editor, children, className, labels, icons, variant, editable, }: RichTextEditorProps): react.JSX.Element;
146
- declare const RichTextEditor: typeof RichTextEditorRoot & {
147
- Toolbar: typeof Toolbar;
148
- Footer: typeof Footer;
149
- ControlsGroup: typeof ControlsGroup;
150
- Content: typeof Content;
151
- Control: typeof RichTextEditorControl;
152
- Link: typeof LinkControl;
153
- YouTubeEmbed: typeof YouTubeEmbedControl;
154
- TwitterEmbed: typeof TwitterEmbedControl;
155
- Bold: {
131
+ declare const RichTextEditor: (({ editor, children, className, labels, icons, variant, editable, }: RichTextEditorProps) => react.JSX.Element) & {
132
+ AlignCenter: {
156
133
  ({ className }: {
157
134
  className?: string;
158
135
  }): react.JSX.Element;
159
136
  displayName: string;
160
137
  };
161
- Italic: {
138
+ AlignJustify: {
162
139
  ({ className }: {
163
140
  className?: string;
164
141
  }): react.JSX.Element;
165
142
  displayName: string;
166
143
  };
167
- Underline: {
144
+ AlignLeft: {
168
145
  ({ className }: {
169
146
  className?: string;
170
147
  }): react.JSX.Element;
171
148
  displayName: string;
172
149
  };
173
- Strikethrough: {
150
+ AlignRight: {
174
151
  ({ className }: {
175
152
  className?: string;
176
153
  }): react.JSX.Element;
177
154
  displayName: string;
178
155
  };
179
- ClearFormatting: {
156
+ Blockquote: {
180
157
  ({ className }: {
181
158
  className?: string;
182
159
  }): react.JSX.Element;
183
160
  displayName: string;
184
161
  };
185
- Code: {
162
+ Bold: {
186
163
  ({ className }: {
187
164
  className?: string;
188
165
  }): react.JSX.Element;
189
166
  displayName: string;
190
167
  };
191
- CodeBlock: {
168
+ BubbleMenu: ({ editor }: BubbleMenuProps) => react.JSX.Element | null;
169
+ BulletList: {
192
170
  ({ className }: {
193
171
  className?: string;
194
172
  }): react.JSX.Element;
195
173
  displayName: string;
196
174
  };
197
- H1: {
175
+ ClearFormatting: {
198
176
  ({ className }: {
199
177
  className?: string;
200
178
  }): react.JSX.Element;
201
179
  displayName: string;
202
180
  };
203
- H2: {
181
+ Code: {
204
182
  ({ className }: {
205
183
  className?: string;
206
184
  }): react.JSX.Element;
207
185
  displayName: string;
208
186
  };
209
- H3: {
187
+ CodeBlock: {
210
188
  ({ className }: {
211
189
  className?: string;
212
190
  }): react.JSX.Element;
213
191
  displayName: string;
214
192
  };
215
- H4: {
193
+ Content: ({ children, className, }: RichTextEditorContentProps) => react.JSX.Element;
194
+ Control: ({ active, interactive: _interactive, className, children, onMouseDown, onClick, disabled, ...props }: RichTextEditorControlProps) => react.JSX.Element;
195
+ ControlsGroup: ({ children, className, }: RichTextEditorControlsGroupProps) => react.JSX.Element;
196
+ Footer: ({ children, className, sticky, stickyOffset, showWordCount, wordCountClassName, wordCountFormatter, }: RichTextEditorFooterProps) => react.JSX.Element | null;
197
+ H1: {
216
198
  ({ className }: {
217
199
  className?: string;
218
200
  }): react.JSX.Element;
219
201
  displayName: string;
220
202
  };
221
- H5: {
203
+ H2: {
222
204
  ({ className }: {
223
205
  className?: string;
224
206
  }): react.JSX.Element;
225
207
  displayName: string;
226
208
  };
227
- H6: {
209
+ H3: {
228
210
  ({ className }: {
229
211
  className?: string;
230
212
  }): react.JSX.Element;
231
213
  displayName: string;
232
214
  };
233
- BulletList: {
215
+ H4: {
234
216
  ({ className }: {
235
217
  className?: string;
236
218
  }): react.JSX.Element;
237
219
  displayName: string;
238
220
  };
239
- OrderedList: {
221
+ H5: {
240
222
  ({ className }: {
241
223
  className?: string;
242
224
  }): react.JSX.Element;
243
225
  displayName: string;
244
226
  };
245
- Blockquote: {
227
+ H6: {
246
228
  ({ className }: {
247
229
  className?: string;
248
230
  }): react.JSX.Element;
249
231
  displayName: string;
250
232
  };
251
- Hr: {
233
+ Highlight: {
252
234
  ({ className }: {
253
235
  className?: string;
254
236
  }): react.JSX.Element;
255
237
  displayName: string;
256
238
  };
257
- Unlink: {
239
+ Hr: {
258
240
  ({ className }: {
259
241
  className?: string;
260
242
  }): react.JSX.Element;
261
243
  displayName: string;
262
244
  };
263
- Undo: {
245
+ Italic: {
264
246
  ({ className }: {
265
247
  className?: string;
266
248
  }): react.JSX.Element;
267
249
  displayName: string;
268
250
  };
269
- Redo: {
251
+ Link: () => react.JSX.Element;
252
+ OrderedList: {
270
253
  ({ className }: {
271
254
  className?: string;
272
255
  }): react.JSX.Element;
273
256
  displayName: string;
274
257
  };
275
- AlignLeft: {
258
+ Redo: {
276
259
  ({ className }: {
277
260
  className?: string;
278
261
  }): react.JSX.Element;
279
262
  displayName: string;
280
263
  };
281
- AlignCenter: {
264
+ Strikethrough: {
282
265
  ({ className }: {
283
266
  className?: string;
284
267
  }): react.JSX.Element;
285
268
  displayName: string;
286
269
  };
287
- AlignRight: {
270
+ Subscript: {
288
271
  ({ className }: {
289
272
  className?: string;
290
273
  }): react.JSX.Element;
291
274
  displayName: string;
292
275
  };
293
- AlignJustify: {
276
+ Superscript: {
294
277
  ({ className }: {
295
278
  className?: string;
296
279
  }): react.JSX.Element;
297
280
  displayName: string;
298
281
  };
299
- Highlight: {
282
+ Toolbar: ({ children, className, sticky, stickyOffset, }: RichTextEditorToolbarProps) => react.JSX.Element | null;
283
+ TwitterEmbed: ({ className }: {
284
+ className?: string;
285
+ }) => react.JSX.Element;
286
+ Underline: {
300
287
  ({ className }: {
301
288
  className?: string;
302
289
  }): react.JSX.Element;
303
290
  displayName: string;
304
291
  };
305
- Subscript: {
292
+ Undo: {
306
293
  ({ className }: {
307
294
  className?: string;
308
295
  }): react.JSX.Element;
309
296
  displayName: string;
310
297
  };
311
- Superscript: {
298
+ Unlink: {
312
299
  ({ className }: {
313
300
  className?: string;
314
301
  }): react.JSX.Element;
315
302
  displayName: string;
316
303
  };
304
+ YouTubeEmbed: ({ className }: {
305
+ className?: string;
306
+ }) => react.JSX.Element;
317
307
  };
318
308
 
319
309
  interface RichTextEditorContextValue {
@@ -323,8 +313,37 @@ interface RichTextEditorContextValue {
323
313
  variant: RichTextEditorVariant;
324
314
  editable: boolean;
325
315
  }
326
- declare function useRichTextEditorContext(): RichTextEditorContextValue;
316
+ declare const useRichTextEditorContext: () => RichTextEditorContextValue;
327
317
 
328
318
  declare const Link: _tiptap_core.Mark<_tiptap_extension_link.LinkOptions, any>;
329
319
 
330
- export { DEFAULT_ICONS, DEFAULT_LABELS, Link, RichTextEditor, type RichTextEditorFooterProps, type RichTextEditorIcons, type RichTextEditorLabels, type RichTextEditorProps, type RichTextEditorVariant, TwitterEmbed, type WordCountInfo, YouTubeEmbed, useRichTextEditorContext };
320
+ declare const CodeBlock: _tiptap_core.Node<_tiptap_extension_code_block_lowlight.CodeBlockLowlightOptions, any>;
321
+
322
+ declare global {
323
+ interface Window {
324
+ twttr?: {
325
+ widgets?: {
326
+ createTweet: (tweetId: string, container: HTMLElement) => Promise<unknown>;
327
+ };
328
+ };
329
+ }
330
+ }
331
+ declare module "@tiptap/core" {
332
+ interface Commands<ReturnType> {
333
+ twitter: {
334
+ setTwitterEmbed: (tweetId: string) => ReturnType;
335
+ };
336
+ }
337
+ }
338
+ declare const TwitterEmbed: Node<any, any>;
339
+
340
+ declare module "@tiptap/core" {
341
+ interface Commands<ReturnType> {
342
+ youtube: {
343
+ setYouTubeEmbed: (src: string) => ReturnType;
344
+ };
345
+ }
346
+ }
347
+ declare const YouTubeEmbed: Node<any, any>;
348
+
349
+ export { BubbleMenu, CodeBlock, DEFAULT_ICONS, DEFAULT_LABELS, DEFAULT_LANGUAGE_ICONS, Link, RichTextEditor, type RichTextEditorFooterProps, type RichTextEditorIcons, type RichTextEditorLabels, type RichTextEditorProps, type RichTextEditorVariant, TwitterEmbed, type WordCountInfo, YouTubeEmbed, useRichTextEditorContext };