@gravity-ui/markdown-editor 14.4.0 → 14.5.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 (54) hide show
  1. package/build/cjs/bundle/Editor.js +1 -0
  2. package/build/cjs/bundle/config/markup.d.ts +41 -17
  3. package/build/cjs/bundle/config/markup.js +413 -308
  4. package/build/cjs/bundle/config/wysiwyg.d.ts +29 -18
  5. package/build/cjs/bundle/config/wysiwyg.js +526 -310
  6. package/build/cjs/bundle/sticky/sticky.css +1 -1
  7. package/build/cjs/bundle/types.d.ts +2 -0
  8. package/build/cjs/extensions/behavior/Clipboard/utils.d.ts +1 -0
  9. package/build/cjs/extensions/behavior/Clipboard/utils.js +1 -0
  10. package/build/cjs/extensions/markdown/CodeBlock/handle-paste.js +5 -17
  11. package/build/cjs/extensions/yfm/YfmFile/YfmFileSpecs/const.d.ts +12 -0
  12. package/build/cjs/extensions/yfm/YfmFile/YfmFileSpecs/const.js +21 -2
  13. package/build/cjs/extensions/yfm/YfmFile/YfmFileSpecs/index.d.ts +8 -1
  14. package/build/cjs/extensions/yfm/YfmFile/YfmFileSpecs/index.js +29 -5
  15. package/build/cjs/markup/codemirror/create.d.ts +1 -0
  16. package/build/cjs/markup/codemirror/create.js +41 -4
  17. package/build/cjs/markup/codemirror/html-to-markdown/converters.d.ts +111 -0
  18. package/build/cjs/markup/codemirror/html-to-markdown/converters.js +214 -0
  19. package/build/cjs/markup/codemirror/html-to-markdown/handlers.d.ts +104 -0
  20. package/build/cjs/markup/codemirror/html-to-markdown/handlers.js +233 -0
  21. package/build/cjs/markup/codemirror/html-to-markdown/helpers.d.ts +1 -0
  22. package/build/cjs/markup/codemirror/html-to-markdown/helpers.js +21 -0
  23. package/build/cjs/markup/commands/inline.js +18 -8
  24. package/build/cjs/utils/clipboard.d.ts +14 -0
  25. package/build/cjs/utils/clipboard.js +36 -1
  26. package/build/cjs/version.js +1 -1
  27. package/build/esm/bundle/Editor.js +1 -0
  28. package/build/esm/bundle/config/markup.d.ts +41 -17
  29. package/build/esm/bundle/config/markup.js +411 -307
  30. package/build/esm/bundle/config/wysiwyg.d.ts +29 -18
  31. package/build/esm/bundle/config/wysiwyg.js +499 -284
  32. package/build/esm/bundle/sticky/sticky.css +1 -1
  33. package/build/esm/bundle/types.d.ts +2 -0
  34. package/build/esm/extensions/behavior/Clipboard/utils.d.ts +1 -0
  35. package/build/esm/extensions/behavior/Clipboard/utils.js +1 -0
  36. package/build/esm/extensions/markdown/CodeBlock/handle-paste.js +2 -14
  37. package/build/esm/extensions/yfm/YfmFile/YfmFileSpecs/const.d.ts +12 -0
  38. package/build/esm/extensions/yfm/YfmFile/YfmFileSpecs/const.js +21 -2
  39. package/build/esm/extensions/yfm/YfmFile/YfmFileSpecs/index.d.ts +8 -1
  40. package/build/esm/extensions/yfm/YfmFile/YfmFileSpecs/index.js +29 -6
  41. package/build/esm/markup/codemirror/create.d.ts +1 -0
  42. package/build/esm/markup/codemirror/create.js +40 -3
  43. package/build/esm/markup/codemirror/html-to-markdown/converters.d.ts +111 -0
  44. package/build/esm/markup/codemirror/html-to-markdown/converters.js +210 -0
  45. package/build/esm/markup/codemirror/html-to-markdown/handlers.d.ts +104 -0
  46. package/build/esm/markup/codemirror/html-to-markdown/handlers.js +215 -0
  47. package/build/esm/markup/codemirror/html-to-markdown/helpers.d.ts +1 -0
  48. package/build/esm/markup/codemirror/html-to-markdown/helpers.js +17 -0
  49. package/build/esm/markup/commands/inline.js +18 -8
  50. package/build/esm/utils/clipboard.d.ts +14 -0
  51. package/build/esm/utils/clipboard.js +32 -0
  52. package/build/esm/version.js +1 -1
  53. package/build/styles.css +1 -1
  54. package/package.json +9 -7
@@ -3,36 +3,34 @@ import { gptHotKeys } from '../../extensions/additional/GPT/constants';
3
3
  import { i18n as i18nHint } from '../../i18n/hints';
4
4
  import { i18n } from '../../i18n/menubar';
5
5
  import { Action as A, formatter as f } from '../../shortcuts';
6
- import { ToolbarDataType, } from '../../toolbar/types';
6
+ import { ToolbarDataType, } from '../../toolbar';
7
7
  import { WToolbarColors } from '../toolbar/wysiwyg/WToolbarColors';
8
8
  import { WToolbarTextSelect } from '../toolbar/wysiwyg/WToolbarTextSelect';
9
9
  import { ActionName } from './action-names';
10
10
  import { icons } from './icons';
