@atlaskit/editor-plugin-media 3.0.1 → 3.0.3

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 (50) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/mediaPlugin.js +2 -1
  3. package/dist/cjs/pm-plugins/alt-text/ui/AltTextEdit.js +21 -10
  4. package/dist/cjs/pm-plugins/pixel-resizing/ui/index.js +15 -4
  5. package/dist/cjs/pm-plugins/pixel-resizing/ui/pixel-entry.js +7 -4
  6. package/dist/cjs/ui/MediaLinkingToolbar.js +20 -5
  7. package/dist/cjs/ui/toolbar/alt-text.js +7 -3
  8. package/dist/cjs/ui/toolbar/comments.js +7 -2
  9. package/dist/cjs/ui/toolbar/index.js +15 -6
  10. package/dist/cjs/ui/toolbar/linking.js +20 -5
  11. package/dist/cjs/ui/toolbar/pixel-resizing.js +4 -2
  12. package/dist/es2019/mediaPlugin.js +2 -1
  13. package/dist/es2019/pm-plugins/alt-text/ui/AltTextEdit.js +14 -3
  14. package/dist/es2019/pm-plugins/pixel-resizing/ui/index.js +17 -6
  15. package/dist/es2019/pm-plugins/pixel-resizing/ui/pixel-entry.js +7 -4
  16. package/dist/es2019/ui/MediaLinkingToolbar.js +19 -6
  17. package/dist/es2019/ui/toolbar/alt-text.js +7 -3
  18. package/dist/es2019/ui/toolbar/comments.js +7 -2
  19. package/dist/es2019/ui/toolbar/index.js +14 -5
  20. package/dist/es2019/ui/toolbar/linking.js +24 -5
  21. package/dist/es2019/ui/toolbar/pixel-resizing.js +4 -2
  22. package/dist/esm/mediaPlugin.js +2 -1
  23. package/dist/esm/pm-plugins/alt-text/ui/AltTextEdit.js +21 -10
  24. package/dist/esm/pm-plugins/pixel-resizing/ui/index.js +15 -4
  25. package/dist/esm/pm-plugins/pixel-resizing/ui/pixel-entry.js +7 -4
  26. package/dist/esm/ui/MediaLinkingToolbar.js +20 -5
  27. package/dist/esm/ui/toolbar/alt-text.js +7 -3
  28. package/dist/esm/ui/toolbar/comments.js +7 -2
  29. package/dist/esm/ui/toolbar/index.js +14 -5
  30. package/dist/esm/ui/toolbar/linking.js +20 -5
  31. package/dist/esm/ui/toolbar/pixel-resizing.js +4 -2
  32. package/dist/types/pm-plugins/alt-text/ui/AltTextEdit.d.ts +2 -0
  33. package/dist/types/pm-plugins/pixel-resizing/ui/index.d.ts +2 -1
  34. package/dist/types/pm-plugins/pixel-resizing/ui/types.d.ts +7 -2
  35. package/dist/types/types/index.d.ts +2 -0
  36. package/dist/types/ui/MediaLinkingToolbar.d.ts +3 -3
  37. package/dist/types/ui/toolbar/alt-text.d.ts +1 -0
  38. package/dist/types/ui/toolbar/comments.d.ts +1 -1
  39. package/dist/types/ui/toolbar/index.d.ts +1 -0
  40. package/dist/types/ui/toolbar/pixel-resizing.d.ts +1 -1
  41. package/dist/types-ts4.5/pm-plugins/alt-text/ui/AltTextEdit.d.ts +2 -0
  42. package/dist/types-ts4.5/pm-plugins/pixel-resizing/ui/index.d.ts +2 -1
  43. package/dist/types-ts4.5/pm-plugins/pixel-resizing/ui/types.d.ts +7 -2
  44. package/dist/types-ts4.5/types/index.d.ts +2 -0
  45. package/dist/types-ts4.5/ui/MediaLinkingToolbar.d.ts +3 -3
  46. package/dist/types-ts4.5/ui/toolbar/alt-text.d.ts +1 -0
  47. package/dist/types-ts4.5/ui/toolbar/comments.d.ts +1 -1
  48. package/dist/types-ts4.5/ui/toolbar/index.d.ts +1 -0
  49. package/dist/types-ts4.5/ui/toolbar/pixel-resizing.d.ts +1 -1
  50. package/package.json +11 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 3.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#153256](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/153256)
