@atlaskit/editor-common 65.0.0 → 66.0.2

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 (102) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/build/tsconfig.json +1 -2
  3. package/dist/cjs/i18n/en.js +27 -0
  4. package/dist/cjs/i18n/en_GB.js +27 -0
  5. package/dist/cjs/normalize-feature-flags.js +40 -4
  6. package/dist/cjs/panel.js +55 -0
  7. package/dist/cjs/styles/index.js +0 -44
  8. package/dist/cjs/styles/shared/link.js +2 -2
  9. package/dist/cjs/styles/shared/lists.js +1 -1
  10. package/dist/cjs/styles/shared/panel.js +15 -6
  11. package/dist/cjs/styles/shared/rule.js +5 -2
  12. package/dist/cjs/styles/shared/table.js +1 -1
  13. package/dist/cjs/ui/BaseTheme/index.js +1 -5
  14. package/dist/cjs/ui/Expand/index.js +84 -46
  15. package/dist/cjs/ui/{IntlNextErrorBoundary → IntlErrorBoundary}/index.js +9 -9
  16. package/dist/cjs/ui/MediaSingle/index.js +13 -8
  17. package/dist/cjs/ui/MediaSingle/styled.js +23 -20
  18. package/dist/cjs/ui/Popup/index.js +15 -1
  19. package/dist/cjs/ui/UnsupportedBlock/index.js +1 -1
  20. package/dist/cjs/ui/index.js +12 -22
  21. package/dist/cjs/utils/compare-props.js +136 -0
  22. package/dist/cjs/utils/index.js +23 -1
  23. package/dist/cjs/utils/performance/hooks/use-component-render-tracking/index.js +47 -0
  24. package/dist/cjs/utils/validator.js +7 -5
  25. package/dist/cjs/version.json +1 -1
  26. package/dist/es2019/i18n/en.js +19 -0
  27. package/dist/es2019/i18n/en_GB.js +19 -0
  28. package/dist/es2019/normalize-feature-flags.js +40 -4
  29. package/dist/es2019/panel.js +1 -0
  30. package/dist/es2019/styles/index.js +0 -1
  31. package/dist/es2019/styles/shared/link.js +1 -1
  32. package/dist/es2019/styles/shared/lists.js +2 -0
  33. package/dist/es2019/styles/shared/panel.js +79 -76
  34. package/dist/es2019/styles/shared/rule.js +3 -3
  35. package/dist/es2019/styles/shared/table.js +9 -1
  36. package/dist/es2019/ui/BaseTheme/index.js +1 -4
  37. package/dist/es2019/ui/Expand/index.js +97 -67
  38. package/dist/es2019/ui/{IntlNextErrorBoundary → IntlErrorBoundary}/index.js +1 -1
  39. package/dist/es2019/ui/MediaSingle/index.js +13 -9
  40. package/dist/es2019/ui/MediaSingle/styled.js +13 -12
  41. package/dist/es2019/ui/Popup/index.js +16 -1
  42. package/dist/es2019/ui/UnsupportedBlock/index.js +0 -1
  43. package/dist/es2019/ui/index.js +2 -4
  44. package/dist/es2019/utils/compare-props.js +99 -0
  45. package/dist/es2019/utils/index.js +3 -1
  46. package/dist/es2019/utils/performance/hooks/use-component-render-tracking/index.js +36 -0
  47. package/dist/es2019/utils/validator.js +3 -2
  48. package/dist/es2019/version.json +1 -1
  49. package/dist/esm/i18n/en.js +19 -0
  50. package/dist/esm/i18n/en_GB.js +19 -0
  51. package/dist/esm/normalize-feature-flags.js +39 -4
  52. package/dist/esm/panel.js +1 -0
  53. package/dist/esm/styles/index.js +0 -1
  54. package/dist/esm/styles/shared/link.js +1 -1
  55. package/dist/esm/styles/shared/lists.js +1 -1
  56. package/dist/esm/styles/shared/panel.js +10 -5
  57. package/dist/esm/styles/shared/rule.js +4 -2
  58. package/dist/esm/styles/shared/table.js +1 -1
  59. package/dist/esm/ui/BaseTheme/index.js +1 -4
  60. package/dist/esm/ui/Expand/index.js +79 -42
  61. package/dist/esm/ui/{IntlNextErrorBoundary → IntlErrorBoundary}/index.js +7 -7
  62. package/dist/esm/ui/MediaSingle/index.js +14 -9
  63. package/dist/esm/ui/MediaSingle/styled.js +17 -10
  64. package/dist/esm/ui/Popup/index.js +16 -1
  65. package/dist/esm/ui/UnsupportedBlock/index.js +1 -1
  66. package/dist/esm/ui/index.js +2 -4
  67. package/dist/esm/utils/compare-props.js +115 -0
  68. package/dist/esm/utils/index.js +3 -1
  69. package/dist/esm/utils/performance/hooks/use-component-render-tracking/index.js +37 -0
  70. package/dist/esm/utils/validator.js +3 -2
  71. package/dist/esm/version.json +1 -1
  72. package/dist/types/extensions/types/field-definitions.d.ts +1 -1
  73. package/dist/types/i18n/en.d.ts +19 -0
  74. package/dist/types/i18n/en_GB.d.ts +19 -0
  75. package/dist/types/normalize-feature-flags.d.ts +6 -3
  76. package/dist/types/panel.d.ts +1 -0
  77. package/dist/types/provider-factory/media-provider.d.ts +2 -2
  78. package/dist/types/provider-factory/types.d.ts +1 -1
  79. package/dist/types/styles/index.d.ts +0 -1
  80. package/dist/types/styles/shared/link.d.ts +1 -1
  81. package/dist/types/styles/shared/panel.d.ts +2 -1
  82. package/dist/types/styles/shared/rule.d.ts +2 -1
  83. package/dist/types/ui/EventHandlers/index.d.ts +2 -2
  84. package/dist/types/ui/Expand/index.d.ts +12 -10
  85. package/dist/types/ui/{IntlNextErrorBoundary → IntlErrorBoundary}/index.d.ts +1 -1
  86. package/dist/types/ui/MediaSingle/index.d.ts +4 -2
  87. package/dist/types/ui/MediaSingle/styled.d.ts +10 -5
  88. package/dist/types/ui/Popup/index.d.ts +3 -0
  89. package/dist/types/ui/index.d.ts +2 -4
  90. package/dist/types/utils/compare-props.d.ts +32 -0
  91. package/dist/types/utils/index.d.ts +4 -0
  92. package/dist/types/utils/performance/hooks/use-component-render-tracking/index.d.ts +19 -0
  93. package/package.json +18 -19
  94. package/panel/package.json +7 -0
  95. package/dist/cjs/ui/IntlLegacyFallbackProvider/index.js +0 -60
  96. package/dist/cjs/ui/LegacyToNextIntlProvider/index.js +0 -67
  97. package/dist/es2019/ui/IntlLegacyFallbackProvider/index.js +0 -21
  98. package/dist/es2019/ui/LegacyToNextIntlProvider/index.js +0 -24
  99. package/dist/esm/ui/IntlLegacyFallbackProvider/index.js +0 -45
  100. package/dist/esm/ui/LegacyToNextIntlProvider/index.js +0 -51
  101. package/dist/types/ui/IntlLegacyFallbackProvider/index.d.ts +0 -8
  102. package/dist/types/ui/LegacyToNextIntlProvider/index.d.ts +0 -8