11
- export const wHistoryGroupConfig = [
12
- {
13
- id: ActionName.undo,
14
- type: ToolbarDataType.SingleButton,
15
- title: i18n.bind(null, 'undo'),
16
- icon: icons.undo,
17
- hotkey: f.toView(A.Undo),
18
- hintWhenDisabled: false,
19
- exec: (e) => e.actions.undo.run(),
20
- isActive: (e) => e.actions.undo.isActive(),
21
- isEnable: (e) => e.actions.undo.isEnable(),
22
- },
23
- {
24
- id: ActionName.redo,
25
- type: ToolbarDataType.SingleButton,
26
- title: i18n.bind(null, 'redo'),
27
- icon: icons.redo,
28
- hotkey: f.toView(A.Redo),
29
- hintWhenDisabled: false,
30
- exec: (e) => e.actions.redo.run(),
31
- isActive: (e) => e.actions.redo.isActive(),
32
- isEnable: (e) => e.actions.redo.isEnable(),
33
- },
34
- ];
35
- /** Bold, Italic, Underline, Strike buttons group */
11
+ export const wUndoItemData = {
12
+ id: ActionName.undo,
13
+ type: ToolbarDataType.SingleButton,
14
+ title: i18n.bind(null, 'undo'),
15
+ icon: icons.undo,
16
+ hotkey: f.toView(A.Undo),
17
+ hintWhenDisabled: false,
18
+ exec: (e) => e.actions.undo.run(),
19
+ isActive: (e) => e.actions.undo.isActive(),
20
+ isEnable: (e) => e.actions.undo.isEnable(),
21
+ };
22
+ export const wRedoItemData = {
23
+ id: ActionName.redo,
24
+ type: ToolbarDataType.SingleButton,
25
+ title: i18n.bind(null, 'redo'),
26
+ icon: icons.redo,
27
+ hotkey: f.toView(A.Redo),
28
+ hintWhenDisabled: false,
29
+ exec: (e) => e.actions.redo.run(),
30
+ isActive: (e) => e.actions.redo.isActive(),
31
+ isEnable: (e) => e.actions.redo.isEnable(),
32
+ };
33
+ // ----
36
34
  export const wBoldItemData = {
37
35
  id: ActionName.bold,
38
36
  type: ToolbarDataType.SingleButton,
@@ -91,131 +89,7 @@ export const wMarkedItemData = {
91
89
  isActive: (e) => e.actions.mark.isActive(),
92
90
  isEnable: (e) => e.actions.mark.isEnable(),
93
91
  };
94
- export const wBiusGroupConfig = [
95
- wBoldItemData,
96
- wItalicItemData,
97
- wUnderlineItemData,
98
- wStrikethroughItemData,
99
- wMonospaceItemData,
100
- wMarkedItemData,
101
- ];
102
- export const wTextItemData = {
103
- id: ActionName.paragraph,
104
- title: i18n.bind(null, 'text'),
105
- icon: icons.text,
106
- hotkey: f.toView(A.Text),
107
- exec: (e) => e.actions.toParagraph.run(),
108
- isActive: (e) => e.actions.toParagraph.isActive(),
109
- isEnable: (e) => e.actions.toParagraph.isEnable(),
110
- doNotActivateList: true,
111
- };
112
- export const wHeadingListConfig = {
113
- icon: icons.headline,
114
- withArrow: true,
115
- title: i18n.bind(null, 'heading'),
116
- data: [
117
- wTextItemData,
118
- {
119
- id: ActionName.heading1,
120
- title: i18n.bind(null, 'heading1'),
121
- icon: icons.h1,
122
- hotkey: f.toView(A.Heading1),
123
- exec: (e) => e.actions.toH1.run(),
124
- isActive: (e) => e.actions.toH1.isActive(),
125
- isEnable: (e) => e.actions.toH1.isEnable(),
126
- },
127
- {
128
- id: ActionName.heading2,
129
- title: i18n.bind(null, 'heading2'),
130
- icon: icons.h2,
131
- hotkey: f.toView(A.Heading2),
132
- exec: (e) => e.actions.toH2.run(),
133
- isActive: (e) => e.actions.toH2.isActive(),
134
- isEnable: (e) => e.actions.toH2.isEnable(),
135
- },
136
- {
137
- id: ActionName.heading3,
138
- title: i18n.bind(null, 'heading3'),
139
- icon: icons.h3,
140
- hotkey: f.toView(A.Heading3),
141
- exec: (e) => e.actions.toH3.run(),
142
- isActive: (e) => e.actions.toH3.isActive(),
143
- isEnable: (e) => e.actions.toH3.isEnable(),
144
- },
145
- {
146
- id: ActionName.heading4,
147
- title: i18n.bind(null, 'heading4'),
148
- icon: icons.h4,
149
- hotkey: f.toView(A.Heading4),
150
- exec: (e) => e.actions.toH4.run(),
151
- isActive: (e) => e.actions.toH4.isActive(),
152
- isEnable: (e) => e.actions.toH4.isEnable(),
153
- },
154
- {
155
- id: ActionName.heading5,
156
- title: i18n.bind(null, 'heading5'),
157
- icon: icons.h5,
158
- hotkey: f.toView(A.Heading5),
159
- exec: (e) => e.actions.toH5.run(),
160
- isActive: (e) => e.actions.toH5.isActive(),
161
- isEnable: (e) => e.actions.toH5.isEnable(),
162
- },
163
- {
164
- id: ActionName.heading6,
165
- title: i18n.bind(null, 'heading6'),
166
- icon: icons.h6,
167
- hotkey: f.toView(A.Heading6),
168
- exec: (e) => e.actions.toH6.run(),
169
- isActive: (e) => e.actions.toH6.isActive(),
170
- isEnable: (e) => e.actions.toH6.isEnable(),
171
- },
172
- ],
173
- };
174
- export const wListsListConfig = {
175
- icon: icons.bulletList,
176
- withArrow: true,
177
- title: i18n.bind(null, 'list'),
178
- data: [
179
- {
180
- id: ActionName.bulletList,
181
- title: i18n.bind(null, 'ulist'),
182
- icon: icons.bulletList,
183
- hotkey: f.toView(A.BulletList),
184
- exec: (e) => e.actions.toBulletList.run(),
185
- isActive: (e) => e.actions.toBulletList.isActive(),
186
- isEnable: (e) => e.actions.toBulletList.isEnable(),
187
- },
188
- {
189
- id: ActionName.orderedList,
190
- title: i18n.bind(null, 'olist'),
191
- icon: icons.orderedList,
192
- hotkey: f.toView(A.OrderedList),
193
- exec: (e) => e.actions.toOrderedList.run(),
194
- isActive: (e) => e.actions.toOrderedList.isActive(),
195
- isEnable: (e) => e.actions.toOrderedList.isEnable(),
196
- },
197
- {
198
- id: ActionName.sinkListItem,
199
- title: i18n.bind(null, 'list__action_sink'),
200
- hintWhenDisabled: () => i18n('list_action_disabled'),
201
- icon: icons.sink,
202
- hotkey: f.toView(A.SinkListItem),
203
- exec: (e) => e.actions.sinkListItem.run(),
204
- isActive: (e) => e.actions.sinkListItem.isActive(),
205
- isEnable: (e) => e.actions.sinkListItem.isEnable(),
206
- },
207
- {
208
- id: ActionName.liftListItem,
209
- title: i18n.bind(null, 'list__action_lift'),
210
- hintWhenDisabled: () => i18n('list_action_disabled'),
211
- icon: icons.lift,
212
- hotkey: f.toView(A.LiftListItem),
213
- exec: (e) => e.actions.liftListItem.run(),
214
- isActive: (e) => e.actions.liftListItem.isActive(),
215
- isEnable: (e) => e.actions.liftListItem.isEnable(),
216
- },
217
- ],
218
- };
92
+ // ----
219
93
  export const wCheckboxItemData = {
220
94
  id: ActionName.checkbox,
221
95
  type: ToolbarDataType.SingleButton,
@@ -255,29 +129,6 @@ export const wCutItemData = {
255
129
  isActive: (e) => e.actions.toYfmCut.isActive(),
256
130
  isEnable: (e) => e.actions.toYfmCut.isEnable(),
257
131
  };
258
- export const wListMoveListConfig = {
259
- icon: icons.lift,
260
- withArrow: true,
261
- title: 'Move list item',
262
- data: [
263
- {
264
- id: ActionName.sinkListItem,
265
- title: 'Sink list item',
266
- icon: icons.sink,
267
- exec: (e) => e.actions.sinkListItem.run(),
268
- isActive: (e) => e.actions.sinkListItem.isActive(),
269
- isEnable: (e) => e.actions.sinkListItem.isEnable(),
270
- },
271
- {
272
- id: ActionName.liftListItem,
273
- title: 'Lift list item',
274
- icon: icons.lift,
275
- exec: (e) => e.actions.liftListItem.run(),
276
- isActive: (e) => e.actions.liftListItem.isActive(),
277
- isEnable: (e) => e.actions.liftListItem.isEnable(),
278
- },
279
- ],
280
- };
281
132
  export const wNoteItemData = {
282
133
  id: ActionName.yfm_note,
283
134
  type: ToolbarDataType.SingleButton,
@@ -307,21 +158,6 @@ export const wCodeItemData = {
307
158
  isActive: (e) => e.actions.code.isActive(),
308
159
  isEnable: (e) => e.actions.code.isEnable(),
309
160
  };
310
- export const wCodeBlockItemData = {
311
- id: ActionName.code_block,
312
- title: i18n.bind(null, 'codeblock'),
313
- icon: icons.codeBlock,
314
- hotkey: f.toView(A.CodeBlock),
315
- exec: (e) => e.actions.toCodeBlock.run(),
316
- isActive: (e) => e.actions.toCodeBlock.isActive(),
317
- isEnable: (e) => e.actions.toCodeBlock.isEnable(),
318
- };
319
- export const wCodeListConfig = {
320
- icon: icons.code,
321
- withArrow: true,
322
- title: i18n.bind(null, 'code'),
323
- data: [wCodeItemData, wCodeBlockItemData],
324
- };
325
161
  export const wImageItemData = {
326
162
  id: ActionName.image,
327
163
  type: ToolbarDataType.SingleButton,
@@ -331,22 +167,6 @@ export const wImageItemData = {
331
167
  isActive: (e) => e.actions.addImageWidget.isActive(),
332
168
  isEnable: (e) => e.actions.addImageWidget.isEnable(),
333
169
  };
334
- export const wHruleItemData = {
335
- id: ActionName.horizontalrule,
336
- title: i18n.bind(null, 'hrule'),
337
- icon: icons.horizontalRule,
338
- exec: (e) => e.actions.hRule.run(),
339
- isActive: (e) => e.actions.hRule.isActive(),
340
- isEnable: (e) => e.actions.hRule.isEnable(),
341
- };
342
- export const wEmojiItemData = {
343
- id: ActionName.emoji,
344
- title: i18n.bind(null, 'emoji'),
345
- icon: icons.emoji,
346
- exec: (e) => e.actions.openEmojiSuggest.run({}),
347
- isActive: (e) => e.actions.openEmojiSuggest.isActive(),
348
- isEnable: (e) => e.actions.openEmojiSuggest.isEnable(),
349
- };
350
170
  export const wFileItemData = {
351
171
  id: ActionName.file,
352
172
  type: ToolbarDataType.SingleButton,
@@ -356,6 +176,15 @@ export const wFileItemData = {
356
176
  isActive: (e) => e.actions.addFile.isActive(),
357
177
  isEnable: (e) => e.actions.addFile.isEnable(),
358
178
  };
179
+ export const wTabsItemData = {
180
+ id: ActionName.tabs,
181
+ type: ToolbarDataType.SingleButton,
182
+ title: i18n.bind(null, 'tabs'),
183
+ icon: icons.tabs,
184
+ exec: (e) => e.actions.toYfmTabs.run(),
185
+ isActive: (e) => e.actions.toYfmTabs.isActive(),
186
+ isEnable: (e) => e.actions.toYfmTabs.isEnable(),
187
+ };
359
188
  export const wMathInlineItemData = {
360
189
  id: ActionName.math_inline,
361
190
  type: ToolbarDataType.SingleButton,
@@ -366,15 +195,6 @@ export const wMathInlineItemData = {
366
195
  isActive: (e) => e.actions.addMathInline.isActive(),
367
196
  isEnable: (e) => e.actions.addMathInline.isEnable(),
368
197
  };
369
- export const wTabsItemData = {
370
- id: ActionName.tabs,
371
- type: ToolbarDataType.SingleButton,
372
- title: i18n.bind(null, 'tabs'),
373
- icon: icons.tabs,
374
- exec: (e) => e.actions.toYfmTabs.run(),
375
- isActive: (e) => e.actions.toYfmTabs.isActive(),
376
- isEnable: (e) => e.actions.toYfmTabs.isEnable(),
377
- };
378
198
  export const wMathBlockItemData = {
379
199
  id: ActionName.math_block,
380
200
  type: ToolbarDataType.SingleButton,
@@ -385,13 +205,6 @@ export const wMathBlockItemData = {
385
205
  isActive: (e) => e.actions.toMathBlock.isActive(),
386
206
  isEnable: (e) => e.actions.toMathBlock.isEnable(),
387
207
  };
388
- export const wMathListConfig = {
389
- icon: icons.functionInline,
390
- withArrow: true,
391
- title: i18n.bind(null, 'math'),
392
- data: [wMathInlineItemData, wMathBlockItemData],
393
- };
394
- export const wMathListItem = Object.assign({ id: 'math', type: ToolbarDataType.ListButton }, wMathListConfig);
395
208
  export const wYfmHtmlBlockItemData = {
396
209
  id: ActionName.yfm_html_block,
397
210
  type: ToolbarDataType.SingleButton,
@@ -411,9 +224,240 @@ export const wGptItemData = {
411
224
  isActive: (e) => e.actions.addGptWidget.isActive(),
412
225
  isEnable: (e) => e.actions.addGptWidget.isEnable(),
413
226
  };
227
+ export const wMermaidItemData = {
228
+ id: ActionName.mermaid,
229
+ type: ToolbarDataType.SingleButton,
230
+ title: i18n.bind(null, 'mermaid'),
231
+ icon: icons.mermaid,
232
+ exec: (e) => e.actions.createMermaid.run(),
233
+ isActive: (e) => e.actions.createMermaid.isActive(),
234
+ isEnable: (e) => e.actions.createMermaid.isEnable(),
235
+ };
236
+ export const wCodeBlockItemData = {
237
+ id: ActionName.code_block,
238
+ title: i18n.bind(null, 'codeblock'),
239
+ icon: icons.codeBlock,
240
+ hotkey: f.toView(A.CodeBlock),
241
+ exec: (e) => e.actions.toCodeBlock.run(),
242
+ isActive: (e) => e.actions.toCodeBlock.isActive(),
243
+ isEnable: (e) => e.actions.toCodeBlock.isEnable(),
244
+ };
245
+ export const wHruleItemData = {
246
+ id: ActionName.horizontalrule,
247
+ title: i18n.bind(null, 'hrule'),
248
+ icon: icons.horizontalRule,
249
+ exec: (e) => e.actions.hRule.run(),
250
+ isActive: (e) => e.actions.hRule.isActive(),
251
+ isEnable: (e) => e.actions.hRule.isEnable(),
252
+ };
253
+ export const wEmojiItemData = {
254
+ id: ActionName.emoji,
255
+ title: i18n.bind(null, 'emoji'),
256
+ icon: icons.emoji,
257
+ exec: (e) => e.actions.openEmojiSuggest.run({}),
258
+ isActive: (e) => e.actions.openEmojiSuggest.isActive(),
259
+ isEnable: (e) => e.actions.openEmojiSuggest.isEnable(),
260
+ };
261
+ export const wToggleHeadingFoldingItemData = {
262
+ id: 'folding-heading',
263
+ type: ToolbarDataType.SingleButton,
264
+ icon: icons.foldingHeading,
265
+ title: () => i18n('folding-heading'),
266
+ hint: () => i18n('folding-heading__hint'),
267
+ 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; },
268
+ 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; },
269
+ exec: (editor) => editor.actions.toggleHeadingFolding.run(),
270
+ condition: 'enabled',
271
+ };
272
+ export const textContextItemData = {
273
+ id: 'text',
274
+ type: ToolbarDataType.ReactComponent,
275
+ component: WToolbarTextSelect,
276
+ width: 0,
277
+ condition: ({ selection: { $from, $to }, schema }) => {
278
+ if (!$from.sameParent($to))
279
+ return false;
280
+ const { parent } = $from;
281
+ return parent.type === pType(schema) || parent.type === headingType(schema);
282
+ },
283
+ };
284
+ export const wMathListItem = {
285
+ id: 'math',
286
+ type: ToolbarDataType.ListButton,
287
+ icon: icons.functionInline,
288
+ withArrow: true,
289
+ title: i18n.bind(null, 'math'),
290
+ data: [wMathInlineItemData, wMathBlockItemData],
291
+ };
292
+ export const wTextItemData = {
293
+ id: ActionName.paragraph,
294
+ title: i18n.bind(null, 'text'),
295
+ icon: icons.text,
296
+ hotkey: f.toView(A.Text),
297
+ exec: (e) => e.actions.toParagraph.run(),
298
+ isActive: (e) => e.actions.toParagraph.isActive(),
299
+ isEnable: (e) => e.actions.toParagraph.isEnable(),
300
+ doNotActivateList: true,
301
+ };
302
+ export const wHeading1ItemData = {
303
+ id: ActionName.heading1,
304
+ title: i18n.bind(null, 'heading1'),
305
+ icon: icons.h1,
306
+ hotkey: f.toView(A.Heading1),
307
+ exec: (e) => e.actions.toH1.run(),
308
+ isActive: (e) => e.actions.toH1.isActive(),
309
+ isEnable: (e) => e.actions.toH1.isEnable(),
310
+ };
311
+ export const wHeading2ItemData = {
312
+ id: ActionName.heading2,
313
+ title: i18n.bind(null, 'heading2'),
314
+ icon: icons.h2,
315
+ hotkey: f.toView(A.Heading2),
316
+ exec: (e) => e.actions.toH2.run(),
317
+ isActive: (e) => e.actions.toH2.isActive(),
318
+ isEnable: (e) => e.actions.toH2.isEnable(),
319
+ };
320
+ export const wHeading3ItemData = {
321
+ id: ActionName.heading3,
322
+ title: i18n.bind(null, 'heading3'),
323
+ icon: icons.h3,
324
+ hotkey: f.toView(A.Heading3),
325
+ exec: (e) => e.actions.toH3.run(),
326
+ isActive: (e) => e.actions.toH3.isActive(),
327
+ isEnable: (e) => e.actions.toH3.isEnable(),
328
+ };
329
+ export const wHeading4ItemData = {
330
+ id: ActionName.heading4,
331
+ title: i18n.bind(null, 'heading4'),
332
+ icon: icons.h4,
333
+ hotkey: f.toView(A.Heading4),
334
+ exec: (e) => e.actions.toH4.run(),
335
+ isActive: (e) => e.actions.toH4.isActive(),
336
+ isEnable: (e) => e.actions.toH4.isEnable(),
337
+ };
338
+ export const wHeading5ItemData = {
339
+ id: ActionName.heading5,
340
+ title: i18n.bind(null, 'heading5'),
341
+ icon: icons.h5,
342
+ hotkey: f.toView(A.Heading5),
343
+ exec: (e) => e.actions.toH5.run(),
344
+ isActive: (e) => e.actions.toH5.isActive(),
345
+ isEnable: (e) => e.actions.toH5.isEnable(),
346
+ };
347
+ export const wHeading6ItemData = {
348
+ id: ActionName.heading6,
349
+ title: i18n.bind(null, 'heading6'),
350
+ icon: icons.h6,
351
+ hotkey: f.toView(A.Heading6),
352
+ exec: (e) => e.actions.toH6.run(),
353
+ isActive: (e) => e.actions.toH6.isActive(),
354
+ isEnable: (e) => e.actions.toH6.isEnable(),
355
+ };
356
+ export const wBulletListItemData = {
357
+ id: ActionName.bulletList,
358
+ title: i18n.bind(null, 'ulist'),
359
+ icon: icons.bulletList,
360
+ hotkey: f.toView(A.BulletList),
361
+ exec: (e) => e.actions.toBulletList.run(),
362
+ isActive: (e) => e.actions.toBulletList.isActive(),
363
+ isEnable: (e) => e.actions.toBulletList.isEnable(),
364
+ };
365
+ export const wOrderedListItemData = {
366
+ id: ActionName.orderedList,
367
+ title: i18n.bind(null, 'olist'),
368
+ icon: icons.orderedList,
369
+ hotkey: f.toView(A.OrderedList),
370
+ exec: (e) => e.actions.toOrderedList.run(),
371
+ isActive: (e) => e.actions.toOrderedList.isActive(),
372
+ isEnable: (e) => e.actions.toOrderedList.isEnable(),
373
+ };
374
+ export const wSinkListItemData = {
375
+ id: ActionName.sinkListItem,
376
+ title: i18n.bind(null, 'list__action_sink'),
377
+ hintWhenDisabled: () => i18n('list_action_disabled'),
378
+ icon: icons.sink,
379
+ hotkey: f.toView(A.SinkListItem),
380
+ exec: (e) => e.actions.sinkListItem.run(),
381
+ isActive: (e) => e.actions.sinkListItem.isActive(),
382
+ isEnable: (e) => e.actions.sinkListItem.isEnable(),
383
+ };
384
+ export const wLiftListItemData = {
385
+ id: ActionName.liftListItem,
386
+ title: i18n.bind(null, 'list__action_lift'),
387
+ hintWhenDisabled: () => i18n('list_action_disabled'),
388
+ icon: icons.lift,
389
+ hotkey: f.toView(A.LiftListItem),
390
+ exec: (e) => e.actions.liftListItem.run(),
391
+ isActive: (e) => e.actions.liftListItem.isActive(),
392
+ isEnable: (e) => e.actions.liftListItem.isEnable(),
393
+ };
394
+ export const wHeadingListConfig = {
395
+ icon: icons.headline,
396
+ withArrow: true,
397
+ title: i18n.bind(null, 'heading'),
398
+ data: [
399
+ wTextItemData,
400
+ wHeading1ItemData,
401
+ wHeading2ItemData,
402
+ wHeading3ItemData,
403
+ wHeading4ItemData,
404
+ wHeading5ItemData,
405
+ wHeading6ItemData,
406
+ ],
407
+ };
408
+ export const wListsListConfig = {
409
+ icon: icons.bulletList,
410
+ withArrow: true,
411
+ title: i18n.bind(null, 'list'),
412
+ data: [wBulletListItemData, wOrderedListItemData, wSinkListItemData, wLiftListItemData],
413
+ };
414
+ export const wListMoveListConfig = {
415
+ icon: icons.lift,
416
+ withArrow: true,
417
+ title: 'Move list item',
418
+ data: [
419
+ {
420
+ id: ActionName.sinkListItem,
421
+ title: 'Sink list item',
422
+ icon: icons.sink,
423
+ exec: (e) => e.actions.sinkListItem.run(),
424
+ isActive: (e) => e.actions.sinkListItem.isActive(),
425
+ isEnable: (e) => e.actions.sinkListItem.isEnable(),
426
+ },
427
+ {
428
+ id: ActionName.liftListItem,
429
+ title: 'Lift list item',
430
+ icon: icons.lift,
431
+ exec: (e) => e.actions.liftListItem.run(),
432
+ isActive: (e) => e.actions.liftListItem.isActive(),
433
+ isEnable: (e) => e.actions.liftListItem.isEnable(),
434
+ },
435
+ ],
436
+ };
437
+ export const wCodeListConfig = {
438
+ icon: icons.code,
439
+ withArrow: true,
440
+ title: i18n.bind(null, 'code'),
441
+ data: [wCodeItemData, wCodeBlockItemData],
442
+ };
443
+ export const wMathListConfig = {
444
+ icon: icons.functionInline,
445
+ withArrow: true,
446
+ title: i18n.bind(null, 'math'),
447
+ data: [wMathInlineItemData, wMathBlockItemData],
448
+ };
414
449
  export const wCommandMenuConfig = [
415
- ...wHeadingListConfig.data,
416
- ...wListsListConfig.data,
450
+ wTextItemData,
451
+ wHeading1ItemData,
452
+ wHeading2ItemData,
453
+ wHeading3ItemData,
454
+ wHeading4ItemData,
455
+ wHeading5ItemData,
456
+ wHeading6ItemData,
457
+ wBulletListItemData,
458
+ wOrderedListItemData,
459
+ wSinkListItemData,
460
+ wLiftListItemData,
417
461
  wLinkItemData,
418
462
  wQuoteItemData,
419
463
  wNoteItemData,
@@ -425,18 +469,53 @@ export const wCommandMenuConfig = [
425
469
  wHruleItemData,
426
470
  wEmojiItemData,
427
471
  wFileItemData,
428
- // wMathInlineItemData,
429
- // wMathBlockItemData,
430
472
  wTabsItemData,
431
473
  ];
432
474
  export const wHiddenData = wCommandMenuConfig;
433
- /** prepared wysiwyg toolbar config */
475
+ export const wHistoryGroupConfig = [wUndoItemData, wRedoItemData];
476
+ export const wBiusGroupConfig = [
477
+ wBoldItemData,
478
+ wItalicItemData,
479
+ wUnderlineItemData,
480
+ wStrikethroughItemData,
481
+ wMonospaceItemData,
482
+ wMarkedItemData,
483
+ ];
434
484
  export const wToolbarConfig = [
435
- wHistoryGroupConfig,
436
- wBiusGroupConfig,
485
+ [wUndoItemData, wRedoItemData],
486
+ [
487
+ wBoldItemData,
488
+ wItalicItemData,
489
+ wUnderlineItemData,
490
+ wStrikethroughItemData,
491
+ wMonospaceItemData,
492
+ wMarkedItemData,
493
+ ],
437
494
  [
438
- Object.assign({ id: 'heading', type: ToolbarDataType.ListButton }, wHeadingListConfig),
439
- Object.assign({ id: 'list', type: ToolbarDataType.ListButton }, wListsListConfig),
495
+ {
496
+ id: 'heading',
497
+ type: ToolbarDataType.ListButton,
498
+ icon: icons.headline,
499
+ withArrow: true,
500
+ title: i18n.bind(null, 'heading'),
501
+ data: [
502
+ wTextItemData,
503
+ wHeading1ItemData,
504
+ wHeading2ItemData,
505
+ wHeading3ItemData,
506
+ wHeading4ItemData,
507
+ wHeading5ItemData,
508
+ wHeading6ItemData,
509
+ ],
510
+ },
511
+ {
512
+ id: 'list',
513
+ type: ToolbarDataType.ListButton,
514
+ icon: icons.bulletList,
515
+ withArrow: true,
516
+ title: i18n.bind(null, 'list'),
517
+ data: [wBulletListItemData, wOrderedListItemData, wSinkListItemData, wLiftListItemData],
518
+ },
440
519
  {
441
520
  id: 'colorify',
442
521
  type: ToolbarDataType.ReactComponent,
@@ -447,36 +526,28 @@ export const wToolbarConfig = [
447
526
  wNoteItemData,
448
527
  wCutItemData,
449
528
  wQuoteItemData,
450
- Object.assign({ id: 'code', type: ToolbarDataType.ListButton }, wCodeListConfig),
529
+ {
530
+ id: 'code',
531
+ type: ToolbarDataType.ListButton,
532
+ icon: icons.code,
533
+ withArrow: true,
534
+ title: i18n.bind(null, 'code'),
535
+ data: [wCodeItemData, wCodeBlockItemData],
536
+ },
451
537
  ],
452
538
  [wImageItemData, wFileItemData, wTableItemData, wCheckboxItemData],
453
539
  ];
454
- export const wToggleHeadingFoldingItemData = {
455
- id: 'folding-heading',
456
- type: ToolbarDataType.SingleButton,
457
- icon: icons.foldingHeading,
458
- title: () => i18n('folding-heading'),
459
- hint: () => i18n('folding-heading__hint'),
460
- 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; },
461
- 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; },
462
- exec: (editor) => editor.actions.toggleHeadingFolding.run(),
463
- condition: 'enabled',
464
- };
465
- const textContextItemData = {
466
- id: 'text',
467
- type: ToolbarDataType.ReactComponent,
468
- component: WToolbarTextSelect,
469
- width: 0,
470
- condition: ({ selection: { $from, $to }, schema }) => {
471
- if (!$from.sameParent($to))
472
- return false;
473
- const { parent } = $from;
474
- return parent.type === pType(schema) || parent.type === headingType(schema);
475
- },
476
- };
477
540
  export const wSelectionMenuConfig = [
478
541
  [wToggleHeadingFoldingItemData, textContextItemData],
479
- [...wBiusGroupConfig, wCodeItemData],
542
+ [
543
+ wBoldItemData,
544
+ wItalicItemData,
545
+ wUnderlineItemData,
546
+ wStrikethroughItemData,
547
+ wMonospaceItemData,
548
+ wMarkedItemData,
549
+ wCodeItemData,
550
+ ],
480
551
  [
481
552
  {
482
553
  id: 'colorify',
@@ -487,41 +558,100 @@ export const wSelectionMenuConfig = [
487
558
  wLinkItemData,
488
559
  ],
489
560
  ];
490
- export const wMermaidItemData = {
491
- id: ActionName.mermaid,
492
- type: ToolbarDataType.SingleButton,
493
- title: i18n.bind(null, 'mermaid'),
494
- icon: icons.mermaid,
495
- exec: (e) => e.actions.createMermaid.run(),
496
- isActive: (e) => e.actions.createMermaid.isActive(),
497
- isEnable: (e) => e.actions.createMermaid.isEnable(),
498
- };
499
561
  export const wToolbarConfigByPreset = {
500
- zero: [wHistoryGroupConfig],
562
+ zero: [[wUndoItemData, wRedoItemData]],
501
563
  commonmark: [
502
- wHistoryGroupConfig,
564
+ [wUndoItemData, wRedoItemData],
503
565
  [wBoldItemData, wItalicItemData],
504
566
  [
505
- Object.assign({ id: 'heading', type: ToolbarDataType.ListButton }, wHeadingListConfig),
506
- Object.assign({ id: 'list', type: ToolbarDataType.ListButton }, wListsListConfig),
567
+ {
568
+ id: 'heading',
569
+ type: ToolbarDataType.ListButton,
570
+ icon: icons.headline,
571
+ withArrow: true,
572
+ title: i18n.bind(null, 'heading'),
573
+ data: [
574
+ wTextItemData,
575
+ wHeading1ItemData,
576
+ wHeading2ItemData,
577
+ wHeading3ItemData,
578
+ wHeading4ItemData,
579
+ wHeading5ItemData,
580
+ wHeading6ItemData,
581
+ ],
582
+ },
583
+ {
584
+ id: 'list',
585
+ type: ToolbarDataType.ListButton,
586
+ icon: icons.bulletList,
587
+ withArrow: true,
588
+ title: i18n.bind(null, 'list'),
589
+ data: [
590
+ wBulletListItemData,
591
+ wOrderedListItemData,
592
+ wSinkListItemData,
593
+ wLiftListItemData,
594
+ ],
595
+ },
507
596
  wLinkItemData,
508
597
  wQuoteItemData,
509
- Object.assign({ id: 'code', type: ToolbarDataType.ListButton }, wCodeListConfig),
598
+ {
599
+ id: 'code',
600
+ type: ToolbarDataType.ListButton,
601
+ icon: icons.code,
602
+ withArrow: true,
603
+ title: i18n.bind(null, 'code'),
604
+ data: [wCodeItemData, wCodeBlockItemData],
605
+ },
510
606
  ],
511
607
  ],
512
608
  default: [
513
- wHistoryGroupConfig,
609
+ [wUndoItemData, wRedoItemData],
514
610
  [wBoldItemData, wItalicItemData, wStrikethroughItemData],
515
611
  [
516
- Object.assign({ id: 'heading', type: ToolbarDataType.ListButton }, wHeadingListConfig),
517
- Object.assign({ id: 'list', type: ToolbarDataType.ListButton }, wListsListConfig),
612
+ {
613
+ id: 'heading',
614
+ type: ToolbarDataType.ListButton,
615
+ icon: icons.headline,
616
+ withArrow: true,
617
+ title: i18n.bind(null, 'heading'),
618
+ data: [
619
+ wTextItemData,
620
+ wHeading1ItemData,
621
+ wHeading2ItemData,
622
+ wHeading3ItemData,
623
+ wHeading4ItemData,
624
+ wHeading5ItemData,
625
+ wHeading6ItemData,
626
+ ],
627
+ },
628
+ {
629
+ id: 'list',
630
+ type: ToolbarDataType.ListButton,
631
+ icon: icons.bulletList,
632
+ withArrow: true,
633
+ title: i18n.bind(null, 'list'),
634
+ data: [
635
+ wBulletListItemData,
636
+ wOrderedListItemData,
637
+ wSinkListItemData,
638
+ wLiftListItemData,
639
+ ],
640
+ },
518
641
  wLinkItemData,
519
642
  wQuoteItemData,
520
- Object.assign({ id: 'code', type: ToolbarDataType.ListButton }, wCodeListConfig),
643
+ {
644
+ id: 'code',
645
+ type: ToolbarDataType.ListButton,
646
+ icon: icons.code,
647
+ withArrow: true,
648
+ title: i18n.bind(null, 'code'),
649
+ data: [wCodeItemData, wCodeBlockItemData],
650
+ },
521
651
  ],
522
652
  ],
523
653
  yfm: [
524
- wHistoryGroupConfig,
654
+ [wUndoItemData, wRedoItemData],
525
655
  [
526
656
  wBoldItemData,
527
657
  wItalicItemData,
@@ -530,13 +660,47 @@ export const wToolbarConfigByPreset = {
530
660
  wMonospaceItemData,
531
661
  ],
532
662
  [
533
- Object.assign({ id: 'heading', type: ToolbarDataType.ListButton }, wHeadingListConfig),
534
- Object.assign({ id: 'list', type: ToolbarDataType.ListButton }, wListsListConfig),
663
+ {
664
+ id: 'heading',
665
+ type: ToolbarDataType.ListButton,
666
+ icon: icons.headline,
667
+ withArrow: true,
668
+ title: i18n.bind(null, 'heading'),
669
+ data: [
670
+ wTextItemData,
671
+ wHeading1ItemData,
672
+ wHeading2ItemData,
673
+ wHeading3ItemData,
674
+ wHeading4ItemData,
675
+ wHeading5ItemData,
676
+ wHeading6ItemData,
677
+ ],
678
+ },
679
+ {
680
+ id: 'list',
681
+ type: ToolbarDataType.ListButton,
682
+ icon: icons.bulletList,
683
+ withArrow: true,
684
+ title: i18n.bind(null, 'list'),
685
+ data: [
686
+ wBulletListItemData,
687
+ wOrderedListItemData,
688
+ wSinkListItemData,
689
+ wLiftListItemData,
690
+ ],
691
+ },
535
692
  wLinkItemData,
536
693
  wNoteItemData,
537
694
  wCutItemData,
538
695
  wQuoteItemData,
539
- Object.assign({ id: 'code', type: ToolbarDataType.ListButton }, wCodeListConfig),
696
+ {
697
+ id: 'code',
698
+ type: ToolbarDataType.ListButton,
699
+ icon: icons.code,
700
+ withArrow: true,
701
+ title: i18n.bind(null, 'code'),
702
+ data: [wCodeItemData, wCodeBlockItemData],
703
+ },
540
704
  ],
541
705
  [wImageItemData, wFileItemData, wTableItemData, wCheckboxItemData],
542
706
  ],
@@ -545,24 +709,75 @@ export const wToolbarConfigByPreset = {
545
709
  export const wCommandMenuConfigByPreset = {
546
710
  zero: [],
547
711
  commonmark: [
548
- ...wHeadingListConfig.data,
549
- ...wListsListConfig.data,
712
+ wTextItemData,
713
+ wHeading1ItemData,
714
+ wHeading2ItemData,
715
+ wHeading3ItemData,
716
+ wHeading4ItemData,
717
+ wHeading5ItemData,
718
+ wHeading6ItemData,
719
+ wBulletListItemData,
720
+ wOrderedListItemData,
721
+ wSinkListItemData,
722
+ wLiftListItemData,
550
723
  wLinkItemData,
551
724
  wQuoteItemData,
552
725
  wCodeBlockItemData,
553
726
  wHruleItemData,
554
727
  ],
555
728
  default: [
556
- ...wHeadingListConfig.data,
557
- ...wListsListConfig.data,
729
+ wTextItemData,
730
+ wHeading1ItemData,
731
+ wHeading2ItemData,
732
+ wHeading3ItemData,
733
+ wHeading4ItemData,
734
+ wHeading5ItemData,
735
+ wHeading6ItemData,
736
+ wBulletListItemData,
737
+ wOrderedListItemData,
738
+ wSinkListItemData,
739
+ wLiftListItemData,
558
740
  wLinkItemData,
559
741
  wQuoteItemData,
560
742
  wCodeBlockItemData,
561
743
  wHruleItemData,
562
744
  ],
563
745
  yfm: [
564
- ...wHeadingListConfig.data,
565
- ...wListsListConfig.data,
746
+ wTextItemData,
747
+ wHeading1ItemData,
748
+ wHeading2ItemData,
749
+ wHeading3ItemData,
750
+ wHeading4ItemData,
751
+ wHeading5ItemData,
752
+ wHeading6ItemData,
753
+ wBulletListItemData,
754
+ wOrderedListItemData,
755
+ wSinkListItemData,
756
+ wLiftListItemData,
757
+ wLinkItemData,
758
+ wQuoteItemData,
759
+ wNoteItemData,
760
+ wCutItemData,
761
+ wCodeBlockItemData,
762
+ wCheckboxItemData,
763
+ wTableItemData,
764
+ wImageItemData,
765
+ wHruleItemData,
766
+ wFileItemData,
767
+ wTabsItemData,
768
+ ],
769
+ full: [
770
+ wTextItemData,
771
+ wHeading1ItemData,
772
+ wHeading2ItemData,
773
+ wHeading3ItemData,
774
+ wHeading4ItemData,
775
+ wHeading5ItemData,
776
+ wHeading6ItemData,
777
+ wBulletListItemData,
778
+ wOrderedListItemData,
779
+ wSinkListItemData,
780
+ wLiftListItemData,
566
781
  wLinkItemData,
567
782
  wQuoteItemData,
568
783
  wNoteItemData,
@@ -572,10 +787,10 @@ export const wCommandMenuConfigByPreset = {
572
787
  wTableItemData,
573
788
  wImageItemData,
574
789
  wHruleItemData,
790
+ wEmojiItemData,
575
791
  wFileItemData,
576
792
  wTabsItemData,
577
793
  ],
578
- full: wCommandMenuConfig.slice(),
579
794
  };
580
795
  export const wHiddenDataByPreset = {
581
796
  zero: wCommandMenuConfigByPreset.zero.slice(),