8
+ [`3644fbe36073d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3644fbe36073d) -
9
+ [ux] When ViewAll dropdown closes via ESC key press or submenus close via ESC or Enter, the focus
10
+ is set on ViewAll button.
11
+ - Updated dependencies
12
+
13
+ ## 3.0.2
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 3.0.1
4
20
 
5
21
  ### Patch Changes
@@ -366,7 +366,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
366
366
  fullWidthEnabled: options && options.fullWidthEnabled,
367
367
  allowMediaInlineImages: options && options.allowMediaInlineImages,
368
368
  isViewOnly: (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view',
369
- allowPixelResizing: options === null || options === void 0 ? void 0 : options.allowPixelResizing
369
+ allowPixelResizing: options === null || options === void 0 ? void 0 : options.allowPixelResizing,
370
+ onCommentButtonMount: options === null || options === void 0 ? void 0 : options.onCommentButtonMount
370
371
  }, api);
371
372
  }
372
373
  }
@@ -22,7 +22,9 @@ var _ui = require("@atlaskit/editor-common/ui");
22
22
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
23
23
  var _crossCircle = _interopRequireDefault(require("@atlaskit/icon/core/migration/cross-circle"));
24
24
  var _chevronLeftChevronLeftLarge = _interopRequireDefault(require("@atlaskit/icon/utility/migration/chevron-left--chevron-left-large"));
25
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
25
26
  var _colors = require("@atlaskit/theme/colors");
27
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
26
28
  var _commands = require("../commands");
27
29
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
28
30
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
@@ -93,11 +95,15 @@ var AltTextEditComponent = exports.AltTextEditComponent = /*#__PURE__*/function
93
95
  (0, _commands.closeMediaAltTextMenu)(view.state, view.dispatch);
94
96
  }
95
97
  });
98
+ (0, _defineProperty2.default)(_this, "closeMediaAltTextMenuAndSetFocus", function () {
99
+ var _this$props$onEnter, _this$props;
100
+ _this.closeMediaAltTextMenu();
101
+ (_this$props$onEnter = (_this$props = _this.props).onEnter) === null || _this$props$onEnter === void 0 || _this$props$onEnter.call(_this$props);
102
+ });
96
103
  (0, _defineProperty2.default)(_this, "dispatchCancelEvent", function (event) {
97
- var _this$props = _this.props,
98
- view = _this$props.view,
99
- onEscape = _this$props.onEscape;
100
-
104
+ var _this$props2 = _this.props,
105
+ view = _this$props2.view,
106
+ onEscape = _this$props2.onEscape;
101
107
  // We need to pass down the ESCAPE keymap
102
108
  // because when we focus on the Toolbar, Prosemirror blur,
103
109
  // making all keyboard shortcuts not working
@@ -130,7 +136,11 @@ var AltTextEditComponent = exports.AltTextEditComponent = /*#__PURE__*/function
130
136
  (0, _defineProperty2.default)(_this, "handleOnBlur", function (e) {
131
137
  // prevent other selection transaction gets triggered
132
138
  e.stopPropagation();
133
- _this.closeMediaAltTextMenu();
139
+ if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_8')) {
140
+ _this.closeMediaAltTextMenuAndSetFocus();
141
+ } else {
142
+ _this.closeMediaAltTextMenu(); // Why do we close the menu on blur? Is it a bug?
143
+ }
134
144
  });
135
145
  (0, _defineProperty2.default)(_this, "handleClearText", function () {
136
146
  _this.handleOnChange('');
@@ -188,6 +198,7 @@ var AltTextEditComponent = exports.AltTextEditComponent = /*#__PURE__*/function
188
198
  }, error);
189
199
  });
190
200
  var hasErrors = !!errorsList.length;
201
+ var onSubmit = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_8') ? this.closeMediaAltTextMenuAndSetFocus : this.closeMediaAltTextMenu;
191
202
  return (0, _react2.jsx)("div", {
192
203
  css: containerStyles
193
204
  }, (0, _react2.jsx)("section", {
@@ -210,7 +221,7 @@ var AltTextEditComponent = exports.AltTextEditComponent = /*#__PURE__*/function
210
221
  onCancel: this.dispatchCancelEvent,
211
222
  onChange: this.handleOnChange,
212
223
  onBlur: this.handleOnBlur,
213
- onSubmit: this.closeMediaAltTextMenu,
224
+ onSubmit: onSubmit,
214
225
  maxLength: MAX_ALT_TEXT_LENGTH,
215
226
  ariaRequired: true,
216
227
  ariaInvalid: hasErrors,
@@ -240,10 +251,10 @@ var AltTextEditComponent = exports.AltTextEditComponent = /*#__PURE__*/function
240
251
  }, {
241
252
  key: "fireAnalytics",
242
253
  value: function fireAnalytics(actionType) {
243
- var _this$props2 = this.props,
244
- createAnalyticsEvent = _this$props2.createAnalyticsEvent,
245
- nodeType = _this$props2.nodeType,
246
- mediaType = _this$props2.mediaType;
254
+ var _this$props3 = this.props,
255
+ createAnalyticsEvent = _this$props3.createAnalyticsEvent,
256
+ nodeType = _this$props3.nodeType,
257
+ mediaType = _this$props3.mediaType;
247
258
  if (createAnalyticsEvent && this.fireCustomAnalytics) {
248
259
  this.fireCustomAnalytics({
249
260
  payload: {
@@ -26,14 +26,15 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
26
26
  * @jsx jsx
27
27
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
28
28
  var PixelEntry = exports.PixelEntry = function PixelEntry(_ref) {
29
- var _pluginInjectionApi$w, _pluginInjectionApi$m;
29
+ var _pluginInjectionApi$w, _pluginInjectionApi$m, _pluginInjectionApi$f;
30
30
  var editorView = _ref.editorView,
31
31
  selectedMediaSingleNode = _ref.selectedMediaSingleNode,
32
32
  pluginInjectionApi = _ref.pluginInjectionApi,
33
33
  intl = _ref.intl,
34
34
  pluginState = _ref.pluginState,
35
35
  hoverDecoration = _ref.hoverDecoration,
36
- isEditorFullWidthEnabled = _ref.isEditorFullWidthEnabled;
36
+ isEditorFullWidthEnabled = _ref.isEditorFullWidthEnabled,
37
+ triggerButtonSelector = _ref.triggerButtonSelector;
37
38
  var state = editorView.state,
38
39
  dispatch = editorView.dispatch;
39
40
  var mediaSingle = state.schema.nodes.mediaSingle;
@@ -68,6 +69,7 @@ var PixelEntry = exports.PixelEntry = function PixelEntry(_ref) {
68
69
  // get pos of media node
69
70
  mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH);
70
71
  var pixelWidth = hasPixelType ? mediaSingleWidth : pixelWidthFromElement;
72
+ var 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;
71
73
  return (0, _react2.jsx)(_pixelEntry.PixelEntryComponent, {
72
74
  intl: intl,
73
75
  width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
@@ -98,19 +100,28 @@ var PixelEntry = exports.PixelEntry = function PixelEntry(_ref) {
98
100
  }));
99
101
  tr.setMeta('scrollIntoView', false);
100
102
  tr.setSelection(_state.NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
103
+ if (triggerButtonSelector) {
104
+ var newTr = forceFocusSelector && forceFocusSelector(triggerButtonSelector)(tr);
105
+ tr = newTr !== undefined ? newTr : tr;
106
+ }
101
107
  dispatch(tr);
102
108
  },
103
- onCloseAndSave: function onCloseAndSave(_ref3) {
109
+ onCloseAndSave: function onCloseAndSave(_ref3, setFocus) {
104
110
  var width = _ref3.width,
105
111
  validation = _ref3.validation;
106
112
  var tr = updateNodeWithTr(width, validation);
113
+ if (setFocus && triggerButtonSelector) {
114
+ var newTr = forceFocusSelector && tr && forceFocusSelector(triggerButtonSelector)(tr);
115
+ tr = newTr !== undefined ? newTr : tr;
116
+ }
107
117
  if (tr) {
108
118
  return (0, _commands2.closePixelEditorAndSave)(function () {
109
119
  return tr;
110
120
  })(state, dispatch);
111
121
  }
112
122
  },
113
- isViewMode: pluginState.isResizing
123
+ isViewMode: pluginState.isResizing,
124
+ triggerButtonSelector: triggerButtonSelector
114
125
  });
115
126
  };
116
127
  var FullWidthDisplay = exports.FullWidthDisplay = function FullWidthDisplay(_ref4) {
@@ -15,6 +15,7 @@ var _new = require("@atlaskit/button/new");
15
15
  var _media = require("@atlaskit/editor-common/media");
16
16
  var _form = _interopRequireWildcard(require("@atlaskit/form"));
17
17
  var _close = _interopRequireDefault(require("@atlaskit/icon/core/close"));
18
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
19
  var _primitives = require("@atlaskit/primitives");
19
20
  var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
20
21
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
@@ -100,7 +101,7 @@ var PixelEntryComponent = exports.PixelEntryComponent = function PixelEntryCompo
100
101
  };
101
102
 
102
103
  // Handle submit when user presses enter or click close button in PixelEntryComponentNext
103
- var handleCloseAndSave = (0, _react.useCallback)(function (data) {
104
+ var handleCloseAndSave = (0, _react.useCallback)(function (data, setFocus) {
104
105
  if (data.inputWidth === '' || data.inputHeight === '') {
105
106
  return;
106
107
  }
@@ -126,7 +127,7 @@ var PixelEntryComponent = exports.PixelEntryComponent = function PixelEntryCompo
126
127
  onCloseAndSave({
127
128
  width: widthToBeSubmitted,
128
129
  validation: validation
129
- });
130
+ }, setFocus);
130
131
  }
131
132
  }, [maxWidth, minWidth, onCloseAndSave, ratioWidth]);
132
133
 
@@ -292,10 +293,11 @@ var PixelEntryComponentNext = exports.PixelEntryComponentNext = function PixelEn
292
293
  }, [isViewMode, widthInputRef]);
293
294
  var handleKeyDown = (0, _react.useCallback)(function (event) {
294
295
  if (event.key === 'Enter') {
296
+ var shouldSetFocus = true;
295
297
  handleCloseAndSave({
296
298
  inputWidth: computedWidth,
297
299
  inputHeight: computedHeight
298
- });
300
+ }, shouldSetFocus);
299
301
  }
300
302
  }, [computedWidth, computedHeight, handleCloseAndSave]);
301
303
  return (0, _react2.jsx)(_primitives.Box, {
@@ -364,6 +366,7 @@ var PixelEntryComponentNext = exports.PixelEntryComponentNext = function PixelEn
364
366
  inputWidth: computedWidth,
365
367
  inputHeight: computedHeight
366
368
  });
367
- }
369
+ },
370
+ onKeyDown: (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_8') ? handleKeyDown : undefined
368
371
  }))));
369
372
  };
@@ -63,14 +63,14 @@ var LinkAddToolbar = /*#__PURE__*/function (_React$PureComponent) {
63
63
  inputMethod: inputMethod
64
64
  });
65
65
  });
66
- (0, _defineProperty2.default)(_this, "handleOnBack", function (_ref2) {
66
+ (0, _defineProperty2.default)(_this, "handleOnBack", function (_ref2, setFocus) {
67
67
  var url = _ref2.url,
68
68
  inputMethod = _ref2.inputMethod;
69
69
  var onBack = _this.props.onBack;
70
70
  if (onBack) {
71
71
  onBack(url, {
72
72
  inputMethod: inputMethod
73
- });
73
+ }, setFocus);
74
74
  }
75
75
  });
76
76
  (0, _defineProperty2.default)(_this, "handleCancel", function () {
@@ -79,10 +79,10 @@ var LinkAddToolbar = /*#__PURE__*/function (_React$PureComponent) {
79
79
  onCancel();
80
80
  }
81
81
  });
82
- (0, _defineProperty2.default)(_this, "handleUnlink", function () {
82
+ (0, _defineProperty2.default)(_this, "handleUnlink", function (setFocus) {
83
83
  var onUnlink = _this.props.onUnlink;
84
84
  if (onUnlink) {
85
- onUnlink();
85
+ onUnlink(setFocus);
86
86
  }
87
87
  });
88
88
  (0, _defineProperty2.default)(_this, "handleOnBlur", function (options) {
@@ -132,6 +132,14 @@ var LinkAddToolbar = /*#__PURE__*/function (_React$PureComponent) {
132
132
  url: value,
133
133
  inputMethod: currentInputMethod
134
134
  });
135
+ },
136
+ onKeyDown: function onKeyDown(event) {
137
+ if (event.key === 'Enter') {
138
+ _this.handleOnBack({
139
+ url: value,
140
+ inputMethod: currentInputMethod
141
+ }, true);
142
+ }
135
143
  }
136
144
  })), (0, _react2.jsx)(_ui.PanelTextInput, {
137
145
  inputId: "media-link-search-input",
@@ -164,7 +172,14 @@ var LinkAddToolbar = /*#__PURE__*/function (_React$PureComponent) {
164
172
  icon: (0, _react2.jsx)(_linkBrokenEditorUnlink.default, {
165
173
  label: formatUnlinkText
166
174
  }),
167
- onClick: _this.handleUnlink
175
+ onClick: function onClick() {
176
+ return _this.handleUnlink();
177
+ },
178
+ onKeyDown: function onKeyDown(event) {
179
+ if (event.key === 'Enter') {
180
+ _this.handleUnlink(true);
181
+ }
182
+ }
168
183
  }))), !!errorsList.length && (0, _react2.jsx)("section", {
169
184
  css: validationWrapper
170
185
  }, errorsList), renderRecentList()))
@@ -13,6 +13,8 @@ var _styles = require("@atlaskit/editor-common/styles");
13
13
  var _ui = require("@atlaskit/editor-common/ui");
14
14
  var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var _text = _interopRequireDefault(require("@atlaskit/icon/core/text"));
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
16
18
  var _commands = require("../../pm-plugins/alt-text/commands");
17
19
  var _AltTextEdit = _interopRequireDefault(require("../../pm-plugins/alt-text/ui/AltTextEdit"));
18
20
  var _isType = require("../../pm-plugins/utils/is-type");
@@ -55,11 +57,12 @@ var altTextEditComponent = function altTextEditComponent(options) {
55
57
  /** Focus should move to the 'Alt text' button when the toolbar closes
56
58
  * and not close the floating toolbar.
57
59
  */
58
- var handleEsc = function handleEsc() {
60
+ var setFocus = function setFocus() {
59
61
  var _options$forceFocusSe;
60
62
  var tr = view.state.tr,
61
63
  dispatch = view.dispatch;
62
- var newTr = options === null || options === void 0 || (_options$forceFocusSe = options.forceFocusSelector) === null || _options$forceFocusSe === void 0 ? void 0 : _options$forceFocusSe.call(options, "[data-testid=\"".concat(testId, "\"]"))(tr);
64
+ var elementSelector = options !== null && options !== void 0 && options.triggerButtonSelector && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_8') ? options.triggerButtonSelector : "[data-testid=\"".concat(testId, "\"]");
65
+ var newTr = options === null || options === void 0 || (_options$forceFocusSe = options.forceFocusSelector) === null || _options$forceFocusSe === void 0 ? void 0 : _options$forceFocusSe.call(options, elementSelector)(tr);
63
66
  if (newTr) {
64
67
  dispatch(newTr);
65
68
  }
@@ -72,7 +75,8 @@ var altTextEditComponent = function altTextEditComponent(options) {
72
75
  mediaType: mediaNode.attrs.type,
73
76
  value: mediaNode.attrs.alt,
74
77
  altTextValidator: options && options.altTextValidator,
75
- onEscape: handleEsc
78
+ onEscape: setFocus,
79
+ onEnter: setFocus
76
80
  });
77
81
  }
78
82
  };
@@ -15,7 +15,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
15
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
16
16
  var _commentWithDotIcon = require("./assets/commentWithDotIcon");
17
17
  var _utils = require("./utils");
18
- var commentButton = exports.commentButton = function commentButton(intl, state, api) {
18
+ var commentButton = exports.commentButton = function commentButton(intl, state, api, onCommentButtonMount) {
19
19
  var _getSelectedMediaSing, _api$annotation, _api$connectivity;
20
20
  var selectMediaNode = (_getSelectedMediaSing = (0, _utils.getSelectedMediaSingle)(state)) === null || _getSelectedMediaSing === void 0 ? void 0 : _getSelectedMediaSing.node.firstChild;
21
21
  var hasActiveComments = false;
@@ -54,6 +54,11 @@ var commentButton = exports.commentButton = function commentButton(intl, state,
54
54
  description: title
55
55
  }),
56
56
  supportsViewMode: true,
57
- disabled: (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline'
57
+ disabled: (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline',
58
+ onMount: function onMount() {
59
+ if ((0, _platformFeatureFlags.fg)('confluence_frontend_preload_inline_comment_editor')) {
60
+ onCommentButtonMount && onCommentButtonMount();
61
+ }
62
+ }
58
63
  };
59
64
  };
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.handleShowMediaViewer = exports.floatingToolbar = void 0;
8
+ exports.overflowDropdwonBtnTriggerTestId = exports.handleShowMediaViewer = exports.floatingToolbar = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
@@ -279,7 +279,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
279
279
  allowMediaInlineImages = options.allowMediaInlineImages,
280
280
  allowImagePreview = options.allowImagePreview,
281
281
  isViewOnly = options.isViewOnly,
282
- allowPixelResizing = options.allowPixelResizing;
282
+ allowPixelResizing = options.allowPixelResizing,
283
+ onCommentButtonMount = options.onCommentButtonMount;
283
284
  var toolbarButtons = [];
284
285
  var _ref2 = (_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 : {},
285
286
  hoverDecoration = _ref2.hoverDecoration;
@@ -549,7 +550,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
549
550
  }
550
551
  if (!isEditorControlsEnabled) {
551
552
  if (allowCommentsOnMedia) {
552
- toolbarButtons.push((0, _comments.commentButton)(intl, state, pluginInjectionApi), {
553
+ toolbarButtons.push((0, _comments.commentButton)(intl, state, pluginInjectionApi, onCommentButtonMount), {
553
554
  type: 'separator',
554
555
  supportsViewMode: true
555
556
  });
@@ -736,7 +737,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
736
737
  });
737
738
  if (allowAdvancedToolBarOptions && allowCommentsOnMedia) {
738
739
  (0, _utils2.updateToFullHeightSeparator)(toolbarButtons);
739
- toolbarButtons.push((0, _comments.commentButton)(intl, state, pluginInjectionApi));
740
+ toolbarButtons.push((0, _comments.commentButton)(intl, state, pluginInjectionApi, onCommentButtonMount));
740
741
  }
741
742
  return toolbarButtons;
742
743
  }
@@ -747,6 +748,7 @@ var getMediaTypeMessage = function getMediaTypeMessage(selectedNodeTypeSingle) {
747
748
  });
748
749
  return mediaType ? mediaTypeMessages[mediaType] : _mediaUi.messages.file_unknown_is_selected;
749
750
  };
751
+ var overflowDropdwonBtnTriggerTestId = exports.overflowDropdwonBtnTriggerTestId = 'media-overflow-dropdown-trigger';
750
752
  var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state, intl) {
751
753
  var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
752
754
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
@@ -792,13 +794,18 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
792
794
  return linkingToolbar;
793
795
  }
794
796
  }
797
+
798
+ // testId is required to show focus on trigger button on ESC key press
799
+ // see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
800
+ var overflowButtonSelector = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_8') ? "[data-testid=\"".concat(overflowDropdwonBtnTriggerTestId, "\"]") : undefined;
795
801
  if (allowAltTextOnImages) {
796
802
  var mediaAltTextPluginState = (0, _altText.getPluginState)(state);
797
803
  if (mediaAltTextPluginState.isAltTextEditorOpen) {
798
804
  var _pluginInjectionApi$f;
799
805
  return (0, _altText2.getAltTextToolbar)(baseToolbar, {
800
806
  altTextValidator: altTextValidator,
801
- 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
807
+ 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,
808
+ triggerButtonSelector: overflowButtonSelector
802
809
  });
803
810
  }
804
811
  }
@@ -812,7 +819,8 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
812
819
  pluginInjectionApi: pluginInjectionApi,
813
820
  pluginState: mediaPluginState,
814
821
  hoverDecoration: hoverDecoration,
815
- isEditorFullWidthEnabled: options.fullWidthEnabled
822
+ isEditorFullWidthEnabled: options.fullWidthEnabled,
823
+ triggerButtonSelector: overflowButtonSelector
816
824
  });
817
825
  }
818
826
  }
@@ -865,6 +873,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
865
873
  items.push({
866
874
  type: 'overflow-dropdown',
867
875
  id: 'media',
876
+ testId: overflowDropdwonBtnTriggerTestId,
868
877
  options: [].concat((0, _toConsumableArray2.default)(customOptions), [_objectSpread({
869
878
  title: intl === null || intl === void 0 ? void 0 : intl.formatMessage(_messages.default.copyToClipboard),
870
879
  onClick: function onClick() {
@@ -15,6 +15,7 @@ var _ui = require("@atlaskit/editor-common/ui");
15
15
  var _link = _interopRequireDefault(require("@atlaskit/icon/core/link"));
16
16
  var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
17
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
19
  var _linking = require("../../pm-plugins/commands/linking");
19
20
  var _linking2 = require("../../pm-plugins/linking");
20
21
  var _currentMediaNode = require("../../pm-plugins/utils/current-media-node");
@@ -22,6 +23,7 @@ var _MediaLinkingToolbar = _interopRequireDefault(require("../../ui/MediaLinking
22
23
  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; }
23
24
  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; }
24
25
  var FORCE_FOCUS_SELECTOR = '[data-testid="add-link-button"],[data-testid="edit-link-button"]';
26
+ var FORCE_FOCUS_SELECTOR_EDITOR_CONTROLS = '[data-testid="media-overflow-dropdown-trigger"]';
25
27
  function shouldShowMediaLinkToolbar(editorState) {
26
28
  var mediaLinkingState = (0, _linking2.getMediaLinkingState)(editorState);
27
29
  if (!mediaLinkingState || mediaLinkingState.mediaPos === null) {
@@ -60,38 +62,51 @@ var getLinkingToolbar = exports.getLinkingToolbar = function getLinkingToolbar(t
60
62
  if (!view || !providerFactory) {
61
63
  return null;
62
64
  }
65
+ var setFocusOnFloatingToolbar = function setFocusOnFloatingToolbar(setFocus) {
66
+ if (setFocus && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_8')) {
67
+ var _pluginInjectionApi$f;
68
+ var tr = view.state.tr,
69
+ dispatch = view.dispatch;
70
+ 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_EDITOR_CONTROLS)(tr);
71
+ dispatch(tr);
72
+ }
73
+ };
63
74
  return /*#__PURE__*/_react.default.createElement(_MediaLinkingToolbar.default, {
64
75
  key: idx,
65
76
  displayUrl: link,
66
77
  providerFactory: providerFactory,
67
78
  intl: intl,
68
79
  editing: editing,
69
- onUnlink: function onUnlink() {
80
+ onUnlink: function onUnlink(setFocus) {
70
81
  var _pluginInjectionApi$a;
71
- return (0, _linking.unlink)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(view.state, view.dispatch, view);
82
+ (0, _linking.unlink)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(view.state, view.dispatch, view);
83
+ setFocusOnFloatingToolbar(setFocus);
72
84
  },
73
- onBack: function onBack(href, meta) {
85
+ onBack: function onBack(href, meta, setFocus) {
74
86
  if (href.trim() && meta.inputMethod) {
75
87
  var _pluginInjectionApi$a2;
76
88
  (0, _linking.setUrlToMedia)(href, meta.inputMethod, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(view.state, view.dispatch, view);
77
89
  }
78
90
  (0, _linking.hideLinkingToolbar)(view.state, view.dispatch, view);
91
+ setFocusOnFloatingToolbar(setFocus);
79
92
  },
80
93
  onCancel: function onCancel() {
81
- var _pluginInjectionApi$f;
94
+ var _pluginInjectionApi$f2;
82
95
  (0, _linking.hideLinkingToolbar)(view.state, view.dispatch, view, true);
83
96
  /** Focus should move to the 'Add link' button when the toolbar closes
84
97
  * and not close the floating toolbar.
85
98
  */
86
99
  var tr = view.state.tr,
87
100
  dispatch = view.dispatch;
88
- 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);
101
+ var selector = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_8') ? FORCE_FOCUS_SELECTOR_EDITOR_CONTROLS : FORCE_FOCUS_SELECTOR;
102
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 || (_pluginInjectionApi$f2 = _pluginInjectionApi$f2.actions) === null || _pluginInjectionApi$f2 === void 0 || _pluginInjectionApi$f2.forceFocusSelector(selector)(tr);
89
103
  dispatch(tr);
90
104
  },
91
105
  onSubmit: function onSubmit(href, meta) {
92
106
  var _pluginInjectionApi$a3;
93
107
  (0, _linking.setUrlToMedia)(href, meta.inputMethod, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(view.state, view.dispatch, view);
94
108
  (0, _linking.hideLinkingToolbar)(view.state, view.dispatch, view);
109
+ setFocusOnFloatingToolbar(true);
95
110
  },
96
111
  onBlur: function onBlur() {
97
112
  (0, _linking.hideLinkingToolbar)(view.state, view.dispatch, view);
@@ -23,7 +23,8 @@ var getPixelResizingToolbar = exports.getPixelResizingToolbar = function getPixe
23
23
  intl = _ref.intl,
24
24
  pluginState = _ref.pluginState,
25
25
  hoverDecoration = _ref.hoverDecoration,
26
- isEditorFullWidthEnabled = _ref.isEditorFullWidthEnabled;
26
+ isEditorFullWidthEnabled = _ref.isEditorFullWidthEnabled,
27
+ triggerButtonSelector = _ref.triggerButtonSelector;
27
28
  return _objectSpread(_objectSpread({}, toolbarBaseConfig), {}, {
28
29
  width: _constants.PIXEL_RESIZING_TOOLBAR_WIDTH,
29
30
  scrollable: true,
@@ -45,7 +46,8 @@ var getPixelResizingToolbar = exports.getPixelResizingToolbar = function getPixe
45
46
  pluginInjectionApi: pluginInjectionApi,
46
47
  pluginState: pluginState,
47
48
  hoverDecoration: hoverDecoration,
48
- isEditorFullWidthEnabled: isEditorFullWidthEnabled
49
+ isEditorFullWidthEnabled: isEditorFullWidthEnabled,
50
+ triggerButtonSelector: triggerButtonSelector
49
51
  });
50
52
  }
51
53
  }]
@@ -361,7 +361,8 @@ export const mediaPlugin = ({
361
361
  fullWidthEnabled: options && options.fullWidthEnabled,
362
362
  allowMediaInlineImages: options && options.allowMediaInlineImages,
363
363
  isViewOnly: (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view',
364
- allowPixelResizing: options === null || options === void 0 ? void 0 : options.allowPixelResizing
364
+ allowPixelResizing: options === null || options === void 0 ? void 0 : options.allowPixelResizing,
365
+ onCommentButtonMount: options === null || options === void 0 ? void 0 : options.onCommentButtonMount
365
366
  }, api);
366
367
  }
367
368
  }
@@ -17,7 +17,9 @@ import { RECENT_SEARCH_WIDTH_IN_PX as CONTAINER_WIDTH_IN_PX, FloatingToolbarButt
17
17
  import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
18
18
  import CrossCircleIcon from '@atlaskit/icon/core/migration/cross-circle';
19
19
  import ChevronLeftLargeIcon from '@atlaskit/icon/utility/migration/chevron-left--chevron-left-large';
20
+ import { fg } from '@atlaskit/platform-feature-flags';
20
21
  import { N200, N30, N80, R400 } from '@atlaskit/theme/colors';
22
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
21
23
  import { closeMediaAltTextMenu, closeMediaAltTextMenuAndSave } from '../commands';
22
24
  export const MAX_ALT_TEXT_LENGTH = 510; // double tweet length
23
25
 
@@ -83,12 +85,16 @@ export class AltTextEditComponent extends React.Component {
83
85
  closeMediaAltTextMenu(view.state, view.dispatch);
84
86
  }
85
87
  });
88
+ _defineProperty(this, "closeMediaAltTextMenuAndSetFocus", () => {
89
+ var _this$props$onEnter, _this$props;
90
+ this.closeMediaAltTextMenu();
91
+ (_this$props$onEnter = (_this$props = this.props).onEnter) === null || _this$props$onEnter === void 0 ? void 0 : _this$props$onEnter.call(_this$props);
92
+ });
86
93
  _defineProperty(this, "dispatchCancelEvent", event => {
87
94
  const {
88
95
  view,
89
96
  onEscape
90
97
  } = this.props;
91
-
92
98
  // We need to pass down the ESCAPE keymap
93
99
  // because when we focus on the Toolbar, Prosemirror blur,
94
100
  // making all keyboard shortcuts not working
@@ -119,7 +125,11 @@ export class AltTextEditComponent extends React.Component {
119
125
  _defineProperty(this, "handleOnBlur", e => {
120
126
  // prevent other selection transaction gets triggered
121
127
  e.stopPropagation();
122
- this.closeMediaAltTextMenu();
128
+ if (editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_8')) {
129
+ this.closeMediaAltTextMenuAndSetFocus();
130
+ } else {
131
+ this.closeMediaAltTextMenu(); // Why do we close the menu on blur? Is it a bug?
132
+ }
123
133
  });
124
134
  _defineProperty(this, "handleClearText", () => {
125
135
  this.handleOnChange('');
@@ -177,6 +187,7 @@ export class AltTextEditComponent extends React.Component {
177
187
  }, error);
178
188
  });
179
189
  const hasErrors = !!errorsList.length;
190
+ const onSubmit = editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_controls_patch_8') ? this.closeMediaAltTextMenuAndSetFocus : this.closeMediaAltTextMenu;
180
191
  return jsx("div", {
181
192
  css: containerStyles
182
193
  }, jsx("section", {
@@ -199,7 +210,7 @@ export class AltTextEditComponent extends React.Component {
199
210
  onCancel: this.dispatchCancelEvent,
200
211
  onChange: this.handleOnChange,
201
212
  onBlur: this.handleOnBlur,
202
- onSubmit: this.closeMediaAltTextMenu,
213
+ onSubmit: onSubmit,
203
214
  maxLength: MAX_ALT_TEXT_LENGTH,
204
215
  ariaRequired: true,
205
216
  ariaInvalid: hasErrors,
@@ -25,9 +25,10 @@ export const PixelEntry = ({
25
25
  intl,
26
26
  pluginState,
27
27
  hoverDecoration,
28
- isEditorFullWidthEnabled
28
+ isEditorFullWidthEnabled,
29
+ triggerButtonSelector
29
30
  }) => {
30
- var _pluginInjectionApi$w, _pluginInjectionApi$m, _pluginInjectionApi$m2;
31
+ var _pluginInjectionApi$w, _pluginInjectionApi$m, _pluginInjectionApi$m2, _pluginInjectionApi$f, _pluginInjectionApi$f2;
31
32
  const {
32
33
  state,
33
34
  dispatch
@@ -66,6 +67,7 @@ export const PixelEntry = ({
66
67
  // get pos of media node
67
68
  mediaWidth || DEFAULT_IMAGE_WIDTH);
68
69
  const pixelWidth = hasPixelType ? mediaSingleWidth : pixelWidthFromElement;
70
+ const 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;
69
71
  return jsx(PixelEntryComponent, {
70
72
  intl: intl,
71
73
  width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
@@ -91,25 +93,34 @@ export const PixelEntry = ({
91
93
  }
92
94
  },
93
95
  onMigrate: () => {
94
- const tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, {
96
+ let tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, {
95
97
  ...selectedMediaSingleNode.node.attrs,
96
98
  width: pixelWidthFromElement,
97
99
  widthType: 'pixel'
98
100
  });
99
101
  tr.setMeta('scrollIntoView', false);
100
102
  tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
103
+ if (triggerButtonSelector) {
104
+ const newTr = forceFocusSelector && forceFocusSelector(triggerButtonSelector)(tr);
105
+ tr = newTr !== undefined ? newTr : tr;
106
+ }
101
107
  dispatch(tr);
102
108
  },
103
109
  onCloseAndSave: ({
104
110
  width,
105
111
  validation
106
- }) => {
107
- const tr = updateNodeWithTr(width, validation);
112
+ }, setFocus) => {
113
+ let tr = updateNodeWithTr(width, validation);
114
+ if (setFocus && triggerButtonSelector) {
115
+ const newTr = forceFocusSelector && tr && forceFocusSelector(triggerButtonSelector)(tr);
116
+ tr = newTr !== undefined ? newTr : tr;
117
+ }
108
118
  if (tr) {
109
119
  return closePixelEditorAndSave(() => tr)(state, dispatch);
110
120
  }
111
121
  },
112
- isViewMode: pluginState.isResizing
122
+ isViewMode: pluginState.isResizing,
123
+ triggerButtonSelector: triggerButtonSelector
113
124
  });
114
125
  };
115
126
  export const FullWidthDisplay = ({