@atlaskit/editor-core 187.43.12 → 187.43.17

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 (92) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/labs/next/presets/default.js +2 -1
  3. package/dist/cjs/labs/next/presets/universal.js +1 -1
  4. package/dist/cjs/plugins/clipboard/pm-plugins/main.js +13 -54
  5. package/dist/cjs/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +1 -1
  6. package/dist/cjs/plugins/floating-toolbar/index.js +1 -2
  7. package/dist/cjs/plugins/index.js +0 -7
  8. package/dist/cjs/plugins/selection/utils.js +29 -80
  9. package/dist/cjs/plugins/type-ahead/index.js +2 -2
  10. package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +4 -4
  11. package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +2 -2
  12. package/dist/cjs/utils/clipboard.js +19 -127
  13. package/dist/cjs/version-wrapper.js +1 -1
  14. package/dist/es2019/labs/next/presets/default.js +2 -1
  15. package/dist/es2019/labs/next/presets/universal.js +2 -2
  16. package/dist/es2019/plugins/clipboard/pm-plugins/main.js +3 -53
  17. package/dist/es2019/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +1 -1
  18. package/dist/es2019/plugins/floating-toolbar/index.js +1 -2
  19. package/dist/es2019/plugins/index.js +0 -1
  20. package/dist/es2019/plugins/selection/utils.js +3 -74
  21. package/dist/es2019/plugins/type-ahead/index.js +1 -1
  22. package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +1 -1
  23. package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +1 -1
  24. package/dist/es2019/utils/clipboard.js +1 -53
  25. package/dist/es2019/version-wrapper.js +1 -1
  26. package/dist/esm/labs/next/presets/default.js +2 -1
  27. package/dist/esm/labs/next/presets/universal.js +2 -2
  28. package/dist/esm/plugins/clipboard/pm-plugins/main.js +3 -49
  29. package/dist/esm/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +1 -1
  30. package/dist/esm/plugins/floating-toolbar/index.js +1 -2
  31. package/dist/esm/plugins/index.js +0 -1
  32. package/dist/esm/plugins/selection/utils.js +3 -72
  33. package/dist/esm/plugins/type-ahead/index.js +1 -1
  34. package/dist/esm/plugins/type-ahead/pm-plugins/main.js +1 -1
  35. package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +1 -1
  36. package/dist/esm/utils/clipboard.js +1 -119
  37. package/dist/esm/version-wrapper.js +1 -1
  38. package/dist/types/labs/next/presets/default.d.ts +68 -4
  39. package/dist/types/plugins/clipboard/pm-plugins/main.d.ts +2 -3
  40. package/dist/types/plugins/index.d.ts +0 -1
  41. package/dist/types/plugins/selection/utils.d.ts +2 -5
  42. package/dist/types/plugins/type-ahead/api.d.ts +1 -1
  43. package/dist/types/plugins/type-ahead/commands/update-list-items.d.ts +1 -1
  44. package/dist/types/plugins/type-ahead/commands/update-query.d.ts +1 -1
  45. package/dist/types/plugins/type-ahead/commands/update-selected-index.d.ts +1 -1
  46. package/dist/types/plugins/type-ahead/pm-plugins/main.d.ts +1 -1
  47. package/dist/types/plugins/type-ahead/types.d.ts +1 -1
  48. package/dist/types/utils/clipboard.d.ts +1 -3
  49. package/dist/types-ts4.5/labs/next/presets/default.d.ts +86 -0
  50. package/dist/types-ts4.5/plugins/clipboard/pm-plugins/main.d.ts +2 -3
  51. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  52. package/dist/types-ts4.5/plugins/selection/utils.d.ts +2 -5
  53. package/dist/types-ts4.5/plugins/type-ahead/api.d.ts +1 -1
  54. package/dist/types-ts4.5/plugins/type-ahead/commands/update-list-items.d.ts +1 -1
  55. package/dist/types-ts4.5/plugins/type-ahead/commands/update-query.d.ts +1 -1
  56. package/dist/types-ts4.5/plugins/type-ahead/commands/update-selected-index.d.ts +1 -1
  57. package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/main.d.ts +1 -1
  58. package/dist/types-ts4.5/plugins/type-ahead/types.d.ts +1 -1
  59. package/dist/types-ts4.5/utils/clipboard.d.ts +1 -3
  60. package/package.json +12 -8
  61. package/report.api.md +1 -1
  62. package/tmp/api-report-tmp.d.ts +1 -1
  63. package/dist/cjs/plugins/copy-button/commands.js +0 -171
  64. package/dist/cjs/plugins/copy-button/index.js +0 -23
  65. package/dist/cjs/plugins/copy-button/pm-plugins/main.js +0 -104
  66. package/dist/cjs/plugins/copy-button/pm-plugins/plugin-key.js +0 -9
  67. package/dist/cjs/plugins/copy-button/toolbar.js +0 -99
  68. package/dist/cjs/plugins/copy-button/utils.js +0 -22
  69. package/dist/es2019/plugins/copy-button/commands.js +0 -157
  70. package/dist/es2019/plugins/copy-button/index.js +0 -11
  71. package/dist/es2019/plugins/copy-button/pm-plugins/main.js +0 -97
  72. package/dist/es2019/plugins/copy-button/pm-plugins/plugin-key.js +0 -2
  73. package/dist/es2019/plugins/copy-button/toolbar.js +0 -82
  74. package/dist/es2019/plugins/copy-button/utils.js +0 -15
  75. package/dist/esm/plugins/copy-button/commands.js +0 -159
  76. package/dist/esm/plugins/copy-button/index.js +0 -15
  77. package/dist/esm/plugins/copy-button/pm-plugins/main.js +0 -96
  78. package/dist/esm/plugins/copy-button/pm-plugins/plugin-key.js +0 -2
  79. package/dist/esm/plugins/copy-button/toolbar.js +0 -89
  80. package/dist/esm/plugins/copy-button/utils.js +0 -14
  81. package/dist/types/plugins/copy-button/commands.d.ts +0 -9
  82. package/dist/types/plugins/copy-button/index.d.ts +0 -3
  83. package/dist/types/plugins/copy-button/pm-plugins/main.d.ts +0 -4
  84. package/dist/types/plugins/copy-button/pm-plugins/plugin-key.d.ts +0 -2
  85. package/dist/types/plugins/copy-button/toolbar.d.ts +0 -13
  86. package/dist/types/plugins/copy-button/utils.d.ts +0 -8
  87. package/dist/types-ts4.5/plugins/copy-button/commands.d.ts +0 -9
  88. package/dist/types-ts4.5/plugins/copy-button/index.d.ts +0 -3
  89. package/dist/types-ts4.5/plugins/copy-button/pm-plugins/main.d.ts +0 -4
  90. package/dist/types-ts4.5/plugins/copy-button/pm-plugins/plugin-key.d.ts +0 -2
  91. package/dist/types-ts4.5/plugins/copy-button/toolbar.d.ts +0 -13
  92. package/dist/types-ts4.5/plugins/copy-button/utils.d.ts +0 -8
