@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
@@ -13,6 +13,7 @@ import React from 'react';
13
13
  import ReactDOM from 'react-dom';
14
14
  import { RawIntlProvider } from 'react-intl-next';
15
15
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
16
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
16
17
  import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
17
18
  import { CAPTION_PLACEHOLDER_ID, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
18
19
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
@@ -29,10 +30,10 @@ import * as helpers from '../commands/helpers';
29
30
  import { updateMediaNodeAttrs } from '../commands/helpers';
30
31
  import PickerFacade from '../picker-facade';
31
32
  import DropPlaceholder from '../ui/Media/DropPlaceholder';
32
- import { getMediaFromSupportedMediaNodesFromSelection, removeMediaNode, splitMediaGroup } from '../utils/media-common';
33
+ import { getMediaFromSupportedMediaNodesFromSelection, isNodeDoubleClickSupportedInLivePagesViewMode, removeMediaNode, splitMediaGroup } from '../utils/media-common';
33
34
  import { insertMediaGroupNode, insertMediaInlineNode } from '../utils/media-files';
34
35
  import { getMediaNodeInsertionType } from '../utils/media-inline';
35
- import { insertMediaSingleNode, isVideo } from '../utils/media-single';
36
+ import { insertMediaSingleNode } from '../utils/media-single';
36
37
  import { ACTIONS } from './actions';
37
38
  import { MediaTaskManager } from './mediaTaskManager';
38
39
  import { stateKey } from './plugin-key';
@@ -918,18 +919,33 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
918
919
  },
919
920
  handleDoubleClickOn: function handleDoubleClickOn(view) {
920
921
  var _pluginInjectionApi$e;
921
- if (!fg('platform_editor_media_previewer_bugfix') || !fg('platform_editor_media_interaction_improvements') || (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 || (_pluginInjectionApi$e = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.mode) === 'view') {
922
+ if (!fg('platform_editor_media_previewer_bugfix') || !fg('platform_editor_media_interaction_improvements')) {
922
923
  return;
923
924
  }
925
+ var isLivePagesViewMode = (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 || (_pluginInjectionApi$e = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.mode) === 'view';
924
926
 
925
927
  // Double Click support for Media Viewer Nodes
926
928
  var maybeMediaNode = getMediaFromSupportedMediaNodesFromSelection(view.state);
927
929
  if (maybeMediaNode) {
930
+ var _pluginInjectionApi$a;
928
931
  // If media type is video, do not open media viewer
929
- if (isVideo(maybeMediaNode.attrs.__fileMimeType)) {
932
+ if (!isNodeDoubleClickSupportedInLivePagesViewMode(isLivePagesViewMode, maybeMediaNode)) {
930
933
  return false;
931
934
  }
935
+ // Show media viewer
932
936
  pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.media.commands.showMediaViewer(maybeMediaNode.attrs));
937
+
938
+ // Call analytics event
939
+ pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 || _pluginInjectionApi$a.actions.fireAnalyticsEvent({
940
+ action: ACTION.OPENED,
941
+ actionSubject: ACTION_SUBJECT.MEDIA_VIEWER,
942
+ actionSubjectId: ACTION_SUBJECT_ID.MEDIA,
943
+ eventType: EVENT_TYPE.UI,
944
+ attributes: {
945
+ nodeType: maybeMediaNode.type.name,
946
+ inputMethod: INPUT_METHOD.DOUBLE_CLICK
947
+ }
948
+ });
933
949
  return true;
934
950
  }
935
951
  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
  var IconCommentWithDotGlyph = function IconCommentWithDotGlyph() {
6
7
  return /*#__PURE__*/React.createElement("svg", {
7
8
  width: "24",
@@ -29,8 +30,37 @@ var IconCommentWithDotGlyph = function IconCommentWithDotGlyph() {
29
30
  fill: "var(--ds-background-warning-bold, ".concat(Y300, ")")
30
31
  }));
31
32
  };
33
+ var IconCommentConfluenceTypeWithDotGlyph = function 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, ".concat(N0, ")"),
58
+ strokeWidth: 2,
59
+ fill: "var(--ds-icon-brand, #0052CC)"
60
+ }));
61
+ };
32
62
  export var CommentWithDotIcon = function 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
  };
@@ -1,5 +1,8 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
3
  var _templateObject;
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
6
  /**
4
7
  * @jsxRuntime classic
5
8
  * @jsx jsx
@@ -11,6 +14,7 @@ import { css, jsx } from '@emotion/react';
11
14
  import { FormattedMessage } from 'react-intl-next';
12
15
  import { captionMessages as messages } from '@atlaskit/editor-common/media';
13
16
  import { CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
17
+ import { fg } from '@atlaskit/platform-feature-flags';
14
18
  import { Pressable, Text, xcss } from '@atlaskit/primitives';
15
19
  import { N200 } from '@atlaskit/theme/colors';
16
20
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
@@ -20,10 +24,11 @@ var placeholderButton = xcss({
20
24
  marginTop: 'space.100'
21
25
  });
22
26
 
23
- // platform_editor_typography_migration_ugc clean up
27
+ // platform_editor_typography_ugc clean up
24
28
  // Remove this component
25
29
  export var CaptionPlaceholder = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
26
30
  var onClick = _ref.onClick;
31
+ var message = fg('platform_editor_media_interaction_improvements') ? _objectSpread({}, messages.placeholderWithDoubleClickPrompt) : _objectSpread({}, messages.placeholder);
27
32
  return (
28
33
  // eslint-disable-next-line @atlaskit/design-system/use-primitives-text
29
34
  jsx("span", {
@@ -32,7 +37,7 @@ export var CaptionPlaceholder = /*#__PURE__*/React.forwardRef(function (_ref, re
32
37
  onClick: onClick,
33
38
  "data-id": CAPTION_PLACEHOLDER_ID,
34
39
  "data-testid": "caption-placeholder"
35
- }, jsx(FormattedMessage, messages.placeholder))
40
+ }, jsx(FormattedMessage, message))
36
41
  );
37
42
  });
38
43
  export var CaptionPlaceholderButton = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
@@ -42,6 +47,7 @@ export var CaptionPlaceholderButton = /*#__PURE__*/React.forwardRef(function (_r
42
47
  // Hence we want to disabled it so that user can type in caption directly after click
43
48
  e.preventDefault();
44
49
  }, []);
50
+ var message = fg('platform_editor_media_interaction_improvements') ? _objectSpread({}, messages.placeholderWithDoubleClickPrompt) : _objectSpread({}, messages.placeholder);
45
51
  return jsx(Pressable, {
46
52
  ref: ref,
47
53
  backgroundColor: "color.background.neutral.subtle",
@@ -54,5 +60,5 @@ export var CaptionPlaceholderButton = /*#__PURE__*/React.forwardRef(function (_r
54
60
  }, jsx(Text, {
55
61
  color: "color.text.subtlest",
56
62
  size: "large"
57
- }, jsx(FormattedMessage, messages.placeholder)));
63
+ }, jsx(FormattedMessage, message)));
58
64
  });