@atlaskit/editor-plugin-help-dialog 1.1.0 → 1.1.2

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 (44) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/ui/Format.js +5 -0
  3. package/dist/cjs/ui/Modal.js +21 -0
  4. package/dist/cjs/ui/ModalContent.js +67 -0
  5. package/dist/cjs/ui/ModalFooter.js +26 -0
  6. package/dist/cjs/ui/ModalHeader.js +35 -0
  7. package/dist/cjs/ui/formatting.js +492 -0
  8. package/dist/cjs/ui/index.js +12 -561
  9. package/dist/cjs/ui/utils.js +55 -0
  10. package/dist/es2019/ui/Format.js +1 -0
  11. package/dist/es2019/ui/Modal.js +16 -0
  12. package/dist/es2019/ui/ModalContent.js +48 -0
  13. package/dist/es2019/ui/ModalFooter.js +16 -0
  14. package/dist/es2019/ui/ModalHeader.js +30 -0
  15. package/dist/es2019/ui/formatting.js +355 -0
  16. package/dist/es2019/ui/index.js +7 -423
  17. package/dist/es2019/ui/utils.js +48 -0
  18. package/dist/esm/ui/Format.js +1 -0
  19. package/dist/esm/ui/Modal.js +14 -0
  20. package/dist/esm/ui/ModalContent.js +59 -0
  21. package/dist/esm/ui/ModalFooter.js +18 -0
  22. package/dist/esm/ui/ModalHeader.js +27 -0
  23. package/dist/esm/ui/formatting.js +484 -0
  24. package/dist/esm/ui/index.js +12 -561
  25. package/dist/esm/ui/utils.js +48 -0
  26. package/dist/types/ui/Format.d.ts +8 -0
  27. package/dist/types/ui/HelpDialogLoader.d.ts +1 -1
  28. package/dist/types/ui/Modal.d.ts +8 -0
  29. package/dist/types/ui/ModalContent.d.ts +9 -0
  30. package/dist/types/ui/ModalFooter.d.ts +4 -0
  31. package/dist/types/ui/ModalHeader.d.ts +10 -0
  32. package/dist/types/ui/formatting.d.ts +5 -0
  33. package/dist/types/ui/index.d.ts +3 -16
  34. package/dist/types/ui/utils.d.ts +5 -0
  35. package/dist/types-ts4.5/ui/Format.d.ts +8 -0
  36. package/dist/types-ts4.5/ui/HelpDialogLoader.d.ts +1 -1
  37. package/dist/types-ts4.5/ui/Modal.d.ts +8 -0
  38. package/dist/types-ts4.5/ui/ModalContent.d.ts +9 -0
  39. package/dist/types-ts4.5/ui/ModalFooter.d.ts +4 -0
  40. package/dist/types-ts4.5/ui/ModalHeader.d.ts +10 -0
  41. package/dist/types-ts4.5/ui/formatting.d.ts +5 -0
  42. package/dist/types-ts4.5/ui/index.d.ts +3 -16
  43. package/dist/types-ts4.5/ui/utils.d.ts +5 -0
  44. package/package.json +11 -13
@@ -1,528 +1,17 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
1
  /** @jsx jsx */
4
2
  import { useCallback, useEffect } from 'react';
5
3
  import { jsx } from '@emotion/react';
