@atlaskit/editor-core 188.12.0 → 188.12.2

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 (79) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/labs/next/presets/universal.js +12 -1
  3. package/dist/cjs/plugins/annotation/index.js +12 -1
  4. package/dist/cjs/plugins/annotation/pm-plugins/inline-comment.js +2 -1
  5. package/dist/cjs/plugins/annotation/pm-plugins/plugin-factory.js +5 -0
  6. package/dist/cjs/plugins/annotation/pm-plugins/reducer.js +2 -1
  7. package/dist/cjs/plugins/annotation/toolbar.js +2 -156
  8. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +33 -31
  9. package/dist/cjs/plugins/layout/actions.js +20 -17
  10. package/dist/cjs/plugins/layout/index.js +6 -2
  11. package/dist/cjs/plugins/panel/index.js +1 -1
  12. package/dist/cjs/plugins/panel/toolbar.js +9 -7
  13. package/dist/cjs/plugins/paste/plugins/media.js +50 -24
  14. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +0 -6
  15. package/dist/cjs/plugins/paste/pm-plugins/main.js +1 -0
  16. package/dist/cjs/plugins/rank.js +1 -1
  17. package/dist/cjs/plugins/tasks-and-decisions/index.js +1 -1
  18. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +104 -90
  19. package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
  20. package/dist/cjs/version-wrapper.js +1 -1
  21. package/dist/es2019/labs/next/presets/universal.js +12 -1
  22. package/dist/es2019/plugins/annotation/index.js +14 -1
  23. package/dist/es2019/plugins/annotation/pm-plugins/inline-comment.js +2 -1
  24. package/dist/es2019/plugins/annotation/pm-plugins/plugin-factory.js +6 -0
  25. package/dist/es2019/plugins/annotation/pm-plugins/reducer.js +2 -1
  26. package/dist/es2019/plugins/annotation/toolbar.js +1 -156
  27. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
  28. package/dist/es2019/plugins/layout/actions.js +4 -3
  29. package/dist/es2019/plugins/layout/index.js +63 -57
  30. package/dist/es2019/plugins/panel/index.js +1 -1
  31. package/dist/es2019/plugins/panel/toolbar.js +9 -7
  32. package/dist/es2019/plugins/paste/plugins/media.js +53 -25
  33. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +1 -4
  34. package/dist/es2019/plugins/paste/pm-plugins/main.js +4 -5
  35. package/dist/es2019/plugins/rank.js +1 -1
  36. package/dist/es2019/plugins/tasks-and-decisions/index.js +1 -1
  37. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +22 -14
  38. package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
  39. package/dist/es2019/version-wrapper.js +1 -1
  40. package/dist/esm/labs/next/presets/universal.js +12 -1
  41. package/dist/esm/plugins/annotation/index.js +12 -1
  42. package/dist/esm/plugins/annotation/pm-plugins/inline-comment.js +2 -1
  43. package/dist/esm/plugins/annotation/pm-plugins/plugin-factory.js +5 -0
  44. package/dist/esm/plugins/annotation/pm-plugins/reducer.js +2 -1
  45. package/dist/esm/plugins/annotation/toolbar.js +1 -156
  46. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +33 -31
  47. package/dist/esm/plugins/layout/actions.js +15 -12
  48. package/dist/esm/plugins/layout/index.js +7 -3
  49. package/dist/esm/plugins/panel/index.js +1 -1
  50. package/dist/esm/plugins/panel/toolbar.js +9 -7
  51. package/dist/esm/plugins/paste/plugins/media.js +50 -23
  52. package/dist/esm/plugins/paste/pm-plugins/analytics.js +1 -6
  53. package/dist/esm/plugins/paste/pm-plugins/main.js +4 -5
  54. package/dist/esm/plugins/rank.js +1 -1
  55. package/dist/esm/plugins/tasks-and-decisions/index.js +1 -1
  56. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +104 -90
  57. package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
  58. package/dist/esm/version-wrapper.js +1 -1
  59. package/dist/types/plugins/annotation/pm-plugins/types.d.ts +1 -0
  60. package/dist/types/plugins/insert-block/types.d.ts +3 -1
  61. package/dist/types/plugins/layout/actions.d.ts +2 -1
  62. package/dist/types/plugins/layout/index.d.ts +4 -0
  63. package/dist/types/plugins/panel/index.d.ts +2 -2
  64. package/dist/types/plugins/panel/toolbar.d.ts +5 -3
  65. package/dist/types/plugins/paste/plugins/media.d.ts +11 -0
  66. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +0 -1
  67. package/dist/types/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +7 -4
  68. package/dist/types/plugins/tasks-and-decisions/types.d.ts +5 -1
  69. package/dist/types-ts4.5/plugins/annotation/pm-plugins/types.d.ts +1 -0
  70. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +3 -1
  71. package/dist/types-ts4.5/plugins/layout/actions.d.ts +2 -1
  72. package/dist/types-ts4.5/plugins/layout/index.d.ts +4 -0
  73. package/dist/types-ts4.5/plugins/panel/index.d.ts +2 -2
  74. package/dist/types-ts4.5/plugins/panel/toolbar.d.ts +5 -3
  75. package/dist/types-ts4.5/plugins/paste/plugins/media.d.ts +11 -0
  76. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +0 -1
  77. package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +7 -4
  78. package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +3 -1
  79. package/package.json +6 -2
