@atlaskit/editor-core 187.14.9 → 187.14.12

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 (55) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/floating-toolbar/ui/Separator.js +2 -13
  3. package/dist/cjs/plugins/media/commands/captions.js +29 -27
  4. package/dist/cjs/plugins/media/commands/linking.js +21 -17
  5. package/dist/cjs/plugins/media/index.js +4 -3
  6. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +4 -2
  7. package/dist/cjs/plugins/media/pm-plugins/keymap.js +17 -15
  8. package/dist/cjs/plugins/media/pm-plugins/main.js +7 -5
  9. package/dist/cjs/plugins/media/toolbar/commands.js +149 -141
  10. package/dist/cjs/plugins/media/toolbar/index.js +20 -16
  11. package/dist/cjs/plugins/media/toolbar/linking.js +4 -3
  12. package/dist/cjs/plugins/media/utils/media-files.js +78 -75
  13. package/dist/cjs/version-wrapper.js +1 -1
  14. package/dist/cjs/version.json +1 -1
  15. package/dist/es2019/plugins/floating-toolbar/ui/Separator.js +2 -14
  16. package/dist/es2019/plugins/media/commands/captions.js +4 -4
  17. package/dist/es2019/plugins/media/commands/linking.js +12 -11
  18. package/dist/es2019/plugins/media/index.js +6 -3
  19. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +4 -2
  20. package/dist/es2019/plugins/media/pm-plugins/keymap.js +5 -5
  21. package/dist/es2019/plugins/media/pm-plugins/main.js +7 -5
  22. package/dist/es2019/plugins/media/toolbar/commands.js +15 -15
  23. package/dist/es2019/plugins/media/toolbar/index.js +20 -16
  24. package/dist/es2019/plugins/media/toolbar/linking.js +6 -3
  25. package/dist/es2019/plugins/media/utils/media-files.js +5 -6
  26. package/dist/es2019/version-wrapper.js +1 -1
  27. package/dist/es2019/version.json +1 -1
  28. package/dist/esm/plugins/floating-toolbar/ui/Separator.js +2 -12
  29. package/dist/esm/plugins/media/commands/captions.js +29 -27
  30. package/dist/esm/plugins/media/commands/linking.js +21 -17
  31. package/dist/esm/plugins/media/index.js +4 -3
  32. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +4 -2
  33. package/dist/esm/plugins/media/pm-plugins/keymap.js +17 -15
  34. package/dist/esm/plugins/media/pm-plugins/main.js +7 -5
  35. package/dist/esm/plugins/media/toolbar/commands.js +148 -140
  36. package/dist/esm/plugins/media/toolbar/index.js +20 -16
  37. package/dist/esm/plugins/media/toolbar/linking.js +4 -3
  38. package/dist/esm/plugins/media/utils/media-files.js +78 -75
  39. package/dist/esm/version-wrapper.js +1 -1
  40. package/dist/esm/version.json +1 -1
  41. package/dist/types/plugins/floating-toolbar/ui/Separator.d.ts +2 -4
  42. package/dist/types/plugins/media/commands/captions.d.ts +2 -1
  43. package/dist/types/plugins/media/commands/linking.d.ts +3 -3
  44. package/dist/types/plugins/media/pm-plugins/keymap.d.ts +2 -1
  45. package/dist/types/plugins/media/pm-plugins/main.d.ts +1 -1
  46. package/dist/types/plugins/media/toolbar/commands.d.ts +5 -4
  47. package/dist/types/plugins/media/utils/media-files.d.ts +3 -2
  48. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Separator.d.ts +2 -4
  49. package/dist/types-ts4.5/plugins/media/commands/captions.d.ts +2 -1
  50. package/dist/types-ts4.5/plugins/media/commands/linking.d.ts +3 -3
  51. package/dist/types-ts4.5/plugins/media/pm-plugins/keymap.d.ts +2 -1
  52. package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +1 -1
  53. package/dist/types-ts4.5/plugins/media/toolbar/commands.d.ts +5 -4
  54. package/dist/types-ts4.5/plugins/media/utils/media-files.d.ts +3 -2
  55. package/package.json +4 -4
@@ -11,7 +11,6 @@ var _mediaCommon = require("./media-common");
11
11
  var _utils3 = require("@atlaskit/editor-prosemirror/utils");
