@atlaskit/renderer 109.31.3 → 109.32.1

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 (53) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cjs/react/index.js +8 -2
  3. package/dist/cjs/react/nodes/date.js +23 -39
  4. package/dist/cjs/react/nodes/emoji.js +41 -41
  5. package/dist/cjs/react/nodes/inlineCard.js +10 -25
  6. package/dist/cjs/react/nodes/mention.js +30 -36
  7. package/dist/cjs/react/nodes/status.js +30 -34
  8. package/dist/cjs/steps/index.js +26 -6
  9. package/dist/cjs/ui/Renderer/index.js +9 -3
  10. package/dist/cjs/ui/Renderer/style.js +18 -1
  11. package/dist/cjs/ui/annotations/element/mark.js +15 -5
  12. package/dist/cjs/ui/annotations/element/useInlineAnnotationProps.js +39 -0
  13. package/dist/es2019/react/index.js +8 -3
  14. package/dist/es2019/react/nodes/date.js +24 -23
  15. package/dist/es2019/react/nodes/emoji.js +35 -15
  16. package/dist/es2019/react/nodes/inlineCard.js +11 -26
  17. package/dist/es2019/react/nodes/mention.js +27 -15
  18. package/dist/es2019/react/nodes/status.js +26 -12
  19. package/dist/es2019/steps/index.js +26 -7
  20. package/dist/es2019/ui/Renderer/index.js +9 -3
  21. package/dist/es2019/ui/Renderer/style.js +21 -1
  22. package/dist/es2019/ui/annotations/element/mark.js +15 -5
  23. package/dist/es2019/ui/annotations/element/useInlineAnnotationProps.js +34 -0
  24. package/dist/esm/react/index.js +8 -2
  25. package/dist/esm/react/nodes/date.js +24 -41
  26. package/dist/esm/react/nodes/emoji.js +40 -39
  27. package/dist/esm/react/nodes/inlineCard.js +11 -26
  28. package/dist/esm/react/nodes/mention.js +31 -38
  29. package/dist/esm/react/nodes/status.js +31 -36
  30. package/dist/esm/steps/index.js +26 -6
  31. package/dist/esm/ui/Renderer/index.js +9 -3
  32. package/dist/esm/ui/Renderer/style.js +19 -1
  33. package/dist/esm/ui/annotations/element/mark.js +15 -5
  34. package/dist/esm/ui/annotations/element/useInlineAnnotationProps.js +33 -0
  35. package/dist/types/react/nodes/date.d.ts +2 -1
  36. package/dist/types/react/nodes/emoji.d.ts +10 -4
  37. package/dist/types/react/nodes/inlineCard.d.ts +4 -2
  38. package/dist/types/react/nodes/mention.d.ts +5 -5
  39. package/dist/types/react/nodes/status.d.ts +5 -5
  40. package/dist/types/steps/index.d.ts +1 -1
  41. package/dist/types/ui/Renderer/style.d.ts +1 -0
  42. package/dist/types/ui/annotations/element/mark.d.ts +4 -4
  43. package/dist/types/ui/annotations/element/useInlineAnnotationProps.d.ts +26 -0
  44. package/dist/types-ts4.5/react/nodes/date.d.ts +2 -1
  45. package/dist/types-ts4.5/react/nodes/emoji.d.ts +10 -4
  46. package/dist/types-ts4.5/react/nodes/inlineCard.d.ts +4 -2
  47. package/dist/types-ts4.5/react/nodes/mention.d.ts +5 -5
  48. package/dist/types-ts4.5/react/nodes/status.d.ts +5 -5
  49. package/dist/types-ts4.5/steps/index.d.ts +1 -1
  50. package/dist/types-ts4.5/ui/Renderer/style.d.ts +1 -0
  51. package/dist/types-ts4.5/ui/annotations/element/mark.d.ts +4 -4
  52. package/dist/types-ts4.5/ui/annotations/element/useInlineAnnotationProps.d.ts +26 -0
  53. package/package.json +9 -9
