@atlaskit/editor-plugin-media 1.37.3 → 1.38.0

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 (27) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/nodeviews/mediaSingle.js +3 -3
  3. package/dist/cjs/nodeviews/mediaSingleNext.js +2 -2
  4. package/dist/cjs/pm-plugins/main.js +17 -2
  5. package/dist/cjs/toolbar/assets/commentWithDotIcon.js +31 -1
  6. package/dist/cjs/ui/CaptionPlaceholder/index.js +9 -3
  7. package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +556 -5
  8. package/dist/cjs/utils/media-common.js +23 -1
  9. package/dist/es2019/nodeviews/mediaSingle.js +3 -3
  10. package/dist/es2019/nodeviews/mediaSingleNext.js +2 -2
  11. package/dist/es2019/pm-plugins/main.js +20 -4
  12. package/dist/es2019/toolbar/assets/commentWithDotIcon.js +32 -2
  13. package/dist/es2019/ui/CaptionPlaceholder/index.js +14 -3
  14. package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +546 -4
  15. package/dist/es2019/utils/media-common.js +22 -0
  16. package/dist/esm/nodeviews/mediaSingle.js +3 -3
  17. package/dist/esm/nodeviews/mediaSingleNext.js +2 -2
  18. package/dist/esm/pm-plugins/main.js +20 -4
  19. package/dist/esm/toolbar/assets/commentWithDotIcon.js +32 -2
  20. package/dist/esm/ui/CaptionPlaceholder/index.js +9 -3
  21. package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +552 -4
  22. package/dist/esm/utils/media-common.js +22 -0
  23. package/dist/types/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +3 -56
  24. package/dist/types/utils/media-common.d.ts +1 -0
  25. package/dist/types-ts4.5/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +3 -56
  26. package/dist/types-ts4.5/utils/media-common.d.ts +1 -0
  27. package/package.json +10 -7
@@ -4,6 +4,7 @@ import React from 'react';
4
4
  import ReactDOM from 'react-dom';
5
5
  import { RawIntlProvider } from 'react-intl-next';
6
6
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
7
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
7
8
  import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
8
9
  import { CAPTION_PLACEHOLDER_ID, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
9
10
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
@@ -20,10 +21,10 @@ import * as helpers from '../commands/helpers';
20
21
  import { updateMediaNodeAttrs } from '../commands/helpers';
21
22
  import PickerFacade from '../picker-facade';
22
23
  import DropPlaceholder from '../ui/Media/DropPlaceholder';
23
- import { getMediaFromSupportedMediaNodesFromSelection, removeMediaNode, splitMediaGroup } from '../utils/media-common';
24
+ import { getMediaFromSupportedMediaNodesFromSelection, isNodeDoubleClickSupportedInLivePagesViewMode, removeMediaNode, splitMediaGroup } from '../utils/media-common';
24
25
  import { insertMediaGroupNode, insertMediaInlineNode } from '../utils/media-files';
25
26
  import { getMediaNodeInsertionType } from '../utils/media-inline';
26
- import { insertMediaSingleNode, isVideo } from '../utils/media-single';
27
+ import { insertMediaSingleNode } from '../utils/media-single';
27
28
  import { ACTIONS } from './actions';
28
29
  import { MediaTaskManager } from './mediaTaskManager';
29
30
  import { stateKey } from './plugin-key';
@@ -817,18 +818,33 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, disp
817
818
  },
