@atlaskit/editor-core 187.43.11 → 187.43.13

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 (84) 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/media/nodeviews/mediaSingle.js +1 -1
  9. package/dist/cjs/plugins/media/pm-plugins/main.js +6 -0
  10. package/dist/cjs/plugins/media/toolbar/index.js +3 -5
  11. package/dist/cjs/plugins/selection/utils.js +29 -80
  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/media/nodeviews/mediaSingle.js +1 -1
  21. package/dist/es2019/plugins/media/pm-plugins/main.js +6 -0
  22. package/dist/es2019/plugins/media/toolbar/index.js +3 -7
  23. package/dist/es2019/plugins/selection/utils.js +3 -74
  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/media/nodeviews/mediaSingle.js +1 -1
  33. package/dist/esm/plugins/media/pm-plugins/main.js +6 -0
  34. package/dist/esm/plugins/media/toolbar/index.js +3 -5
  35. package/dist/esm/plugins/selection/utils.js +3 -72
  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/media/pm-plugins/main.d.ts +1 -0
  42. package/dist/types/plugins/media/pm-plugins/types.d.ts +1 -0
  43. package/dist/types/plugins/selection/utils.d.ts +2 -5
  44. package/dist/types/utils/clipboard.d.ts +1 -3
  45. package/dist/types-ts4.5/labs/next/presets/default.d.ts +86 -0
  46. package/dist/types-ts4.5/plugins/clipboard/pm-plugins/main.d.ts +2 -3
  47. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  48. package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +1 -0
  49. package/dist/types-ts4.5/plugins/media/pm-plugins/types.d.ts +1 -0
  50. package/dist/types-ts4.5/plugins/selection/utils.d.ts +2 -5
  51. package/dist/types-ts4.5/utils/clipboard.d.ts +1 -3
  52. package/package.json +7 -7
  53. package/report.api.md +2 -0
  54. package/tmp/api-report-tmp.d.ts +2 -0
  55. package/dist/cjs/plugins/copy-button/commands.js +0 -171
  56. package/dist/cjs/plugins/copy-button/index.js +0 -23
  57. package/dist/cjs/plugins/copy-button/pm-plugins/main.js +0 -104
  58. package/dist/cjs/plugins/copy-button/pm-plugins/plugin-key.js +0 -9
  59. package/dist/cjs/plugins/copy-button/toolbar.js +0 -99
  60. package/dist/cjs/plugins/copy-button/utils.js +0 -22
  61. package/dist/es2019/plugins/copy-button/commands.js +0 -157
  62. package/dist/es2019/plugins/copy-button/index.js +0 -11
  63. package/dist/es2019/plugins/copy-button/pm-plugins/main.js +0 -97
  64. package/dist/es2019/plugins/copy-button/pm-plugins/plugin-key.js +0 -2
  65. package/dist/es2019/plugins/copy-button/toolbar.js +0 -82
  66. package/dist/es2019/plugins/copy-button/utils.js +0 -15
  67. package/dist/esm/plugins/copy-button/commands.js +0 -159
  68. package/dist/esm/plugins/copy-button/index.js +0 -15
  69. package/dist/esm/plugins/copy-button/pm-plugins/main.js +0 -96
  70. package/dist/esm/plugins/copy-button/pm-plugins/plugin-key.js +0 -2
  71. package/dist/esm/plugins/copy-button/toolbar.js +0 -89
  72. package/dist/esm/plugins/copy-button/utils.js +0 -14
  73. package/dist/types/plugins/copy-button/commands.d.ts +0 -9
  74. package/dist/types/plugins/copy-button/index.d.ts +0 -3
  75. package/dist/types/plugins/copy-button/pm-plugins/main.d.ts +0 -4
  76. package/dist/types/plugins/copy-button/pm-plugins/plugin-key.d.ts +0 -2
  77. package/dist/types/plugins/copy-button/toolbar.d.ts +0 -13
  78. package/dist/types/plugins/copy-button/utils.d.ts +0 -8
  79. package/dist/types-ts4.5/plugins/copy-button/commands.d.ts +0 -9
  80. package/dist/types-ts4.5/plugins/copy-button/index.d.ts +0 -3
  81. package/dist/types-ts4.5/plugins/copy-button/pm-plugins/main.d.ts +0 -4
  82. package/dist/types-ts4.5/plugins/copy-button/pm-plugins/plugin-key.d.ts +0 -2
  83. package/dist/types-ts4.5/plugins/copy-button/toolbar.d.ts +0 -13
  84. 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';