6
- import { FormattedMessage, injectIntl } from 'react-intl-next';
4
+ import { injectIntl } from 'react-intl-next';
7
5
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
- import { addInlineComment, addLink, alignCenter, alignLeft, alignRight, clearFormatting, decreaseMediaSize, focusTableResizer, increaseMediaSize, insertRule, navToEditorToolbar, navToFloatingToolbar, openHelp, pastePlainText, redo, setNormalText, toggleBlockQuote, toggleBold, toggleBulletList, toggleCode, toggleHeading1, toggleHeading2, toggleHeading3, toggleHeading4, toggleHeading5, toggleHeading6, toggleItalic, toggleOrderedList, toggleStrikethrough, toggleSubscript, toggleSuperscript, toggleTaskItemCheckbox, toggleUnderline, undo } from '@atlaskit/editor-common/keymaps';
9
- import { alignmentMessages, annotationMessages, blockTypeMessages, listMessages, helpDialogMessages as messages, toolbarInsertBlockMessages, toolbarMessages, undoRedoMessages } from '@atlaskit/editor-common/messages';
10
- import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
11
- import { browser } from '@atlaskit/editor-common/utils';
12
- import CrossIcon from '@atlaskit/icon/glyph/cross';
13
- import AkModalDialog, { ModalTransition, useModal } from '@atlaskit/modal-dialog';
14
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
+ import AkModalDialog, { ModalTransition } from '@atlaskit/modal-dialog';
15
7
  import { closeHelpCommand } from '../commands';
