@atlaskit/renderer 109.10.4 → 109.10.5

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/renderer
2
2
 
3
+ ## 109.10.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#82755](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/82755) [`c204f74b46a5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c204f74b46a5) - The media renderer node will now correctly render annotation marks if/when they're applied to the node.
8
+ - Updated dependencies
9
+
3
10
  ## 109.10.4
4
11
 
5
12
  ### Patch Changes
@@ -85,7 +85,7 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
85
85
  var shouldSkipLinkMark = function shouldSkipLinkMark(mark) {
86
86
  return _this.allowMediaLinking !== true && isMedia && mark.type.name === 'link';
87
87
  };
88
- return marks.reverse().reduce(function (content, mark) {
88
+ return marks.reduceRight(function (content, mark) {
89
89
  if (shouldSkipLinkMark(mark) || shouldSkipBorderMark(mark)) {
90
90
  return content;
91
91
  }
@@ -389,12 +389,16 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
389
389
  _this$media;
390
390
  var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
391
391
  var _node$type$schema$mar = node.type.schema.marks,
392
+ annotation = _node$type$schema$mar.annotation,
392
393
  link = _node$type$schema$mar.link,
393
394
  border = _node$type$schema$mar.border;
394
395
  var isChildOfMediaSingle = path.some(function (n) {
395
396
  var _n$type2;
396
397
  return ((_n$type2 = n.type) === null || _n$type2 === void 0 ? void 0 : _n$type2.name) === 'mediaSingle';
397
398
  });
399
+ var isAnnotationMark = function isAnnotationMark(mark) {
400
+ return mark.type === annotation;
401
+ };
398
402
  var isLinkMark = function isLinkMark(mark) {
399
403
  return mark.type === link;
400
404
  };
@@ -407,6 +411,7 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
407
411
  }),
408
412
  isLinkMark: isLinkMark,
409
413
  isBorderMark: isBorderMark,
414
+ isAnnotationMark: isAnnotationMark,
410
415
  allowAltTextOnImages: this.allowAltTextOnImages,
411
416
  featureFlags: this.media && this.media.featureFlags,
412
417
  shouldOpenMediaViewer: this.shouldOpenMediaViewer,
@@ -25,23 +25,73 @@ var _editorPalette = require("@atlaskit/editor-palette");
25
25
  var _utils = require("../../../utils");
26
26
  var _analytics = require("@atlaskit/editor-common/analytics");
27
27
  var _events = require("../../../analytics/events");
28
+ var _annotation = _interopRequireDefault(require("../../marks/annotation"));
28
29
  var _styles = require("./styles");
29
30
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
30
31
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
31
32
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
32
33
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /** @jsx jsx */
34
+ var MediaBorder = function MediaBorder(_ref) {
35
+ var _mark$attrs$color, _mark$attrs$size;
36
+ var mark = _ref.mark,
37
+ children = _ref.children;
38
+ if (!mark) {
39
+ return (0, _react2.jsx)(_react.Fragment, null, children);
40
+ }
41
+ var borderColor = (_mark$attrs$color = mark === null || mark === void 0 ? void 0 : mark.attrs.color) !== null && _mark$attrs$color !== void 0 ? _mark$attrs$color : '';
42
+ var borderWidth = (_mark$attrs$size = mark === null || mark === void 0 ? void 0 : mark.attrs.size) !== null && _mark$attrs$size !== void 0 ? _mark$attrs$size : 0;
43
+ var paletteColorValue = (0, _editorPalette.hexToEditorBorderPaletteColor)(borderColor) || borderColor;
44
+ return (0, _react2.jsx)("div", {
45
+ "data-mark-type": "border",
46
+ "data-color": borderColor,
47
+ "data-size": borderWidth,
48
+ css: (0, _styles.borderStyle)(paletteColorValue, borderWidth)
49
+ }, (0, _react2.jsx)(_ui.MediaBorderGapFiller, {
50
+ borderColor: borderColor
51
+ }), children);
52
+ };
53
+ var MediaLink = function MediaLink(_ref2) {
54
+ var mark = _ref2.mark,
55
+ children = _ref2.children,
56
+ onClick = _ref2.onClick;
57
+ if (!mark) {
58
+ return (0, _react2.jsx)(_react.Fragment, null, children);
59
+ }
60
+ var linkHref = mark === null || mark === void 0 ? void 0 : mark.attrs.href;
61
+ return (0, _react2.jsx)("a", {
62
+ href: linkHref,
63
+ rel: "noreferrer noopener",
64
+ onClick: onClick,
65
+ "data-block-link": linkHref,
66
+ css: _styles.linkStyle
67
+ }, children);
68
+ };
69
+ var MediaAnnotation = function MediaAnnotation(_ref3) {
70
+ var mark = _ref3.mark,
71
+ children = _ref3.children;
72
+ if (!mark) {
73
+ return (0, _react2.jsx)(_react.Fragment, null, children);
74
+ }
75
+ return (0, _react2.jsx)(_annotation.default, {
76
+ id: mark.attrs.id,
77
+ annotationType: mark.attrs.annotationType,
78
+ dataAttributes: {
79
+ 'data-renderer-mark': true
80
+ }
81
+ // This should be fine being empty [] since the serializer serializeFragmentChild getMarkProps call always passes
82
+ ,
83
+ annotationParentIds: [],
84
+ allowAnnotations: true
85
+ }, children);
86
+ };
33
87
  var Media = exports.default = /*#__PURE__*/function (_PureComponent) {
34
88
  (0, _inherits2.default)(Media, _PureComponent);
35
89
  var _super = _createSuper(Media);
36
- function Media() {
90
+ function Media(props) {
37
91
  var _this;
38
92
  (0, _classCallCheck2.default)(this, Media);
39
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
40
- args[_key] = arguments[_key];
41
- }
42
- _this = _super.call.apply(_super, [this].concat(args));
93
+ _this = _super.call(this, props);
43
94
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderCard", function () {
44
- var _borderMark$attrs$col, _borderMark$attrs$siz;
45
95
  var providers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
46
96
  var contextIdentifierProvider = providers.contextIdentifierProvider;
47
97
  var _this$props = _this.props,
@@ -51,14 +101,20 @@ var Media = exports.default = /*#__PURE__*/function (_PureComponent) {
51
101
  allowMediaViewer = _this$props.shouldOpenMediaViewer,
52
102
  enableDownloadButton = _this$props.enableDownloadButton,
53
103
  ssr = _this$props.ssr;
104
+ var annotationMark = _this.props.isAnnotationMark ? _this.props.marks.find(_this.props.isAnnotationMark) : undefined;
54
105
  var borderMark = _this.props.marks.find(_this.props.isBorderMark);
55
- var borderColor = (_borderMark$attrs$col = borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.color) !== null && _borderMark$attrs$col !== void 0 ? _borderMark$attrs$col : '';
56
- var borderWidth = (_borderMark$attrs$siz = borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.size) !== null && _borderMark$attrs$siz !== void 0 ? _borderMark$attrs$siz : 0;
57
106
  var linkMark = _this.props.marks.find(_this.props.isLinkMark);
58
107
  var linkHref = linkMark === null || linkMark === void 0 ? void 0 : linkMark.attrs.href;
59
108
  var eventHandlers = linkHref ? undefined : _this.props.eventHandlers;
60
109
  var shouldOpenMediaViewer = !linkHref && allowMediaViewer;
61
- var mediaComponent = (0, _react2.jsx)(_analyticsNext.AnalyticsContext, {
110
+ return (0, _react2.jsx)(MediaLink, {
111
+ mark: linkMark,
112
+ onClick: _this.handleMediaLinkClickFn
113
+ }, (0, _react2.jsx)(MediaAnnotation, {
114
+ mark: annotationMark
115
+ }, (0, _react2.jsx)(MediaBorder, {
116
+ mark: borderMark
117
+ }, (0, _react2.jsx)(_analyticsNext.AnalyticsContext, {
62
118
  data: (0, _defineProperty2.default)({}, _analyticsNamespacedContext.MEDIA_CONTEXT, {
63
119
  border: !!borderMark
64
120
  })
@@ -71,23 +127,7 @@ var Media = exports.default = /*#__PURE__*/function (_PureComponent) {
71
127
  featureFlags: featureFlags,
72
128
  shouldEnableDownloadButton: enableDownloadButton,
73
129
  ssr: ssr
74
- })));
75
- var paletteColorValue = (0, _editorPalette.hexToEditorBorderPaletteColor)(borderColor) || borderColor;
76
- var mediaComponentWithBorder = borderMark ? (0, _react2.jsx)("div", {
77
- "data-mark-type": "border",
78
- "data-color": borderColor,
79
- "data-size": borderWidth,
80
- css: (0, _styles.borderStyle)(paletteColorValue, borderWidth)
81
- }, (0, _react2.jsx)(_ui.MediaBorderGapFiller, {
82
- borderColor: borderColor
83
- }), mediaComponent) : mediaComponent;
84
- return linkHref ? (0, _react2.jsx)("a", {
85
- href: linkHref,
86
- rel: "noreferrer noopener",
87
- onClick: _this.handleMediaLinkClick,
88
- "data-block-link": linkHref,
89
- css: _styles.linkStyle
90
- }, mediaComponentWithBorder) : mediaComponentWithBorder;
130
+ }))))));
91
131
  });
