@atlaskit/editor-core 169.0.0 → 170.0.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 (137) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/cjs/create-editor/create-plugins-list.js +7 -0
  3. package/dist/cjs/plugins/analytics/types/toolbar-button.js +2 -0
  4. package/dist/cjs/plugins/breakout/index.js +7 -0
  5. package/dist/cjs/plugins/breakout/ui/LayoutButton.js +3 -1
  6. package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +6 -1
  7. package/dist/cjs/plugins/card/styles.js +4 -2
  8. package/dist/cjs/plugins/card/toolbar.js +6 -1
  9. package/dist/cjs/plugins/code-block/styles.js +17 -41
  10. package/dist/cjs/plugins/code-block/ui/class-names.js +5 -2
  11. package/dist/cjs/plugins/copy-button/commands.js +85 -0
  12. package/dist/cjs/plugins/copy-button/index.js +27 -0
  13. package/dist/cjs/plugins/copy-button/pm-plugins/main.js +38 -0
  14. package/dist/cjs/plugins/copy-button/pm-plugins/plugin-key.js +11 -0
  15. package/dist/cjs/plugins/copy-button/utils.js +51 -0
  16. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +4 -2
  17. package/dist/cjs/plugins/indentation/messages.js +23 -0
  18. package/dist/cjs/plugins/index.js +16 -0
  19. package/dist/cjs/plugins/list/index.js +0 -43
  20. package/dist/cjs/plugins/panel/toolbar.js +10 -2
  21. package/dist/cjs/plugins/quick-insert/search.js +3 -4
  22. package/dist/cjs/plugins/table/commands/hover.js +2 -2
  23. package/dist/cjs/plugins/table/toolbar.js +5 -1
  24. package/dist/cjs/plugins/table/utils/decoration.js +5 -1
  25. package/dist/cjs/plugins/toolbar-lists-indentation/index.js +65 -0
  26. package/dist/cjs/plugins/toolbar-lists-indentation/types.js +5 -0
  27. package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +122 -0
  28. package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +173 -0
  29. package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +58 -0
  30. package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +48 -0
  31. package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +4 -5
  32. package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +17 -51
  33. package/dist/cjs/ui/ElementBrowser/InsertMenu.js +12 -39
  34. package/dist/cjs/ui/ElementBrowser/components/ElementList/ElementList.js +31 -87
  35. package/dist/cjs/utils/clipboard.js +67 -2
  36. package/dist/cjs/version-wrapper.js +1 -1
  37. package/dist/cjs/version.json +1 -1
  38. package/dist/es2019/create-editor/create-plugins-list.js +8 -1
  39. package/dist/es2019/plugins/analytics/types/toolbar-button.js +2 -0
  40. package/dist/es2019/plugins/breakout/index.js +7 -0
  41. package/dist/es2019/plugins/breakout/ui/LayoutButton.js +3 -1
  42. package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +6 -1
  43. package/dist/es2019/plugins/card/styles.js +5 -0
  44. package/dist/es2019/plugins/card/toolbar.js +5 -1
  45. package/dist/es2019/plugins/code-block/styles.js +18 -95
  46. package/dist/es2019/plugins/code-block/ui/class-names.js +3 -2
  47. package/dist/es2019/plugins/copy-button/commands.js +64 -0
  48. package/dist/es2019/plugins/copy-button/index.js +15 -0
  49. package/dist/es2019/plugins/copy-button/pm-plugins/main.js +28 -0
  50. package/dist/es2019/plugins/copy-button/pm-plugins/plugin-key.js +2 -0
  51. package/dist/es2019/plugins/copy-button/utils.js +29 -0
  52. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +4 -2
  53. package/dist/es2019/plugins/indentation/messages.js +14 -0
  54. package/dist/es2019/plugins/index.js +3 -1
  55. package/dist/es2019/plugins/list/index.js +1 -44
  56. package/dist/es2019/plugins/panel/toolbar.js +9 -2
  57. package/dist/es2019/plugins/quick-insert/search.js +3 -4
  58. package/dist/es2019/plugins/table/commands/hover.js +2 -2
  59. package/dist/es2019/plugins/table/toolbar.js +5 -2
  60. package/dist/es2019/plugins/table/utils/decoration.js +5 -1
  61. package/dist/es2019/plugins/toolbar-lists-indentation/index.js +53 -0
  62. package/dist/es2019/plugins/toolbar-lists-indentation/types.js +1 -0
  63. package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +94 -0
  64. package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +149 -0
  65. package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +49 -0
  66. package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +35 -0
  67. package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +11 -10
  68. package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +17 -48
  69. package/dist/es2019/ui/ElementBrowser/InsertMenu.js +10 -30
  70. package/dist/es2019/ui/ElementBrowser/components/ElementList/ElementList.js +34 -93
  71. package/dist/es2019/utils/clipboard.js +26 -0
  72. package/dist/es2019/version-wrapper.js +1 -1
  73. package/dist/es2019/version.json +1 -1
  74. package/dist/esm/create-editor/create-plugins-list.js +8 -1
  75. package/dist/esm/plugins/analytics/types/toolbar-button.js +2 -0
  76. package/dist/esm/plugins/breakout/index.js +7 -0
  77. package/dist/esm/plugins/breakout/ui/LayoutButton.js +3 -1
  78. package/dist/esm/plugins/card/pm-plugins/util/resolve.js +6 -1
  79. package/dist/esm/plugins/card/styles.js +2 -1
  80. package/dist/esm/plugins/card/toolbar.js +5 -1
  81. package/dist/esm/plugins/code-block/styles.js +16 -35
  82. package/dist/esm/plugins/code-block/ui/class-names.js +3 -2
  83. package/dist/esm/plugins/copy-button/commands.js +66 -0
  84. package/dist/esm/plugins/copy-button/index.js +17 -0
  85. package/dist/esm/plugins/copy-button/pm-plugins/main.js +26 -0
  86. package/dist/esm/plugins/copy-button/pm-plugins/plugin-key.js +2 -0
  87. package/dist/esm/plugins/copy-button/utils.js +31 -0
  88. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +4 -2
  89. package/dist/esm/plugins/indentation/messages.js +14 -0
  90. package/dist/esm/plugins/index.js +3 -1
  91. package/dist/esm/plugins/list/index.js +1 -41
  92. package/dist/esm/plugins/panel/toolbar.js +9 -2
  93. package/dist/esm/plugins/quick-insert/search.js +3 -4
  94. package/dist/esm/plugins/table/commands/hover.js +2 -2
  95. package/dist/esm/plugins/table/toolbar.js +5 -2
  96. package/dist/esm/plugins/table/utils/decoration.js +5 -1
  97. package/dist/esm/plugins/toolbar-lists-indentation/index.js +51 -0
  98. package/dist/esm/plugins/toolbar-lists-indentation/types.js +1 -0
  99. package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +96 -0
  100. package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +153 -0
  101. package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +47 -0
  102. package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +39 -0
  103. package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +6 -8
  104. package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +18 -51
  105. package/dist/esm/ui/ElementBrowser/InsertMenu.js +12 -35
  106. package/dist/esm/ui/ElementBrowser/components/ElementList/ElementList.js +31 -89
  107. package/dist/esm/utils/clipboard.js +55 -0
  108. package/dist/esm/version-wrapper.js +1 -1
  109. package/dist/esm/version.json +1 -1
  110. package/dist/types/plugins/analytics/types/toolbar-button.d.ts +3 -1
  111. package/dist/types/plugins/card/styles.d.ts +1 -0
  112. package/dist/types/plugins/copy-button/commands.d.ts +4 -0
  113. package/dist/types/plugins/copy-button/index.d.ts +3 -0
  114. package/dist/types/plugins/copy-button/pm-plugins/main.d.ts +3 -0
  115. package/dist/types/plugins/copy-button/pm-plugins/plugin-key.d.ts +2 -0
  116. package/dist/types/plugins/copy-button/utils.d.ts +7 -0
  117. package/dist/types/plugins/indentation/messages.d.ts +12 -0
  118. package/dist/types/plugins/index.d.ts +2 -0
  119. package/dist/types/plugins/panel/toolbar.d.ts +1 -1
  120. package/dist/types/plugins/table/commands/hover.d.ts +1 -1
  121. package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
  122. package/dist/types/plugins/text-formatting/utils.d.ts +1 -1
  123. package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +5 -0
  124. package/dist/types/plugins/toolbar-lists-indentation/types.d.ts +16 -0
  125. package/dist/types/plugins/toolbar-lists-indentation/ui/Toolbar.d.ts +4 -0
  126. package/dist/types/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.d.ts +9 -0
  127. package/dist/types/plugins/{list/ui/ToolbarLists → toolbar-lists-indentation/ui}/index.d.ts +4 -10
  128. package/dist/types/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +6 -0
  129. package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +0 -25
  130. package/dist/types/types/feature-flags.d.ts +18 -0
  131. package/dist/types/ui/ElementBrowser/components/ElementList/ElementList.d.ts +11 -0
  132. package/dist/types/utils/clipboard.d.ts +1 -0
  133. package/package.json +21 -21
  134. package/report.api.md +5373 -1324
  135. package/dist/cjs/plugins/list/ui/ToolbarLists/index.js +0 -266
  136. package/dist/es2019/plugins/list/ui/ToolbarLists/index.js +0 -220
  137. package/dist/esm/plugins/list/ui/ToolbarLists/index.js +0 -241