@@ -1,166 +1,11 @@
1
1
  import React from 'react';
2
2
  import CommentIcon from '@atlaskit/icon/glyph/comment';
3
- // AFP-2532 TODO: Fix automatic suppressions below
4
- // eslint-disable-next-line @atlassian/tangerine/import/entry-points
5
3
  import { addInlineComment, ToolTipContent } from '../../keymaps';
6
4
  import { setInlineCommentDraftState } from './commands';
7
5
  import { AnnotationTestIds, AnnotationSelectionType } from './types';
8
6
  import { isSelectionValid } from './utils';
9
7
  import { annotationMessages } from '@atlaskit/editor-common/messages';
10
-
11
- /**
12
- * Returns the coordintes at the bottom the selection.
13
- */
14
- const getCoordsBelowSelection = (bottomCoords, toolbarRect) => {
15
- return {
16
- top: (bottomCoords.top || 0) + toolbarRect.height / 1.15,
17
- left: bottomCoords.right - toolbarRect.width / 2
18
- };
19
- };
20
-
21
- /*
22
- Calculates the position of the floating toolbar relative to the selection.
23
-
24
- This is a re-implementation which closely matches the behaviour on Confluence renderer.
25
- The main difference is the popup is always above the selection.
26
-
27
- Things to consider:
28
- - popup is always above the selection
29
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport (not including scroll offsets)
30
- - popup may appear in '.fabric-editor-popup-scroll-parent' (or body)
31
- - we use the toolbarRect to center align toolbar
32
- - use wrapperBounds to clamp values
33
- - editorView.dom bounds differ to wrapperBounds, convert at the end
34
- */
35
- const calculateToolbarPositionAboveSelection = toolbarTitle => (editorView, nextPos) => {
36
- const toolbar = document.querySelector(`div[aria-label="${toolbarTitle}"]`);
37
- if (!toolbar) {
38
- return nextPos;
39
- }
40
-
41
- // scroll wrapper for full page, fall back to document body
42
- // TODO: look into using getScrollGutterOptions()
43
- const scrollWrapper = editorView.dom.closest('.fabric-editor-popup-scroll-parent') || document.body;
44
- const wrapperBounds = scrollWrapper.getBoundingClientRect();
45
- const selection = window && window.getSelection();
46
- const range = selection && !selection.isCollapsed && selection.getRangeAt(0);
47
- if (!range) {
48
- return nextPos;
49
- }
50
- const toolbarRect = toolbar.getBoundingClientRect();
51
- const {
52
- head,
53
- anchor
54
- } = editorView.state.selection;
55
- const topCoords = editorView.coordsAtPos(Math.min(head, anchor));
56
- const bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
57
- let top = (topCoords.top || 0) - toolbarRect.height * 1.5;
58
- let left = 0;
59
-
60
- // If not on the same line
61
- if (topCoords.top !== bottomCoords.top) {
62
- // selecting downwards
63
- if (head > anchor) {
64
- left = Math.max(topCoords.right, bottomCoords.right);
65
- } else {
66
- left = Math.min(topCoords.left, bottomCoords.left);
67
- }
68
-
69
- /*
70
- short selection above a long paragraph
71
- eg. short {<}heading
72
- The purpose of this text is to show the selection range{>}.
73
- The horizontal positioning should center around "heading",
74
- not where it ends at "range".
75
- Note: if it was "head<b>ing</b>" then it would only center
76
- around "head". Undesireable but matches the current renderer.
77
- */
78
- const cliffPosition = range.getClientRects()[0];
79
- if (cliffPosition.right < left) {
80
- left = cliffPosition.left + cliffPosition.width / 2;
81
- }
82
- } else {
83
- // Otherwise center on the single line selection
84
- left = topCoords.left + (bottomCoords.right - topCoords.left) / 2;
85
- }
86
- left -= toolbarRect.width / 2;
87
-
88
- // Place toolbar below selection if not sufficient space above
89
- if (top < wrapperBounds.top) {
90
- ({
91
- top,
92
- left
93
- } = getCoordsBelowSelection(bottomCoords, toolbarRect));
94
- }
95
-
96
- // remap positions from browser document to wrapperBounds
97
- return {
98
- top: top - wrapperBounds.top + scrollWrapper.scrollTop,
99
- left: Math.max(0, left - wrapperBounds.left)
100
- };
101
- };
102
-
103
- /*
104
- Calculates the position of the floating toolbar relative to the selection.
105
-
106
- This is a re-implementation which closely matches the behaviour on Confluence renderer.
107
- The main difference is the popup is always above the selection.
108
-
109
- Things to consider:
110
- - stick as close to the head X release coordinates as possible
111
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport (not including scroll offsets)
112
- - popup may appear in '.fabric-editor-popup-scroll-parent' (or body)
113
- - we use the toolbarRect to center align toolbar
114
- - use wrapperBounds to clamp values
115
- - editorView.dom bounds differ to wrapperBounds, convert at the end
116
- */
117
- const calculateToolbarPositionTrackHead = toolbarTitle => (editorView, nextPos) => {
118
- const toolbar = document.querySelector(`div[aria-label="${toolbarTitle}"]`);
119
- if (!toolbar) {
120
- return nextPos;
121
- }
122
-
123
- // scroll wrapper for full page, fall back to document body
124
- // TODO: look into using getScrollGutterOptions()
125
- const scrollWrapper = editorView.dom.closest('.fabric-editor-popup-scroll-parent') || document.body;
126
- const wrapperBounds = scrollWrapper.getBoundingClientRect();
127
- const selection = window && window.getSelection();
128
- const range = selection && !selection.isCollapsed && selection.getRangeAt(0);
129
- if (!range) {
130
- return nextPos;
131
- }
132
- const toolbarRect = toolbar.getBoundingClientRect();
133
- const {
134
- head,
135
- anchor
136
- } = editorView.state.selection;
137
- let topCoords = editorView.coordsAtPos(Math.min(head, anchor));
138
- let bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
139
- let top;
140
- // If not the same line, display toolbar below.
141
- if (head > anchor && topCoords.top !== bottomCoords.top) {
142
- // We are taking the previous pos to the maxium, so avoid end of line positions
143
- // returning the next line's rect.
144
- top = (bottomCoords.top || 0) + toolbarRect.height / 1.15;
145
- } else {
146
- top = (topCoords.top || 0) - toolbarRect.height * 1.5;
147
- }
148
- let left = (head > anchor ? bottomCoords.right : topCoords.left) - toolbarRect.width / 2;
149
-
150
- // Place toolbar below selection if not sufficient space above
151
- if (top < wrapperBounds.top) {
152
- ({
153
- top,
154
- left
155
- } = getCoordsBelowSelection(bottomCoords, toolbarRect));
156
- }
157
-
158
- // remap positions from browser document to wrapperBounds
159
- return {
160
- top: top - wrapperBounds.top + scrollWrapper.scrollTop,
161
- left: Math.max(0, left - wrapperBounds.left)
162
- };
163
- };
8
+ import { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
164
9
  export const buildToolbar = (state, intl, isToolbarAbove = false) => {
165
10
  const {
166
11
  schema
@@ -10,7 +10,6 @@ import ToolbarButton from '../../../../ui/ToolbarButton';
10
10
  import { separatorStyles, buttonGroupStyle, wrapperStyle } from '@atlaskit/editor-common/styles';
11
11
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
12
12
  import { showPlaceholderFloatingToolbar } from '../../../placeholder-text/actions';
13
- import { insertLayoutColumnsWithAnalytics } from '../../../layout/actions';
14
13
  import { insertTaskDecisionCommand } from '../../../tasks-and-decisions/commands';
15
14
  import { insertExpand } from '../../../expand/commands';
16
15
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
@@ -206,10 +205,12 @@ export class ToolbarInsertBlock extends React.PureComponent {
206
205
  return true;
207
206
  });
208
207
  _defineProperty(this, "insertLayoutColumns", inputMethod => {
208
+ var _pluginInjectionApi$l;
209
209
  const {
210
- editorView
210
+ editorView,
211
+ pluginInjectionApi
211
212
  } = this.props;
212
- insertLayoutColumnsWithAnalytics(inputMethod)(editorView.state, editorView.dispatch);
213
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$l = pluginInjectionApi.layout) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.insertLayoutColumns(inputMethod)(editorView.state, editorView.dispatch);
213
214
  return true;
214
215
  });
215
216
  _defineProperty(this, "createStatus", inputMethod => {
@@ -3,8 +3,9 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
3
3
  import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { flatmap, mapChildren } from '../../utils/slice';
5
5
  import { getStepRange, isEmptyDocument } from '@atlaskit/editor-common/utils';
6
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics/types/enums';
7
- import { addAnalytics, withAnalytics } from '../analytics/utils';
6
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
7
+ import { addAnalytics } from '../analytics/utils';
8
+ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
8
9
  import { LAYOUT_TYPE } from '../analytics/types/node-events';
9
10
  import { pluginKey } from './pm-plugins/plugin-key';
10
11
  export const ONE_COL_LAYOUTS = ['single'];
@@ -75,7 +76,7 @@ export const insertLayoutColumns = (state, dispatch) => {
75
76
  }
76
77
  return true;
77
78
  };
78
- export const insertLayoutColumnsWithAnalytics = inputMethod => withAnalytics({
79
+ export const insertLayoutColumnsWithAnalytics = editorAnalyticsAPI => inputMethod => withAnalytics(editorAnalyticsAPI, {
79
80
  action: ACTION.INSERTED,
80
81
  actionSubject: ACTION_SUBJECT.DOCUMENT,
81
82
  actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { layoutColumn, layoutSection } from '@atlaskit/adf-schema';
3
3
  import { default as createLayoutPlugin } from './pm-plugins/main';
4
4
  import { buildToolbar } from './toolbar';
5
- import { createDefaultLayoutSection } from './actions';
5
+ import { createDefaultLayoutSection, insertLayoutColumnsWithAnalytics } from './actions';
6
6
  import { IconLayout } from '@atlaskit/editor-common/quick-insert';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
8
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
@@ -11,61 +11,67 @@ export { pluginKey };
11
11
  const layoutPlugin = ({
12
12
  config: options = {},
13
13
  api
14
- }) => ({
15
- name: 'layout',
16
- nodes() {
17
- return [{
18
- name: 'layoutSection',
19
- node: layoutSection
20
- }, {
21
- name: 'layoutColumn',
22
- node: layoutColumn
23
- }];
24
- },
25
- pmPlugins() {
26
- return [{
27
- name: 'layout',
28
- plugin: () => createLayoutPlugin(options)
29
- }];
30
- },
31
- pluginsOptions: {
32
- floatingToolbar(state, intl) {
33
- const {
34
- pos,
35
- allowBreakout,
36
- addSidebarLayouts,
37
- allowSingleColumnLayout
38
- } = pluginKey.getState(state);
39
- if (pos !== null) {
40
- var _api$decorations$acti;
41
- return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api === null || api === void 0 ? void 0 : (_api$decorations$acti = api.decorations.actions) === null || _api$decorations$acti === void 0 ? void 0 : _api$decorations$acti.hoverDecoration);
42
- }
43
- return undefined;
14
+ }) => {
15
+ var _api$analytics;
16
+ return {
17
+ name: 'layout',
18
+ nodes() {
19
+ return [{
20
+ name: 'layoutSection',
21
+ node: layoutSection
22
+ }, {
23
+ name: 'layoutColumn',
24
+ node: layoutColumn
25
+ }];
44
26
  },
45
- quickInsert: ({
46
- formatMessage
47
- }) => [{
48
- id: 'layout',
49
- title: formatMessage(messages.columns),
50
- description: formatMessage(messages.columnsDescription),
51
- keywords: ['column', 'section'],
52
- priority: 1100,
53
- icon: () => /*#__PURE__*/React.createElement(IconLayout, null),
54
- action(insert, state) {
55
- var _api$analytics, _api$analytics$action;
56
- const tr = insert(createDefaultLayoutSection(state));
57
- api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent({
58
- action: ACTION.INSERTED,
59
- actionSubject: ACTION_SUBJECT.DOCUMENT,
60
- actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
61
- attributes: {
62
- inputMethod: INPUT_METHOD.QUICK_INSERT
63
- },
64
- eventType: EVENT_TYPE.TRACK
65
- })(tr);
66
- return tr;
67
- }
68
- }]
69
- }
70
- });
27
+ pmPlugins() {
28
+ return [{
29
+ name: 'layout',
30
+ plugin: () => createLayoutPlugin(options)
31
+ }];
32
+ },
33
+ actions: {
34
+ insertLayoutColumns: insertLayoutColumnsWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
35
+ },
36
+ pluginsOptions: {
37
+ floatingToolbar(state, intl) {
38
+ const {
39
+ pos,
40
+ allowBreakout,
41
+ addSidebarLayouts,
42
+ allowSingleColumnLayout
43
+ } = pluginKey.getState(state);
44
+ if (pos !== null) {
45
+ var _api$decorations$acti;
46
+ return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api === null || api === void 0 ? void 0 : (_api$decorations$acti = api.decorations.actions) === null || _api$decorations$acti === void 0 ? void 0 : _api$decorations$acti.hoverDecoration);
47
+ }
48
+ return undefined;
49
+ },
50
+ quickInsert: ({
51
+ formatMessage
52
+ }) => [{
53
+ id: 'layout',
54
+ title: formatMessage(messages.columns),
55
+ description: formatMessage(messages.columnsDescription),
56
+ keywords: ['column', 'section'],
57
+ priority: 1100,
58
+ icon: () => /*#__PURE__*/React.createElement(IconLayout, null),
59
+ action(insert, state) {
60
+ var _api$analytics2, _api$analytics2$actio;
61
+ const tr = insert(createDefaultLayoutSection(state));
62
+ api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : (_api$analytics2$actio = _api$analytics2.actions) === null || _api$analytics2$actio === void 0 ? void 0 : _api$analytics2$actio.attachAnalyticsEvent({
63
+ action: ACTION.INSERTED,
64
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
65
+ actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
66
+ attributes: {
67
+ inputMethod: INPUT_METHOD.QUICK_INSERT
68
+ },
69
+ eventType: EVENT_TYPE.TRACK
70
+ })(tr);
71
+ return tr;
72
+ }
73
+ }]
74
+ }
75
+ };
76
+ };
71
77
  export default layoutPlugin;
@@ -142,7 +142,7 @@ const panelPlugin = ({
142
142
  }
143
143
  return quickInsertOptions;
144
144
  },
145
- floatingToolbar: (state, intl, providerFactory) => getToolbarConfig(state, intl, options, providerFactory, api === null || api === void 0 ? void 0 : api.decorations.actions.hoverDecoration)
145
+ floatingToolbar: (state, intl, providerFactory) => getToolbarConfig(state, intl, options, providerFactory, api)
146
146
  }
147
147
  });