@@ -1,5 +1,9 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+
3
+ /** @jsx jsx */
4
+ import React, { forwardRef } from 'react';
5
+ import { css, jsx } from '@emotion/react';
1
6
  import { defineMessages } from 'react-intl-next';
2
- import styled, { css } from 'styled-components';
3
7
  import { akEditorLineHeight, akEditorSwoopCubicBezier, akLayoutGutterOffset, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
4
8
  import * as colors from '@atlaskit/theme/colors';
5
9
  import { themed } from '@atlaskit/theme/components';
@@ -38,13 +42,22 @@ const EXPAND_EXPANDED_BORDER_COLOR = themed({
38
42
  light: colors.N40A,
39
43
  dark: colors.DN50
40
44
  });
41
- export const ExpandIconWrapper = styled.div`
45
+ export const ExpandIconWrapper = ({
46
+ children,
47
+ expanded
48
+ }) => {
49
+ return jsx("div", {
50
+ css: props => expanded ? [expandIconWrapperStyle(props), expandIconWrapperExpandedStyle] : expandIconWrapperStyle(props)
51
+ }, children);
52
+ };
53
+
54
+ const expandIconWrapperStyle = props => css`
42
55
  cursor: pointer;
43
56
  display: flex;
44
57
  color: ${themed({
45
58
  light: colors.N90,
46
59
  dark: '#d9dde3'
47
- })};
60
+ })(props)};
48
61
  border-radius: ${gridSize() / 2}px;