@@ -273,7 +273,7 @@ export default class MediaSingleNode extends Component {
273
273
  origWidth: width,
274
274
  layout,
275
275
  // This will only be used when calculating legacy media single width
276
- // thus we use the legecy value (exclude table as container node)
276
+ // thus we use the legacy value (exclude table as container node)
277
277
  contentWidth: contentWidthForLegacyExperience,
278
278
  containerWidth,
279
279
  gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
@@ -24,6 +24,7 @@ import { CAPTION_PLACEHOLDER_ID } from '../ui/CaptionPlaceholder';
24
24
  import { RawIntlProvider } from 'react-intl-next';
25
25
  import { MediaTaskManager } from './mediaTaskManager';
26
26
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
27
+ import { getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
27
28
  export { stateKey } from './plugin-key';
28
29
  export const MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
29
30
  export const MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
@@ -437,6 +438,11 @@ export class MediaPluginStateImplementation {
437
438
  const selectedContainer = this.selectedMediaContainerNode();
438
439
  if (selectedContainer && this.isMediaSchemaNode(selectedContainer)) {
439
440
  newElement = this.getDomElement(this.view.domAtPos.bind(this.view));
441
+ if (selectedContainer.type === this.view.state.schema.nodes.mediaSingle) {
442
+ this.currentMaxWidth = getMaxWidthForNestedNodeNext(this.view, this.view.state.selection.$anchor.pos) || undefined;
443
+ } else {
444
+ this.currentMaxWidth = undefined;
445
+ }
440
446
  }
441
447
  if (this.element !== newElement) {
442
448
  this.element = newElement;
@@ -246,13 +246,9 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
246
246
  var _widthPlugin$sharedSt;
247
247
  const contentWidth = widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
248
248
  const selectedNode = getSelectedMediaSingle(state);
249
- if (selectedNode && contentWidth) {
250
- const {
251
- width
252
- } = selectedNode.node.attrs;
253
- if (width >= contentWidth) {
254
- isChangingLayoutDisabled = true;
255
- }
249
+ const selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
250
+ if (selectedNode && selectedNodeMaxWidth && selectedNode.node.attrs.width >= selectedNodeMaxWidth) {
251
+ isChangingLayoutDisabled = true;
256
252
  }
257
253
  }
258
254
  const layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
@@ -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 };
@@ -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.11";
2
+ export const version = "187.43.13";
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';
@@ -357,7 +357,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
357
357
  origWidth: width,
358
358
  layout: layout,
359
359
  // This will only be used when calculating legacy media single width
360
- // thus we use the legecy value (exclude table as container node)
360
+ // thus we use the legacy value (exclude table as container node)
361
361
  contentWidth: contentWidthForLegacyExperience,
362
362
  containerWidth: containerWidth,
363
363
  gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
@@ -33,6 +33,7 @@ import { CAPTION_PLACEHOLDER_ID } from '../ui/CaptionPlaceholder';
33
33
  import { RawIntlProvider } from 'react-intl-next';
34
34
  import { MediaTaskManager } from './mediaTaskManager';
35
35
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
36
+ import { getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
36
37
  export { stateKey } from './plugin-key';
37
38
  export var MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
38
39
  export var MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
@@ -498,6 +499,11 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
498
499
  var selectedContainer = this.selectedMediaContainerNode();
499
500
  if (selectedContainer && this.isMediaSchemaNode(selectedContainer)) {
500
501
  newElement = this.getDomElement(this.view.domAtPos.bind(this.view));
502
+ if (selectedContainer.type === this.view.state.schema.nodes.mediaSingle) {
503
+ this.currentMaxWidth = getMaxWidthForNestedNodeNext(this.view, this.view.state.selection.$anchor.pos) || undefined;
504
+ } else {
505
+ this.currentMaxWidth = undefined;
506
+ }
501
507
  }
502
508
  if (this.element !== newElement) {
503
509
  this.element = newElement;
@@ -239,11 +239,9 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
239
239
  var _widthPlugin$sharedSt;
240
240
  var contentWidth = widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
241
241
  var selectedNode = getSelectedMediaSingle(state);
242
- if (selectedNode && contentWidth) {
243
- var width = selectedNode.node.attrs.width;
244
- if (width >= contentWidth) {
245
- isChangingLayoutDisabled = true;
246
- }
242
+ var selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
243
+ if (selectedNode && selectedNodeMaxWidth && selectedNode.node.attrs.width >= selectedNodeMaxWidth) {
244
+ isChangingLayoutDisabled = true;
247
245
  }
248
246
  }
249
247
  var layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
@@ -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 };