@atlaskit/editor-plugin-media 1.34.7 → 1.34.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 1.34.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#149178](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/149178)
8
+ [`f3c027c1f8373`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f3c027c1f8373) -
9
+ [ED-24859] Improve LazyNodeView toDOM implementation to avoid LayoutShifts
10
+
3
11
  ## 1.34.7
4
12
 
5
13
  ### Patch Changes
@@ -7,12 +7,11 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.mediaSpecWithFixedToDOM = exports.defaultImageCardDimensions = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
+ var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
10
11
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
11
12
  var _toDOMAttrs = require("./toDOMAttrs");
12
13
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
14
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
- var skeletonStyling = "background: ".concat("var(--ds-background-neutral, #091E420F)", "; outline: none;");
15
-
16
15
  /**
17
16
  * Duplicate consts from `media-card`.
18
17
  * `packages/media/media-card/src/utils/cardDimensions.ts`
@@ -37,11 +36,15 @@ var mediaSpecWithFixedToDOM = exports.mediaSpecWithFixedToDOM = function mediaSp
37
36
  return _objectSpread(_objectSpread({}, _adfSchema.media), {}, {
38
37
  toDOM: function toDOM(node) {
39
38
  var attrs = (0, _toDOMAttrs.getMediaAttrs)('media', node);
40
- var styles = skeletonStyling;
41
39
  if (node.attrs.type === 'external') {
42
40
  return ['img', _objectSpread(_objectSpread({}, attrs), {}, {
43
41
  src: node.attrs.url,
44
- styles: styles
42
+ style: (0, _lazyNodeView.convertToInlineCss)({
43
+ backgroundColor: "var(--ds-background-neutral, #091E420F)",
44
+ outline: 'none',
45
+ width: "var(--ak-editor-media-card-width, 100%)",
46
+ height: "var(--ak-editor-media-card-height, 100%)"
47
+ })
45
48
  })];
46
49
  }
47
50
  if (node.attrs.type === 'file') {
@@ -54,11 +57,27 @@ var mediaSpecWithFixedToDOM = exports.mediaSpecWithFixedToDOM = function mediaSp
54
57
  }, attrs), {}, {
55
58
  // Manually kept in sync with the style of media cards. The goal is to render a plain gray
56
59
  // rectangle that provides an affordance for media.
57
- style: "\n\t\t\t\t\t\tdisplay: inline-block;\n\t\t\t\t\t\tbackground-image: url(\"".concat(dataUrl, "\");\n\t\t\t\t\t\tmargin-left: 0;\n\t\t\t\t\t\tmargin-right: 4px;\n\t\t\t\t\t\tborder-radius: 3px;\n\t\t\t\t\t\toutline: none;\n\n\t\t\t\t\t\tflex-basis: ").concat(defaultImageCardDimensions.width, "px;\n\t\t\t\t\t\tbackground-color: var(--media-card-background-color);\n\t\t\t\t\t\twidth: var(--media-card-width, ").concat(node.attrs.width || width, "px);\n\t\t\t\t\t\theight: var(--media-card-height, ").concat(node.attrs.height || height, "px);\n\t\t\t\t\t\t")
60
+
61
+ style: (0, _lazyNodeView.convertToInlineCss)({
62
+ display: 'var(--ak-editor-media-card-display, inline-block)',
63
+ backgroundImage: "url(\"".concat(dataUrl, "\")"),
64
+ marginLeft: '0',
65
+ marginRight: 'var(--ak-editor-media-margin-right, 4px)',
66
+ borderRadius: '3px',
67
+ outline: 'none',
68
+ flexBasis: "".concat(defaultImageCardDimensions.width, "px"),
69
+ backgroundColor: 'var(--ak-editor-media-card-background-color)',
70
+ width: "var(--ak-editor-media-card-width, 100%)",
71
+ height: "var(--ak-editor-media-card-height, 0)",
72
+ paddingBottom: "var(--ak-editor-media-padding-bottom, 0)"
73
+ })
58
74
  })];
59
75
  }
60
76
  return ['div', _objectSpread(_objectSpread({}, attrs), {}, {
61
- styles: styles
77
+ styles: (0, _lazyNodeView.convertToInlineCss)({
78
+ backgroundColor: "var(--ak-editor-media-card-background-color, ".concat("var(--ds-background-neutral, #091E420F)", ")"),
79
+ outline: 'none'
80
+ })
62
81
  })];
63
82
  }
64
83
  });
@@ -68,7 +68,7 @@ var mediaGroupSpecWithFixedToDOM = exports.mediaGroupSpecWithFixedToDOM = functi
68
68
  toDOM: function toDOM(node) {
69
69
  // Margin margin that consolidates the margin in the
70
70
  return ['div', {
71
- style: "\n\t\t\t\t\t\tmargin: 3px 5px;\n\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\tgap: 8px;\n\t\t\t\t\t\t--media-card-background-color: #EBECF0;\n\t\t\t\t\t\t--media-card-width: ".concat(defaultImageCardDimensions.width, "px;\n\t\t\t\t\t\t--media-card-height: ").concat(defaultImageCardDimensions.height, "px;\n\t\t\t\t\t"),
71
+ style: "\n\t\t\t\t\t\tmargin: 3px 5px;\n\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\tgap: 8px;\n\t\t\t\t\t\t--ak-editor-media-card-background-color: #EBECF0;\n\t\t\t\t\t\t--ak-editor-media-card-width: ".concat(defaultImageCardDimensions.width, "px;\n\t\t\t\t\t\t--ak-editor-media-card-height: ").concat(defaultImageCardDimensions.height, "px;\n\t\t\t\t\t"),
72
72
  'data-node-type': 'mediaGroup'
73
73
  }, 0];
74
74
  }
@@ -4,118 +4,209 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getMediaSinglePixelWidth = getMediaSinglePixelWidth;
8
- exports.wrappedLayouts = exports.shouldAddDefaultWrappedWidth = exports.mediaSingleSpecWithFixedToDOM = void 0;
7
+ exports.toDOM = exports.prepareWrapperContentDOM = exports.mediaWidthCSSCalc = exports.mediaSingleSpecWithFixedToDOM = exports.mediaProportionalWidthCSSCalc = exports.mediaJustifyContentCSS = exports.mediaContentWrapperWidthCSSCalc = void 0;
9
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
+ var _lazyNodeView = require("@atlaskit/editor-common/lazy-node-view");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
+ var _colors = require("@atlaskit/theme/colors");
11
13
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
12
14
  var _toDOMAttrs = require("./toDOMAttrs");
13
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
- var skeletonStyling = "background: ".concat("var(--ds-background-neutral, #091E420F)", "; outline: none;");
16
- var wrappedLayouts = exports.wrappedLayouts = ['wrap-left', 'wrap-right', 'align-end', 'align-start'];
17
-
18
- /**
19
- * Duplicate of method from `@atlaskit/editor-common/utils`.
20
- * `packages/editor/editor-common/src/utils/rich-media-utils.ts`
21
- *
22
- * WHY?
23
- * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
24
- * `@atlaskit/editor-common` from here or it will cause dependency issues.
25
- *
26
- * In the long term likely `toDOM` will move back out of `adf-schema` in which
27
- * case we can consolidate them.
28
- */
29
- var shouldAddDefaultWrappedWidth = exports.shouldAddDefaultWrappedWidth = function shouldAddDefaultWrappedWidth(layout, width, lineLength) {
30
- return wrappedLayouts.indexOf(layout) > -1 && lineLength && width && width > 0.5 * lineLength;
17
+ var WRAPPED_LAYOUTS = ['wrap-left', 'wrap-right'];
18
+ var ALIGNED_LAYOUTS = ['align-end', 'align-start'];
19
+ var LEGACY_LAYOUTS = ['full-width', 'wide'];
20
+ var DEFAULT_IMAGE_WIDTH = 250;
21
+ var DEFAULT_IMAGE_HEIGHT = 200;
22
+ var GUTTER_SIZE = '24px';
23
+ var HALF_GUTTER_SIZE = '12px';
24
+ var mediaWidthCSSCalc = exports.mediaWidthCSSCalc = function mediaWidthCSSCalc(_ref) {
25
+ var mediaSingleDimensionWidth = _ref.mediaSingleDimensionWidth,
26
+ layout = _ref.layout,
27
+ baseWidth = _ref.baseWidth,
28
+ isPixelWidth = _ref.isPixelWidth,
29
+ isExtendedResizeExperience = _ref.isExtendedResizeExperience;
30
+ var hasMediaDimensionWidth = typeof mediaSingleDimensionWidth === 'number';
31
+ var isMediaWrapped = WRAPPED_LAYOUTS.includes(layout);
32
+ var isMediaAligned = ALIGNED_LAYOUTS.includes(layout);
33
+ var isMediaLegacyLayout = LEGACY_LAYOUTS.includes(layout);
34
+ var shouldUseAlignedLayoutCalc = isMediaAligned && !hasMediaDimensionWidth;
35
+ var shouldUseWrappedLayoutCalc = isMediaWrapped && !hasMediaDimensionWidth;
36
+ var shouldUseBreakoutWideLogic = layout === 'wide';
37
+ var shouldUseBreakoutFullWidthLogic = layout === 'full-width';
38
+ var shouldUseProportionalCalc = !isExtendedResizeExperience && !isPixelWidth && hasMediaDimensionWidth && !isMediaLegacyLayout && !isMediaWrapped;
39
+ var shouldUseHalfContainerCalc = shouldUseProportionalCalc && isMediaAligned && mediaSingleDimensionWidth >= 100;
40
+ var shouldHardCodePixelWidth = isExtendedResizeExperience && isPixelWidth && hasMediaDimensionWidth;
41
+ var containerWidthPlusGutter = "(min(100cqw, 100%) + ".concat(GUTTER_SIZE, ")");
42
+ var fullContainerWidth = 'var(--ak-editor-max-container-width, 100cqw)';
43
+ var applyContainerWidthBoundaries = function applyContainerWidthBoundaries(calc) {
44
+ // Safe measure to avoid bleeding
45
+ return "min(".concat(calc, ", ").concat(fullContainerWidth, ")");
46
+ };
47
+ var cssCalc = '';
48
+ if (shouldUseAlignedLayoutCalc) {
49
+ cssCalc = "min(calc(".concat(containerWidthPlusGutter, " * 0.5 - ").concat(GUTTER_SIZE, "), ").concat(baseWidth, "px)");
50
+ } else if (shouldUseWrappedLayoutCalc) {
51
+ cssCalc = "100%";
52
+ } else if (shouldUseHalfContainerCalc) {
53
+ cssCalc = "min(min(".concat(baseWidth, "px, calc(50cqw - ").concat(HALF_GUTTER_SIZE, ")), 100%)");
54
+ } else if (shouldUseProportionalCalc) {
55
+ cssCalc = "calc(".concat(containerWidthPlusGutter, " * var(--ak-editor-media-single--proportion, 1px) - ").concat(GUTTER_SIZE, ")");
56
+ } else if (shouldHardCodePixelWidth) {
57
+ cssCalc = "min(".concat(mediaSingleDimensionWidth, "px, ").concat(fullContainerWidth, ")");
58
+ } else if (shouldUseBreakoutWideLogic) {
59
+ cssCalc = "max(var(--ak-editor--line-length), min(var(--ak-editor--breakout-wide-layout-width), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))";
60
+ } else if (shouldUseBreakoutFullWidthLogic) {
61
+ cssCalc = "max(var(--ak-editor--line-length), min(var(--ak-editor--full-width-layout-width), calc(100cqw - var(--ak-editor--breakout-full-page-guttering-padding))))";
62
+ } else {
63
+ cssCalc = "max(min(".concat(baseWidth, "px, min(100cqw, 100%)), ").concat(GUTTER_SIZE, ")");
64
+ }
65
+ return applyContainerWidthBoundaries(cssCalc);
31
66
  };
32
- var MEDIA_SINGLE_GUTTER_SIZE = 24;
33
- var DEFAULT_EMBED_CARD_WIDTH = 680;
34
- var akEditorMediaResizeHandlerPaddingWide = 12;
35
-
36
- /**
37
- * Duplicate of method from `@atlaskit/editor-common/media-single`.
38
- * `packages/editor/editor-common/src/media-single/utils.ts`
39
- *
40
- * WHY?
41
- * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
42
- * `@atlaskit/editor-common` from here or it will cause dependency issues.
43
- *
44
- * In the long term likely `toDOM` will move back out of `adf-schema` in which
45
- * case we can consolidate them.
46
- */
47
- function getMediaSinglePixelWidth(width, editorWidth) {
48
- var widthType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'percentage';
49
- var gutterOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
50
- if (widthType === 'pixel') {
51
- return width;
67
+ var mediaContentWrapperWidthCSSCalc = exports.mediaContentWrapperWidthCSSCalc = function mediaContentWrapperWidthCSSCalc(_ref2) {
68
+ var isMediaWrapped = _ref2.isMediaWrapped,
69
+ isExternalMedia = _ref2.isExternalMedia,
70
+ isPixelWidth = _ref2.isPixelWidth,
71
+ childMediaWidth = _ref2.childMediaWidth,
72
+ mediaSingleDimensionWidth = _ref2.mediaSingleDimensionWidth;
73
+ if (isExternalMedia || !isMediaWrapped) {
74
+ return 'unset';
52
75
  }
53
- return Math.ceil((editorWidth + gutterOffset) * (width / 100) - gutterOffset);
54
- }
55
-
56
- /**
57
- * Duplicate logic from `@atlaskit/editor-common/ui` for MediaSingle.
58
- * `packages/editor/editor-common/src/ui/MediaSingle/index.tsx`
59
- *
60
- * WHY?
61
- * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
62
- * `@atlaskit/editor-common` from here or it will cause dependency issues.
63
- *
64
- * In the long term likely `toDOM` will move back out of `adf-schema` in which
65
- * case we can consolidate them.
66
- */
67
- function computeMediaSingleDimensions(_ref) {
68
- var childNode = _ref.childNode,
69
- mediaSingleWidth = _ref.mediaSingleWidth,
70
- widthType = _ref.widthType,
71
- editorWidth = _ref.editorWidth;
72
- var width = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width;
73
- var height = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height;
74
- if (!mediaSingleWidth && shouldAddDefaultWrappedWidth(childNode === null || childNode === void 0 ? void 0 : childNode.attrs.layout, width, editorWidth)) {
75
- mediaSingleWidth = widthType === 'pixel' ? editorWidth / 2 : 50;
76
+ var hasMediaDimensionWidth = typeof mediaSingleDimensionWidth === 'number';
77
+ if (!hasMediaDimensionWidth) {
78
+ return "calc((100% / 2) - ".concat(HALF_GUTTER_SIZE, ")");
76
79
  }
77
- var isHeightOnly = width === undefined;
78
- if (mediaSingleWidth) {
79
- var pxWidth = getMediaSinglePixelWidth(mediaSingleWidth, editorWidth, widthType, MEDIA_SINGLE_GUTTER_SIZE);
80
- if (isHeightOnly) {
81
- return {
82
- width: pxWidth - akEditorMediaResizeHandlerPaddingWide,
83
- height: height
84
- };
85
- } else {
86
- return {
87
- width: pxWidth,
88
- height: height / width * pxWidth
89
- };
90
- }
91
- } else if (isHeightOnly) {
92
- return {
93
- width: DEFAULT_EMBED_CARD_WIDTH - akEditorMediaResizeHandlerPaddingWide,
94
- height: height
95
- };
80
+ if (isPixelWidth) {
81
+ return "min(calc((var(--ak-editor-max-container-width, 100%) / 2) - ".concat(HALF_GUTTER_SIZE, "), ").concat(mediaSingleDimensionWidth, "px)");
96
82
  }
97
- return {
98
- height: height,
99
- width: width
100
- };
101
- }
102
- function computeLayoutStyles(width, layout) {
83
+ var hasChildMediaWidth = typeof childMediaWidth === 'number';
84
+ if (hasChildMediaWidth) {
85
+ return "min(calc(100% * (".concat(mediaSingleDimensionWidth, " / 100) - ").concat(HALF_GUTTER_SIZE, "), ").concat(childMediaWidth, "px)");
86
+ }
87
+ return "calc(100% * (".concat(mediaSingleDimensionWidth, " / 100) - ").concat(HALF_GUTTER_SIZE, ")");
88
+ };
89
+ var mediaProportionalWidthCSSCalc = exports.mediaProportionalWidthCSSCalc = function mediaProportionalWidthCSSCalc(_ref3) {
90
+ var isPixelWidth = _ref3.isPixelWidth,
91
+ isExtendedResizeExperience = _ref3.isExtendedResizeExperience,
92
+ mediaSingleDimensionWidth = _ref3.mediaSingleDimensionWidth,
93
+ isMediaWrapped = _ref3.isMediaWrapped;
94
+ var hasMediaWidth = typeof mediaSingleDimensionWidth === 'number';
95
+ if (isPixelWidth || isExtendedResizeExperience || !hasMediaWidth) {
96
+ return 'unset';
97
+ }
98
+ if (isMediaWrapped) {
99
+ return mediaSingleDimensionWidth >= 50 ? '1' : "".concat(1 - mediaSingleDimensionWidth / 100);
100
+ }
101
+ return "".concat(mediaSingleDimensionWidth / 100);
102
+ };
103
+ var mediaJustifyContentCSS = exports.mediaJustifyContentCSS = function mediaJustifyContentCSS(_ref4) {
104
+ var layout = _ref4.layout;
103
105
  switch (layout) {
104
106
  case 'align-end':
105
- return "margin-left: auto; margin-right: 0; width: ".concat(width, "px;");
107
+ case 'wrap-right':
108
+ return 'end';
106
109
  case 'align-start':
107
- return "margin-left: 0; margin-right: auto; width: ".concat(width, "px;");
108
- case 'center':
109
- return 'margin-left: auto; margin-right: auto;';
110
- case 'full-width':
111
- case 'wide':
112
- return 'width: 100%; margin-top: 56px; margin-bottom: 56px;';
113
110
  case 'wrap-left':
114
- return 'float: left;';
115
- case 'wrap-right':
116
- return 'float: right;';
111
+ return 'start';
112
+ default:
113
+ return 'center';
117
114
  }
118
- }
115
+ };
116
+ var prepareWrapperContentDOM = exports.prepareWrapperContentDOM = function prepareWrapperContentDOM(_ref5) {
117
+ var layout = _ref5.layout,
118
+ dataAttrs = _ref5.dataAttrs,
119
+ childMediaWidth = _ref5.childMediaWidth,
120
+ childMediaHeight = _ref5.childMediaHeight,
121
+ mediaSingleDimensionWidth = _ref5.mediaSingleDimensionWidth,
122
+ isPixelWidth = _ref5.isPixelWidth,
123
+ isExtendedResizeExperience = _ref5.isExtendedResizeExperience;
124
+ var layoutStyleJustifyContent = mediaJustifyContentCSS({
125
+ layout: layout
126
+ });
127
+ var mediaWidthCalc = mediaWidthCSSCalc({
128
+ layout: layout,
129
+ mediaSingleDimensionWidth: mediaSingleDimensionWidth,
130
+ baseWidth: childMediaWidth,
131
+ isPixelWidth: isPixelWidth,
132
+ isExtendedResizeExperience: isExtendedResizeExperience
133
+ });
134
+ var paddingBottom = "calc((".concat(childMediaHeight, " / ").concat(childMediaWidth, ") * 100%)");
135
+ return ['div', _objectSpread({
136
+ class: "rich-media-item mediaSingleView-content-wrap image-".concat(layout),
137
+ style: (0, _lazyNodeView.convertToInlineCss)({
138
+ display: 'flex',
139
+ justifyContent: layoutStyleJustifyContent,
140
+ transform: 'unset',
141
+ marginLeft: '0'
142
+ })
143
+ }, dataAttrs), ['div', {
144
+ style: (0, _lazyNodeView.convertToInlineCss)({
145
+ borderRadius: "var(--ds-border-radius, 3px)",
146
+ width: mediaWidthCalc,
147
+ minWidth: mediaWidthCalc,
148
+ color: "var(--ds-icon, ".concat(_colors.N50, ")")
149
+ })
150
+ }, ['figure', {
151
+ class: 'media-single-node',
152
+ style: (0, _lazyNodeView.convertToInlineCss)({
153
+ '--ak-editor-media-padding-bottom': paddingBottom,
154
+ margin: '0px'
155
+ })
156
+ }, ['div', {}, ['div', {
157
+ class: 'media-content-wrap'
158
+ }, 0]]]]];
159
+ };
160
+ var toDOM = exports.toDOM = function toDOM(node) {
161
+ var _mediaSingleAttrs$lay;
162
+ var mediaSingleAttrs = node.attrs;
163
+ var isPixelWidth = (mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType) === 'pixel';
164
+ var layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
165
+ var childNode = node.firstChild;
166
+ var isExternalMedia = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.type) === 'external';
167
+ var childMediaWidth = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width) || DEFAULT_IMAGE_WIDTH;
168
+ var childMediaHeight = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height) || DEFAULT_IMAGE_HEIGHT;
169
+ var dataAttrs = (0, _toDOMAttrs.getAttrsFromNodeMediaSingle)((0, _platformFeatureFlags.fg)('platform.editor.media.extended-resize-experience'), node);
170
+ var content = prepareWrapperContentDOM({
171
+ layout: layout,
172
+ dataAttrs: dataAttrs,
173
+ childMediaWidth: childMediaWidth,
174
+ childMediaHeight: childMediaHeight,
175
+ mediaSingleDimensionWidth: mediaSingleAttrs.width,
176
+ isPixelWidth: isPixelWidth,
177
+ isExtendedResizeExperience: (0, _platformFeatureFlags.fg)('platform.editor.media.extended-resize-experience')
178
+ });
179
+ var isMediaWrapped = WRAPPED_LAYOUTS.includes(layout);
180
+ var proportionCalc = mediaProportionalWidthCSSCalc({
181
+ isPixelWidth: isPixelWidth,
182
+ isMediaWrapped: isMediaWrapped,
183
+ mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width,
184
+ isExtendedResizeExperience: (0, _platformFeatureFlags.fg)('platform.editor.media.extended-resize-experience')
185
+ });
186
+ var contentWrapperWidth = mediaContentWrapperWidthCSSCalc({
187
+ isMediaWrapped: isMediaWrapped,
188
+ isExternalMedia: isExternalMedia,
189
+ isPixelWidth: isPixelWidth,
190
+ childMediaWidth: childMediaWidth,
191
+ mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width
192
+ });
193
+ return ['div', {
194
+ class: 'mediaSingleView-content-wrap',
195
+ layout: layout,
196
+ style: (0, _lazyNodeView.convertToInlineCss)({
197
+ '--ak-editor-media-single--proportion': proportionCalc,
198
+ '--ak-editor-media-card-display': 'block',
199
+ '--ak-editor-media-single--gutter-size': GUTTER_SIZE,
200
+ '--ak-editor-media-margin-right': '0',
201
+ '--ak-editor-media-card-background-color': "var(--ds-background-neutral, ".concat(_colors.N20, ")"),
202
+ marginTop: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
203
+ marginBottom: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
204
+ marginRight: isMediaWrapped ? layout === 'wrap-right' ? 'auto' : HALF_GUTTER_SIZE : 0,
205
+ marginLeft: isMediaWrapped ? layout === 'wrap-left' ? 'auto' : HALF_GUTTER_SIZE : 0,
206
+ width: contentWrapperWidth
207
+ })
208
+ }, content];
209
+ };
119
210
 
120
211
  // @nodeSpecException:toDOM patch
121
212
  var mediaSingleSpecWithFixedToDOM = exports.mediaSingleSpecWithFixedToDOM = function mediaSingleSpecWithFixedToDOM(mediaSingleOption) {
@@ -124,45 +215,6 @@ var mediaSingleSpecWithFixedToDOM = exports.mediaSingleSpecWithFixedToDOM = func
124
215
  return mediaSingleNode;
125
216
  }
126
217
  return _objectSpread(_objectSpread({}, mediaSingleNode), {}, {
127
- toDOM: function toDOM(node, lazyNodeViewOptions) {
128
- var _mediaSingleAttrs$lay;
129
- var mediaSingleAttrs = node.attrs;
130
- var layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
131
- var mediaSingleWidth = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width;
132
- var widthType = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType;
133
- var childNode = node.firstChild;
134
- var dataAttrs = (0, _toDOMAttrs.getAttrsFromNodeMediaSingle)(mediaSingleOption.withExtendedWidthTypes, node);
135
- var _computeMediaSingleDi = computeMediaSingleDimensions({
136
- childNode: childNode,
137
- widthType: widthType,
138
- mediaSingleWidth: mediaSingleWidth,
139
- editorWidth: (lazyNodeViewOptions === null || lazyNodeViewOptions === void 0 ? void 0 : lazyNodeViewOptions.editorLineWidth) || 760
140
- }),
141
- width = _computeMediaSingleDi.width,
142
- height = _computeMediaSingleDi.height;
143
- var sizes = width && height ? "width: ".concat(width, "px; height: ").concat(height, "px; ").concat(skeletonStyling) : '';
144
- var layoutStyles = computeLayoutStyles(mediaSingleWidth, layout);
145
- var style = "display: block; margin-top: ".concat("var(--ds-space-300, 24px)", "; margin-bottom: ", "var(--ds-space-300, 24px)", "; ", layoutStyles);
146
- var layoutClass = "image-".concat(layout);
147
- var centerLayout = "display: flex; justify-content: center;";
148
- var endLayout = "display: flex; justify-content: end;";
149
- var startLayout = "display: flex; justify-content: start;";
150
- var layoutStyle = layout === 'align-end' ? endLayout : layout === 'align-start' ? startLayout : centerLayout;
151
- var content = ['div', _objectSpread({
152
- class: "rich-media-item mediaSingleView-content-wrap ".concat(layoutClass)
153
- }, dataAttrs), ['div', {
154
- // Transparent image workaround to control styling
155
- style: "".concat(sizes, "; ").concat(style, "; max-width: 100%; border-radius: ", "var(--ds-border-radius, 3px)", "; ").concat(layoutStyle)
156
- }, ['figure', {
157
- class: 'media-single-node',
158
- style: 'margin: 0px'
159
- }, ['div', {}, ['div', {
160
- class: 'media-content-wrap'
161
- }, 0]]]]];
162
- return ['div', {
163
- class: 'mediaSingleView-content-wrap',
164
- layout: layout
165
- }, content];
166
- }
218
+ toDOM: toDOM
167
219
  });
168
220
  };
