@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
@@ -3,12 +3,10 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  /** @jsx jsx */
4
4
  import React, { Fragment, memo, useCallback, useEffect, useMemo } from 'react';
5
5
  import { css, jsx } from '@emotion/react';
6
- import memoizeOne from 'memoize-one';
7
6
  import { AutoSizer } from 'react-virtualized/dist/commonjs/AutoSizer';
8
7
  import { Collection } from 'react-virtualized/dist/commonjs/Collection';
9
- // eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
10
- import Item from '@atlaskit/item';
11
- import { B100, N20, N200 } from '@atlaskit/theme/colors';
8
+ import { ButtonItem } from '@atlaskit/menu';
9
+ import { B100, N200 } from '@atlaskit/theme/colors';
12
10
  import Tooltip from '@atlaskit/tooltip';
13
11
  import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
14
12
  import { token } from '@atlaskit/tokens';
@@ -17,7 +15,7 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '../../..
17
15
  import IconFallback from '../../../../plugins/quick-insert/assets/fallback';
18
16
  import { itemIcon } from '../../../../plugins/type-ahead/ui/TypeAheadListItem';
19
17
  import { shortcutStyle } from '../../../styles';
20
- import { ELEMENT_ITEM_HEIGHT, ELEMENT_LIST_PADDING, GRID_SIZE, SCROLLBAR_THUMB_COLOR, SCROLLBAR_TRACK_COLOR, SCROLLBAR_WIDTH } from '../../constants';
18
+ import { ELEMENT_LIST_PADDING, SCROLLBAR_THUMB_COLOR, SCROLLBAR_TRACK_COLOR, SCROLLBAR_WIDTH } from '../../constants';
21
19
  import useContainerWidth from '../../hooks/use-container-width';
22
20
  import useFocus from '../../hooks/use-focus';
23
21
  import { Modes } from '../../types';
@@ -114,44 +112,9 @@ function ElementList({
114
112
  })))));
115
113
  }
116
114
 
117
- const getStyles = memoizeOne(mode => {
118
- return { ...(mode === Modes.full && {
119
- '-ms-flex': 'auto',
120
- position: 'relative',
121
- boxSizing: 'border-box'
122
- }),
123
- height: {
124
- default: ELEMENT_ITEM_HEIGHT
125
- },
126
- padding: {
127
- default: {
128
- top: GRID_SIZE * 1.5,
129
- right: GRID_SIZE * 1.5,
130
- bottom: GRID_SIZE * 1.5,
131
- left: GRID_SIZE * 1.5
132
- }
133
- },
134
- borderRadius: GRID_SIZE / 2,
135
- // TODO: apply a different background for when a selected item is hovered.
136
- // Not possible due to current implementation of @atlaskit/item component.
137
- selected: {
138
- background: token('color.background.selected', N20)
139
- },
140
- hover: {
141
- background: token('color.background.neutral.subtle.hovered', 'rgb(244, 245, 247)')
142
- },
143
- active: {
144
- background: token('color.background.neutral.subtle.pressed', 'rgb(244, 245, 247)')
145
- },
146
- beforeItemSpacing: {
147
- default: GRID_SIZE * 1.5
148
- }
149
- };
150
- });
151
115
  const MemoizedElementItem = /*#__PURE__*/memo(ElementItem);
152
116
  MemoizedElementItem.displayName = 'MemoizedElementItem';