@@ -4,6 +4,7 @@ import { N20 } from '@atlaskit/theme/colors';
4
4
  import { SmartCardSharedCssClassName } from '@atlaskit/editor-common/styles';
5
5
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
6
6
  import { token } from '@atlaskit/tokens';
7
+ export const FLOATING_TOOLBAR_LINKPICKER_CLASSNAME = 'card-floating-toolbar--link-picker';
7
8
  export const smartCardStyles = css`
8
9
  .${SmartCardSharedCssClassName.INLINE_CARD_CONTAINER} {
9
10
  max-width: calc(100% - 20px);
@@ -98,4 +99,8 @@ export const smartCardStyles = css`
98
99
  }
99
100
  }
100
101
  }
102
+
103
+ .${FLOATING_TOOLBAR_LINKPICKER_CLASSNAME} {
104
+ padding: 0;
105
+ }
101
106
  `;
@@ -18,6 +18,7 @@ import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
18
18
  import { messages } from './messages';
19
19
  import buildLayoutButtons from '../../ui/MediaAndEmbedsToolbar';
20
20
  import { buildVisitedLinkPayload } from '../../utils/linking-utils';
21
+ import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME } from './styles';
21
22
  export const removeCard = (state, dispatch) => {
22
23
  if (!(state.selection instanceof NodeSelection)) {
23
24
  return false;
@@ -227,9 +228,12 @@ export const floatingToolbar = (cardOptions, platform) => {
227
228
 
228
229
  const toolbarOffset = isEmbedCard ? {
229
230
  offset: [0, 24]
230
- } : {};
231
+ } : {}; // Applies padding override for when link picker is currently displayed
232
+
233
+ const className = pluginState.showLinkingToolbar ? FLOATING_TOOLBAR_LINKPICKER_CLASSNAME : undefined;
231
234
  return {
232
235
  title: intl.formatMessage(messages.card),
236
+ className,
233
237
  nodeType,
234
238
  ...toolbarOffset,
235
239
  getDomRef: view => {
@@ -1,10 +1,11 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { themed } from '@atlaskit/theme/components';
3
3
  import { borderRadius, fontSize, gridSize } from '@atlaskit/theme/constants';
4
- import * as colors from '@atlaskit/theme/colors';
4
+ import { R75, N20, DN50, N30, DN20, N90, DN90, N400, DN400, N800, DN500 } from '@atlaskit/theme/colors';
5
5
  import { blockNodesVerticalMargin, akEditorTableCellMinWidth, akEditorDeleteBackground, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorDeleteIconColor, SelectionStyle, getSelectionStyles, akEditorCodeFontFamily, akEditorSelectedNodeClassName, overflowShadow, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
6
6
  import { token } from '@atlaskit/tokens';
7
7
  import { codeBlockClassNames } from './ui/class-names';
8
+ import { codeBlockSharedStyles } from '@atlaskit/editor-common/styles';
8
9
  export const highlightingCodeBlockStyles = props => css`