@@ -1,7 +1,7 @@
1
1
  import { media } from '@atlaskit/adf-schema';
2
+ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
2
3
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
4
  import { getMediaAttrs } from './toDOMAttrs';
4
- const skeletonStyling = `background: ${"var(--ds-background-neutral, #091E420F)"}; outline: none;`;
5
5
 
6
6
  /**
7
7
  * Duplicate consts from `media-card`.
@@ -28,12 +28,16 @@ export const mediaSpecWithFixedToDOM = () => {
28
28
  ...media,
29
29
  toDOM: node => {
30
30
  const attrs = getMediaAttrs('media', node);
31
- const styles = skeletonStyling;
32
31
  if (node.attrs.type === 'external') {
33
32
  return ['img', {
34
33
  ...attrs,
35
34
  src: node.attrs.url,
36
- styles
35
+ style: convertToInlineCss({
36
+ backgroundColor: `${"var(--ds-background-neutral, #091E420F)"}`,
37
+ outline: 'none',
38
+ width: `var(--ak-editor-media-card-width, 100%)`,
39
+ height: `var(--ak-editor-media-card-height, 100%)`
40
+ })
37
41
  }];
38
42
  }
39
43
  if (node.attrs.type === 'file') {
@@ -46,24 +50,28 @@ export const mediaSpecWithFixedToDOM = () => {
46
50
  ...attrs,
47
51
  // Manually kept in sync with the style of media cards. The goal is to render a plain gray
48
52
  // rectangle that provides an affordance for media.
49
- style: `
50
- display: inline-block;
51
- background-image: url("${dataUrl}");
52
- margin-left: 0;
53
- margin-right: 4px;
54
- border-radius: 3px;
55
- outline: none;
56
53
 
57
- flex-basis: ${defaultImageCardDimensions.width}px;
58
- background-color: var(--media-card-background-color);
59
- width: var(--media-card-width, ${node.attrs.width || width}px);
60
- height: var(--media-card-height, ${node.attrs.height || height}px);
61
- `
54
+ style: convertToInlineCss({
55
+ display: 'var(--ak-editor-media-card-display, inline-block)',
56
+ backgroundImage: `url("${dataUrl}")`,
57
+ marginLeft: '0',
58
+ marginRight: 'var(--ak-editor-media-margin-right, 4px)',
59
+ borderRadius: '3px',
60
+ outline: 'none',
61
+ flexBasis: `${defaultImageCardDimensions.width}px`,
62
+ backgroundColor: 'var(--ak-editor-media-card-background-color)',
63
+ width: `var(--ak-editor-media-card-width, 100%)`,
64
+ height: `var(--ak-editor-media-card-height, 0)`,
65
+ paddingBottom: `var(--ak-editor-media-padding-bottom, 0)`
66
+ })
62
67
  }];
63
68
  }
64
69
  return ['div', {
65
70
  ...attrs,
66
- styles
71
+ styles: convertToInlineCss({
72
+ backgroundColor: `var(--ak-editor-media-card-background-color, ${"var(--ds-background-neutral, #091E420F)"})`,
73
+ outline: 'none'
74
+ })
67
75
  }];
68
76
  }
69
77
  };
@@ -63,9 +63,9 @@ export const mediaGroupSpecWithFixedToDOM = () => {
63
63
  margin: 3px 5px;
64
64
  display: flex;
65
65
  gap: 8px;
66
- --media-card-background-color: #EBECF0;
67
- --media-card-width: ${defaultImageCardDimensions.width}px;
68
- --media-card-height: ${defaultImageCardDimensions.height}px;
66
+ --ak-editor-media-card-background-color: #EBECF0;
67
+ --ak-editor-media-card-width: ${defaultImageCardDimensions.width}px;
68
+ --ak-editor-media-card-height: ${defaultImageCardDimensions.height}px;
69
69
  `,
70
70
  'data-node-type': 'mediaGroup'
71
71
  }, 0];