@atlaskit/editor-plugin-insert-block 2.2.2 → 2.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-insert-block
2
2
 
3
+ ## 2.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#146643](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/146643)
8
+ [`6b3dec2ad5378`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6b3dec2ad5378) -
9
+ [ux] ED-25116 Pin media popup to toolbar when triggered from toolbar
10
+ - Updated dependencies
11
+
3
12
  ## 2.2.2
4
13
 
5
14
  ### Patch Changes
@@ -340,13 +340,13 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
340
340
  }
341
341
  };
342
342
  var emojiProvider = getEmojiProvider();
343
- var onShowMediaPicker = function onShowMediaPicker() {
343
+ var onShowMediaPicker = function onShowMediaPicker(targetRef) {
344
344
  if (!mediaState) {
345
345
  return;
346
346
  }
347
347
  if ((0, _experiments.editorExperiment)('add-media-from-url', true)) {
348
348
  var _pluginInjectionApi$c, _pluginInjectionApi$m;
349
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.mediaInsert) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.commands.showMediaInsertPopup);
349
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.mediaInsert) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.commands.showMediaInsertPopup(targetRef));
350
350
  } else {
351
351
  mediaState.showMediaPicker();
352
352
  }
@@ -54,7 +54,6 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
54
54
  var isDetachedElement = function isDetachedElement(el) {
55
55
  return !document.body.contains(el);
56
56
  };
57
- var noop = function noop() {};
58
57
  var EmojiPickerWithListeners = (0, _uiReact.withReactEditorViewOuterListeners)(_picker.EmojiPicker);
59
58
  var TABLE_SELECTOR_STRING = 'table selector';
60
59
 
@@ -167,10 +166,20 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
167
166
  _this.toggleEmojiPicker(_analytics.INPUT_METHOD.TOOLBAR);
168
167
  }
169
168
  });
170
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleEmojiButtonRef", function (ref) {
171
- if (ref) {
172
- _this.emojiButtonRef = ref;
173
- }
169
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleToolbarRef", function (buttonName) {
170
+ return function (ref) {
171
+ if (!ref) {
172
+ return;
173
+ }
174
+ switch (buttonName) {
175
+ case 'emoji':
176
+ _this.emojiButtonRef = ref;
177
+ break;
178
+ case 'media':
179
+ _this.mediaButtonRef = ref;
180
+ break;
181
+ }
182
+ };
174
183
  });
