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