16
- import { codeLg, codeMd, codeSm, column, componentFromKeymapWrapperStyles, content, contentWrapper, dialogHeader, footer, header, line, row, shortcutsArray, title } from './styles';
17
- var navigationKeymaps = function navigationKeymaps(_ref) {
18
- var formatMessage = _ref.formatMessage;
19
- return [{
20
- name: formatMessage(toolbarMessages.navigateToEditorToolbar),
21
- type: 'navigation',
22
- keymap: function keymap() {
23
- return navToEditorToolbar;
24
- }
25
- }, {
26
- name: formatMessage(toolbarMessages.navigateToFloatingToolbar),
27
- type: 'navigation',
28
- keymap: function keymap() {
29
- return navToFloatingToolbar;
30
- }
31
- }];
32
- };
33
- export var formatting = function formatting(_ref2) {
34
- var formatMessage = _ref2.formatMessage;
35
- return [{
36
- name: formatMessage(toolbarMessages.bold),
37
- type: 'strong',
38
- keymap: function keymap() {
39
- return toggleBold;
40
- },
41
- autoFormatting: function autoFormatting() {
42
- return jsx("span", null, jsx("span", {
43
- css: codeLg
44
- }, "**", jsx(FormattedMessage, toolbarMessages.bold), "**"));
45
- }
46
- }, {
47
- name: formatMessage(toolbarMessages.italic),
48
- type: 'em',
49
- keymap: function keymap() {
50
- return toggleItalic;
51
- },
52
- autoFormatting: function autoFormatting() {
53
- return jsx("span", null, jsx("span", {
54
- css: codeLg
55
- }, "*", jsx(FormattedMessage, toolbarMessages.italic), "*"));
56
- }
57
- }, {
58
- name: formatMessage(toolbarMessages.underline),
59
- type: 'underline',
60
- keymap: function keymap() {
61
- return toggleUnderline;
62
- }
63
- }, {
64
- name: formatMessage(toolbarMessages.strike),
65
- type: 'strike',
66
- keymap: function keymap() {
67
- return toggleStrikethrough;
68
- },
69
- autoFormatting: function autoFormatting() {
70
- return jsx("span", null, jsx("span", {
71
- css: codeLg
72
- }, "~~", jsx(FormattedMessage, toolbarMessages.strike), "~~"));
73
- }
74
- }, {
75
- name: formatMessage(toolbarMessages.subscript),
76
- type: 'subsup',
77
- keymap: function keymap() {
78
- return toggleSubscript;
79
- }
80
- }, {
81
- name: formatMessage(toolbarMessages.superscript),
82
- type: 'subsup',
83
- keymap: function keymap() {
84
- return toggleSuperscript;
85
- }
86
- }, {
87
- name: formatMessage(blockTypeMessages.heading1),
88
- type: 'heading',
89
- keymap: function keymap() {
90
- return toggleHeading1;
91
- },
92
- autoFormatting: function autoFormatting() {
93
- return jsx("span", null, jsx("span", {
94
- css: codeSm
95
- }, "#"), " ", jsx("span", {
96
- css: codeLg
97
- }, "Space"));
98
- }
99
- }, {
100
- name: formatMessage(blockTypeMessages.heading2),
101
- type: 'heading',
102
- keymap: function keymap() {
103
- return toggleHeading2;
104
- },
105
- autoFormatting: function autoFormatting() {
106
- return jsx("span", null, jsx("span", {
107
- css: codeLg
108
- }, "##"), " ", jsx("span", {
109
- css: codeLg
110
- }, "Space"));
111
- }
112
- }, {
113
- name: formatMessage(blockTypeMessages.heading3),
114
- type: 'heading',
115
- keymap: function keymap() {
116
- return toggleHeading3;
117
- },
118
- autoFormatting: function autoFormatting() {
119
- return jsx("span", null, jsx("span", {
120
- css: codeLg
121
- }, "###"), " ", jsx("span", {
122
- css: codeLg
123
- }, "Space"));
124
- }
125
- }, {
126
- name: formatMessage(blockTypeMessages.heading4),
127
- type: 'heading',
128
- keymap: function keymap() {
129
- return toggleHeading4;
130
- },
131
- autoFormatting: function autoFormatting() {
132
- return jsx("span", null, jsx("span", {
133
- css: codeLg
134
- }, "####"), " ", jsx("span", {
135
- css: codeLg
136
- }, "Space"));
137
- }
138
- }, {
139
- name: formatMessage(blockTypeMessages.heading5),
140
- type: 'heading',
141
- keymap: function keymap() {
142
- return toggleHeading5;
143
- },
144
- autoFormatting: function autoFormatting() {
145
- return jsx("span", null, jsx("span", {
146
- css: codeLg
147
- }, "#####"), " ", jsx("span", {
148
- css: codeLg
149
- }, "Space"));
150
- }
151
- }, {
152
- name: formatMessage(blockTypeMessages.heading6),
153
- type: 'heading',
154
- keymap: function keymap() {
155
- return toggleHeading6;
156
- },
157
- autoFormatting: function autoFormatting() {
158
- return jsx("span", null, jsx("span", {
159
- css: codeLg
160
- }, "######"), " ", jsx("span", {
161
- css: codeLg
162
- }, "Space"));
163
- }
164
- }, {
165
- name: formatMessage(blockTypeMessages.normal),
166
- type: 'paragraph',
167
- keymap: function keymap() {
168
- return setNormalText;
169
- }
170
- }, {
171
- name: formatMessage(listMessages.orderedList),
172
- type: 'orderedList',
173
- keymap: function keymap() {
174
- return toggleOrderedList;
175
- },
176
- autoFormatting: function autoFormatting() {
177
- return jsx("span", null, jsx("span", {
178
- css: codeSm
179
- }, "1."), " ", jsx("span", {
180
- css: codeLg
181
- }, "Space"));
182
- }
183
- }, {
184
- name: formatMessage(listMessages.unorderedList),
185
- type: 'bulletList',
186
- keymap: function keymap() {
187
- return toggleBulletList;
188
- },
189
- autoFormatting: function autoFormatting() {
190
- return jsx("span", null, jsx("span", {
191
- css: codeSm
192
- }, "*"), " ", jsx("span", {
193
- css: codeLg
194
- }, "Space"));
195
- }
196
- }, {
197
- name: formatMessage(blockTypeMessages.blockquote),
198
- type: 'blockquote',
199
- keymap: function keymap() {
200
- return toggleBlockQuote;
201
- },
202
- autoFormatting: function autoFormatting() {
203
- return jsx("span", null, jsx("span", {
204
- css: codeLg
205
- }, '>'), " ", jsx("span", {
206
- css: codeLg
207
- }, "Space"));
208
- }
209
- }, {
210
- name: formatMessage(blockTypeMessages.codeblock),
211
- type: 'codeBlock',
212
- autoFormatting: function autoFormatting() {
213
- return jsx("span", null, jsx("span", {
214
- css: codeLg
215
- }, "```"));
216
- }
217
- }, {
218
- name: formatMessage(toolbarInsertBlockMessages.horizontalRule),
219
- type: 'rule',
220
- keymap: function keymap() {
221
- return insertRule;
222
- },
223
- autoFormatting: function autoFormatting() {
224
- return jsx("span", null, jsx("span", {
225
- css: codeLg
226
- }, "---"));
227
- }
228
- }, {
229
- name: formatMessage(toolbarInsertBlockMessages.link),
230
- type: 'link',
231
- keymap: function keymap() {
232
- return addLink;
233
- },
234
- autoFormatting: function autoFormatting() {
235
- return jsx("span", null, jsx("span", {
236
- css: codeLg
237
- }, "[", jsx(FormattedMessage, toolbarInsertBlockMessages.link), "](http://a.com)"));
238
- }
239
- }, {
240
- name: formatMessage(toolbarMessages.code),
241
- type: 'code',
242
- keymap: function keymap() {
243
- return toggleCode;
244
- },
245
- autoFormatting: function autoFormatting() {
246
- return jsx("span", null, jsx("span", {
247
- css: codeLg
248
- }, "`", jsx(FormattedMessage, toolbarMessages.code), "`"));
249
- }
250
- }, {
251
- name: formatMessage(toolbarInsertBlockMessages.action),
252
- type: 'taskItem',
253
- autoFormatting: function autoFormatting() {
254
- return jsx("span", null, jsx("span", {
255
- css: codeSm
256
- }, "[]"), " ", jsx("span", {
257
- css: codeLg
258
- }, "Space"));
259
- }
260
- }, {
261
- name: formatMessage(toolbarInsertBlockMessages.decision),
262
- type: 'decisionItem',
263
- autoFormatting: function autoFormatting() {
264
- return jsx("span", null, jsx("span", {
265
- css: codeSm
266
- }, "<>"), " ", jsx("span", {
267
- css: codeLg
268
- }, "Space"));
269
- }
270
- }, {
271
- name: formatMessage(toolbarInsertBlockMessages.emoji),
272
- type: 'emoji',
273
- autoFormatting: function autoFormatting() {
274
- return jsx("span", null, jsx("span", {
275
- css: codeLg
276
- }, ":"));
277
- }
278
- }, {
279
- name: formatMessage(toolbarInsertBlockMessages.mention),
280
- type: 'mention',
281
- autoFormatting: function autoFormatting() {
282
- return jsx("span", null, jsx("span", {
283
- css: codeLg
284
- }, "@"));
285
- }
286
- }, {
287
- name: formatMessage(alignmentMessages.alignLeft),
288
- type: 'alignment',
289
- keymap: function keymap() {
290
- return alignLeft;
291
- }
292
- }].concat(_toConsumableArray(getBooleanFF('platform.editor.text-alignment-keyboard-shortcuts') ? [{
293
- name: formatMessage(alignmentMessages.alignCenter),
294
- type: 'alignment',
295
- keymap: function keymap() {
296
- return alignCenter;
297
- }
298
- }, {
299
- name: formatMessage(alignmentMessages.alignRight),
300
- type: 'alignment',
301
- keymap: function keymap() {
302
- return alignRight;
303
- }
304
- }] : []));
305
- };
306
- var shortcutNamesWithoutKeymap = ['emoji', 'mention', 'quickInsert'];
307
- var otherFormatting = function otherFormatting(_ref3) {
308
- var formatMessage = _ref3.formatMessage;
309
- return [{
310
- name: formatMessage(toolbarMessages.clearFormatting),
311
- type: 'clearFormatting',
312
- keymap: function keymap() {
313
- return clearFormatting;
314
- }
315
- }, {
316
- name: formatMessage(undoRedoMessages.undo),
317
- type: 'undo',
318
- keymap: function keymap() {
319
- return undo;
320
- }
321
- }, {
322
- name: formatMessage(undoRedoMessages.redo),
323
- type: 'redo',
324
- keymap: function keymap() {
325
- return redo;
326
- }
327
- }, {
328
- name: formatMessage(messages.pastePlainText),
329
- type: 'paste',
330
- keymap: function keymap() {
331
- return pastePlainText;
332
- }
333
- }, {
334
- name: formatMessage(annotationMessages.createComment),
335
- type: 'annotation',
336
- keymap: function keymap() {
337
- return addInlineComment;
338
- }
339
- }, {
340
- name: formatMessage(messages.CheckUncheckActionItem),
341
- type: 'checkbox',
342
- keymap: function keymap() {
343
- return toggleTaskItemCheckbox;
344
- }
345
- }].concat(_toConsumableArray(getBooleanFF('platform.editor.a11y.table-selection_9uv33') ? [{
346
- name: formatMessage(messages.selectTableRow),
347
- type: 'table',
348
- autoFormatting: function autoFormatting() {
349
- return jsx("span", {
350
- css: shortcutsArray
351
- }, jsx("span", null, jsx("span", {
352
- css: codeSm
353
- }, browser.mac ? '⌘' : 'Ctrl'), ' + ', jsx("span", {
354
- css: codeMd
355
- }, browser.mac ? 'Opt' : 'Alt'), ' + ', jsx("span", {
356
- css: codeMd
357
- }, "Shift"), ' + ', jsx("span", {
358
- css: codeSm
359
- }, "\u2190")), jsx("span", null, jsx("span", {
360
- css: codeSm
361
- }, browser.mac ? '⌘' : 'Ctrl'), ' + ', jsx("span", {
362
- css: codeMd
363
- }, browser.mac ? 'Opt' : 'Alt'), ' + ', jsx("span", {
364
- css: codeMd
365
- }, "Shift"), ' + ', jsx("span", {
366
- css: codeSm
367
- }, "\u2192")));
368
- }
369
- }, {
370
- name: formatMessage(messages.selectTableColumn),
371
- type: 'table',
372
- autoFormatting: function autoFormatting() {
373
- return jsx("span", {
374
- css: shortcutsArray
375
- }, jsx("span", null, jsx("span", {
376
- css: codeSm
377
- }, browser.mac ? '⌘' : 'Ctrl'), ' + ', jsx("span", {
378
- css: codeMd
379
- }, browser.mac ? 'Opt' : 'Alt'), ' + ', jsx("span", {
380
- css: codeMd
381
- }, "Shift"), ' + ', jsx("span", {
382
- css: codeSm
383
- }, "\u2191")), jsx("span", null, jsx("span", {
384
- css: codeSm
385
- }, browser.mac ? '⌘' : 'Ctrl'), ' + ', jsx("span", {
386
- css: codeMd
387
- }, browser.mac ? 'Opt' : 'Alt'), ' + ', jsx("span", {
388
- css: codeMd
389
- }, "Shift"), ' + ', jsx("span", {
390
- css: codeSm
391
- }, "\u2193")));
392
- }
393
- }] : []));
394
- };
395
- var resizeInformationFormatting = function resizeInformationFormatting(_ref4) {
396
- var formatMessage = _ref4.formatMessage;
397
- return [{
398
- name: formatMessage(messages.increaseSize),
399
- type: 'media',
400
- keymap: function keymap() {
401
- return increaseMediaSize;
402
- }
403
- }, {
404
- name: formatMessage(messages.decreaseSize),
405
- type: 'media',
406
- keymap: function keymap() {
407
- return decreaseMediaSize;
408
- }
409
- }];
410
- };
411
- var focusTableResizeHandleFormatting = function focusTableResizeHandleFormatting(_ref5) {
412
- var formatMessage = _ref5.formatMessage;
413
- return [{
414
- name: formatMessage(messages.focusTableResizeHandle),
415
- type: 'navigation',
416
- keymap: function keymap() {
417
- return focusTableResizer;
418
- }
419
- }];
420
- };
421
- var imageAutoFormat = {
422
- name: 'Image',
423
- type: 'image',
424
- autoFormatting: function autoFormatting() {
425
- return jsx("span", null, jsx("span", {
426
- css: codeLg
427
- }, "![", jsx(FormattedMessage, messages.altText), "](http://www.image.com)"));
428
- }
429
- };
430
- var quickInsertAutoFormat = function quickInsertAutoFormat(_ref6) {
431
- var formatMessage = _ref6.formatMessage;
432
- return {
433
- name: formatMessage(messages.quickInsert),
434
- type: 'quickInsert',
435
- autoFormatting: function autoFormatting() {
436
- return jsx("span", null, jsx("span", {
437
- css: codeLg
438
- }, "/"));
439
- }
440
- };
441
- };
442
- var getKeyParts = function getKeyParts(keymap) {
443
- var shortcut = keymap[browser.mac ? 'mac' : 'windows'];
444
- if (browser.mac) {
445
- shortcut = shortcut.replace('Alt', 'Opt');
446
- }
447
- return shortcut.replace(/\-(?=.)/g, ' + ').split(' ');
448
- };
449
- var isAnyA11yResizeFeatureFlagEnabled = getBooleanFF('platform.editor.a11y-media-resizing_b5v0o') || getBooleanFF('platform.editor.a11y-table-resizing_uapcv');
450
- export var getSupportedFormatting = function getSupportedFormatting(schema, intl, imageEnabled, quickInsertEnabled) {
451
- var supportedBySchema = formatting(intl).filter(function (format) {
452
- return schema.nodes[format.type] || schema.marks[format.type];
453
- });
454
- return [].concat(_toConsumableArray(navigationKeymaps(intl)), _toConsumableArray(supportedBySchema), _toConsumableArray(imageEnabled ? [imageAutoFormat] : []), _toConsumableArray(quickInsertEnabled ? [quickInsertAutoFormat(intl)] : []), _toConsumableArray(otherFormatting(intl)), _toConsumableArray(isAnyA11yResizeFeatureFlagEnabled ? resizeInformationFormatting(intl) : []), _toConsumableArray(getBooleanFF('platform.editor.a11y-table-resizing_uapcv') ? focusTableResizeHandleFormatting(intl) : []));
455
- };
456
- export var getComponentFromKeymap = function getComponentFromKeymap(keymap) {
457
- var keyParts = getKeyParts(keymap);
458
- return jsx("span", {
459
- css: componentFromKeymapWrapperStyles
460
- }, keyParts.map(function (part, index) {
461
- if (part === '+') {
462
- return jsx("span", {
463
- key: "".concat(keyParts, "-").concat(index)
464
- }, ' + ');
465
- } else if (part === 'Cmd') {
466
- return jsx("span", {
467
- css: codeSm,
468
- key: "".concat(keyParts, "-").concat(index)
469
- }, "\u2318");
470
- } else if (['ctrl', 'alt', 'opt', 'shift'].indexOf(part.toLowerCase()) >= 0) {
471
- return jsx("span", {
472
- css: codeMd,
473
- key: "".concat(keyParts, "-").concat(index)
474
- }, part);
475
- } else if (['f9', 'f10'].indexOf(part.toLowerCase()) >= 0) {
476
- return jsx("span", {
477
- css: codeLg,
478
- key: "".concat(keyParts, "-").concat(index)
479
- }, part);
480
- } else if (part.toLowerCase() === 'enter') {
481
- return jsx("span", {
482
- css: codeSm,
483
- key: "".concat(keyParts, "-").concat(index)
484
- }, '⏎');
485
- }
486
- return jsx("span", {
487
- css: codeSm,
488
- key: "".concat(keyParts, "-").concat(index)
489
- }, part.toUpperCase());
490
- }));
491
- };
492
- var ModalHeader = injectIntl(function (_ref7) {
493
- var formatMessage = _ref7.intl.formatMessage;
494
- var _useModal = useModal(),
495
- onClose = _useModal.onClose;
496
- return jsx("div", {
497
- css: header
498
- }, jsx("h1", {
499
- css: dialogHeader
500
- }, jsx(FormattedMessage, messages.editorHelp)), jsx("div", null, jsx(ToolbarButton
501
- // @ts-ignore
502
- , {
503
- onClick: onClose,
504
- title: formatMessage(messages.closeHelpDialog),
505
- spacing: "compact",
506
- iconBefore: jsx(CrossIcon, {
507
- label: formatMessage(messages.closeHelpDialog),
508
- size: "medium"
509
- })
510
- })));
511
- });
512
- var ModalFooter = function ModalFooter() {
513
- return jsx("div", {
514
- css: footer
515
- }, jsx(FormattedMessage, _extends({}, messages.helpDialogTips, {
516
- values: {
517
- keyMap: getComponentFromKeymap(openHelp)
518
- }
519
- })));
520
- };
521
- var HelpDialog = function HelpDialog(_ref8) {
522
- var pluginInjectionApi = _ref8.pluginInjectionApi,
523
- editorView = _ref8.editorView,
524
- quickInsertEnabled = _ref8.quickInsertEnabled,
525
- intl = _ref8.intl;
8
+ import { getSupportedFormatting } from './formatting';
9
+ import Modal from './Modal';
10
+ var HelpDialog = function HelpDialog(_ref) {
11
+ var pluginInjectionApi = _ref.pluginInjectionApi,
12
+ editorView = _ref.editorView,
13
+ quickInsertEnabled = _ref.quickInsertEnabled,
14
+ intl = _ref.intl;
526
15
  var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['helpDialog']),
527
16
  helpDialogState = _useSharedPluginState.helpDialogState;
528
17
  var closeDialog = useCallback(function () {
@@ -546,46 +35,8 @@ var HelpDialog = function HelpDialog(_ref8) {
546
35
  width: "large",
547
36
  onClose: closeDialog,
548
37
  testId: "help-modal-dialog"
549
- }, jsx(ModalHeader, null), jsx("div", {
550
- css: contentWrapper
551
- }, jsx("div", {
552
- css: line
553
- }), jsx("div", {
554
- css: content
555
- }, jsx("div", {
556
- css: column
557
- }, jsx("h2", {
558
- css: title
559
- }, jsx(FormattedMessage, messages.keyboardShortcuts)), jsx("ul", null, formatting.filter(function (form) {
560
- var keymap = form.keymap && form.keymap();
561
- return keymap && keymap[browser.mac ? 'mac' : 'windows'];
562
- }).map(function (form) {
563
- return jsx("li", {
564
- css: row,
565
- key: "textFormatting-".concat(form.name)
566
- }, jsx("span", null, form.name), getComponentFromKeymap(form.keymap()));
567
- }), formatting.filter(function (form) {
568
- return shortcutNamesWithoutKeymap.indexOf(form.type) !== -1;
569
- }).filter(function (form) {
570
- return form.autoFormatting;
571
- }).map(function (form) {
572
- return jsx("li", {
573
- css: row,
574
- key: "autoFormatting-".concat(form.name)
575
- }, jsx("span", null, form.name), form.autoFormatting());
576
- }))), jsx("div", {
577
- css: line
578
- }), jsx("div", {
579
- css: column
580
- }, jsx("h2", {
581
- css: title
582
- }, jsx(FormattedMessage, messages.markdown)), jsx("ul", null, formatting.filter(function (form) {
583
- return shortcutNamesWithoutKeymap.indexOf(form.type) === -1;
584
- }).map(function (form) {
585
- return form.autoFormatting && jsx("li", {
586
- key: "autoFormatting-".concat(form.name),
587
- css: row
588
- }, jsx("span", null, form.name), form.autoFormatting());
589
- }))))), jsx(ModalFooter, null)) : null);
38
+ }, jsx(Modal, {
39
+ formatting: formatting
40
+ })) : null);
590
41
  };
