@gravity-ui/markdown-editor 14.7.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 +10 -2
@@ -0,0 +1,730 @@
1
+ import React from 'react';
2
+ import { icons } from '../../bundle/config/icons';
3
+ import { MToolbarColors } from '../../bundle/toolbar/markup/MToolbarColors';
4
+ import { MToolbarFilePopup } from '../../bundle/toolbar/markup/MToolbarFilePopup';
5
+ import { MToolbarImagePopup } from '../../bundle/toolbar/markup/MToolbarImagePopup';
6
+ import { WToolbarColors } from '../../bundle/toolbar/wysiwyg/WToolbarColors';
7
+ import { WToolbarTextSelect } from '../../bundle/toolbar/wysiwyg/WToolbarTextSelect';
8
+ import { headingType, pType } from '../../extensions';
9
+ import { gptHotKeys } from '../../extensions/additional/GPT/constants';
10
+ import { i18n as i18nHint } from '../../i18n/hints';
11
+ import { i18n } from '../../i18n/menubar';
12
+ import { insertHRule, insertLink, insertMermaidDiagram, insertYfmHtmlBlock, insertYfmTable, insertYfmTabs, liftListItem as liftListItemCommand, redo, redoDepth, sinkListItem as sinkListItemCommand, toBulletList, toH1, toH2, toH3, toH4, toH5, toH6, toOrderedList, toggleBold, toggleItalic, toggleMarked, toggleMonospace, toggleStrikethrough, toggleUnderline, undo, undoDepth, wrapToBlockquote, wrapToCheckbox, wrapToCodeBlock, wrapToInlineCode, wrapToMathBlock, wrapToMathInline, wrapToYfmCut, wrapToYfmNote, } from '../../markup/commands';
13
+ import { Action as A, formatter as f } from '../../shortcuts';
14
+ import { ToolbarDataType } from '../../toolbar';
15
+ const noop = () => { };
16
+ const inactive = () => false;
17
+ const enable = () => true;
18
+ const disable = () => false;
19
+ // ---- Undo ----
20
+ export const undoItemView = {
21
+ type: ToolbarDataType.SingleButton,
22
+ title: i18n.bind(null, 'undo'),
23
+ icon: icons.undo,
24
+ hotkey: f.toView(A.Undo),
25
+ };
26
+ export const undoItemWysiwyg = {
27
+ hintWhenDisabled: false,
28
+ exec: (e) => e.actions.undo.run(),
29
+ isActive: (e) => e.actions.undo.isActive(),
30
+ isEnable: (e) => e.actions.undo.isEnable(),
31
+ };
32
+ export const undoItemMarkup = {
33
+ hintWhenDisabled: false,
34
+ exec: (e) => undo(e.cm),
35
+ isActive: inactive,
36
+ isEnable: (e) => undoDepth(e.cm.state) > 0,
37
+ };
38
+ // ---- Redo ----
39
+ export const redoItemView = {
40
+ type: ToolbarDataType.SingleButton,
41
+ title: i18n.bind(null, 'redo'),
42
+ icon: icons.redo,
43
+ hotkey: f.toView(A.Redo),
44
+ };
45
+ export const redoItemWysiwyg = {
46
+ hintWhenDisabled: false,
47
+ exec: (e) => e.actions.redo.run(),
48
+ isActive: (e) => e.actions.redo.isActive(),
49
+ isEnable: (e) => e.actions.redo.isEnable(),
50
+ };
51
+ export const redoItemMarkup = {
52
+ hintWhenDisabled: false,
53
+ exec: (e) => redo(e.cm),
54
+ isActive: inactive,
55
+ isEnable: (e) => redoDepth(e.cm.state) > 0,
56
+ };
57
+ // ---- Bold ----
58
+ export const boldItemView = {
59
+ type: ToolbarDataType.SingleButton,
60
+ title: i18n.bind(null, 'bold'),
61
+ icon: icons.bold,
62
+ hotkey: f.toView(A.Bold),
63
+ };
64
+ export const boldItemWysiwyg = {
65
+ exec: (e) => e.actions.bold.run(),
66
+ isActive: (e) => e.actions.bold.isActive(),
67
+ isEnable: (e) => e.actions.bold.isEnable(),
68
+ };
69
+ export const boldItemMarkup = {
70
+ exec: (e) => toggleBold(e.cm),
71
+ isActive: inactive,
72
+ isEnable: enable,
73
+ };
74
+ // ---- Italic ----
75
+ export const italicItemView = {
76
+ type: ToolbarDataType.SingleButton,
77
+ title: i18n.bind(null, 'italic'),
78
+ icon: icons.italic,
79
+ hotkey: f.toView(A.Italic),
80
+ };
81
+ export const italicItemWysiwyg = {
82
+ exec: (e) => e.actions.italic.run(),
83
+ isActive: (e) => e.actions.italic.isActive(),
84
+ isEnable: (e) => e.actions.italic.isEnable(),
85
+ };
86
+ export const italicItemMarkup = {
87
+ exec: (e) => toggleItalic(e.cm),
88
+ isActive: inactive,
89
+ isEnable: enable,
90
+ };
91
+ // ---- Underline ----
92
+ export const underlineItemView = {
93
+ type: ToolbarDataType.SingleButton,
94
+ title: i18n.bind(null, 'underline'),
95
+ icon: icons.underline,
96
+ hotkey: f.toView(A.Underline),
97
+ };
98
+ export const underlineItemWysiwyg = {
99
+ exec: (e) => e.actions.underline.run(),
100
+ isActive: (e) => e.actions.underline.isActive(),
101
+ isEnable: (e) => e.actions.underline.isEnable(),
102
+ };
103
+ export const underlineItemMarkup = {
104
+ exec: (e) => toggleUnderline(e.cm),
105
+ isActive: inactive,
106
+ isEnable: enable,
107
+ };
108
+ // ---- Strikethrough ----
109
+ export const strikethroughItemView = {
110
+ type: ToolbarDataType.SingleButton,
111
+ title: i18n.bind(null, 'strike'),
112
+ icon: icons.strikethrough,
113
+ hotkey: f.toView(A.Strike),
114
+ };
115
+ export const strikethroughItemWysiwyg = {
116
+ exec: (e) => e.actions.strike.run(),
117
+ isActive: (e) => e.actions.strike.isActive(),
118
+ isEnable: (e) => e.actions.strike.isEnable(),
119
+ };
120
+ export const strikethroughItemMarkup = {
121
+ exec: (e) => toggleStrikethrough(e.cm),
122
+ isActive: inactive,
123
+ isEnable: enable,
124
+ };
125
+ // ---- Monospace ----
126
+ export const monospaceItemView = {
127
+ type: ToolbarDataType.SingleButton,
128
+ title: i18n.bind(null, 'mono'),
129
+ icon: icons.mono,
130
+ };
131
+ export const monospaceItemWysiwyg = {
132
+ exec: (e) => e.actions.mono.run(),
133
+ isActive: (e) => e.actions.mono.isActive(),
134
+ isEnable: (e) => e.actions.mono.isEnable(),
135
+ };
136
+ export const monospaceItemMarkup = {
137
+ exec: (e) => toggleMonospace(e.cm),
138
+ isActive: inactive,
139
+ isEnable: enable,
140
+ };
141
+ // ---- Marked ----
142
+ export const markedItemView = {
143
+ type: ToolbarDataType.SingleButton,
144
+ title: i18n.bind(null, 'mark'),
145
+ icon: icons.mark,
146
+ };
147
+ export const markedItemWysiwyg = {
148
+ exec: (e) => e.actions.mark.run(),
149
+ isActive: (e) => e.actions.mark.isActive(),
150
+ isEnable: (e) => e.actions.mark.isEnable(),
151
+ };
152
+ export const markedItemMarkup = {
153
+ exec: (e) => toggleMarked(e.cm),
154
+ isActive: inactive,
155
+ isEnable: enable,
156
+ };
157
+ // ---- Checkbox ----
158
+ export const checkboxItemView = {
159
+ type: ToolbarDataType.SingleButton,
160
+ title: i18n.bind(null, 'checkbox'),
161
+ icon: icons.checklist,
162
+ };
163
+ export const checkboxItemWysiwyg = {
164
+ exec: (e) => e.actions.addCheckbox.run(),
165
+ isActive: (e) => e.actions.addCheckbox.isActive(),
166
+ isEnable: (e) => e.actions.addCheckbox.isEnable(),
167
+ };
168
+ export const checkboxItemMarkup = {
169
+ exec: (e) => wrapToCheckbox(e.cm),
170
+ isActive: inactive,
171
+ isEnable: enable,
172
+ };
173
+ // ---- Link ----
174
+ export const linkItemView = {
175
+ type: ToolbarDataType.SingleButton,
176
+ title: i18n.bind(null, 'link'),
177
+ icon: icons.link,
178
+ hotkey: f.toView(A.Link),
179
+ };
180
+ export const linkItemWysiwyg = {
181
+ exec: (e) => e.actions.addLink.run(),
182
+ isActive: (e) => e.actions.addLink.isActive(),
183
+ isEnable: (e) => e.actions.addLink.isEnable(),
184
+ };
185
+ export const linkItemMarkup = {
186
+ exec: (e) => insertLink(e.cm),
187
+ isActive: inactive,
188
+ isEnable: enable,
189
+ };
190
+ // ---- Quote ----
191
+ export const quoteItemView = {
192
+ type: ToolbarDataType.SingleButton,
193
+ title: i18n.bind(null, 'quote'),
194
+ icon: icons.quote,
195
+ hotkey: f.toView(A.Quote),
196
+ };
197
+ export const quoteItemWysiwyg = {
198
+ exec: (e) => e.actions.quote.run(),
199
+ isActive: (e) => e.actions.quote.isActive(),
200
+ isEnable: (e) => e.actions.quote.isEnable(),
201
+ };
202
+ export const quoteItemMarkup = {
203
+ exec: (e) => wrapToBlockquote(e.cm),
204
+ isActive: inactive,
205
+ isEnable: enable,
206
+ };
207
+ // ---- Cut ----
208
+ export const cutItemView = {
209
+ type: ToolbarDataType.SingleButton,
210
+ title: i18n.bind(null, 'cut'),
211
+ icon: icons.cut,
212
+ hotkey: f.toView(A.Cut),
213
+ };
214
+ export const cutItemWysiwyg = {
215
+ exec: (e) => e.actions.toYfmCut.run(),
216
+ isActive: (e) => e.actions.toYfmCut.isActive(),
217
+ isEnable: (e) => e.actions.toYfmCut.isEnable(),
218
+ };
219
+ export const cutItemMarkup = {
220
+ exec: (e) => wrapToYfmCut(e.cm),
221
+ isActive: inactive,
222
+ isEnable: enable,
223
+ };
224
+ // ---- Note ----
225
+ export const noteItemView = {
226
+ type: ToolbarDataType.SingleButton,
227
+ title: i18n.bind(null, 'note'),
228
+ icon: icons.note,
229
+ hotkey: f.toView(A.Note),
230
+ };
231
+ export const noteItemWysiwyg = {
232
+ exec: (e) => e.actions.toYfmNote.run(),
233
+ isActive: (e) => e.actions.toYfmNote.isActive(),
234
+ isEnable: (e) => e.actions.toYfmNote.isEnable(),
235
+ };
236
+ export const noteItemMarkup = {
237
+ exec: (e) => wrapToYfmNote(e.cm),
238
+ isActive: inactive,
239
+ isEnable: enable,
240
+ };
241
+ // ---- Table ----
242
+ export const tableItemView = {
243
+ type: ToolbarDataType.SingleButton,
244
+ title: i18n.bind(null, 'table'),
245
+ icon: icons.table,
246
+ };
247
+ export const tableItemWysiwyg = {
248
+ exec: (e) => e.actions.createYfmTable.run(),
249
+ isActive: (e) => e.actions.createYfmTable.isActive(),
250
+ isEnable: (e) => e.actions.createYfmTable.isEnable(),
251
+ };
252
+ export const tableItemMarkup = {
253
+ exec: (e) => insertYfmTable(e.cm),
254
+ isActive: inactive,
255
+ isEnable: enable,
256
+ };
257
+ // ---- Code ----
258
+ export const codeItemView = {
259
+ type: ToolbarDataType.SingleButton,
260
+ title: i18n.bind(null, 'code_inline'),
261
+ icon: icons.code,
262
+ hotkey: f.toView(A.Code),
263
+ };
264
+ export const codeItemWysiwyg = {
265
+ exec: (e) => e.actions.code.run(),
266
+ isActive: (e) => e.actions.code.isActive(),
267
+ isEnable: (e) => e.actions.code.isEnable(),
268
+ };
269
+ export const codeItemMarkup = {
270
+ exec: (e) => wrapToInlineCode(e.cm),
271
+ isActive: inactive,
272
+ isEnable: enable,
273
+ };
274
+ // ---- Image ----
275
+ export const imageItemView = {
276
+ type: ToolbarDataType.SingleButton,
277
+ title: i18n.bind(null, 'image'),
278
+ icon: icons.image,
279
+ };
280
+ export const imagePopupItemView = {
281
+ type: ToolbarDataType.ButtonPopup,
282
+ title: i18n.bind(null, 'image'),
283
+ icon: icons.image,
284
+ };
285
+ export const imageItemWysiwyg = {
286
+ exec: (e) => e.actions.addImageWidget.run(),
287
+ isActive: (e) => e.actions.addImageWidget.isActive(),
288
+ isEnable: (e) => e.actions.addImageWidget.isEnable(),
289
+ };
290
+ export const imageItemMarkup = {
291
+ exec: noop,
292
+ isActive: inactive,
293
+ isEnable: enable,
294
+ renderPopup: (props) => React.createElement(MToolbarImagePopup, Object.assign({}, props)),
295
+ };
296
+ // ---- File ----
297
+ export const fileItemView = {
298
+ type: ToolbarDataType.SingleButton,
299
+ title: i18n.bind(null, 'file'),
300
+ icon: icons.file,
301
+ };
302
+ export const filePopupItemView = {
303
+ type: ToolbarDataType.ButtonPopup,
304
+ title: i18n.bind(null, 'file'),
305
+ icon: icons.file,
306
+ };
307
+ export const fileItemWysiwyg = {
308
+ exec: (e) => e.actions.addFile.run(),
309
+ isActive: (e) => e.actions.addFile.isActive(),
310
+ isEnable: (e) => e.actions.addFile.isEnable(),
311
+ };
312
+ export const fileItemMarkup = {
313
+ exec: noop,
314
+ isActive: inactive,
315
+ isEnable: enable,
316
+ renderPopup: (props) => React.createElement(MToolbarFilePopup, Object.assign({}, props)),
317
+ };
318
+ // ---- Tabs ----
319
+ export const tabsItemView = {
320
+ type: ToolbarDataType.SingleButton,
321
+ title: i18n.bind(null, 'tabs'),
322
+ icon: icons.tabs,
323
+ };
324
+ export const tabsItemWysiwyg = {
325
+ exec: (e) => e.actions.toYfmTabs.run(),
326
+ isActive: (e) => e.actions.toYfmTabs.isActive(),
327
+ isEnable: (e) => e.actions.toYfmTabs.isEnable(),
328
+ };
329
+ export const tabsItemMarkup = {
330
+ exec: (e) => insertYfmTabs(e.cm),
331
+ isActive: inactive,
332
+ isEnable: enable,
333
+ };
334
+ // ---- Math Inline ----
335
+ export const mathInlineItemView = {
336
+ type: ToolbarDataType.SingleButton,
337
+ title: i18n.bind(null, 'math_inline'),
338
+ icon: icons.functionInline,
339
+ hint: () => `${i18nHint.bind(null, 'math_hint')()} ${i18nHint.bind(null, 'math_hint_katex')()}`,
340
+ };
341
+ export const mathInlineItemWysiwyg = {
342
+ exec: (e) => e.actions.addMathInline.run(),
343
+ isActive: (e) => e.actions.addMathInline.isActive(),
344
+ isEnable: (e) => e.actions.addMathInline.isEnable(),
345
+ };
346
+ export const mathInlineItemMarkup = {
347
+ exec: (e) => wrapToMathInline(e.cm),
348
+ isActive: inactive,
349
+ isEnable: enable,
350
+ };
351
+ // ---- Math Block ----
352
+ export const mathBlockItemView = {
353
+ type: ToolbarDataType.SingleButton,
354
+ title: i18n.bind(null, 'math_block'),
355
+ icon: icons.functionBlock,
356
+ hint: () => `${i18nHint.bind(null, 'math_hint')()} ${i18nHint.bind(null, 'math_hint_katex')()}`,
357
+ };
358
+ export const mathBlockItemWysiwyg = {
359
+ exec: (e) => e.actions.toMathBlock.run(),
360
+ isActive: (e) => e.actions.toMathBlock.isActive(),
361
+ isEnable: (e) => e.actions.toMathBlock.isEnable(),
362
+ };
363
+ export const mathBlockItemMarkup = {
364
+ exec: (e) => wrapToMathBlock(e.cm),
365
+ isActive: inactive,
366
+ isEnable: enable,
367
+ };
368
+ // ---- Yfm Html Block ----
369
+ export const yfmHtmlBlockItemView = {
370
+ type: ToolbarDataType.SingleButton,
371
+ title: i18n.bind(null, 'html'),
372
+ icon: icons.html,
373
+ };
374
+ export const yfmHtmlBlockItemWysiwyg = {
375
+ exec: (e) => e.actions.createYfmHtmlBlock.run(),
376
+ isActive: (e) => e.actions.createYfmHtmlBlock.isActive(),
377
+ isEnable: (e) => e.actions.createYfmHtmlBlock.isEnable(),
378
+ };
379
+ export const yfmHtmlBlockItemMarkup = {
380
+ exec: (e) => insertYfmHtmlBlock(e.cm),
381
+ isActive: inactive,
382
+ isEnable: enable,
383
+ };
384
+ // ---- Mermaid ----
385
+ export const mermaidItemView = {
386
+ type: ToolbarDataType.SingleButton,
387
+ title: i18n.bind(null, 'mermaid'),
388
+ icon: icons.mermaid,
389
+ };
390
+ export const mermaidItemWysiwyg = {
391
+ exec: (e) => e.actions.createMermaid.run(),
392
+ isActive: (e) => e.actions.createMermaid.isActive(),
393
+ isEnable: (e) => e.actions.createMermaid.isEnable(),
394
+ };
395
+ export const mermaidItemMarkup = {
396
+ exec: (e) => insertMermaidDiagram(e.cm),
397
+ isActive: inactive,
398
+ isEnable: enable,
399
+ };
400
+ // ---- Code Block ----
401
+ export const codeBlockItemView = {
402
+ type: ToolbarDataType.SingleButton,
403
+ title: i18n.bind(null, 'codeblock'),
404
+ icon: icons.codeBlock,
405
+ hotkey: f.toView(A.CodeBlock),
406
+ };
407
+ export const codeBlockItemWysiwyg = {
408
+ exec: (e) => e.actions.toCodeBlock.run(),
409
+ isActive: (e) => e.actions.toCodeBlock.isActive(),
410
+ isEnable: (e) => e.actions.toCodeBlock.isEnable(),
411
+ };
412
+ export const codeBlockItemMarkup = {
413
+ exec: (e) => wrapToCodeBlock(e.cm),
414
+ isActive: inactive,
415
+ isEnable: enable,
416
+ };
417
+ // ---- Horizontal Rule ----
418
+ export const hruleItemView = {
419
+ type: ToolbarDataType.SingleButton,
420
+ title: i18n.bind(null, 'hrule'),
421
+ icon: icons.horizontalRule,
422
+ };
423
+ export const hruleItemWysiwyg = {
424
+ exec: (e) => e.actions.hRule.run(),
425
+ isActive: (e) => e.actions.hRule.isActive(),
426
+ isEnable: (e) => e.actions.hRule.isEnable(),
427
+ };
428
+ export const hruleItemMarkup = {
429
+ exec: (e) => insertHRule(e.cm),
430
+ isActive: inactive,
431
+ isEnable: enable,
432
+ };
433
+ // ---- Emoji ----
434
+ export const emojiItemView = {
435
+ type: ToolbarDataType.SingleButton,
436
+ title: i18n.bind(null, 'emoji'),
437
+ icon: icons.emoji,
438
+ };
439
+ export const emojiItemWysiwyg = {
440
+ exec: (e) => e.actions.openEmojiSuggest.run({}),
441
+ isActive: (e) => e.actions.openEmojiSuggest.isActive(),
442
+ isEnable: (e) => e.actions.openEmojiSuggest.isEnable(),
443
+ };
444
+ export const emojiItemMarkup = {
445
+ exec: noop,
446
+ hintWhenDisabled: i18n.bind(null, 'emoji__hint'),
447
+ isActive: inactive,
448
+ isEnable: disable,
449
+ };
450
+ // ---- Heading 1 ----
451
+ export const heading1ItemView = {
452
+ type: ToolbarDataType.SingleButton,
453
+ title: i18n.bind(null, 'heading1'),
454
+ icon: icons.h1,
455
+ hotkey: f.toView(A.Heading1),
456
+ };
457
+ export const heading1ItemWysiwyg = {
458
+ exec: (e) => e.actions.toH1.run(),
459
+ isActive: (e) => e.actions.toH1.isActive(),
460
+ isEnable: (e) => e.actions.toH1.isEnable(),
461
+ };
462
+ export const heading1ItemMarkup = {
463
+ exec: (e) => toH1(e.cm),
464
+ isActive: inactive,
465
+ isEnable: enable,
466
+ };
467
+ // ---- Heading 2 ----
468
+ export const heading2ItemView = {
469
+ type: ToolbarDataType.SingleButton,
470
+ title: i18n.bind(null, 'heading2'),
471
+ icon: icons.h2,
472
+ hotkey: f.toView(A.Heading2),
473
+ };
474
+ export const heading2ItemWysiwyg = {
475
+ exec: (e) => e.actions.toH2.run(),
476
+ isActive: (e) => e.actions.toH2.isActive(),
477
+ isEnable: (e) => e.actions.toH2.isEnable(),
478
+ };
479
+ export const heading2ItemMarkup = {
480
+ exec: (e) => toH2(e.cm),
481
+ isActive: inactive,
482
+ isEnable: enable,
483
+ };
484
+ // ---- Heading 3 ----
485
+ export const heading3ItemView = {
486
+ type: ToolbarDataType.SingleButton,
487
+ title: i18n.bind(null, 'heading3'),
488
+ icon: icons.h3,
489
+ hotkey: f.toView(A.Heading3),
490
+ };
491
+ export const heading3ItemWysiwyg = {
492
+ exec: (e) => e.actions.toH3.run(),
493
+ isActive: (e) => e.actions.toH3.isActive(),
494
+ isEnable: (e) => e.actions.toH3.isEnable(),
495
+ };
496
+ export const heading3ItemMarkup = {
497
+ exec: (e) => toH3(e.cm),
498
+ isActive: inactive,
499
+ isEnable: enable,
500
+ };
501
+ // ---- Heading 4 ----
502
+ export const heading4ItemView = {
503
+ type: ToolbarDataType.SingleButton,
504
+ title: i18n.bind(null, 'heading4'),
505
+ icon: icons.h4,
506
+ hotkey: f.toView(A.Heading4),
507
+ };
508
+ export const heading4ItemWysiwyg = {
509
+ exec: (e) => e.actions.toH4.run(),
510
+ isActive: (e) => e.actions.toH4.isActive(),
511
+ isEnable: (e) => e.actions.toH4.isEnable(),
512
+ };
513
+ export const heading4ItemMarkup = {
514
+ exec: (e) => toH4(e.cm),
515
+ isActive: inactive,
516
+ isEnable: enable,
517
+ };
518
+ // ---- Heading 5 ----
519
+ export const heading5ItemView = {
520
+ type: ToolbarDataType.SingleButton,
521
+ title: i18n.bind(null, 'heading5'),
522
+ icon: icons.h5,
523
+ hotkey: f.toView(A.Heading5),
524
+ };
525
+ export const heading5ItemWysiwyg = {
526
+ exec: (e) => e.actions.toH5.run(),
527
+ isActive: (e) => e.actions.toH5.isActive(),
528
+ isEnable: (e) => e.actions.toH5.isEnable(),
529
+ };
530
+ export const heading5ItemMarkup = {
531
+ exec: (e) => toH5(e.cm),
532
+ isActive: inactive,
533
+ isEnable: enable,
534
+ };
535
+ // ---- Heading 6 ----
536
+ export const heading6ItemView = {
537
+ type: ToolbarDataType.SingleButton,
538
+ title: i18n.bind(null, 'heading6'),
539
+ icon: icons.h6,
540
+ hotkey: f.toView(A.Heading6),
541
+ };
542
+ export const heading6ItemWysiwyg = {
543
+ exec: (e) => e.actions.toH6.run(),
544
+ isActive: (e) => e.actions.toH6.isActive(),
545
+ isEnable: (e) => e.actions.toH6.isEnable(),
546
+ };
547
+ export const heading6ItemMarkup = {
548
+ exec: (e) => toH6(e.cm),
549
+ isActive: inactive,
550
+ isEnable: enable,
551
+ };
552
+ // ---- Bullet List ----
553
+ export const bulletListItemView = {
554
+ type: ToolbarDataType.SingleButton,
555
+ title: i18n.bind(null, 'ulist'),
556
+ icon: icons.bulletList,
557
+ hotkey: f.toView(A.BulletList),
558
+ };
559
+ export const bulletListItemWysiwyg = {
560
+ exec: (e) => e.actions.toBulletList.run(),
561
+ isActive: (e) => e.actions.toBulletList.isActive(),
562
+ isEnable: (e) => e.actions.toBulletList.isEnable(),
563
+ };
564
+ export const bulletListItemMarkup = {
565
+ exec: (e) => toBulletList(e.cm),
566
+ isActive: inactive,
567
+ isEnable: enable,
568
+ };
569
+ // ---- Ordered List ----
570
+ export const orderedListItemView = {
571
+ type: ToolbarDataType.SingleButton,
572
+ title: i18n.bind(null, 'olist'),
573
+ icon: icons.orderedList,
574
+ hotkey: f.toView(A.OrderedList),
575
+ };
576
+ export const orderedListItemWysiwyg = {
577
+ exec: (e) => e.actions.toOrderedList.run(),
578
+ isActive: (e) => e.actions.toOrderedList.isActive(),
579
+ isEnable: (e) => e.actions.toOrderedList.isEnable(),
580
+ };
581
+ export const orderedListItemMarkup = {
582
+ exec: (e) => toOrderedList(e.cm),
583
+ isActive: inactive,
584
+ isEnable: enable,
585
+ };
586
+ // ---- Sink List ----
587
+ export const sinkListItemView = {
588
+ type: ToolbarDataType.SingleButton,
589
+ title: i18n.bind(null, 'list__action_sink'),
590
+ icon: icons.sink,
591
+ hotkey: f.toView(A.SinkListItem),
592
+ };
593
+ export const sinkListItemWysiwyg = {
594
+ exec: (e) => e.actions.sinkListItem.run(),
595
+ hintWhenDisabled: () => i18n('list_action_disabled'),
596
+ isActive: (e) => e.actions.sinkListItem.isActive(),
597
+ isEnable: (e) => e.actions.sinkListItem.isEnable(),
598
+ };
599
+ export const sinkListItemMarkup = {
600
+ exec: (e) => sinkListItemCommand(e.cm),
601
+ isActive: inactive,
602
+ isEnable: enable,
603
+ };
604
+ // ---- Lift List ----
605
+ export const liftListItemView = {
606
+ type: ToolbarDataType.SingleButton,
607
+ title: i18n.bind(null, 'list__action_lift'),
608
+ icon: icons.lift,
609
+ hotkey: f.toView(A.LiftListItem),
610
+ };
611
+ export const liftListItemWysiwyg = {
612
+ exec: (e) => e.actions.liftListItem.run(),
613
+ hintWhenDisabled: () => i18n('list_action_disabled'),
614
+ isActive: (e) => e.actions.liftListItem.isActive(),
615
+ isEnable: (e) => e.actions.liftListItem.isEnable(),
616
+ };
617
+ export const liftListItemMarkup = {
618
+ exec: (e) => liftListItemCommand(e.cm),
619
+ isActive: inactive,
620
+ isEnable: enable,
621
+ };
622
+ // ---- Toggle Heading Folding ----
623
+ export const toggleHeadingFoldingItemView = {
624
+ type: ToolbarDataType.SingleButton,
625
+ icon: icons.foldingHeading,
626
+ title: () => i18n('folding-heading'),
627
+ hint: () => i18n('folding-heading__hint'),
628
+ };
629
+ export const toggleHeadingFoldingItemWysiwyg = {
630
+ isActive: (editor) => { var _a, _b; return (_b = (_a = editor.actions.toggleHeadingFolding) === null || _a === void 0 ? void 0 : _a.isActive()) !== null && _b !== void 0 ? _b : false; },
631
+ isEnable: (editor) => { var _a, _b; return (_b = (_a = editor.actions.toggleHeadingFolding) === null || _a === void 0 ? void 0 : _a.isEnable()) !== null && _b !== void 0 ? _b : false; },
632
+ exec: (editor) => editor.actions.toggleHeadingFolding.run(),
633
+ condition: 'enabled',
634
+ };
635
+ // ---- Text Context ----
636
+ export const textContextItemView = {
637
+ type: ToolbarDataType.ReactComponent,
638
+ };
639
+ export const textContextItemWisywig = {
640
+ component: WToolbarTextSelect,
641
+ width: 0,
642
+ condition: ({ selection: { $from, $to }, schema }) => {
643
+ if (!$from.sameParent($to))
644
+ return false;
645
+ const { parent } = $from;
646
+ return parent.type === pType(schema) || parent.type === headingType(schema);
647
+ },
648
+ };
649
+ // ---- Paragraph ----
650
+ export const paragraphItemView = {
651
+ type: ToolbarDataType.SingleButton,
652
+ title: i18n.bind(null, 'text'),
653
+ icon: icons.text,
654
+ hotkey: f.toView(A.Text),
655
+ doNotActivateList: true,
656
+ };
657
+ export const paragraphItemWisywig = {
658
+ exec: (e) => e.actions.toParagraph.run(),
659
+ isActive: (e) => e.actions.toParagraph.isActive(),
660
+ isEnable: (e) => e.actions.toParagraph.isEnable(),
661
+ };
662
+ export const paragraphItemMarkup = {
663
+ exec: noop,
664
+ isActive: inactive,
665
+ isEnable: enable,
666
+ };
667
+ // --- Colorify ----
668
+ export const colorifyItemView = {
669
+ type: ToolbarDataType.ReactComponent,
670
+ };
671
+ export const colorifyItemWysiwyg = {
672
+ component: WToolbarColors,
673
+ width: 42,
674
+ };
675
+ export const colorifyItemMarkup = {
676
+ component: MToolbarColors,
677
+ width: 42,
678
+ };
679
+ // ---- GPT ----
680
+ export const gptItemView = {
681
+ type: ToolbarDataType.SingleButton,
682
+ title: i18n.bind(null, 'gpt'),
683
+ hotkey: gptHotKeys.openGptKeyTooltip,
684
+ icon: icons.gpt,
685
+ };
686
+ export const gptItemWysiwyg = {
687
+ exec: (e) => e.actions.addGptWidget.run({}),
688
+ isActive: (e) => e.actions.addGptWidget.isActive(),
689
+ isEnable: (e) => e.actions.addGptWidget.isEnable(),
690
+ };
691
+ export const gptItemMarkup = {
692
+ exec: (e) => insertMermaidDiagram(e.cm),
693
+ isActive: inactive,
694
+ isEnable: enable,
695
+ };
696
+ // ---- Heading list ----
697
+ export const headingListItemView = {
698
+ type: ToolbarDataType.ListButton,
699
+ icon: icons.headline,
700
+ title: i18n.bind(null, 'heading'),
701
+ withArrow: true,
702
+ };
703
+ // ---- Lists list ----
704
+ export const listsListItemView = {
705
+ type: ToolbarDataType.ListButton,
706
+ icon: icons.bulletList,
707
+ withArrow: true,
708
+ title: i18n.bind(null, 'list'),
709
+ };
710
+ // ---- Move list ----
711
+ export const moveListItemView = {
712
+ type: ToolbarDataType.ListButton,
713
+ icon: icons.lift,
714
+ withArrow: true,
715
+ title: i18n.bind(null, 'move_list'),
716
+ };
717
+ // ---- Code list ----
718
+ export const codeBlocksListItemView = {
719
+ type: ToolbarDataType.ListButton,
720
+ icon: icons.code,
721
+ title: i18n.bind(null, 'code'),
722
+ withArrow: true,
723
+ };
724
+ // ---- Math list ----
725
+ export const mathListItemView = {
726
+ type: ToolbarDataType.ListButton,
727
+ icon: icons.functionInline,
728
+ withArrow: true,
729
+ title: i18n.bind(null, 'math'),
730
+ };