@gravity-ui/markdown-editor 14.8.0 → 14.9.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 (62) hide show
  1. package/README.md +16 -14
  2. package/build/cjs/bundle/MarkdownEditorView.d.ts +27 -0
  3. package/build/cjs/bundle/MarkdownEditorView.js +19 -2
  4. package/build/cjs/bundle/config/action-names.d.ts +1 -1
  5. package/build/cjs/bundle/config/action-names.js +50 -27
  6. package/build/cjs/bundle/config/index.d.ts +3 -0
  7. package/build/cjs/bundle/config/index.js +3 -0
  8. package/build/cjs/bundle/config/markup.js +3 -0
  9. package/build/cjs/bundle/config/wysiwyg.d.ts +3 -0
  10. package/build/cjs/bundle/toolbar/utils.d.ts +17 -0
  11. package/build/cjs/bundle/toolbar/utils.js +64 -0
  12. package/build/cjs/extensions/markdown/Link/paste-plugin.js +21 -5
  13. package/build/cjs/i18n/menubar/en.json +1 -0
  14. package/build/cjs/i18n/menubar/index.d.ts +2 -1
  15. package/build/cjs/i18n/menubar/ru.json +1 -0
  16. package/build/cjs/markup/codemirror/create.js +24 -11
  17. package/build/cjs/markup/codemirror/smart-reindent/index.d.ts +4 -0
  18. package/build/cjs/markup/codemirror/smart-reindent/index.js +42 -0
  19. package/build/cjs/markup/codemirror/smart-reindent/utils.d.ts +15 -0
  20. package/build/cjs/markup/codemirror/smart-reindent/utils.js +59 -0
  21. package/build/cjs/modules/toolbars/constants.d.ts +13 -0
  22. package/build/cjs/modules/toolbars/constants.js +18 -0
  23. package/build/cjs/modules/toolbars/items.d.ts +127 -0
  24. package/build/cjs/modules/toolbars/items.js +736 -0
  25. package/build/cjs/modules/toolbars/presets.d.ts +6 -0
  26. package/build/cjs/modules/toolbars/presets.js +465 -0
  27. package/build/cjs/modules/toolbars/types.d.ts +62 -0
  28. package/build/cjs/modules/toolbars/types.js +2 -0
  29. package/build/cjs/toolbar/types.d.ts +8 -0
  30. package/build/cjs/toolbar/types.js +2 -0
  31. package/build/cjs/version.js +1 -1
  32. package/build/esm/bundle/MarkdownEditorView.d.ts +27 -0
  33. package/build/esm/bundle/MarkdownEditorView.js +19 -2
  34. package/build/esm/bundle/config/action-names.d.ts +1 -1
  35. package/build/esm/bundle/config/action-names.js +50 -27
  36. package/build/esm/bundle/config/index.d.ts +3 -0
  37. package/build/esm/bundle/config/index.js +3 -0
  38. package/build/esm/bundle/config/markup.js +3 -0
  39. package/build/esm/bundle/config/wysiwyg.d.ts +3 -0
  40. package/build/esm/bundle/toolbar/utils.d.ts +17 -0
  41. package/build/esm/bundle/toolbar/utils.js +59 -0
  42. package/build/esm/extensions/markdown/Link/paste-plugin.js +21 -5
  43. package/build/esm/i18n/menubar/en.json +1 -0
  44. package/build/esm/i18n/menubar/index.d.ts +2 -1
  45. package/build/esm/i18n/menubar/ru.json +1 -0
  46. package/build/esm/markup/codemirror/create.js +24 -11
  47. package/build/esm/markup/codemirror/smart-reindent/index.d.ts +4 -0
  48. package/build/esm/markup/codemirror/smart-reindent/index.js +38 -0
  49. package/build/esm/markup/codemirror/smart-reindent/utils.d.ts +15 -0
  50. package/build/esm/markup/codemirror/smart-reindent/utils.js +55 -0
  51. package/build/esm/modules/toolbars/constants.d.ts +13 -0
  52. package/build/esm/modules/toolbars/constants.js +15 -0
  53. package/build/esm/modules/toolbars/items.d.ts +127 -0
  54. package/build/esm/modules/toolbars/items.js +730 -0
  55. package/build/esm/modules/toolbars/presets.d.ts +6 -0
  56. package/build/esm/modules/toolbars/presets.js +462 -0
  57. package/build/esm/modules/toolbars/types.d.ts +62 -0
  58. package/build/esm/modules/toolbars/types.js +1 -0
  59. package/build/esm/toolbar/types.d.ts +8 -0
  60. package/build/esm/toolbar/types.js +2 -0
  61. package/build/esm/version.js +1 -1
  62. package/package.json +1 -1