818
819
  handleDoubleClickOn: view => {
819
820
  var _pluginInjectionApi$e, _pluginInjectionApi$e2;
820
- if (!fg('platform_editor_media_previewer_bugfix') || !fg('platform_editor_media_interaction_improvements') || (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : (_pluginInjectionApi$e2 = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e2 === void 0 ? void 0 : _pluginInjectionApi$e2.mode) === 'view') {
821
+ if (!fg('platform_editor_media_previewer_bugfix') || !fg('platform_editor_media_interaction_improvements')) {
821
822
  return;
822
823
  }
824
+ const isLivePagesViewMode = (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : (_pluginInjectionApi$e2 = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e2 === void 0 ? void 0 : _pluginInjectionApi$e2.mode) === 'view';
823
825
 
824
826
  // Double Click support for Media Viewer Nodes
825
827
  const maybeMediaNode = getMediaFromSupportedMediaNodesFromSelection(view.state);
826
828
  if (maybeMediaNode) {
829
+ var _pluginInjectionApi$a;
827
830
  // If media type is video, do not open media viewer
828
- if (isVideo(maybeMediaNode.attrs.__fileMimeType)) {
831
+ if (!isNodeDoubleClickSupportedInLivePagesViewMode(isLivePagesViewMode, maybeMediaNode)) {
829
832
  return false;
830
833
  }
834
+ // Show media viewer
831
835
  pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.media.commands.showMediaViewer(maybeMediaNode.attrs));
836
+
837
+ // Call analytics event
838
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions.fireAnalyticsEvent({
839
+ action: ACTION.OPENED,
840
+ actionSubject: ACTION_SUBJECT.MEDIA_VIEWER,
841
+ actionSubjectId: ACTION_SUBJECT_ID.MEDIA,
842
+ eventType: EVENT_TYPE.UI,
843
+ attributes: {
844
+ nodeType: maybeMediaNode.type.name,
845
+ inputMethod: INPUT_METHOD.DOUBLE_CLICK
846
+ }
847
+ });
832
848
  return true;
833
849
  }
834
850
  return false;
@@ -1,7 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import Icon from '@atlaskit/icon';
4
- import { Y300 } from '@atlaskit/theme/colors';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
5
+ import { N0, Y300 } from '@atlaskit/theme/colors';
5
6
  const IconCommentWithDotGlyph = () => {
6
7
  return /*#__PURE__*/React.createElement("svg", {
7
8
  width: "24",
@@ -29,8 +30,37 @@ const IconCommentWithDotGlyph = () => {
29
30
  fill: `var(--ds-background-warning-bold, ${Y300})`
30
31
  }));
31
32
  };
33
+ const IconCommentConfluenceTypeWithDotGlyph = () => {
34
+ return /*#__PURE__*/React.createElement("svg", {
35
+ width: "24",
36
+ height: "24",
37
+ viewBox: "0 0 24 24",
38
+ fill: "none",
39
+ xmlns: "http://www.w3.org/2000/svg"
40
+ }, /*#__PURE__*/React.createElement("path", {
41
+ fillRule: "evenodd",
42
+ clipRule: "evenodd",
43
+ d: "M4.998 11.513C4.998 8.475 8.139 6.003 12 6.003C15.861 6.003 19.002 8.475 19.002 11.513C19.002 14.552 15.861 17.023 12 17.023C8.139 17.023 4.998 14.552 4.998 11.513ZM19.838 19.284V19.282C19.838 19.282 18.274 17.022 19.071 16.166L19.034 16.186C20.261 14.902 21 13.279 21 11.513C21 7.371 16.963 4 12 4C7.037 4 3 7.37 3 11.513C3 15.656 7.037 19.027 12 19.027C13.42 19.027 14.76 18.742 15.957 18.251C16.96 19.273 18.244 19.823 19.197 19.97L19.199 19.967C19.2515 19.9867 19.3069 19.9979 19.363 20C19.448 20 19.5317 19.9789 19.6067 19.9386C19.6816 19.8984 19.7453 19.8402 19.7923 19.7693C19.8392 19.6984 19.8679 19.6169 19.8757 19.5323C19.8835 19.4476 19.8712 19.3623 19.838 19.284Z",
44
+ fill: "currentColor"
45
+ }), /*#__PURE__*/React.createElement("path", {
46
+ d: "M16 9H8C7.44772 9 7 9.44772 7 10C7 10.5523 7.44772 11 8 11H16C16.5523 11 17 10.5523 17 10C17 9.44772 16.5523 9 16 9Z",
47
+ fill: "currentColor"
48
+ }), /*#__PURE__*/React.createElement("path", {
49
+ d: "M11 12H8C7.44772 12 7 12.4477 7 13C7 13.5523 7.44772 14 8 14H11C11.5523 14 12 13.5523 12 13C12 12.4477 11.5523 12 11 12Z",
50
+ fill: "currentColor"
51
+ }), /*#__PURE__*/React.createElement("rect", {
52
+ x: "13",
53
+ y: "1",
54
+ width: "8",
55
+ height: "8",
56
+ rx: "4",
57
+ stroke: `var(--ds-border-inverse, ${N0})`,
58
+ strokeWidth: 2,
59
+ fill: "var(--ds-icon-brand, #0052CC)"
60
+ }));
61
+ };
32
62
  export const CommentWithDotIcon = props => {
33
63
  return /*#__PURE__*/React.createElement(Icon, _extends({
34
- glyph: IconCommentWithDotGlyph
64
+ glyph: fg('platform_editor_media_interaction_improvements') ? IconCommentConfluenceTypeWithDotGlyph : IconCommentWithDotGlyph
35
65
  }, props));
36
66
  };
@@ -9,6 +9,7 @@ import { css, jsx } from '@emotion/react';
9
9
  import { FormattedMessage } from 'react-intl-next';
10
10
  import { captionMessages as messages } from '@atlaskit/editor-common/media';
11
11
  import { CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
12
+ import { fg } from '@atlaskit/platform-feature-flags';
12
13
  import { Pressable, Text, xcss } from '@atlaskit/primitives';
13
14
  import { N200 } from '@atlaskit/theme/colors';
14
15
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
@@ -24,11 +25,16 @@ const placeholderButton = xcss({
24
25
  marginTop: 'space.100'
25
26
  });
26
27
 
27
- // platform_editor_typography_migration_ugc clean up
28
+ // platform_editor_typography_ugc clean up
28
29
  // Remove this component
29
30
  export const CaptionPlaceholder = /*#__PURE__*/React.forwardRef(({
30
31
  onClick
31
32
  }, ref) => {
33
+ const message = fg('platform_editor_media_interaction_improvements') ? {
34
+ ...messages.placeholderWithDoubleClickPrompt
35
+ } : {
36
+ ...messages.placeholder
37
+ };
32
38
  return (
33
39
  // eslint-disable-next-line @atlaskit/design-system/use-primitives-text
34
40
  jsx("span", {
@@ -37,7 +43,7 @@ export const CaptionPlaceholder = /*#__PURE__*/React.forwardRef(({
37
43
  onClick: onClick,
38
44
  "data-id": CAPTION_PLACEHOLDER_ID,
39
45
  "data-testid": "caption-placeholder"
40
- }, jsx(FormattedMessage, messages.placeholder))
46
+ }, jsx(FormattedMessage, message))
41
47
  );
42
48
  });
43
49
  export const CaptionPlaceholderButton = /*#__PURE__*/React.forwardRef(({
@@ -48,6 +54,11 @@ export const CaptionPlaceholderButton = /*#__PURE__*/React.forwardRef(({
48
54
  // Hence we want to disabled it so that user can type in caption directly after click
49
55
  e.preventDefault();
50
56
  }, []);
57
+ const message = fg('platform_editor_media_interaction_improvements') ? {
58
+ ...messages.placeholderWithDoubleClickPrompt
59
+ } : {
60
+ ...messages.placeholder
61
+ };
51
62
  return jsx(Pressable, {
52
63
  ref: ref,
53
64
  backgroundColor: "color.background.neutral.subtle",
@@ -60,5 +71,5 @@ export const CaptionPlaceholderButton = /*#__PURE__*/React.forwardRef(({
60
71
  }, jsx(Text, {
61
72
  color: "color.text.subtlest",
62
73
  size: "large"
63
- }, jsx(FormattedMessage, messages.placeholder)));
74
+ }, jsx(FormattedMessage, message)));
64
75
  });