591
42
  export default injectIntl(HelpDialog);
@@ -0,0 +1,48 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import { browser } from '@atlaskit/editor-common/utils';
4
+ import { codeLg, codeMd, codeSm, componentFromKeymapWrapperStyles } from './styles';
5
+ var getKeyParts = function getKeyParts(keymap) {
6
+ var shortcut = keymap[browser.mac ? 'mac' : 'windows'];
7
+ if (browser.mac) {
8
+ shortcut = shortcut.replace('Alt', 'Opt');
9
+ }
10
+ return shortcut.replace(/\-(?=.)/g, ' + ').split(' ');
11
+ };
12
+ export var shortcutNamesWithoutKeymap = ['emoji', 'mention', 'quickInsert'];
13
+ export var getComponentFromKeymap = function getComponentFromKeymap(keymap) {
14
+ var keyParts = getKeyParts(keymap);
15
+ return jsx("span", {
16
+ css: componentFromKeymapWrapperStyles
17
+ }, keyParts.map(function (part, index) {
18
+ if (part === '+') {
19
+ return jsx("span", {
20
+ key: "".concat(keyParts, "-").concat(index)
21
+ }, ' + ');
22
+ } else if (part === 'Cmd') {
23
+ return jsx("span", {
24
+ css: codeSm,
25
+ key: "".concat(keyParts, "-").concat(index)
26
+ }, "\u2318");
27
+ } else if (['ctrl', 'alt', 'opt', 'shift'].indexOf(part.toLowerCase()) >= 0) {
28
+ return jsx("span", {
29
+ css: codeMd,
30
+ key: "".concat(keyParts, "-").concat(index)
31
+ }, part);
32
+ } else if (['f9', 'f10'].indexOf(part.toLowerCase()) >= 0) {
33
+ return jsx("span", {
34
+ css: codeLg,
35
+ key: "".concat(keyParts, "-").concat(index)
36
+ }, part);
37
+ } else if (part.toLowerCase() === 'enter') {
38
+ return jsx("span", {
39
+ css: codeSm,
40
+ key: "".concat(keyParts, "-").concat(index)
41
+ }, '⏎');
42
+ }
43
+ return jsx("span", {
44
+ css: codeSm,
45
+ key: "".concat(keyParts, "-").concat(index)
46
+ }, part.toUpperCase());
47
+ }));
48
+ };
@@ -0,0 +1,8 @@
1
+ interface Format {
2
+ name: string;
3
+ type: string;
4
+ keymap?: Function;
5
+ autoFormatting?: Function;
6
+ imageEnabled?: boolean;
7
+ }
8
+ export default Format;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import Loadable from 'react-loadable';
3
3
  import type { HelpDialogProps } from './index';