12
12
  var _position = require("../../../utils/prosemirror/position");
13
13
  var _analytics = require("@atlaskit/editor-common/analytics");
14
- var _analytics2 = require("../../analytics");
15
14
  var canInsertMediaInline = function canInsertMediaInline(state) {
16
15
  var node = state.schema.nodes.mediaInline.create({});
17
16
  return (0, _utils3.canInsert)(state.selection.$to, _model.Fragment.from(node));
@@ -79,41 +78,43 @@ function shouldAppendParagraph(state, node) {
79
78
  * @param mediaState Media file to be added to the editor
80
79
  * @param collection Collection for the media to be added
81
80
  */
82
- var insertMediaInlineNode = function insertMediaInlineNode(view, mediaState, collection, inputMethod) {
83
- var state = view.state,
84
- dispatch = view.dispatch;
85
- var schema = state.schema,
86
- tr = state.tr;
87
- var mediaInline = schema.nodes.mediaInline;
81
+ var insertMediaInlineNode = function insertMediaInlineNode(editorAnalyticsAPI) {
82
+ return function (view, mediaState, collection, inputMethod) {
83
+ var state = view.state,
84
+ dispatch = view.dispatch;
85
+ var schema = state.schema,
86
+ tr = state.tr;
87
+ var mediaInline = schema.nodes.mediaInline;
88
88
 
89
- // Do nothing if no media found
90
- if (!mediaInline || !mediaState || collection === undefined) {
91
- return false;
92
- }
93
- var id = mediaState.id;
94
- var mediaInlineNode = mediaInline.create({
95
- id: id,
96
- collection: collection
97
- });
98
- var space = state.schema.text(' ');
99
- var pos = state.selection.$to.pos;
89
+ // Do nothing if no media found
90
+ if (!mediaInline || !mediaState || collection === undefined) {
91
+ return false;
92
+ }
93
+ var id = mediaState.id;
94
+ var mediaInlineNode = mediaInline.create({
95
+ id: id,
96
+ collection: collection
97
+ });
98
+ var space = state.schema.text(' ');
99
+ var pos = state.selection.$to.pos;
100
100
 
101
- // If the selection is inside an empty list item set pos inside paragraph
102
- if ((0, _utils.isInListItem)(state) && (0, _mediaCommon.isInsidePotentialEmptyParagraph)(state)) {
103
- pos = pos + 1;
104
- }
105
- var content = _model.Fragment.from([mediaInlineNode, space]);
101
+ // If the selection is inside an empty list item set pos inside paragraph
102
+ if ((0, _utils.isInListItem)(state) && (0, _mediaCommon.isInsidePotentialEmptyParagraph)(state)) {
103
+ pos = pos + 1;
104
+ }
105
+ var content = _model.Fragment.from([mediaInlineNode, space]);
106
106
 
107
- // Delete the selection if a selection is made
108
- var deleteRange = findDeleteRange(state);
109
- if (!deleteRange) {
110
- tr.insert(pos, content);
111
- } else {
112
- tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
113
- }
114
- (0, _analytics2.addAnalytics)(state, tr, getInsertMediaInlineAnalytics(mediaState, inputMethod));
115
- dispatch(tr);
116
- return true;
107
+ // Delete the selection if a selection is made
108
+ var deleteRange = findDeleteRange(state);
109
+ if (!deleteRange) {
110
+ tr.insert(pos, content);
111
+ } else {
112
+ tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
113
+ }
114
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaInlineAnalytics(mediaState, inputMethod))(tr);
115
+ dispatch(tr);
116
+ return true;
117
+ };
117
118
  };
118
119
 
119
120
  /**
@@ -124,51 +125,53 @@ var insertMediaInlineNode = function insertMediaInlineNode(view, mediaState, col
124
125
  * @param collection Collection for the media to be added
125
126
  */
126
127
  exports.insertMediaInlineNode = insertMediaInlineNode;
127
- var insertMediaGroupNode = function insertMediaGroupNode(view, mediaStates, collection, inputMethod) {
128
- var state = view.state,
129
- dispatch = view.dispatch;
130
- var tr = state.tr,
131
- schema = state.schema;
132
- var _schema$nodes = schema.nodes,
133
- media = _schema$nodes.media,
134
- paragraph = _schema$nodes.paragraph;
128
+ var insertMediaGroupNode = function insertMediaGroupNode(editorAnalyticsAPI) {
129
+ return function (view, mediaStates, collection, inputMethod) {
130
+ var state = view.state,
131
+ dispatch = view.dispatch;
132
+ var tr = state.tr,
133
+ schema = state.schema;
134
+ var _schema$nodes = schema.nodes,
135
+ media = _schema$nodes.media,
136
+ paragraph = _schema$nodes.paragraph;
135
137
 
136
- // Do nothing if no media found
137
- if (!media || !mediaStates.length) {
138
- return;
139
- }
140
- var mediaNodes = createMediaFileNodes(mediaStates, collection, media);
141
- var mediaInsertPos = findMediaInsertPos(state);
142
- var resolvedInsertPos = tr.doc.resolve(mediaInsertPos);
143
- var parent = resolvedInsertPos.parent;
144
- var nodeAtInsertionPoint = tr.doc.nodeAt(mediaInsertPos);
145
- var shouldSplit = !isSelectionMediaGroup(state) && (0, _utils2.isSupportedInParent)(state, _model.Fragment.from(state.schema.nodes.mediaGroup.createChecked({}, mediaNodes)));
146
- var withParagraph = shouldAppendParagraph(state, nodeAtInsertionPoint);
147
- var content = parent.type === schema.nodes.mediaGroup ? mediaNodes // If parent is a mediaGroup do not wrap items again.
148
- : [schema.nodes.mediaGroup.createChecked({}, mediaNodes)];
149
- if (shouldSplit) {
150
- content = withParagraph ? content.concat(paragraph.create()) : content;
151
- // delete the selection or empty paragraph
152
- var deleteRange = findDeleteRange(state);
153
- if (!deleteRange) {
154
- tr.insert(mediaInsertPos, content);
155
- } else if (mediaInsertPos <= deleteRange.start) {
156
- tr.deleteRange(deleteRange.start, deleteRange.end).insert(mediaInsertPos, content);
157
- } else {
158
- tr.insert(mediaInsertPos, content).deleteRange(deleteRange.start, deleteRange.end);
138
+ // Do nothing if no media found
139
+ if (!media || !mediaStates.length) {
140
+ return;
141
+ }
142
+ var mediaNodes = createMediaFileNodes(mediaStates, collection, media);
143
+ var mediaInsertPos = findMediaInsertPos(state);
144
+ var resolvedInsertPos = tr.doc.resolve(mediaInsertPos);
145
+ var parent = resolvedInsertPos.parent;
146
+ var nodeAtInsertionPoint = tr.doc.nodeAt(mediaInsertPos);
147
+ var shouldSplit = !isSelectionMediaGroup(state) && (0, _utils2.isSupportedInParent)(state, _model.Fragment.from(state.schema.nodes.mediaGroup.createChecked({}, mediaNodes)));
148
+ var withParagraph = shouldAppendParagraph(state, nodeAtInsertionPoint);
149
+ var content = parent.type === schema.nodes.mediaGroup ? mediaNodes // If parent is a mediaGroup do not wrap items again.
150
+ : [schema.nodes.mediaGroup.createChecked({}, mediaNodes)];
151
+ if (shouldSplit) {
152
+ content = withParagraph ? content.concat(paragraph.create()) : content;
153
+ // delete the selection or empty paragraph
154
+ var deleteRange = findDeleteRange(state);
155
+ if (!deleteRange) {
156
+ tr.insert(mediaInsertPos, content);
157
+ } else if (mediaInsertPos <= deleteRange.start) {
158
+ tr.deleteRange(deleteRange.start, deleteRange.end).insert(mediaInsertPos, content);
159
+ } else {
160
+ tr.insert(mediaInsertPos, content).deleteRange(deleteRange.start, deleteRange.end);
161
+ }
162
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaGroupAnalytics(mediaStates, inputMethod))(tr);
163
+ dispatch(tr);
164
+ setSelectionAfterMediaInsertion(view);
165
+ return;
159
166
  }
160
- (0, _analytics2.addAnalytics)(state, tr, getInsertMediaGroupAnalytics(mediaStates, inputMethod));
161
- dispatch(tr);
162
- setSelectionAfterMediaInsertion(view);
163
- return;
164
- }
165
167
 
166
- // Don't append new paragraph when adding media to a existing mediaGroup
167
- if (withParagraph && parent.type !== schema.nodes.mediaGroup) {
168
- content.push(paragraph.create());
169
- }
170
- (0, _analytics2.addAnalytics)(state, tr, getInsertMediaGroupAnalytics(mediaStates, inputMethod));
171
- dispatch((0, _utils3.safeInsert)(_model.Fragment.fromArray(content), mediaInsertPos)(tr));
168
+ // Don't append new paragraph when adding media to a existing mediaGroup
169
+ if (withParagraph && parent.type !== schema.nodes.mediaGroup) {
170
+ content.push(paragraph.create());
171
+ }
172
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaGroupAnalytics(mediaStates, inputMethod))(tr);
173
+ dispatch((0, _utils3.safeInsert)(_model.Fragment.fromArray(content), mediaInsertPos)(tr));
174
+ };
172
175
  };
173
176
  exports.insertMediaGroupNode = insertMediaGroupNode;
174
177
  var createMediaFileNodes = function createMediaFileNodes(mediaStates, collection, media) {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "187.14.9";
9
+ var version = "187.14.12";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.14.9",
3
+ "version": "187.14.12",
4
4
  "sideEffects": false
5
5
  }
@@ -1,14 +1,2 @@
1
- /** @jsx jsx */
2
- import { css, jsx } from '@emotion/react';
3
- import { N30 } from '@atlaskit/theme/colors';
4
- const separator = css`
5
- background: ${`var(--ds-border, ${N30})`};
6
- width: 1px;
7
- height: 20px;
8
- margin: 0 4px;
9
- align-self: center;
10
- `;
11
- export default (() => jsx("div", {
12
- css: separator,
13
- className: "separator"
14
- }));
1
+ import { FloatingToolbarSeparator } from '@atlaskit/editor-common/ui';
2
+ export default FloatingToolbarSeparator;
@@ -1,5 +1,5 @@
1
1
  import { setTextSelection } from '@atlaskit/editor-prosemirror/utils';
2
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE } from '../../analytics';
2
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
3
  export const selectCaptionFromMediaSinglePos = (mediaSingleNodePos, mediaSingleNode) => (state, dispatch) => {
4
4
  // node should have two children, media and caption
5
5
  if (mediaSingleNode.childCount !== 2) {
@@ -15,7 +15,7 @@ export const selectCaptionFromMediaSinglePos = (mediaSingleNodePos, mediaSingleN
15
15
  }
16
16
  return true;
17
17
  };
18
- export const insertAndSelectCaptionFromMediaSinglePos = (mediaSingleNodePos, mediaSingleNode) => (state, dispatch) => {
18
+ export const insertAndSelectCaptionFromMediaSinglePos = editorAnalyticsAPI => (mediaSingleNodePos, mediaSingleNode) => (state, dispatch) => {
19
19
  if (typeof mediaSingleNodePos !== 'number') {
20
20
  return false;
21
21
  }
@@ -32,12 +32,12 @@ export const insertAndSelectCaptionFromMediaSinglePos = (mediaSingleNodePos, med
32
32
  tr = state.tr.insert(mediaSingleNodePos + media.nodeSize + 1, caption);
33
33
  tr = setSelectionAtEndOfCaption(tr, mediaSingleNodePos, media.nodeSize, caption.nodeSize);
34
34
  tr.setMeta('scrollIntoView', false);
35
- addAnalytics(state, tr, {
35
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
36
36
  action: ACTION.ADDED,
37
37
  eventType: EVENT_TYPE.TRACK,
38
38
  actionSubject: ACTION_SUBJECT.MEDIA_SINGLE,
39
39
  actionSubjectId: ACTION_SUBJECT_ID.CAPTION
40
- });
40
+ })(tr);
41
41
  dispatch(tr);
42
42
  }
43
43
  return true;
@@ -2,7 +2,7 @@ import { createMediaLinkingCommand, getMediaLinkingState, mediaLinkingPluginKey
2
2
  import { normalizeUrl } from '@atlaskit/editor-common/utils';
3
3
  import { createToggleBlockMarkOnRange } from '../../../commands';
4
4
  import { MediaLinkingActionsTypes } from '../pm-plugins/linking/actions';
5
- import { addAnalytics, EVENT_TYPE, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../../analytics';
5
+ import { EVENT_TYPE, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
6
6
  import { currentMediaNode } from '../utils/current-media-node';
7
7
  import { checkMediaType } from '../utils/check-media-type';
8
8
  import { getMediaPluginState } from '../pm-plugins/main';
@@ -117,22 +117,23 @@ function toggleLinkMark(tr, state, {
117
117
  toggleBlockLinkMark($pos.pos, $pos.pos + node.nodeSize, tr, state);
118
118
  return tr;
119
119
  }
120
- const fireAnalyticForMediaLink = (tr, state, action, attributes = undefined) => {
121
- return addAnalytics(state, tr, {
120
+ const fireAnalyticForMediaLink = (tr, action, attributes = undefined, editorAnalyticsAPI) => {
121
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
122
122
  action,
123
123
  eventType: EVENT_TYPE.TRACK,
124
124
  actionSubject: ACTION_SUBJECT.MEDIA,
125
125
  actionSubjectId: ACTION_SUBJECT_ID.LINK,
126
126
  attributes
127
- });
127
+ })(tr);
128
+ return tr;
128
129
  };
129
- export const unlink = createMediaLinkingCommand({
130
+ export const unlink = editorAnalyticsAPI => createMediaLinkingCommand({
130
131
  type: MediaLinkingActionsTypes.unlink
131
132
  }, (tr, state) => {
132
133
  const transaction = toggleLinkMark(tr, state, {
133
134
  forceRemove: true
134
135
  });
135
- return fireAnalyticForMediaLink(transaction, state, ACTION.DELETED);
136
+ return fireAnalyticForMediaLink(transaction, ACTION.DELETED, undefined, editorAnalyticsAPI);
136
137
  });
137
138
  const getAction = (newUrl, state) => {
138
139
  const currentUrl = getCurrentUrl(state);
@@ -143,7 +144,7 @@ const getAction = (newUrl, state) => {
143
144
  }
144
145
  return undefined;
145
146
  };
146
- export const setUrlToMedia = (url, inputMethod) => createMediaLinkingCommand({
147
+ export const setUrlToMedia = (url, inputMethod, editorAnalyticsAPI) => createMediaLinkingCommand({
147
148
  type: MediaLinkingActionsTypes.setUrl,
148
149
  payload: normalizeUrl(url)
149
150
  }, (tr, state) => {
@@ -155,14 +156,14 @@ export const setUrlToMedia = (url, inputMethod) => createMediaLinkingCommand({
155
156
  const toggleLinkMarkResult = toggleLinkMark(tr, state, {
156
157
  url: url
157
158
  });
158
- fireAnalyticForMediaLink(tr, state, action, action === ACTION.ADDED ? {
159
+ fireAnalyticForMediaLink(tr, action, action === ACTION.ADDED ? {
159
160
  inputMethod
160
- } : undefined);
161
+ } : undefined, editorAnalyticsAPI);
161
162
  return toggleLinkMarkResult;
162
163
  } catch (e) {
163
- fireAnalyticForMediaLink(tr, state, ACTION.ERRORED, {
164
+ fireAnalyticForMediaLink(tr, ACTION.ERRORED, {
164
165
  action: action
165
- });
166
+ }, editorAnalyticsAPI);
166
167
  throw e;
167
168
  }
168
169
  });
@@ -108,7 +108,10 @@ const mediaPlugin = (options = {}, api) => {
108
108
  }
109
109
  }, {
110
110
  name: 'mediaKeymap',
111
- plugin: () => keymapPlugin(options)
111
+ plugin: () => {
112
+ var _api$dependencies$ana;
113
+ return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
114
+ }
112
115
  }];
113
116
  if (options && options.allowMediaSingle) {
114
117
  pmPlugins.push({
@@ -222,11 +225,11 @@ const mediaPlugin = (options = {}, api) => {
222
225
  keywords: ['attachment', 'gif', 'media', 'picture', 'image', 'video'],
223
226
  icon: () => /*#__PURE__*/React.createElement(IconImages, null),
224
227
  action(insert, state) {
225
- var _api$dependencies$ana;
228
+ var _api$dependencies$ana2;
226
229
  const pluginState = pluginKey.getState(state);
227
230
  pluginState === null || pluginState === void 0 ? void 0 : pluginState.showMediaPicker();
228
231
  const tr = insert('');
229
- api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions.attachAnalyticsEvent({
232
+ api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions.attachAnalyticsEvent({
230
233
  action: ACTION.OPENED,
231
234
  actionSubject: ACTION_SUBJECT.PICKER,
232
235
  actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
@@ -164,15 +164,17 @@ export default class MediaSingleNode extends Component {
164
164
  (_this$captionPlaceHol = this.captionPlaceHolderRef.current) === null || _this$captionPlaceHol === void 0 ? void 0 : _this$captionPlaceHol.click();
165
165
  });
166
166
  _defineProperty(this, "clickPlaceholder", () => {
167
+ var _pluginInjectionApi$d, _pluginInjectionApi$d2;
167
168
  const {
168
169
  view,
169
170
  getPos,
170
- node
171
+ node,
172
+ pluginInjectionApi
171
173
  } = this.props;
172
174
  if (typeof getPos === 'boolean') {
173
175
  return;
174
176
  }
175
- insertAndSelectCaptionFromMediaSinglePos(getPos(), node)(view.state, view.dispatch);
177
+ insertAndSelectCaptionFromMediaSinglePos(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(getPos(), node)(view.state, view.dispatch);
176
178
  });
177
179
  /**
178
180
  * Get parent width for a nested media single node
@@ -5,7 +5,7 @@ import { stateKey } from '../pm-plugins/plugin-key';
5
5
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
6
6
  import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
7
7
  import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from '../commands/captions';
8
- export function keymapPlugin(options) {
8
+ export function keymapPlugin(options, editorAnalyticsAPI) {
9
9
  const list = {};
10
10
  const {
11
11
  featureFlags
@@ -13,8 +13,8 @@ export function keymapPlugin(options) {
13
13
  keymaps.bindKeymapWithCommand(keymaps.undo.common, ignoreLinksInSteps, list);
14
14
  keymaps.bindKeymapWithCommand(keymaps.enter.common, splitMediaGroup, list);
15
15
  if (getMediaFeatureFlag('captions', featureFlags)) {
16
- keymaps.bindKeymapWithCommand(keymaps.moveDown.common, insertAndSelectCaption, list);
17
- keymaps.bindKeymapWithCommand(keymaps.tab.common, insertAndSelectCaption, list);
16
+ keymaps.bindKeymapWithCommand(keymaps.moveDown.common, insertAndSelectCaption(editorAnalyticsAPI), list);
17
+ keymaps.bindKeymapWithCommand(keymaps.tab.common, insertAndSelectCaption(editorAnalyticsAPI), list);
18
18
  keymaps.bindKeymapWithCommand(keymaps.moveLeft.common, arrowLeftFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
19
19
  keymaps.bindKeymapWithCommand(keymaps.moveRight.common, arrowRightFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
20
20
  }
@@ -30,7 +30,7 @@ const splitMediaGroup = state => {
30
30
  const mediaPluginState = stateKey.getState(state);
31
31
  return mediaPluginState.splitMediaGroup();
32
32
  };
33
- const insertAndSelectCaption = (state, dispatch) => {
33
+ const insertAndSelectCaption = editorAnalyticsAPI => (state, dispatch) => {
34
34
  const {
35
35
  selection,
36
36
  schema
@@ -41,7 +41,7 @@ const insertAndSelectCaption = (state, dispatch) => {
41
41
  from,
42
42
  node
43
43
  } = selection;
44
- if (!insertAndSelectCaptionFromMediaSinglePos(from, node)(state, dispatch)) {
44
+ if (!insertAndSelectCaptionFromMediaSinglePos(editorAnalyticsAPI)(from, node)(state, dispatch)) {
45
45
  selectCaptionFromMediaSinglePos(from, node)(state, dispatch);
46
46
  }
47
47
  }
@@ -45,7 +45,7 @@ const createDropPlaceholder = (intl, allowDropLine) => {
45
45
  };
46
46
  const MEDIA_RESOLVED_STATES = ['ready', 'error', 'cancelled'];
47
47
  export class MediaPluginStateImplementation {
48
- constructor(_state, options, mediaOptions, newInsertionBehaviour, _dispatch, pluginInjectionApi) {
48
+ constructor(_state, options, mediaOptions, newInsertionBehaviour, _dispatch, _pluginInjectionApi) {
49
49
  _defineProperty(this, "allowsUploads", false);
50
50
  _defineProperty(this, "ignoreLinks", false);
51
51
  _defineProperty(this, "waitForMediaUpload", true);
@@ -149,7 +149,7 @@ export class MediaPluginStateImplementation {
149
149
  *
150
150
  * called when we insert a new file via the picker (connected via pickerfacade)
151
151
  */
152
- _defineProperty(this, "insertFile", (mediaState, onMediaStateChanged, pickerType) => {
152
+ _defineProperty(this, "insertFile", (mediaState, onMediaStateChanged, pickerType, pluginInjectionApi) => {
153
153
  var _mediaState$collectio, _this$mediaOptions2;
154
154
  const {
155
155
  state
@@ -175,9 +175,11 @@ export class MediaPluginStateImplementation {
175
175
  const widthPluginState = (_this$pluginInjection = this.pluginInjectionApi) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.dependencies.width.sharedState.currentState();
176
176
  insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, this.newInsertionBehaviour, widthPluginState);
177
177
  } else if (getMediaFeatureFlag('mediaInline', (_this$mediaOptions2 = this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInListItem(state)) && canInsertMediaInline(state)) {
178
- insertMediaInlineNode(this.view, mediaStateWithContext, collection, this.getInputMethod(pickerType));
178
+ var _pluginInjectionApi$d, _pluginInjectionApi$d2;
179
+ insertMediaInlineNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(this.view, mediaStateWithContext, collection, this.getInputMethod(pickerType));
179
180
  } else {
180
- insertMediaGroupNode(this.view, [mediaStateWithContext], collection, this.getInputMethod(pickerType));
181
+ var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
182
+ insertMediaGroupNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.analytics) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions)(this.view, [mediaStateWithContext], collection, this.getInputMethod(pickerType));
181
183
  }
182
184
 
183
185
  // do events when media state changes
@@ -413,7 +415,7 @@ export class MediaPluginStateImplementation {
413
415
  this.mediaOptions = mediaOptions;
414
416
  this.newInsertionBehaviour = newInsertionBehaviour;
415
417
  this.dispatch = _dispatch;
416
- this.pluginInjectionApi = pluginInjectionApi;
418
+ this.pluginInjectionApi = _pluginInjectionApi;
417
419
  this.waitForMediaUpload = options.waitForMediaUpload === undefined ? true : options.waitForMediaUpload;
418
420
  const {
419
421
  nodes
@@ -1,12 +1,12 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
4
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE } from '../../analytics';
4
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
5
5
  import { removeMediaGroupNode } from './utils';
6
6
  import { currentMediaNodeWithPos } from '../utils/current-media-node';
7
7
  export const DEFAULT_BORDER_COLOR = '#091e4224';
8
8
  export const DEFAULT_BORDER_SIZE = 2;
9
- export const changeInlineToMediaCard = (state, dispatch) => {
9
+ export const changeInlineToMediaCard = editorAnalyticsAPI => (state, dispatch) => {
10
10
  const {
11
11
  media,
12
12
  mediaInline,
@@ -32,7 +32,7 @@ export const changeInlineToMediaCard = (state, dispatch) => {
32
32
  tr = removeSelectedNode(tr);
33
33
  tr = safeInsert(group, nodePos, true)(tr);
34
34
  if (dispatch) {
35
- addAnalytics(state, tr, {
35
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
36
36
  action: ACTION.CHANGED_TYPE,
37
37
  actionSubject: ACTION_SUBJECT.MEDIA,
38
38
  eventType: EVENT_TYPE.TRACK,
@@ -40,12 +40,12 @@ export const changeInlineToMediaCard = (state, dispatch) => {
40
40
  newType: ACTION_SUBJECT_ID.MEDIA_GROUP,
41
41
  previousType: ACTION_SUBJECT_ID.MEDIA_INLINE
42
42
  }
43
- });
43
+ })(tr);
44
44
  dispatch(tr);
45
45
  }
46
46
  return true;
47
47
  };
48
- export const changeMediaCardToInline = (state, dispatch) => {
48
+ export const changeMediaCardToInline = editorAnalyticsAPI => (state, dispatch) => {
49
49
  const {
50
50
  media,
51
51
  mediaInline,
@@ -68,7 +68,7 @@ export const changeMediaCardToInline = (state, dispatch) => {
68
68
  let tr = removeMediaGroupNode(state);
69
69
  tr = safeInsert(node, nodePos, true)(tr);
70
70
  if (dispatch) {
71
- addAnalytics(state, tr, {
71
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
72
72
  action: ACTION.CHANGED_TYPE,
73
73
  actionSubject: ACTION_SUBJECT.MEDIA,
74
74
  eventType: EVENT_TYPE.TRACK,
@@ -76,7 +76,7 @@ export const changeMediaCardToInline = (state, dispatch) => {
76
76
  newType: ACTION_SUBJECT_ID.MEDIA_INLINE,
77
77
  previousType: ACTION_SUBJECT_ID.MEDIA_GROUP
78
78
  }
79
- });
79
+ })(tr);
80
80
  dispatch(tr);
81
81
  }
82
82
  return true;
@@ -90,7 +90,7 @@ export const removeInlineCard = (state, dispatch) => {
90
90
  }
91
91
  return false;
92
92
  };
93
- export const toggleBorderMark = (state, dispatch) => {
93
+ export const toggleBorderMark = editorAnalyticsAPI => (state, dispatch) => {
94
94
  const nodeWithPos = currentMediaNodeWithPos(state);
95
95
  if (!nodeWithPos) {
96
96
  return false;
@@ -113,7 +113,7 @@ export const toggleBorderMark = (state, dispatch) => {
113
113
  }
114
114
  if (dispatch) {
115
115
  if (borderMark !== null && borderMark !== void 0 && borderMark.attrs) {
116
- addAnalytics(state, tr, {
116
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
117
117
  action: ACTION.DELETED,
118
118
  actionSubject: ACTION_SUBJECT.MEDIA,
119
119
  actionSubjectId: ACTION_SUBJECT_ID.BORDER,
@@ -122,9 +122,9 @@ export const toggleBorderMark = (state, dispatch) => {
122
122
  previousColor: borderMark.attrs.color,
123
123
  previousSize: borderMark.attrs.size
124
124
  }
125
- });
125
+ })(tr);
126
126
  } else {
127
- addAnalytics(state, tr, {
127
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
128
128
  action: ACTION.ADDED,
129
129
  actionSubject: ACTION_SUBJECT.MEDIA,
130
130
  actionSubjectId: ACTION_SUBJECT_ID.BORDER,
@@ -133,13 +133,13 @@ export const toggleBorderMark = (state, dispatch) => {
133
133
  color: DEFAULT_BORDER_COLOR,
134
134
  size: DEFAULT_BORDER_SIZE
135
135
  }
136
- });
136
+ })(tr);
137
137
  }
138
138
  dispatch(tr);
139
139
  }
140
140
  return true;
141
141
  };
142
- export const setBorderMark = attrs => (state, dispatch) => {
142
+ export const setBorderMark = editorAnalyticsAPI => attrs => (state, dispatch) => {
143
143
  var _node$marks$find, _ref, _attrs$color, _ref2, _attrs$size;
144
144
  const nodeWithPos = currentMediaNodeWithPos(state);
145
145
  if (!nodeWithPos) {
@@ -164,7 +164,7 @@ export const setBorderMark = attrs => (state, dispatch) => {
164
164
  }
165
165
  }
166
166
  if (dispatch) {
167
- addAnalytics(state, tr, {
167
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
168
168
  action: ACTION.UPDATED,
169
169
  actionSubject: ACTION_SUBJECT.MEDIA,
170
170
  actionSubjectId: ACTION_SUBJECT_ID.BORDER,
@@ -175,7 +175,7 @@ export const setBorderMark = attrs => (state, dispatch) => {
175
175
  newColor: color,
176
176
  newSize: size
177
177
  }
178
- });
178
+ })(tr);
179
179
  dispatch(tr);
180
180
  }
181
181
  return true;