@atlaskit/renderer 94.0.0 → 96.0.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 (93) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/cjs/react/index.js +0 -2
  3. package/dist/cjs/react/marks/link.js +3 -1
  4. package/dist/cjs/react/nodes/codeBlock.js +5 -0
  5. package/dist/cjs/react/nodes/codeBlockCopyButton.js +3 -1
  6. package/dist/cjs/react/nodes/embedCard.js +2 -5
  7. package/dist/cjs/react/nodes/heading-anchor.js +4 -2
  8. package/dist/cjs/react/nodes/inlineCard.js +5 -1
  9. package/dist/cjs/react/nodes/mediaInline.js +41 -4
  10. package/dist/cjs/react/nodes/mediaSingle/index.js +3 -7
  11. package/dist/cjs/react/nodes/table/colgroup.js +6 -12
  12. package/dist/cjs/react/nodes/table/sticky.js +21 -21
  13. package/dist/cjs/react/nodes/table/table.js +1 -3
  14. package/dist/cjs/react/nodes/table.js +20 -9
  15. package/dist/cjs/react/nodes/tableCell.js +5 -3
  16. package/dist/cjs/render-document.js +142 -55
  17. package/dist/cjs/ui/MediaCard.js +2 -2
  18. package/dist/cjs/ui/Renderer/breakout-ssr.js +6 -8
  19. package/dist/cjs/ui/Renderer/index.js +22 -34
  20. package/dist/cjs/ui/Renderer/style.js +30 -28
  21. package/dist/cjs/ui/Renderer/truncated-wrapper.js +6 -3
  22. package/dist/cjs/ui/SortingIcon.js +6 -2
  23. package/dist/cjs/ui/annotations/draft/component.js +1 -1
  24. package/dist/cjs/ui/annotations/element/mark.js +1 -1
  25. package/dist/cjs/ui/annotations/hooks/use-events.js +4 -2
  26. package/dist/cjs/version.json +1 -1
  27. package/dist/es2019/react/index.js +0 -2
  28. package/dist/es2019/react/marks/link.js +8 -3
  29. package/dist/es2019/react/nodes/codeBlock.js +5 -0
  30. package/dist/es2019/react/nodes/codeBlockCopyButton.js +7 -6
  31. package/dist/es2019/react/nodes/embedCard.js +4 -7
  32. package/dist/es2019/react/nodes/heading-anchor.js +3 -2
  33. package/dist/es2019/react/nodes/inlineCard.js +4 -1
  34. package/dist/es2019/react/nodes/mediaInline.js +36 -4
  35. package/dist/es2019/react/nodes/mediaSingle/index.js +5 -9
  36. package/dist/es2019/react/nodes/table/colgroup.js +2 -8
  37. package/dist/es2019/react/nodes/table/sticky.js +30 -28
  38. package/dist/es2019/react/nodes/table/table.js +1 -3
  39. package/dist/es2019/react/nodes/table.js +18 -9
  40. package/dist/es2019/react/nodes/tableCell.js +4 -1
  41. package/dist/es2019/render-document.js +117 -56
  42. package/dist/es2019/ui/MediaCard.js +1 -1
  43. package/dist/es2019/ui/Renderer/breakout-ssr.js +6 -8
  44. package/dist/es2019/ui/Renderer/index.js +6 -19
  45. package/dist/es2019/ui/Renderer/style.js +50 -32
  46. package/dist/es2019/ui/Renderer/truncated-wrapper.js +5 -3
  47. package/dist/es2019/ui/SortingIcon.js +7 -5
  48. package/dist/es2019/ui/annotations/draft/component.js +1 -1
  49. package/dist/es2019/ui/annotations/element/mark.js +1 -1
  50. package/dist/es2019/ui/annotations/hooks/use-events.js +2 -2
  51. package/dist/es2019/version.json +1 -1
  52. package/dist/esm/react/index.js +0 -2
  53. package/dist/esm/react/marks/link.js +3 -2
  54. package/dist/esm/react/nodes/codeBlock.js +5 -0
  55. package/dist/esm/react/nodes/codeBlockCopyButton.js +2 -1
  56. package/dist/esm/react/nodes/embedCard.js +4 -7
  57. package/dist/esm/react/nodes/heading-anchor.js +3 -2
  58. package/dist/esm/react/nodes/inlineCard.js +4 -1
  59. package/dist/esm/react/nodes/mediaInline.js +36 -4
  60. package/dist/esm/react/nodes/mediaSingle/index.js +5 -9
  61. package/dist/esm/react/nodes/table/colgroup.js +6 -12
  62. package/dist/esm/react/nodes/table/sticky.js +20 -22
  63. package/dist/esm/react/nodes/table/table.js +1 -3
  64. package/dist/esm/react/nodes/table.js +20 -9
  65. package/dist/esm/react/nodes/tableCell.js +5 -3
  66. package/dist/esm/render-document.js +137 -55
  67. package/dist/esm/ui/MediaCard.js +1 -1
  68. package/dist/esm/ui/Renderer/breakout-ssr.js +6 -8
  69. package/dist/esm/ui/Renderer/index.js +21 -33
  70. package/dist/esm/ui/Renderer/style.js +30 -28
  71. package/dist/esm/ui/Renderer/truncated-wrapper.js +5 -3
  72. package/dist/esm/ui/SortingIcon.js +5 -3
  73. package/dist/esm/ui/annotations/draft/component.js +1 -1
  74. package/dist/esm/ui/annotations/element/mark.js +1 -1
  75. package/dist/esm/ui/annotations/hooks/use-events.js +4 -2
  76. package/dist/esm/version.json +1 -1
  77. package/dist/types/react/index.d.ts +0 -2
  78. package/dist/types/react/nodes/embedCard.d.ts +0 -1
  79. package/dist/types/react/nodes/extension.d.ts +6 -0
  80. package/dist/types/react/nodes/index.d.ts +1 -2
  81. package/dist/types/react/nodes/media.d.ts +0 -1
  82. package/dist/types/react/nodes/mediaInline.d.ts +6 -3
  83. package/dist/types/react/nodes/mediaSingle/index.d.ts +0 -1
  84. package/dist/types/react/nodes/table/sticky.d.ts +1 -2
  85. package/dist/types/react/nodes/table/table.d.ts +1 -1
  86. package/dist/types/react/nodes/table/types.d.ts +0 -1
  87. package/dist/types/react/types.d.ts +0 -1
  88. package/dist/types/render-document.d.ts +1 -1
  89. package/dist/types/renderer-context.d.ts +1 -0
  90. package/dist/types/ui/MediaCard.d.ts +1 -1
  91. package/dist/types/ui/Renderer/breakout-ssr.d.ts +2 -4
  92. package/dist/types/ui/renderer-props.d.ts +1 -0
  93. package/package.json +27 -20