4
- export declare const HelpDialogLoader: import("react").ComponentType<HelpDialogProps> & Loadable.LoadableComponent;
4
+ export declare const HelpDialogLoader: import("react").ComponentType<import("react").PropsWithChildren<HelpDialogProps>> & Loadable.LoadableComponent;
@@ -0,0 +1,8 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import type Format from './Format';
4
+ interface ModalProps {
5
+ formatting: Format[];
6
+ }
7
+ declare const Modal: ({ formatting }: ModalProps) => jsx.JSX.Element;
8
+ export default Modal;
@@ -0,0 +1,9 @@
1
+ import { jsx } from '@emotion/react';
2
+ import type { OnCloseHandler } from '@atlaskit/modal-dialog';
3
+ import type Format from './Format';
4
+ interface ModalContentProps {
5
+ formatting: Format[];
6
+ onClose: OnCloseHandler | undefined;
7
+ }
8
+ export declare const ModalContent: ({ formatting, onClose }: ModalContentProps) => jsx.JSX.Element;
9
+ export default ModalContent;
@@ -0,0 +1,4 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ declare const ModalFooter: () => jsx.JSX.Element;
4
+ export default ModalFooter;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { OnCloseHandler } from '@atlaskit/modal-dialog';
4
+ interface ModalHeaderProps extends WrappedComponentProps {
5
+ onClose: OnCloseHandler | undefined;
6
+ }
7
+ declare const ModalHeader: import("react").FC<import("react-intl-next").WithIntlProps<ModalHeaderProps>> & {
8
+ WrappedComponent: import("react").ComponentType<ModalHeaderProps>;
9
+ };
10
+ export default ModalHeader;