@atlaskit/editor-plugin-insert-block 2.2.2 → 2.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/editor-plugin-insert-block
2
2
 
3
+ ## 2.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#146985](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/146985)
8
+ [`44f7dd482bdef`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/44f7dd482bdef) -
9
+ make icon hiding on smaller screens less aggressive
10
+ - [#146966](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/146966)
11
+ [`ee4562a10804e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ee4562a10804e) -
12
+ cleaned up platform_editor_get_emoji_provider_from_config feature flag
13
+
14
+ ## 2.2.3
15
+
16
+ ### Patch Changes
17
+
18
+ - [#146643](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/146643)
19
+ [`6b3dec2ad5378`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6b3dec2ad5378) -
20
+ [ux] ED-25116 Pin media popup to toolbar when triggered from toolbar
21
+ - Updated dependencies
22
+
3
23
  ## 2.2.2
4
24
 
5
25
  ### Patch Changes
@@ -42,10 +42,10 @@ var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize, appearance
42
42
  if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_responsive_fixes')) {
43
43
  switch (toolbarSize) {
44
44
  case _types.ToolbarSize.XXL:
45
- return 7;
46
45
  case _types.ToolbarSize.XL:
47
- return 5;
46
+ return 7;
48
47
  case _types.ToolbarSize.L:
48
+ return 5;
49
49
  case _types.ToolbarSize.M:
50
50
  case _types.ToolbarSize.S:
51
51
  return 2;
@@ -331,22 +331,18 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
331
331
  typeAheadState = _useSharedPluginState.typeAheadState,
332
332
  placeholderTextState = _useSharedPluginState.placeholderTextState;
333
333
  var getEmojiProvider = function getEmojiProvider() {
334
- if ((0, _platformFeatureFlags.fg)('platform_editor_get_emoji_provider_from_config')) {
335
- if (emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider) {
336
- return Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider);
337
- }
338
- } else {
339
- return providers.emojiProvider;
334
+ if (emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider) {
335
+ return Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider);
340
336
  }
341
337
  };
342
338
  var emojiProvider = getEmojiProvider();
343
- var onShowMediaPicker = function onShowMediaPicker() {
339
+ var onShowMediaPicker = function onShowMediaPicker(targetRef) {
344
340
  if (!mediaState) {
345
341
  return;
346
342
  }
347
343
  if ((0, _experiments.editorExperiment)('add-media-from-url', true)) {
348
344
  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);
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));
350
346
  } else {
351
347
  mediaState.showMediaPicker();
352
348
  }
@@ -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,
@@ -32,10 +32,10 @@ const toolbarSizeToButtons = (toolbarSize, appearance) => {
32
32
  if (fg('platform_editor_toolbar_responsive_fixes')) {
33
33
  switch (toolbarSize) {
34
34
  case ToolbarSize.XXL:
35
- return 7;
36
35
  case ToolbarSize.XL:
37
- return 5;
36
+ return 7;
38
37
  case ToolbarSize.L:
38
+ return 5;
39
39
  case ToolbarSize.M:
40
40
  case ToolbarSize.S:
41
41
  return 2;
@@ -326,22 +326,18 @@ function ToolbarInsertBlockWithInjectionApi({
326
326
  placeholderTextState
327
327
  } = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText']);
328
328
  const getEmojiProvider = () => {
329
- if (fg('platform_editor_get_emoji_provider_from_config')) {
330
- if (emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider) {
331
- return Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider);
332
- }
333
- } else {
334
- return providers.emojiProvider;
329
+ if (emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider) {
330
+ return Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider);
335
331
  }
336
332
  };
337
333
  const emojiProvider = getEmojiProvider();
338
- const onShowMediaPicker = () => {
334
+ const onShowMediaPicker = targetRef => {
339
335
  if (!mediaState) {
340
336
  return;
341
337
  }
342
338
  if (editorExperiment('add-media-from-url', true)) {
343
339
  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);
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));
345
341
  } else {
346
342
  mediaState.showMediaPicker();
347
343
  }
@@ -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,
@@ -32,10 +32,10 @@ var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize, appearance
32
32
  if (fg('platform_editor_toolbar_responsive_fixes')) {
33
33
  switch (toolbarSize) {
34
34
  case ToolbarSize.XXL:
35
- return 7;
36
35
  case ToolbarSize.XL:
37
- return 5;
36
+ return 7;
38
37
  case ToolbarSize.L:
38
+ return 5;
39
39
  case ToolbarSize.M:
40
40
  case ToolbarSize.S:
41
41
  return 2;
@@ -321,22 +321,18 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
321
321
  typeAheadState = _useSharedPluginState.typeAheadState,
322
322
  placeholderTextState = _useSharedPluginState.placeholderTextState;
323
323
  var getEmojiProvider = function getEmojiProvider() {
324
- if (fg('platform_editor_get_emoji_provider_from_config')) {
325
- if (emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider) {
326
- return Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider);
327
- }
328
- } else {
329
- return providers.emojiProvider;
324
+ if (emojiState !== null && emojiState !== void 0 && emojiState.emojiProvider) {
325
+ return Promise.resolve(emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider);
330
326
  }
331
327
  };
332
328
  var emojiProvider = getEmojiProvider();
333
- var onShowMediaPicker = function onShowMediaPicker() {
329
+ var onShowMediaPicker = function onShowMediaPicker(targetRef) {
334
330
  if (!mediaState) {
335
331
  return;
336
332
  }
337
333
  if (editorExperiment('add-media-from-url', true)) {
338
334
  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);
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));
340
336
  } else {
341
337
  mediaState.showMediaPicker();
342
338
  }
@@ -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.4",
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",
@@ -122,9 +122,6 @@
122
122
  }
123
123
  },
124
124
  "platform-feature-flags": {
125
- "platform_editor_get_emoji_provider_from_config": {
126
- "type": "boolean"
127
- },
128
125
  "platform_editor_toolbar_responsive_fixes": {
129
126
  "type": "boolean"
130
127
  }