@@ -19,7 +19,7 @@ export const useAnnotationStateByTypeEvent = ({
19
19
  }
20
20
 
21
21
  const nextStates = Object.values(payload).reduce((acc, curr) => {
22
- if (curr.annotationType === type) {
22
+ if (curr.id && curr.annotationType === type) {
23
23
  // Check for empty state to prevent additional renders
24
24
  const isEmpty = curr.state === null || curr.state === undefined;
25
25
  return { ...acc,
@@ -83,7 +83,7 @@ export const useAnnotationClickEvent = props => {
83
83
  annotationIds,
84
84
  eventTarget
85
85
  }) => {
86
- const annotationsByType = annotationIds.map(id => ({
86
+ const annotationsByType = annotationIds.filter(id => !!id).map(id => ({
87
87
  id,
88
88
  type: AnnotationTypes.INLINE_COMMENT
89
89
  }));
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "94.0.0",
3
+ "version": "96.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -179,7 +179,6 @@ var ReactSerializer = /*#__PURE__*/function () {
179
179
  this.appearance = init.appearance;
180
180
  this.disableHeadingIDs = init.disableHeadingIDs;
181
181
  this.disableActions = init.disableActions;
182
- this.allowDynamicTextSizing = init.allowDynamicTextSizing;
183
182
  this.allowHeadingAnchorLinks = init.allowHeadingAnchorLinks;
184
183
  this.allowCopyToClipboard = init.allowCopyToClipboard;
185
184
  this.allowPlaceholderText = init.allowPlaceholderText;
@@ -550,7 +549,6 @@ var ReactSerializer = /*#__PURE__*/function () {
550
549
  rendererContext: this.rendererContext,
551
550
  serializer: this,
552
551
  content: node.content ? node.content.toJSON() : undefined,
553
- allowDynamicTextSizing: this.allowDynamicTextSizing,
554
552
  allowHeadingAnchorLinks: this.allowHeadingAnchorLinks,
555
553
  allowCopyToClipboard: this.allowCopyToClipboard,
556
554
  allowPlaceholderText: this.allowPlaceholderText,
@@ -6,11 +6,12 @@ var _templateObject;
6
6
  /** @jsx jsx */
7
7
  import React, { Fragment } from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
- import { B400, B300 } from '@atlaskit/theme/colors';
9
+ import { B400, B300, B500 } from '@atlaskit/theme/colors';
10
10
  import { getEventHandler } from '../../utils';
11
11
  import { PLATFORM, MODE } from '../../analytics/events';
12
12
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../../analytics/enums';
13
- var anchorStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n\n &:hover {\n color: ", ";\n text-decoration: underline;\n }\n"])), B400, B300);
13
+ import { token } from '@atlaskit/tokens';
14
+ var anchorStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n\n &:hover {\n color: ", ";\n text-decoration: underline;\n }\n\n &:active {\n color: ", ";\n }\n"])), token('color.link', B400), token('color.link', B300), token('color.link.pressed', B500));
14
15
  export default function Link(props) {
15
16
  var href = props.href,
16
17
  target = props.target,
@@ -14,6 +14,9 @@ import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
14
14
  import { useFeatureFlags } from '../../use-feature-flags';
15
15
  import CopyButton from './codeBlockCopyButton';
16
16
 
17
+ // TODO: Quality ticket https://product-fabric.atlassian.net/browse/DSP-4118
18
+
19
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
17
20
  var codeBlockStyle = function codeBlockStyle(props) {
18
21
  return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n tab-size: 4;\n [data-ds--code--code-block] {\n font-size: ", ";\n line-height: 1.5rem;\n background-image: ", ";\n background-attachment: local, scroll, scroll;\n background-position: 100% 0, 100% 0, 0 0;\n }\n "])), relativeFontSizeToBase16(fontSize()), overflowShadow({
19
22
  background: themed({
@@ -23,6 +26,8 @@ var codeBlockStyle = function codeBlockStyle(props) {
23
26
  width: "".concat(gridSize(), "px")
24
27
  }));
25
28
  };
29
+ /* eslint-enable */
30
+
26
31
 
27
32
  function CodeBlock(props) {
28
33
  var text = props.text,
@@ -13,7 +13,8 @@ import CopyIcon from '@atlaskit/icon/glyph/copy';
13
13
  import { N20, N30, N700 } from '@atlaskit/theme/colors';
14
14
  import { CopyTextConsumer } from './copy-text-provider';
15
15
  import { codeBlockCopyButtonMessages } from '../../messages';
16
- var copyButtonWrapperStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n position: sticky;\n justify-content: flex-end;\n top: 0;\n\n button {\n position: absolute;\n display: flex;\n justify-content: center;\n height: 32px;\n width: 32px;\n right: 6px;\n top: 4px;\n padding: 2px;\n opacity: 0;\n transition: opacity 0.2s ease 0s;\n border: 2px solid #fff;\n border-radius: 4px;\n background-color: ", ";\n color: rgb(66, 82, 110);\n }\n\n button:hover {\n background-color: ", ";\n }\n\n button.clicked {\n background-color: ", ";\n color: #fff !important;\n }\n"])), N20, N30, N700);
16
+ import { token } from '@atlaskit/tokens';
17
+ var copyButtonWrapperStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n position: sticky;\n justify-content: flex-end;\n top: 0;\n\n button {\n position: absolute;\n display: flex;\n justify-content: center;\n height: 32px;\n width: 32px;\n right: 6px;\n top: 4px;\n padding: 2px;\n opacity: 0;\n transition: opacity 0.2s ease 0s;\n border: 2px solid ", ";\n border-radius: 4px;\n background-color: ", ";\n color: ", ";\n }\n\n button:hover {\n background-color: ", ";\n }\n\n button.clicked {\n background-color: ", ";\n color: ", " !important;\n }\n"])), token('color.border.inverse', '#fff'), token('color.background.neutral.subtle', N20), token('color.icon', 'rgb(66, 82, 110)'), token('color.background.neutral.hovered', N30), token('color.background.neutral.bold.pressed', N700), token('color.icon.inverse', '#fff'));
17
18
 
18
19
  var CopyButton = function CopyButton(_ref) {
19
20
  var content = _ref.content,
@@ -8,8 +8,8 @@ var _templateObject, _templateObject2;
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { useMemo, useContext, useState, useRef } from 'react';
10
10
  import { Card, Context as CardContext, EmbedResizeMessageListener } from '@atlaskit/smart-card';
11
- import { WidthConsumer, mapBreakpointToLayoutMaxWidth, UnsupportedBlock, MediaSingle as UIMediaSingle } from '@atlaskit/editor-common/ui';
12
- import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH, getAkEditorFullPageMaxWidth } from '@atlaskit/editor-shared-styles';
11
+ import { WidthConsumer, UnsupportedBlock, MediaSingle as UIMediaSingle } from '@atlaskit/editor-common/ui';
12
+ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
13
13
  import { getPlatform } from '../../utils';
14
14
  import { CardErrorBoundary } from './fallback';
15
15
  import { FullPagePadding } from '../../ui/Renderer/style';
@@ -24,7 +24,6 @@ export default function EmbedCard(props) {
24
24
  layout = props.layout,
25
25
  width = props.width,
26
26
  isInsideOfBlockNode = props.isInsideOfBlockNode,
27
- allowDynamicTextSizing = props.allowDynamicTextSizing,
28
27
  rendererAppearance = props.rendererAppearance;
29
28
  var embedIframeRef = useRef(null);
30
29
  var onClick = getCardClickHandler(eventHandlers, url);
@@ -103,10 +102,8 @@ export default function EmbedCard(props) {
103
102
  if (!isInsideOfBlockNode && rendererAppearance !== 'comment') {
104
103
  var isContainerSizeGreaterThanMaxFullPageWidth = containerWidth - padding >= akEditorDefaultLayoutWidth;
105
104
 
106
- if (isContainerSizeGreaterThanMaxFullPageWidth && allowDynamicTextSizing) {
107
- nonFullWidthSize = mapBreakpointToLayoutMaxWidth(breakpoint);
108
- } else if (isContainerSizeGreaterThanMaxFullPageWidth) {
109
- nonFullWidthSize = getAkEditorFullPageMaxWidth(allowDynamicTextSizing);
105
+ if (isContainerSizeGreaterThanMaxFullPageWidth) {
106
+ nonFullWidthSize = akEditorDefaultLayoutWidth;
110
107
  } else {
111
108
  nonFullWidthSize = containerWidth - padding;
112
109
  }
@@ -27,6 +27,7 @@ import LinkIcon from '@atlaskit/icon/glyph/link';
27
27
  import Tooltip from '@atlaskit/tooltip';
28
28
  import { injectIntl } from 'react-intl-next';
29
29
  import { headingAnchorLinkMessages } from '../../messages';
30
+ import { token } from '@atlaskit/tokens';
30
31
  export var HeadingAnchorWrapperClassName = 'heading-anchor-wrapper';
31
32
  var CopyAnchorWrapperWithRef = /*#__PURE__*/React.forwardRef(function (props, ref) {
32
33
  var children = props.children,
@@ -37,7 +38,7 @@ var CopyAnchorWrapperWithRef = /*#__PURE__*/React.forwardRef(function (props, re
37
38
  ref: ref
38
39
  }), children);
39
40
  });
40
- var copyAnchorButtonStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline;\n outline: none;\n background-color: transparent;\n border: none;\n color: ", ";\n cursor: pointer;\n right: 0;\n"])), N500);
41
+ var copyAnchorButtonStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline;\n outline: none;\n background-color: transparent;\n border: none;\n color: ", ";\n cursor: pointer;\n right: 0;\n"])), token('color.icon', N500));
41
42
 
42
43
  var HeadingAnchor = /*#__PURE__*/function (_React$PureComponent) {
43
44
  _inherits(HeadingAnchor, _React$PureComponent);
@@ -126,7 +127,7 @@ var HeadingAnchor = /*#__PURE__*/function (_React$PureComponent) {
126
127
  }, jsx(LinkIcon, {
127
128
  label: _this.getCopyAriaLabel(),
128
129
  size: _this.props.level > 3 ? 'small' : 'medium',
129
- primaryColor: _this.state.isClicked ? B400 : N200
130
+ primaryColor: _this.state.isClicked ? token('color.icon.selected', B400) : token('color.icon.subtle', N200)
130
131
  }));
131
132
  });
132
133
 
@@ -6,6 +6,7 @@ import { UnsupportedInline } from '@atlaskit/editor-common/ui';
6
6
  import { CardErrorBoundary } from './fallback';
7
7
  import { withSmartCardStorage } from '../../ui/SmartCardStorage';
8
8
  import { getCardClickHandler } from '../utils/getCardClickHandler';
9
+ import { useFeatureFlags } from '../../use-feature-flags';
9
10
 
10
11
  var InlineCard = function InlineCard(props) {
11
12
  var url = props.url,
@@ -20,6 +21,7 @@ var InlineCard = function InlineCard(props) {
20
21
  onClick: onClick,
21
22
  container: portal
22
23
  };
24
+ var featureFlags = useFeatureFlags();
23
25
 
24
26
  if (smartLinks !== null && smartLinks !== void 0 && smartLinks.ssr && url) {
25
27
  return /*#__PURE__*/React.createElement(CardSSR, {
@@ -35,7 +37,8 @@ var InlineCard = function InlineCard(props) {
35
37
  }, /*#__PURE__*/React.createElement(CardErrorBoundary, _extends({
36
38
  unsupportedComponent: UnsupportedInline
37
39
  }, cardProps), /*#__PURE__*/React.createElement(Card, _extends({
38
- appearance: "inline"
40
+ appearance: "inline",
41
+ showHoverPreview: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.showHoverPreview
39
42
  }, cardProps, {
40
43
  onResolve: function onResolve(data) {
41
44
  if (!data.url || !data.title) {
@@ -1,13 +1,17 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
2
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
5
  import React, { useEffect, useState } from 'react';
5
6
  import { MediaInlineCard } from '@atlaskit/media-card';
7
+ import { MediaInlineCardErroredView, MediaInlineCardLoadingView, messages } from '@atlaskit/media-ui';
6
8
  import { WithProviders } from '@atlaskit/editor-common/provider-factory';
9
+ import { getClipboardAttrs } from '../../ui/MediaCard';
10
+ import { createIntl, injectIntl } from 'react-intl-next';
7
11
  export var RenderMediaInline = function RenderMediaInline(props) {
8
12
  var mediaProvider = props.mediaProvider;
9
13
 
10
- var _useState = useState({}),
14
+ var _useState = useState(),
11
15
  _useState2 = _slicedToArray(_useState, 2),
12
16
  viewMediaClientConfigState = _useState2[0],
13
17
  setViewMediaClientConfigState = _useState2[1];
@@ -47,6 +51,18 @@ export var RenderMediaInline = function RenderMediaInline(props) {
47
51
  return _ref.apply(this, arguments);
48
52
  };
49
53
  }();
54
+ /*
55
+ * Only show the loading view if the media provider is not ready
56
+ * prevents calling the media API before the provider is ready
57
+ */
58
+
59
+
60
+ if (!viewMediaClientConfigState) {
61
+ return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
62
+ message: "",
63
+ isSelected: false
64
+ });
65
+ }
50
66
 
51
67
  return /*#__PURE__*/React.createElement(MediaInlineCard, {
52
68
  identifier: props.identifier,
@@ -58,17 +74,33 @@ export var RenderMediaInline = function RenderMediaInline(props) {
58
74
  var MediaInline = function MediaInline(props) {
59
75
  var collection = props.collection,
60
76
  id = props.id,
61
- providers = props.providers;
77
+ providers = props.providers,
78
+ intl = props.intl;
62
79
  var identifier = {
63
80
  id: id,
64
81
  mediaItemType: 'file',
65
82
  collectionName: collection
66
83
  };
67
- return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(WithProviders, {
84
+ var defaultIntl = createIntl({
85
+ locale: 'en'
86
+ });
87
+ return /*#__PURE__*/React.createElement("span", _extends({}, getClipboardAttrs({
88
+ id: id,
89
+ collection: collection
90
+ }), {
91
+ "data-node-type": "mediaInline"
92
+ }), /*#__PURE__*/React.createElement(WithProviders, {
68
93
  providers: ['mediaProvider'],
69
94
  providerFactory: providers,
70
95
  renderNode: function renderNode(providers) {
71
96
  var mediaProvider = providers.mediaProvider;
97
+
98
+ if (!mediaProvider) {
99
+ return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
100
+ message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file)
101
+ });
102
+ }
103
+
72
104
  return /*#__PURE__*/React.createElement(RenderMediaInline, {
73
105
  identifier: identifier,
74
106
  mediaProvider: mediaProvider
@@ -77,4 +109,4 @@ var MediaInline = function MediaInline(props) {
77
109
  }));
78
110
  };
79
111
 
80
- export default MediaInline;
112
+ export default injectIntl(MediaInline);
@@ -5,8 +5,8 @@ import { default as React, Fragment } from 'react';
5
5
  import { jsx } from '@emotion/react';
6
6
  import { injectIntl } from 'react-intl-next';
7
7
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
8
- import { mapBreakpointToLayoutMaxWidth, getBreakpoint, MediaSingle as UIMediaSingle, WidthConsumer } from '@atlaskit/editor-common/ui';
9
- import { akEditorFullWidthLayoutWidth, getAkEditorFullPageMaxWidth, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
8
+ import { MediaSingle as UIMediaSingle, WidthConsumer } from '@atlaskit/editor-common/ui';
9
+ import { akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
10
10
  import { FullPagePadding } from '../../../ui/Renderer/style';
11
11
  import { useObservedWidth } from '../../hooks/use-observed-width';
12
12
  import { uiMediaSingleBaseStyles, uiMediaSingleLayoutStyles } from './styles';
@@ -51,7 +51,6 @@ var MediaSingle = function MediaSingle(props) {
51
51
  var rendererAppearance = props.rendererAppearance,
52
52
  featureFlags = props.featureFlags,
53
53
  isInsideOfBlockNode = props.isInsideOfBlockNode,
54
- allowDynamicTextSizing = props.allowDynamicTextSizing,
55
54
  layout = props.layout,
56
55
  children = props.children,
57
56
  pctWidth = props.width;
@@ -129,7 +128,6 @@ var MediaSingle = function MediaSingle(props) {
129
128
 
130
129
  var calcDimensions = function calcDimensions(mediaContainerWidth, mediaBreakpoint) {
131
130
  var containerWidth = getMediaContainerWidth(mediaContainerWidth, layout);
132
- var breakpoint = mediaBreakpoint || getBreakpoint(containerWidth);
133
131
  var maxWidth = containerWidth;
134
132
  var maxHeight = height / width * maxWidth;
135
133
  var cardDimensions = {
@@ -139,12 +137,10 @@ var MediaSingle = function MediaSingle(props) {
139
137
  var nonFullWidthSize = containerWidth;
140
138
 
141
139
  if (!isInsideOfBlockNode && rendererAppearance !== 'comment') {
142
- var isContainerSizeGreaterThanMaxFullPageWidth = containerWidth - padding >= getAkEditorFullPageMaxWidth(allowDynamicTextSizing);
140
+ var isContainerSizeGreaterThanMaxFullPageWidth = containerWidth - padding >= akEditorDefaultLayoutWidth;
143
141
 
144
- if (isContainerSizeGreaterThanMaxFullPageWidth && allowDynamicTextSizing) {
145
- nonFullWidthSize = mapBreakpointToLayoutMaxWidth(breakpoint);
146
- } else if (isContainerSizeGreaterThanMaxFullPageWidth) {
147
- nonFullWidthSize = getAkEditorFullPageMaxWidth(allowDynamicTextSizing);
142
+ if (isContainerSizeGreaterThanMaxFullPageWidth) {
143
+ nonFullWidthSize = akEditorDefaultLayoutWidth;
148
144
  } else {
149
145
  nonFullWidthSize = containerWidth - padding;
150
146
  }
@@ -14,11 +14,7 @@ var getTableLayoutWidth = function getTableLayoutWidth(layout, opts) {
14
14
  return akEditorWideLayoutWidth;
15
15
 
16
16
  default:
17
- var _ref = opts || {},
18
- containerWidth = _ref.containerWidth,
19
- isDynamicTextSizingEnabled = _ref.isDynamicTextSizingEnabled;
20
-
21
- return calcLineLength(containerWidth, isDynamicTextSizingEnabled);
17
+ return calcLineLength();
22
18
  }
23
19
  };
24
20
 
@@ -44,10 +40,10 @@ var fixColumnWidth = function fixColumnWidth(columnWidth, _tableWidth, _layoutWi
44
40
  columnWidth - tableCellBorderWidth, zeroWidthColumnsCount ? akEditorTableLegacyCellMinWidth : tableCellMinWidth);
45
41
  };
46
42
 
47
- export var calcScalePercent = function calcScalePercent(_ref2) {
48
- var renderWidth = _ref2.renderWidth,
49
- tableWidth = _ref2.tableWidth,
50
- maxScale = _ref2.maxScale;
43
+ export var calcScalePercent = function calcScalePercent(_ref) {
44
+ var renderWidth = _ref.renderWidth,
45
+ tableWidth = _ref.tableWidth,
46
+ maxScale = _ref.maxScale;
51
47
  var diffPercent = 1 - renderWidth / tableWidth;
52
48
  return diffPercent < maxScale ? diffPercent : maxScale;
53
49
  };
@@ -55,8 +51,7 @@ export var Colgroup = function Colgroup(props) {
55
51
  var columnWidths = props.columnWidths,
56
52
  layout = props.layout,
57
53
  isNumberColumnEnabled = props.isNumberColumnEnabled,
58
- renderWidth = props.renderWidth,
59
- allowDynamicTextSizing = props.allowDynamicTextSizing;
54
+ renderWidth = props.renderWidth;
60
55
 
61
56
  if (!columnWidths || !isTableResized(columnWidths)) {
62
57
  return null;
@@ -64,7 +59,6 @@ export var Colgroup = function Colgroup(props) {
64
59
 
65
60
 
66
61
  var layoutWidth = getTableLayoutWidth(layout, {
67
- isDynamicTextSizingEnabled: allowDynamicTextSizing,
68
62
  containerWidth: renderWidth
69
63
  });
70
64
  var maxTableWidth = renderWidth < layoutWidth ? renderWidth : layoutWidth; // If table has a layout of default, it is confined by the defined column width.
@@ -1,45 +1,45 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _extends from "@babel/runtime/helpers/extends";
3
4
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
5
 
5
- var _templateObject, _templateObject2, _templateObject3;
6
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
6
7
 
7
8
  /** @jsx jsx */
8
9
  import React from 'react';
9
10
  import { css, jsx } from '@emotion/react';
10
11
  import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
11
12
  import { akEditorStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
12
- import * as colors from '@atlaskit/theme/colors';
13
+ import * as colors from '@atlaskit/theme/colors'; // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
14
+
13
15
  var N40A = colors.N40A;
16
+ import { token } from '@atlaskit/tokens';
14
17
  import { findHorizontalOverflowScrollParent } from '../../../utils';
15
18
  import { Table } from './table';
16
19
  import { recursivelyInjectProps } from '../../utils/inject-props';
17
20
  export var tableStickyPadding = 8;
18
- var fixedTableDivModeToPosition = {
19
- stick: 'fixed',
20
- 'pin-bottom': 'absolute'
21
- };
22
-
23
- var getModeSpecificStyles = function getModeSpecificStyles(mode) {
24
- if (mode === 'none') {
25
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: none;\n "])));
26
- } else {
27
- return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: ", ";\n "])), fixedTableDivModeToPosition[mode]);
28
- }
29
- };
21
+ var modeSpecficStyles = {
22
+ none: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: none;\n "]))),
23
+ stick: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: fixed;\n "]))),
24
+ 'pin-bottom': css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n "])))
25
+ }; // TODO: Quality ticket: https://product-fabric.atlassian.net/browse/DSP-4123
30
26
 
31
27
  var fixedTableDivStaticStyles = function fixedTableDivStaticStyles(top, width) {
32
- return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n top: ", "px;\n width: ", "px;\n z-index: ", ";\n &\n .", ",\n &\n .", "\n > table {\n margin-top: 0;\n margin-bottom: 0;\n }\n\n border-top: ", "px solid white;\n background: white;\n box-shadow: 0 6px 4px -4px ", ";\n\n div[data-expanded='false'] & {\n display: none;\n }\n\n &\n .", ".right-shadow::after,\n &\n .", ".left-shadow::before {\n top: 0px;\n height: 100%;\n }\n"])), top, width, akEditorStickyHeaderZIndex, TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_STICKY_WRAPPER, tableStickyPadding, N40A, TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_CONTAINER);
28
+ return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n width: ", "px;\n z-index: ", ";\n &\n .", ",\n &\n .", "\n > table {\n margin-top: 0;\n margin-bottom: 0;\n }\n\n border-top: ", "px solid\n ", ";\n background: ", ";\n box-shadow: ", ";\n\n div[data-expanded='false'] & {\n display: none;\n }\n\n &\n .", ".right-shadow::after,\n &\n .", ".left-shadow::before {\n top: 0px;\n height: 100%;\n }\n"])), typeof top === 'number' && "top: ".concat(top, "px;"), width, akEditorStickyHeaderZIndex, TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_STICKY_WRAPPER, tableStickyPadding, token('elevation.surface', 'white'), token('elevation.surface.overlay', 'white'), token('elevation.shadow.overflow', "0 6px 4px -4px ".concat(N40A)), TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_CONTAINER);
33
29
  };
34
30
 
35
31
  export var FixedTableDiv = function FixedTableDiv(props) {
36
32
  var top = props.top,
37
33
  wrapperWidth = props.wrapperWidth,
38
34
  mode = props.mode;
39
- var fixedTableCss = [fixedTableDivStaticStyles(top, wrapperWidth), getModeSpecificStyles(mode)];
40
- return jsx("div", {
35
+ var fixedTableCss = [fixedTableDivStaticStyles(top, wrapperWidth), modeSpecficStyles === null || modeSpecficStyles === void 0 ? void 0 : modeSpecficStyles[mode]];
36
+ var attrs = {
37
+ mode: mode
38
+ };
39
+ return jsx("div", _extends({}, attrs, {
40
+ "data-testid": "sticky-table-fixed",
41
41
  css: fixedTableCss
42
- }, props.children);
42
+ }), props.children);
43
43
  };
44
44
  export var StickyTable = function StickyTable(_ref) {
45
45
  var top = _ref.top,
@@ -54,7 +54,6 @@ export var StickyTable = function StickyTable(_ref) {
54
54
  children = _ref.children,
55
55
  columnWidths = _ref.columnWidths,
56
56
  renderWidth = _ref.renderWidth,
57
- allowDynamicTextSizing = _ref.allowDynamicTextSizing,
58
57
  rowHeight = _ref.rowHeight;
59
58
  return jsx("div", {
60
59
  css: {
@@ -67,7 +66,7 @@ export var StickyTable = function StickyTable(_ref) {
67
66
  mode: rowHeight > 300 ? 'none' : mode,
68
67
  wrapperWidth: wrapperWidth
69
68
  }, jsx("div", {
70
- className: "".concat(TableSharedCssClassName.TABLE_CONTAINER, " ").concat(shadowClassNames),
69
+ className: "".concat(TableSharedCssClassName.TABLE_CONTAINER, " ").concat(shadowClassNames || ''),
71
70
  "data-layout": layout,
72
71
  style: {
73
72
  width: tableWidth
@@ -82,8 +81,7 @@ export var StickyTable = function StickyTable(_ref) {
82
81
  columnWidths: columnWidths,
83
82
  layout: layout,
84
83
  isNumberColumnEnabled: isNumberColumnEnabled,
85
- renderWidth: renderWidth,
86
- allowDynamicTextSizing: allowDynamicTextSizing
84
+ renderWidth: renderWidth
87
85
  },
88
86
  /**
89
87
  * @see https://product-fabric.atlassian.net/browse/ED-10235
@@ -6,7 +6,6 @@ export var Table = /*#__PURE__*/React.memo(function (_ref) {
6
6
  columnWidths = _ref.columnWidths,
7
7
  layout = _ref.layout,
8
8
  renderWidth = _ref.renderWidth,
9
- allowDynamicTextSizing = _ref.allowDynamicTextSizing,
10
9
  children = _ref.children;
11
10
  return /*#__PURE__*/React.createElement("table", {
12
11
  "data-number-column": isNumberColumnEnabled,
@@ -15,7 +14,6 @@ export var Table = /*#__PURE__*/React.memo(function (_ref) {
15
14
  columnWidths: columnWidths,
16
15
  layout: layout,
17
16
  isNumberColumnEnabled: isNumberColumnEnabled,
18
- renderWidth: renderWidth,
19
- allowDynamicTextSizing: allowDynamicTextSizing
17
+ renderWidth: renderWidth
20
18
  }), /*#__PURE__*/React.createElement("tbody", null, children));
21
19
  });
@@ -293,13 +293,12 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
293
293
  isNumberColumnEnabled = _this$props.isNumberColumnEnabled,
294
294
  layout = _this$props.layout,
295
295
  renderWidth = _this$props.renderWidth,
296
- allowDynamicTextSizing = _this$props.allowDynamicTextSizing,
297
296
  columnWidths = _this$props.columnWidths,
298
297
  stickyHeaders = _this$props.stickyHeaders,
299
298
  tableNode = _this$props.tableNode;
300
299
  var stickyMode = this.state.stickyMode;
301
300
  var tableWidth = calcTableWidth(layout, renderWidth, false);
302
- var lineLength = calcLineLength(renderWidth, allowDynamicTextSizing);
301
+ var lineLength = calcLineLength();
303
302
  var left;
304
303
 
305
304
  if (canUseLinelength(this.props.rendererAppearance) && tableWidth !== 'inherit') {
@@ -322,10 +321,9 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
322
321
  innerRef: this.stickyWrapperRef,
323
322
  wrapperWidth: wrapperWidth,
324
323
  columnWidths: columnWidths,
325
- rowHeight: this.headerRowHeight,
326
- allowDynamicTextSizing: allowDynamicTextSizing
324
+ rowHeight: this.headerRowHeight
327
325
  }, [children && children[0]]), /*#__PURE__*/React.createElement("div", {
328
- className: "".concat(TableSharedCssClassName.TABLE_CONTAINER, " ").concat(this.props.shadowClassNames),
326
+ className: "".concat(TableSharedCssClassName.TABLE_CONTAINER, " ").concat(this.props.shadowClassNames || ''),
329
327
  "data-layout": layout,
330
328
  ref: this.props.handleRef,
331
329
  style: {
@@ -341,8 +339,7 @@ export var TableContainer = /*#__PURE__*/function (_React$Component) {
341
339
  columnWidths: columnWidths,
342
340
  layout: layout,
343
341
  isNumberColumnEnabled: isNumberColumnEnabled,
344
- renderWidth: renderWidth,
345
- allowDynamicTextSizing: allowDynamicTextSizing
342
+ renderWidth: renderWidth
346
343
  }, this.grabFirstRowRef(children)))));
347
344
  }
348
345
  }]);
@@ -425,14 +422,28 @@ export var TableProcessor = /*#__PURE__*/function (_React$Component2) {
425
422
  return TableProcessor;
426
423
  }(React.Component);
427
424
  var TableWithShadows = overflowShadow(TableProcessor, {
428
- overflowSelector: ".".concat(TableSharedCssClassName.TABLE_NODE_WRAPPER)
425
+ overflowSelector: ".".concat(TableSharedCssClassName.TABLE_NODE_WRAPPER),
426
+ useShadowObserver: true
429
427
  });
430
428
 
431
429
  var TableWithWidth = function TableWithWidth(props) {
432
430
  return /*#__PURE__*/React.createElement(WidthConsumer, null, function (_ref2) {
431
+ var _props$columnWidths;
432
+
433
433
  var width = _ref2.width;
434
434
  var renderWidth = props.rendererAppearance === 'full-page' ? width - FullPagePadding * 2 : width;
435
- return /*#__PURE__*/React.createElement(TableWithShadows, _extends({
435
+ var colWidthsSum = ((_props$columnWidths = props.columnWidths) === null || _props$columnWidths === void 0 ? void 0 : _props$columnWidths.reduce(function (total, val) {
436
+ return total + val;
437
+ }, 0)) || 0;
438
+
439
+ if (colWidthsSum) {
440
+ return /*#__PURE__*/React.createElement(TableWithShadows, _extends({
441
+ renderWidth: renderWidth
442
+ }, props));
443
+ } // there should not be a case when colWidthsSum is 0 and table is in overflow state - so no need to render shadows in this case
444
+
445
+
446
+ return /*#__PURE__*/React.createElement(TableProcessor, _extends({
436
447
  renderWidth: renderWidth
437
448
  }, props));
438
449
  });
@@ -146,8 +146,10 @@ export var withSortableColumn = function withSortableColumn(WrapperComponent) {
146
146
 
147
147
  _defineProperty(_assertThisInitialized(_this), "onKeyPress", function (event) {
148
148
  var keys = [' ', 'Enter', 'Spacebar'];
149
+ var _ref = event.target,
150
+ tagName = _ref.tagName; // trigger sorting if space or enter are clicked but not when in an input field (template variables)
149
151
 
150
- if (keys.includes(event.key)) {
152
+ if (keys.includes(event.key) && !IgnoreSorting.includes(tagName)) {
151
153
  event.preventDefault();
152
154
 
153
155
  _this.onClick(event);
@@ -156,8 +158,8 @@ export var withSortableColumn = function withSortableColumn(WrapperComponent) {
156
158
 
157
159
  _defineProperty(_assertThisInitialized(_this), "onClick", function (event) {
158
160
  // ignore sorting when specific elements are clicked
159
- var _ref = event.target,
160
- tagName = _ref.tagName;
161
+ var _ref2 = event.target,
162
+ tagName = _ref2.tagName;
161
163
 
162
164
  if (IgnoreSorting.includes(tagName)) {
163
165
  return;