@atlaskit/editor-plugin-insert-block 2.2.6 → 2.2.8

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,22 @@
1
1
  # @atlaskit/editor-plugin-insert-block
2
2
 
3
+ ## 2.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#147412](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147412)
8
+ [`aa848a0cd334a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/aa848a0cd334a) -
9
+ fix button number issue, show more buttons on smaller screens
10
+ - Updated dependencies
11
+
12
+ ## 2.2.7
13
+
14
+ ### Patch Changes
15
+
16
+ - [#147461](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147461)
17
+ [`acef010cdb706`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/acef010cdb706) -
18
+ [ux] [ED-25164] Pass mounting point to media insert plugin for correct toolbar popup positioning
19
+
3
20
  ## 2.2.6
4
21
 
5
22
  ### Patch Changes
@@ -32,9 +32,10 @@ var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize, appearance
32
32
  switch (toolbarSize) {
33
33
  case _types.ToolbarSize.XXL:
34
34
  case _types.ToolbarSize.XL:
35
- return 7;
36
35
  case _types.ToolbarSize.L:
37
- return 5;
36
+ return 7;
37
+ case _types.ToolbarSize.M:
38
+ return 3;
38
39
  default:
39
40
  return 0;
40
41
  }
@@ -336,13 +337,13 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
336
337
  }
337
338
  };
338
339
  var emojiProvider = getEmojiProvider();
339
- var onShowMediaPicker = function onShowMediaPicker(targetRef) {
340
+ var onShowMediaPicker = function onShowMediaPicker(mountInfo) {
340
341
  if (!mediaState) {
341
342
  return;
342
343
  }
343
344
  if ((0, _experiments.editorExperiment)('add-media-from-url', true)) {
344
345
  var _pluginInjectionApi$c, _pluginInjectionApi$m;
345
- 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));
346
+ 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(mountInfo));
346
347
  } else {
347
348
  mediaState.showMediaPicker();
348
349
  }
@@ -216,12 +216,18 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
216
216
  disabled: false
217
217
  }));
218
218
  }
219
- var numButtonsWithoutTableSelector = numberOfButtons;
220
- if (!(0, _platformFeatureFlags.fg)('platform_editor_toolbar_responsive_fixes')) {
221
- numButtonsWithoutTableSelector = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
222
- }
223
- var buttonItems = items.slice(0, numButtonsWithoutTableSelector).map(buttonToItem);
224
- var remainingItems = items.slice(numButtonsWithoutTableSelector).filter(function (_ref) {
219
+ var numButtonsAdjusted = numberOfButtons;
220
+ if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_responsive_fixes')) {
221
+ if (items.slice(0, numButtonsAdjusted).some(function (item) {
222
+ return item.value.name === 'table selector';
223
+ })) {
224
+ numButtonsAdjusted++;
225
+ }
226
+ } else {
227
+ numButtonsAdjusted = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
228
+ }
229
+ var buttonItems = items.slice(0, numButtonsAdjusted).map(buttonToItem);
230
+ var remainingItems = items.slice(numButtonsAdjusted).filter(function (_ref) {
225
231
  var name = _ref.value.name;
226
232
  return name !== 'table selector';
227
233
  });
@@ -75,10 +75,10 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
75
75
  function ToolbarInsertBlock() {
76
76
  var _this;
77
77
  (0, _classCallCheck2.default)(this, ToolbarInsertBlock);
78
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
79
- args[_key] = arguments[_key];
78
+ for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
79
+ _args[_key] = arguments[_key];
80
80
  }
81
- _this = _super.call.apply(_super, [this].concat(args));
81
+ _this = _super.call.apply(_super, [this].concat(_args));
82
82
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tableButtonRef", /*#__PURE__*/_react.default.createRef());
83
83
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tableSelectorButtonRef", /*#__PURE__*/_react.default.createRef());
84
84
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unregisterToggleDropdownMenuOptions", null);
@@ -372,7 +372,12 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
372
372
  onShowMediaPicker = _this$props5.onShowMediaPicker,
373
373
  dispatchAnalyticsEvent = _this$props5.dispatchAnalyticsEvent;
374
374
  if (onShowMediaPicker) {
375
- onShowMediaPicker(_this.mediaButtonRef);
375
+ var _this$props$popupsMou;
376
+ var args = _this.mediaButtonRef ? {
377
+ ref: _this.mediaButtonRef,
378
+ mountPoint: (_this$props$popupsMou = _this.props.popupsMountPoint) !== null && _this$props$popupsMou !== void 0 ? _this$props$popupsMou : _this.mediaButtonRef
379
+ } : undefined;
380
+ onShowMediaPicker(args);
376
381
  if (dispatchAnalyticsEvent) {
377
382
  dispatchAnalyticsEvent({
378
383
  action: _analytics.ACTION.OPENED,
@@ -22,9 +22,10 @@ const toolbarSizeToButtons = (toolbarSize, appearance) => {
22
22
  switch (toolbarSize) {
23
23
  case ToolbarSize.XXL:
24
24
  case ToolbarSize.XL:
25
- return 7;
26
25
  case ToolbarSize.L:
27
- return 5;
26
+ return 7;
27
+ case ToolbarSize.M:
28
+ return 3;
28
29
  default:
29
30
  return 0;
30
31
  }
@@ -331,13 +332,13 @@ function ToolbarInsertBlockWithInjectionApi({
331
332
  }
332
333
  };
333
334
  const emojiProvider = getEmojiProvider();
334
- const onShowMediaPicker = targetRef => {
335
+ const onShowMediaPicker = mountInfo => {
335
336
  if (!mediaState) {
336
337
  return;
337
338
  }
338
339
  if (editorExperiment('add-media-from-url', true)) {
339
340
  var _pluginInjectionApi$c, _pluginInjectionApi$m;
340
- 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));
341
+ 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(mountInfo));
341
342
  } else {
342
343
  mediaState.showMediaPicker();
343
344
  }
@@ -197,12 +197,16 @@ const createInsertBlockItems = config => {
197
197
  disabled: false
198
198
  }));
199
199
  }
200
- let numButtonsWithoutTableSelector = numberOfButtons;
201
- if (!fg('platform_editor_toolbar_responsive_fixes')) {
202
- numButtonsWithoutTableSelector = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
200
+ let numButtonsAdjusted = numberOfButtons;
201
+ if (fg('platform_editor_toolbar_responsive_fixes')) {
202
+ if (items.slice(0, numButtonsAdjusted).some(item => item.value.name === 'table selector')) {
203
+ numButtonsAdjusted++;
204
+ }
205
+ } else {
206
+ numButtonsAdjusted = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
203
207
  }
204
- const buttonItems = items.slice(0, numButtonsWithoutTableSelector).map(buttonToItem);
205
- const remainingItems = items.slice(numButtonsWithoutTableSelector).filter(({
208
+ const buttonItems = items.slice(0, numButtonsAdjusted).map(buttonToItem);
209
+ const remainingItems = items.slice(numButtonsAdjusted).filter(({
206
210
  value: {
207
211
  name
208
212
  }
@@ -73,8 +73,8 @@ css`
73
73
  `;
74
74
  // eslint-disable-next-line @repo/internal/react/no-class-components
75
75
  export class ToolbarInsertBlock extends React.PureComponent {
76
- constructor(...args) {
77
- super(...args);
76
+ constructor(..._args) {
77
+ super(..._args);
78
78
  _defineProperty(this, "tableButtonRef", /*#__PURE__*/React.createRef());
79
79
  _defineProperty(this, "tableSelectorButtonRef", /*#__PURE__*/React.createRef());
80
80
  _defineProperty(this, "unregisterToggleDropdownMenuOptions", null);
@@ -386,7 +386,12 @@ export class ToolbarInsertBlock extends React.PureComponent {
386
386
  dispatchAnalyticsEvent
387
387
  } = this.props;
388
388
  if (onShowMediaPicker) {
389
- onShowMediaPicker(this.mediaButtonRef);
389
+ var _this$props$popupsMou;
390
+ const args = this.mediaButtonRef ? {
391
+ ref: this.mediaButtonRef,
392
+ mountPoint: (_this$props$popupsMou = this.props.popupsMountPoint) !== null && _this$props$popupsMou !== void 0 ? _this$props$popupsMou : this.mediaButtonRef
393
+ } : undefined;
394
+ onShowMediaPicker(args);
390
395
  if (dispatchAnalyticsEvent) {
391
396
  dispatchAnalyticsEvent({
392
397
  action: ACTION.OPENED,
@@ -22,9 +22,10 @@ var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize, appearance
22
22
  switch (toolbarSize) {
23
23
  case ToolbarSize.XXL:
24
24
  case ToolbarSize.XL:
25
- return 7;
26
25
  case ToolbarSize.L:
27
- return 5;
26
+ return 7;
27
+ case ToolbarSize.M:
28
+ return 3;
28
29
  default:
29
30
  return 0;
30
31
  }
@@ -326,13 +327,13 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
326
327
  }
327
328
  };
328
329
  var emojiProvider = getEmojiProvider();
329
- var onShowMediaPicker = function onShowMediaPicker(targetRef) {
330
+ var onShowMediaPicker = function onShowMediaPicker(mountInfo) {
330
331
  if (!mediaState) {
331
332
  return;
332
333
  }
333
334
  if (editorExperiment('add-media-from-url', true)) {
334
335
  var _pluginInjectionApi$c, _pluginInjectionApi$m;
335
- 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));
336
+ 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(mountInfo));
336
337
  } else {
337
338
  mediaState.showMediaPicker();
338
339
  }
@@ -209,12 +209,18 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
209
209
  disabled: false
210
210
  }));
211
211
  }
212
- var numButtonsWithoutTableSelector = numberOfButtons;
213
- if (!fg('platform_editor_toolbar_responsive_fixes')) {
214
- numButtonsWithoutTableSelector = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
215
- }
216
- var buttonItems = items.slice(0, numButtonsWithoutTableSelector).map(buttonToItem);
217
- var remainingItems = items.slice(numButtonsWithoutTableSelector).filter(function (_ref) {
212
+ var numButtonsAdjusted = numberOfButtons;
213
+ if (fg('platform_editor_toolbar_responsive_fixes')) {
214
+ if (items.slice(0, numButtonsAdjusted).some(function (item) {
215
+ return item.value.name === 'table selector';
216
+ })) {
217
+ numButtonsAdjusted++;
218
+ }
219
+ } else {
220
+ numButtonsAdjusted = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
221
+ }
222
+ var buttonItems = items.slice(0, numButtonsAdjusted).map(buttonToItem);
223
+ var remainingItems = items.slice(numButtonsAdjusted).filter(function (_ref) {
218
224
  var name = _ref.value.name;
219
225
  return name !== 'table selector';
220
226
  });
@@ -66,10 +66,10 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
66
66
  function ToolbarInsertBlock() {
67
67
  var _this;
68
68
  _classCallCheck(this, ToolbarInsertBlock);
69
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
70
- args[_key] = arguments[_key];
69
+ for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
70
+ _args[_key] = arguments[_key];
71
71
  }
72
- _this = _super.call.apply(_super, [this].concat(args));
72
+ _this = _super.call.apply(_super, [this].concat(_args));
73
73
  _defineProperty(_assertThisInitialized(_this), "tableButtonRef", /*#__PURE__*/React.createRef());
74
74
  _defineProperty(_assertThisInitialized(_this), "tableSelectorButtonRef", /*#__PURE__*/React.createRef());
75
75
  _defineProperty(_assertThisInitialized(_this), "unregisterToggleDropdownMenuOptions", null);
@@ -363,7 +363,12 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
363
363
  onShowMediaPicker = _this$props5.onShowMediaPicker,
364
364
  dispatchAnalyticsEvent = _this$props5.dispatchAnalyticsEvent;
365
365
  if (onShowMediaPicker) {
366
- onShowMediaPicker(_this.mediaButtonRef);
366
+ var _this$props$popupsMou;
367
+ var args = _this.mediaButtonRef ? {
368
+ ref: _this.mediaButtonRef,
369
+ mountPoint: (_this$props$popupsMou = _this.props.popupsMountPoint) !== null && _this$props$popupsMou !== void 0 ? _this$props$popupsMou : _this.mediaButtonRef
370
+ } : undefined;
371
+ onShowMediaPicker(args);
367
372
  if (dispatchAnalyticsEvent) {
368
373
  dispatchAnalyticsEvent({
369
374
  action: ACTION.OPENED,
@@ -42,7 +42,10 @@ export interface Props {
42
42
  insertMenuItems?: MenuItem[];
43
43
  showElementBrowserLink?: boolean;
44
44
  showSeparator?: boolean;
45
- onShowMediaPicker?: (ref?: HTMLElement) => void;
45
+ onShowMediaPicker?: (mountInfo?: {
46
+ ref: HTMLElement;
47
+ mountPoint: HTMLElement;
48
+ }) => void;
46
49
  onInsertBlockType?: (name: string) => Command;
47
50
  onInsertMacroFromMacroBrowser?: (macroProvider: MacroProvider, node?: PMNode, isEditing?: boolean) => (view: EditorView) => void;
48
51
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
@@ -42,7 +42,10 @@ export interface Props {
42
42
  insertMenuItems?: MenuItem[];
43
43
  showElementBrowserLink?: boolean;
44
44
  showSeparator?: boolean;
45
- onShowMediaPicker?: (ref?: HTMLElement) => void;
45
+ onShowMediaPicker?: (mountInfo?: {
46
+ ref: HTMLElement;
47
+ mountPoint: HTMLElement;
48
+ }) => void;
46
49
  onInsertBlockType?: (name: string) => Command;
47
50
  onInsertMacroFromMacroBrowser?: (macroProvider: MacroProvider, node?: PMNode, isEditing?: boolean) => (view: EditorView) => void;
48
51
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-insert-block",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "description": "Insert block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/button": "^20.2.0",
35
- "@atlaskit/editor-common": "^92.0.0",
35
+ "@atlaskit/editor-common": "^92.1.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
37
37
  "@atlaskit/editor-plugin-block-type": "^3.15.0",
38
38
  "@atlaskit/editor-plugin-code-block": "^3.4.0",
@@ -65,7 +65,7 @@
65
65
  "@atlaskit/platform-feature-flags": "^0.3.0",
66
66
  "@atlaskit/primitives": "^12.2.0",
67
67
  "@atlaskit/theme": "^13.0.0",
68
- "@atlaskit/tmp-editor-statsig": "^2.1.0",
68
+ "@atlaskit/tmp-editor-statsig": "^2.2.0",
69
69
  "@atlaskit/tokens": "^2.0.0",
70
70
  "@atlaskit/tooltip": "18.7.3",
71
71
  "@babel/runtime": "^7.0.0",