@atlaskit/editor-plugin-help-dialog 0.1.0 → 0.2.1

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 (40) hide show
  1. package/.eslintrc.js +2 -0
  2. package/CHANGELOG.md +12 -0
  3. package/dist/cjs/commands.js +19 -0
  4. package/dist/cjs/index.js +15 -1
  5. package/dist/cjs/plugin-key.js +8 -0
  6. package/dist/cjs/plugin.js +137 -0
  7. package/dist/cjs/ui/HelpDialogLoader.js +24 -0
  8. package/dist/cjs/ui/index.js +563 -0
  9. package/dist/cjs/ui/styles.js +50 -0
  10. package/dist/es2019/commands.js +13 -0
  11. package/dist/es2019/index.js +6 -1
  12. package/dist/es2019/plugin-key.js +2 -0
  13. package/dist/es2019/plugin.js +124 -0
  14. package/dist/es2019/ui/HelpDialogLoader.js +6 -0
  15. package/dist/es2019/ui/index.js +441 -0
  16. package/dist/es2019/ui/styles.js +110 -0
  17. package/dist/esm/commands.js +13 -0
  18. package/dist/esm/index.js +6 -1
  19. package/dist/esm/plugin-key.js +2 -0
  20. package/dist/esm/plugin.js +129 -0
  21. package/dist/esm/ui/HelpDialogLoader.js +12 -0
  22. package/dist/esm/ui/index.js +552 -0
  23. package/dist/esm/ui/styles.js +40 -0
  24. package/dist/types/commands.d.ts +3 -0
  25. package/dist/types/index.d.ts +6 -0
  26. package/dist/types/plugin-key.d.ts +2 -0
  27. package/dist/types/plugin.d.ts +4 -0
  28. package/dist/types/ui/HelpDialogLoader.d.ts +4 -0
  29. package/dist/types/ui/index.d.ts +27 -0
  30. package/dist/types/ui/styles.d.ts +33 -0
  31. package/dist/types-ts4.5/commands.d.ts +3 -0
  32. package/dist/types-ts4.5/index.d.ts +6 -0
  33. package/dist/types-ts4.5/plugin-key.d.ts +2 -0
  34. package/dist/types-ts4.5/plugin.d.ts +4 -0
  35. package/dist/types-ts4.5/ui/HelpDialogLoader.d.ts +4 -0
  36. package/dist/types-ts4.5/ui/index.d.ts +27 -0
  37. package/dist/types-ts4.5/ui/styles.d.ts +33 -0
  38. package/package.json +13 -4
  39. package/report.api.md +10 -0
  40. package/tmp/api-report-tmp.d.ts +7 -0