148
148
 
@@ -13,7 +13,8 @@ import { findPanel } from './utils';
13
13
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
14
14
  import { DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
15
15
  import { PanelType } from '@atlaskit/adf-schema';
16
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, withAnalytics } from '../analytics';
16
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
17
+ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
17
18
  import { messages } from './message';
18
19
  export const panelIconMap = {
19
20
  [PanelType.INFO]: {
@@ -41,7 +42,7 @@ export const panelIconMap = {
41
42
  id: 'atlassian-tip'
42
43
  }
43
44
  };
44
- export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, hoverDecoration, activePanelType, activePanelColor, activePanelIcon, state) => {
45
+ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, hoverDecoration, editorAnalyticsAPI, activePanelType, activePanelColor, activePanelIcon, state) => {
45
46
  // TODO: ED-14403 investigate why these titles are not getting translated for the tooltips
46
47
  const items = [{
47
48
  id: 'editor.panel.info',
@@ -114,7 +115,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
114
115
  },
115
116
  eventType: EVENT_TYPE.TRACK
116
117
  };
117
- withAnalytics(payload)(changePanelType(PanelType.CUSTOM, {
118
+ withAnalytics(editorAnalyticsAPI, payload)(changePanelType(PanelType.CUSTOM, {
118
119
  color,
119
120
  ...previousEmoji
120
121
  }, isCustomPanelEnabled))(state, dispatch);
@@ -144,7 +145,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
144
145
  },
145
146
  eventType: EVENT_TYPE.TRACK
146
147
  };
147
- withAnalytics(payload)(changePanelType(PanelType.CUSTOM, {
148
+ withAnalytics(editorAnalyticsAPI, payload)(changePanelType(PanelType.CUSTOM, {
148
149
  emoji: emoji.shortName,
149
150
  emojiId: emoji.id,
150
151
  emojiText: emoji.fallback
@@ -168,7 +169,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
168
169
  },
169
170
  eventType: EVENT_TYPE.TRACK
170
171
  };
171
- withAnalytics(payload)(changePanelType(PanelType.CUSTOM, {
172
+ withAnalytics(editorAnalyticsAPI, payload)(changePanelType(PanelType.CUSTOM, {
172
173
  emoji: undefined,
173
174
  emojiId: undefined,
174
175
  emojiText: undefined
@@ -243,12 +244,13 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
243
244
  });
244
245
  return items;
245
246
  };
246
- export const getToolbarConfig = (state, intl, options = {}, providerFactory, hoverDecoration) => {
247
+ export const getToolbarConfig = (state, intl, options = {}, providerFactory, api) => {
247
248
  const {
248
249
  formatMessage
249
250
  } = intl;
250
251
  const panelObject = findPanel(state);
251
252
  if (panelObject) {
253
+ var _api$analytics;
252
254
  const nodeType = state.schema.nodes.panel;
253
255
  const {
254
256
  panelType,
@@ -260,7 +262,7 @@ export const getToolbarConfig = (state, intl, options = {}, providerFactory, hov
260
262
  };
261
263
 
262
264
  // force toolbar to be turned on
263
- const items = getToolbarItems(formatMessage, nodeType, options.allowCustomPanel || false, options.allowCustomPanel && options.allowCustomPanelEdit || false, providerFactory, hoverDecoration, panelType, options.allowCustomPanel ? panelColor : undefined, options.allowCustomPanel ? panelIcon || isStandardPanel(panelType) : undefined, state);
265
+ const items = getToolbarItems(formatMessage, nodeType, options.allowCustomPanel || false, options.allowCustomPanel && options.allowCustomPanelEdit || false, providerFactory, api === null || api === void 0 ? void 0 : api.decorations.actions.hoverDecoration, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, panelType, options.allowCustomPanel ? panelColor : undefined, options.allowCustomPanel ? panelIcon || isStandardPanel(panelType) : undefined, state);
264
266
  const getDomRef = editorView => {
265
267
  const domAtPos = editorView.domAtPos.bind(editorView);
266
268
  const element = findDomRefAtPos(panelObject.pos, domAtPos);
@@ -2,6 +2,13 @@ import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
2
2
  import { mapSlice, unwrap, removeNestedEmptyEls, walkUpTreeUntil } from '@atlaskit/editor-common/utils';
3
3
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
4
  import { getRandomHex } from '@atlaskit/media-common';
5
+ import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
6
+
7
+ /**
8
+ * Ensure correct layout in nested mode
9
+ *
10
+ * TODO: this func is only used in handlePaste, so layout update won't work for drop event
11
+ */
5
12
  export function transformSliceForMedia(slice, schema) {
6
13
  const {
7
14
  mediaSingle,
@@ -9,8 +16,6 @@ export function transformSliceForMedia(slice, schema) {
9
16
  table,
10
17
  bulletList,
11
18
  orderedList,
12
- media,
13
- mediaInline,
14
19
  expand,
15
20
  nestedExpand
16
21
  } = schema.nodes;
@@ -41,29 +46,6 @@ export function transformSliceForMedia(slice, schema) {
41
46
  return node.type.name === 'mediaSingle' ? mediaSingle.createChecked(attrs, node.content, node.marks) : node;
42
47
  });
43
48
  }
44
- const __mediaTraceId = getRandomHex(8);
45
- newSlice = mapSlice(newSlice, node => {
46
- // This logic is duplicated in editor-plugin-ai where external images can be inserted
47
- // from external sources through the use of AI. The editor-plugin-ai package is avoiding
48
- // sharing dependencies with editor-core to support products using it with various versions
49
- // of editor packages.
50
- // The duplication is in the following file:
51
- // packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
52
- if (node.type.name === 'media') {
53
- return media.createChecked({
54
- ...node.attrs,
55
- __external: node.attrs.type === 'external',
56
- __mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
57
- }, node.content, node.marks);
58
- }
59
- if (node.type.name === 'mediaInline') {
60
- return mediaInline.createChecked({
61
- ...node.attrs,
62
- __mediaTraceId
63
- }, node.content, node.marks);
64
- }
65
- return node;
66
- });
67
49
  return newSlice;
68
50
  };
69
51
  }
@@ -90,6 +72,52 @@ export const transformSliceToCorrectMediaWrapper = (slice, schema) => {
90
72
  });
91
73
  };
92
74
 
75
+ /**
76
+ * This func will be called when copy & paste, drag & drop external html with media, media files, and slices from editor
77
+ * Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
78
+ *
79
+ */
80
+ export const transformSliceToMediaSingleWithNewExperience = (slice, schema) => {
81
+ const {
82
+ mediaInline,
83
+ mediaSingle,
84
+ media
85
+ } = schema.nodes;
86
+ const newSlice = mapSlice(slice, node => {
87
+ // This logic is duplicated in editor-plugin-ai where external images can be inserted
88
+ // from external sources through the use of AI. The editor-plugin-ai package is avoiding
89
+ // sharing dependencies with editor-core to support products using it with various versions
90
+ // of editor packages.
91
+ // The duplication is in the following file:
92
+ // packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
93
+ if (node.type === mediaSingle) {
94
+ return getBooleanFF('platform.editor.media.extended-resize-experience') ? mediaSingle.createChecked({
95
+ width: node.attrs.width || DEFAULT_IMAGE_WIDTH,
96
+ widthType: node.attrs.widthType || 'pixel',
97
+ layout: node.attrs.layout
98
+ }, node.content, node.marks) : node;
99
+ }
100
+ return node;
101
+ });
102
+ return mapSlice(newSlice, node => {
103
+ const __mediaTraceId = getRandomHex(8);
104
+ if (node.type === media) {
105
+ return media.createChecked({
106
+ ...node.attrs,
107
+ __external: node.attrs.type === 'external',
108
+ __mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
109
+ }, node.content, node.marks);
110
+ }
111
+ if (node.type.name === 'mediaInline') {
112
+ return mediaInline.createChecked({
113
+ ...node.attrs,
114
+ __mediaTraceId
115
+ }, node.content, node.marks);
116
+ }
117
+ return node;
118
+ });
119
+ };
120
+
93
121
  /**
94
122
  * Check base styles to see if an element will be invisible when rendered in a document.
95
123
  * @param element
@@ -1,4 +1,4 @@
1
- import { ACTION, INPUT_METHOD, EVENT_TYPE, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, PasteTypes, PasteContents, withAnalytics } from '../../analytics';
1
+ import { ACTION, INPUT_METHOD, EVENT_TYPE, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, PasteTypes, PasteContents } from '../../analytics';
2
2
  import { getPasteSource } from '../util';
3
3
  import { handlePasteAsPlainText, handlePasteIntoTaskOrDecisionOrPanel, handleCodeBlock, handleMediaSingle, handlePastePreservingMarks, handleMarkdown, handleRichText, handleExpandPasteInTable, handleSelectedTable, handlePasteLinkOnSelectedText, handlePasteIntoCaption, handlePastePanelOrDecisionContentIntoList, handlePasteNonNestableBlockNodesIntoList } from '../handlers';
4
4
  import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
@@ -219,9 +219,6 @@ export function sendPasteAnalyticsEvent(view, event, slice, pasteContext) {
219
219
  const payload = createPasteAnalyticsPayload(view, event, slice, pasteContext);
220
220
  view.dispatch(addAnalytics(view.state, view.state.tr, payload));
221
221
  }
222
- export function pasteCommandWithAnalytics(view, event, slice, pasteContext) {
223
- return withAnalytics(() => createPasteAnalyticsPayload(view, event, slice, pasteContext));
224
- }
225
222
  export const handlePasteAsPlainTextWithAnalytics = (view, event, slice) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
226
223
  type: PasteTypes.plain,
227
224
  asPlain: true
@@ -5,19 +5,17 @@ import { MarkdownTransformer } from '@atlaskit/editor-markdown-transformer';
5
5
  import { addLinkMetadata } from '@atlaskit/editor-common/card';
6
6
  import { mapChildren } from '../../../utils/slice';
7
7
  import { getExtensionAutoConvertersFromProvider } from '@atlaskit/editor-common/extensions';
8
- import { isPastedFile as isPastedFileFromEvent } from '@atlaskit/editor-common/paste';
9
- import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, unwrapNestedMediaElements } from '../plugins/media';
8
+ import { isPastedFile as isPastedFileFromEvent, md } from '@atlaskit/editor-common/paste';
9
+ import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, transformSliceToMediaSingleWithNewExperience, unwrapNestedMediaElements } from '../plugins/media';
10
10
  import { escapeLinks, htmlContainsSingleFile, isPastedFromWord, isPastedFromExcel, htmlHasInvalidLinkTags, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from '../util';
11
- import { linkifyContent } from '@atlaskit/editor-common/utils';
11
+ import { linkifyContent, measureRender } from '@atlaskit/editor-common/utils';
12
12
  import { transformSliceNestedExpandToExpand } from '../../expand/utils';
13
13
  import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks } from '../handlers';
14
14
  import { transformSliceToJoinAdjacentCodeBlocks, transformSingleLineCodeBlockToCodeMark } from '../../code-block/utils';
15
15
  import { createPasteMeasurePayload, getContentNodeTypes, handlePasteAsPlainTextWithAnalytics, handlePasteIntoTaskAndDecisionWithAnalytics, handleCodeBlockWithAnalytics, handleMediaSingleWithAnalytics, handlePastePreservingMarksWithAnalytics, handleMarkdownWithAnalytics, handleRichTextWithAnalytics, handleExpandWithAnalytics, handleSelectedTableWithAnalytics, handlePasteLinkOnSelectedTextWithAnalytics, sendPasteAnalyticsEvent, handlePasteIntoCaptionWithAnalytics, handlePastePanelOrDecisionIntoListWithAnalytics, handlePasteNonNestableBlockNodesIntoListWithAnalytics } from './analytics';
16
16
  import { ACTION, analyticsPluginKey, INPUT_METHOD, PasteTypes } from '../../analytics';
17
17
  import { isInsideBlockQuote, insideTable, measurements } from '../../../utils';
18
- import { measureRender } from '@atlaskit/editor-common/utils';
19
18
  import { upgradeTextToLists, splitParagraphs } from '../commands';
20
- import { md } from '@atlaskit/editor-common/paste';
21
19
  import { transformSliceToDecisionList } from '../../tasks-and-decisions/utils';
22
20
  import { containsAnyAnnotations, stripNonExistingAnnotations } from '../../annotation/utils';
23
21
  import { clipboardTextSerializer } from './clipboard-text-serializer';
@@ -365,6 +363,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
365
363
  }
366
364
  slice = transformSingleLineCodeBlockToCodeMark(slice, schema);
367
365
  slice = transformSliceToCorrectMediaWrapper(slice, schema);
366
+ slice = transformSliceToMediaSingleWithNewExperience(slice, schema);
368
367
  slice = transformSliceToDecisionList(slice, schema);
369
368
 
370
369
  // splitting linebreaks into paragraphs must happen before upgrading text to lists
@@ -13,7 +13,7 @@ export default {
13
13
  'mediaKeymap',
14
14
  // selection keymap needs to be above gap cursor keymap so it can set node selections from
15
15
  // left/right arrows
16
- 'selectionKeymap', 'gapCursorKeymap', 'gapCursor', 'syncUrlText', 'fakeCursorToolbarPlugin', 'hyperLink', 'table', 'tableDecorations', 'hyperlinkInputRule', 'tablePMColResizing', 'hyperlinkKeymap', 'tableColResizing', 'undoRedoKeyMap', 'blockTypeKeyMap', 'tableEditing', 'filterStepsPlugin', 'pmCollab', 'collab', 'ruleInputRule', 'ruleKeymap', 'panel', 'media', 'mediaSingleKeymap', 'mediaEditor', 'unsupportedContent', 'jiraIssue', 'fakeTextCursor', 'helpDialog', 'helpDialogKeymap', 'macro', 'expand', 'extension', 'layout', 'contextPanel', 'floatingToolbar', 'clearMarksOnChange', 'reactNodeView', 'history', 'undoRedoPlugin', 'codeBlockIndent', 'placeholder', 'width', 'maxContentSize', 'multilineContent', 'grid', 'mobileDimensions', 'scrollGutterPlugin', 'analytics', 'findReplace', 'selection', 'avatarGroup', 'viewUpdateSubscription', 'beforePrimaryToolbar', 'inlineCode'],
16
+ 'selectionKeymap', 'gapCursorKeymap', 'gapCursor', 'syncUrlText', 'fakeCursorToolbarPlugin', 'hyperLink', 'table', 'tableDecorations', 'hyperlinkInputRule', 'tablePMColResizing', 'hyperlinkKeymap', 'tableColResizing', 'undoRedoKeyMap', 'blockTypeKeyMap', 'tableEditing', 'filterStepsPlugin', 'pmCollab', 'collab', 'ruleInputRule', 'ruleKeymap', 'panel', 'media', 'mediaSingleKeymap', 'mediaEditor', 'unsupportedContent', 'jiraIssue', 'fakeTextCursor', 'helpDialog', 'helpDialogKeymap', 'macro', 'expand', 'extension', 'layout', 'contextPanel', 'selectionToolbar', 'floatingToolbar', 'clearMarksOnChange', 'reactNodeView', 'history', 'undoRedoPlugin', 'codeBlockIndent', 'placeholder', 'width', 'maxContentSize', 'multilineContent', 'grid', 'mobileDimensions', 'scrollGutterPlugin', 'analytics', 'findReplace', 'selection', 'avatarGroup', 'viewUpdateSubscription', 'beforePrimaryToolbar', 'inlineCode'],
17
17
  nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'rule', 'panel', 'mention', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'unsupportedBlock', 'unsupportedInline', 'confluenceJiraIssue', 'hardBreak', 'emoji', 'placeholder', 'mediaSingle', 'mediaGroup', 'table', 'expand', 'nestedExpand', 'media', 'tableHeader', 'decisionList', 'tableRow', 'decisionItem', 'tableCell', 'taskList', 'taskItem', 'extension', 'bodiedExtension', 'inlineExtension', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard'],
18
18
  marks: [
19
19
  // Fragment mark is both for inline and block elements
@@ -72,7 +72,7 @@ const tasksAndDecisionsPlugin = ({
72
72
  name: 'tasksAndDecisionsKeyMap',
73
73
  plugin: ({
74
74
  schema
75
- }) => keymap(schema, allowNestedTasks, consumeTabs)
75
+ }) => keymap(schema, api, allowNestedTasks, consumeTabs)
76
76
  } // Needs to be after "save-on-enter"
77
77
  ];
78
78
  },