@atlaskit/editor-common 78.10.1 → 78.11.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 (44) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/extensibility/Extension/InlineExtension/index.js +40 -42
  3. package/dist/cjs/extensibility/Extension/InlineExtension/styles.js +32 -5
  4. package/dist/cjs/extensibility/ExtensionComponent.js +2 -1
  5. package/dist/cjs/monitoring/error.js +1 -1
  6. package/dist/cjs/ui/DropList/index.js +1 -1
  7. package/dist/cjs/ui/MediaSingle/index.js +5 -2
  8. package/dist/cjs/ui/MediaSingle/styled.js +44 -8
  9. package/dist/cjs/ui/MultiBodiedExtension/index.js +1 -8
  10. package/dist/cjs/ui/WidthProvider/index.js +35 -49
  11. package/dist/cjs/ui/index.js +6 -0
  12. package/dist/es2019/extensibility/Extension/InlineExtension/index.js +43 -28
  13. package/dist/es2019/extensibility/Extension/InlineExtension/styles.js +29 -22
  14. package/dist/es2019/extensibility/ExtensionComponent.js +2 -1
  15. package/dist/es2019/monitoring/error.js +1 -1
  16. package/dist/es2019/ui/DropList/index.js +1 -1
  17. package/dist/es2019/ui/MediaSingle/index.js +4 -2
  18. package/dist/es2019/ui/MediaSingle/styled.js +40 -10
  19. package/dist/es2019/ui/MultiBodiedExtension/index.js +1 -8
  20. package/dist/es2019/ui/WidthProvider/index.js +29 -35
  21. package/dist/es2019/ui/index.js +1 -1
  22. package/dist/esm/extensibility/Extension/InlineExtension/index.js +40 -45
  23. package/dist/esm/extensibility/Extension/InlineExtension/styles.js +31 -3
  24. package/dist/esm/extensibility/ExtensionComponent.js +2 -1
  25. package/dist/esm/monitoring/error.js +1 -1
  26. package/dist/esm/ui/DropList/index.js +1 -1
  27. package/dist/esm/ui/MediaSingle/index.js +5 -2
  28. package/dist/esm/ui/MediaSingle/styled.js +44 -9
  29. package/dist/esm/ui/MultiBodiedExtension/index.js +1 -8
  30. package/dist/esm/ui/WidthProvider/index.js +31 -49
  31. package/dist/esm/ui/index.js +1 -1
  32. package/dist/types/extensibility/Extension/InlineExtension/index.d.ts +5 -4
  33. package/dist/types/extensibility/Extension/InlineExtension/styles.d.ts +1 -0
  34. package/dist/types/ui/MediaSingle/index.d.ts +2 -1
  35. package/dist/types/ui/MediaSingle/styled.d.ts +11 -2
  36. package/dist/types/ui/WidthProvider/index.d.ts +3 -10
  37. package/dist/types/ui/index.d.ts +1 -1
  38. package/dist/types-ts4.5/extensibility/Extension/InlineExtension/index.d.ts +5 -4
  39. package/dist/types-ts4.5/extensibility/Extension/InlineExtension/styles.d.ts +1 -0
  40. package/dist/types-ts4.5/ui/MediaSingle/index.d.ts +2 -1
  41. package/dist/types-ts4.5/ui/MediaSingle/styled.d.ts +11 -2
  42. package/dist/types-ts4.5/ui/WidthProvider/index.d.ts +3 -10
  43. package/dist/types-ts4.5/ui/index.d.ts +1 -1
  44. package/package.json +4 -1