@@ -0,0 +1,6 @@
1
+ import { ToolbarsPreset } from './types';
2
+ export declare const zero: ToolbarsPreset;
3
+ export declare const commonmark: ToolbarsPreset;
4
+ export declare const defaultPreset: ToolbarsPreset;
5
+ export declare const yfm: ToolbarsPreset;
6
+ export declare const full: ToolbarsPreset;
@@ -0,0 +1,462 @@
1
+ import { ActionName as Action } from '../../bundle/config/action-names';
2
+ import { ListName as List, ToolbarName as Toolbar } from './constants';
3
+ import { boldItemMarkup, boldItemView, boldItemWysiwyg, bulletListItemMarkup, bulletListItemView, bulletListItemWysiwyg, checkboxItemMarkup, checkboxItemView, checkboxItemWysiwyg, codeBlockItemMarkup, codeBlockItemView, codeBlockItemWysiwyg, codeBlocksListItemView, codeItemMarkup, codeItemView, codeItemWysiwyg, colorifyItemMarkup, colorifyItemView, colorifyItemWysiwyg, cutItemMarkup, cutItemView, cutItemWysiwyg, emojiItemMarkup, emojiItemView, emojiItemWysiwyg, fileItemMarkup, fileItemView, fileItemWysiwyg, filePopupItemView, heading1ItemMarkup, heading1ItemView, heading1ItemWysiwyg, heading2ItemMarkup, heading2ItemView, heading2ItemWysiwyg, heading3ItemMarkup, heading3ItemView, heading3ItemWysiwyg, heading4ItemMarkup, heading4ItemView, heading4ItemWysiwyg, heading5ItemMarkup, heading5ItemView, heading5ItemWysiwyg, heading6ItemMarkup, heading6ItemView, heading6ItemWysiwyg, headingListItemView, hruleItemMarkup, hruleItemView, hruleItemWysiwyg, imageItemMarkup, imageItemView, imageItemWysiwyg, imagePopupItemView, italicItemMarkup, italicItemView, italicItemWysiwyg, liftListItemMarkup, liftListItemView, liftListItemWysiwyg, linkItemMarkup, linkItemView, linkItemWysiwyg, listsListItemView, markedItemMarkup, markedItemView, markedItemWysiwyg, monospaceItemMarkup, monospaceItemView, monospaceItemWysiwyg, noteItemMarkup, noteItemView, noteItemWysiwyg, orderedListItemMarkup, orderedListItemView, orderedListItemWysiwyg, paragraphItemMarkup, paragraphItemView, paragraphItemWisywig, quoteItemMarkup, quoteItemView, quoteItemWysiwyg, redoItemMarkup, redoItemView, redoItemWysiwyg, sinkListItemMarkup, sinkListItemView, sinkListItemWysiwyg, strikethroughItemMarkup, strikethroughItemView, tableItemMarkup, tableItemView, tableItemWysiwyg, underlineItemMarkup, underlineItemView, underlineItemWysiwyg, undoItemMarkup, undoItemView, undoItemWysiwyg, } from './items';
4
+ // presets
5
+ export const zero = {
6
+ items: {
7
+ [Action.undo]: {
8
+ view: undoItemView,
9
+ wysiwyg: undoItemWysiwyg,
10
+ markup: undoItemMarkup,
11
+ },
12
+ [Action.redo]: {
13
+ view: redoItemView,
14
+ wysiwyg: redoItemWysiwyg,
15
+ markup: redoItemMarkup,
16
+ },
17
+ },
18
+ orders: {
19
+ [Toolbar.wysiwygMain]: [[Action.undo, Action.redo]],
20
+ [Toolbar.markupMain]: [[Action.undo, Action.redo]],
21
+ },
22
+ };
23
+ export const commonmark = {
24
+ items: Object.assign(Object.assign({}, zero.items), { [Action.bold]: {
25
+ view: boldItemView,
26
+ wysiwyg: boldItemWysiwyg,
27
+ markup: boldItemMarkup,
28
+ }, [Action.italic]: {
29
+ view: italicItemView,
30
+ wysiwyg: italicItemWysiwyg,
31
+ markup: italicItemMarkup,
32
+ }, [List.heading]: {
33
+ view: headingListItemView,
34
+ }, [Action.paragraph]: {
35
+ view: paragraphItemView,
36
+ wysiwyg: paragraphItemWisywig,
37
+ markup: paragraphItemMarkup,
38
+ }, [Action.heading1]: {
39
+ view: heading1ItemView,
40
+ wysiwyg: heading1ItemWysiwyg,
41
+ markup: heading1ItemMarkup,
42
+ }, [Action.heading2]: {
43
+ view: heading2ItemView,
44
+ wysiwyg: heading2ItemWysiwyg,
45
+ markup: heading2ItemMarkup,
46
+ }, [Action.heading3]: {
47
+ view: heading3ItemView,
48
+ wysiwyg: heading3ItemWysiwyg,
49
+ markup: heading3ItemMarkup,
50
+ }, [Action.heading4]: {
51
+ view: heading4ItemView,
52
+ wysiwyg: heading4ItemWysiwyg,
53
+ markup: heading4ItemMarkup,
54
+ }, [Action.heading5]: {
55
+ view: heading5ItemView,
56
+ wysiwyg: heading5ItemWysiwyg,
57
+ markup: heading5ItemMarkup,
58
+ }, [Action.heading6]: {
59
+ view: heading6ItemView,
60
+ wysiwyg: heading6ItemWysiwyg,
61
+ markup: heading6ItemMarkup,
62
+ }, [List.lists]: {
63
+ view: listsListItemView,
64
+ }, [Action.bulletList]: {
65
+ view: bulletListItemView,
66
+ wysiwyg: bulletListItemWysiwyg,
67
+ markup: bulletListItemMarkup,
68
+ }, [Action.orderedList]: {
69
+ view: orderedListItemView,
70
+ wysiwyg: orderedListItemWysiwyg,
71
+ markup: orderedListItemMarkup,
72
+ }, [Action.sinkListItem]: {
73
+ view: sinkListItemView,
74
+ wysiwyg: sinkListItemWysiwyg,
75
+ markup: sinkListItemMarkup,
76
+ }, [Action.liftListItem]: {
77
+ view: liftListItemView,
78
+ wysiwyg: liftListItemWysiwyg,
79
+ markup: liftListItemMarkup,
80
+ }, [Action.link]: {
81
+ view: linkItemView,
82
+ wysiwyg: linkItemWysiwyg,
83
+ markup: linkItemMarkup,
84
+ }, [Action.quote]: {
85
+ view: quoteItemView,
86
+ wysiwyg: quoteItemWysiwyg,
87
+ markup: quoteItemMarkup,
88
+ }, [List.code]: {
89
+ view: codeBlocksListItemView,
90
+ }, [Action.codeInline]: {
91
+ view: codeItemView,
92
+ wysiwyg: codeItemWysiwyg,
93
+ markup: codeItemMarkup,
94
+ }, [Action.codeBlock]: {
95
+ view: codeBlockItemView,
96
+ wysiwyg: codeBlockItemWysiwyg,
97
+ markup: codeBlockItemMarkup,
98
+ }, [Action.horizontalRule]: {
99
+ view: hruleItemView,
100
+ wysiwyg: hruleItemWysiwyg,
101
+ markup: hruleItemMarkup,
102
+ } }),
103
+ orders: {
104
+ [Toolbar.wysiwygMain]: [
105
+ [Action.undo, Action.redo],
106
+ [Action.bold, Action.italic],
107
+ [
108
+ {
109
+ id: List.heading,
110
+ items: [
111
+ Action.paragraph,
112
+ Action.heading1,
113
+ Action.heading2,
114
+ Action.heading3,
115
+ Action.heading4,
116
+ Action.heading5,
117
+ Action.heading6,
118
+ ],
119
+ },
120
+ {
121
+ id: List.lists,
122
+ items: [
123
+ Action.bulletList,
124
+ Action.orderedList,
125
+ Action.sinkListItem,
126
+ Action.liftListItem,
127
+ ],
128
+ },
129
+ Action.link,
130
+ Action.quote,
131
+ {
132
+ id: List.code,
133
+ items: [Action.codeInline, Action.codeBlock],
134
+ },
135
+ ],
136
+ ],
137
+ [Toolbar.markupMain]: [
138
+ [Action.undo, Action.redo],
139
+ [Action.bold, Action.italic],
140
+ [
141
+ {
142
+ id: List.heading,
143
+ items: [
144
+ Action.paragraph,
145
+ Action.heading1,
146
+ Action.heading2,
147
+ Action.heading3,
148
+ Action.heading4,
149
+ Action.heading5,
150
+ Action.heading6,
151
+ ],
152
+ },
153
+ {
154
+ id: List.lists,
155
+ items: [
156
+ Action.bulletList,
157
+ Action.orderedList,
158
+ Action.sinkListItem,
159
+ Action.liftListItem,
160
+ ],
161
+ },
162
+ Action.link,
163
+ Action.quote,
164
+ {
165
+ id: List.code,
166
+ items: [Action.codeInline, Action.codeBlock],
167
+ },
168
+ ],
169
+ ],
170
+ [Toolbar.wysiwygHidden]: [[Action.horizontalRule]],
171
+ [Toolbar.markupHidden]: [[Action.horizontalRule]],
172
+ },
173
+ };
174
+ export const defaultPreset = {
175
+ items: Object.assign(Object.assign({}, commonmark.items), { [Action.strike]: {
176
+ view: strikethroughItemView,
177
+ wysiwyg: sinkListItemWysiwyg,
178
+ markup: strikethroughItemMarkup,
179
+ } }),
180
+ orders: {
181
+ [Toolbar.wysiwygMain]: [
182
+ [Action.undo, Action.redo],
183
+ [Action.bold, Action.italic, Action.strike],
184
+ [
185
+ {
186
+ id: List.heading,
187
+ items: [
188
+ Action.paragraph,
189
+ Action.heading1,
190
+ Action.heading2,
191
+ Action.heading3,
192
+ Action.heading4,
193
+ Action.heading5,
194
+ Action.heading6,
195
+ ],
196
+ },
197
+ {
198
+ id: List.lists,
199
+ items: [
200
+ Action.bulletList,
201
+ Action.orderedList,
202
+ Action.sinkListItem,
203
+ Action.liftListItem,
204
+ ],
205
+ },
206
+ Action.link,
207
+ Action.quote,
208
+ {
209
+ id: List.code,
210
+ items: [Action.codeInline, Action.codeBlock],
211
+ },
212
+ ],
213
+ ],
214
+ [Toolbar.markupMain]: [
215
+ [Action.undo, Action.redo],
216
+ [Action.bold, Action.italic, Action.strike],
217
+ [
218
+ {
219
+ id: List.heading,
220
+ items: [
221
+ Action.paragraph,
222
+ Action.heading1,
223
+ Action.heading2,
224
+ Action.heading3,
225
+ Action.heading4,
226
+ Action.heading5,
227
+ Action.heading6,
228
+ ],
229
+ },
230
+ {
231
+ id: List.lists,
232
+ items: [
233
+ Action.bulletList,
234
+ Action.orderedList,
235
+ Action.sinkListItem,
236
+ Action.liftListItem,
237
+ ],
238
+ },
239
+ Action.link,
240
+ Action.quote,
241
+ {
242
+ id: List.code,
243
+ items: [Action.codeInline, Action.codeBlock],
244
+ },
245
+ ],
246
+ ],
247
+ [Toolbar.wysiwygHidden]: [[Action.horizontalRule]],
248
+ [Toolbar.markupHidden]: [[Action.horizontalRule]],
249
+ },
250
+ };
251
+ export const yfm = {
252
+ items: Object.assign(Object.assign({}, defaultPreset.items), { [Action.underline]: {
253
+ view: underlineItemView,
254
+ wysiwyg: underlineItemWysiwyg,
255
+ markup: underlineItemMarkup,
256
+ }, [Action.mono]: {
257
+ view: monospaceItemView,
258
+ wysiwyg: monospaceItemWysiwyg,
259
+ markup: monospaceItemMarkup,
260
+ }, [Action.note]: {
261
+ view: noteItemView,
262
+ wysiwyg: noteItemWysiwyg,
263
+ markup: noteItemMarkup,
264
+ }, [Action.cut]: {
265
+ view: cutItemView,
266
+ wysiwyg: cutItemWysiwyg,
267
+ markup: cutItemMarkup,
268
+ }, [Action.image]: {
269
+ view: imageItemView,
270
+ wysiwyg: imageItemWysiwyg,
271
+ }, [Action.imagePopup]: {
272
+ view: imagePopupItemView,
273
+ markup: imageItemMarkup,
274
+ }, [Action.file]: {
275
+ view: fileItemView,
276
+ wysiwyg: fileItemWysiwyg,
277
+ }, [Action.filePopup]: {
278
+ view: filePopupItemView,
279
+ markup: fileItemMarkup,
280
+ }, [Action.table]: {
281
+ view: tableItemView,
282
+ wysiwyg: tableItemWysiwyg,
283
+ markup: tableItemMarkup,
284
+ }, [Action.checkbox]: {
285
+ view: checkboxItemView,
286
+ wysiwyg: checkboxItemWysiwyg,
287
+ markup: checkboxItemMarkup,
288
+ }, [Action.tabs]: {
289
+ view: tableItemView,
290
+ wysiwyg: tableItemWysiwyg,
291
+ markup: tableItemMarkup,
292
+ } }),
293
+ orders: {
294
+ [Toolbar.wysiwygMain]: [
295
+ [Action.undo, Action.redo],
296
+ [Action.bold, Action.italic, Action.underline, Action.strike, Action.mono],
297
+ [
298
+ {
299
+ id: List.heading,
300
+ items: [
301
+ Action.paragraph,
302
+ Action.heading1,
303
+ Action.heading2,
304
+ Action.heading3,
305
+ Action.heading4,
306
+ Action.heading5,
307
+ Action.heading6,
308
+ ],
309
+ },
310
+ {
311
+ id: List.lists,
312
+ items: [
313
+ Action.bulletList,
314
+ Action.orderedList,
315
+ Action.sinkListItem,
316
+ Action.liftListItem,
317
+ ],
318
+ },
319
+ Action.link,
320
+ Action.note,
321
+ Action.cut,
322
+ Action.quote,
323
+ {
324
+ id: List.code,
325
+ items: [Action.codeInline, Action.codeBlock],
326
+ },
327
+ ],
328
+ [Action.image, Action.file, Action.table, Action.checkbox],
329
+ ],
330
+ [Toolbar.markupMain]: [
331
+ [Action.undo, Action.redo],
332
+ [Action.bold, Action.italic, Action.underline, Action.strike, Action.mono],
333
+ [
334
+ {
335
+ id: List.heading,
336
+ items: [
337
+ Action.paragraph,
338
+ Action.heading1,
339
+ Action.heading2,
340
+ Action.heading3,
341
+ Action.heading4,
342
+ Action.heading5,
343
+ Action.heading6,
344
+ ],
345
+ },
346
+ {
347
+ id: List.lists,
348
+ items: [
349
+ Action.bulletList,
350
+ Action.orderedList,
351
+ Action.sinkListItem,
352
+ Action.liftListItem,
353
+ ],
354
+ },
355
+ Action.link,
356
+ Action.note,
357
+ Action.cut,
358
+ Action.quote,
359
+ {
360
+ id: List.code,
361
+ items: [Action.codeInline, Action.codeBlock],
362
+ },
363
+ ],
364
+ [Action.imagePopup, Action.filePopup, Action.table, Action.checkbox],
365
+ ],
366
+ [Toolbar.wysiwygHidden]: [[Action.horizontalRule, Action.tabs]],
367
+ [Toolbar.markupHidden]: [[Action.horizontalRule, Action.tabs]],
368
+ },
369
+ };
370
+ export const full = {
371
+ items: Object.assign(Object.assign({}, yfm.items), { [Action.mark]: {
372
+ view: markedItemView,
373
+ wysiwyg: markedItemWysiwyg,
374
+ markup: markedItemMarkup,
375
+ }, [Action.colorify]: {
376
+ view: colorifyItemView,
377
+ wysiwyg: colorifyItemWysiwyg,
378
+ markup: colorifyItemMarkup,
379
+ }, [Action.emoji]: {
380
+ view: emojiItemView,
381
+ wysiwyg: emojiItemWysiwyg,
382
+ markup: emojiItemMarkup,
383
+ } }),
384
+ orders: {
385
+ [Toolbar.wysiwygMain]: [
386
+ [Action.undo, Action.redo],
387
+ [Action.bold, Action.italic, Action.underline, Action.strike, Action.mono, Action.mark],
388
+ [
389
+ {
390
+ id: List.heading,
391
+ items: [
392
+ Action.paragraph,
393
+ Action.heading1,
394
+ Action.heading2,
395
+ Action.heading3,
396
+ Action.heading4,
397
+ Action.heading5,
398
+ Action.heading6,
399
+ ],
400
+ },
401
+ {
402
+ id: List.lists,
403
+ items: [
404
+ Action.bulletList,
405
+ Action.orderedList,
406
+ Action.sinkListItem,
407
+ Action.liftListItem,
408
+ ],
409
+ },
410
+ Action.colorify,
411
+ Action.link,
412
+ Action.note,
413
+ Action.cut,
414
+ Action.quote,
415
+ {
416
+ id: List.code,
417
+ items: [Action.codeInline, Action.codeBlock],
418
+ },
419
+ ],
420
+ [Action.image, Action.file, Action.table, Action.checkbox],
421
+ ],
422
+ [Toolbar.markupMain]: [
423
+ [Action.undo, Action.redo],
424
+ [Action.bold, Action.italic, Action.underline, Action.strike, Action.mono, Action.mark],
425
+ [
426
+ {
427
+ id: List.heading,
428
+ items: [
429
+ Action.paragraph,
430
+ Action.heading1,
431
+ Action.heading2,
432
+ Action.heading3,
433
+ Action.heading4,
434
+ Action.heading5,
435
+ Action.heading6,
436
+ ],
437
+ },
438
+ {
439
+ id: List.lists,
440
+ items: [
441
+ Action.bulletList,
442
+ Action.orderedList,
443
+ Action.sinkListItem,
444
+ Action.liftListItem,
445
+ ],
446
+ },
447
+ Action.colorify,
448
+ Action.link,
449
+ Action.note,
450
+ Action.cut,
451
+ Action.quote,
452
+ {
453
+ id: List.code,
454
+ items: [Action.codeInline, Action.codeBlock],
455
+ },
456
+ ],
457
+ [Action.imagePopup, Action.filePopup, Action.table, Action.checkbox],
458
+ ],
459
+ [Toolbar.wysiwygHidden]: [[Action.horizontalRule, Action.emoji, Action.tabs]],
460
+ [Toolbar.markupHidden]: [[Action.horizontalRule, Action.emoji, Action.tabs]],
461
+ },
462
+ };
@@ -0,0 +1,62 @@
1
+ import type { RefObject } from 'react';
2
+ import type { HotkeyProps } from '@gravity-ui/uikit';
3
+ import type { EditorState } from 'prosemirror-state';
4
+ import type { ActionStorage } from '../../core';
5
+ import type { CodeEditor } from '../../markup';
6
+ import type { ToolbarBaseProps, ToolbarDataType, ToolbarIconData } from '../../toolbar';
7
+ export declare type ToolbarItemId = string & {};
8
+ export declare type ToolbarListId = string & {};
9
+ export interface ToolbarList {
10
+ id: ToolbarListId;
11
+ items: ToolbarItemId[];
12
+ }
13
+ /**
14
+ * The default value for the `type` property is `ToolbarDataType.SingleButton`.
15
+ */
16
+ export declare type ToolbarItemView<T extends ToolbarDataType = ToolbarDataType.SingleButton> = {
17
+ className?: string;
18
+ hint?: string | (() => string);
19
+ hotkey?: HotkeyProps['value'];
20
+ type?: ToolbarDataType;
21
+ doNotActivateList?: boolean;
22
+ } & (T extends ToolbarDataType.SingleButton ? {
23
+ icon: ToolbarIconData;
24
+ title: string | (() => string);
25
+ } : T extends ToolbarDataType.ListButton ? {
26
+ withArrow?: boolean;
27
+ icon: ToolbarIconData;
28
+ title: string | (() => string);
29
+ } : {});
30
+ export interface EditorActions<E> {
31
+ exec(editor: E): void;
32
+ isActive(editor: E): boolean;
33
+ isEnable(editor: E): boolean;
34
+ }
35
+ declare type ToolbarItemEditor<T, E> = Partial<EditorActions<E>> & {
36
+ hintWhenDisabled?: boolean | string | (() => string);
37
+ condition?: ((state: EditorState) => void) | 'enabled';
38
+ } & (T extends ToolbarDataType.ButtonPopup ? {
39
+ renderPopup: (props: ToolbarBaseProps<E> & {
40
+ hide: () => void;
41
+ anchorRef: RefObject<HTMLElement>;
42
+ }) => React.ReactNode;
43
+ } : T extends ToolbarDataType.ReactComponent ? {
44
+ width: number;
45
+ component: React.ComponentType<ToolbarBaseProps<E>>;
46
+ } : {});
47
+ export declare type ToolbarItemWysiwyg<T extends ToolbarDataType = ToolbarDataType.SingleButton> = ToolbarItemEditor<T, ActionStorage>;
48
+ export declare type ToolbarItemMarkup<T extends ToolbarDataType = ToolbarDataType.SingleButton> = ToolbarItemEditor<T, CodeEditor>;
49
+ export declare type ToolbarItem<T extends ToolbarDataType> = {
50
+ view: ToolbarItemView<T>;
51
+ wysiwyg?: ToolbarItemWysiwyg<T>;
52
+ markup?: ToolbarItemMarkup<T>;
53
+ };
54
+ export declare type ToolbarsItems = Record<ToolbarItemId, ToolbarItem<ToolbarDataType>>;
55
+ export declare type ToolbarId = string;
56
+ export declare type ToolbarOrders = (ToolbarList | ToolbarItemId)[][];
57
+ export declare type ToolbarsOrders = Record<ToolbarId, ToolbarOrders>;
58
+ export interface ToolbarsPreset {
59
+ items: ToolbarsItems;
60
+ orders: ToolbarsOrders;
61
+ }
62
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -38,7 +38,9 @@ export declare enum ToolbarDataType {
38
38
  SingleButton = "s-button",
39
39
  ListButton = "list-b",
40
40
  ButtonPopup = "b-popup",
41
+ /** @deprecated Use ReactComponent type instead */
41
42
  ReactNode = "r-node",
43
+ /** @deprecated Use ReactComponent type instead */
42
44
  ReactNodeFn = "r-node-fn",
43
45
  ReactComponent = "r-component"
44
46
  }
