@atlaskit/editor-plugin-media 9.3.2 → 9.3.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,12 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 9.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`0457795b04c62`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0457795b04c62) -
8
+ EDITOR-4396 Media toolbar button doesn't when missing the mediaInsert Plugin
9
+
3
10
  ## 9.3.2
4
11
 
5
12
  ### Patch Changes
@@ -9,6 +9,8 @@ exports.mediaPlugin = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
+ var _messages = require("@atlaskit/editor-common/messages");
13
+ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
12
14
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
13
15
  var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
14
16
  var _state = require("@atlaskit/editor-prosemirror/state");
@@ -341,8 +343,35 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
341
343
  });
342
344
  },
343
345
  pluginsOptions: {
344
- quickInsert: function quickInsert() {
345
- return [];
346
+ quickInsert: function quickInsert(_ref12) {
347
+ var formatMessage = _ref12.formatMessage;
348
+ return !(api !== null && api !== void 0 && api.mediaInsert) && (0, _platformFeatureFlags.fg)('platform_editor_media_insert_check') ? [{
349
+ id: 'media',
350
+ title: formatMessage(_messages.toolbarInsertBlockMessages.mediaFiles),
351
+ description: formatMessage(_messages.toolbarInsertBlockMessages.mediaFilesDescription),
352
+ priority: 400,
353
+ keywords: ['attachment', 'gif', 'media', 'picture', 'image', 'video', 'file'],
354
+ icon: function icon() {
355
+ return /*#__PURE__*/_react.default.createElement(_quickInsert.IconImages, null);
356
+ },
357
+ isDisabledOffline: true,
358
+ action: function action(insert, state) {
359
+ var _api$analytics6;
360
+ var pluginState = _pluginKey.stateKey.getState(state);
361
+ pluginState === null || pluginState === void 0 || pluginState.showMediaPicker();
362
+ var tr = insert('');
363
+ api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 || _api$analytics6.actions.attachAnalyticsEvent({
364
+ action: _analytics.ACTION.OPENED,
365
+ actionSubject: _analytics.ACTION_SUBJECT.PICKER,
366
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.PICKER_CLOUD,
367
+ attributes: {
368
+ inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
369
+ },
370
+ eventType: _analytics.EVENT_TYPE.UI
371
+ })(tr);
372
+ return tr;
373
+ }
374
+ }] : [];
346
375
  },
347
376
  floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
348
377
  var _api$editorViewMode;
@@ -46,8 +46,7 @@ var IconWrapperComponent = function IconWrapperComponent(props) {
46
46
  return (0, _react.jsx)("div", {
47
47
  css: iconWrapperStyles
48
48
  }, (0, _react.jsx)(_file.default, {
49
- label: intl.formatMessage(dropPlaceholderLabel),
50
- LEGACY_size: "medium"
49
+ label: intl.formatMessage(dropPlaceholderLabel)
51
50
  }));
52
51
  };
53
52
  var IntlIconWrapper = (0, _reactIntlNext.injectIntl)(IconWrapperComponent);
@@ -1,6 +1,8 @@
1
1
  import React, { useMemo } from 'react';
2
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { IconImages } from '@atlaskit/editor-common/quick-insert';
4
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
7
  import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
6
8
  import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
@@ -340,7 +342,33 @@ export const mediaPlugin = ({
340
342
  });
341
343
  },
342
344
  pluginsOptions: {
343
- quickInsert: () => [],
345
+ quickInsert: ({
346
+ formatMessage
347
+ }) => !(api !== null && api !== void 0 && api.mediaInsert) && fg('platform_editor_media_insert_check') ? [{
348
+ id: 'media',
349
+ title: formatMessage(messages.mediaFiles),
350
+ description: formatMessage(messages.mediaFilesDescription),
351
+ priority: 400,
352
+ keywords: ['attachment', 'gif', 'media', 'picture', 'image', 'video', 'file'],
353
+ icon: () => /*#__PURE__*/React.createElement(IconImages, null),
354
+ isDisabledOffline: true,
355
+ action(insert, state) {
356
+ var _api$analytics6;
357
+ const pluginState = stateKey.getState(state);
358
+ pluginState === null || pluginState === void 0 ? void 0 : pluginState.showMediaPicker();
359
+ const tr = insert('');
360
+ api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions.attachAnalyticsEvent({
361
+ action: ACTION.OPENED,
362
+ actionSubject: ACTION_SUBJECT.PICKER,
363
+ actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
364
+ attributes: {
365
+ inputMethod: INPUT_METHOD.QUICK_INSERT
366
+ },
367
+ eventType: EVENT_TYPE.UI
368
+ })(tr);
369
+ return tr;
370
+ }
371
+ }] : [],
344
372
  floatingToolbar: (state, intl, providerFactory) => {
345
373
  var _api$editorViewMode, _api$editorViewMode$s;
346
374
  return floatingToolbar(state, intl, {
@@ -42,8 +42,7 @@ const IconWrapperComponent = props => {
42
42
  return jsx("div", {
43
43
  css: iconWrapperStyles
44
44
  }, jsx(DocumentFilledIcon, {
45
- label: intl.formatMessage(dropPlaceholderLabel),
46
- LEGACY_size: "medium"
45
+ label: intl.formatMessage(dropPlaceholderLabel)
47
46
  }));
48
47
  };
49
48
  const IntlIconWrapper = injectIntl(IconWrapperComponent);
@@ -1,6 +1,8 @@
1
1
  import React, { useMemo } from 'react';
2
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { IconImages } from '@atlaskit/editor-common/quick-insert';
4
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
7
  import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-check';
6
8
  import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
@@ -332,8 +334,35 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
332
334
  });
333
335
  },
334
336
  pluginsOptions: {
335
- quickInsert: function quickInsert() {
336
- return [];
337
+ quickInsert: function quickInsert(_ref12) {
338
+ var formatMessage = _ref12.formatMessage;
339
+ return !(api !== null && api !== void 0 && api.mediaInsert) && fg('platform_editor_media_insert_check') ? [{
340
+ id: 'media',
341
+ title: formatMessage(messages.mediaFiles),
342
+ description: formatMessage(messages.mediaFilesDescription),
343
+ priority: 400,
344
+ keywords: ['attachment', 'gif', 'media', 'picture', 'image', 'video', 'file'],
345
+ icon: function icon() {
346
+ return /*#__PURE__*/React.createElement(IconImages, null);
347
+ },
348
+ isDisabledOffline: true,
349
+ action: function action(insert, state) {
350
+ var _api$analytics6;
351
+ var pluginState = stateKey.getState(state);
352
+ pluginState === null || pluginState === void 0 || pluginState.showMediaPicker();
353
+ var tr = insert('');
354
+ api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 || _api$analytics6.actions.attachAnalyticsEvent({
355
+ action: ACTION.OPENED,
356
+ actionSubject: ACTION_SUBJECT.PICKER,
357
+ actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
358
+ attributes: {
359
+ inputMethod: INPUT_METHOD.QUICK_INSERT
360
+ },
361
+ eventType: EVENT_TYPE.UI
362
+ })(tr);
363
+ return tr;
364
+ }
365
+ }] : [];
337
366
  },
338
367
  floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
339
368
  var _api$editorViewMode;
@@ -38,8 +38,7 @@ var IconWrapperComponent = function IconWrapperComponent(props) {
38
38
  return jsx("div", {
39
39
  css: iconWrapperStyles
40
40
  }, jsx(DocumentFilledIcon, {
41
- label: intl.formatMessage(dropPlaceholderLabel),
42
- LEGACY_size: "medium"
41
+ label: intl.formatMessage(dropPlaceholderLabel)
43
42
  }));
44
43
  };
45
44
  var IntlIconWrapper = injectIntl(IconWrapperComponent);
@@ -23,6 +23,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
23
23
  import type { MediaPluginState } from './pm-plugins/types';
24
24
  import type { InsertMediaAsMediaSingle } from './pm-plugins/utils/media-single';
25
25
  import type { MediaOptions } from './types';
26
+ type MediaInsertPlugin = NextEditorPlugin<'mediaInsert', any>;
26
27
  export type MediaPluginDependencies = [
27
28
  OptionalPlugin<AnalyticsPlugin>,
28
29
  OptionalPlugin<ContextIdentifierPlugin>,
@@ -34,6 +35,7 @@ export type MediaPluginDependencies = [
34
35
  FloatingToolbarPlugin,
35
36
  EditorDisabledPlugin,
36
37
  FocusPlugin,
38
+ OptionalPlugin<MediaInsertPlugin>,
37
39
  OptionalPlugin<InteractionPlugin>,
38
40
  SelectionPlugin,
39
41
  OptionalPlugin<AnnotationPlugin>,
@@ -84,3 +86,4 @@ export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
84
86
  pluginConfiguration: MediaOptions | undefined;
85
87
  sharedState: MediaPluginState | null;
86
88
  }>;
89
+ export {};
@@ -23,6 +23,7 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
23
23
  import type { MediaPluginState } from './pm-plugins/types';
24
24
  import type { InsertMediaAsMediaSingle } from './pm-plugins/utils/media-single';
25
25
  import type { MediaOptions } from './types';
26
+ type MediaInsertPlugin = NextEditorPlugin<'mediaInsert', any>;
26
27
  export type MediaPluginDependencies = [
27
28
  OptionalPlugin<AnalyticsPlugin>,
28
29
  OptionalPlugin<ContextIdentifierPlugin>,
@@ -34,6 +35,7 @@ export type MediaPluginDependencies = [
34
35
  FloatingToolbarPlugin,
35
36
  EditorDisabledPlugin,
36
37
  FocusPlugin,
38
+ OptionalPlugin<MediaInsertPlugin>,
37
39
  OptionalPlugin<InteractionPlugin>,
38
40
  SelectionPlugin,
39
41
  OptionalPlugin<AnnotationPlugin>,
@@ -84,3 +86,4 @@ export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
84
86
  pluginConfiguration: MediaOptions | undefined;
85
87
  sharedState: MediaPluginState | null;
86
88
  }>;
89
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "9.3.2",
3
+ "version": "9.3.3",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -66,9 +66,9 @@
66
66
  "@atlaskit/primitives": "^17.0.0",
67
67
  "@atlaskit/textfield": "^8.2.0",
68
68
  "@atlaskit/theme": "^21.0.0",
69
- "@atlaskit/tmp-editor-statsig": "^16.11.0",
69
+ "@atlaskit/tmp-editor-statsig": "^16.14.0",
70
70
  "@atlaskit/tokens": "^9.1.0",
71
- "@atlaskit/tooltip": "^20.12.0",
71
+ "@atlaskit/tooltip": "^20.13.0",
72
72
  "@babel/runtime": "^7.0.0",
73
73
  "@emotion/react": "^11.7.1",
74
74
  "bind-event-listener": "^3.0.0",
@@ -159,6 +159,9 @@
159
159
  },
160
160
  "jira_kuro-jjj_disable_auto_focus_after_img_upload": {
161
161
  "type": "boolean"
162
+ },
163
+ "platform_editor_media_insert_check": {
164
+ "type": "boolean"
162
165
  }
163
166
  },
164
167
  "stricter": {