@atlaskit/editor-plugin-media 0.11.2 → 0.11.4

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 (36) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/commands/helpers.js +2 -0
  3. package/dist/cjs/nodeviews/mediaSingle.js +1 -1
  4. package/dist/cjs/plugin.js +2 -2
  5. package/dist/cjs/pm-plugins/alt-text/commands.js +14 -5
  6. package/dist/cjs/pm-plugins/alt-text/ui/AltTextEdit.js +12 -5
  7. package/dist/cjs/pm-plugins/main.js +1 -1
  8. package/dist/cjs/toolbar/alt-text.js +4 -0
  9. package/dist/cjs/toolbar/commands.js +2 -2
  10. package/dist/cjs/toolbar/index.js +6 -6
  11. package/dist/cjs/toolbar/linking.js +1 -1
  12. package/dist/es2019/commands/helpers.js +2 -0
  13. package/dist/es2019/nodeviews/mediaSingle.js +2 -2
  14. package/dist/es2019/plugin.js +2 -2
  15. package/dist/es2019/pm-plugins/alt-text/commands.js +17 -6
  16. package/dist/es2019/pm-plugins/alt-text/ui/AltTextEdit.js +11 -5
  17. package/dist/es2019/pm-plugins/main.js +2 -2
  18. package/dist/es2019/toolbar/alt-text.js +4 -0
  19. package/dist/es2019/toolbar/commands.js +1 -1
  20. package/dist/es2019/toolbar/index.js +10 -10
  21. package/dist/es2019/toolbar/linking.js +2 -2
  22. package/dist/esm/commands/helpers.js +2 -0
  23. package/dist/esm/nodeviews/mediaSingle.js +1 -1
  24. package/dist/esm/plugin.js +2 -2
  25. package/dist/esm/pm-plugins/alt-text/commands.js +14 -5
  26. package/dist/esm/pm-plugins/alt-text/ui/AltTextEdit.js +12 -5
  27. package/dist/esm/pm-plugins/main.js +1 -1
  28. package/dist/esm/toolbar/alt-text.js +4 -0
  29. package/dist/esm/toolbar/commands.js +1 -1
  30. package/dist/esm/toolbar/index.js +6 -6
  31. package/dist/esm/toolbar/linking.js +1 -1
  32. package/dist/types/pm-plugins/alt-text/ui/AltTextEdit.d.ts +2 -0
  33. package/dist/types/toolbar/commands.d.ts +2 -0
  34. package/dist/types-ts4.5/pm-plugins/alt-text/ui/AltTextEdit.d.ts +2 -0
  35. package/dist/types-ts4.5/toolbar/commands.d.ts +2 -0
  36. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 0.11.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#67238](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67238) [`40533849b2ec`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/40533849b2ec) - [ED-21835] Change EditorAPI type to always union with undefined
8
+
9
+ ## 0.11.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#66631](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/66631) [`c1d10d6c2013`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c1d10d6c2013) - Updated alt text analytics to log additional attributes
14
+ - [#67194](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67194) [`37379761475c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/37379761475c) - [ED-21806] Skip changes from NCS and tinted transactions.
15
+
3
16
  ## 0.11.2
4
17
 
5
18
  ### Patch Changes
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.updateMediaSingleNodeAttrs = exports.updateCurrentMediaNodeAttrs = exports.updateAllMediaSingleNodesAttrs = exports.replaceExternalMedia = exports.isMediaNode = exports.findMediaSingleNode = exports.findAllMediaSingleNodes = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _steps = require("@atlaskit/adf-schema/steps");
10
+ var _collab = require("@atlaskit/editor-common/collab");
10
11
  var _pluginKey = require("../pm-plugins/plugin-key");
11
12
  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; }
12
13
  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) { (0, _defineProperty2.default)(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; }
@@ -65,6 +66,7 @@ var updateAllMediaSingleNodesAttrs = exports.updateAllMediaSingleNodesAttrs = fu
65
66
  return tr.step(new _steps.SetAttrsStep(pos, attrs));
66
67
  });
67
68
  tr.setMeta('addToHistory', false);
69
+ (0, _collab.tintDirtyTransaction)(tr);
68
70
  if (dispatch) {
69
71
  dispatch(tr);
70
72
  }
@@ -372,7 +372,7 @@ var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
372
372
  height = _mediaSingle.DEFAULT_IMAGE_HEIGHT;
373
373
  }
374
374
  var isSelected = selected();
