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