9
10
  .ProseMirror .code-block {
10
11
  position: relative;
@@ -12,15 +13,15 @@ export const highlightingCodeBlockStyles = props => css`
12
13
  // TODO: https://product-fabric.atlassian.net/browse/DSP-4118
13
14
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
14
15
  background: themed({
15
- light: colors.N20,
16
- dark: colors.DN50
16
+ light: N20,
17
+ dark: DN50
17
18
  })(props),
18
19
  width: '8px'
19
20
  })};
20
21
  background-repeat: no-repeat;
21
22
  background-color: ${themed({
22
- light: token('color.background.neutral', colors.N20),
23
- dark: token('color.background.neutral', colors.DN50)
23
+ light: token('color.background.neutral', N20),
24
+ dark: token('color.background.neutral', DN50)
24
25
  })(props)};
25
26
 
26
27
  --ds--code--bg-color: transparent;
@@ -42,13 +43,13 @@ export const highlightingCodeBlockStyles = props => css`
42
43
  flex-shrink: 0;
43
44
  text-align: right;
44
45
  background-color: ${themed({
45
- light: token('color.background.neutral', colors.N30),
46
- dark: token('color.background.neutral', colors.DN20)
46
+ light: token('color.background.neutral', N30),
47
+ dark: token('color.background.neutral', DN20)
47
48
  })(props)};
48
49
  padding: ${gridSize()}px;
49
50
  color: ${themed({
50
- light: token('color.text.subtlest', colors.N90),
51
- dark: token('color.text.subtlest', colors.DN90)
51
+ light: token('color.text.subtlest', N90),
52
+ dark: token('color.text.subtlest', DN90)
52
53
  })(props)};
53
54
 
54
55
  span {
@@ -63,8 +64,8 @@ export const highlightingCodeBlockStyles = props => css`
63
64
  font-size: ${relativeFontSizeToBase16(fontSize())};
64
65
  line-height: 1.5rem;
65
66
  color: ${themed({
66
- light: token('color.text.subtle', colors.N400),
67
- dark: token('color.text.subtle', colors.DN400)
67
+ light: token('color.text.subtle', N400),
68
+ dark: token('color.text.subtle', DN400)
68
69
  })(props)};
69
70
  }
70
71
  }
@@ -117,8 +118,8 @@ export const highlightingCodeBlockStyles = props => css`
117
118
  > code:not([data-language='plaintext']):not([data-language='none']):not([data-language='']) {
118
119
  color: transparent;
119
120
  caret-color: ${themed({
120
- light: token('color.text', colors.N800),
121
- dark: token('color.text', colors.DN500)
121
+ light: token('color.text', N800),
122
+ dark: token('color.text', DN500)
122
123
  })(props)};
123
124
  }
124
125
  }
@@ -139,7 +140,7 @@ export const highlightingCodeBlockStyles = props => css`
139
140
  ${token('color.border.danger', akEditorDeleteBorder)};
140
141
 
141
142
  .${codeBlockClassNames.gutter} {
142
- background-color: ${token('color.blanket.danger', colors.R75)};
143
+ background-color: ${token('color.blanket.danger', R75)};
143
144
  color: ${token('color.text.danger', akEditorDeleteIconColor)};
144
145
  }
145
146
 
@@ -161,86 +162,8 @@ export const highlightingCodeBlockStyles = props => css`
161
162
  }