375
- var currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
375
+ var currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 || (_pluginInjectionApi$m = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
376
376
  var contentWidthForLegacyExperience = (0, _mediaSingle.getMaxWidthForNestedNode)(view, getPos()) || lineLength;
377
377
  var contentWidth = currentMaxWidth || lineLength;
378
378
  var mediaSingleProps = {
@@ -146,9 +146,9 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
146
146
  }, {
147
147
  name: 'mediaKeymap',
148
148
  plugin: function plugin(_ref5) {
149
- var _api$analytics2;
149
+ var _api$analytics2, _api$selection;
150
150
  var getIntl = _ref5.getIntl;
151
- return (0, _keymap2.default)(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
151
+ return (0, _keymap2.default)(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
152
152
  }
153
153
  }];
154
154
  if (options && options.allowMediaSingle) {
@@ -9,17 +9,26 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
+ var _commands = require("../../toolbar/commands");
12
13
  var _mediaCommon = require("../../utils/media-common");
13
14
  var _index = require("./index");
14
15
  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; }
15
16
  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) { (0, _defineProperty2.default)(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; }
16
17
  var createCommandWithAnalytics = function createCommandWithAnalytics(actionType, action, transform) {
17
18
  return function (editorAnalyticsAPI) {
18
- return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
19
- action: actionType,
20
- actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
21
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.ALT_TEXT,
22
- eventType: _analytics.EVENT_TYPE.TRACK
19
+ return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, function (state) {
20
+ var mediaNode = (0, _mediaCommon.getMediaSingleOrInlineNodeFromSelection)(state);
21
+ var type = (0, _commands.getNodeType)(state);
22
+ return {
23
+ action: actionType,
24
+ actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
25
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.ALT_TEXT,
26
+ eventType: _analytics.EVENT_TYPE.TRACK,
27
+ attributes: {
28
+ type: type,
29
+ mediaType: mediaNode.attrs.type
30
+ }
31
+ };
23
32
  })((0, _index.createCommand)(action, transform));
24
33
  };
25
34
  };
@@ -114,13 +114,13 @@ var AltTextEditComponent = exports.AltTextEditComponent = /*#__PURE__*/function
114
114
  key: "componentWillUnmount",
115
115
  value: function componentWillUnmount() {
116
116
  this.fireAnalytics(_analytics.ACTION.CLOSED);
117
- if (!this.prevValue && this.props.value) {
117
+ if (!this.prevValue && this.state.lastValue) {
118
118
  this.fireAnalytics(_analytics.ACTION.ADDED);
119
119
  }
120
- if (this.prevValue && !this.props.value) {
120
+ if (this.prevValue && !this.state.lastValue) {
121
121
  this.fireAnalytics(_analytics.ACTION.CLEARED);
122
122
  }
123
- if (this.prevValue && this.prevValue !== this.props.value) {
123
+ if (this.prevValue && this.prevValue !== this.state.lastValue) {
124
124
  this.fireAnalytics(_analytics.ACTION.EDITED);
125
125
  }
126
126
  }
@@ -202,14 +202,21 @@ var AltTextEditComponent = exports.AltTextEditComponent = /*#__PURE__*/function
202
202
  }, {
203
203
  key: "fireAnalytics",
204
204
  value: function fireAnalytics(actionType) {
205
- var createAnalyticsEvent = this.props.createAnalyticsEvent;
205
+ var _this$props2 = this.props,
206
+ createAnalyticsEvent = _this$props2.createAnalyticsEvent,
207
+ nodeType = _this$props2.nodeType,
208
+ mediaType = _this$props2.mediaType;
206
209
  if (createAnalyticsEvent && this.fireCustomAnalytics) {
207
210
  this.fireCustomAnalytics({
208
211
  payload: {
209
212
  action: actionType,
210
213
  actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
211
214
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.ALT_TEXT,
212
- eventType: _analytics.EVENT_TYPE.TRACK
215
+ eventType: _analytics.EVENT_TYPE.TRACK,
216
+ attributes: {
217
+ type: nodeType,
218
+ mediaType: mediaType
219
+ }
213
220
  }
214
221
  });
215
222
  }
@@ -248,7 +248,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
248
248
  break;
249
249
  case 'block':
250
250
  // read width state right before inserting to get up-to-date and define values
251
- var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.width.sharedState.currentState();
251
+ var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 || (_this$pluginInjection2 = _this$pluginInjection2.width) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.sharedState.currentState();
252
252
  (0, _mediaSingle2.insertMediaSingleNode)(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, widthPluginState, editorAnalyticsAPI);
253
253
  break;
254
254
  case 'group':
@@ -14,6 +14,7 @@ var _commands = require("../pm-plugins/alt-text/commands");
14
14
  var _messages = require("../pm-plugins/alt-text/messages");
15
15
  var _AltTextEdit = _interopRequireWildcard(require("../pm-plugins/alt-text/ui/AltTextEdit"));
16
16
  var _mediaCommon = require("../utils/media-common");
17
+ var _commands2 = require("./commands");
17
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
20
  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; }
@@ -62,9 +63,12 @@ var altTextEditComponent = exports.altTextEditComponent = function altTextEditCo
62
63
  dispatch(newTr);
63
64
  }
64
65
  };
66
+ var type = (0, _commands2.getNodeType)(state);
65
67
  return /*#__PURE__*/_react.default.createElement(_AltTextEdit.default, {
66
68
  view: view,
67
69
  key: idx,
70
+ nodeType: type,
71
+ mediaType: mediaNode.attrs.type,
68
72
  value: mediaNode.attrs.alt,
69
73
  altTextValidator: options && options.altTextValidator,
70
74
  onEscape: handleEsc
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateMediaSingleWidth = exports.toggleBorderMark = exports.setBorderMark = exports.removeInlineCard = exports.changeMediaSingleToMediaInline = exports.changeMediaInlineToMediaSingle = exports.changeMediaCardToInline = exports.changeInlineToMediaCard = exports.DEFAULT_BORDER_SIZE = exports.DEFAULT_BORDER_COLOR = void 0;
7
+ exports.updateMediaSingleWidth = exports.toggleBorderMark = exports.setBorderMark = exports.removeInlineCard = exports.getNodeType = exports.changeMediaSingleToMediaInline = exports.changeMediaInlineToMediaSingle = exports.changeMediaCardToInline = exports.changeInlineToMediaCard = exports.DEFAULT_BORDER_SIZE = exports.DEFAULT_BORDER_COLOR = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _model = require("@atlaskit/editor-prosemirror/model");
@@ -20,7 +20,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
20
20
  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) { (0, _defineProperty2.default)(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; }
21
21
  var DEFAULT_BORDER_COLOR = exports.DEFAULT_BORDER_COLOR = '#091e4224';
22
22
  var DEFAULT_BORDER_SIZE = exports.DEFAULT_BORDER_SIZE = 2;
23
- var getNodeType = function getNodeType(state) {
23
+ var getNodeType = exports.getNodeType = function getNodeType(state) {
24
24
  var _state$schema$nodes = state.schema.nodes,
25
25
  mediaSingle = _state$schema$nodes.mediaSingle,
26
26
  mediaInline = _state$schema$nodes.mediaInline;
@@ -166,7 +166,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
166
166
  return items;
167
167
  };
168
168
  var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToolbar(state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) {
169
- var _pluginInjectionApi$d;
169
+ var _pluginInjectionApi$d, _pluginInjectionApi$d2;
170
170
  var mediaSingle = state.schema.nodes.mediaSingle;
171
171
  var allowResizing = options.allowResizing,
172
172
  allowLinking = options.allowLinking,
@@ -174,7 +174,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
174
174
  allowResizingInTables = options.allowResizingInTables,
175
175
  allowAltTextOnImages = options.allowAltTextOnImages;
176
176
  var toolbarButtons = [];
177
- var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
177
+ var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
178
178
  hoverDecoration = _ref.hoverDecoration;
179
179
  if ((0, _imageBorder.shouldShowImageBorder)(state)) {
180
180
  toolbarButtons.push({
@@ -326,7 +326,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
326
326
  var _selectedMediaNode$at = selectedMediaNode.attrs,
327
327
  mediaWidth = _selectedMediaNode$at.width,
328
328
  mediaHeight = _selectedMediaNode$at.height;
329
- var maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
329
+ var maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 || (_pluginInjectionApi$m = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
330
330
  var maxWidth = maxWidthForNestedNode || _editorSharedStyles.akEditorFullWidthLayoutWidth;
331
331
  var isVideoFile = (0, _mediaSingle2.isVideo)(selectedMediaNode.attrs.__fileMimeType);
332
332
  var minWidth = (0, _mediaSingle.calcMinWidth)(isVideoFile, maxWidthForNestedNode || contentWidth);
@@ -482,7 +482,7 @@ var getMediaTypeMessage = function getMediaTypeMessage(selectedNodeTypeSingle) {
482
482
  return mediaType ? mediaTypeMessages[mediaType] : _mediaUi.messages.file_unknown_is_selected;
483
483
  };
484
484
  var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state, intl) {
485
- var _pluginInjectionApi$d2;
485
+ var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
486
486
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
487
487
  var pluginInjectionApi = arguments.length > 3 ? arguments[3] : undefined;
488
488
  var _state$schema$nodes = state.schema.nodes,
@@ -499,7 +499,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
499
499
  getEditorFeatureFlags = options.getEditorFeatureFlags;
500
500
  var mediaPluginState = _pluginKey.stateKey.getState(state);
501
501
  var mediaLinkingState = (0, _linking2.getMediaLinkingState)(state);
502
- var _ref3 = (_pluginInjectionApi$d2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions) !== null && _pluginInjectionApi$d2 !== void 0 ? _pluginInjectionApi$d2 : {},
502
+ var _ref3 = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d4 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {},
503
503
  hoverDecoration = _ref3.hoverDecoration;
504
504
  if (!mediaPluginState) {
505
505
  return;
@@ -524,7 +524,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
524
524
  var _pluginInjectionApi$f;
525
525
  return (0, _altText2.getAltTextToolbar)(baseToolbar, {
526
526
  altTextValidator: altTextValidator,
527
- forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar.actions) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.forceFocusSelector
527
+ forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.actions) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.forceFocusSelector
528
528
  });
529
529
  }
530
530
  }
@@ -78,7 +78,7 @@ var getLinkingToolbar = exports.getLinkingToolbar = function getLinkingToolbar(t
78
78
  */
79
79
  var tr = view.state.tr,
80
80
  dispatch = view.dispatch;
81
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar.actions) === null || _pluginInjectionApi$f === void 0 || _pluginInjectionApi$f.forceFocusSelector(FORCE_FOCUS_SELECTOR)(tr);
81
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.actions) === null || _pluginInjectionApi$f === void 0 || _pluginInjectionApi$f.forceFocusSelector(FORCE_FOCUS_SELECTOR)(tr);
82
82
  dispatch(tr);
83
83
  },
84
84
  onSubmit: function onSubmit(href, meta) {
@@ -1,4 +1,5 @@
1
1
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
2
+ import { tintDirtyTransaction } from '@atlaskit/editor-common/collab';
2
3
  import { stateKey as mediaPluginKey } from '../pm-plugins/plugin-key';
3
4
  /**
4
5
  * Note that Media Inline is inserted like a media single node into the media plugin state.
@@ -57,6 +58,7 @@ export const updateAllMediaSingleNodesAttrs = (id, attrs) => (state, dispatch) =
57
58
  const tr = state.tr;
58
59
  validMediaNodePositions.forEach(pos => tr.step(new SetAttrsStep(pos, attrs)));
59
60
  tr.setMeta('addToHistory', false);
61
+ tintDirtyTransaction(tr);
60
62
  if (dispatch) {
61
63
  dispatch(tr);
62
64
  }
@@ -225,7 +225,7 @@ export default class MediaSingleNode extends Component {
225
225
  });
226
226
  }
227
227
  render() {
228
- var _pluginInjectionApi$m;
228
+ var _pluginInjectionApi$m, _pluginInjectionApi$m2;
229
229
  const {
230
230
  selected,
231
231
  getPos,
@@ -282,7 +282,7 @@ export default class MediaSingleNode extends Component {
282
282
  height = DEFAULT_IMAGE_HEIGHT;
283
283
  }
284
284
  const isSelected = selected();
285
- const currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
285
+ const currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 ? void 0 : (_pluginInjectionApi$m2 = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m2 === void 0 ? void 0 : _pluginInjectionApi$m2.currentMaxWidth : undefined;
286
286
  const contentWidthForLegacyExperience = getMaxWidthForNestedNode(view, getPos()) || lineLength;
287
287
  const contentWidth = currentMaxWidth || lineLength;
288
288
  const mediaSingleProps = {
@@ -139,8 +139,8 @@ export const mediaPlugin = ({
139
139
  plugin: ({
140
140
  getIntl
141
141
  }) => {
142
- var _api$analytics2;
143
- return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
142
+ var _api$analytics2, _api$selection;
143
+ return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
144
144
  }
145
145
  }];
146
146
  if (options && options.allowMediaSingle) {
@@ -1,15 +1,26 @@
1
1
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
2
  import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
3
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
+ import { getNodeType } from '../../toolbar/commands';
4
5
  import { getMediaSingleOrInlineNodeFromSelection, isMediaSingleOrInlineNodeSelected } from '../../utils/media-common';
5
6
  import { createCommand } from './index';
6
7
  const createCommandWithAnalytics = (actionType, action, transform) => {
7
- return editorAnalyticsAPI => withAnalytics(editorAnalyticsAPI, {
8
- action: actionType,
9
- actionSubject: ACTION_SUBJECT.MEDIA,
10
- actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
11
- eventType: EVENT_TYPE.TRACK
12
- })(createCommand(action, transform));
8
+ return editorAnalyticsAPI => {
9
+ return withAnalytics(editorAnalyticsAPI, state => {
10
+ const mediaNode = getMediaSingleOrInlineNodeFromSelection(state);
11
+ const type = getNodeType(state);
12
+ return {
13
+ action: actionType,
14
+ actionSubject: ACTION_SUBJECT.MEDIA,
15
+ actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
16
+ eventType: EVENT_TYPE.TRACK,
17
+ attributes: {
18
+ type,
19
+ mediaType: mediaNode.attrs.type
20
+ }
21
+ };
22
+ })(createCommand(action, transform));
23
+ };
13
24
  };
14
25
 
15
26
  // pass in undefined to close the alt text menu without saving
@@ -124,13 +124,13 @@ export class AltTextEditComponent extends React.Component {
124
124
  }
125
125
  componentWillUnmount() {
126
126
  this.fireAnalytics(ACTION.CLOSED);
127
- if (!this.prevValue && this.props.value) {
127
+ if (!this.prevValue && this.state.lastValue) {
128
128
  this.fireAnalytics(ACTION.ADDED);
129
129
  }
130
- if (this.prevValue && !this.props.value) {
130
+ if (this.prevValue && !this.state.lastValue) {
131
131
  this.fireAnalytics(ACTION.CLEARED);
132
132
  }
133
- if (this.prevValue && this.prevValue !== this.props.value) {
133
+ if (this.prevValue && this.prevValue !== this.state.lastValue) {
134
134
  this.fireAnalytics(ACTION.EDITED);
135
135
  }
136
136
  }
@@ -215,7 +215,9 @@ export class AltTextEditComponent extends React.Component {
215
215
  }
216
216
  fireAnalytics(actionType) {
217
217
  const {
218
- createAnalyticsEvent
218
+ createAnalyticsEvent,
219
+ nodeType,
220
+ mediaType
219
221
  } = this.props;
220
222
  if (createAnalyticsEvent && this.fireCustomAnalytics) {
221
223
  this.fireCustomAnalytics({
@@ -223,7 +225,11 @@ export class AltTextEditComponent extends React.Component {
223
225
  action: actionType,
224
226
  actionSubject: ACTION_SUBJECT.MEDIA,
225
227
  actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
226
- eventType: EVENT_TYPE.TRACK
228
+ eventType: EVENT_TYPE.TRACK,
229
+ attributes: {
230
+ type: nodeType,
231
+ mediaType
232
+ }
227
233
  }
228
234
  });
229
235
  }
@@ -153,7 +153,7 @@ export class MediaPluginStateImplementation {
153
153
  * called when we insert a new file via the picker (connected via pickerfacade)
154
154
  */
155
155
  _defineProperty(this, "insertFile", (mediaState, onMediaStateChanged, pickerType) => {
156
- var _this$pluginInjection, _this$pluginInjection2, _mediaState$collectio, _this$mediaOptions2, _this$pluginInjection3;
156
+ var _this$pluginInjection, _this$pluginInjection2, _mediaState$collectio, _this$mediaOptions2, _this$pluginInjection3, _this$pluginInjection4;
157
157
  const {
158
158
  state
159
159
  } = this.view;
@@ -179,7 +179,7 @@ export class MediaPluginStateImplementation {
179
179
  break;
180
180
  case 'block':
181
181
  // read width state right before inserting to get up-to-date and define values
182
- const widthPluginState = (_this$pluginInjection3 = this.pluginInjectionApi) === null || _this$pluginInjection3 === void 0 ? void 0 : _this$pluginInjection3.width.sharedState.currentState();
182
+ const widthPluginState = (_this$pluginInjection3 = this.pluginInjectionApi) === null || _this$pluginInjection3 === void 0 ? void 0 : (_this$pluginInjection4 = _this$pluginInjection3.width) === null || _this$pluginInjection4 === void 0 ? void 0 : _this$pluginInjection4.sharedState.currentState();
183
183
  insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, this.newInsertionBehaviour, widthPluginState, editorAnalyticsAPI);
184
184
  break;
185
185
  case 'group':
@@ -5,6 +5,7 @@ import { openMediaAltTextMenu } from '../pm-plugins/alt-text/commands';
5
5
  import { messages } from '../pm-plugins/alt-text/messages';
6
6
  import AltTextEdit, { CONTAINER_WIDTH_IN_PX } from '../pm-plugins/alt-text/ui/AltTextEdit';
7
7
  import { getMediaSingleOrInlineNodeFromSelection } from '../utils/media-common';
8
+ import { getNodeType } from './commands';
8
9
  const testId = 'alt-text-edit-button';
9
10
  export const altTextButton = (intl, state, editorAnalyticsAPI) => {
10
11
  const mediaNode = getMediaSingleOrInlineNodeFromSelection(state);
@@ -53,9 +54,12 @@ export const altTextEditComponent = options => {
53
54
  dispatch(newTr);
54
55
  }
55
56
  };
57
+ const type = getNodeType(state);
56
58
  return /*#__PURE__*/React.createElement(AltTextEdit, {
57
59
  view: view,
58
60
  key: idx,
61
+ nodeType: type,
62
+ mediaType: mediaNode.attrs.type,
59
63
  value: mediaNode.attrs.alt,
60
64
  altTextValidator: options && options.altTextValidator,
61
65
  onEscape: handleEsc
@@ -10,7 +10,7 @@ import { changeFromMediaInlineToMediaSingleNode } from '../utils/media-single';
10
10
  import { getSelectedMediaSingle, removeMediaGroupNode } from './utils';
11
11
  export const DEFAULT_BORDER_COLOR = '#091e4224';
12
12
  export const DEFAULT_BORDER_SIZE = 2;
13
- const getNodeType = state => {
13
+ export const getNodeType = state => {
14
14
  const {
15
15
  mediaSingle,
16
16
  mediaInline
@@ -152,7 +152,7 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDe
152
152
  return items;
153
153
  };
154
154
  const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) => {
155
- var _pluginInjectionApi$d;
155
+ var _pluginInjectionApi$d, _pluginInjectionApi$d2;
156
156
  const {
157
157
  mediaSingle
158
158
  } = state.schema.nodes;
@@ -166,7 +166,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
166
166
  let toolbarButtons = [];
167
167
  const {
168
168
  hoverDecoration
169
- } = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {};
169
+ } = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {};
170
170
  if (shouldShowImageBorder(state)) {
171
171
  toolbarButtons.push({
172
172
  type: 'custom',
@@ -299,7 +299,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
299
299
  type: 'custom',
300
300
  fallback: [],
301
301
  render: editorView => {
302
- var _widthPlugin$sharedSt2, _pluginInjectionApi$m;
302
+ var _widthPlugin$sharedSt2, _pluginInjectionApi$m, _pluginInjectionApi$m2;
303
303
  if (!editorView || !selectedMediaSingleNode) {
304
304
  return null;
305
305
  }
@@ -321,7 +321,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
321
321
  width: mediaWidth,
322
322
  height: mediaHeight
323
323
  } = selectedMediaNode.attrs;
324
- const maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
324
+ const maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 ? void 0 : (_pluginInjectionApi$m2 = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m2 === void 0 ? void 0 : _pluginInjectionApi$m2.currentMaxWidth;
325
325
  const maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
326
326
  const isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
327
327
  const minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
@@ -483,7 +483,7 @@ const getMediaTypeMessage = selectedNodeTypeSingle => {
483
483
  return mediaType ? mediaTypeMessages[mediaType] : messages.file_unknown_is_selected;
484
484
  };
485
485
  export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) => {
486
- var _pluginInjectionApi$d2;
486
+ var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
487
487
  const {
488
488
  media,
489
489
  mediaInline,
@@ -503,7 +503,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
503
503
  const mediaLinkingState = getMediaLinkingState(state);
504
504
  const {
505
505
  hoverDecoration
506
- } = (_pluginInjectionApi$d2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions) !== null && _pluginInjectionApi$d2 !== void 0 ? _pluginInjectionApi$d2 : {};
506
+ } = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {};
507
507
  if (!mediaPluginState) {
508
508
  return;
509
509
  }
@@ -522,10 +522,10 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
522
522
  if (allowAltTextOnImages) {
523
523
  const mediaAltTextPluginState = getMediaAltTextPluginState(state);
524
524
  if (mediaAltTextPluginState.isAltTextEditorOpen) {
525
- var _pluginInjectionApi$f;
525
+ var _pluginInjectionApi$f, _pluginInjectionApi$f2;
526
526
  return getAltTextToolbar(baseToolbar, {
527
527
  altTextValidator,
528
- forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar.actions) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.forceFocusSelector
528
+ forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : (_pluginInjectionApi$f2 = _pluginInjectionApi$f.actions) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.forceFocusSelector
529
529
  });
530
530
  }
531
531
  }
@@ -536,14 +536,14 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
536
536
  selectedNodeType = state.selection.node.type;
537
537
  }
538
538
  if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
539
- var _pluginInjectionApi$a8, _pluginInjectionApi$f2, _pluginInjectionApi$f3;
539
+ var _pluginInjectionApi$a8, _pluginInjectionApi$f3, _pluginInjectionApi$f4;
540
540
  const mediaOffset = state.selection.$from.parentOffset + 1;
541
541
  baseToolbar.getDomRef = () => {
542
542
  var _mediaPluginState$ele;
543
543
  const selector = mediaFilmstripItemDOMSelector(mediaOffset);
544
544
  return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
545
545
  };
546
- items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : (_pluginInjectionApi$f3 = _pluginInjectionApi$f2.actions) === null || _pluginInjectionApi$f3 === void 0 ? void 0 : _pluginInjectionApi$f3.forceFocusSelector);
546
+ items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f3 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f3 === void 0 ? void 0 : (_pluginInjectionApi$f4 = _pluginInjectionApi$f3.actions) === null || _pluginInjectionApi$f4 === void 0 ? void 0 : _pluginInjectionApi$f4.forceFocusSelector);
547
547
  } else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
548
548
  baseToolbar.getDomRef = () => {
549
549
  var _mediaPluginState$ele2;
@@ -68,7 +68,7 @@ export const getLinkingToolbar = (toolbarBaseConfig, mediaLinkingState, state, i
68
68
  hideLinkingToolbar(view.state, view.dispatch, view);
69
69
  },
70
70
  onCancel: () => {
71
- var _pluginInjectionApi$f;
71
+ var _pluginInjectionApi$f, _pluginInjectionApi$f2;
72
72
  hideLinkingToolbar(view.state, view.dispatch, view, true);
73
73
  /** Focus should move to the 'Add link' button when the toolbar closes
74
74
  * and not close the floating toolbar.
@@ -79,7 +79,7 @@ export const getLinkingToolbar = (toolbarBaseConfig, mediaLinkingState, state, i
79
79
  },
80
80
  dispatch
81
81
  } = view;
82
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar.actions) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.forceFocusSelector(FORCE_FOCUS_SELECTOR)(tr);
82
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 ? void 0 : (_pluginInjectionApi$f2 = _pluginInjectionApi$f.actions) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.forceFocusSelector(FORCE_FOCUS_SELECTOR)(tr);
83
83
  dispatch(tr);
84
84
  },
85
85
  onSubmit: (href, meta) => {
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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; }
3
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; }
4
4
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
5
+ import { tintDirtyTransaction } from '@atlaskit/editor-common/collab';
5
6
  import { stateKey as mediaPluginKey } from '../pm-plugins/plugin-key';
6
7
  /**
7
8
  * Note that Media Inline is inserted like a media single node into the media plugin state.
@@ -58,6 +59,7 @@ export var updateAllMediaSingleNodesAttrs = function updateAllMediaSingleNodesAt
58
59
  return tr.step(new SetAttrsStep(pos, attrs));
59
60
  });
60
61
  tr.setMeta('addToHistory', false);
62
+ tintDirtyTransaction(tr);
61
63
  if (dispatch) {
62
64
  dispatch(tr);
63
65
  }
@@ -364,7 +364,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
364
364
  height = DEFAULT_IMAGE_HEIGHT;
365
365
  }
366
366
  var isSelected = selected();
367
- var currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
367
+ var currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 || (_pluginInjectionApi$m = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
368
368
  var contentWidthForLegacyExperience = getMaxWidthForNestedNode(view, getPos()) || lineLength;
369
369
  var contentWidth = currentMaxWidth || lineLength;
370
370
  var mediaSingleProps = {
@@ -135,9 +135,9 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
135
135
  }, {
136
136
  name: 'mediaKeymap',
137
137
  plugin: function plugin(_ref5) {
138
- var _api$analytics2;
138
+ var _api$analytics2, _api$selection;
139
139
  var getIntl = _ref5.getIntl;
140
- return keymapPlugin(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
140
+ return keymapPlugin(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
141
141
  }
142
142
  }];
143
143
  if (options && options.allowMediaSingle) {
@@ -4,15 +4,24 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
5
5
  import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
6
6
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
+ import { getNodeType } from '../../toolbar/commands';
7
8
  import { getMediaSingleOrInlineNodeFromSelection, isMediaSingleOrInlineNodeSelected } from '../../utils/media-common';
8
9
  import { createCommand } from './index';
9
10
  var createCommandWithAnalytics = function createCommandWithAnalytics(actionType, action, transform) {
10
11
  return function (editorAnalyticsAPI) {
11
- return withAnalytics(editorAnalyticsAPI, {
12
- action: actionType,
13
- actionSubject: ACTION_SUBJECT.MEDIA,
14
- actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
15
- eventType: EVENT_TYPE.TRACK
12
+ return withAnalytics(editorAnalyticsAPI, function (state) {
13
+ var mediaNode = getMediaSingleOrInlineNodeFromSelection(state);
14
+ var type = getNodeType(state);
15
+ return {
16
+ action: actionType,
17
+ actionSubject: ACTION_SUBJECT.MEDIA,
18
+ actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
19
+ eventType: EVENT_TYPE.TRACK,
20
+ attributes: {
21
+ type: type,
22
+ mediaType: mediaNode.attrs.type
23
+ }
24
+ };
16
25
  })(createCommand(action, transform));
17
26
  };
18
27
  };
@@ -108,13 +108,13 @@ export var AltTextEditComponent = /*#__PURE__*/function (_React$Component) {
108
108
  key: "componentWillUnmount",
109
109
  value: function componentWillUnmount() {
110
110
  this.fireAnalytics(ACTION.CLOSED);
111
- if (!this.prevValue && this.props.value) {
111
+ if (!this.prevValue && this.state.lastValue) {
112
112
  this.fireAnalytics(ACTION.ADDED);
113
113
  }
114
- if (this.prevValue && !this.props.value) {
114
+ if (this.prevValue && !this.state.lastValue) {
115
115
  this.fireAnalytics(ACTION.CLEARED);
116
116
  }
117
- if (this.prevValue && this.prevValue !== this.props.value) {
117
+ if (this.prevValue && this.prevValue !== this.state.lastValue) {
118
118
  this.fireAnalytics(ACTION.EDITED);
119
119
  }
120
120
  }
@@ -196,14 +196,21 @@ export var AltTextEditComponent = /*#__PURE__*/function (_React$Component) {
196
196
  }, {
197
197
  key: "fireAnalytics",
198
198
  value: function fireAnalytics(actionType) {
199
- var createAnalyticsEvent = this.props.createAnalyticsEvent;
199
+ var _this$props2 = this.props,
200
+ createAnalyticsEvent = _this$props2.createAnalyticsEvent,
201
+ nodeType = _this$props2.nodeType,
202
+ mediaType = _this$props2.mediaType;
200
203
  if (createAnalyticsEvent && this.fireCustomAnalytics) {
201
204
  this.fireCustomAnalytics({
202
205
  payload: {
203
206
  action: actionType,
204
207
  actionSubject: ACTION_SUBJECT.MEDIA,
205
208
  actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
206
- eventType: EVENT_TYPE.TRACK
209
+ eventType: EVENT_TYPE.TRACK,
210
+ attributes: {
211
+ type: nodeType,
212
+ mediaType: mediaType
213
+ }
207
214
  }
208
215
  });
209
216
  }
@@ -233,7 +233,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
233
233
  break;
234
234
  case 'block':
235
235
  // read width state right before inserting to get up-to-date and define values
236
- var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.width.sharedState.currentState();
236
+ var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 || (_this$pluginInjection2 = _this$pluginInjection2.width) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.sharedState.currentState();
237
237
  insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, widthPluginState, editorAnalyticsAPI);
238
238
  break;
239
239
  case 'group':
@@ -8,6 +8,7 @@ import { openMediaAltTextMenu } from '../pm-plugins/alt-text/commands';
8
8
  import { messages } from '../pm-plugins/alt-text/messages';
9
9
  import AltTextEdit, { CONTAINER_WIDTH_IN_PX } from '../pm-plugins/alt-text/ui/AltTextEdit';
10
10
  import { getMediaSingleOrInlineNodeFromSelection } from '../utils/media-common';
11
+ import { getNodeType } from './commands';
11
12
  var testId = 'alt-text-edit-button';
12
13
  export var altTextButton = function altTextButton(intl, state, editorAnalyticsAPI) {
13
14
  var mediaNode = getMediaSingleOrInlineNodeFromSelection(state);
@@ -52,9 +53,12 @@ export var altTextEditComponent = function altTextEditComponent(options) {
52
53
  dispatch(newTr);
53
54
  }
54
55
  };
56
+ var type = getNodeType(state);
55
57
  return /*#__PURE__*/React.createElement(AltTextEdit, {
56
58
  view: view,
57
59
  key: idx,
60
+ nodeType: type,
61
+ mediaType: mediaNode.attrs.type,
58
62
  value: mediaNode.attrs.alt,
59
63
  altTextValidator: options && options.altTextValidator,
60
64
  onEscape: handleEsc
@@ -13,7 +13,7 @@ import { changeFromMediaInlineToMediaSingleNode } from '../utils/media-single';
13
13
  import { getSelectedMediaSingle, removeMediaGroupNode } from './utils';
14
14
  export var DEFAULT_BORDER_COLOR = '#091e4224';
15
15
  export var DEFAULT_BORDER_SIZE = 2;
16
- var getNodeType = function getNodeType(state) {
16
+ export var getNodeType = function getNodeType(state) {
17
17
  var _state$schema$nodes = state.schema.nodes,
18
18
  mediaSingle = _state$schema$nodes.mediaSingle,
19
19
  mediaInline = _state$schema$nodes.mediaInline;
@@ -156,7 +156,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
156
156
  return items;
157
157
  };
158
158
  var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToolbar(state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) {
159
- var _pluginInjectionApi$d;
159
+ var _pluginInjectionApi$d, _pluginInjectionApi$d2;
160
160
  var mediaSingle = state.schema.nodes.mediaSingle;
161
161
  var allowResizing = options.allowResizing,
162
162
  allowLinking = options.allowLinking,
@@ -164,7 +164,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
164
164
  allowResizingInTables = options.allowResizingInTables,
165
165
  allowAltTextOnImages = options.allowAltTextOnImages;
166
166
  var toolbarButtons = [];
167
- var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
167
+ var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
168
168
  hoverDecoration = _ref.hoverDecoration;
169
169
  if (shouldShowImageBorder(state)) {
170
170
  toolbarButtons.push({
@@ -316,7 +316,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
316
316
  var _selectedMediaNode$at = selectedMediaNode.attrs,
317
317
  mediaWidth = _selectedMediaNode$at.width,
318
318
  mediaHeight = _selectedMediaNode$at.height;
319
- var maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
319
+ var maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 || (_pluginInjectionApi$m = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
320
320
  var maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
321
321
  var isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
322
322
  var minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
@@ -472,7 +472,7 @@ var getMediaTypeMessage = function getMediaTypeMessage(selectedNodeTypeSingle) {
472
472
  return mediaType ? mediaTypeMessages[mediaType] : messages.file_unknown_is_selected;
473
473
  };
474
474
  export var floatingToolbar = function floatingToolbar(state, intl) {
475
- var _pluginInjectionApi$d2;
475
+ var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
476
476
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
477
477
  var pluginInjectionApi = arguments.length > 3 ? arguments[3] : undefined;
478
478
  var _state$schema$nodes = state.schema.nodes,
@@ -489,7 +489,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
489
489
  getEditorFeatureFlags = options.getEditorFeatureFlags;
490
490
  var mediaPluginState = stateKey.getState(state);
491
491
  var mediaLinkingState = getMediaLinkingState(state);
492
- var _ref3 = (_pluginInjectionApi$d2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions) !== null && _pluginInjectionApi$d2 !== void 0 ? _pluginInjectionApi$d2 : {},
492
+ var _ref3 = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d4 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {},
493
493
  hoverDecoration = _ref3.hoverDecoration;
494
494
  if (!mediaPluginState) {
495
495
  return;
@@ -514,7 +514,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
514
514
  var _pluginInjectionApi$f;
515
515
  return getAltTextToolbar(baseToolbar, {
516
516
  altTextValidator: altTextValidator,
517
- forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar.actions) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.forceFocusSelector
517
+ forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.actions) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.forceFocusSelector
518
518
  });
519
519
  }
520
520
  }
@@ -70,7 +70,7 @@ export var getLinkingToolbar = function getLinkingToolbar(toolbarBaseConfig, med
70
70
  */
71
71
  var tr = view.state.tr,
72
72
  dispatch = view.dispatch;
73
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar.actions) === null || _pluginInjectionApi$f === void 0 || _pluginInjectionApi$f.forceFocusSelector(FORCE_FOCUS_SELECTOR)(tr);
73
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.actions) === null || _pluginInjectionApi$f === void 0 || _pluginInjectionApi$f.forceFocusSelector(FORCE_FOCUS_SELECTOR)(tr);
74
74
  dispatch(tr);
75
75
  },
76
76
  onSubmit: function onSubmit(href, meta) {
@@ -7,6 +7,8 @@ export declare const CONTAINER_WIDTH_IN_PX = 420;
7
7
  export declare const MAX_ALT_TEXT_LENGTH = 510;
8
8
  type Props = {
9
9
  view: EditorView;
10
+ nodeType: 'mediaSingle' | 'mediaInline';
11
+ mediaType: 'file' | 'image' | 'external';
10
12
  value?: string;
11
13
  altTextValidator?: (value: string) => string[];
12
14
  onEscape?: () => void;
@@ -3,10 +3,12 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Command } from '@atlaskit/editor-common/types';
4
4
  import type { ForceFocusSelector } from '@atlaskit/editor-plugin-floating-toolbar';
5
5
  import type { WidthPluginState } from '@atlaskit/editor-plugin-width';
6
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
6
7
  import type { EventInput } from '../pm-plugins/types';
7
8
  import type { PixelEntryValidation } from '../ui/PixelEntry/types';
8
9
  export declare const DEFAULT_BORDER_COLOR = "#091e4224";
9
10
  export declare const DEFAULT_BORDER_SIZE = 2;
11
+ export declare const getNodeType: (state: EditorState) => "mediaInline" | "mediaSingle";
10
12
  export declare const changeInlineToMediaCard: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, forceFocusSelector: ForceFocusSelector | undefined) => Command;
11
13
  export declare const changeMediaCardToInline: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, forceFocusSelector: ForceFocusSelector | undefined) => Command;
12
14
  export declare const changeMediaInlineToMediaSingle: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, widthPluginState: WidthPluginState | undefined) => Command;
@@ -7,6 +7,8 @@ export declare const CONTAINER_WIDTH_IN_PX = 420;
7
7
  export declare const MAX_ALT_TEXT_LENGTH = 510;
8
8
  type Props = {
9
9
  view: EditorView;
10
+ nodeType: 'mediaSingle' | 'mediaInline';
11
+ mediaType: 'file' | 'image' | 'external';
10
12
  value?: string;
11
13
  altTextValidator?: (value: string) => string[];
12
14
  onEscape?: () => void;
@@ -3,10 +3,12 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Command } from '@atlaskit/editor-common/types';
4
4
  import type { ForceFocusSelector } from '@atlaskit/editor-plugin-floating-toolbar';
5
5
  import type { WidthPluginState } from '@atlaskit/editor-plugin-width';
6
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
6
7
  import type { EventInput } from '../pm-plugins/types';
7
8
  import type { PixelEntryValidation } from '../ui/PixelEntry/types';
8
9
  export declare const DEFAULT_BORDER_COLOR = "#091e4224";
9
10
  export declare const DEFAULT_BORDER_SIZE = 2;
11
+ export declare const getNodeType: (state: EditorState) => "mediaInline" | "mediaSingle";
10
12
  export declare const changeInlineToMediaCard: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, forceFocusSelector: ForceFocusSelector | undefined) => Command;
11
13
  export declare const changeMediaCardToInline: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, forceFocusSelector: ForceFocusSelector | undefined) => Command;
12
14
  export declare const changeMediaInlineToMediaSingle: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, widthPluginState: WidthPluginState | undefined) => Command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -13,7 +13,7 @@
13
13
  "singleton": true,
14
14
  "runReact18": false
15
15
  },
16
- "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
16
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
17
17
  "main": "dist/cjs/index.js",
18
18
  "module": "dist/esm/index.js",
19
19
  "module:es2019": "dist/es2019/index.js",