92
132
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleMediaLinkClick", function (event) {
93
133
  var _this$props2 = _this.props,
@@ -114,6 +154,7 @@ var Media = exports.default = /*#__PURE__*/function (_PureComponent) {
114
154
  handler(event, _linkMark && linkHref);
115
155
  }
116
156
  });
157
+ _this.handleMediaLinkClickFn = _this.handleMediaLinkClick.bind((0, _assertThisInitialized2.default)(_this));
117
158
  return _this;
118
159
  }
119
160
  (0, _createClass2.default)(Media, [{
@@ -55,7 +55,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
55
55
  var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
56
56
  var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
57
57
  var packageName = "@atlaskit/renderer";
58
- var packageVersion = "109.10.4";
58
+ var packageVersion = "109.10.5";
59
59
  var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
60
60
  (0, _inherits2.default)(Renderer, _PureComponent);
61
61
  var _super = _createSuper(Renderer);
@@ -23,7 +23,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
23
23
  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) { (0, _defineProperty2.default)(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; }
24
24
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- `AnnotationSharedCSSByState` is not object-safe
25
25
  var markStyles = function markStyles() {
26
- return (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: inherit;\n background-color: unset;\n -webkit-tap-highlight-color: transparent;\n\n &[data-mark-annotation-state='", "'] {\n ", ";\n\n &:focus,\n &[data-has-focus='true'] {\n ", ";\n }\n\n & div.rich-media-item {\n ", ";\n }\n }\n"])), _adfSchema.AnnotationMarkStates.ACTIVE, (0, _styles.AnnotationSharedCSSByState)().blur, (0, _styles.AnnotationSharedCSSByState)().focus, _styles.mediaAnnotationStyles);
26
+ return (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: inherit;\n background-color: unset;\n -webkit-tap-highlight-color: transparent;\n\n &[data-mark-annotation-state='", "'] {\n ", ";\n\n &:focus,\n &[data-has-focus='true'] {\n ", ";\n }\n\n & div.media-file-card-view {\n ", ";\n z-index: -1;\n }\n }\n"])), _adfSchema.AnnotationMarkStates.ACTIVE, (0, _styles.AnnotationSharedCSSByState)().blur, (0, _styles.AnnotationSharedCSSByState)().focus, _styles.mediaAnnotationStyles);
27
27
  };
28
28
  var MarkComponent = exports.MarkComponent = function MarkComponent(_ref) {
29
29
  var annotationParentIds = _ref.annotationParentIds,
@@ -66,7 +66,7 @@ export default class ReactSerializer {
66
66
  return ((_n$type = n.type) === null || _n$type === void 0 ? void 0 : _n$type.name) !== 'mediaSingle';
67
67
  }) && isMedia && mark.type.name === 'border';
68
68
  const shouldSkipLinkMark = mark => this.allowMediaLinking !== true && isMedia && mark.type.name === 'link';
69
- return marks.reverse().reduce((content, mark) => {
69
+ return marks.reduceRight((content, mark) => {
70
70
  if (shouldSkipLinkMark(mark) || shouldSkipBorderMark(mark)) {
71
71
  return content;
72
72
  }
@@ -342,6 +342,7 @@ export default class ReactSerializer {
342
342
  var _this$media;
343
343
  const {
344
344
  marks: {
345
+ annotation,
345
346
  link,
346
347
  border
347
348
  }
@@ -350,6 +351,7 @@ export default class ReactSerializer {
350
351
  var _n$type2;
351
352
  return ((_n$type2 = n.type) === null || _n$type2 === void 0 ? void 0 : _n$type2.name) === 'mediaSingle';
352
353
  });
354
+ const isAnnotationMark = mark => mark.type === annotation;
353
355
  const isLinkMark = mark => mark.type === link;
354
356
  const isBorderMark = mark => isChildOfMediaSingle && mark.type === border;
355
357
  return {
@@ -357,6 +359,7 @@ export default class ReactSerializer {
357
359
  marks: node.marks.filter(m => !isLinkMark(m) || this.allowMediaLinking === true),
358
360
  isLinkMark,
359
361
  isBorderMark,
362
+ isAnnotationMark,
360
363
  allowAltTextOnImages: this.allowAltTextOnImages,
361
364
  featureFlags: this.media && this.media.featureFlags,
362
365
  shouldOpenMediaViewer: this.shouldOpenMediaViewer,
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  /** @jsx jsx */
4
4
 
5
- import React, { PureComponent } from 'react';
5
+ import React, { PureComponent, Fragment } from 'react';
6
6
  import { jsx } from '@emotion/react';
7
7
  import { AnalyticsContext } from '@atlaskit/analytics-next';
8
8
  import { MEDIA_CONTEXT } from '@atlaskit/analytics-namespaced-context';
@@ -13,12 +13,68 @@ import { hexToEditorBorderPaletteColor } from '@atlaskit/editor-palette';
13
13
  import { getEventHandler } from '../../../utils';
14
14
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
15
15
  import { MODE, PLATFORM } from '../../../analytics/events';
16
+ import AnnotationComponent from '../../marks/annotation';
16
17
  import { linkStyle, borderStyle } from './styles';
18
+ const MediaBorder = ({
19
+ mark,
20
+ children
21
+ }) => {
22
+ var _mark$attrs$color, _mark$attrs$size;
23
+ if (!mark) {
24
+ return jsx(Fragment, null, children);
25
+ }
26
+ const borderColor = (_mark$attrs$color = mark === null || mark === void 0 ? void 0 : mark.attrs.color) !== null && _mark$attrs$color !== void 0 ? _mark$attrs$color : '';
27
+ const borderWidth = (_mark$attrs$size = mark === null || mark === void 0 ? void 0 : mark.attrs.size) !== null && _mark$attrs$size !== void 0 ? _mark$attrs$size : 0;
28
+ const paletteColorValue = hexToEditorBorderPaletteColor(borderColor) || borderColor;
29
+ return jsx("div", {
30
+ "data-mark-type": "border",
31
+ "data-color": borderColor,
32
+ "data-size": borderWidth,
33
+ css: borderStyle(paletteColorValue, borderWidth)
34
+ }, jsx(MediaBorderGapFiller, {
35
+ borderColor: borderColor
36
+ }), children);
37
+ };
38
+ const MediaLink = ({
39
+ mark,
40
+ children,
41
+ onClick
42
+ }) => {
43
+ if (!mark) {
44
+ return jsx(Fragment, null, children);
45
+ }
46
+ const linkHref = mark === null || mark === void 0 ? void 0 : mark.attrs.href;
47
+ return jsx("a", {
48
+ href: linkHref,
49
+ rel: "noreferrer noopener",
50
+ onClick: onClick,
51
+ "data-block-link": linkHref,
52
+ css: linkStyle
53
+ }, children);
54
+ };
55
+ const MediaAnnotation = ({
56
+ mark,
57
+ children
58
+ }) => {
59
+ if (!mark) {
60
+ return jsx(Fragment, null, children);
61
+ }
62
+ return jsx(AnnotationComponent, {
63
+ id: mark.attrs.id,
64
+ annotationType: mark.attrs.annotationType,
65
+ dataAttributes: {
66
+ 'data-renderer-mark': true
67
+ }
68
+ // This should be fine being empty [] since the serializer serializeFragmentChild getMarkProps call always passes
69
+ ,
70
+ annotationParentIds: [],
71
+ allowAnnotations: true
72
+ }, children);
73
+ };
17
74
  export default class Media extends PureComponent {
18
- constructor(...args) {
19
- super(...args);
75
+ constructor(props) {
76
+ super(props);
20
77
  _defineProperty(this, "renderCard", (providers = {}) => {
21
- var _borderMark$attrs$col, _borderMark$attrs$siz;
22
78
  const {
23
79
  contextIdentifierProvider
24
80
  } = providers;
@@ -30,14 +86,20 @@ export default class Media extends PureComponent {
30
86
  enableDownloadButton,
31
87
  ssr
32
88
  } = this.props;
89
+ const annotationMark = this.props.isAnnotationMark ? this.props.marks.find(this.props.isAnnotationMark) : undefined;
33
90
  const borderMark = this.props.marks.find(this.props.isBorderMark);
34
- const borderColor = (_borderMark$attrs$col = borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.color) !== null && _borderMark$attrs$col !== void 0 ? _borderMark$attrs$col : '';
35
- const borderWidth = (_borderMark$attrs$siz = borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.size) !== null && _borderMark$attrs$siz !== void 0 ? _borderMark$attrs$siz : 0;
36
91
  const linkMark = this.props.marks.find(this.props.isLinkMark);
37
92
  const linkHref = linkMark === null || linkMark === void 0 ? void 0 : linkMark.attrs.href;
38
93
  const eventHandlers = linkHref ? undefined : this.props.eventHandlers;
39
94
  const shouldOpenMediaViewer = !linkHref && allowMediaViewer;
40
- const mediaComponent = jsx(AnalyticsContext, {
95
+ return jsx(MediaLink, {
96
+ mark: linkMark,
97
+ onClick: this.handleMediaLinkClickFn
98
+ }, jsx(MediaAnnotation, {
99
+ mark: annotationMark
100
+ }, jsx(MediaBorder, {
101
+ mark: borderMark
102
+ }, jsx(AnalyticsContext, {
41
103
  data: {
42
104
  [MEDIA_CONTEXT]: {
43
105
  border: !!borderMark
@@ -52,23 +114,7 @@ export default class Media extends PureComponent {
52
114
  featureFlags: featureFlags,
53
115
  shouldEnableDownloadButton: enableDownloadButton,
54
116
  ssr: ssr
55
- })));
56
- const paletteColorValue = hexToEditorBorderPaletteColor(borderColor) || borderColor;
57
- const mediaComponentWithBorder = borderMark ? jsx("div", {
58
- "data-mark-type": "border",
59
- "data-color": borderColor,
60
- "data-size": borderWidth,
61
- css: borderStyle(paletteColorValue, borderWidth)
62
- }, jsx(MediaBorderGapFiller, {
63
- borderColor: borderColor
64
- }), mediaComponent) : mediaComponent;
65
- return linkHref ? jsx("a", {
66
- href: linkHref,
67
- rel: "noreferrer noopener",
68
- onClick: this.handleMediaLinkClick,
69
- "data-block-link": linkHref,
70
- css: linkStyle
71
- }, mediaComponentWithBorder) : mediaComponentWithBorder;
117
+ }))))));
72
118
  });
73
119
  _defineProperty(this, "handleMediaLinkClick", event => {
74
120
  const {
@@ -96,6 +142,7 @@ export default class Media extends PureComponent {
96
142
  handler(event, linkMark && linkHref);
97
143
  }
98
144
  });
145
+ this.handleMediaLinkClickFn = this.handleMediaLinkClick.bind(this);
99
146
  }
100
147
  render() {
101
148
  const {
@@ -36,7 +36,7 @@ import { EditorMediaClientProvider } from '../../react/utils/EditorMediaClientPr
36
36
  export const NORMAL_SEVERITY_THRESHOLD = 2000;
37
37
  export const DEGRADED_SEVERITY_THRESHOLD = 3000;
38
38
  const packageName = "@atlaskit/renderer";
39
- const packageVersion = "109.10.4";
39
+ const packageVersion = "109.10.5";
40
40
  export class Renderer extends PureComponent {
41
41
  constructor(props) {
42
42
  super(props);
@@ -21,8 +21,9 @@ const markStyles = () => css`
21
21
  ${AnnotationSharedCSSByState().focus};
22
22
  }
23
23
 
24
- & div.rich-media-item {
24
+ & div.media-file-card-view {
25
25
  ${mediaAnnotationStyles};
26
+ z-index: -1;
26
27
  }
27
28
  }
28
29
  `;
@@ -78,7 +78,7 @@ var ReactSerializer = /*#__PURE__*/function () {
78
78
  var shouldSkipLinkMark = function shouldSkipLinkMark(mark) {
79
79
  return _this.allowMediaLinking !== true && isMedia && mark.type.name === 'link';
80
80
  };
81
- return marks.reverse().reduce(function (content, mark) {
81
+ return marks.reduceRight(function (content, mark) {
82
82
  if (shouldSkipLinkMark(mark) || shouldSkipBorderMark(mark)) {
83
83
  return content;
84
84
  }
@@ -382,12 +382,16 @@ var ReactSerializer = /*#__PURE__*/function () {
382
382
  _this$media;
383
383
  var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
384
384
  var _node$type$schema$mar = node.type.schema.marks,
385
+ annotation = _node$type$schema$mar.annotation,
385
386
  link = _node$type$schema$mar.link,
386
387
  border = _node$type$schema$mar.border;
387
388
  var isChildOfMediaSingle = path.some(function (n) {
388
389
  var _n$type2;
389
390
  return ((_n$type2 = n.type) === null || _n$type2 === void 0 ? void 0 : _n$type2.name) === 'mediaSingle';
390
391
  });
392
+ var isAnnotationMark = function isAnnotationMark(mark) {
393
+ return mark.type === annotation;
394
+ };
391
395
  var isLinkMark = function isLinkMark(mark) {
392
396
  return mark.type === link;
393
397
  };
@@ -400,6 +404,7 @@ var ReactSerializer = /*#__PURE__*/function () {
400
404
  }),
401
405
  isLinkMark: isLinkMark,
402
406
  isBorderMark: isBorderMark,
407
+ isAnnotationMark: isAnnotationMark,
403
408
  allowAltTextOnImages: this.allowAltTextOnImages,
404
409
  featureFlags: this.media && this.media.featureFlags,
405
410
  shouldOpenMediaViewer: this.shouldOpenMediaViewer,
@@ -10,7 +10,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
10
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
11
  /** @jsx jsx */
12
12
 
13
- import React, { PureComponent } from 'react';
13
+ import React, { PureComponent, Fragment } from 'react';
14
14
  import { jsx } from '@emotion/react';
15
15
  import { AnalyticsContext } from '@atlaskit/analytics-next';
16
16
  import { MEDIA_CONTEXT } from '@atlaskit/analytics-namespaced-context';
@@ -21,19 +21,69 @@ import { hexToEditorBorderPaletteColor } from '@atlaskit/editor-palette';
21
21
  import { getEventHandler } from '../../../utils';
22
22
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
23
23
  import { MODE, PLATFORM } from '../../../analytics/events';
24
+ import AnnotationComponent from '../../marks/annotation';
24
25
  import { linkStyle, borderStyle } from './styles';
26
+ var MediaBorder = function MediaBorder(_ref) {
27
+ var _mark$attrs$color, _mark$attrs$size;
28
+ var mark = _ref.mark,
29
+ children = _ref.children;
30
+ if (!mark) {
31
+ return jsx(Fragment, null, children);
32
+ }
33
+ var borderColor = (_mark$attrs$color = mark === null || mark === void 0 ? void 0 : mark.attrs.color) !== null && _mark$attrs$color !== void 0 ? _mark$attrs$color : '';
34
+ var borderWidth = (_mark$attrs$size = mark === null || mark === void 0 ? void 0 : mark.attrs.size) !== null && _mark$attrs$size !== void 0 ? _mark$attrs$size : 0;
35
+ var paletteColorValue = hexToEditorBorderPaletteColor(borderColor) || borderColor;
36
+ return jsx("div", {
37
+ "data-mark-type": "border",
38
+ "data-color": borderColor,
39
+ "data-size": borderWidth,
40
+ css: borderStyle(paletteColorValue, borderWidth)
41
+ }, jsx(MediaBorderGapFiller, {
42
+ borderColor: borderColor
43
+ }), children);
44
+ };
45
+ var MediaLink = function MediaLink(_ref2) {
46
+ var mark = _ref2.mark,
47
+ children = _ref2.children,
48
+ onClick = _ref2.onClick;
49
+ if (!mark) {
50
+ return jsx(Fragment, null, children);
51
+ }
52
+ var linkHref = mark === null || mark === void 0 ? void 0 : mark.attrs.href;
53
+ return jsx("a", {
54
+ href: linkHref,
55
+ rel: "noreferrer noopener",
56
+ onClick: onClick,
57
+ "data-block-link": linkHref,
58
+ css: linkStyle
59
+ }, children);
60
+ };
61
+ var MediaAnnotation = function MediaAnnotation(_ref3) {
62
+ var mark = _ref3.mark,
63
+ children = _ref3.children;
64
+ if (!mark) {
65
+ return jsx(Fragment, null, children);
66
+ }
67
+ return jsx(AnnotationComponent, {
68
+ id: mark.attrs.id,
69
+ annotationType: mark.attrs.annotationType,
70
+ dataAttributes: {
71
+ 'data-renderer-mark': true
72
+ }
73
+ // This should be fine being empty [] since the serializer serializeFragmentChild getMarkProps call always passes
74
+ ,
75
+ annotationParentIds: [],
76
+ allowAnnotations: true
77
+ }, children);
78
+ };
25
79
  var Media = /*#__PURE__*/function (_PureComponent) {
26
80
  _inherits(Media, _PureComponent);
27
81
  var _super = _createSuper(Media);
28
- function Media() {
82
+ function Media(props) {
29
83
  var _this;
30
84
  _classCallCheck(this, Media);
31
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
32
- args[_key] = arguments[_key];
33
- }
34
- _this = _super.call.apply(_super, [this].concat(args));
85
+ _this = _super.call(this, props);
35
86
  _defineProperty(_assertThisInitialized(_this), "renderCard", function () {
36
- var _borderMark$attrs$col, _borderMark$attrs$siz;
37
87
  var providers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
38
88
  var contextIdentifierProvider = providers.contextIdentifierProvider;
39
89
  var _this$props = _this.props,
@@ -43,14 +93,20 @@ var Media = /*#__PURE__*/function (_PureComponent) {
43
93
  allowMediaViewer = _this$props.shouldOpenMediaViewer,
44
94
  enableDownloadButton = _this$props.enableDownloadButton,
45
95
  ssr = _this$props.ssr;
96
+ var annotationMark = _this.props.isAnnotationMark ? _this.props.marks.find(_this.props.isAnnotationMark) : undefined;
46
97
  var borderMark = _this.props.marks.find(_this.props.isBorderMark);
47
- var borderColor = (_borderMark$attrs$col = borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.color) !== null && _borderMark$attrs$col !== void 0 ? _borderMark$attrs$col : '';
48
- var borderWidth = (_borderMark$attrs$siz = borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.size) !== null && _borderMark$attrs$siz !== void 0 ? _borderMark$attrs$siz : 0;
49
98
  var linkMark = _this.props.marks.find(_this.props.isLinkMark);
50
99
  var linkHref = linkMark === null || linkMark === void 0 ? void 0 : linkMark.attrs.href;
51
100
  var eventHandlers = linkHref ? undefined : _this.props.eventHandlers;
52
101
  var shouldOpenMediaViewer = !linkHref && allowMediaViewer;
53
- var mediaComponent = jsx(AnalyticsContext, {
102
+ return jsx(MediaLink, {
103
+ mark: linkMark,
104
+ onClick: _this.handleMediaLinkClickFn
105
+ }, jsx(MediaAnnotation, {
106
+ mark: annotationMark
107
+ }, jsx(MediaBorder, {
108
+ mark: borderMark
109
+ }, jsx(AnalyticsContext, {
54
110
  data: _defineProperty({}, MEDIA_CONTEXT, {
55
111
  border: !!borderMark
56
112
  })
@@ -63,23 +119,7 @@ var Media = /*#__PURE__*/function (_PureComponent) {
63
119
  featureFlags: featureFlags,
64
120
  shouldEnableDownloadButton: enableDownloadButton,
65
121
  ssr: ssr
66
- })));
67
- var paletteColorValue = hexToEditorBorderPaletteColor(borderColor) || borderColor;
68
- var mediaComponentWithBorder = borderMark ? jsx("div", {
69
- "data-mark-type": "border",
70
- "data-color": borderColor,
71
- "data-size": borderWidth,
72
- css: borderStyle(paletteColorValue, borderWidth)
73
- }, jsx(MediaBorderGapFiller, {
74
- borderColor: borderColor
75
- }), mediaComponent) : mediaComponent;
76
- return linkHref ? jsx("a", {
77
- href: linkHref,
78
- rel: "noreferrer noopener",
79
- onClick: _this.handleMediaLinkClick,
80
- "data-block-link": linkHref,
81
- css: linkStyle
82
- }, mediaComponentWithBorder) : mediaComponentWithBorder;
122
+ }))))));
83
123
  });
84
124
  _defineProperty(_assertThisInitialized(_this), "handleMediaLinkClick", function (event) {
85
125
  var _this$props2 = _this.props,
@@ -106,6 +146,7 @@ var Media = /*#__PURE__*/function (_PureComponent) {
106
146
  handler(event, _linkMark && linkHref);
107
147
  }
108
148
  });
149
+ _this.handleMediaLinkClickFn = _this.handleMediaLinkClick.bind(_assertThisInitialized(_this));
109
150
  return _this;
110
151
  }
111
152
  _createClass(Media, [{
@@ -46,7 +46,7 @@ import { EditorMediaClientProvider } from '../../react/utils/EditorMediaClientPr
46
46
  export var NORMAL_SEVERITY_THRESHOLD = 2000;
47
47
  export var DEGRADED_SEVERITY_THRESHOLD = 3000;
48
48
  var packageName = "@atlaskit/renderer";
49
- var packageVersion = "109.10.4";
49
+ var packageVersion = "109.10.5";
50
50
  export var Renderer = /*#__PURE__*/function (_PureComponent) {
51
51
  _inherits(Renderer, _PureComponent);
52
52
  var _super = _createSuper(Renderer);
@@ -15,7 +15,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
15
15
 
16
16
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- `AnnotationSharedCSSByState` is not object-safe
17
17
  var markStyles = function markStyles() {
18
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: inherit;\n background-color: unset;\n -webkit-tap-highlight-color: transparent;\n\n &[data-mark-annotation-state='", "'] {\n ", ";\n\n &:focus,\n &[data-has-focus='true'] {\n ", ";\n }\n\n & div.rich-media-item {\n ", ";\n }\n }\n"])), AnnotationMarkStates.ACTIVE, AnnotationSharedCSSByState().blur, AnnotationSharedCSSByState().focus, mediaAnnotationStyles);
18
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: inherit;\n background-color: unset;\n -webkit-tap-highlight-color: transparent;\n\n &[data-mark-annotation-state='", "'] {\n ", ";\n\n &:focus,\n &[data-has-focus='true'] {\n ", ";\n }\n\n & div.media-file-card-view {\n ", ";\n z-index: -1;\n }\n }\n"])), AnnotationMarkStates.ACTIVE, AnnotationSharedCSSByState().blur, AnnotationSharedCSSByState().focus, mediaAnnotationStyles);
19
19
  };
20
20
  export var MarkComponent = function MarkComponent(_ref) {
21
21
  var annotationParentIds = _ref.annotationParentIds,
@@ -3,7 +3,7 @@ import { jsx } from '@emotion/react';
3
3
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
4
4
  import type { EventHandlers } from '@atlaskit/editor-common/ui';
5
5
  import type { MediaCardProps } from '../../../ui/MediaCard';
6
- import type { LinkDefinition, BorderMarkDefinition } from '@atlaskit/adf-schema';
6
+ import type { LinkDefinition, BorderMarkDefinition, AnnotationMarkDefinition } from '@atlaskit/adf-schema';
7
7
  import type { MediaFeatureFlags } from '@atlaskit/media-common';
8
8
  import type { AnalyticsEventPayload } from '../../../analytics/events';
9
9
  export type MediaProps = MediaCardProps & {
@@ -11,15 +11,18 @@ export type MediaProps = MediaCardProps & {
11
11
  allowAltTextOnImages?: boolean;
12
12
  children?: React.ReactNode;
13
13
  isInsideOfBlockNode?: boolean;
14
- marks: Array<LinkDefinition | BorderMarkDefinition>;
14
+ marks: Array<LinkDefinition | BorderMarkDefinition | AnnotationMarkDefinition>;
15
15
  isBorderMark: () => boolean;
16
16
  isLinkMark: () => boolean;
17
+ isAnnotationMark?: () => boolean;
17
18
  fireAnalyticsEvent?: (event: AnalyticsEventPayload) => void;
18
19
  featureFlags?: MediaFeatureFlags;
19
20
  eventHandlers?: EventHandlers;
20
21
  enableDownloadButton?: boolean;
21
22
  };
22
23
  export default class Media extends PureComponent<MediaProps, {}> {
24
+ constructor(props: MediaProps);
25
+ private handleMediaLinkClickFn;
23
26
  private renderCard;
24
27
  private handleMediaLinkClick;
25
28
  render(): jsx.JSX.Element;
@@ -3,7 +3,7 @@ import { jsx } from '@emotion/react';
3
3
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
4
4
  import type { EventHandlers } from '@atlaskit/editor-common/ui';
5
5
  import type { MediaCardProps } from '../../../ui/MediaCard';
6
- import type { LinkDefinition, BorderMarkDefinition } from '@atlaskit/adf-schema';
6
+ import type { LinkDefinition, BorderMarkDefinition, AnnotationMarkDefinition } from '@atlaskit/adf-schema';
7
7
  import type { MediaFeatureFlags } from '@atlaskit/media-common';
8
8
  import type { AnalyticsEventPayload } from '../../../analytics/events';
9
9
  export type MediaProps = MediaCardProps & {
@@ -11,15 +11,18 @@ export type MediaProps = MediaCardProps & {
11
11
  allowAltTextOnImages?: boolean;
12
12
  children?: React.ReactNode;
13
13
  isInsideOfBlockNode?: boolean;
14
- marks: Array<LinkDefinition | BorderMarkDefinition>;
14
+ marks: Array<LinkDefinition | BorderMarkDefinition | AnnotationMarkDefinition>;
15
15
  isBorderMark: () => boolean;
16
16
  isLinkMark: () => boolean;
17
+ isAnnotationMark?: () => boolean;
17
18
  fireAnalyticsEvent?: (event: AnalyticsEventPayload) => void;
18
19
  featureFlags?: MediaFeatureFlags;
19
20
  eventHandlers?: EventHandlers;
20
21
  enableDownloadButton?: boolean;
21
22
  };
22
23
  export default class Media extends PureComponent<MediaProps, {}> {
24
+ constructor(props: MediaProps);
25
+ private handleMediaLinkClickFn;
23
26
  private renderCard;
24
27
  private handleMediaLinkClick;
25
28
  render(): jsx.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "109.10.4",
3
+ "version": "109.10.5",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/analytics-next": "^9.2.0",
32
32
  "@atlaskit/button": "^17.7.0",
33
33
  "@atlaskit/code": "^15.1.0",
34
- "@atlaskit/editor-common": "^78.18.0",
34
+ "@atlaskit/editor-common": "^78.19.0",
35
35
  "@atlaskit/editor-json-transformer": "^8.10.0",
36
36
  "@atlaskit/editor-palette": "1.5.3",
37
37
  "@atlaskit/editor-prosemirror": "3.0.0",