@@ -0,0 +1,124 @@
1
+ import React from 'react';
2
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { bindKeymapWithCommand, openHelp, tooltip } from '@atlaskit/editor-common/keymaps';
4
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
+ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
7
+ import QuestionCircleIcon from '@atlaskit/icon/glyph/question-circle';
8
+ import { openHelpCommand } from './commands';
9
+ import { pluginKey } from './plugin-key';
10
+ import { HelpDialogLoader } from './ui/HelpDialogLoader';
11
+ export function createPlugin(dispatch, imageEnabled) {
12
+ return new SafePlugin({
13
+ key: pluginKey,
14
+ state: {
15
+ init() {
16
+ return {
17
+ isVisible: false,
18
+ imageEnabled
19
+ };
20
+ },
21
+ apply(tr, _value, state) {
22
+ const isVisible = tr.getMeta(pluginKey);
23
+ const currentState = pluginKey.getState(state);
24
+ if (isVisible !== undefined && isVisible !== currentState.isVisible) {
25
+ const newState = {
26
+ ...currentState,
27
+ isVisible
28
+ };
29
+ dispatch(pluginKey, newState);
30
+ return newState;
31
+ }
32
+ return currentState;
33
+ }
34
+ }
35
+ });
36
+ }
37
+ export const helpDialogPlugin = ({
38
+ config: imageUploadProviderExists = false,
39
+ api
40
+ }) => ({
41
+ name: 'helpDialog',
42
+ pmPlugins() {
43
+ return [{
44
+ name: 'helpDialog',
45
+ plugin: ({
46
+ dispatch
47
+ }) => createPlugin(dispatch, imageUploadProviderExists)
48
+ }, {
49
+ name: 'helpDialogKeymap',
50
+ plugin: () => {
51
+ var _api$analytics;
52
+ return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
53
+ }
54
+ }];
55
+ },
56
+ pluginsOptions: {
57
+ quickInsert: ({
58
+ formatMessage
59
+ }) => [{
60
+ id: 'helpdialog',
61
+ title: formatMessage(messages.help),
62
+ description: formatMessage(messages.helpDescription),
63
+ keywords: ['?'],
64
+ priority: 4000,
65
+ keyshortcut: tooltip(openHelp),
66
+ icon: () => /*#__PURE__*/React.createElement(QuestionCircleIcon, {
67
+ label: ""
68
+ }),
69
+ action(insert) {
70
+ var _api$analytics2;
71
+ const tr = insert('');
72
+ openHelpCommand(tr);
73
+ api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent({
74
+ action: ACTION.HELP_OPENED,
75
+ actionSubject: ACTION_SUBJECT.HELP,
76
+ actionSubjectId: ACTION_SUBJECT_ID.HELP_QUICK_INSERT,
77
+ attributes: {
78
+ inputMethod: INPUT_METHOD.QUICK_INSERT
79
+ },
80
+ eventType: EVENT_TYPE.UI
81
+ })(tr);
82
+ return tr;
83
+ }
84
+ }]
85
+ },
86
+ contentComponent({
87
+ editorView
88
+ }) {
89
+ return /*#__PURE__*/React.createElement(HelpDialogLoader, {
90
+ pluginInjectionApi: api,
91
+ editorView: editorView,
92
+ quickInsertEnabled: !!(api !== null && api !== void 0 && api.quickInsert)
93
+ });
94
+ },
95
+ getSharedState(editorState) {
96
+ if (!editorState) {
97
+ return null;
98
+ }
99
+ return pluginKey.getState(editorState) || null;
100
+ }
101
+ });
102
+ const keymapPlugin = editorAnalyticsAPI => {
103
+ const list = {};
104
+ bindKeymapWithCommand(openHelp.common, (state, dispatch) => {
105
+ let {
106
+ tr
107
+ } = state;
108
+ const isVisible = tr.getMeta(pluginKey);
109
+ if (!isVisible) {
110
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
111
+ action: ACTION.CLICKED,
112
+ actionSubject: ACTION_SUBJECT.BUTTON,
113
+ actionSubjectId: ACTION_SUBJECT_ID.BUTTON_HELP,
114
+ attributes: {
115
+ inputMethod: INPUT_METHOD.SHORTCUT
116
+ },
117
+ eventType: EVENT_TYPE.UI
118
+ })(tr);
119
+ openHelpCommand(tr, dispatch);
120
+ }
121
+ return true;
122
+ }, list);
123
+ return keymap(list);
124
+ };
@@ -0,0 +1,6 @@
1
+ import Loadable from 'react-loadable';
2
+ export const HelpDialogLoader = Loadable({
3
+ loader: () => import( /* webpackChunkName: "@atlaskit-internal_editor-core-helpdialog" */
4
+ './index').then(mod => mod.default),
5
+ loading: () => null
6
+ });
@@ -0,0 +1,441 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ /** @jsx jsx */
3
+ import { useCallback, useEffect } from 'react';
4
+ import { jsx } from '@emotion/react';
5
+ import { defineMessages, FormattedMessage, injectIntl } from 'react-intl-next';
6
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ import { addInlineComment, addLink, alignLeft, clearFormatting, 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';
8
+ import { alignmentMessages, annotationMessages, blockTypeMessages, listMessages, toolbarInsertBlockMessages, toolbarMessages, undoRedoMessages } from '@atlaskit/editor-common/messages';
9
+ import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
10
+ import { browser } from '@atlaskit/editor-common/utils';
11
+ import CrossIcon from '@atlaskit/icon/glyph/cross';
12
+ import AkModalDialog, { ModalTransition, useModal } from '@atlaskit/modal-dialog';
13
+ import { closeHelpCommand } from '../commands';
14
+ import { codeLg, codeMd, codeSm, column, content, contentWrapper, dialogHeader, footer, header, line, row, title } from './styles';
15
+ const messages = defineMessages({
16
+ editorHelp: {
17
+ id: 'fabric.editor.editorHelp',
18
+ defaultMessage: 'Editor help',
19
+ description: 'Title of editor help dialog.'
20
+ },
21
+ helpDialogTips: {
22
+ id: 'fabric.editor.helpDialogTips',
23
+ defaultMessage: 'Press {keyMap} to quickly open this dialog at any time',
24
+ description: 'Hint about how to open a dialog quickly using a shortcut.'
25
+ },
26
+ keyboardShortcuts: {
27
+ id: 'fabric.editor.keyboardShortcuts',
28
+ defaultMessage: 'Keyboard shortcuts',
29
+ description: ''
30
+ },
31
+ markdown: {
32
+ id: 'fabric.editor.markdown',
33
+ defaultMessage: 'Markdown',
34
+ description: 'It is a name of popular markup language.'
35
+ },
36
+ pastePlainText: {
37
+ id: 'fabric.editor.pastePlainText',
38
+ defaultMessage: 'Paste plain text',
39
+ description: ''
40
+ },
41
+ CheckUncheckActionItem: {
42
+ id: 'fabric.editor.checkUncheckActionItem',
43
+ defaultMessage: 'Toggle action item',
44
+ description: 'For Check/Uncheck Action item use shortcut'
45
+ },
46
+ altText: {
47
+ id: 'fabric.editor.altText',
48
+ defaultMessage: 'Alt text',
49
+ description: 'Alternative text for image.'
50
+ },
51
+ closeHelpDialog: {
52
+ id: 'fabric.editor.closeHelpDialog',
53
+ defaultMessage: 'Close help dialog',
54
+ description: ''
55
+ },
56
+ // TODO: Move it inside quick insert plugin
57
+ quickInsert: {
58
+ id: 'fabric.editor.quickInsert',
59
+ defaultMessage: 'Quick insert',
60
+ description: 'Name of a feature, which let you insert items quickly.'
61
+ }
62
+ });
63
+ const navigationKeymaps = ({
64
+ formatMessage
65
+ }) => [{
66
+ name: formatMessage(toolbarMessages.navigateToEditorToolbar),
67
+ type: 'navigation',
68
+ keymap: () => navToEditorToolbar
69
+ }, {
70
+ name: formatMessage(toolbarMessages.navigateToFloatingToolbar),
71
+ type: 'navigation',
72
+ keymap: () => navToFloatingToolbar
73
+ }];
74
+ export const formatting = ({
75
+ formatMessage
76
+ }) => [{
77
+ name: formatMessage(toolbarMessages.bold),
78
+ type: 'strong',
79
+ keymap: () => toggleBold,
80
+ autoFormatting: () => jsx("span", null, jsx("span", {
81
+ css: codeLg
82
+ }, "**", jsx(FormattedMessage, toolbarMessages.bold), "**"))
83
+ }, {
84
+ name: formatMessage(toolbarMessages.italic),
85
+ type: 'em',
86
+ keymap: () => toggleItalic,
87
+ autoFormatting: () => jsx("span", null, jsx("span", {
88
+ css: codeLg
89
+ }, "*", jsx(FormattedMessage, toolbarMessages.italic), "*"))
90
+ }, {
91
+ name: formatMessage(toolbarMessages.underline),
92
+ type: 'underline',
93
+ keymap: () => toggleUnderline
94
+ }, {
95
+ name: formatMessage(toolbarMessages.strike),
96
+ type: 'strike',
97
+ keymap: () => toggleStrikethrough,
98
+ autoFormatting: () => jsx("span", null, jsx("span", {
99
+ css: codeLg
100
+ }, "~~", jsx(FormattedMessage, toolbarMessages.strike), "~~"))
101
+ }, {
102
+ name: formatMessage(toolbarMessages.subscript),
103
+ type: 'subsup',
104
+ keymap: () => toggleSubscript
105
+ }, {
106
+ name: formatMessage(toolbarMessages.superscript),
107
+ type: 'subsup',
108
+ keymap: () => toggleSuperscript
109
+ }, {
110
+ name: formatMessage(blockTypeMessages.heading1),
111
+ type: 'heading',
112
+ keymap: () => toggleHeading1,
113
+ autoFormatting: () => jsx("span", null, jsx("span", {
114
+ css: codeSm
115
+ }, "#"), " ", jsx("span", {
116
+ css: codeLg
117
+ }, "Space"))
118
+ }, {
119
+ name: formatMessage(blockTypeMessages.heading2),
120
+ type: 'heading',
121
+ keymap: () => toggleHeading2,
122
+ autoFormatting: () => jsx("span", null, jsx("span", {
123
+ css: codeLg
124
+ }, "##"), " ", jsx("span", {
125
+ css: codeLg
126
+ }, "Space"))
127
+ }, {
128
+ name: formatMessage(blockTypeMessages.heading3),
129
+ type: 'heading',
130
+ keymap: () => toggleHeading3,
131
+ autoFormatting: () => jsx("span", null, jsx("span", {
132
+ css: codeLg
133
+ }, "###"), " ", jsx("span", {
134
+ css: codeLg
135
+ }, "Space"))
136
+ }, {
137
+ name: formatMessage(blockTypeMessages.heading4),
138
+ type: 'heading',
139
+ keymap: () => toggleHeading4,
140
+ autoFormatting: () => jsx("span", null, jsx("span", {
141
+ css: codeLg
142
+ }, "####"), " ", jsx("span", {
143
+ css: codeLg
144
+ }, "Space"))
145
+ }, {
146
+ name: formatMessage(blockTypeMessages.heading5),
147
+ type: 'heading',
148
+ keymap: () => toggleHeading5,
149
+ autoFormatting: () => jsx("span", null, jsx("span", {
150
+ css: codeLg
151
+ }, "#####"), " ", jsx("span", {
152
+ css: codeLg
153
+ }, "Space"))
154
+ }, {
155
+ name: formatMessage(blockTypeMessages.heading6),
156
+ type: 'heading',
157
+ keymap: () => toggleHeading6,
158
+ autoFormatting: () => jsx("span", null, jsx("span", {
159
+ css: codeLg
160
+ }, "######"), " ", jsx("span", {
161
+ css: codeLg
162
+ }, "Space"))
163
+ }, {
164
+ name: formatMessage(blockTypeMessages.normal),
165
+ type: 'paragraph',
166
+ keymap: () => setNormalText
167
+ }, {
168
+ name: formatMessage(listMessages.orderedList),
169
+ type: 'orderedList',
170
+ keymap: () => toggleOrderedList,
171
+ autoFormatting: () => jsx("span", null, jsx("span", {
172
+ css: codeSm
173
+ }, "1."), " ", jsx("span", {
174
+ css: codeLg
175
+ }, "Space"))
176
+ }, {
177
+ name: formatMessage(listMessages.unorderedList),
178
+ type: 'bulletList',
179
+ keymap: () => toggleBulletList,
180
+ autoFormatting: () => jsx("span", null, jsx("span", {
181
+ css: codeSm
182
+ }, "*"), " ", jsx("span", {
183
+ css: codeLg
184
+ }, "Space"))
185
+ }, {
186
+ name: formatMessage(blockTypeMessages.blockquote),
187
+ type: 'blockquote',
188
+ keymap: () => toggleBlockQuote,
189
+ autoFormatting: () => jsx("span", null, jsx("span", {
190
+ css: codeLg
191
+ }, '>'), " ", jsx("span", {
192
+ css: codeLg
193
+ }, "Space"))
194
+ }, {
195
+ name: formatMessage(blockTypeMessages.codeblock),
196
+ type: 'codeBlock',
197
+ autoFormatting: () => jsx("span", null, jsx("span", {
198
+ css: codeLg
199
+ }, "```"))
200
+ }, {
201
+ name: formatMessage(toolbarInsertBlockMessages.horizontalRule),
202
+ type: 'rule',
203
+ keymap: () => insertRule,
204
+ autoFormatting: () => jsx("span", null, jsx("span", {
205
+ css: codeLg
206
+ }, "---"))
207
+ }, {
208
+ name: formatMessage(toolbarInsertBlockMessages.link),
209
+ type: 'link',
210
+ keymap: () => addLink,
211
+ autoFormatting: () => jsx("span", null, jsx("span", {
212
+ css: codeLg
213
+ }, "[", jsx(FormattedMessage, toolbarInsertBlockMessages.link), "](http://a.com)"))
214
+ }, {
215
+ name: formatMessage(toolbarMessages.code),
216
+ type: 'code',
217
+ keymap: () => toggleCode,
218
+ autoFormatting: () => jsx("span", null, jsx("span", {
219
+ css: codeLg
220
+ }, "`", jsx(FormattedMessage, toolbarMessages.code), "`"))
221
+ }, {
222
+ name: formatMessage(toolbarInsertBlockMessages.action),
223
+ type: 'taskItem',
224
+ autoFormatting: () => jsx("span", null, jsx("span", {
225
+ css: codeSm
226
+ }, "[]"), " ", jsx("span", {
227
+ css: codeLg
228
+ }, "Space"))
229
+ }, {
230
+ name: formatMessage(toolbarInsertBlockMessages.decision),
231
+ type: 'decisionItem',
232
+ autoFormatting: () => jsx("span", null, jsx("span", {
233
+ css: codeSm
234
+ }, "<>"), " ", jsx("span", {
235
+ css: codeLg
236
+ }, "Space"))
237
+ }, {
238
+ name: formatMessage(toolbarInsertBlockMessages.emoji),
239
+ type: 'emoji',
240
+ autoFormatting: () => jsx("span", null, jsx("span", {
241
+ css: codeLg
242
+ }, ":"))
243
+ }, {
244
+ name: formatMessage(toolbarInsertBlockMessages.mention),
245
+ type: 'mention',
246
+ autoFormatting: () => jsx("span", null, jsx("span", {
247
+ css: codeLg
248
+ }, "@"))
249
+ }, {
250
+ name: formatMessage(alignmentMessages.alignLeft),
251
+ type: 'alignment',
252
+ keymap: () => alignLeft
253
+ }, {
254
+ name: formatMessage(alignmentMessages.alignRight),
255
+ type: 'alignment'
256
+ }];
257
+ const shortcutNamesWithoutKeymap = ['emoji', 'mention', 'quickInsert'];
258
+ const otherFormatting = ({
259
+ formatMessage
260
+ }) => [{
261
+ name: formatMessage(toolbarMessages.clearFormatting),
262
+ type: 'clearFormatting',
263
+ keymap: () => clearFormatting
264
+ }, {
265
+ name: formatMessage(undoRedoMessages.undo),
266
+ type: 'undo',
267
+ keymap: () => undo
268
+ }, {
269
+ name: formatMessage(undoRedoMessages.redo),
270
+ type: 'redo',
271
+ keymap: () => redo
272
+ }, {
273
+ name: formatMessage(messages.pastePlainText),
274
+ type: 'paste',
275
+ keymap: () => pastePlainText
276
+ }, {
277
+ name: formatMessage(annotationMessages.createComment),
278
+ type: 'annotation',
279
+ keymap: () => addInlineComment
280
+ }, {
281
+ name: formatMessage(messages.CheckUncheckActionItem),
282
+ type: 'checkbox',
283
+ keymap: () => toggleTaskItemCheckbox
284
+ }];
285
+ const imageAutoFormat = {
286
+ name: 'Image',
287
+ type: 'image',
288
+ autoFormatting: () => jsx("span", null, jsx("span", {
289
+ css: codeLg
290
+ }, "![", jsx(FormattedMessage, messages.altText), "](http://www.image.com)"))
291
+ };
292
+ const quickInsertAutoFormat = ({
293
+ formatMessage
294
+ }) => ({
295
+ name: formatMessage(messages.quickInsert),
296
+ type: 'quickInsert',
297
+ autoFormatting: () => jsx("span", null, jsx("span", {
298
+ css: codeLg
299
+ }, "/"))
300
+ });
301
+ const getKeyParts = keymap => {
302
+ let shortcut = keymap[browser.mac ? 'mac' : 'windows'];
303
+ if (browser.mac) {
304
+ shortcut = shortcut.replace('Alt', 'Opt');
305
+ }
306
+ return shortcut.replace(/\-(?=.)/g, ' + ').split(' ');
307
+ };
308
+ export const getSupportedFormatting = (schema, intl, imageEnabled, quickInsertEnabled) => {
309
+ const supportedBySchema = formatting(intl).filter(format => schema.nodes[format.type] || schema.marks[format.type]);
310
+ return [...navigationKeymaps(intl), ...supportedBySchema, ...(imageEnabled ? [imageAutoFormat] : []), ...(quickInsertEnabled ? [quickInsertAutoFormat(intl)] : []), ...otherFormatting(intl)];
311
+ };
312
+ export const getComponentFromKeymap = keymap => {
313
+ const keyParts = getKeyParts(keymap);
314
+ return jsx("span", null, keyParts.map((part, index) => {
315
+ if (part === '+') {
316
+ return jsx("span", {
317
+ key: `${keyParts}-${index}`
318
+ }, ' + ');
319
+ } else if (part === 'Cmd') {
320
+ return jsx("span", {
321
+ css: codeSm,
322
+ key: `${keyParts}-${index}`
323
+ }, "\u2318");
324
+ } else if (['ctrl', 'alt', 'opt', 'shift'].indexOf(part.toLowerCase()) >= 0) {
325
+ return jsx("span", {
326
+ css: codeMd,
327
+ key: `${keyParts}-${index}`
328
+ }, part);
329
+ } else if (['f9', 'f10'].indexOf(part.toLowerCase()) >= 0) {
330
+ return jsx("span", {
331
+ css: codeLg,
332
+ key: `${keyParts}-${index}`
333
+ }, part);
334
+ } else if (part.toLowerCase() === 'enter') {
335
+ return jsx("span", {
336
+ css: codeSm,
337
+ key: `${keyParts}-${index}`
338
+ }, '⏎');
339
+ }
340
+ return jsx("span", {
341
+ css: codeSm,
342
+ key: `${keyParts}-${index}`
343
+ }, part.toUpperCase());
344
+ }));
345
+ };
346
+ const ModalHeader = injectIntl(({
347
+ intl: {
348
+ formatMessage
349
+ }
350
+ }) => {
351
+ const {
352
+ onClose
353
+ } = useModal();
354
+ return jsx("div", {
355
+ css: header
356
+ }, jsx("h1", {
357
+ css: dialogHeader
358
+ }, jsx(FormattedMessage, messages.editorHelp)), jsx("div", null, jsx(ToolbarButton
359
+ // @ts-ignore
360
+ , {
361
+ onClick: onClose,
362
+ title: formatMessage(messages.closeHelpDialog),
363
+ spacing: "compact",
364
+ iconBefore: jsx(CrossIcon, {
365
+ label: formatMessage(messages.closeHelpDialog),
366
+ size: "medium"
367
+ })
368
+ })));
369
+ });
370
+ const ModalFooter = () => jsx("div", {
371
+ css: footer
372
+ }, jsx(FormattedMessage, _extends({}, messages.helpDialogTips, {
373
+ values: {
374
+ keyMap: getComponentFromKeymap(openHelp)
375
+ }
376
+ })));
377
+ const HelpDialog = ({
378
+ pluginInjectionApi,
379
+ editorView,
380
+ quickInsertEnabled,
381
+ intl
382
+ }) => {
383
+ const {
384
+ helpDialogState
385
+ } = useSharedPluginState(pluginInjectionApi, ['helpDialog']);
386
+ const closeDialog = useCallback(() => {
387
+ const {
388
+ state: {
389
+ tr
390
+ },
391
+ dispatch
392
+ } = editorView;
393
+ closeHelpCommand(tr, dispatch);
394
+ }, [editorView]);
395
+ const handleEsc = useCallback(e => {
396
+ if (e.key === 'Escape' && helpDialogState !== null && helpDialogState !== void 0 && helpDialogState.isVisible) {
397
+ closeDialog();
398
+ }
399
+ }, [closeDialog, helpDialogState === null || helpDialogState === void 0 ? void 0 : helpDialogState.isVisible]);
400
+ useEffect(() => {
401
+ document.addEventListener('keydown', handleEsc);
402
+ return () => {
403
+ document.removeEventListener('keydown', handleEsc);
404
+ };
405
+ }, [handleEsc]);
406
+ const formatting = getSupportedFormatting(editorView.state.schema, intl, helpDialogState === null || helpDialogState === void 0 ? void 0 : helpDialogState.imageEnabled, quickInsertEnabled);
407
+ return jsx(ModalTransition, null, helpDialogState !== null && helpDialogState !== void 0 && helpDialogState.isVisible ? jsx(AkModalDialog, {
408
+ width: "large",
409
+ onClose: closeDialog,
410
+ testId: "help-modal-dialog"
411
+ }, jsx(ModalHeader, null), jsx("div", {
412
+ css: contentWrapper
413
+ }, jsx("div", {
414
+ css: line
415
+ }), jsx("div", {
416
+ css: content
417
+ }, jsx("div", {
418
+ css: column
419
+ }, jsx("h2", {
420
+ css: title
421
+ }, jsx(FormattedMessage, messages.keyboardShortcuts)), jsx("ul", null, formatting.filter(form => {
422
+ const keymap = form.keymap && form.keymap();
423
+ return keymap && keymap[browser.mac ? 'mac' : 'windows'];
424
+ }).map(form => jsx("li", {
425
+ css: row,
426
+ key: `textFormatting-${form.name}`
427
+ }, jsx("span", null, form.name), getComponentFromKeymap(form.keymap()))), formatting.filter(form => shortcutNamesWithoutKeymap.indexOf(form.type) !== -1).filter(form => form.autoFormatting).map(form => jsx("li", {
428
+ css: row,
429
+ key: `autoFormatting-${form.name}`
430
+ }, jsx("span", null, form.name), form.autoFormatting())))), jsx("div", {
431
+ css: line
432
+ }), jsx("div", {
433
+ css: column
434
+ }, jsx("h2", {
435
+ css: title
436
+ }, jsx(FormattedMessage, messages.markdown)), jsx("ul", null, formatting.filter(form => shortcutNamesWithoutKeymap.indexOf(form.type) === -1).map(form => form.autoFormatting && jsx("li", {
437
+ key: `autoFormatting-${form.name}`,
438
+ css: row
439
+ }, jsx("span", null, form.name), form.autoFormatting())))))), jsx(ModalFooter, null)) : null);
440
+ };
441
+ export default injectIntl(HelpDialog);
@@ -0,0 +1,110 @@
1
+ import { css } from '@emotion/react';
2
+ import { akEditorUnitZIndex, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
3
+ import * as colors from '@atlaskit/theme/colors';
4
+ import { N400 } from '@atlaskit/theme/colors';
5
+ import { borderRadius } from '@atlaskit/theme/constants';
6
+ export const header = css`
7
+ z-index: ${akEditorUnitZIndex};
8
+ min-height: 24px;
9
+ padding: ${"var(--ds-space-250, 20px)"} ${"var(--ds-space-500, 40px)"};
10
+ font-size: ${relativeFontSizeToBase16(24)};
11
+ display: flex;
12
+ justify-content: space-between;
13
+ align-items: center;
14
+ box-shadow: 'none';
15
+ color: ${`var(--ds-text, ${colors.N400})`};
16
+ background-color: ${`var(--ds-background-neutral-subtle, ${colors.N0})`};
17
+ border-radius: ${borderRadius()}px;
18
+ `;
19
+ export const footer = css`
20
+ z-index: ${akEditorUnitZIndex};
21
+ font-size: ${relativeFontSizeToBase16(14)};
22
+ line-height: 20px;
23
+ color: ${`var(--ds-text-subtlest, ${colors.N300})`};
24
+ padding: ${"var(--ds-space-300, 24px)"};
25
+ text-align: right;
26
+ box-shadow: 'none';
27
+ `;
28
+ export const contentWrapper = css`
29
+ padding: ${"var(--ds-space-250, 20px)"} 44px;
30
+ border-bottom-right-radius: ${borderRadius()}px;
31
+ overflow: auto;
32
+ position: relative;
33
+ color: ${`var(--ds-text-subtle, ${colors.N400})`};
34
+ background-color: ${`var(--ds-background-neutral-subtle, ${colors.N0})`};
35
+ `;
36
+ export const line = css`
37
+ background: ${"var(--ds-background-neutral-subtle, #fff)"};
38
+ content: '';
39
+ display: block;
40
+ height: 2px;
41
+ left: 0;
42
+ position: absolute;
43
+ top: 0;
44
+ right: 0;
45
+ width: 100%;
46
+ min-width: 604px;
47
+ `;
48
+ export const content = css`
49
+ min-width: 524px;
50
+ width: 100%;
51
+ position: relative;
52
+ display: flex;
53
+ justify-content: space-between;
54
+ `;
55
+ export const column = {
56
+ width: '44%',
57
+ '& > ul': {
58
+ padding: 0
59
+ }
60
+ };
61
+ export const row = css`
62
+ margin: ${"var(--ds-space-250, 20px)"} 0;
63
+ display: flex;
64
+ justify-content: space-between;
65
+ `;
66
+ export const dialogHeader = {
67
+ '&': {
68
+ fontSize: relativeFontSizeToBase16(24),
69
+ fontWeight: 400,
70
+ color: `var(--ds-text-subtle, ${N400})`,
71
+ letterSpacing: 'normal',
72
+ lineHeight: 1.42857142857143
73
+ }
74
+ };
75
+ export const title = {
76
+ '&': {
77
+ fontSize: relativeFontSizeToBase16(18),
78
+ fontWeight: 400,
79
+ color: `var(--ds-text-subtle, ${N400})`,
80
+ letterSpacing: 'normal',
81
+ lineHeight: 1.42857142857143
82
+ }
83
+ };
84
+ export const codeSm = css`
85
+ background-color: ${`var(--ds-background-neutral, ${colors.N20})`};
86
+ border-radius: ${borderRadius()}px;
87
+ width: 24px;
88
+ display: inline-block;
89
+ height: 24px;
90
+ line-height: 24px;
91
+ text-align: center;
92
+ `;
93
+ export const codeMd = css`
94
+ background-color: ${`var(--ds-background-neutral, ${colors.N20})`};
95
+ border-radius: ${borderRadius()}px;
96
+ display: inline-block;
97
+ height: 24px;
98
+ line-height: 24px;
99
+ width: 50px;
100
+ text-align: center;
101
+ `;
102
+ export const codeLg = css`
103
+ background-color: ${`var(--ds-background-neutral, ${colors.N20})`};
104
+ border-radius: ${borderRadius()}px;
105
+ display: inline-block;
106
+ height: 24px;
107
+ line-height: 24px;
108
+ padding: 0 10px;
109
+ text-align: center;
110
+ `;
@@ -0,0 +1,13 @@
1
+ import { pluginKey } from './plugin-key';
2
+ export var openHelpCommand = function openHelpCommand(tr, dispatch) {
3
+ tr = tr.setMeta(pluginKey, true);
4
+ if (dispatch) {
5
+ dispatch(tr);
6
+ return true;
7
+ }
8
+ return false;
9
+ };
10
+ export var closeHelpCommand = function closeHelpCommand(tr, dispatch) {
11
+ tr = tr.setMeta(pluginKey, false);
12
+ dispatch(tr);
13
+ };
package/dist/esm/index.js CHANGED
@@ -1 +1,6 @@
1
- export {};
1
+ export { helpDialogPlugin } from './plugin';
2
+ export {
3
+ /**
4
+ * @deprecated DO NOT USE, it is only available to maintain an existing deprecated API
5
+ */
6
+ openHelpCommand as deprecatedOpenHelpCommand } from './commands';