175
184
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handlePlusButtonRef", function (ref) {
176
185
  if (ref) {
@@ -363,7 +372,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
363
372
  onShowMediaPicker = _this$props5.onShowMediaPicker,
364
373
  dispatchAnalyticsEvent = _this$props5.dispatchAnalyticsEvent;
365
374
  if (onShowMediaPicker) {
366
- onShowMediaPicker();
375
+ onShowMediaPicker(_this.mediaButtonRef);
367
376
  if (dispatchAnalyticsEvent) {
368
377
  dispatchAnalyticsEvent({
369
378
  action: _analytics.ACTION.OPENED,
@@ -712,7 +721,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
712
721
  return (0, _react2.jsx)(_uiMenu.ToolbarButton, {
713
722
  item: btn,
714
723
  testId: String(btn.content),
715
- ref: btn.value.name === 'emoji' ? _this4.handleEmojiButtonRef : noop,
724
+ ref: _this4.handleToolbarRef(btn.value.name),
716
725
  key: btn.value.name,
717
726
  spacing: isReducedSpacing ? 'none' : 'default',
718
727
  disabled: isDisabled || btn.isDisabled,
@@ -335,13 +335,13 @@ function ToolbarInsertBlockWithInjectionApi({
335
335
  }
336
336
  };
337
337
  const emojiProvider = getEmojiProvider();
338
- const onShowMediaPicker = () => {
338
+ const onShowMediaPicker = targetRef => {
339
339
  if (!mediaState) {
340
340
  return;
341
341
  }
342
342
  if (editorExperiment('add-media-from-url', true)) {
343
343
  var _pluginInjectionApi$c, _pluginInjectionApi$m;
344
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.mediaInsert) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.commands.showMediaInsertPopup);
344
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.mediaInsert) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.commands.showMediaInsertPopup(targetRef));
345
345
  } else {
346
346
  mediaState.showMediaPicker();
347
347
  }
@@ -27,7 +27,6 @@ import TableSelectorPopup from './table-selector-popup-with-listeners';
27
27
  * Checks if an element is detached (i.e. not in the current document)
28
28
  */
29
29
  const isDetachedElement = el => !document.body.contains(el);
30
- const noop = () => {};
31
30
  const EmojiPickerWithListeners = withOuterListeners(AkEmojiPicker);
32
31
  const TABLE_SELECTOR_STRING = 'table selector';
33
32
 
@@ -168,9 +167,17 @@ export class ToolbarInsertBlock extends React.PureComponent {
168
167
  this.toggleEmojiPicker(INPUT_METHOD.TOOLBAR);
169
168
  }
170
169
  });
171
- _defineProperty(this, "handleEmojiButtonRef", ref => {
172
- if (ref) {
173
- this.emojiButtonRef = ref;
170
+ _defineProperty(this, "handleToolbarRef", buttonName => ref => {
171
+ if (!ref) {
172
+ return;
173
+ }
174
+ switch (buttonName) {
175
+ case 'emoji':
176
+ this.emojiButtonRef = ref;
177
+ break;
178
+ case 'media':
179
+ this.mediaButtonRef = ref;
180
+ break;
174
181
  }
175
182
  });
176
183
  _defineProperty(this, "handlePlusButtonRef", ref => {
@@ -379,7 +386,7 @@ export class ToolbarInsertBlock extends React.PureComponent {
379
386
  dispatchAnalyticsEvent
380
387
  } = this.props;
381
388
  if (onShowMediaPicker) {
382
- onShowMediaPicker();
389
+ onShowMediaPicker(this.mediaButtonRef);
383
390
  if (dispatchAnalyticsEvent) {
384
391
  dispatchAnalyticsEvent({
385
392
  action: ACTION.OPENED,
@@ -746,7 +753,7 @@ export class ToolbarInsertBlock extends React.PureComponent {
746
753
  return jsx(ToolbarButton, {
747
754
  item: btn,
748
755
  testId: String(btn.content),
749
- ref: btn.value.name === 'emoji' ? this.handleEmojiButtonRef : noop,
756
+ ref: this.handleToolbarRef(btn.value.name),
750
757
  key: btn.value.name,
751
758
  spacing: isReducedSpacing ? 'none' : 'default',
752
759
  disabled: isDisabled || btn.isDisabled,
@@ -330,13 +330,13 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
330
330
  }
331
331
  };
332
332
  var emojiProvider = getEmojiProvider();
333
- var onShowMediaPicker = function onShowMediaPicker() {
333
+ var onShowMediaPicker = function onShowMediaPicker(targetRef) {
334
334
  if (!mediaState) {
335
335
  return;
336
336
  }
337
337
  if (editorExperiment('add-media-from-url', true)) {
338
338
  var _pluginInjectionApi$c, _pluginInjectionApi$m;
339
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.mediaInsert) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.commands.showMediaInsertPopup);
339
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.mediaInsert) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.commands.showMediaInsertPopup(targetRef));
340
340
  } else {
341
341
  mediaState.showMediaPicker();
342
342
  }
@@ -45,7 +45,6 @@ import TableSelectorPopup from './table-selector-popup-with-listeners';
45
45
  var isDetachedElement = function isDetachedElement(el) {
46
46
  return !document.body.contains(el);
47
47
  };
48
- var noop = function noop() {};
49
48
  var EmojiPickerWithListeners = withOuterListeners(AkEmojiPicker);
50
49
  var TABLE_SELECTOR_STRING = 'table selector';
51
50
 
@@ -158,10 +157,20 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
158
157
  _this.toggleEmojiPicker(INPUT_METHOD.TOOLBAR);
159
158
  }
160
159
  });
161
- _defineProperty(_assertThisInitialized(_this), "handleEmojiButtonRef", function (ref) {
162
- if (ref) {
163
- _this.emojiButtonRef = ref;
164
- }
160
+ _defineProperty(_assertThisInitialized(_this), "handleToolbarRef", function (buttonName) {
161
+ return function (ref) {
162
+ if (!ref) {
163
+ return;
164
+ }
165
+ switch (buttonName) {
166
+ case 'emoji':
167
+ _this.emojiButtonRef = ref;
168
+ break;
169
+ case 'media':
170
+ _this.mediaButtonRef = ref;
171
+ break;
172
+ }
173
+ };
165
174
  });
166
175
  _defineProperty(_assertThisInitialized(_this), "handlePlusButtonRef", function (ref) {
167
176
  if (ref) {
@@ -354,7 +363,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
354
363
  onShowMediaPicker = _this$props5.onShowMediaPicker,
355
364
  dispatchAnalyticsEvent = _this$props5.dispatchAnalyticsEvent;
356
365
  if (onShowMediaPicker) {
357
- onShowMediaPicker();
366
+ onShowMediaPicker(_this.mediaButtonRef);
358
367
  if (dispatchAnalyticsEvent) {
359
368
  dispatchAnalyticsEvent({
360
369
  action: ACTION.OPENED,
@@ -703,7 +712,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
703
712
  return jsx(ToolbarButton, {
704
713
  item: btn,
705
714
  testId: String(btn.content),
706
- ref: btn.value.name === 'emoji' ? _this4.handleEmojiButtonRef : noop,
715
+ ref: _this4.handleToolbarRef(btn.value.name),
707
716
  key: btn.value.name,
708
717
  spacing: isReducedSpacing ? 'none' : 'default',
709
718
  disabled: isDisabled || btn.isDisabled,
@@ -16,6 +16,7 @@ type InternalActions = {
16
16
  export declare class ToolbarInsertBlock extends React.PureComponent<Props & WrappedComponentProps & InternalActions, State> {
17
17
  private dropdownButtonRef?;
18
18
  private emojiButtonRef?;
19
+ private mediaButtonRef?;
19
20
  private plusButtonRef?;
20
21
  private tableButtonRef;
21
22
  private tableSelectorButtonRef;
@@ -29,7 +30,7 @@ export declare class ToolbarInsertBlock extends React.PureComponent<Props & Wrap
29
30
  private handleEmojiPressEscape;
30
31
  private handleEmojiClickOutside;
31
32
  private renderPopup;
32
- private handleEmojiButtonRef;
33
+ private handleToolbarRef;
33
34
  private handlePlusButtonRef;
34
35
  private handleDropDownButtonRef;
35
36
  private toggleTableSelector;
@@ -42,7 +42,7 @@ export interface Props {
42
42
  insertMenuItems?: MenuItem[];
43
43
  showElementBrowserLink?: boolean;
44
44
  showSeparator?: boolean;
45
- onShowMediaPicker?: () => void;
45
+ onShowMediaPicker?: (ref?: HTMLElement) => void;
46
46
  onInsertBlockType?: (name: string) => Command;
47
47
  onInsertMacroFromMacroBrowser?: (macroProvider: MacroProvider, node?: PMNode, isEditing?: boolean) => (view: EditorView) => void;
48
48
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
@@ -16,6 +16,7 @@ type InternalActions = {
16
16
  export declare class ToolbarInsertBlock extends React.PureComponent<Props & WrappedComponentProps & InternalActions, State> {
17
17
  private dropdownButtonRef?;
18
18
  private emojiButtonRef?;
19
+ private mediaButtonRef?;
19
20
  private plusButtonRef?;
20
21
  private tableButtonRef;
21
22
  private tableSelectorButtonRef;
@@ -29,7 +30,7 @@ export declare class ToolbarInsertBlock extends React.PureComponent<Props & Wrap
29
30
  private handleEmojiPressEscape;
30
31
  private handleEmojiClickOutside;
31
32
  private renderPopup;
32
- private handleEmojiButtonRef;
33
+ private handleToolbarRef;
33
34
  private handlePlusButtonRef;
34
35
  private handleDropDownButtonRef;
35
36
  private toggleTableSelector;
@@ -42,7 +42,7 @@ export interface Props {
42
42
  insertMenuItems?: MenuItem[];
43
43
  showElementBrowserLink?: boolean;
44
44
  showSeparator?: boolean;
45
- onShowMediaPicker?: () => void;
45
+ onShowMediaPicker?: (ref?: HTMLElement) => void;
46
46
  onInsertBlockType?: (name: string) => Command;
47
47
  onInsertMacroFromMacroBrowser?: (macroProvider: MacroProvider, node?: PMNode, isEditing?: boolean) => (view: EditorView) => void;
48
48
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-insert-block",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "Insert block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -45,7 +45,7 @@
45
45
  "@atlaskit/editor-plugin-image-upload": "^1.2.0",
46
46
  "@atlaskit/editor-plugin-layout": "^1.8.0",
47
47
  "@atlaskit/editor-plugin-media": "^1.34.0",
48
- "@atlaskit/editor-plugin-media-insert": "^3.0.0",
48
+ "@atlaskit/editor-plugin-media-insert": "^3.1.0",
49
49
  "@atlaskit/editor-plugin-mentions": "^2.6.0",
50
50
  "@atlaskit/editor-plugin-panel": "^2.5.0",
51
51
  "@atlaskit/editor-plugin-placeholder-text": "^1.7.0",
@@ -54,7 +54,7 @@
54
54
  "@atlaskit/editor-plugin-rule": "^1.8.0",
55
55
  "@atlaskit/editor-plugin-status": "^2.4.0",
56
56
  "@atlaskit/editor-plugin-table": "^7.28.0",
57
- "@atlaskit/editor-plugin-tasks-and-decisions": "^2.6.0",
57
+ "@atlaskit/editor-plugin-tasks-and-decisions": "^2.7.0",
58
58
  "@atlaskit/editor-plugin-type-ahead": "^1.8.0",
59
59
  "@atlaskit/editor-prosemirror": "6.0.0",
60
60
  "@atlaskit/editor-shared-styles": "^3.0.0",