@@ -21,7 +21,8 @@ export default function MediaSingle({
21
21
  fullWidthMode,
22
22
  lineLength: editorWidth,
23
23
  hasFallbackContainer = true,
24
- handleMediaSingleRef
24
+ handleMediaSingleRef,
25
+ isInsideOfInlineExtension = false
25
26
  }) {
26
27
  const isPixelWidth = (size === null || size === void 0 ? void 0 : size.widthType) === 'pixel';
27
28
  let mediaSingleWidth = (size === null || size === void 0 ? void 0 : size.width) || pctWidth;
@@ -79,7 +80,8 @@ export default function MediaSingle({
79
80
  containerWidth,
80
81
  mediaSingleWidth,
81
82
  fullWidthMode,
82
- isExtendedResizeExperienceOn: isPixelWidth
83
+ isExtendedResizeExperienceOn: isPixelWidth,
84
+ isInsideOfInlineExtension
83
85
  }),
84
86
  "data-layout": layout,
85
87
  "data-width": mediaSingleWidth,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import React from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
- import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
5
+ import { akEditorDefaultLayoutWidth, akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
6
6
  import { nonWrappedLayouts } from '../../utils';
7
7
  import { calcBreakoutWidth, calcWideWidth } from '../../utils/breakout';
8
8
  function float(layout) {
@@ -15,11 +15,17 @@ function float(layout) {
15
15
  return 'none';
16
16
  }
17
17
  }
18
- function getWidthIfFullWidthMode(width) {
19
- return width > akEditorFullWidthLayoutWidth ? '100%' : `${width}px`;
18
+ function getWidthIfFullWidthMode(originalWidth, containerWidth, isInsideOfInlineExtension) {
19
+ if (isInsideOfInlineExtension) {
20
+ return originalWidth > akEditorFullWidthLayoutWidth ? `${Math.min(containerWidth, akEditorFullWidthLayoutWidth)}px` : `${originalWidth}px`;
21
+ }
22
+ return originalWidth > akEditorFullWidthLayoutWidth ? '100%' : `${originalWidth}px`;
20
23
  }
21
- function getWidthIfDefaultMode(width) {
22
- return width > akEditorFullPageMaxWidth ? '100%' : `${width}px`;
24
+ function getWidthIfDefaultMode(originalWidth, containerWidth, isInsideOfInlineExtension) {
25
+ if (isInsideOfInlineExtension) {
26
+ return originalWidth > akEditorFullPageMaxWidth ? `${Math.min(containerWidth, akEditorDefaultLayoutWidth)}px` : `${originalWidth}px`;
27
+ }
28
+ return originalWidth > akEditorFullPageMaxWidth ? '100%' : `${originalWidth}px`;
23
29
  }
24
30
 
25
31
  /**
@@ -29,7 +35,7 @@ function getWidthIfDefaultMode(width) {
29
35
  * then an image in wide or full-width can not be wider than the image's
30
36
  * original width.
31
37
  */
32
- export function calcLegacyWidth(layout, width, containerWidth = 0, fullWidthMode, isResized) {
38
+ export function calcLegacyWidth(layout, width, containerWidth = 0, fullWidthMode, isResized, isInsideOfInlineExtension) {
33
39
  switch (layout) {
34
40
  case 'align-start':
35
41
  case 'align-end':
@@ -37,11 +43,34 @@ export function calcLegacyWidth(layout, width, containerWidth = 0, fullWidthMode
37
43
  case 'wrap-left':
38
44
  return width > containerWidth / 2 ? 'calc(50% - 12px)' : `${width}px`;
39
45
  case 'wide':
40
- return calcWideWidth(containerWidth);
46
+ return isInsideOfInlineExtension ? calcWideWidth(containerWidth, Infinity, `${containerWidth}px`) : calcWideWidth(containerWidth);
47
+ case 'full-width':
48
+ return calcBreakoutWidth(layout, containerWidth);
49
+ default:
50
+ return isResized ? `${width}px` : fullWidthMode ? getWidthIfFullWidthMode(width, containerWidth, isInsideOfInlineExtension) : getWidthIfDefaultMode(width, containerWidth, isInsideOfInlineExtension);
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Calculates the image width for non-resized images.
56
+ *
57
+ * If an image has not been resized using the pctWidth attribute,
58
+ * then an image in wide or full-width can not be wider than the image's
59
+ * original width.
60
+ */
61
+ export function calcLegacyWidthForInline(layout, width, containerWidth = 0, fullWidthMode, isResized) {
62
+ switch (layout) {
63
+ case 'align-start':
64
+ case 'align-end':
65
+ case 'wrap-right':
66
+ case 'wrap-left':
67
+ return width > containerWidth / 2 ? 'calc(50% - 12px)' : `${width}px`;
68
+ case 'wide':
69
+ return calcWideWidth(containerWidth, Infinity, `${containerWidth}px`);
41
70
  case 'full-width':
42
71
  return calcBreakoutWidth(layout, containerWidth);
43
72
  default:
44
- return isResized ? `${width}px` : fullWidthMode ? getWidthIfFullWidthMode(width) : getWidthIfDefaultMode(width);
73
+ return isResized ? `${width}px` : fullWidthMode ? getWidthIfFullWidthMode(width, containerWidth) : getWidthIfDefaultMode(width, containerWidth);
45
74
  }
46
75
  }
47
76
 
@@ -104,7 +133,8 @@ export const MediaSingleDimensionHelper = ({
104
133
  width,
105
134
  // original media width
106
135
  isExtendedResizeExperienceOn,
107
- isNestedNode = false
136
+ isNestedNode = false,
137
+ isInsideOfInlineExtension = false
108
138
  }) => css`
109
139
  /* For nested rich media items, set max-width to 100% */
110
140
  tr &,
@@ -115,7 +145,7 @@ export const MediaSingleDimensionHelper = ({
115
145
  max-width: 100%;
116
146
  }
117
147
 
118
- width: ${isExtendedResizeExperienceOn ? `${mediaSingleWidth || width}px` : mediaSingleWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized)};
148
+ width: ${isExtendedResizeExperienceOn ? `${mediaSingleWidth || width}px` : mediaSingleWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized, isInsideOfInlineExtension)};
119
149
  ${layout === 'full-width' &&
120
150
  /* This causes issues for new experience where we don't strip layout attributes
121
151
  when copying top-level node and pasting into a table/layout,
@@ -6,9 +6,8 @@ import { BODIED_EXT_MBE_MARGIN_TOP } from '../../styles';
6
6
 
7
7
  // Wraps the navigation bar and extensionFrames
8
8
  const mbeExtensionContainer = css({
9
- background: 'transpaent !important',
9
+ background: 'transparent !important',
10
10
  'padding:': {
11
- bottom: `${"var(--ds-space-100, 8px)"} !important`,
12
11
  left: `${"var(--ds-space-100, 8px)"} !important`,
13
12
  right: `${"var(--ds-space-100, 8px)"} !important`
14
13
  },
@@ -60,12 +59,6 @@ const extensionFrameContent = css({
60
59
  },
61
60
  '.extensionView-content-wrap': {
62
61
  marginTop: `${"var(--ds-space-100, 8px)"} !important`
63
- },
64
- '.decisionItemView-content-wrap': {
65
- marginTop: '0px !important'
66
- },
67
- '.decisionItemView-content-wrap > [data-decision-wrapper]': {
68
- marginTop: '0px !important'
69
62
  }
70
63
  });
71
64
  export const sharedMultiBodiedExtensionStyles = {
@@ -1,6 +1,5 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  /** @jsx jsx */
3
- import React from 'react';
2
+ import React, { Fragment } from 'react';
4
3
  import { css, jsx } from '@emotion/react';
5
4
  import rafSchedule from 'raf-schd';
6
5
  import { WidthObserver } from '@atlaskit/width-detector';
@@ -26,38 +25,33 @@ const {
26
25
  Provider,
27
26
  Consumer
28
27
  } = WidthContext;
29
- export class WidthProvider extends React.Component {
30
- constructor(props) {
31
- super(props);
32
- _defineProperty(this, "state", {
33
- width: 0
34
- });
35
- _defineProperty(this, "setWidth", rafSchedule(width => {
36
- // Ignore changes that are less than SCROLLBAR_WIDTH, otherwise it can cause infinite re-scaling
37
- if (Math.abs(this.state.width - width) < SCROLLBAR_WIDTH) {
38
- return;
39
- }
40
- this.setState({
41
- width
42
- });
43
- }));
44
- if (typeof document !== 'undefined') {
45
- this.state.width = document.body.offsetWidth;
28
+ export const WidthProvider = ({
29
+ className,
30
+ shouldCheckExistingValue,
31
+ children
32
+ }) => {
33
+ const existingContextValue = React.useContext(WidthContext);
34
+ const [width, setWidth] = React.useState(typeof document !== 'undefined' ? document.body.offsetWidth : 0);
35
+ const providerValue = React.useMemo(() => createWidthContext(width), [width]);
36
+ const updateWidth = rafSchedule(nextWidth => {
37
+ // Ignore changes that are less than SCROLLBAR_WIDTH, otherwise it can cause infinite re-scaling
38
+ if (Math.abs(width - nextWidth) < SCROLLBAR_WIDTH) {
39
+ return;
46
40
  }
47
- }
48
- render() {
49
- return jsx("div", {
50
- css: css`
51
- position: relative;
52
- width: 100%;
53
- `,
54
- className: this.props.className
55
- }, jsx(WidthObserver, {
56
- setWidth: this.setWidth,
57
- offscreen: true
58
- }), jsx(Provider, {
59
- value: createWidthContext(this.state.width)
60
- }, this.props.children));
61
- }
62
- }
41
+ setWidth(nextWidth);
42
+ });
43
+ const skipWidthDetection = shouldCheckExistingValue && existingContextValue.width > 0;
44
+ return jsx("div", {
45
+ css: css`
46
+ position: relative;
47
+ width: 100%;
48
+ `,
49
+ className: className
50
+ }, !skipWidthDetection && jsx(Fragment, null, jsx(WidthObserver, {
51
+ setWidth: updateWidth,
52
+ offscreen: true
53
+ }), jsx(Provider, {
54
+ value: providerValue
55
+ }, children)), skipWidthDetection && children);
56
+ };
63
57
  export { Consumer as WidthConsumer };
@@ -8,7 +8,7 @@ export { default as UnsupportedBlock } from './UnsupportedBlock';
8
8
  export { default as UnsupportedInline } from './UnsupportedInline';
9
9
  export { BaseTheme, mapBreakpointToLayoutMaxWidth } from './BaseTheme';
10
10
  export { default as withOuterListeners } from './with-outer-listeners';
11
- export { WidthContext, WidthConsumer, WidthProvider, getBreakpoint } from './WidthProvider';
11
+ export { WidthContext, WidthConsumer, WidthProvider, createWidthContext, getBreakpoint } from './WidthProvider';
12
12
  export { default as overflowShadow, shadowClassNames } from './OverflowShadow';
13
13
  export { shadowObserverClassNames, ShadowObserver } from './OverflowShadow/shadowObserver';
14
14
  export { WithCreateAnalyticsEvent } from './WithCreateAnalyticsEvent';
@@ -1,50 +1,45 @@
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() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
8
1
  /** @jsx jsx */
9
- import React, { Component, Fragment } from 'react';
2
+ import React, { Fragment } from 'react';
10
3
  import { jsx } from '@emotion/react';
4
+ import { akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
5
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
+ import { useSharedPluginState } from '../../../hooks';
7
+ import { createWidthContext, WidthContext } from '../../../ui';
11
8
  import ExtensionLozenge from '../Lozenge';
12
9
  import { overlay } from '../styles';
13
- import { wrapperStyle } from './styles';
14
- var InlineExtension = /*#__PURE__*/function (_Component) {
15
- _inherits(InlineExtension, _Component);
16
- var _super = _createSuper(InlineExtension);
17
- function InlineExtension() {
18
- _classCallCheck(this, InlineExtension);
19
- return _super.apply(this, arguments);
10
+ import { inlineWrapperStyels, wrapperStyle } from './styles';
11
+ var InlineExtension = function InlineExtension(props) {
12
+ var node = props.node,
13
+ pluginInjectionApi = props.pluginInjectionApi,
14
+ showMacroInteractionDesignUpdates = props.showMacroInteractionDesignUpdates,
15
+ isNodeSelected = props.isNodeSelected,
16
+ children = props.children;
17
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['width']),
18
+ widthState = _useSharedPluginState.widthState;
19
+ var hasChildren = !!children;
20
+ var className = hasChildren ? 'with-overlay with-children' : 'with-overlay';
21
+ var rendererContainerWidth = widthState ? widthState.width - akEditorGutterPadding * 2 : 0;
22
+ var extendedInlineExtension = getBooleanFF('platform.editor.inline_extension.extended_lcqdn') || false;
23
+ var inlineExtensionInternal = jsx(Fragment, null, showMacroInteractionDesignUpdates && jsx(ExtensionLozenge, {
24
+ node: node,
25
+ isNodeSelected: isNodeSelected,
26
+ showMacroInteractionDesignUpdates: showMacroInteractionDesignUpdates
27
+ }), jsx("div", {
28
+ css: [wrapperStyle, extendedInlineExtension && inlineWrapperStyels],
29
+ className: "extension-container inline ".concat(className)
30
+ }, jsx("div", {
31
+ css: overlay,
32
+ className: "extension-overlay"
33
+ }), children ? children : jsx(ExtensionLozenge, {
34
+ node: node,
35
+ isNodeSelected: isNodeSelected,
36
+ showMacroInteractionDesignUpdates: showMacroInteractionDesignUpdates
37
+ })));
38
+ if (extendedInlineExtension) {
39
+ return jsx(WidthContext.Provider, {
40
+ value: createWidthContext(rendererContainerWidth)
41
+ }, inlineExtensionInternal);
20
42
  }
21
- _createClass(InlineExtension, [{
22
- key: "render",
23
- value: function render() {
24
- var _this$props = this.props,
25
- node = _this$props.node,
26
- children = _this$props.children,
27
- showMacroInteractionDesignUpdates = _this$props.showMacroInteractionDesignUpdates,
28
- isNodeSelected = _this$props.isNodeSelected;
29
- var hasChildren = !!children;
30
- var className = hasChildren ? 'with-overlay with-children' : 'with-overlay';
31
- return jsx(Fragment, null, showMacroInteractionDesignUpdates && jsx(ExtensionLozenge, {
32
- node: node,
33
- isNodeSelected: isNodeSelected,
34
- showMacroInteractionDesignUpdates: showMacroInteractionDesignUpdates
35
- }), jsx("div", {
36
- css: wrapperStyle,
37
- className: "extension-container inline ".concat(className)
38
- }, jsx("div", {
39
- css: overlay,
40
- className: "extension-overlay"
41
- }), children ? children : jsx(ExtensionLozenge, {
42
- node: node,
43
- isNodeSelected: isNodeSelected,
44
- showMacroInteractionDesignUpdates: showMacroInteractionDesignUpdates
45
- })));
46
- }
47
- }]);
48
- return InlineExtension;
49
- }(Component);
50
- export { InlineExtension as default };
43
+ return inlineExtensionInternal;
44
+ };
45
+ export default InlineExtension;
@@ -1,5 +1,33 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject;
3
1
  import { css } from '@emotion/react';
4
2
  import { wrapperDefault } from '../styles';
5
- export var wrapperStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n\n cursor: pointer;\n display: inline-flex;\n margin: 1px 1px ", ";\n\n > img {\n border-radius: ", ";\n }\n\n &::after,\n &::before {\n vertical-align: text-top;\n display: inline-block;\n width: 1px;\n content: '';\n }\n\n &.with-children {\n padding: 0;\n background: ", ";\n }\n"])), wrapperDefault, "var(--ds-space-050, 4px)", "var(--ds-border-radius, 3px)", "var(--ds-background-neutral-subtle, white)");
3
+ export var wrapperStyle = css(wrapperDefault, {
4
+ cursor: 'pointer',
5
+ display: 'inline-flex',
6
+ margin: "1px 1px ".concat("var(--ds-space-050, 4px)"),
7
+ '> img': {
8
+ borderRadius: "var(--ds-border-radius, 3px)"
9
+ },
10
+ '&::after, &::before': {
11
+ verticalAlign: 'text-top',
12
+ display: 'inline-block',
13
+ width: '1px',
14
+ content: "''"
15
+ },
16
+ '&.with-children': {
17
+ padding: 0,
18
+ background: "var(--ds-background-neutral-subtle, white)"
19
+ }
20
+ });
21
+ export var inlineWrapperStyels = css({
22
+ maxWidth: '100%',
23
+ display: 'inline-block',
24
+ '&::after, &::before': {
25
+ display: 'block'
26
+ },
27
+ 'tr &': {
28
+ maxWidth: 'inherit'
29
+ },
30
+ '.rich-media-item': {
31
+ maxWidth: '100%'
32
+ }
33
+ });
@@ -223,7 +223,8 @@ export var ExtensionComponent = /*#__PURE__*/function (_Component) {
223
223
  return /*#__PURE__*/React.createElement(InlineExtension, {
224
224
  node: node,
225
225
  showMacroInteractionDesignUpdates: showMacroInteractionDesignUpdates,
226
- isNodeSelected: selectedNode === node
226
+ isNodeSelected: selectedNode === node,
227
+ pluginInjectionApi: pluginInjectionApi
227
228
  }, extensionHandlerResult);
228
229
  default:
229
230
  return null;
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "78.10.1";
9
+ var packageVersion = "78.11.0";
10
10
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
11
11
  // Remove URL as it has UGC
12
12
  // TODO: Sanitise the URL instead of just removing it
@@ -17,7 +17,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
17
17
  import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
18
18
  import Layer from '../Layer';
19
19
  var packageName = "@atlaskit/editor-common";
20
- var packageVersion = "78.10.1";
20
+ var packageVersion = "78.11.0";
21
21
  var halfFocusRing = 1;
22
22
  var dropOffset = '0, 8';
23
23
  var DropList = /*#__PURE__*/function (_Component) {
@@ -26,7 +26,9 @@ export default function MediaSingle(_ref) {
26
26
  editorWidth = _ref.lineLength,
27
27
  _ref$hasFallbackConta = _ref.hasFallbackContainer,
28
28
  hasFallbackContainer = _ref$hasFallbackConta === void 0 ? true : _ref$hasFallbackConta,
29
- handleMediaSingleRef = _ref.handleMediaSingleRef;
29
+ handleMediaSingleRef = _ref.handleMediaSingleRef,
30
+ _ref$isInsideOfInline = _ref.isInsideOfInlineExtension,
31
+ isInsideOfInlineExtension = _ref$isInsideOfInline === void 0 ? false : _ref$isInsideOfInline;
30
32
  var isPixelWidth = (size === null || size === void 0 ? void 0 : size.widthType) === 'pixel';
31
33
  var mediaSingleWidth = (size === null || size === void 0 ? void 0 : size.width) || pctWidth;
32
34
  var children = React.Children.toArray(propsChildren);
@@ -85,7 +87,8 @@ export default function MediaSingle(_ref) {
85
87
  containerWidth: containerWidth,
86
88
  mediaSingleWidth: mediaSingleWidth,
87
89
  fullWidthMode: fullWidthMode,
88
- isExtendedResizeExperienceOn: isPixelWidth
90
+ isExtendedResizeExperienceOn: isPixelWidth,
91
+ isInsideOfInlineExtension: isInsideOfInlineExtension
89
92
  }),
90
93
  "data-layout": layout,
91
94
  "data-width": mediaSingleWidth,
@@ -6,7 +6,7 @@ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
6
6
 
7
7
  import React from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
- import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
9
+ import { akEditorDefaultLayoutWidth, akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
10
10
  import { nonWrappedLayouts } from '../../utils';
11
11
  import { calcBreakoutWidth, calcWideWidth } from '../../utils/breakout';
12
12
  function float(layout) {
@@ -19,11 +19,17 @@ function float(layout) {
19
19
  return 'none';
20
20
  }
21
21
  }
22
- function getWidthIfFullWidthMode(width) {
23
- return width > akEditorFullWidthLayoutWidth ? '100%' : "".concat(width, "px");
22
+ function getWidthIfFullWidthMode(originalWidth, containerWidth, isInsideOfInlineExtension) {
23
+ if (isInsideOfInlineExtension) {
24
+ return originalWidth > akEditorFullWidthLayoutWidth ? "".concat(Math.min(containerWidth, akEditorFullWidthLayoutWidth), "px") : "".concat(originalWidth, "px");
25
+ }
26
+ return originalWidth > akEditorFullWidthLayoutWidth ? '100%' : "".concat(originalWidth, "px");
24
27
  }
25
- function getWidthIfDefaultMode(width) {
26
- return width > akEditorFullPageMaxWidth ? '100%' : "".concat(width, "px");
28
+ function getWidthIfDefaultMode(originalWidth, containerWidth, isInsideOfInlineExtension) {
29
+ if (isInsideOfInlineExtension) {
30
+ return originalWidth > akEditorFullPageMaxWidth ? "".concat(Math.min(containerWidth, akEditorDefaultLayoutWidth), "px") : "".concat(originalWidth, "px");
31
+ }
32
+ return originalWidth > akEditorFullPageMaxWidth ? '100%' : "".concat(originalWidth, "px");
27
33
  }
28
34
 
29
35
  /**
@@ -37,6 +43,7 @@ export function calcLegacyWidth(layout, width) {
37
43
  var containerWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
38
44
  var fullWidthMode = arguments.length > 3 ? arguments[3] : undefined;
39
45
  var isResized = arguments.length > 4 ? arguments[4] : undefined;
46
+ var isInsideOfInlineExtension = arguments.length > 5 ? arguments[5] : undefined;
40
47
  switch (layout) {
41
48
  case 'align-start':
42
49
  case 'align-end':
@@ -44,11 +51,37 @@ export function calcLegacyWidth(layout, width) {
44
51
  case 'wrap-left':
45
52
  return width > containerWidth / 2 ? 'calc(50% - 12px)' : "".concat(width, "px");
46
53
  case 'wide':
47
- return calcWideWidth(containerWidth);
54
+ return isInsideOfInlineExtension ? calcWideWidth(containerWidth, Infinity, "".concat(containerWidth, "px")) : calcWideWidth(containerWidth);
55
+ case 'full-width':
56
+ return calcBreakoutWidth(layout, containerWidth);
57
+ default:
58
+ return isResized ? "".concat(width, "px") : fullWidthMode ? getWidthIfFullWidthMode(width, containerWidth, isInsideOfInlineExtension) : getWidthIfDefaultMode(width, containerWidth, isInsideOfInlineExtension);
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Calculates the image width for non-resized images.
64
+ *
65
+ * If an image has not been resized using the pctWidth attribute,
66
+ * then an image in wide or full-width can not be wider than the image's
67
+ * original width.
68
+ */
69
+ export function calcLegacyWidthForInline(layout, width) {
70
+ var containerWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
71
+ var fullWidthMode = arguments.length > 3 ? arguments[3] : undefined;
72
+ var isResized = arguments.length > 4 ? arguments[4] : undefined;
73
+ switch (layout) {
74
+ case 'align-start':
75
+ case 'align-end':
76
+ case 'wrap-right':
77
+ case 'wrap-left':
78
+ return width > containerWidth / 2 ? 'calc(50% - 12px)' : "".concat(width, "px");
79
+ case 'wide':
80
+ return calcWideWidth(containerWidth, Infinity, "".concat(containerWidth, "px"));
48
81
  case 'full-width':
49
82
  return calcBreakoutWidth(layout, containerWidth);
50
83
  default:
51
- return isResized ? "".concat(width, "px") : fullWidthMode ? getWidthIfFullWidthMode(width) : getWidthIfDefaultMode(width);
84
+ return isResized ? "".concat(width, "px") : fullWidthMode ? getWidthIfFullWidthMode(width, containerWidth) : getWidthIfDefaultMode(width, containerWidth);
52
85
  }
53
86
  }
54
87
 
@@ -113,8 +146,10 @@ export var MediaSingleDimensionHelper = function MediaSingleDimensionHelper(_ref
113
146
  width = _ref.width,
114
147
  isExtendedResizeExperienceOn = _ref.isExtendedResizeExperienceOn,
115
148
  _ref$isNestedNode = _ref.isNestedNode,
116
- isNestedNode = _ref$isNestedNode === void 0 ? false : _ref$isNestedNode;
117
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* For nested rich media items, set max-width to 100% */\n tr &,\n [data-layout-column] &,\n [data-node-type='expand'] &,\n [data-panel-type] &,\n li & {\n max-width: 100%;\n }\n\n width: ", ";\n ", "\n max-width: ", ";\n\n ", "\n\n &:not(.is-resizing) {\n transition: width 100ms ease-in;\n }\n\n float: ", ";\n margin: ", ";\n\n &[class*='not-resizing'] {\n ", "\n }\n\n ", ";\n"])), isExtendedResizeExperienceOn ? "".concat(mediaSingleWidth || width, "px") : mediaSingleWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized), layout === 'full-width' &&
149
+ isNestedNode = _ref$isNestedNode === void 0 ? false : _ref$isNestedNode,
150
+ _ref$isInsideOfInline = _ref.isInsideOfInlineExtension,
151
+ isInsideOfInlineExtension = _ref$isInsideOfInline === void 0 ? false : _ref$isInsideOfInline;
152
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* For nested rich media items, set max-width to 100% */\n tr &,\n [data-layout-column] &,\n [data-node-type='expand'] &,\n [data-panel-type] &,\n li & {\n max-width: 100%;\n }\n\n width: ", ";\n ", "\n max-width: ", ";\n\n ", "\n\n &:not(.is-resizing) {\n transition: width 100ms ease-in;\n }\n\n float: ", ";\n margin: ", ";\n\n &[class*='not-resizing'] {\n ", "\n }\n\n ", ";\n"])), isExtendedResizeExperienceOn ? "".concat(mediaSingleWidth || width, "px") : mediaSingleWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized, isInsideOfInlineExtension), layout === 'full-width' &&
118
153
  /* This causes issues for new experience where we don't strip layout attributes
119
154
  when copying top-level node and pasting into a table/layout,
120
155
  because full-width layout will remain, causing node to be edge-to-edge */
@@ -6,9 +6,8 @@ import { BODIED_EXT_MBE_MARGIN_TOP } from '../../styles';
6
6
 
7
7
  // Wraps the navigation bar and extensionFrames
8
8
  var mbeExtensionContainer = css({
9
- background: 'transpaent !important',
9
+ background: 'transparent !important',
10
10
  'padding:': {
11
- bottom: "var(--ds-space-100, 8px)".concat(" !important"),
12
11
  left: "var(--ds-space-100, 8px)".concat(" !important"),
13
12
  right: "var(--ds-space-100, 8px)".concat(" !important")
14
13
  },
@@ -60,12 +59,6 @@ var extensionFrameContent = css({
60
59
  },
61
60
  '.extensionView-content-wrap': {
62
61
  marginTop: "var(--ds-space-100, 8px)".concat(" !important")
63
- },
64
- '.decisionItemView-content-wrap': {
65
- marginTop: '0px !important'
66
- },
67
- '.decisionItemView-content-wrap > [data-decision-wrapper]': {
68
- marginTop: '0px !important'
69
62
  }
70
63
  });
71
64
  export var sharedMultiBodiedExtensionStyles = {
@@ -1,16 +1,8 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
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
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
9
3
  var _templateObject;
10
- 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); }; }
11
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
4
  /** @jsx jsx */
13
- import React from 'react';
5
+ import React, { Fragment } from 'react';
14
6
  import { css, jsx } from '@emotion/react';
15
7
  import rafSchedule from 'raf-schd';
16
8
  import { WidthObserver } from '@atlaskit/width-detector';
@@ -36,44 +28,34 @@ export function createWidthContext() {
36
28
  export var WidthContext = /*#__PURE__*/React.createContext(createWidthContext());
37
29
  var Provider = WidthContext.Provider,
38
30
  Consumer = WidthContext.Consumer;
39
- export var WidthProvider = /*#__PURE__*/function (_React$Component) {
40
- _inherits(WidthProvider, _React$Component);
41
- var _super = _createSuper(WidthProvider);
42
- function WidthProvider(props) {
43
- var _this;
44
- _classCallCheck(this, WidthProvider);
45
- _this = _super.call(this, props);
46
- _defineProperty(_assertThisInitialized(_this), "state", {
47
- width: 0
48
- });
49
- _defineProperty(_assertThisInitialized(_this), "setWidth", rafSchedule(function (width) {
50
- // Ignore changes that are less than SCROLLBAR_WIDTH, otherwise it can cause infinite re-scaling
51
- if (Math.abs(_this.state.width - width) < SCROLLBAR_WIDTH) {
52
- return;
53
- }
54
- _this.setState({
55
- width: width
56
- });
57
- }));
58
- if (typeof document !== 'undefined') {
59
- _this.state.width = document.body.offsetWidth;
31
+ export var WidthProvider = function WidthProvider(_ref) {
32
+ var className = _ref.className,
33
+ shouldCheckExistingValue = _ref.shouldCheckExistingValue,
34
+ children = _ref.children;
35
+ var existingContextValue = React.useContext(WidthContext);
36
+ var _React$useState = React.useState(typeof document !== 'undefined' ? document.body.offsetWidth : 0),
37
+ _React$useState2 = _slicedToArray(_React$useState, 2),
38
+ width = _React$useState2[0],
39
+ setWidth = _React$useState2[1];
40
+ var providerValue = React.useMemo(function () {
41
+ return createWidthContext(width);
42
+ }, [width]);
43
+ var updateWidth = rafSchedule(function (nextWidth) {
44
+ // Ignore changes that are less than SCROLLBAR_WIDTH, otherwise it can cause infinite re-scaling
45
+ if (Math.abs(width - nextWidth) < SCROLLBAR_WIDTH) {
46
+ return;
60
47
  }
61
- return _this;
62
- }
63
- _createClass(WidthProvider, [{
64
- key: "render",
65
- value: function render() {
66
- return jsx("div", {
67
- css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n width: 100%;\n "]))),
68
- className: this.props.className
69
- }, jsx(WidthObserver, {
70
- setWidth: this.setWidth,
71
- offscreen: true
72
- }), jsx(Provider, {
73
- value: createWidthContext(this.state.width)
74
- }, this.props.children));
75
- }
76
- }]);
77
- return WidthProvider;
78
- }(React.Component);
48
+ setWidth(nextWidth);
49
+ });
50
+ var skipWidthDetection = shouldCheckExistingValue && existingContextValue.width > 0;
51
+ return jsx("div", {
52
+ css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n width: 100%;\n "]))),
53
+ className: className
54
+ }, !skipWidthDetection && jsx(Fragment, null, jsx(WidthObserver, {
55
+ setWidth: updateWidth,
56
+ offscreen: true
57
+ }), jsx(Provider, {
58
+ value: providerValue
59
+ }, children)), skipWidthDetection && children);
60
+ };
79
61
  export { Consumer as WidthConsumer };
@@ -8,7 +8,7 @@ export { default as UnsupportedBlock } from './UnsupportedBlock';
8
8
  export { default as UnsupportedInline } from './UnsupportedInline';
9
9
  export { BaseTheme, mapBreakpointToLayoutMaxWidth } from './BaseTheme';
10
10
  export { default as withOuterListeners } from './with-outer-listeners';
11
- export { WidthContext, WidthConsumer, WidthProvider, getBreakpoint } from './WidthProvider';
11
+ export { WidthContext, WidthConsumer, WidthProvider, createWidthContext, getBreakpoint } from './WidthProvider';
12
12
  export { default as overflowShadow, shadowClassNames } from './OverflowShadow';
13
13
  export { shadowObserverClassNames, ShadowObserver } from './OverflowShadow/shadowObserver';
14
14
  export { WithCreateAnalyticsEvent } from './WithCreateAnalyticsEvent';