153
-
154
- function ElementItem({
117
+ export function ElementItem({
155
118
  inlineMode,
156
119
  selected,
157
120
  item,
@@ -161,9 +124,6 @@ function ElementItem({
161
124
  setFocusedItemIndex
162
125
  }) {
163
126
  const ref = useFocus(focus);
164
- const theme = useMemo(() => ({
165
- '@atlaskit-shared-theme/item': getStyles(inlineMode ? 'inline' : 'full')
166
- }), [inlineMode]);
167
127
  /**
168
128
  * Note: props.onSelectItem(item) is not called here as the StatelessElementBrowser's
169
129
  * useEffect would trigger it on selectedItemIndex change. (Line 106-110)
@@ -175,33 +135,29 @@ function ElementItem({
175
135
  e.stopPropagation();
176
136
  setFocusedItemIndex(index);
177
137
 
178
- if (inlineMode) {
179
- onInsertItem(item);
180
- }
181
- }, [index, inlineMode, item, onInsertItem, setFocusedItemIndex]);
182
- const onDoubleClick = useCallback(e => {
183
- if (inlineMode) {
184
- return;
185
- }
138
+ switch (e.nativeEvent.detail) {
139
+ case 0:
140
+ onInsertItem(item);
141
+ break;
186
142
 
187
- e.preventDefault();
188
- e.stopPropagation();
189
- setFocusedItemIndex(index);
190
- onInsertItem(item);
191
- }, [inlineMode, setFocusedItemIndex, index, onInsertItem, item]); // After tabbing we wanna select the item on enter/space key press from item level,
192
- // preventing the default top level component behavior.
143
+ case 1:
144
+ if (inlineMode) {
145
+ onInsertItem(item);
146
+ }
147
+
148
+ break;
193
149
 
194
- const onKeyPress = useCallback(e => {
195
- const SPACE_KEY = 32;
196
- const ENTER_KEY = 13;
150
+ case 2:
151
+ if (!inlineMode) {
152
+ onInsertItem(item);
153
+ }
197
154
 
198
- if (e.which === ENTER_KEY || e.which === SPACE_KEY) {
199
- e.preventDefault();
200
- e.stopPropagation();
201
- setFocusedItemIndex(index);
202
- onInsertItem(item);
155
+ break;
156
+
157
+ default:
158
+ return;
203
159
  }
204
- }, [index, item, onInsertItem, setFocusedItemIndex]);
160
+ }, [index, inlineMode, item, onInsertItem, setFocusedItemIndex]);
205
161
  const {
206
162
  icon,
207
163
  title,
@@ -211,35 +167,28 @@ function ElementItem({
211
167
  return jsx(Tooltip, {
212
168
  content: description,
213
169
  testId: `element-item-tooltip-${index}`
214
- }, jsx(Item, {
170
+ }, jsx(ButtonItem, {
215
171
  onClick: onClick,
216
- onDoubleClick: onDoubleClick,
217
- elemBefore: jsx(ElementBefore, {
172
+ iconBefore: jsx(ElementBefore, {
218
173
  icon: icon,
219
174
  title: title
220
175
  }),
221
176
  isSelected: selected,
222
177
  "aria-describedby": title,
223
- innerRef: ref,
224
- onKeyPress: onKeyPress,
225
- "data-testid": `element-item-${index}`,
226
- tabIndex: 0,
227
- style: inlineMode ? null : itemStyleOverrides,
228
- theme: theme
178
+ ref: ref,
179
+ testId: `element-item-${index}`
229
180
  }, jsx(ItemContent, {
181
+ style: inlineMode ? null : itemStyleOverrides,
182
+ tabIndex: 0,
230
183
  title: title,
231
184
  description: description,
232
185
  keyshortcut: keyshortcut
233
186
  })));
234
187
  }
235
188
  /**
236
- * Some properties (specified in 'BaseItem' packages/design-system/item/src/styled/Item.js) cannot be changed with
237
- * ThemeProvider as they are of higher specificity.
238
- *
239
189
  * Inline mode should use the existing Align-items:center value.
240
190
  */
241
191
 
242
-
243
192
  const itemStyleOverrides = {
244
193
  alignItems: 'flex-start'
245
194
  };
@@ -308,21 +257,13 @@ const elementItemsWrapper = css`
308
257
  padding-bottom: 4px;
309
258
  }
310
259
  }
311
-
312
- // temporary solution before we migrated off dst/item
313
- & span[class^='ItemParts__Before'] {
314
- margin-right: 12px;
315
- }
316
260
  `;
317
261
  const elementItemWrapper = css`
318
- /**
319
- * Since we are using "Item" component's content itself for description,
320
- * the height of description overflows the parent container padding/margin.
321
- * manually setting it to take 100% of parent.
322
- */
323
- span {
324
- span:nth-of-type(2) {
325
- max-height: 100%;
262
+ div {
263
+ button {
264
+ height: 75px;
265
+ align-items: flex-start;
266
+ padding: 12px 12px 11px;
326
267
  }
327
268
  }
328
269
  `;
@@ -1,3 +1,4 @@
1
+ import * as clipboard from 'clipboard-polyfill';
1
2
  export function checkClipboardTypes(type, item) {
2
3
  const isDOMStringList = t => !t.indexOf && !!t.contains;
3
4
 
@@ -35,4 +36,29 @@ export const copyToClipboard = async textToCopy => {
35
36
  } else {
36
37
  throw new Error('Clipboard api is not supported');
37
38
  }
39
+ };
40
+ export const copyHTMLToClipboard = async htmlToCopy => {
41
+ // @ts-ignore
42
+ if (isClipboardApiSupported() && typeof ClipboardItem !== 'undefined') {
43
+ try {
44
+ const blobInput = new Blob([htmlToCopy], {
45
+ type: 'text/html'
46
+ }); // @ts-ignore
47
+
48
+ const data = [new ClipboardItem({
49
+ 'text/html': blobInput
50
+ })]; // @ts-ignore
51
+
52
+ navigator.clipboard.write(data);
53
+ } catch (error) {
54
+ throw new Error('Clipboard api is not supported');
55
+ }
56
+ } else {
57
+ // At the time of development, Firefox doesn't support ClipboardItem API
58
+ // Hence of use of this polyfill
59
+ const Clipboard = clipboard;
60
+ const dt = new Clipboard.DT();
61
+ dt.setData('text/html', htmlToCopy);
62
+ Clipboard.write(dt);
63
+ }
38
64
  };
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "169.0.0";
2
+ export const version = "170.0.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "169.0.0",
3
+ "version": "170.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -5,7 +5,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
5
5
 
6
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
7
 
8
- import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, emojiPlugin, extensionPlugin, fragmentMarkPlugin, helpDialogPlugin, imageUploadPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, listPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, rulePlugin, saveOnEnterPlugin, tablesPlugin, tasksAndDecisionsPlugin, textColorPlugin, cardPlugin, gridPlugin, statusPlugin, alignmentPlugin, indentationPlugin, analyticsPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, contextPanelPlugin, mobileSelectionPlugin, annotationPlugin, captionPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../plugins';
8
+ import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, emojiPlugin, extensionPlugin, fragmentMarkPlugin, helpDialogPlugin, imageUploadPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, listPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, rulePlugin, saveOnEnterPlugin, tablesPlugin, tasksAndDecisionsPlugin, textColorPlugin, cardPlugin, gridPlugin, statusPlugin, alignmentPlugin, indentationPlugin, analyticsPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, contextPanelPlugin, mobileSelectionPlugin, annotationPlugin, captionPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin, copyButtonPlugin } from '../plugins';
9
9
  import { isFullPage as fullPageCheck } from '../utils/is-full-page';
10
10
  import { GUTTER_SIZE_MOBILE_IN_PX } from '../plugins/base/pm-plugins/scroll-gutter';
11
11
  import { createFeatureFlagsFromProps } from '../plugins/feature-flags-context/feature-flags-from-props';
@@ -363,6 +363,9 @@ export default function createPluginsList(props, prevProps, createAnalyticsEvent
363
363
  } // UI only plugins
364
364
 
365
365
 
366
+ preset.add([toolbarListsIndentationPlugin, {
367
+ showIndentationButtons: !!featureFlags.indentationButtonsInTheToolbar
368
+ }]);
366
369
  preset.add([insertBlockPlugin, {
367
370
  allowTables: !!props.allowTables,
368
371
  allowExpand: isExpandInsertionEnabled(props),
@@ -415,6 +418,10 @@ export default function createPluginsList(props, prevProps, createAnalyticsEvent
415
418
  }]);
416
419
  }
417
420
 
421
+ if (featureFlags.floatingToolbarCopyButton) {
422
+ preset.add(copyButtonPlugin);
423
+ }
424
+
418
425
  var excludes = new Set();
419
426
 
420
427
  if (!isCodeBlockAllowed({
@@ -14,4 +14,6 @@ export var TOOLBAR_ACTION_SUBJECT_ID;
14
14
  TOOLBAR_ACTION_SUBJECT_ID["TEXT_FORMATTING_ITALIC"] = "italic";
15
15
  TOOLBAR_ACTION_SUBJECT_ID["UNDO"] = "undo";
16
16
  TOOLBAR_ACTION_SUBJECT_ID["REDO"] = "redo";
17
+ TOOLBAR_ACTION_SUBJECT_ID["INDENT"] = "indent";
18
+ TOOLBAR_ACTION_SUBJECT_ID["OUTDENT"] = "outdent";
17
19
  })(TOOLBAR_ACTION_SUBJECT_ID || (TOOLBAR_ACTION_SUBJECT_ID = {}));
@@ -25,6 +25,13 @@ var BreakoutView = /*#__PURE__*/function () {
25
25
  _classCallCheck(this, BreakoutView);
26
26
 
27
27
  _defineProperty(this, "updateWidth", function (widthState) {
28
+ // we skip updating the width of breakout nodes if the editorView dom
29
+ // element was hidden (to avoid breakout width and button thrashing
30
+ // when an editor is hidden, re-rendered and unhidden).
31
+ if (widthState.width === 0) {
32
+ return;
33
+ }
34
+
28
35
  var width = calcBreakoutWidth(_this.node.attrs.mode, widthState.width);
29
36
  var newStyle = "width: ".concat(width, "; ");
30
37
  var lineLength = widthState.lineLength;
@@ -147,7 +147,9 @@ var LayoutButton = /*#__PURE__*/function (_React$Component) {
147
147
  boundariesElement: boundariesElement,
148
148
  scrollableElement: scrollableElement,
149
149
  stick: true,
150
- forcePlacement: true
150
+ forcePlacement: true,
151
+ scheduleExtraLayoutUpdates: true,
152
+ waitForExtraLayoutUpdates: true
151
153
  }, jsx("div", {
152
154
  css: toolbarButtonWrapper
153
155
  }, jsx(ToolbarButton, {
@@ -6,7 +6,12 @@ import { replaceQueuedUrlWithCard, handleFallbackWithAnalytics } from '../doc';
6
6
  // Used for all interactions with the EditorCardProvider.
7
7
  // ============================================================================ //
8
8
  export var resolveWithProvider = function resolveWithProvider(view, outstandingRequests, provider, request, options) {
9
- var handleResolve = provider.resolve(request.url, request.appearance).then(function (resolvedCard) {
9
+ // When user manually changes appearance from blue link to smart link, we should respect that,
10
+ var shouldForceAppearance = // This flag is set to true only in one place atm:
11
+ // packages/editor/editor-core/src/plugins/card/pm-plugins/doc.ts @ convertHyperlinkToSmartCard
12
+ // Which is used when user switching from URL to smart link appearance.
13
+ !!request.shouldReplaceLink;
14
+ var handleResolve = provider.resolve(request.url, request.appearance, shouldForceAppearance).then(function (resolvedCard) {
10
15
  delete outstandingRequests[request.url];
11
16
  return resolvedCard;
12
17
  }).then(handleResolved(view, request, options), handleRejected(view, request));
@@ -8,4 +8,5 @@ import { N20 } from '@atlaskit/theme/colors';
8
8
  import { SmartCardSharedCssClassName } from '@atlaskit/editor-common/styles';
9
9
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
10
10
  import { token } from '@atlaskit/tokens';
11
- export var smartCardStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n max-width: calc(100% - 20px);\n vertical-align: top;\n word-break: break-all;\n\n .card {\n padding-left: 2px;\n padding-right: 2px;\n padding-top: 0.5em;\n padding-bottom: 0.5em;\n margin-bottom: -0.5em;\n\n .", " > a:focus {\n ", "\n }\n }\n\n &.", "\n .", "\n > a {\n ", "\n }\n .", " > a {\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 1;\n position: relative;\n /* EDM-1717: box-shadow Safari fix end */\n }\n\n &.danger {\n .", " > a {\n box-shadow: 0 0 0 1px\n ", ";\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 2;\n /* EDM-1717: box-shadow Safari fix end */\n }\n }\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &:hover {\n background-color: ", ";\n }\n }\n\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.danger {\n .", " > div {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n }\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &::after {\n transition: box-shadow 0s;\n }\n }\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.", "\n .", "\n > div::after {\n ", "\n }\n\n &.danger {\n .media-card-frame::after {\n box-shadow: 0 0 0 1px\n ", " !important;\n background: ", " !important;\n }\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n }\n }\n"])), SmartCardSharedCssClassName.INLINE_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), SmartCardSharedCssClassName.LOADER_WRAPPER, SmartCardSharedCssClassName.LOADER_WRAPPER, token('color.border.danger', akEditorDeleteBorder), SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, token('color.background.neutral.subtle.hovered', N20), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), SmartCardSharedCssClassName.LOADER_WRAPPER, token('color.border.danger', akEditorDeleteBorder), SmartCardSharedCssClassName.EMBED_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), token('color.border.danger', akEditorDeleteBorder), token('color.background.danger', akEditorDeleteBackground), token('color.border.danger', akEditorDeleteBorder));
11
+ export var FLOATING_TOOLBAR_LINKPICKER_CLASSNAME = 'card-floating-toolbar--link-picker';
12
+ export var smartCardStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n max-width: calc(100% - 20px);\n vertical-align: top;\n word-break: break-all;\n\n .card {\n padding-left: 2px;\n padding-right: 2px;\n padding-top: 0.5em;\n padding-bottom: 0.5em;\n margin-bottom: -0.5em;\n\n .", " > a:focus {\n ", "\n }\n }\n\n &.", "\n .", "\n > a {\n ", "\n }\n .", " > a {\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 1;\n position: relative;\n /* EDM-1717: box-shadow Safari fix end */\n }\n\n &.danger {\n .", " > a {\n box-shadow: 0 0 0 1px\n ", ";\n /* EDM-1717: box-shadow Safari fix start */\n z-index: 2;\n /* EDM-1717: box-shadow Safari fix end */\n }\n }\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &:hover {\n background-color: ", ";\n }\n }\n\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.danger {\n .", " > div {\n box-shadow: 0 0 0 1px\n ", " !important;\n }\n }\n }\n\n .", " {\n .", " > div {\n cursor: pointer;\n &::after {\n transition: box-shadow 0s;\n }\n }\n &.", "\n .", "\n > div {\n ", "\n }\n\n &.", "\n .", "\n > div::after {\n ", "\n }\n\n &.danger {\n .media-card-frame::after {\n box-shadow: 0 0 0 1px\n ", " !important;\n background: ", " !important;\n }\n .richMedia-resize-handle-right::after,\n .richMedia-resize-handle-left::after {\n background: ", ";\n }\n }\n }\n\n .", " {\n padding: 0;\n }\n"])), SmartCardSharedCssClassName.INLINE_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), SmartCardSharedCssClassName.LOADER_WRAPPER, SmartCardSharedCssClassName.LOADER_WRAPPER, token('color.border.danger', akEditorDeleteBorder), SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, token('color.background.neutral.subtle.hovered', N20), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), SmartCardSharedCssClassName.LOADER_WRAPPER, token('color.border.danger', akEditorDeleteBorder), SmartCardSharedCssClassName.EMBED_CARD_CONTAINER, SmartCardSharedCssClassName.LOADER_WRAPPER, akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), akEditorSelectedNodeClassName, SmartCardSharedCssClassName.LOADER_WRAPPER, getSelectionStyles([SelectionStyle.BoxShadow]), token('color.border.danger', akEditorDeleteBorder), token('color.background.danger', akEditorDeleteBackground), token('color.border.danger', akEditorDeleteBorder), FLOATING_TOOLBAR_LINKPICKER_CLASSNAME);
@@ -25,6 +25,7 @@ import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
25
25
  import { messages } from './messages';
26
26
  import buildLayoutButtons from '../../ui/MediaAndEmbedsToolbar';
27
27
  import { buildVisitedLinkPayload } from '../../utils/linking-utils';
28
+ import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME } from './styles';
28
29
  export var removeCard = function removeCard(state, dispatch) {
29
30
  if (!(state.selection instanceof NodeSelection)) {
30
31
  return false;
@@ -234,9 +235,12 @@ export var floatingToolbar = function floatingToolbar(cardOptions, platform) {
234
235
 
235
236
  var toolbarOffset = isEmbedCard ? {
236
237
  offset: [0, 24]
237
- } : {};
238
+ } : {}; // Applies padding override for when link picker is currently displayed
239
+
240
+ var className = pluginState.showLinkingToolbar ? FLOATING_TOOLBAR_LINKPICKER_CLASSNAME : undefined;
238
241
  return _objectSpread(_objectSpread({
239
242
  title: intl.formatMessage(messages.card),
243
+ className: className,
240
244
  nodeType: nodeType
241
245
  }, toolbarOffset), {}, {
242
246
  getDomRef: function getDomRef(view) {
@@ -5,56 +5,37 @@ var _templateObject, _templateObject2;
5
5
  import { css } from '@emotion/react';
6
6
  import { themed } from '@atlaskit/theme/components';
7
7
  import { borderRadius, fontSize, gridSize } from '@atlaskit/theme/constants';
8
- import * as colors from '@atlaskit/theme/colors';
8
+ import { R75, N20, DN50, N30, DN20, N90, DN90, N400, DN400, N800, DN500 } from '@atlaskit/theme/colors';
9
9
  import { blockNodesVerticalMargin, akEditorTableCellMinWidth, akEditorDeleteBackground, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorDeleteIconColor, SelectionStyle, getSelectionStyles, akEditorCodeFontFamily, akEditorSelectedNodeClassName, overflowShadow, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
10
10
  import { token } from '@atlaskit/tokens';
11
11
  import { codeBlockClassNames } from './ui/class-names';
12
+ import { codeBlockSharedStyles } from '@atlaskit/editor-common/styles';
12
13
  export var highlightingCodeBlockStyles = function highlightingCodeBlockStyles(props) {
13
14
  return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror .code-block {\n position: relative;\n background-image: ", ";\n background-repeat: no-repeat;\n background-color: ", ";\n\n --ds--code--bg-color: transparent;\n\n background-attachment: local, scroll, scroll;\n background-size: 8px 100%, 8px 100%, 8px 100%;\n background-position: 100% 0, 100% 0, 0 0;\n font-family: ", ";\n border-radius: ", "px;\n margin: ", " 0 0 0;\n counter-reset: line;\n display: flex;\n min-width: ", "px;\n cursor: pointer;\n overflow-x: auto;\n\n .", " {\n /* 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 */\n flex-shrink: 0;\n text-align: right;\n background-color: ", ";\n padding: ", "px;\n color: ", ";\n\n span {\n display: block;\n line-height: 0;\n font-size: 0;\n\n &::before {\n display: inline-block;\n content: counter(line);\n counter-increment: line;\n font-size: ", ";\n line-height: 1.5rem;\n color: ", ";\n }\n }\n }\n\n .", " {\n position: absolute;\n z-index: 2;\n width: 100%;\n height: 100%;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n pointer-events: none;\n overflow: hidden;\n tab-size: 4;\n\n & [data-ds--code--code-block] {\n font-size: ", ";\n line-height: 1.5rem;\n }\n }\n\n .", " {\n position: relative;\n z-index: 1;\n display: flex;\n flex: 1;\n\n > code {\n flex-grow: 1;\n tab-size: 4;\n cursor: text;\n /* https://bitbucket.org/atlassian/atlassian-frontend/src/218202daeaf527262c21841e6f88fa058d349ad4/packages/design-system/code/src/themes/themeBuilder.ts#lines-12:17 */\n font-size: ", ";\n line-height: 1.5rem;\n border-radius: ", "px;\n margin: ", "px;\n white-space: pre;\n }\n\n &[data-debounce='true'] {\n .", " {\n display: none;\n }\n }\n\n &:not([data-debounce='true']) {\n > code:not([data-language='plaintext']):not([data-language='none']):not([data-language='']) {\n color: transparent;\n caret-color: ", ";\n }\n }\n }\n }\n\n .ProseMirror li > .code-block {\n margin: 0;\n }\n\n .ProseMirror .code-block.", ":not(.danger) {\n ", "\n }\n\n /* Danger when top level node */\n .ProseMirror .danger.code-block {\n box-shadow: 0 0 0 ", "px\n ", ";\n\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n\n /* Danger when nested node */\n .ProseMirror .danger .code-block {\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n"])), overflowShadow({
14
15
  // TODO: https://product-fabric.atlassian.net/browse/DSP-4118
15
16
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
16
17
  background: themed({
17
- light: colors.N20,
18
- dark: colors.DN50
18
+ light: N20,
19
+ dark: DN50
19
20
  })(props),
20
21
  width: '8px'
21
22
  }), 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), akEditorCodeFontFamily, borderRadius(), blockNodesVerticalMargin, akEditorTableCellMinWidth, codeBlockClassNames.gutter, themed({
25
- light: token('color.background.neutral', colors.N30),
26
- dark: token('color.background.neutral', colors.DN20)
26
+ light: token('color.background.neutral', N30),
27
+ dark: token('color.background.neutral', DN20)
27
28
  })(props), gridSize(), themed({
28
- light: token('color.text.subtlest', colors.N90),
29
- dark: token('color.text.subtlest', colors.DN90)
29
+ light: token('color.text.subtlest', N90),
30
+ dark: token('color.text.subtlest', DN90)
30
31
  })(props), relativeFontSizeToBase16(fontSize()), themed({
31
- light: token('color.text.subtle', colors.N400),
32
- dark: token('color.text.subtle', colors.DN400)
32
+ light: token('color.text.subtle', N400),
33
+ dark: token('color.text.subtle', DN400)
33
34
  })(props), codeBlockClassNames.highlighting, relativeFontSizeToBase16(fontSize()), codeBlockClassNames.content, relativeFontSizeToBase16(fontSize()), borderRadius(), gridSize(), codeBlockClassNames.highlighting, themed({
34
- light: token('color.text', colors.N800),
35
- dark: token('color.text', colors.DN500)
36
- })(props), akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.BoxShadow, SelectionStyle.Blanket]), akEditorSelectedBorderSize, token('color.border.danger', akEditorDeleteBorder), codeBlockClassNames.gutter, token('color.blanket.danger', colors.R75), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', akEditorDeleteBackground), codeBlockClassNames.gutter, token('color.blanket.danger', 'rgba(255, 143, 115, 0.5)'), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', 'rgba(255, 189, 173, 0.5)'));
35
+ light: token('color.text', N800),
36
+ dark: token('color.text', DN500)
37
+ })(props), akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.BoxShadow, SelectionStyle.Blanket]), akEditorSelectedBorderSize, token('color.border.danger', akEditorDeleteBorder), codeBlockClassNames.gutter, token('color.blanket.danger', R75), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', akEditorDeleteBackground), codeBlockClassNames.gutter, token('color.blanket.danger', 'rgba(255, 143, 115, 0.5)'), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', 'rgba(255, 189, 173, 0.5)'));
37
38
  };
38
39
  export var codeBlockStyles = function codeBlockStyles(props) {
39
- return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .ProseMirror .code-block {\n position: relative;\n background-image: ", ";\n\n --ds--code--bg-color: transparent;\n\n background-repeat: no-repeat;\n background-color: ", ";\n background-attachment: local, scroll, scroll;\n background-size: 8px 100%, 8px 100%, 8px 100%;\n background-position: 100% 0, 100% 0, 0 0;\n font-family: ", ";\n border-radius: ", "px;\n margin: ", " 0 0 0;\n counter-reset: line;\n display: flex;\n min-width: ", "px;\n cursor: pointer;\n overflow-x: auto;\n\n .", " {\n /* 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 */\n flex-shrink: 0;\n text-align: right;\n background-color: ", ";\n padding: ", "px;\n\n span {\n display: block;\n line-height: 0;\n font-size: 0;\n\n &::before {\n display: inline-block;\n content: counter(line);\n counter-increment: line;\n font-size: ", ";\n line-height: 1.5rem;\n color: ", ";\n }\n }\n }\n\n .", " {\n display: flex;\n flex: 1;\n\n code {\n flex-grow: 1;\n tab-size: 4;\n cursor: text;\n /* https://bitbucket.org/atlassian/atlassian-frontend/src/218202daeaf527262c21841e6f88fa058d349ad4/packages/design-system/code/src/themes/themeBuilder.ts#lines-12:17 */\n font-size: ", ";\n line-height: 1.5rem;\n color: ", ";\n border-radius: ", "px;\n margin: ", "px;\n white-space: pre;\n }\n }\n }\n\n .ProseMirror li > .code-block {\n margin: 0;\n }\n\n .ProseMirror .code-block.", ":not(.danger) {\n ", "\n }\n\n /* Danger when top level node */\n .ProseMirror .danger.code-block {\n box-shadow: 0 0 0 ", "px ", ";\n\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n\n /* Danger when nested node */\n .ProseMirror .danger .code-block {\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n"])), overflowShadow({
40
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4118
41
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
42
- background: themed({
43
- light: colors.N20,
44
- dark: colors.DN50
45
- })(props),
46
- width: '8px'
47
- }), themed({
48
- light: token('color.background.neutral', colors.N20),
49
- dark: token('color.background.neutral', colors.DN50)
50
- })(props), akEditorCodeFontFamily, borderRadius(), blockNodesVerticalMargin, akEditorTableCellMinWidth, codeBlockClassNames.gutter, themed({
51
- light: token('color.background.neutral', colors.N30),
52
- dark: token('color.background.neutral', colors.DN20)
53
- })(props), gridSize(), relativeFontSizeToBase16(fontSize()), themed({
54
- light: token('color.text', colors.N400),
55
- dark: token('color.text', colors.DN400)
56
- })(props), codeBlockClassNames.content, relativeFontSizeToBase16(fontSize()), themed({
57
- light: token('color.text', colors.N800),
58
- dark: token('color.text', colors.DN800)
59
- })(props), borderRadius(), gridSize(), akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.BoxShadow, SelectionStyle.Blanket]), akEditorSelectedBorderSize, akEditorDeleteBorder, codeBlockClassNames.gutter, token('color.blanket.danger', colors.R75), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', akEditorDeleteBackground), codeBlockClassNames.gutter, token('color.blanket.danger', 'rgba(255, 143, 115, 0.5)'), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', 'rgba(255, 189, 173, 0.5)'));
40
+ return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .ProseMirror {\n ", "\n }\n\n .ProseMirror li > .code-block {\n margin: 0;\n }\n\n .ProseMirror .code-block.", ":not(.danger) {\n ", "\n }\n\n /* Danger when top level node */\n .ProseMirror .danger.code-block {\n box-shadow: 0 0 0 ", "px ", ";\n\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n\n /* Danger when nested node */\n .ProseMirror .danger .code-block {\n .", " {\n background-color: ", ";\n color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n }\n"])), codeBlockSharedStyles(props), akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.BoxShadow, SelectionStyle.Blanket]), akEditorSelectedBorderSize, akEditorDeleteBorder, codeBlockClassNames.gutter, token('color.blanket.danger', R75), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', akEditorDeleteBackground), codeBlockClassNames.gutter, token('color.blanket.danger', 'rgba(255, 143, 115, 0.5)'), token('color.text.danger', akEditorDeleteIconColor), codeBlockClassNames.content, token('color.background.danger', 'rgba(255, 189, 173, 0.5)'));
60
41
  };
@@ -1,5 +1,6 @@
1
+ import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
1
2
  export var 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,66 @@
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 var copy = function copy(nodeType) {
7
+ return function (state, dispatch) {
8
+ var tr = state.tr,
9
+ schema = state.schema; // This command should only be triggered by the Copy button in the floating toolbar
10
+ // which is only visible when selection is inside the target node
11
+
12
+ var node = findSelectedNodeOfType(nodeType)(tr.selection);
13
+
14
+ if (!node) {
15
+ node = findParentNodeOfType(nodeType)(tr.selection);
16
+ }
17
+
18
+ if (!node) {
19
+ return false;
20
+ }
21
+
22
+ var domNode = DOMSerializer.fromSchema(schema).serializeNode(node.node);
23
+ var div = document.createElement('div');
24
+ div.appendChild(domNode); // The "0 0" refers to the start and end depth of the slice
25
+ // since we're coping the block node only, it will always be 0 0
26
+ // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
27
+
28
+ div.firstChild.setAttribute('data-pm-slice', '0 0 []');
29
+ copyHTMLToClipboard(div.innerHTML);
30
+ var copyToClipboardTr = tr;
31
+ copyToClipboardTr.setMeta(pluginKey, {
32
+ copied: true
33
+ });
34
+
35
+ if (dispatch) {
36
+ dispatch(copyToClipboardTr);
37
+ }
38
+
39
+ return true;
40
+ };
41
+ };
42
+ export var resetCopiedState = function resetCopiedState(nodeType, onMouseLeave) {
43
+ return function (state, dispatch) {
44
+ var customTr = state.tr; // Avoid multipe dispatch
45
+ // 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
46
+
47
+ var customDispatch = function customDispatch(tr) {
48
+ customTr = tr;
49
+ };
50
+
51
+ onMouseLeave ? onMouseLeave(state, customDispatch) : hoverDecoration(nodeType, false)(state, customDispatch);
52
+ var copyButtonState = pluginKey.getState(state);
53
+
54
+ if (copyButtonState !== null && copyButtonState !== void 0 && copyButtonState.copied) {
55
+ customTr.setMeta(pluginKey, {
56
+ copied: false
57
+ });
58
+ }
59
+
60
+ if (dispatch) {
61
+ dispatch(customTr);
62
+ }
63
+
64
+ return true;
65
+ };
66
+ };
@@ -0,0 +1,17 @@
1
+ import createPlugin from './pm-plugins/main';
2
+
3
+ var copyButtonPlugin = function copyButtonPlugin() {
4
+ return {
5
+ name: 'copyButton',
6
+ pmPlugins: function pmPlugins() {
7
+ return [{
8
+ name: 'copyButton',
9
+ plugin: function plugin() {
10
+ return createPlugin();
11
+ }
12
+ }];
13
+ }
14
+ };
15
+ };
16
+
17
+ export default copyButtonPlugin;
@@ -0,0 +1,26 @@
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: function init() {
7
+ return {
8
+ copied: false
9
+ };
10
+ },
11
+ apply: function apply(tr, pluginState) {
12
+ var meta = tr.getMeta(pluginKey);
13
+
14
+ if ((meta === null || meta === void 0 ? void 0 : meta.copied) !== undefined) {
15
+ return {
16
+ copied: meta.copied
17
+ };
18
+ }
19
+
20
+ return pluginState;
21
+ }
22
+ },
23
+ key: pluginKey
24
+ });
25
+ }
26
+ export default copyButtonPlugin;
@@ -0,0 +1,2 @@
1
+ import { PluginKey } from 'prosemirror-state';
2
+ export var pluginKey = new PluginKey('copyButtonPlugin');
@@ -0,0 +1,31 @@
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 var getCopyButtonConfig = function getCopyButtonConfig(state, formatMessage, nodeType, onMouseEnter, onMouseLeave) {
7
+ var 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 var showCopyButton = function showCopyButton(state) {
26
+ return state && // Check if the Copy button plugin is enabled
27
+ // @ts-ignore pluginKey.key
28
+ state.plugins.find(function (p) {
29
+ return p.key === pluginKey.key;
30
+ });
31
+ };