49
62
  width: 24px;
50
63
  height: 24px;
@@ -54,69 +67,85 @@ export const ExpandIconWrapper = styled.div`
54
67
  }
55
68
 
56
69
  svg {
57
- ${props => props.expanded ? 'transform: rotate(90deg);' : ''}
58
70
  transition: transform 0.2s ${akEditorSwoopCubicBezier};
59
71
  }
60
72
  `;
61
- export const ExpandLayoutWrapper = styled.div`
73
+
74
+ const expandIconWrapperExpandedStyle = css`
75
+ svg {
76
+ transform: rotate(90deg);
77
+ }
78
+ `;
79
+ export const expandLayoutWrapperStyle = css`
62
80
  width: ${gridSize() * 3}px;
63
81
  height: ${gridSize() * 3}px;
64
82
  `;
65
- const ContainerStyles = css`
66
- border-width: 1px;
67
- border-style: solid;
68
- border-color: ${({
69
- expanded,
70
- focused
71
- }) => {
72
- const expandedBorderColor = expanded ? EXPAND_EXPANDED_BORDER_COLOR : EXPAND_COLLAPSED_BORDER_COLOR;
73
- return focused ? EXPAND_FOCUSED_BORDER_COLOR : expandedBorderColor;
74
- }};
75
- border-radius: ${BORDER_RADIUS}px;
76
- min-height: 25px;
77
- background: ${({
78
- expanded
79
- }) => !expanded ? EXPAND_COLLAPSED_BACKGROUND : EXPAND_SELECTED_BACKGROUND};
80
- margin: ${props => `${gridSize() / 2 / fontSize()}rem ${// Only only these margins if the expand isn't editable
81
- // and is the root level expand.
82
- props['data-node-type'] === 'expand' ? `-${akLayoutGutterOffset}px` : `0`} 0`};
83
+ export const ExpandLayoutWrapperWithRef = /*#__PURE__*/forwardRef((props, ref) => {
84
+ const {
85
+ children,
86
+ ...rest
87
+ } = props;
88
+ return jsx("div", _extends({
89
+ css: expandLayoutWrapperStyle
90
+ }, rest, {
91
+ ref: ref
92
+ }), children);
93
+ });
83
94
 