@@ -2,8 +2,10 @@
2
2
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
3
3
 
4
4
  import { css } from '@emotion/react';
5
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
6
  import { fontFamily, fontSize } from '@atlaskit/theme/constants';
6
7
  import * as colors from '@atlaskit/theme/colors';
8
+ import { N60A, Y300, Y75 } from '@atlaskit/theme/colors';
7
9
  import { headingSizes as headingSizesImport } from '@atlaskit/theme/typography';
8
10
  import { getGlobalTheme } from '@atlaskit/tokens';
9
11
  import { mediaInlineImageStyles } from '@atlaskit/editor-common/media-inline';
@@ -388,6 +390,23 @@ const getShadowOverrides = () => {
388
390
  }
389
391
  `;
390
392
  };
393
+ function getAnnotationStyles({
394
+ allowAnnotations
395
+ }) {
396
+ if (!getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes')) {
397
+ return '';
398
+ }
399
+ return css({
400
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
401
+ "& [data-mark-type='annotation'][data-mark-annotation-state='active'] [data-annotation-mark], & [data-annotation-draft-mark][data-annotation-inline-node]": {
402
+ background: `var(--ds-background-accent-yellow-subtler, ${Y75})`,
403
+ borderBottom: `2px solid ${`var(--ds-border-accent-yellow, ${Y300})`}`,
404
+ boxShadow: `var(--ds-shadow-overlay, ${`1px 2px 3px ${N60A}, -1px 2px 3px ${N60A}`})`,
405
+ cursor: 'pointer',
406
+ padding: `${"var(--ds-space-050, 4px)"} ${"var(--ds-space-025, 2px)"}`
407
+ }
408
+ });
409
+ }
391
410
  export const rendererStyles = wrapperProps => theme => {
392
411
  const {
393
412
  colorMode
@@ -483,9 +502,10 @@ export const rendererStyles = wrapperProps => theme => {
483
502
  ${shadowSharedStyle};
484
503
  ${dateSharedStyle};
485
504
  ${textColorStyles};
486
- ${backgroundColorStyles(colorMode)};
505
+ ${backgroundColorStyles};
487
506
  ${tasksAndDecisionsStyles};
488
507
  ${smartCardSharedStyles}
508
+ ${getAnnotationStyles(wrapperProps)}
489
509
 
490
510
  & .UnknownBlock {
491
511
  font-family: ${fontFamily()};
@@ -42,11 +42,21 @@ export const MarkComponent = ({
42
42
  if (event.defaultPrevented || state !== AnnotationMarkStates.ACTIVE) {
43
43
  return;
44
44
  }
45
-
46
- // prevents from opening link URL inside webView in Safari
47
- event.preventDefault();
48
45
  if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes')) {
49
- event.stopPropagation();
46
+ // We only want to interfere with click events if the click is on some ui inside the renderer document
47
+ // This is to prevent the click events from portaled content (such as link previews and mention profiles)
48
+ if (event.target instanceof HTMLElement && event.target.closest('.ak-renderer-document')) {
49
+ if (event.target.closest('[data-mention-id]')) {
50
+ // don't prevent default for mentions
51
+ } else {
52
+ // prevents from opening link URL inside webView in Safari
53
+ event.preventDefault();
54
+ event.stopPropagation();
55
+ }
56
+ }
57
+ } else {
58
+ // prevents from opening link URL inside webView in Safari
59
+ event.preventDefault();
50
60
  }
51
61
  onClick({
52
62
  eventTarget: event.target,
@@ -69,7 +79,7 @@ export const MarkComponent = ({
69
79
  ...accessibility,
70
80
  ...overriddenData,
71
81
  ...(!useBlockLevel && {
72
- css: markStyles
82
+ css: [markStyles]
73
83
  })
74
84
  }, children);
75
85
  };
@@ -0,0 +1,34 @@
1
+ import { useContext } from 'react';
2
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
+ import { AnnotationsDraftContext } from '../context';
4
+ export function useInlineAnnotationProps(props, {
5
+ isInlineCard
6
+ }) {
7
+ const draftPosition = useContext(AnnotationsDraftContext);
8
+ if (!isInlineCard && !getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
9
+ return {};
10
+ }
11
+ if (!getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes')) {
12
+ return {};
13
+ }
14
+ if (!props.dataAttributes) {
15
+ // the inlineCard component is currently used by the block card, embed card and card error boundary components
16
+ // when used via these components, no dataAttributes are passed (and we don't want it setup for inline comments)
17
+ return {};
18
+ }
19
+ const inlineCardPosition = props.dataAttributes['data-renderer-start-pos'] - 1;
20
+ const hasDraft = draftPosition && (draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from) <= inlineCardPosition && (draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.to) >= inlineCardPosition + 1;
21
+ if (hasDraft) {
22
+ return {
23
+ 'data-renderer-mark': true,
24
+ 'data-annotation-draft-mark': true,
25
+ 'data-annotation-inline-node': true,
26
+ 'data-renderer-start-pos': inlineCardPosition
27
+ };
28
+ }
29
+ return {
30
+ 'data-annotation-inline-node': true,
31
+ 'data-annotation-mark': true,
32
+ 'data-renderer-start-pos': inlineCardPosition
33
+ };
34
+ }
@@ -198,7 +198,7 @@ var ReactSerializer = /*#__PURE__*/function () {
198
198
  var path = parentInfo ? parentInfo.path : undefined;
199
199
  switch (node.type.name) {
200
200
  case 'date':
201
- return this.getDateProps(node, parentInfo);
201
+ return this.getDateProps(node, parentInfo, path);
202
202
  case 'hardBreak':
203
203
  return this.getHardBreakProps(node, path);
204
204
  case 'heading':
@@ -362,9 +362,15 @@ var ReactSerializer = /*#__PURE__*/function () {
362
362
  }, {
363
363
  key: "getDateProps",
364
364
  value: function getDateProps(node, parentInfo) {
365
+ var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
365
366
  return {
366
367
  timestamp: node.attrs && node.attrs.timestamp,
367
- parentIsIncompleteTask: parentInfo && parentInfo.parentIsIncompleteTask
368
+ parentIsIncompleteTask: parentInfo && parentInfo.parentIsIncompleteTask,
369
+ dataAttributes: {
370
+ // We need to account for depth (path.length gives up depth) here
371
+ // but depth doesnt increment the pos, only accounted for.
372
+ 'data-renderer-start-pos': this.startPos + path.length
373
+ }
368
374
  };
369
375
  }
370
376
  }, {
@@ -1,49 +1,32 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/createClass";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
- import React from 'react';
11
- import { PureComponent } from 'react';
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import React, { memo } from 'react';
12
4
  import { DateSharedCssClassName } from '@atlaskit/editor-common/styles';
13
5
  import { isPastDate, timestampToString, timestampToTaskContext } from '@atlaskit/editor-common/utils';
14
6
  import { injectIntl } from 'react-intl-next';
15
7
  import { useTaskItemsFormatContext } from '../../ui/TaskItemsFormatContext';
16
- var Date = /*#__PURE__*/function (_PureComponent) {
17
- _inherits(Date, _PureComponent);
18
- var _super = _createSuper(Date);
19
- function Date() {
20
- _classCallCheck(this, Date);
21
- return _super.apply(this, arguments);
22
- }
23
- _createClass(Date, [{
24
- key: "render",
25
- value: function render() {
26
- var _this$props = this.props,
27
- timestamp = _this$props.timestamp,
28
- parentIsIncompleteTask = _this$props.parentIsIncompleteTask,
29
- intl = _this$props.intl;
30
- var className = !!parentIsIncompleteTask && isPastDate(timestamp) ? 'date-node date-node-highlighted' : 'date-node';
31
- return (
32
- /*#__PURE__*/
33
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
34
- React.createElement("span", {
35
- className: DateSharedCssClassName.DATE_WRAPPER
36
- }, /*#__PURE__*/React.createElement("span", {
37
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
38
- className: className,
39
- "data-node-type": "date",
40
- "data-timestamp": timestamp
41
- }, parentIsIncompleteTask ? timestampToTaskContext(timestamp, intl) : timestampToString(timestamp, intl)))
42
- );
43
- }
44
- }]);
45
- return Date;
46
- }(PureComponent);
8
+ import { useInlineAnnotationProps } from '../../ui/annotations/element/useInlineAnnotationProps';
9
+ var Date = /*#__PURE__*/memo(function Date(props) {
10
+ var inlineAnnotationProps = useInlineAnnotationProps(props, {
11
+ isInlineCard: false
12
+ });
13
+ var timestamp = props.timestamp,
14
+ parentIsIncompleteTask = props.parentIsIncompleteTask,
15
+ intl = props.intl;
16
+ var className = !!parentIsIncompleteTask && isPastDate(timestamp) ? 'date-node date-node-highlighted' : 'date-node';
17
+ return (
18
+ /*#__PURE__*/
19
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
20
+ React.createElement("span", _extends({
21
+ className: DateSharedCssClassName.DATE_WRAPPER
22
+ }, inlineAnnotationProps), /*#__PURE__*/React.createElement("span", {
23
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
24
+ className: className,
25
+ "data-node-type": "date",
26
+ "data-timestamp": timestamp
27
+ }, parentIsIncompleteTask ? timestampToTaskContext(timestamp, intl) : timestampToString(timestamp, intl)))
28
+ );
29
+ });
47
30
  export var DateComponent = injectIntl(Date);
48
31
  function DateWithFormatContext(props) {
49
32
  var _useTaskItemsFormatCo = useTaskItemsFormatContext(),
@@ -1,41 +1,42 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
- import React from 'react';
9
- import { PureComponent } from 'react';
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
+ import { memo } from 'react';
10
5
  import { Emoji } from '@atlaskit/editor-common/emoji';
11
- var EmojiItem = /*#__PURE__*/function (_PureComponent) {
12
- _inherits(EmojiItem, _PureComponent);
13
- var _super = _createSuper(EmojiItem);
14
- function EmojiItem() {
15
- _classCallCheck(this, EmojiItem);
16
- return _super.apply(this, arguments);
6
+ import { useInlineAnnotationProps } from '../../ui/annotations/element/useInlineAnnotationProps';
7
+ function EmojiItem(props) {
8
+ var id = props.id,
9
+ providers = props.providers,
10
+ shortName = props.shortName,
11
+ text = props.text,
12
+ fitToHeight = props.fitToHeight,
13
+ resourceConfig = props.resourceConfig;
14
+ var inlineAnnotationProps = useInlineAnnotationProps(props, {
15
+ isInlineCard: false
16
+ });
17
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
18
+ return jsx("span", inlineAnnotationProps, jsx(Emoji, {
19
+ allowTextFallback: true,
20
+ id: id,
21
+ shortName: shortName,
22
+ fallback: text,
23
+ providers: providers,
24
+ fitToHeight: fitToHeight,
25
+ resourceConfig: resourceConfig
26
+ }));
17
27
  }
18
- _createClass(EmojiItem, [{
19
- key: "render",
20
- value: function render() {
21
- var _this$props = this.props,
22
- id = _this$props.id,
23
- providers = _this$props.providers,
24
- shortName = _this$props.shortName,
25
- text = _this$props.text,
26
- fitToHeight = _this$props.fitToHeight,
27
- resourceConfig = _this$props.resourceConfig;
28
- return /*#__PURE__*/React.createElement(Emoji, {
29
- allowTextFallback: true,
30
- id: id,
31
- shortName: shortName,
32
- fallback: text,
33
- providers: providers,
34
- fitToHeight: fitToHeight,
35
- resourceConfig: resourceConfig
36
- });
37
- }
38
- }]);
39
- return EmojiItem;
40
- }(PureComponent);
41
- export { EmojiItem as default };
28
+ return jsx(Emoji, {
29
+ allowTextFallback: true,
30
+ id: id,
31
+ shortName: shortName,
32
+ fallback: text,
33
+ providers: providers,
34
+ fitToHeight: fitToHeight,
35
+ resourceConfig: resourceConfig
36
+ });
37
+ }
38
+
39
+ // Working around an issue with pre existing tests using react-test-renderer
40
+ // https://github.com/facebook/react/issues/17301#issuecomment-557765213
41
+ EmojiItem.defaultProps = {};
42
+ export default /*#__PURE__*/memo(EmojiItem);
@@ -1,26 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
- import { css, jsx } from '@emotion/react';
3
+ import { jsx } from '@emotion/react';
4
4
  import { Card } from '@atlaskit/smart-card';
5
5
  import { CardSSR } from '@atlaskit/smart-card/ssr';
6
6
  import { UnsupportedInline } from '@atlaskit/editor-common/ui';
7
- import { N60A, Y300, Y75 } from '@atlaskit/theme/colors';
8
7
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
8
  import { CardErrorBoundary } from './fallback';
10
9
  import { withSmartCardStorage } from '../../ui/SmartCardStorage';
11
10
  import { getCardClickHandler } from '../utils/getCardClickHandler';
12
11
  import { AnalyticsContext } from '@atlaskit/analytics-next';
13
- var annotatedCard = css({
14
- // This is expected to be reworked as part of https://team.atlassian.com/project/ATLAS-61846/updates
15
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
16
- "[data-mark-type='annotation'][data-mark-annotation-state='active'] &": {
17
- background: "var(--ds-background-accent-yellow-subtler, ".concat(Y75, ")"),
18
- borderBottom: "2px solid ".concat("var(--ds-border-accent-yellow, ".concat(Y300, ")")),
19
- boxShadow: "var(--ds-shadow-overlay, ".concat("1px 2px 3px ".concat(N60A, ", -1px 2px 3px ").concat(N60A), ")"),
20
- cursor: 'pointer',
21
- padding: "var(--ds-space-050, 4px)".concat(" ", "var(--ds-space-025, 2px)")
22
- }
23
- });
12
+ import { useInlineAnnotationProps } from '../../ui/annotations/element/useInlineAnnotationProps';
24
13
  var InlineCard = function InlineCard(props) {
25
14
  var url = props.url,
26
15
  data = props.data,
@@ -47,21 +36,18 @@ var InlineCard = function InlineCard(props) {
47
36
  // Below is added for the future implementation of Linking Platform namespaced analytic context
48
37
  location: 'renderer'
49
38
  };
39
+ var inlineAnnotationProps = useInlineAnnotationProps(props, {
40
+ isInlineCard: true
41
+ });
50
42
  if (ssr && url) {
51
- // platform.editor.allow-inline-comments-for-inline-nodes requires this change to work -- however this feature flag is only intended to go to HELLO (and is expected to last for Q4).
52
- // platform.editor.renderer-inline-card-ssr-fix_kqcwl is the feature flag that allows this change to be safely released more widely.
53
- // Once platform.editor.renderer-inline-card-ssr-fix_kqcwl reaches 100% we can remove both checks
54
43
  if (
55
44
  // eslint-disable-next-line @atlaskit/platform/no-invalid-feature-flag-usage
56
- getBooleanFF('platform.editor.renderer-inline-card-ssr-fix_kqcwl') ||
57
- // eslint-disable-next-line @atlaskit/platform/no-invalid-feature-flag-usage
58
45
  getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes')) {
59
- return jsx("span", {
46
+ return jsx("span", _extends({
60
47
  "data-inline-card": true,
61
48
  "data-card-data": data ? JSON.stringify(data) : undefined,
62
- "data-card-url": url,
63
- css: annotatedCard
64
- }, jsx(AnalyticsContext, {
49
+ "data-card-url": url
50
+ }, inlineAnnotationProps), jsx(AnalyticsContext, {
65
51
  data: analyticsData
66
52
  }, jsx(CardSSR, {
67
53
  appearance: "inline",
@@ -93,12 +79,11 @@ var InlineCard = function InlineCard(props) {
93
79
  };
94
80
  return jsx(AnalyticsContext, {
95
81
  data: analyticsData
96
- }, jsx("span", {
82
+ }, jsx("span", _extends({
97
83
  "data-inline-card": true,
98
84
  "data-card-data": data ? JSON.stringify(data) : undefined,
99
- "data-card-url": url,
100
- css: getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes') ? annotatedCard : undefined
101
- }, jsx(CardErrorBoundary, _extends({
85
+ "data-card-url": url
86
+ }, inlineAnnotationProps), jsx(CardErrorBoundary, _extends({
102
87
  unsupportedComponent: UnsupportedInline
103
88
  }, cardProps), jsx(Card, _extends({
104
89
  appearance: "inline",
@@ -1,40 +1,33 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
- import React from 'react';
9
- import { PureComponent } from 'react';
1
+ import React, { memo } from 'react';
10
2
  import { Mention } from '@atlaskit/editor-common/mention';
11
- var MentionItem = /*#__PURE__*/function (_PureComponent) {
12
- _inherits(MentionItem, _PureComponent);
13
- var _super = _createSuper(MentionItem);
14
- function MentionItem() {
15
- _classCallCheck(this, MentionItem);
16
- return _super.apply(this, arguments);
3
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
+ import { useInlineAnnotationProps } from '../../ui/annotations/element/useInlineAnnotationProps';
5
+ export default /*#__PURE__*/memo(function MentionItem(props) {
6
+ var eventHandlers = props.eventHandlers,
7
+ id = props.id,
8
+ providers = props.providers,
9
+ text = props.text,
10
+ accessLevel = props.accessLevel,
11
+ localId = props.localId;
12
+ var inlineAnnotationProps = useInlineAnnotationProps(props, {
13
+ isInlineCard: false
14
+ });
15
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
16
+ return /*#__PURE__*/React.createElement("span", inlineAnnotationProps, /*#__PURE__*/React.createElement(Mention, {
17
+ id: id,
18
+ text: text,
19
+ accessLevel: accessLevel,
20
+ providers: providers,
21
+ localId: localId,
22
+ eventHandlers: eventHandlers && eventHandlers.mention
23
+ }));
17
24
  }
18
- _createClass(MentionItem, [{
19
- key: "render",
20
- value: function render() {
21
- var _this$props = this.props,
22
- eventHandlers = _this$props.eventHandlers,
23
- id = _this$props.id,
24
- providers = _this$props.providers,
25
- text = _this$props.text,
26
- accessLevel = _this$props.accessLevel,
27
- localId = _this$props.localId;
28
- return /*#__PURE__*/React.createElement(Mention, {
29
- id: id,
30
- text: text,
31
- accessLevel: accessLevel,
32
- providers: providers,
33
- localId: localId,
34
- eventHandlers: eventHandlers && eventHandlers.mention
35
- });
36
- }
37
- }]);
38
- return MentionItem;
39
- }(PureComponent);
40
- export { MentionItem as default };
25
+ return /*#__PURE__*/React.createElement(Mention, {
26
+ id: id,
27
+ text: text,
28
+ accessLevel: accessLevel,
29
+ providers: providers,
30
+ localId: localId,
31
+ eventHandlers: eventHandlers && eventHandlers.mention
32
+ });
33
+ });
@@ -1,40 +1,35 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
- import React from 'react';
9
- import { PureComponent } from 'react';
1
+ import React, { memo } from 'react';
10
2
  import { Status as AkStatus } from '@atlaskit/status/element';
11
3
  import { FabricElementsAnalyticsContext } from '@atlaskit/analytics-namespaced-context';
12
- var Status = /*#__PURE__*/function (_PureComponent) {
13
- _inherits(Status, _PureComponent);
14
- var _super = _createSuper(Status);
15
- function Status() {
16
- _classCallCheck(this, Status);
17
- return _super.apply(this, arguments);
4
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
+ import { useInlineAnnotationProps } from '../../ui/annotations/element/useInlineAnnotationProps';
6
+ export default /*#__PURE__*/memo(function Status(props) {
7
+ var text = props.text,
8
+ color = props.color,
9
+ localId = props.localId;
10
+ var inlineAnnotationProps = useInlineAnnotationProps(props, {
11
+ isInlineCard: false
12
+ });
13
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
14
+ return /*#__PURE__*/React.createElement("span", inlineAnnotationProps, /*#__PURE__*/React.createElement(FabricElementsAnalyticsContext, {
15
+ data: {
16
+ userContext: 'document'
17
+ }
18
+ }, /*#__PURE__*/React.createElement(AkStatus, {
19
+ text: text,
20
+ color: color,
21
+ localId: localId,
22
+ role: "presentation"
23
+ })));
18
24
  }
19
- _createClass(Status, [{
20
- key: "render",
21
- value: function render() {
22
- var _this$props = this.props,
23
- text = _this$props.text,
24
- color = _this$props.color,
25
- localId = _this$props.localId;
26
- return /*#__PURE__*/React.createElement(FabricElementsAnalyticsContext, {
27
- data: {
28
- userContext: 'document'
29
- }
30
- }, /*#__PURE__*/React.createElement(AkStatus, {
31
- text: text,
32
- color: color,
33
- localId: localId,
34
- role: "presentation"
35
- }));
25
+ return /*#__PURE__*/React.createElement(FabricElementsAnalyticsContext, {
26
+ data: {
27
+ userContext: 'document'
36
28
  }
37
- }]);
38
- return Status;
39
- }(PureComponent);
40
- export { Status as default };
29
+ }, /*#__PURE__*/React.createElement(AkStatus, {
30
+ text: text,
31
+ color: color,
32
+ localId: localId,
33
+ role: "presentation"
34
+ }));
35
+ });
@@ -70,7 +70,7 @@ function isNodeInlineTextMark(node) {
70
70
  * inline text mark.
71
71
  **/
72
72
 
73
- if (hasInlineCardDescendant(node)) {
73
+ if (hasInlineNodeDescendant(node)) {
74
74
  return false;
75
75
  }
76
76
  return true;
@@ -80,12 +80,18 @@ function isNodeInlineTextMark(node) {
80
80
  * This checks all the descendents of a node and returns true if it reaches
81
81
  * a descendant with the data-inline-card attribute set to 'true'.
82
82
  */
83
- function hasInlineCardDescendant(node) {
83
+ function hasInlineNodeDescendant(node) {
84
84
  if (isElementNode(node)) {
85
- if (node.dataset.inlineCard === 'true') {
86
- return true;
85
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
86
+ if (node.dataset.annotationInlineNode === 'true') {
87
+ return true;
88
+ }
89
+ } else {
90
+ if (node.dataset.inlineCard === 'true') {
91
+ return true;
92
+ }
87
93
  }
88
- return Array.from(node.childNodes).some(hasInlineCardDescendant);
94
+ return Array.from(node.childNodes).some(hasInlineNodeDescendant);
89
95
  }
90
96
  return false;
91
97
  }
@@ -118,10 +124,23 @@ function isRoot(element) {
118
124
  return !!element && element.classList.contains('ak-renderer-document');
119
125
  }
120
126
  export function resolvePos(node, offset) {
127
+ var findEnd = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
121
128
  // If the passed node doesn't exist, we should abort
122
129
  if (!node) {
123
130
  return false;
124
131
  }
132
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes')) {
133
+ var _node$parentElement;
134
+ var startPosAncestor = (_node$parentElement = node.parentElement) === null || _node$parentElement === void 0 ? void 0 : _node$parentElement.closest('[data-renderer-start-pos');
135
+ var potentialParent = getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz') ? 'data-annotation-mark' : 'data-inline-card';
136
+ if (startPosAncestor !== null && startPosAncestor !== void 0 && startPosAncestor.hasAttribute(potentialParent)) {
137
+ if (findEnd) {
138
+ return parseInt((startPosAncestor === null || startPosAncestor === void 0 ? void 0 : startPosAncestor.getAttribute('data-renderer-start-pos')) || '-1', 10) + 1;
139
+ } else {
140
+ return parseInt((startPosAncestor === null || startPosAncestor === void 0 ? void 0 : startPosAncestor.getAttribute('data-renderer-start-pos')) || '-1', 10);
141
+ }
142
+ }
143
+ }
125
144
  if (node instanceof HTMLElement && isPositionPointer(node)) {
126
145
  return getStartPos(node) + offset;
127
146
  }
@@ -207,7 +226,8 @@ export function getPosFromRange(range, isCommentsOnMediaBugFixEnabled, isComment
207
226
  }
208
227
  }
209
228
  var from = resolvePos(startContainer, startOffset);
210
- var to = resolvePos(endContainer, endOffset);
229
+ var findEnd = true;
230
+ var to = resolvePos(endContainer, endOffset, findEnd);
211
231
  if (from === false || to === false) {
212
232
  return false;
213
233
  }
@@ -47,7 +47,7 @@ import { nodeToReact } from '../../react/nodes';
47
47
  export var NORMAL_SEVERITY_THRESHOLD = 2000;
48
48
  export var DEGRADED_SEVERITY_THRESHOLD = 3000;
49
49
  var packageName = "@atlaskit/renderer";
50
- var packageVersion = "109.31.3";
50
+ var packageVersion = "109.32.1";
51
51
  export var defaultNodeComponents = nodeToReact;
52
52
  export var Renderer = /*#__PURE__*/function (_PureComponent) {
53
53
  _inherits(Renderer, _PureComponent);
@@ -288,6 +288,7 @@ export var Renderer = /*#__PURE__*/function (_PureComponent) {
288
288
  onComplete = _this$props.onComplete,
289
289
  onError = _this$props.onError,
290
290
  appearance = _this$props.appearance,
291
+ allowAnnotations = _this$props.allowAnnotations,
291
292
  adfStage = _this$props.adfStage,
292
293
  truncated = _this$props.truncated,
293
294
  maxHeight = _this$props.maxHeight,
@@ -370,6 +371,7 @@ export var Renderer = /*#__PURE__*/function (_PureComponent) {
370
371
  }, jsx(SmartCardStorageProvider, null, jsx(ProviderFactoryProvider, {
371
372
  value: this.providerFactory
372
373
  }, jsx(RendererWrapper, {
374
+ allowAnnotations: allowAnnotations,
373
375
  appearance: appearance,
374
376
  allowNestedHeaderLinks: allowNestedHeaderLinks,
375
377
  allowColumnSorting: allowColumnSorting,
@@ -408,6 +410,7 @@ export var Renderer = /*#__PURE__*/function (_PureComponent) {
408
410
  onError(e);
409
411
  }
410
412
  return jsx(RendererWrapper, {
413
+ allowAnnotations: allowAnnotations,
411
414
  appearance: appearance,
412
415
  allowCopyToClipboard: allowCopyToClipboard,
413
416
  allowWrapCodeBlock: allowWrapCodeBlock,
@@ -536,12 +539,15 @@ var RendererWrapper = /*#__PURE__*/React.memo(function (props) {
536
539
  }, jsx("div", {
537
540
  ref: innerRef,
538
541
  onClick: onClick,
539
- onMouseDown: onMouseDown,
542
+ onMouseDown: onMouseDown
543
+ // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
544
+ ,
540
545
  css: rendererStyles({
541
546
  appearance: appearance,
542
547
  allowNestedHeaderLinks: allowNestedHeaderLinks,
543
548
  allowColumnSorting: !!allowColumnSorting,
544
- useBlockRenderForCodeBlock: useBlockRenderForCodeBlock
549
+ useBlockRenderForCodeBlock: useBlockRenderForCodeBlock,
550
+ allowAnnotations: props.allowAnnotations
545
551
  })
546
552
  }, children))));
547
553
  });