@@ -1,11 +1,10 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
2
  import { clipboardPluginKey } from '../plugin-key';
4
- import { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload } from '../../selection/utils';
5
- import { EVENT_TYPE, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../../analytics/types/enums';
3
+ import { ACTION } from '../../analytics/types/enums';
6
4
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
7
5
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
8
6
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
7
+ import { getAnalyticsPayload } from '@atlaskit/editor-common/clipboard';
9
8
  export const createPlugin = ({
10
9
  dispatchAnalyticsEvent,
11
10
  schema
@@ -101,53 +100,4 @@ export const sendClipboardAnalytics = (view, dispatchAnalyticsEvent, action) =>
101
100
  // from running just because we are sending an analytics event
102
101
  return false;
103
102
  };
104
- export const getAnalyticsPayload = (state, action) => {
105
- const {
106
- selection,
107
- doc
108
- } = state;
109
- const selectionAnalyticsPayload = getNodeSelectionAnalyticsPayload(selection) || getRangeSelectionAnalyticsPayload(selection, doc) || getAllSelectionAnalyticsPayload(selection) || getCellSelectionAnalyticsPayload(state);
110
- if (selectionAnalyticsPayload) {
111
- const {
112
- actionSubjectId: selectionActionSubjectId
113
- } = selectionAnalyticsPayload;
114
- let content = [];
115
- switch (selectionActionSubjectId) {
116
- case ACTION_SUBJECT_ID.NODE:
117
- content.push(selectionAnalyticsPayload.attributes.node);
118
- break;
119
- case ACTION_SUBJECT_ID.RANGE:
120
- content.push(...selectionAnalyticsPayload.attributes.nodes);
121
- break;
122
- case ACTION_SUBJECT_ID.ALL:
123
- content.push('all');
124
- break;
125
- case ACTION_SUBJECT_ID.CELL:
126
- {
127
- const {
128
- selectedCells
129
- } = selectionAnalyticsPayload.attributes;
130
- content.push(...Array(selectedCells).fill('tableCell'));
131
- break;
132
- }
133
- }
134
- return {
135
- eventType: EVENT_TYPE.TRACK,
136
- action,
137
- actionSubject: ACTION_SUBJECT.DOCUMENT,
138
- attributes: {
139
- content
140
- }
141
- };
142
- }
143
- if (selection instanceof TextSelection && selection.$cursor) {
144
- return {
145
- eventType: EVENT_TYPE.TRACK,
146
- action,
147
- actionSubject: ACTION_SUBJECT.DOCUMENT,
148
- attributes: {
149
- content: ['caret']
150
- }
151
- };
152
- }
153
- };
103
+ export { getAnalyticsPayload };
@@ -1,7 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
3
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import { getSelectedNodeOrNodeParentByNodeType } from '../../copy-button/utils';
4
+ import { getSelectedNodeOrNodeParentByNodeType } from '@atlaskit/editor-plugin-copy-button/utils';
5
5
  export const copySelectionPluginKey = new PluginKey('codeBlockCopySelectionPlugin');
6
6
  function getSelectionDecorationStartAndEnd({
7
7
  state,
@@ -16,7 +16,6 @@ import { ConfirmationModal } from './ui/ConfirmationModal';
16
16
  import { ToolbarLoader } from './ui/ToolbarLoader';
17
17
  import { findNode } from './utils';
18
18
  import { ErrorBoundary } from '../../ui/ErrorBoundary';
19
- import { processCopyButtonItems } from '../copy-button/toolbar';
20
19
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
21
20
  export const getRelevantConfig = (selection, configs) => {
22
21
  // node selections always take precedence, see if
@@ -219,7 +218,7 @@ function ContentComponent({
219
218
  return null;
220
219
  }
221
220
  let customPositionCalculation;
222
- const toolbarItems = processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions.hoverDecoration);
221
+ const toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.copyButton.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions.hoverDecoration);
223
222
  if (onPositionCalculated) {
224
223
  customPositionCalculation = nextPos => {
225
224
  return onPositionCalculated(editorView, nextPos);
@@ -48,5 +48,4 @@ export { default as avatarGroupPlugin } from './avatar-group';
48
48
  export { default as viewUpdateSubscriptionPlugin } from './view-update-subscription';
49
49
  export { default as beforePrimaryToolbarPlugin } from './before-primaryToolbar';
50
50
  export { default as codeBidiWarningPlugin } from './code-bidi-warning';
51
- export { default as copyButtonPlugin } from './copy-button';
52
51
  export { default as borderPlugin } from './border';
@@ -1,15 +1,13 @@
1
1
  import { NodeSelection, TextSelection, Selection, AllSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
- import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
- import { selectedRect } from '@atlaskit/editor-tables/utils';
5
3
  import { flatten, findParentNode } from '@atlaskit/editor-prosemirror/utils';
6
4
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
7
5
  import { isSelectionAtStartOfNode, isSelectionAtEndOfNode } from '@atlaskit/editor-common/selection';
8
6
  import { selectNode } from '../../utils/commands';
9
7
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
10
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics';
11
8
  import { isIgnored as isIgnoredByGapCursor } from '../selection/gap-cursor/utils/is-ignored';
12
9
  import { selectionPluginKey } from './types';
10
+ import { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload } from '@atlaskit/editor-common/selection';
13
11
  export function createSelectionClickHandler(nodes, isValidTarget, options) {
14
12
  return function handleClickOn(view, pos, node, nodePos, event, direct) {
15
13
  if (options.useLongPressSelection) {
@@ -47,46 +45,6 @@ export const getDecorations = tr => {
47
45
  }
48
46
  return DecorationSet.empty;
49
47
  };
50
- export function getNodeSelectionAnalyticsPayload(selection) {
51
- if (selection instanceof NodeSelection) {
52
- return {
53
- action: ACTION.SELECTED,
54
- actionSubject: ACTION_SUBJECT.DOCUMENT,
55
- actionSubjectId: ACTION_SUBJECT_ID.NODE,
56
- eventType: EVENT_TYPE.TRACK,
57
- attributes: {
58
- node: selection.node.type.name
59
- }
60
- };
61
- }
62
- }
63
- export function getAllSelectionAnalyticsPayload(selection) {
64
- if (selection instanceof AllSelection) {
65
- return {
66
- action: ACTION.SELECTED,
67
- actionSubject: ACTION_SUBJECT.DOCUMENT,
68
- actionSubjectId: ACTION_SUBJECT_ID.ALL,
69
- eventType: EVENT_TYPE.TRACK
70
- };
71
- }
72
- }
73
- export function getCellSelectionAnalyticsPayload(state) {
74
- if (state.selection instanceof CellSelection) {
75
- const rect = selectedRect(state);
76
- const selectedCells = rect.map.cellsInRect(rect).length;
77
- const totalCells = rect.map.map.length;
78
- return {
79
- action: ACTION.SELECTED,
80
- actionSubject: ACTION_SUBJECT.DOCUMENT,
81
- actionSubjectId: ACTION_SUBJECT_ID.CELL,
82
- eventType: EVENT_TYPE.TRACK,
83
- attributes: {
84
- selectedCells,
85
- totalCells
86
- }
87
- };
88
- }
89
- }
90
48
  const topLevelBlockNodesThatHaveSelectionStyles = ['table', 'panel', 'expand', 'layoutSection', 'decisionList', 'decisionItem', 'codeBlock'];
91
49
 
92
50
  /**
@@ -142,36 +100,6 @@ export const getNodesToDecorateFromSelection = (selection, doc) => {
142
100
  }
143
101
  return nodes;
144
102
  };
145
- export function getRangeSelectionAnalyticsPayload(selection, doc) {
146
- if (selection instanceof TextSelection && selection.from !== selection.to) {
147
- const {
148
- from,
149
- to,
150
- anchor,
151
- head
152
- } = selection;
153
- const nodes = [];
154
- doc.nodesBetween(from, to, (node, pos) => {
155
- // We want to send top-level nodes only, ie. the nodes that would have the selection styling
156
- // We allow text nodes that are not fully covered as they are a special case
157
- if (node.isText || pos >= from && pos + node.nodeSize <= to) {
158
- nodes.push(node.type.name);
159
- return false;
160
- }
161
- });
162
- return {
163
- action: ACTION.SELECTED,
164
- actionSubject: ACTION_SUBJECT.DOCUMENT,
165
- actionSubjectId: ACTION_SUBJECT_ID.RANGE,
166
- eventType: EVENT_TYPE.TRACK,
167
- attributes: {
168
- from: anchor,
169
- to: head,
170
- nodes
171
- }
172
- };
173
- }
174
- }
175
103
  export function shouldRecalcDecorations({
176
104
  oldEditorState,
177
105
  newEditorState
@@ -322,4 +250,5 @@ export const findLastChildNodeToSelect = parent => {
322
250
  }
323
251
  };
324
252
  export const isSelectionAtStartOfParentNode = ($pos, selection) => isSelectionAtStartOfNode($pos, findSelectableContainerParent(selection));
325
- export const isSelectionAtEndOfParentNode = ($pos, selection) => isSelectionAtEndOfNode($pos, findSelectableContainerParent(selection));
253
+ export const isSelectionAtEndOfParentNode = ($pos, selection) => isSelectionAtEndOfNode($pos, findSelectableContainerParent(selection));
254
+ export { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload };
@@ -10,7 +10,7 @@ import React from 'react';
10
10
  import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
11
11
  import { createPlugin } from './pm-plugins/main';
12
12
  import { createPlugin as createInsertItemPlugin } from './pm-plugins/insert-item-plugin';
13
- import WithPluginState from '../../ui/WithPluginState';
13
+ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
14
14
  import { typeAheadQuery } from '@atlaskit/adf-schema';
15
15
  import { pluginKey as typeAheadPluginKey } from './pm-plugins/key';
16
16
  import { inputRulePlugin } from './pm-plugins/input-rules';
@@ -4,7 +4,7 @@ import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
4
4
  import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE } from '../constants';
5
5
  import { ACTIONS } from './actions';
6
6
  import { pluginKey } from './key';
7
- import { closest } from '../../../utils/dom';
7
+ import { closest } from '@atlaskit/editor-common/utils';
8
8
  import { createReducer } from './reducer';
9
9
  import { factoryDecorations } from './decorations';
10
10
  import { isInsertionTransaction } from './utils';
@@ -7,7 +7,7 @@ import { borderRadius } from '@atlaskit/theme/constants';
7
7
  import { ButtonItem } from '@atlaskit/menu';
8
8
  import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
9
9
  import { IconFallback } from '@atlaskit/editor-common/quick-insert';
10
- import { shortcutStyle } from '../../../ui/styles';
10
+ import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
11
11
  import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
12
12
  import { useIntl } from 'react-intl-next';
13
13
  import { typeAheadListMessages } from '../messages';
@@ -1,53 +1 @@
1
- import * as clipboard from 'clipboard-polyfill';
2
- const isClipboardApiSupported = () => !!navigator.clipboard && typeof navigator.clipboard.writeText === 'function';
3
- const isIEClipboardApiSupported = () => window.clipboardData && typeof window.clipboardData.setData === 'function';
4
- export const copyToClipboard = async textToCopy => {
5
- if (isClipboardApiSupported()) {
6
- try {
7
- await navigator.clipboard.writeText(textToCopy);
8
- } catch (error) {
9
- throw new Error('Clipboard api is not supported');
10
- }
11
- } else if (isIEClipboardApiSupported()) {
12
- try {
13
- await window.clipboardData.setData('text', textToCopy);
14
- } catch (error) {
15
- throw new Error('IE clipboard api is not supported');
16
- }
17
- } else {
18
- throw new Error('Clipboard api is not supported');
19
- }
20
- };
21
- export const copyHTMLToClipboard = async (elementToCopy, plainTextToCopy) => {
22
- // @ts-ignore
23
- if (isClipboardApiSupported() && typeof ClipboardItem !== 'undefined') {
24
- try {
25
- const data = new ClipboardItem({
26
- 'text/plain': new Blob([plainTextToCopy || elementToCopy.innerText], {
27
- type: 'text/plain'
28
- }),
29
- 'text/html': new Blob([elementToCopy.innerHTML], {
30
- type: 'text/html'
31
- })
32
- });
33
- // @ts-ignore
34
- await navigator.clipboard.write([data]);
35
- } catch (error) {
36
- throw new Error('Clipboard api is not supported');
37
- }
38
- } else if (typeof document !== undefined) {
39
- // ED-17083 extension copy seems have issue with ClipboardItem API
40
- // Hence of use of this polyfill
41
- copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy);
42
- }
43
- };
44
-
45
- // At the time of development, Firefox doesn't support ClipboardItem API
46
- // Hence of use of this polyfill
47
- export const copyHTMLToClipboardPolyfill = (elementToCopy, plainTextToCopy) => {
48
- const Clipboard = clipboard;
49
- const dt = new Clipboard.DT();
50
- dt.setData('text/plain', plainTextToCopy || elementToCopy.innerText);
51
- dt.setData('text/html', elementToCopy.innerHTML);
52
- Clipboard.write(dt);
53
- };
1
+ export { copyToClipboard, copyHTMLToClipboard, copyHTMLToClipboardPolyfill } from '@atlaskit/editor-common/clipboard';
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.43.12";
2
+ export const version = "187.43.17";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -14,6 +14,7 @@ import typeAheadPlugin from '../../../plugins/type-ahead';
14
14
  import submitEditorPlugin from '../../../plugins/submit-editor';
15
15
  import fakeTextCursorPlugin from '../../../plugins/fake-text-cursor';
16
16
  import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
17
+ import { copyButtonPlugin } from '@atlaskit/editor-plugin-copy-button';
17
18
  import floatingToolbarPlugin from '../../../plugins/floating-toolbar';
18
19
  import clipboardPlugin from '../../../plugins/clipboard';
19
20
  import { analyticsPlugin as deprecatedAnalyticsPlugin } from '../../../plugins';
@@ -68,7 +69,7 @@ export function createDefaultPreset(options) {
68
69
  return builder;
69
70
  }).add([hyperlinkPlugin, options.hyperlinkOptions]).add([textFormattingPlugin, options.textFormatting]).add(widthPlugin).add([quickInsertPlugin, options.quickInsert]).add([typeAheadPlugin, options.typeAhead || {
70
71
  createAnalyticsEvent: options.createAnalyticsEvent
71
- }]).add([placeholderPlugin, options.placeholder]).add(unsupportedContentPlugin).add(editorDisabledPlugin).add([submitEditorPlugin, options.submitEditor]).add(fakeTextCursorPlugin).add(floatingToolbarPlugin).add([selectionPlugin, options.selection]).add([codeBlockPlugin, options.codeBlock || {
72
+ }]).add([placeholderPlugin, options.placeholder]).add(unsupportedContentPlugin).add(editorDisabledPlugin).add([submitEditorPlugin, options.submitEditor]).add(fakeTextCursorPlugin).add(copyButtonPlugin).add(floatingToolbarPlugin).add([selectionPlugin, options.selection]).add([codeBlockPlugin, options.codeBlock || {
72
73
  appearance: 'full-page'
73
74
  }]);
74
75
  return preset;
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  import { createEditorSelectionAPI } from '../../../selection-api/api';
6
- import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, extensionPlugin, fragmentMarkPlugin, helpDialogPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, saveOnEnterPlugin, tasksAndDecisionsPlugin, textColorPlugin, statusPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, captionPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin, copyButtonPlugin, borderPlugin } from '../../../plugins';
6
+ import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, extensionPlugin, fragmentMarkPlugin, helpDialogPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, saveOnEnterPlugin, tasksAndDecisionsPlugin, textColorPlugin, statusPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, captionPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin, borderPlugin } from '../../../plugins';
7
7
  import { rulePlugin } from '@atlaskit/editor-plugin-rule';
8
8
  import { emojiPlugin } from '@atlaskit/editor-plugin-emoji';
9
9
  import { listPlugin } from '@atlaskit/editor-plugin-list';
@@ -388,6 +388,6 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
388
388
  return builder;
389
389
  }).add([codeBidiWarningPlugin, {
390
390
  appearance: appearance
391
- }]).add(copyButtonPlugin);
391
+ }]);
392
392
  return finalPreset;
393
393
  }
@@ -1,15 +1,13 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
7
5
  import { clipboardPluginKey } from '../plugin-key';
8
- import { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload } from '../../selection/utils';
9
- import { EVENT_TYPE, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../../analytics/types/enums';
6
+ import { ACTION } from '../../analytics/types/enums';
10
7
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
11
8
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
12
9
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
10
+ import { getAnalyticsPayload } from '@atlaskit/editor-common/clipboard';
13
11
  export var createPlugin = function createPlugin(_ref) {
14
12
  var dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
15
13
  schema = _ref.schema;
@@ -111,48 +109,4 @@ export var sendClipboardAnalytics = function sendClipboardAnalytics(view, dispat
111
109
  // from running just because we are sending an analytics event
112
110
  return false;
113
111
  };
114
- export var getAnalyticsPayload = function getAnalyticsPayload(state, action) {
115
- var selection = state.selection,
116
- doc = state.doc;
117
- var selectionAnalyticsPayload = getNodeSelectionAnalyticsPayload(selection) || getRangeSelectionAnalyticsPayload(selection, doc) || getAllSelectionAnalyticsPayload(selection) || getCellSelectionAnalyticsPayload(state);
118
- if (selectionAnalyticsPayload) {
119
- var selectionActionSubjectId = selectionAnalyticsPayload.actionSubjectId;
120
- var content = [];
121
- switch (selectionActionSubjectId) {
122
- case ACTION_SUBJECT_ID.NODE:
123
- content.push(selectionAnalyticsPayload.attributes.node);
124
- break;
125
- case ACTION_SUBJECT_ID.RANGE:
126
- content.push.apply(content, _toConsumableArray(selectionAnalyticsPayload.attributes.nodes));
127
- break;
128
- case ACTION_SUBJECT_ID.ALL:
129
- content.push('all');
130
- break;
131
- case ACTION_SUBJECT_ID.CELL:
132
- {
133
- var _ref2 = selectionAnalyticsPayload.attributes,
134
- selectedCells = _ref2.selectedCells;
135
- content.push.apply(content, _toConsumableArray(Array(selectedCells).fill('tableCell')));
136
- break;
137
- }
138
- }
139
- return {
140
- eventType: EVENT_TYPE.TRACK,
141
- action: action,
142
- actionSubject: ACTION_SUBJECT.DOCUMENT,
143
- attributes: {
144
- content: content
145
- }
146
- };
147
- }
148
- if (selection instanceof TextSelection && selection.$cursor) {
149
- return {
150
- eventType: EVENT_TYPE.TRACK,
151
- action: action,
152
- actionSubject: ACTION_SUBJECT.DOCUMENT,
153
- attributes: {
154
- content: ['caret']
155
- }
156
- };
157
- }
158
- };
112
+ export { getAnalyticsPayload };
@@ -2,7 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
4
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
- import { getSelectedNodeOrNodeParentByNodeType } from '../../copy-button/utils';
5
+ import { getSelectedNodeOrNodeParentByNodeType } from '@atlaskit/editor-plugin-copy-button/utils';
6
6
  export var copySelectionPluginKey = new PluginKey('codeBlockCopySelectionPlugin');
7
7
  function getSelectionDecorationStartAndEnd(_ref) {
8
8
  var state = _ref.state,
@@ -19,7 +19,6 @@ import { ConfirmationModal } from './ui/ConfirmationModal';
19
19
  import { ToolbarLoader } from './ui/ToolbarLoader';
20
20
  import { findNode } from './utils';
21
21
  import { ErrorBoundary } from '../../ui/ErrorBoundary';
22
- import { processCopyButtonItems } from '../copy-button/toolbar';
23
22
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
24
23
  export var getRelevantConfig = function getRelevantConfig(selection, configs) {
25
24
  // node selections always take precedence, see if
@@ -220,7 +219,7 @@ function ContentComponent(_ref5) {
220
219
  return null;
221
220
  }
222
221
  var customPositionCalculation;
223
- var toolbarItems = processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions.hoverDecoration);
222
+ var toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.copyButton.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions.hoverDecoration);
224
223
  if (onPositionCalculated) {
225
224
  customPositionCalculation = function customPositionCalculation(nextPos) {
226
225
  return onPositionCalculated(editorView, nextPos);
@@ -48,5 +48,4 @@ export { default as avatarGroupPlugin } from './avatar-group';
48
48
  export { default as viewUpdateSubscriptionPlugin } from './view-update-subscription';
49
49
  export { default as beforePrimaryToolbarPlugin } from './before-primaryToolbar';
50
50
  export { default as codeBidiWarningPlugin } from './code-bidi-warning';
51
- export { default as copyButtonPlugin } from './copy-button';
52
51
  export { default as borderPlugin } from './border';
@@ -1,15 +1,13 @@
1
1
  import { NodeSelection, TextSelection, Selection, AllSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
- import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
- import { selectedRect } from '@atlaskit/editor-tables/utils';
5
3
  import { flatten, findParentNode } from '@atlaskit/editor-prosemirror/utils';
6
4
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
7
5
  import { isSelectionAtStartOfNode, isSelectionAtEndOfNode } from '@atlaskit/editor-common/selection';
8
6
  import { selectNode } from '../../utils/commands';
9
7
  import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
10
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics';
11
8
  import { isIgnored as isIgnoredByGapCursor } from '../selection/gap-cursor/utils/is-ignored';
12
9
  import { selectionPluginKey } from './types';
10
+ import { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload } from '@atlaskit/editor-common/selection';
13
11
  export function createSelectionClickHandler(nodes, isValidTarget, options) {
14
12
  return function handleClickOn(view, pos, node, nodePos, event, direct) {
15
13
  if (options.useLongPressSelection) {
@@ -46,46 +44,6 @@ export var getDecorations = function getDecorations(tr) {
46
44
  }
47
45
  return DecorationSet.empty;
48
46
  };
49
- export function getNodeSelectionAnalyticsPayload(selection) {
50
- if (selection instanceof NodeSelection) {
51
- return {
52
- action: ACTION.SELECTED,
53
- actionSubject: ACTION_SUBJECT.DOCUMENT,
54
- actionSubjectId: ACTION_SUBJECT_ID.NODE,
55
- eventType: EVENT_TYPE.TRACK,
56
- attributes: {
57
- node: selection.node.type.name
58
- }
59
- };
60
- }
61
- }
62
- export function getAllSelectionAnalyticsPayload(selection) {
63
- if (selection instanceof AllSelection) {
64
- return {
65
- action: ACTION.SELECTED,
66
- actionSubject: ACTION_SUBJECT.DOCUMENT,
67
- actionSubjectId: ACTION_SUBJECT_ID.ALL,
68
- eventType: EVENT_TYPE.TRACK
69
- };
70
- }
71
- }
72
- export function getCellSelectionAnalyticsPayload(state) {
73
- if (state.selection instanceof CellSelection) {
74
- var rect = selectedRect(state);
75
- var selectedCells = rect.map.cellsInRect(rect).length;
76
- var totalCells = rect.map.map.length;
77
- return {
78
- action: ACTION.SELECTED,
79
- actionSubject: ACTION_SUBJECT.DOCUMENT,
80
- actionSubjectId: ACTION_SUBJECT_ID.CELL,
81
- eventType: EVENT_TYPE.TRACK,
82
- attributes: {
83
- selectedCells: selectedCells,
84
- totalCells: totalCells
85
- }
86
- };
87
- }
88
- }
89
47
  var topLevelBlockNodesThatHaveSelectionStyles = ['table', 'panel', 'expand', 'layoutSection', 'decisionList', 'decisionItem', 'codeBlock'];
90
48
 
91
49
  /**
@@ -139,34 +97,6 @@ export var getNodesToDecorateFromSelection = function getNodesToDecorateFromSele
139
97
  }
140
98
  return nodes;
141
99
  };
142
- export function getRangeSelectionAnalyticsPayload(selection, doc) {
143
- if (selection instanceof TextSelection && selection.from !== selection.to) {
144
- var from = selection.from,
145
- to = selection.to,
146
- anchor = selection.anchor,
147
- head = selection.head;
148
- var nodes = [];
149
- doc.nodesBetween(from, to, function (node, pos) {
150
- // We want to send top-level nodes only, ie. the nodes that would have the selection styling
151
- // We allow text nodes that are not fully covered as they are a special case
152
- if (node.isText || pos >= from && pos + node.nodeSize <= to) {
153
- nodes.push(node.type.name);
154
- return false;
155
- }
156
- });
157
- return {
158
- action: ACTION.SELECTED,
159
- actionSubject: ACTION_SUBJECT.DOCUMENT,
160
- actionSubjectId: ACTION_SUBJECT_ID.RANGE,
161
- eventType: EVENT_TYPE.TRACK,
162
- attributes: {
163
- from: anchor,
164
- to: head,
165
- nodes: nodes
166
- }
167
- };
168
- }
169
- }
170
100
  export function shouldRecalcDecorations(_ref2) {
171
101
  var oldEditorState = _ref2.oldEditorState,
172
102
  newEditorState = _ref2.newEditorState;
@@ -328,4 +258,5 @@ export var isSelectionAtStartOfParentNode = function isSelectionAtStartOfParentN
328
258
  };
329
259
  export var isSelectionAtEndOfParentNode = function isSelectionAtEndOfParentNode($pos, selection) {
330
260
  return isSelectionAtEndOfNode($pos, findSelectableContainerParent(selection));
331
- };
261
+ };
262
+ export { getNodeSelectionAnalyticsPayload, getAllSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload };
@@ -11,7 +11,7 @@ import React from 'react';
11
11
  import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
12
12
  import { createPlugin } from './pm-plugins/main';
13
13
  import { createPlugin as createInsertItemPlugin } from './pm-plugins/insert-item-plugin';
14
- import WithPluginState from '../../ui/WithPluginState';
14
+ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
15
15
  import { typeAheadQuery } from '@atlaskit/adf-schema';
16
16
  import { pluginKey as typeAheadPluginKey } from './pm-plugins/key';
17
17
  import { inputRulePlugin } from './pm-plugins/input-rules';
@@ -4,7 +4,7 @@ import { InsertTypeAheadStep } from '@atlaskit/adf-schema/steps';
4
4
  import { TYPE_AHEAD_DECORATION_DATA_ATTRIBUTE } from '../constants';
5
5
  import { ACTIONS } from './actions';
6
6
  import { pluginKey } from './key';
7
- import { closest } from '../../../utils/dom';
7
+ import { closest } from '@atlaskit/editor-common/utils';
8
8
  import { createReducer } from './reducer';
9
9
  import { factoryDecorations } from './decorations';
10
10
  import { isInsertionTransaction } from './utils';
@@ -9,7 +9,7 @@ import { borderRadius } from '@atlaskit/theme/constants';
9
9
  import { ButtonItem } from '@atlaskit/menu';
10
10
  import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
11
11
  import { IconFallback } from '@atlaskit/editor-common/quick-insert';
12
- import { shortcutStyle } from '../../../ui/styles';
12
+ import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
13
13
  import { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
14
14
  import { useIntl } from 'react-intl-next';
15
15
  import { typeAheadListMessages } from '../messages';