84
- transition: background 0.3s ${akEditorSwoopCubicBezier},
85
- border-color 0.3s ${akEditorSwoopCubicBezier};
86
- padding: ${gridSize}px;
95
+ const containerStyles = styleProps => {
96
+ const {
97
+ expanded,
98
+ focused
99
+ } = styleProps;
100
+ const marginTop = `${gridSize() / 2 / fontSize()}rem`;
101
+ const marginBottom = 0; // Only only these margins if the expand isn't editable
102
+ // and is the root level expand.
87
103
 
88
- &:hover {
89
- border: 1px solid ${themed({
90
- light: colors.N50A,
91
- dark: colors.DN50
92
- })};
93
- background: ${EXPAND_SELECTED_BACKGROUND};
94
- }
104
+ const marginHorizontal = styleProps['data-node-type'] === 'expand' ? `-${akLayoutGutterOffset}px` : 0;
105
+ const margin = `${marginTop} ${marginHorizontal} ${marginBottom}`;
106
+ return themeProps => css`
107
+ border-width: 1px;
108
+ border-style: solid;
109
+ border-color: ${focused ? EXPAND_FOCUSED_BORDER_COLOR : expanded ? EXPAND_EXPANDED_BORDER_COLOR(themeProps) : EXPAND_COLLAPSED_BORDER_COLOR};
110
+ border-radius: ${BORDER_RADIUS}px;
111
+ min-height: 25px;
112
+ background: ${!expanded ? EXPAND_COLLAPSED_BACKGROUND : EXPAND_SELECTED_BACKGROUND(themeProps)};
113
+ margin: ${margin};
114
+
115
+ transition: background 0.3s ${akEditorSwoopCubicBezier},
116
+ border-color 0.3s ${akEditorSwoopCubicBezier};
117
+ padding: ${gridSize()}px;
118
+
119
+ &:hover {
120
+ border: 1px solid
121
+ ${themed({
122
+ light: colors.N50A,
123
+ dark: colors.DN50
124
+ })(themeProps)};
125
+ background: ${EXPAND_SELECTED_BACKGROUND(themeProps)};
126
+ }
95
127
 
96
- td > &:first-child {
97
- margin-top: 0;
128
+ td > &:first-child {
129
+ margin-top: 0;
130
+ }
131
+ `;
132
+ };
133
+
134
+ const contentStyles = styleProps => themeProps => css`
135
+ padding-top: ${styleProps.expanded ? gridSize() : 0}px;
136
+ padding-right: ${gridSize()}px;
137
+ padding-left: ${gridSize() * 4 - gridSize() / 2}px;
138
+ display: flow-root;
139
+
140
+ // The follow rules inside @supports block are added as a part of ED-8893
141
+ // The fix is targeting mobile bridge on iOS 12 or below,
142
+ // We should consider remove this fix when we no longer support iOS 12
143
+ @supports not (display: flow-root) {
144
+ width: 100%;
145
+ box-sizing: border-box;
98
146
  }
99
- `;
100
- const ContentStyles = css`
101
- ${({
102
- expanded
103
- }) => {
104
- return css`
105
- padding-top: ${expanded ? gridSize() : 0}px;
106
- padding-right: ${gridSize()}px;
107
- padding-left: ${gridSize() * 4 - gridSize() / 2}px;
108
- display: table;
109
- display: flow-root;
110
-
111
- // The follow rules inside @supports block are added as a part of ED-8893
112
- // The fix is targeting mobile bridge on iOS 12 or below,
113
- // We should consider remove this fix when we no longer support iOS 12
114
- @supports not (display: flow-root) {
115
- width: 100%;
116
- box-sizing: border-box;
117
- }
118
-
119
- ${!expanded ? `
147
+
148
+ ${!styleProps.expanded ? `
120
149
  .expand-content-wrapper, .nestedExpand-content-wrapper {
121
150
  /* We visually hide the content here to preserve the content during copy+paste */
122
151
  width: 100%;
@@ -128,10 +157,9 @@ const ContentStyles = css`
128
157
  user-select: none;
129
158
  }
130
159
  ` : ''}
131
- `;
132
- }};
133
160
  `;
134
- const TitleInputStyles = css`
161
+
162
+ const titleInputStyles = props => css`
135
163
  outline: none;
136
164
  border: none;
137
165
  font-size: ${relativeFontSizeToBase16(fontSize())};
@@ -140,7 +168,7 @@ const TitleInputStyles = css`
140
168
  color: ${themed({
141
169
  light: colors.N200A,
142
170
  dark: colors.DN600
143
- })};
171
+ })(props)};
144
172
  background: transparent;
145
173
  display: flex;
146
174
  flex: 1;
@@ -152,10 +180,11 @@ const TitleInputStyles = css`
152
180
  color: ${themed({
153
181
  light: colors.N200A,
154
182
  dark: colors.DN600
155
- })};
183
+ })(props)};
156
184
  }
157
185
  `;
158
- const TitleContainerStyles = css`
186
+
187
+ const titleContainerStyles = props => css`
159
188
  padding: 0;
160
189
  display: flex;
161
190
  align-items: flex-start;
@@ -166,7 +195,7 @@ const TitleContainerStyles = css`
166
195
  color: ${themed({
167
196
  light: colors.N300A,
168
197
  dark: colors.DN600
169
- })};
198
+ })(props)};
170
199
  overflow: hidden;
171
200
  cursor: pointer;
172
201
  // Prevent browser selection being inside the title container
@@ -176,9 +205,10 @@ const TitleContainerStyles = css`
176
205
  outline: 0;
177
206
  }
178
207
  `;
208
+
179
209
  export const sharedExpandStyles = {
180
- TitleInputStyles,
181
- TitleContainerStyles,
182
- ContainerStyles,
183
- ContentStyles
210
+ titleInputStyles,
211
+ titleContainerStyles,
212
+ containerStyles,
213
+ contentStyles
184
214
  };