@@ -73,12 +75,18 @@ export declare type ToolbarButtonPopupData<E> = ToolbarItemData<E> & {
73
75
  export declare type ToolbarListButtonItemData<E> = ToolbarItemData<E> & {
74
76
  doNotActivateList?: boolean;
75
77
  };
78
+ /**
79
+ * @deprecated Use ReactComponent type instead
80
+ * */
76
81
  export declare type ToolbarReactNodeData = {
77
82
  id: string;
78
83
  type: ToolbarDataType.ReactNode;
79
84
  width: number;
80
85
  content: React.ReactNode;
81
86
  };
87
+ /**
88
+ * @deprecated Use ReactComponent type instead
89
+ * */
82
90
  export declare type ToolbarReactNodeFnData<E> = {
83
91
  id: string;
84
92
  type: ToolbarDataType.ReactNodeFn;
@@ -3,7 +3,9 @@ export var ToolbarDataType;
3
3
  ToolbarDataType["SingleButton"] = "s-button";
4
4
  ToolbarDataType["ListButton"] = "list-b";
5
5
  ToolbarDataType["ButtonPopup"] = "b-popup";
6
+ /** @deprecated Use ReactComponent type instead */
6
7
  ToolbarDataType["ReactNode"] = "r-node";
8
+ /** @deprecated Use ReactComponent type instead */
7
9
  ToolbarDataType["ReactNodeFn"] = "r-node-fn";
8
10
  ToolbarDataType["ReactComponent"] = "r-component";
9
11
  })(ToolbarDataType || (ToolbarDataType = {}));
@@ -1,2 +1,2 @@
1
1
  /** During build process, the current version will be injected here */
2
- export const VERSION = typeof '14.8.0' !== 'undefined' ? '14.8.0' : 'unknown';
2
+ export const VERSION = typeof '14.9.0' !== 'undefined' ? '14.9.0' : 'unknown';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/markdown-editor",
3
- "version": "14.8.0",
3
+ "version": "14.9.0",
4
4
  "description": "Markdown wysiwyg and markup editor",
5
5
  "license": "MIT",
6
6
  "repository": {