162
163
  `;
163
164
  export const codeBlockStyles = props => css`
164
- .ProseMirror .code-block {
165
- position: relative;
166
- background-image: ${overflowShadow({
167
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4118
168
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
169
- background: themed({
170
- light: colors.N20,
171
- dark: colors.DN50
172
- })(props),
173
- width: '8px'
174
- })};
175
-
176
- --ds--code--bg-color: transparent;
177
-
178
- background-repeat: no-repeat;
179
- background-color: ${themed({
180
- light: token('color.background.neutral', colors.N20),
181
- dark: token('color.background.neutral', colors.DN50)
182
- })(props)};
183
- background-attachment: local, scroll, scroll;
184
- background-size: 8px 100%, 8px 100%, 8px 100%;
185
- background-position: 100% 0, 100% 0, 0 0;
186
- font-family: ${akEditorCodeFontFamily};
187
- border-radius: ${borderRadius()}px;
188
- margin: ${blockNodesVerticalMargin} 0 0 0;
189
- counter-reset: line;
190
- display: flex;
191
- min-width: ${akEditorTableCellMinWidth}px;
192
- cursor: pointer;
193
- overflow-x: auto;
194
-
195
- .${codeBlockClassNames.gutter} {
196
- /* https://bitbucket.org/atlassian/atlassian-frontend/src/develop/packages/design-system/code/src/themes/themeBuilder.ts#packages/design-system/code/src/themes/themeBuilder.ts-19:28 */
197
- flex-shrink: 0;
198
- text-align: right;
199
- background-color: ${themed({
200
- light: token('color.background.neutral', colors.N30),
201
- dark: token('color.background.neutral', colors.DN20)
202
- })(props)};
203
- padding: ${gridSize()}px;
204
-
205
- span {
206
- display: block;
207
- line-height: 0;
208
- font-size: 0;
209
-
210
- &::before {
211
- display: inline-block;
212
- content: counter(line);
213
- counter-increment: line;
214
- font-size: ${relativeFontSizeToBase16(fontSize())};
215
- line-height: 1.5rem;
216
- color: ${themed({
217
- light: token('color.text', colors.N400),
218
- dark: token('color.text', colors.DN400)
219
- })(props)};
220
- }
221
- }
222
- }
223
-
224
- .${codeBlockClassNames.content} {
225
- display: flex;
226
- flex: 1;
227
-
228
- code {
229
- flex-grow: 1;
230
- tab-size: 4;
231
- cursor: text;
232
- /* https://bitbucket.org/atlassian/atlassian-frontend/src/218202daeaf527262c21841e6f88fa058d349ad4/packages/design-system/code/src/themes/themeBuilder.ts#lines-12:17 */
233
- font-size: ${relativeFontSizeToBase16(fontSize())};
234
- line-height: 1.5rem;
235
- color: ${themed({
236
- light: token('color.text', colors.N800),
237
- dark: token('color.text', colors.DN800)
238
- })(props)};
239
- border-radius: ${borderRadius()}px;
240
- margin: ${gridSize()}px;
241
- white-space: pre;
242
- }
243
- }
165
+ .ProseMirror {
166
+ ${codeBlockSharedStyles(props)}
244
167
  }
245
168
 
246
169
  .ProseMirror li > .code-block {
@@ -256,7 +179,7 @@ export const codeBlockStyles = props => css`
256
179
  box-shadow: 0 0 0 ${akEditorSelectedBorderSize}px ${akEditorDeleteBorder};
257
180
 
258
181
  .${codeBlockClassNames.gutter} {
259
- background-color: ${token('color.blanket.danger', colors.R75)};
182
+ background-color: ${token('color.blanket.danger', R75)};
260
183
  color: ${token('color.text.danger', akEditorDeleteIconColor)};
261
184
  }
262
185
 
@@ -1,5 +1,6 @@
1
+ import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
1
2
  export const codeBlockClassNames = {
2
- gutter: 'line-number-gutter',
3
- content: 'code-content',
3
+ gutter: CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER,
4
+ content: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT,
4
5
  highlighting: 'code-highlighting'
5
6
  };
@@ -0,0 +1,64 @@
1
+ import { findSelectedNodeOfType, findParentNodeOfType } from 'prosemirror-utils';
2
+ import { pluginKey } from './pm-plugins/plugin-key';
3
+ import { hoverDecoration } from '../base/pm-plugins/decoration';
4
+ import { DOMSerializer } from 'prosemirror-model';
5
+ import { copyHTMLToClipboard } from '../../utils/clipboard';
6
+ export const copy = nodeType => (state, dispatch) => {
7
+ const {
8
+ tr,
9
+ schema
10
+ } = state; // This command should only be triggered by the Copy button in the floating toolbar
11
+ // which is only visible when selection is inside the target node
12
+
13
+ let node = findSelectedNodeOfType(nodeType)(tr.selection);
14
+
15
+ if (!node) {
16
+ node = findParentNodeOfType(nodeType)(tr.selection);
17
+ }
18
+
19
+ if (!node) {
20
+ return false;
21
+ }
22
+
23
+ const domNode = DOMSerializer.fromSchema(schema).serializeNode(node.node);
24
+ const div = document.createElement('div');
25
+ div.appendChild(domNode); // The "0 0" refers to the start and end depth of the slice
26
+ // since we're coping the block node only, it will always be 0 0
27
+ // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
28
+
29
+ div.firstChild.setAttribute('data-pm-slice', '0 0 []');
30
+ copyHTMLToClipboard(div.innerHTML);
31
+ const copyToClipboardTr = tr;
32
+ copyToClipboardTr.setMeta(pluginKey, {
33
+ copied: true
34
+ });
35
+
36
+ if (dispatch) {
37
+ dispatch(copyToClipboardTr);
38
+ }
39
+
40
+ return true;
41
+ };
42
+ export const resetCopiedState = (nodeType, onMouseLeave) => (state, dispatch) => {
43
+ let customTr = state.tr; // Avoid multipe dispatch
44
+ // https://product-fabric.atlassian.net/wiki/spaces/E/pages/2241659456/All+about+dispatch+and+why+there+shouldn+t+be+multiple#How-do-I-avoid-them%3F
45
+
46
+ const customDispatch = tr => {
47
+ customTr = tr;
48
+ };
49
+
50
+ onMouseLeave ? onMouseLeave(state, customDispatch) : hoverDecoration(nodeType, false)(state, customDispatch);
51
+ const copyButtonState = pluginKey.getState(state);
52
+
53
+ if (copyButtonState !== null && copyButtonState !== void 0 && copyButtonState.copied) {
54
+ customTr.setMeta(pluginKey, {
55
+ copied: false
56
+ });
57
+ }
58
+
59
+ if (dispatch) {
60
+ dispatch(customTr);
61
+ }
62
+
63
+ return true;
64
+ };
@@ -0,0 +1,15 @@
1
+ import createPlugin from './pm-plugins/main';
2
+
3
+ const copyButtonPlugin = () => ({
4
+ name: 'copyButton',
5
+
6
+ pmPlugins() {
7
+ return [{
8
+ name: 'copyButton',
9
+ plugin: () => createPlugin()
10
+ }];
11
+ }
12
+
13
+ });
14
+
15
+ export default copyButtonPlugin;
@@ -0,0 +1,28 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { pluginKey } from './plugin-key';
3
+ export function copyButtonPlugin() {
4
+ return new SafePlugin({
5
+ state: {
6
+ init() {
7
+ return {
8
+ copied: false
9
+ };
10
+ },
11
+
12
+ apply(tr, pluginState) {
13
+ const meta = tr.getMeta(pluginKey);
14
+
15
+ if ((meta === null || meta === void 0 ? void 0 : meta.copied) !== undefined) {
16
+ return {
17
+ copied: meta.copied
18
+ };
19
+ }
20
+
21
+ return pluginState;
22
+ }
23
+
24
+ },
25
+ key: pluginKey
26
+ });
27
+ }
28
+ export default copyButtonPlugin;
@@ -0,0 +1,2 @@
1
+ import { PluginKey } from 'prosemirror-state';
2
+ export const pluginKey = new PluginKey('copyButtonPlugin');
@@ -0,0 +1,29 @@
1
+ import CopyIcon from '@atlaskit/icon/glyph/copy';
2
+ import commonMessages from '../../messages';
3
+ import { hoverDecoration } from '../base/pm-plugins/decoration';
4
+ import { copy, resetCopiedState } from './commands';
5
+ import { pluginKey } from './pm-plugins/plugin-key';
6
+ export const getCopyButtonConfig = (state, formatMessage, nodeType, onMouseEnter, onMouseLeave) => {
7
+ const copyButtonState = pluginKey.getState(state);
8
+ return {
9
+ id: 'editor.floatingToolbar.copy',
10
+ type: 'button',
11
+ appearance: 'subtle',
12
+ icon: CopyIcon,
13
+ onClick: copy(nodeType),
14
+ title: formatMessage(copyButtonState !== null && copyButtonState !== void 0 && copyButtonState.copied ? commonMessages.copiedToClipboard : commonMessages.copyToClipboard),
15
+ onMouseEnter: onMouseEnter || hoverDecoration(nodeType, true, 'ak-editor-selected-node'),
16
+ onMouseLeave: resetCopiedState(nodeType, onMouseLeave),
17
+ onFocus: hoverDecoration(nodeType, true, 'ak-editor-selected-node'),
18
+ onBlur: hoverDecoration(nodeType, false),
19
+ hideTooltipOnClick: false,
20
+ tabIndex: null // TODO select and delete styling needs to be removed when keyboard cursor moves away
21
+ // problem already exist with delete as well
22
+
23
+ };
24
+ };
25
+ export const showCopyButton = state => {
26
+ return state && // Check if the Copy button plugin is enabled
27
+ // @ts-ignore pluginKey.key
28
+ state.plugins.find(p => p.key === pluginKey.key);
29
+ };
@@ -12,7 +12,7 @@ const safeNumberFeatureFlag = value => {
12
12
 
13
13
 
14
14
  export function createFeatureFlagsFromProps(props) {
15
- var _props$allowTextColor, _props$allowLayouts, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$allowTables, _props$featureFlags3, _props$featureFlags4, _props$allowTables2, _props$featureFlags5, _props$featureFlags6, _props$allowTables3, _props$featureFlags7, _props$featureFlags8, _props$allowTables4, _props$featureFlags9, _props$featureFlags10, _props$allowTables5, _props$allowExtension, _props$featureFlags11, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22, _props$featureFlags23, _props$featureFlags24, _props$featureFlags25, _props$featureFlags26, _props$featureFlags27, _props$featureFlags28, _props$featureFlags29, _props$featureFlags30, _props$featureFlags31, _props$featureFlags32, _props$featureFlags33, _props$collabEdit, _props$collabEdit2, _props$featureFlags34, _props$featureFlags35, _props$featureFlags36, _props$featureFlags37;
15
+ var _props$allowTextColor, _props$allowLayouts, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$allowTables, _props$featureFlags3, _props$featureFlags4, _props$allowTables2, _props$featureFlags5, _props$featureFlags6, _props$allowTables3, _props$featureFlags7, _props$featureFlags8, _props$allowTables4, _props$featureFlags9, _props$featureFlags10, _props$allowTables5, _props$allowExtension, _props$featureFlags11, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22, _props$featureFlags23, _props$featureFlags24, _props$featureFlags25, _props$featureFlags26, _props$featureFlags27, _props$featureFlags28, _props$featureFlags29, _props$featureFlags30, _props$featureFlags31, _props$featureFlags32, _props$featureFlags33, _props$collabEdit, _props$collabEdit2, _props$featureFlags34, _props$featureFlags35, _props$featureFlags36, _props$featureFlags37, _props$featureFlags38, _props$featureFlags39, _props$featureFlags40, _props$featureFlags41;
16
16
 
17
17
  const normalizedFeatureFlags = normalizeFeatureFlags(props.featureFlags);
18
18
  return { ...normalizedFeatureFlags,
@@ -50,6 +50,8 @@ export function createFeatureFlagsFromProps(props) {
50
50
  useNativeCollabPlugin: Boolean(typeof ((_props$collabEdit = props.collabEdit) === null || _props$collabEdit === void 0 ? void 0 : _props$collabEdit.useNativePlugin) === 'boolean' ? !!((_props$collabEdit2 = props.collabEdit) !== null && _props$collabEdit2 !== void 0 && _props$collabEdit2.useNativePlugin) : false),
51
51
  chromeCursorHandlerFixedVersion: typeof ((_props$featureFlags34 = props.featureFlags) === null || _props$featureFlags34 === void 0 ? void 0 : _props$featureFlags34.chromeCursorHandlerFixedVersion) === 'string' ? Number(props.featureFlags.chromeCursorHandlerFixedVersion) || undefined : undefined,
52
52
  viewChangingExperimentToolbarStyle: typeof ((_props$featureFlags35 = props.featureFlags) === null || _props$featureFlags35 === void 0 ? void 0 : _props$featureFlags35['view-changing-experiment-toolbar-style']) === 'string' ? props.featureFlags['view-changing-experiment-toolbar-style'] || undefined : undefined,
53
- showHoverPreview: Boolean(typeof ((_props$featureFlags36 = props.featureFlags) === null || _props$featureFlags36 === void 0 ? void 0 : _props$featureFlags36.showHoverPreview) === 'boolean' ? !!((_props$featureFlags37 = props.featureFlags) !== null && _props$featureFlags37 !== void 0 && _props$featureFlags37.showHoverPreview) : false)
53
+ showHoverPreview: Boolean(typeof ((_props$featureFlags36 = props.featureFlags) === null || _props$featureFlags36 === void 0 ? void 0 : _props$featureFlags36.showHoverPreview) === 'boolean' ? !!((_props$featureFlags37 = props.featureFlags) !== null && _props$featureFlags37 !== void 0 && _props$featureFlags37.showHoverPreview) : false),
54
+ indentationButtonsInTheToolbar: Boolean(typeof ((_props$featureFlags38 = props.featureFlags) === null || _props$featureFlags38 === void 0 ? void 0 : _props$featureFlags38['indentation-buttons-in-the-toolbar']) === 'boolean' ? !!((_props$featureFlags39 = props.featureFlags) !== null && _props$featureFlags39 !== void 0 && _props$featureFlags39['indentation-buttons-in-the-toolbar']) : false),
55
+ floatingToolbarCopyButton: Boolean(typeof ((_props$featureFlags40 = props.featureFlags) === null || _props$featureFlags40 === void 0 ? void 0 : _props$featureFlags40.floatingToolbarCopyButton) === 'boolean' ? !!((_props$featureFlags41 = props.featureFlags) !== null && _props$featureFlags41 !== void 0 && _props$featureFlags41.floatingToolbarCopyButton) : false)
54
56
  };
55
57
  }
@@ -0,0 +1,14 @@
1
+ // Common Translations will live here
2
+ import { defineMessages } from 'react-intl-next';
3
+ export const messages = defineMessages({
4
+ indent: {
5
+ id: 'fabric.editor.indent',
6
+ defaultMessage: 'Indent',
7
+ description: 'Indent a list item, paragraph or heading'
8
+ },
9
+ outdent: {
10
+ id: 'fabric.editor.outdent',
11
+ defaultMessage: 'Outdent',
12
+ description: 'Outdent a list item, paragraph or heading'
13
+ }
14
+ });
@@ -15,6 +15,7 @@ export { default as insertBlockPlugin } from './insert-block';
15
15
  export { default as jiraIssuePlugin } from './jira-issue';
16
16
  export { default as layoutPlugin } from './layout';
17
17
  export { default as listPlugin } from './list';
18
+ export { default as toolbarListsIndentationPlugin } from './toolbar-lists-indentation';
18
19
  export { default as macroPlugin } from './macro';
19
20
  export { default as maxContentSizePlugin } from './max-content-size';
20
21
  export { default as mediaPlugin } from './media';
@@ -63,4 +64,5 @@ export { default as undoRedoPlugin } from './undo-redo';
63
64
  export { default as avatarGroupPlugin } from './avatar-group';
64
65
  export { default as viewUpdateSubscriptionPlugin } from './view-update-subscription';
65
66
  export { default as beforePrimaryToolbarPlugin } from './before-primaryToolbar';
66
- export { default as codeBidiWarningPlugin } from './code-bidi-warning';
67
+ export { default as codeBidiWarningPlugin } from './code-bidi-warning';
68
+ export { default as copyButtonPlugin } from './copy-button';
@@ -1,15 +1,12 @@
1
1
  import React from 'react';
2
2
  import { orderedList, bulletList, listItem } from '@atlaskit/adf-schema';
3
- import ToolbarLists from './ui/ToolbarLists';
4
- import { createPlugin, pluginKey } from './pm-plugins/main';
3
+ import { createPlugin } from './pm-plugins/main';
5
4
  import inputRulePlugin from './pm-plugins/input-rules';
6
5
  import keymapPlugin from './pm-plugins/keymap';
7
- import WithPluginState from '../../ui/WithPluginState';
8
6
  import { messages } from './messages';
9
7
  import { addAnalytics, ACTION, EVENT_TYPE, INPUT_METHOD, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
10
8
  import { tooltip, toggleBulletList, toggleOrderedList } from '../../keymaps';
11
9
  import { IconList, IconListNumber } from '../quick-insert/assets';
12
- import { ToolbarSize } from '../../ui/Toolbar/types';
13
10
 
14
11
  const listPlugin = () => ({
15
12
  name: 'list',
@@ -93,47 +90,7 @@ const listPlugin = () => ({
93
90
  }
94
91
 
95
92
  }]
96
- },
97
-
98
- primaryToolbarComponent({
99
- editorView,
100
- popupsMountPoint,
101
- popupsBoundariesElement,
102
- popupsScrollableElement,
103
- toolbarSize,
104
- disabled,
105
- isToolbarReducedSpacing
106
- }) {
107
- const isSmall = toolbarSize < ToolbarSize.L;
108
- return /*#__PURE__*/React.createElement(WithPluginState, {
109
- plugins: {
110
- listState: pluginKey
111
- },
112
- render: ({
113
- listState: listState
114
- }) => {
115
- if (!listState) {
116
- return null;
117
- }
118
-
119
- return /*#__PURE__*/React.createElement(ToolbarLists, {
120
- isSmall: isSmall,
121
- isSeparator: true,
122
- isReducedSpacing: isToolbarReducedSpacing,
123
- disabled: disabled,
124
- editorView: editorView,
125
- popupsMountPoint: popupsMountPoint,
126
- popupsBoundariesElement: popupsBoundariesElement,
127
- popupsScrollableElement: popupsScrollableElement,
128
- bulletListActive: listState.bulletListActive,
129
- bulletListDisabled: listState.bulletListDisabled,
130
- orderedListActive: listState.orderedListActive,
131
- orderedListDisabled: listState.orderedListDisabled
132
- });
133
- }
134
- });
135
93
  }
136
-
137
94
  });
138
95
 
139
96
  export default listPlugin;
@@ -16,6 +16,7 @@ import { DEFAULT_BORDER_COLOR } from '../../ui/ColorPalette/Palettes';
16
16
  import { PanelType } from '@atlaskit/adf-schema';
17
17
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, withAnalytics } from '../analytics';
18
18
  import { messages } from './message';
19
+ import { getCopyButtonConfig, showCopyButton } from '../copy-button/utils';
19
20
  export const panelIconMap = {
20
21
  [PanelType.INFO]: {
21
22
  shortName: ':info:',
@@ -42,7 +43,7 @@ export const panelIconMap = {
42
43
  id: 'atlassian-tip'
43
44
  }
44
45
  };
45
- export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, activePanelType, activePanelColor, activePanelIcon) => {
46
+ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, activePanelType, activePanelColor, activePanelIcon, state) => {
46
47
  // TODO: ED-14403 investigate why these titles are not getting translated for the tooltips
47
48
  const items = [{
48
49
  id: 'editor.panel.info',
@@ -231,6 +232,12 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
231
232
  }
232
233
  }
233
234
 
235
+ if (state && showCopyButton(state)) {
236
+ items.push({
237
+ type: 'separator'
238
+ }, getCopyButtonConfig(state, formatMessage, panelNodeType));
239
+ }
240
+
234
241
  items.push({
235
242
  type: 'separator'
236
243
  }, {
@@ -267,7 +274,7 @@ export const getToolbarConfig = (state, intl, options = {}, providerFactory) =>
267
274
  }; // force toolbar to be turned on
268
275
 
269
276
 
270
- const items = getToolbarItems(formatMessage, nodeType, options.allowCustomPanel || false, options.allowCustomPanel && options.allowCustomPanelEdit || false, providerFactory, panelType, options.allowCustomPanel ? panelColor : undefined, options.allowCustomPanel ? panelIcon || isStandardPanel(panelType) : undefined);
277
+ const items = getToolbarItems(formatMessage, nodeType, options.allowCustomPanel || false, options.allowCustomPanel && options.allowCustomPanelEdit || false, providerFactory, panelType, options.allowCustomPanel ? panelColor : undefined, options.allowCustomPanel ? panelIcon || isStandardPanel(panelType) : undefined, state);
271
278
 
272
279
  const getDomRef = editorView => {
273
280
  const domAtPos = editorView.domAtPos.bind(editorView);
@@ -2,16 +2,15 @@ import Fuse from 'fuse.js';
2
2
  import { dedupe } from '../../utils';
3
3
  const options = {
4
4
  threshold: 0.3,
5
- keys: [// Weights must sum to <= 1.0
6
- {
5
+ keys: [{
7
6
  name: 'title',
8
- weight: 0.5
7
+ weight: 0.57
9
8
  }, {
10
9
  name: 'priority',
11
10
  weight: 0.3
12
11
  }, {
13
12
  name: 'keywords',
14
- weight: 0.15
13
+ weight: 0.08
15
14
  }, {
16
15
  name: 'description',
17
16
  weight: 0.04
@@ -70,7 +70,7 @@ export const hoverRows = (hoveredRows, isInDanger) => createCommand(state => {
70
70
  }
71
71
  };
72
72
  }, tr => tr.setMeta('addToHistory', false));
73
- export const hoverTable = isInDanger => createCommand(state => {
73
+ export const hoverTable = (isInDanger, isSelected) => createCommand(state => {
74
74
  const table = findTable(state.selection);
75
75
 
76
76
  if (!table) {
@@ -86,7 +86,7 @@ export const hoverTable = isInDanger => createCommand(state => {
86
86
  return false;
87
87
  }
88
88
 
89
- const decorations = createControlsHoverDecoration(cells, 'table', isInDanger);
89
+ const decorations = createControlsHoverDecoration(cells, 'table', isInDanger, isSelected);
90
90
  return {
91
91
  type: 'HOVER_TABLE',
92
92
  data: {
@@ -14,7 +14,8 @@ import { splitCell } from '@atlaskit/editor-tables/utils';
14
14
  import tableMessages from './ui/messages';
15
15
  import { messages as ContextualMenuMessages } from './ui/FloatingContextualMenu/ContextualMenu';
16
16
  import { findParentDomRefOfType } from 'prosemirror-utils';
17
- import { closestElement } from '../../utils/dom'; // TODO: ED-14403 investigate why these translations don't work
17
+ import { closestElement } from '../../utils/dom';
18
+ import { getCopyButtonConfig, showCopyButton } from '../copy-button/utils'; // TODO: ED-14403 investigate why these translations don't work
18
19
 
19
20
  export const messages = defineMessages({
20
21
  tableOptions: {
@@ -244,7 +245,9 @@ export const getToolbarConfig = config => (state, intl) => {
244
245
  items: [menu, separator(menu.hidden), ...cellItems, {
245
246
  type: 'extensions-placeholder',
246
247
  separator: 'end'
247
- }, {
248
+ }, ...(state && showCopyButton(state) ? [getCopyButtonConfig(state, intl.formatMessage, nodeType, hoverTable(false, true), clearHoverSelection()), {
249
+ type: 'separator'
250
+ }] : []), {
248
251
  id: 'editor.table.delete',
249
252
  type: 'button',
250
253
  appearance: 'danger',
@@ -13,13 +13,17 @@ export const createCellHoverDecoration = (cells, type) => cells.map(cell => Deco
13
13
  }, {
14
14
  key: TableDecorations.CELL_CONTROLS_HOVER
15
15
  }));
16
- export const createControlsHoverDecoration = (cells, type, danger) => cells.map(cell => {
16
+ export const createControlsHoverDecoration = (cells, type, danger, selected) => cells.map(cell => {
17
17
  const classes = [ClassName.HOVERED_CELL];
18
18
 
19
19
  if (danger) {
20
20
  classes.push(ClassName.HOVERED_CELL_IN_DANGER);
21
21
  }
22
22
 
23
+ if (selected) {
24
+ classes.push(ClassName.SELECTED_CELL);
25
+ }
26
+
23
27
  classes.push(type === 'column' ? ClassName.HOVERED_COLUMN : type === 'row' ? ClassName.HOVERED_ROW : ClassName.HOVERED_TABLE);
24
28
  let key;
25
29