@@ -9,7 +9,7 @@ const isMissingIntlProviderInAncestryError = err => {
9
9
  return err === null || err === void 0 ? void 0 : (_err$toString = err.toString()) === null || _err$toString === void 0 ? void 0 : _err$toString.includes('<IntlProvider> needs to exist in the component ancestry');
10
10
  };
11
11
 
12
- export class IntlNextErrorBoundary extends React.Component {
12
+ export class IntlErrorBoundary extends React.Component {
13
13
  constructor(...args) {
14
14
  super(...args);
15
15
 
@@ -1,8 +1,10 @@
1
+ /** @jsx jsx */
1
2
  import React from 'react';
3
+ import { jsx } from '@emotion/react';
2
4
  import classnames from 'classnames';
3
5
  import { akEditorMediaResizeHandlerPaddingWide, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
4
6
  import { calcPxFromPct } from './grid';
5
- import { MediaSingleWrapper, MediaWrapper } from './styled';
7
+ import { MediaSingleDimensionHelper, MediaWrapper } from './styled';
6
8
  export const DEFAULT_IMAGE_WIDTH = 250;
7
9
  export const DEFAULT_IMAGE_HEIGHT = 200;
8
10
  export const wrappedLayouts = ['wrap-left', 'wrap-right', 'align-end', 'align-start'];
@@ -74,13 +76,15 @@ export default function MediaSingle({
74
76
  }
75
77
 
76
78
  const [media, caption] = children;
77
- return /*#__PURE__*/React.createElement(MediaSingleWrapper, {
78
- innerRef: handleMediaSingleRef,
79
- width: width,
80
- layout: layout,
81
- containerWidth: containerWidth,
82
- pctWidth: pctWidth,
83
- fullWidthMode: fullWidthMode,
79
+ return jsx("div", {
80
+ ref: handleMediaSingleRef,
81
+ css: MediaSingleDimensionHelper({
82
+ width,
83
+ layout,
84
+ containerWidth,
85
+ pctWidth,
86
+ fullWidthMode
87
+ }),
84
88
  "data-layout": layout,
85
89
  "data-width": pctWidth,
86
90
  "data-node-type": nodeType,
@@ -88,7 +92,7 @@ export default function MediaSingle({
88
92
  'is-loading': isLoading,
89
93
  'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
90
94
  })
91
- }, /*#__PURE__*/React.createElement(MediaWrapper, {
95
+ }, jsx(MediaWrapper, {
92
96
  hasFallbackContainer: hasFallbackContainer,
93
97
  height: mediaWrapperHeight,
94
98
  paddingBottom: paddingBottom
@@ -1,4 +1,6 @@
1
- import styled, { css } from 'styled-components';
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { css, jsx } from '@emotion/react';
2
4
  import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
3
5
  import { calcBreakoutWidth, calcWideWidth } from '../../utils/breakout';
4
6
 
@@ -156,24 +158,20 @@ const RenderFallbackContainer = ({
156
158
  ` : ''}
157
159
  `;
158
160
 
159
- export const MediaWrapper = styled.div`
161
+ export const mediaWrapperStyle = props => css`
160
162
  position: relative;
161
163
 
162
- ${RenderFallbackContainer}
164
+ ${RenderFallbackContainer(props)}
163
165
 
164
166
  /* Editor */
165
167
  & > figure {
166
- position: ${({
167
- hasFallbackContainer
168
- }) => hasFallbackContainer ? 'absolute' : 'relative'};
168
+ position: ${props.hasFallbackContainer ? 'absolute' : 'relative'};
169
169
  height: 100%;
170
170
  width: 100%;
171
171
  }
172
172
 
173
173
  & > div {
174
- position: ${({
175
- hasFallbackContainer
176
- }) => hasFallbackContainer ? 'absolute' : 'relative'};
174
+ position: ${props.hasFallbackContainer ? 'absolute' : 'relative'};
177
175
  height: 100%;
178
176
  width: 100%;
179
177
  }
@@ -192,7 +190,10 @@ export const MediaWrapper = styled.div`
192
190
  }
193
191
  }
194
192
  `;
195
- export const MediaSingleWrapper = styled.div`
196
- ${MediaSingleDimensionHelper};
197
- `;
193
+ export const MediaWrapper = ({
194
+ children,
195
+ ...rest
196
+ }) => jsx("div", {
197
+ css: mediaWrapperStyle(rest)
198
+ }, children);
198
199
  MediaWrapper.displayName = 'WrapperMediaSingle';
@@ -6,6 +6,8 @@ import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
6
6
  import { calculatePlacement, calculatePosition, findOverflowScrollParent, validatePosition } from './utils';
7
7
  export default class Popup extends React.Component {
8
8
  constructor(...args) {
9
+ var _window;
10
+
9
11
  super(...args);
10
12
 
11
13
  _defineProperty(this, "state", {
@@ -25,6 +27,10 @@ export default class Popup extends React.Component {
25
27
  _defineProperty(this, "scheduledUpdatePosition", rafSchedule(props => this.updatePosition(props)));
26
28
 
27
29
  _defineProperty(this, "onResize", () => this.scheduledUpdatePosition(this.props));
30
+
31
+ _defineProperty(this, "resizeObserver", (_window = window) !== null && _window !== void 0 && _window.ResizeObserver ? new ResizeObserver(() => {
32
+ this.scheduledUpdatePosition(this.props);
33
+ }) : undefined);
28
34
  }
29
35
 
30
36
  /**
@@ -147,9 +153,14 @@ export default class Popup extends React.Component {
147
153
  const {
148
154
  stick
149
155
  } = this.props;
156
+ this.scrollParentElement = findOverflowScrollParent(this.props.target);
157
+
158
+ if (this.scrollParentElement && this.resizeObserver) {
159
+ this.resizeObserver.observe(this.scrollParentElement);
160
+ }
150
161
 
151
162
  if (stick) {
152
- this.scrollElement = findOverflowScrollParent(this.props.target);
163
+ this.scrollElement = this.scrollParentElement;
153
164
  } else {
154
165
  this.scrollElement = this.props.scrollableElement;
155
166
  }
@@ -166,6 +177,10 @@ export default class Popup extends React.Component {
166
177
  this.scrollElement.removeEventListener('scroll', this.onResize);
167
178
  }
168
179
 
180
+ if (this.scrollParentElement && this.resizeObserver) {
181
+ this.resizeObserver.unobserve(this.scrollParentElement);
182
+ }
183
+
169
184
  this.scheduledUpdatePosition.cancel();
170
185
  }
171
186
 
@@ -12,7 +12,6 @@ import { ACTION_SUBJECT_ID } from '../../utils/analytics';
12
12
  import { trackUnsupportedContentTooltipDisplayedFor } from '../../utils/track-unsupported-content';
13
13
  import { getUnsupportedContent } from '../unsupported-content-helper';
14
14
  const blockNodeStyle = css`
15
- align-items: center;
16
15
  background: ${N30};
17
16
  border: 1px dashed ${N50};
18
17
  border-radius: ${borderRadius()}px;
@@ -11,9 +11,7 @@ export { default as withOuterListeners } from './with-outer-listeners';
11
11
  export { WidthConsumer, WidthProvider, getBreakpoint } from './WidthProvider';
12
12
  export { default as overflowShadow, shadowClassNames } from './OverflowShadow';
13
13
  export { WithCreateAnalyticsEvent } from './WithCreateAnalyticsEvent';
14
- export { messages as expandMessages, sharedExpandStyles, ExpandIconWrapper, ExpandLayoutWrapper } from './Expand';
14
+ export { messages as expandMessages, sharedExpandStyles, ExpandIconWrapper, expandLayoutWrapperStyle, ExpandLayoutWrapperWithRef } from './Expand';
15
15
  export { ErrorMessage, HelperMessage, ValidMessage } from './Messages';
16
16
  export { clearNextSiblingMarginTopStyle } from './clear-next-sibling-margin-top';
17
- export { IntlNextErrorBoundary, REACT_INTL_ERROR_MESSAGE } from './IntlNextErrorBoundary';
18
- export { IntlLegacyFallbackProvider } from './IntlLegacyFallbackProvider';
19
- export { LegacyToNextIntlProvider } from './LegacyToNextIntlProvider';
17
+ export { IntlErrorBoundary, REACT_INTL_ERROR_MESSAGE } from './IntlErrorBoundary';
@@ -0,0 +1,99 @@
1
+ import React from 'react';
2
+ export const getKeys = Object.keys;
3
+ export const getKeysAddedRemovedCommon = (object1, object2) => {
4
+ const oldKeys = object1 !== null ? getKeys(object1) : [];
5
+ const newKeys = object2 !== null ? getKeys(object2) : [];
6
+ const removed = oldKeys.filter(key => !newKeys.includes(key));
7
+ const added = newKeys.filter(key => !oldKeys.includes(key));
8
+ const common = oldKeys.filter(key => newKeys.includes(key));
9
+ return {
10
+ added,
11
+ common,
12
+ removed
13
+ };
14
+ };
15
+ export const serializeValue = value => {
16
+ const valueType = typeof value;
17
+
18
+ if (value === null) {
19
+ return 'null';
20
+ } else if (value === undefined) {
21
+ return 'undefined';
22
+ } else if (valueType === 'string' || valueType === 'number') {
23
+ return value;
24
+ } else if (valueType === 'symbol') {
25
+ return value.toString();
26
+ } // Calling toString of function returns whole function text with body.
27
+ // So, just return function with name.
28
+ else if (valueType === 'function') {
29
+ return `function:${value.name}`;
30
+ } else if (valueType === 'object') {
31
+ return {
32
+ type: 'object',
33
+ keys: Object.keys(value)
34
+ };
35
+ }
36
+ };
37
+ export const getPropsDifference = (object1, object2, curDepth = 0, maxDepth = 2, keysToIgnore = []) => {
38
+ const {
39
+ added,
40
+ common,
41
+ removed
42
+ } = getKeysAddedRemovedCommon(object1, object2);
43
+ const changed = [];
44
+ common.forEach(key => {
45
+ const value1 = object1[key];
46
+ const value2 = object2[key];
47
+ const value1Type = typeof value1;
48
+ const value2Type = typeof value2; // Do comparision only if values doesn't match (or reference to same object in memory).
49
+ // Or if key does not exist in keys to ignore.
50
+
51
+ if (value1 !== value2 && keysToIgnore.indexOf(key) === -1) {
52
+ // if both key value are objects and not referencing same object in memory.
53
+ // then get recursive difference.
54
+ if ( /*#__PURE__*/React.isValidElement(value1) || /*#__PURE__*/React.isValidElement(value2)) {
55
+ changed.push({
56
+ key,
57
+ reactElementChanged: true
58
+ });
59
+ } else if (value1Type === 'object' && value2Type === 'object') {
60
+ if (curDepth <= maxDepth) {
61
+ const difference = getPropsDifference(value1, value2, curDepth + 1, maxDepth);
62
+ changed.push({
63
+ key,
64
+ difference
65
+ });
66
+ } else {
67
+ changed.push({
68
+ key,
69
+ maxDepthReached: true
70
+ });
71
+ }
72
+ } else {
73
+ changed.push({
74
+ key,
75
+ oldValue: serializeValue(value1),
76
+ newValue: serializeValue(value2)
77
+ });
78
+ }
79
+ }
80
+ });
81
+ return {
82
+ added,
83
+ changed,
84
+ removed
85
+ };
86
+ };
87
+ export const getShallowPropsDifference = (object1, object2) => {
88
+ const {
89
+ added,
90
+ common,
91
+ removed
92
+ } = getKeysAddedRemovedCommon(object1, object2);
93
+ const changed = common.filter(key => object1[key] !== object2[key]);
94
+ return {
95
+ added,
96
+ changed,
97
+ removed
98
+ };
99
+ };
@@ -23,4 +23,6 @@ export { shouldForceTracking } from './should-force-tracking';
23
23
  export { getModeFromTheme } from './getModeFromTheme';
24
24
  export { sniffUserBrowserExtensions } from './browser-extensions';
25
25
  export { RenderCountProfiler } from './profiler/render-count';
26
- export { validateADFEntity, validationErrorHandler } from './validate-using-spec';
26
+ export { validateADFEntity, validationErrorHandler } from './validate-using-spec';
27
+ export { getShallowPropsDifference, getPropsDifference } from './compare-props';
28
+ export { useComponentRenderTracking } from './performance/hooks/use-component-render-tracking';
@@ -0,0 +1,36 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { uuid } from '@atlaskit/adf-schema';
3
+ import { getPropsDifference, getShallowPropsDifference } from '../../../compare-props';
4
+ export function useComponentRenderTracking({
5
+ onRender,
6
+ propsDiffingOptions,
7
+ zeroBasedCount = true
8
+ }) {
9
+ const propsRef = useRef();
10
+ const renderCountRef = useRef(zeroBasedCount ? 0 : 1);
11
+ const {
12
+ current: componentId
13
+ } = useRef(uuid.generate());
14
+ useEffect(() => {
15
+ const lastProps = propsRef.current;
16
+ const renderCount = renderCountRef.current;
17
+ let propsDifference;
18
+
19
+ if (propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.enabled && lastProps) {
20
+ propsDifference = propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.useShallow ? getShallowPropsDifference(lastProps, propsDiffingOptions.props) : getPropsDifference(lastProps, propsDiffingOptions.props, 0, 2, propsDiffingOptions === null || propsDiffingOptions === void 0 ? void 0 : propsDiffingOptions.propsToIgnore);
21
+ }
22
+
23
+ const result = {
24
+ renderCount,
25
+ propsDifference,
26
+ componentId
27
+ };
28
+ onRender(result);
29
+
30
+ if (propsDiffingOptions !== null && propsDiffingOptions !== void 0 && propsDiffingOptions.enabled) {
31
+ propsRef.current = propsDiffingOptions.props;
32
+ }
33
+
34
+ renderCountRef.current = renderCountRef.current + 1;
35
+ }); // No dependencies run on each render
36
+ }
@@ -1,4 +1,5 @@
1
- import { defaultSchema, inlineNodes, isSafeUrl, PanelType, generateUuid as uuid } from '@atlaskit/adf-schema';
1
+ import { inlineNodes, isSafeUrl, PanelType, generateUuid as uuid } from '@atlaskit/adf-schema';
2
+ import { defaultSchema } from '@atlaskit/adf-schema/schema-default';
2
3
  export const ADFStages = {
3
4
  FINAL: 'final',
4
5
  STAGE_0: 'stage0'
@@ -356,7 +357,7 @@ export const getValidNode = (originalNode, schema = defaultSchema, adfStage = 'f
356
357
  mediaCollection = collection;
357
358
  }
358
359
 
359
- if (mediaId && mediaCollection && adfStage === 'stage0') {
360
+ if (mediaId && mediaCollection) {
360
361
  return {
361
362
  type,
362
363
  attrs,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "65.0.0",
3
+ "version": "66.0.2",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * NOTE:
3
+ *
4
+ * This file is automatically generated by Traduki 2.0.
5
+ * DO NOT CHANGE IT BY HAND or your changes will be lost.
6
+ */
7
+ //
8
+ export default {
9
+ 'fabric.editor.captionPlaceholder': 'Add a caption',
10
+ 'fabric.editor.codeBidiWarningLabel': 'Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.',
11
+ 'fabric.editor.collapseNode': 'Collapse content',
12
+ 'fabric.editor.expandDefaultTitle': 'Click here to expand...',
13
+ 'fabric.editor.expandNode': 'Expand content',
14
+ 'fabric.editor.expandPlaceholder': 'Give this expand a title...',
15
+ 'fabric.editor.openLink': 'Open link in a new tab',
16
+ 'fabric.editor.unsupportedBlockContent': 'This editor does not support displaying this content',
17
+ 'fabric.editor.unsupportedContentTooltip': 'Content is not available in this editor, this will be preserved when you edit and save',
18
+ 'fabric.editor.unsupportedInlineContent': 'Unsupported content'
19
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * NOTE:
3
+ *
4
+ * This file is automatically generated by Traduki 2.0.
5
+ * DO NOT CHANGE IT BY HAND or your changes will be lost.
6
+ */
7
+ //English (United Kingdom)
8
+ export default {
9
+ 'fabric.editor.captionPlaceholder': 'Add a caption',
10
+ 'fabric.editor.codeBidiWarningLabel': 'Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.',
11
+ 'fabric.editor.collapseNode': 'Collapse content',
12
+ 'fabric.editor.expandDefaultTitle': 'Click here to expand...',
13
+ 'fabric.editor.expandNode': 'Expand content',
14
+ 'fabric.editor.expandPlaceholder': 'Give this expand a title...',
15
+ 'fabric.editor.openLink': 'Open link in a new tab',
16
+ 'fabric.editor.unsupportedBlockContent': 'This editor does not support displaying this content',
17
+ 'fabric.editor.unsupportedContentTooltip': 'Content is not available in this editor, this will be preserved when you edit and save',
18
+ 'fabric.editor.unsupportedInlineContent': 'Unsupported content'
19
+ };