@atlaskit/editor-plugin-media 1.28.3 → 1.28.5

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,20 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 1.28.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#129804](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/129804)
8
+ [`790a6fe6bc9e8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/790a6fe6bc9e8) -
9
+ [ED-24516] Fix VR test helpers for fallback LazyNodeViews
10
+ - Updated dependencies
11
+
12
+ ## 1.28.4
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 1.28.3
4
19
 
5
20
  ### Patch Changes
@@ -4,13 +4,31 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.mediaSpecWithFixedToDOM = void 0;
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
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
11
  var _toDOMAttrs = require("./toDOMAttrs");
12
12
  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
13
  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
+ /**
17
+ * Duplicate consts from `media-card`.
18
+ * `packages/media/media-card/src/utils/cardDimensions.ts`
19
+ *
20
+ * WHY?
21
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
22
+ * `media-card` from here or it will cause dependency issues.
23
+ *
24
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
25
+ * case we can consolidate them.
26
+ */
27
+ var defaultImageCardDimensions = exports.defaultImageCardDimensions = {
28
+ width: 156,
29
+ height: 125
30
+ };
31
+
14
32
  // @nodeSpecException:toDOM patch
15
33
  var mediaSpecWithFixedToDOM = exports.mediaSpecWithFixedToDOM = function mediaSpecWithFixedToDOM() {
16
34
  if (!(0, _platformFeatureFlags.fg)('platform_editor_lazy-node-views')) {
@@ -19,7 +37,29 @@ var mediaSpecWithFixedToDOM = exports.mediaSpecWithFixedToDOM = function mediaSp
19
37
  return _objectSpread(_objectSpread({}, _adfSchema.media), {}, {
20
38
  toDOM: function toDOM(node) {
21
39
  var attrs = (0, _toDOMAttrs.getMediaAttrs)('media', node);
22
- return ['div', attrs];
40
+ var styles = skeletonStyling;
41
+ if (node.attrs.type === 'external') {
42
+ return ['img', _objectSpread(_objectSpread({}, attrs), {}, {
43
+ src: node.attrs.url,
44
+ styles: styles
45
+ })];
46
+ }
47
+ if (node.attrs.type === 'file') {
48
+ var dataUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
49
+ var width = defaultImageCardDimensions.width;
50
+ var height = defaultImageCardDimensions.height;
51
+ return ['div', _objectSpread(_objectSpread({
52
+ width: width,
53
+ height: height
54
+ }, attrs), {}, {
55
+ // Manually kept in sync with the style of media cards. The goal is to render a plain gray
56
+ // 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: ").concat(skeletonStyling, ";\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, unset);\n\t\t\t\t\t\twidth: var(--media-card-width, 0);\n\t\t\t\t\t\theight: var(--media-card-height, 0);\n\t\t\t\t\t\t")
58
+ })];
59
+ }
60
+ return ['div', _objectSpread(_objectSpread({}, attrs), {}, {
61
+ styles: styles
62
+ })];
23
63
  }
24
64
  });
25
65
  };
@@ -10,8 +10,6 @@ var _adfSchema = require("@atlaskit/adf-schema");
10
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
11
  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; }
12
12
  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; }
13
- var skeletonStyling = "background: ".concat("var(--ds-background-neutral, #091E420F)", ";");
14
-
15
13
  /**
16
14
  * Duplicate consts from `media-card`.
17
15
  * `packages/media/media-card/src/utils/cardDimensions.ts`
@@ -68,27 +66,11 @@ var mediaGroupSpecWithFixedToDOM = exports.mediaGroupSpecWithFixedToDOM = functi
68
66
  }
69
67
  return _objectSpread(_objectSpread({}, _adfSchema.mediaGroup), {}, {
70
68
  toDOM: function toDOM(node) {
71
- var childNodes = [];
72
- for (var i = 0; i < node.childCount; i++) {
73
- var _getDefaultCardDimens = getDefaultCardDimensions(),
74
- width = _getDefaultCardDimens.width,
75
- height = _getDefaultCardDimens.height;
76
- var nodeHolder = ['img', {
77
- width: width,
78
- height: height,
79
- // Transparent image workaround to control styling
80
- src: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
81
- style: "margin-left: ".concat(i !== 0 ? "4px" : '0', "; margin-right: 4px; border-radius: ", "var(--ds-border-radius, 3px)", "; ").concat(skeletonStyling)
82
- }];
83
- childNodes.push(nodeHolder);
84
- }
85
-
86
69
  // Margin margin that consolidates the margin in the
87
70
  return ['div', {
88
- style: 'margin: "3px 5px";',
89
- // From adf-schema
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"),
90
72
  'data-node-type': 'mediaGroup'
91
- }].concat(childNodes);
73
+ }, 0];
92
74
  }
93
75
  });
94
76
  };
@@ -67,11 +67,8 @@ function getMediaSinglePixelWidth(width, editorWidth) {
67
67
  function computeMediaSingleDimensions(_ref) {
68
68
  var childNode = _ref.childNode,
69
69
  mediaSingleWidth = _ref.mediaSingleWidth,
70
- widthType = _ref.widthType;
71
- // TODO: We can't retrieve the editor width from here easily.
72
- // For now we're using the default line length here, but this will be
73
- // incorrect on smaller devices.
74
- var editorWidth = 760;
70
+ widthType = _ref.widthType,
71
+ editorWidth = _ref.editorWidth;
75
72
  var width = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width;
76
73
  var height = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height;
77
74
  if (!mediaSingleWidth && shouldAddDefaultWrappedWidth(childNode === null || childNode === void 0 ? void 0 : childNode.attrs.layout, width, editorWidth)) {
@@ -127,36 +124,44 @@ var mediaSingleSpecWithFixedToDOM = exports.mediaSingleSpecWithFixedToDOM = func
127
124
  return mediaSingleNode;
128
125
  }
129
126
  return _objectSpread(_objectSpread({}, mediaSingleNode), {}, {
130
- toDOM: function toDOM(node) {
127
+ toDOM: function toDOM(node, lazyNodeViewOptions) {
131
128
  var _mediaSingleAttrs$lay;
132
- var childNode = node.firstChild;
133
129
  var mediaSingleAttrs = node.attrs;
134
130
  var layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
135
131
  var mediaSingleWidth = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width;
136
132
  var widthType = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType;
133
+ var childNode = node.firstChild;
137
134
  var dataAttrs = (0, _toDOMAttrs.getAttrsFromNodeMediaSingle)(mediaSingleOption.withExtendedWidthTypes, node);
138
135
  var _computeMediaSingleDi = computeMediaSingleDimensions({
139
136
  childNode: childNode,
140
137
  widthType: widthType,
141
- mediaSingleWidth: mediaSingleWidth
138
+ mediaSingleWidth: mediaSingleWidth,
139
+ editorWidth: (lazyNodeViewOptions === null || lazyNodeViewOptions === void 0 ? void 0 : lazyNodeViewOptions.editorLineWidth) || 760
142
140
  }),
143
141
  width = _computeMediaSingleDi.width,
144
142
  height = _computeMediaSingleDi.height;
145
- var layoutStyles = computeLayoutStyles(width, layout);
143
+ var sizes = width && height ? "width: ".concat(width, "px; height: ").concat(height, "px; ").concat(skeletonStyling) : '';
144
+ var layoutStyles = computeLayoutStyles(mediaSingleWidth, layout);
146
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;
147
151
  var content = ['div', _objectSpread({
148
- class: 'rich-media-item mediaSingleView-content-wrap image-center'
152
+ class: "rich-media-item mediaSingleView-content-wrap ".concat(layoutClass)
149
153
  }, dataAttrs), ['div', {
150
- class: 'css-13f4nzt-MediaWrapper',
151
154
  // Transparent image workaround to control styling
152
- style: "width: ".concat(width, "px; height: ").concat(height, "px; ").concat(style, " ").concat(skeletonStyling, " border-radius: ", "var(--ds-border-radius, 3px)", ";")
155
+ style: "".concat(sizes, "; ").concat(style, "; max-width: 100%; border-radius: ", "var(--ds-border-radius, 3px)", "; ").concat(layoutStyle)
153
156
  }, ['figure', {
154
- class: 'media-single-node'
157
+ class: 'media-single-node',
158
+ style: 'margin: 0px'
155
159
  }, ['div', {}, ['div', {
156
160
  class: 'media-content-wrap'
157
161
  }, 0]]]]];
158
162
  return ['div', {
159
- class: 'mediaSingleView-content-wrap'
163
+ class: 'mediaSingleView-content-wrap',
164
+ layout: layout
160
165
  }, content];
161
166
  }
162
167
  });
@@ -1,6 +1,23 @@
1
1
  import { media } from '@atlaskit/adf-schema';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
3
  import { getMediaAttrs } from './toDOMAttrs';
4
+ const skeletonStyling = `background: ${"var(--ds-background-neutral, #091E420F)"}; outline: none;`;
5
+
6
+ /**
7
+ * Duplicate consts from `media-card`.
8
+ * `packages/media/media-card/src/utils/cardDimensions.ts`
9
+ *
10
+ * WHY?
11
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
12
+ * `media-card` from here or it will cause dependency issues.
13
+ *
14
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
15
+ * case we can consolidate them.
16
+ */
17
+ export const defaultImageCardDimensions = {
18
+ width: 156,
19
+ height: 125
20
+ };
4
21
 
5
22
  // @nodeSpecException:toDOM patch
6
23
  export const mediaSpecWithFixedToDOM = () => {
@@ -11,7 +28,42 @@ export const mediaSpecWithFixedToDOM = () => {
11
28
  ...media,
12
29
  toDOM: node => {
13
30
  const attrs = getMediaAttrs('media', node);
14
- return ['div', attrs];
31
+ const styles = skeletonStyling;
32
+ if (node.attrs.type === 'external') {
33
+ return ['img', {
34
+ ...attrs,
35
+ src: node.attrs.url,
36
+ styles
37
+ }];
38
+ }
39
+ if (node.attrs.type === 'file') {
40
+ const dataUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
41
+ const width = defaultImageCardDimensions.width;
42
+ const height = defaultImageCardDimensions.height;
43
+ return ['div', {
44
+ width,
45
+ height,
46
+ ...attrs,
47
+ // Manually kept in sync with the style of media cards. The goal is to render a plain gray
48
+ // 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: ${skeletonStyling};
55
+
56
+ flex-basis: ${defaultImageCardDimensions.width}px;
57
+ background-color: var(--media-card-background-color, unset);
58
+ width: var(--media-card-width, 0);
59
+ height: var(--media-card-height, 0);
60
+ `
61
+ }];
62
+ }
63
+ return ['div', {
64
+ ...attrs,
65
+ styles
66
+ }];
15
67
  }
16
68
  };
17
69
  };
@@ -1,6 +1,5 @@
1
1
  import { mediaGroup } from '@atlaskit/adf-schema';
2
2
  import { fg } from '@atlaskit/platform-feature-flags';
3
- const skeletonStyling = `background: ${"var(--ds-background-neutral, #091E420F)"};`;
4
3
 
5
4
  /**
6
5
  * Duplicate consts from `media-card`.
@@ -58,28 +57,18 @@ export const mediaGroupSpecWithFixedToDOM = () => {
58
57
  return {
59
58
  ...mediaGroup,
60
59
  toDOM: node => {
61
- const childNodes = [];
62
- for (let i = 0; i < node.childCount; i++) {
63
- const {
64
- width,
65
- height
66
- } = getDefaultCardDimensions();
67
- const nodeHolder = ['img', {
68
- width,
69
- height,
70
- // Transparent image workaround to control styling
71
- src: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
72
- style: `margin-left: ${i !== 0 ? `4px` : '0'}; margin-right: 4px; border-radius: ${"var(--ds-border-radius, 3px)"}; ${skeletonStyling}`
73
- }];
74
- childNodes.push(nodeHolder);
75
- }
76
-
77
60
  // Margin margin that consolidates the margin in the
78
61
  return ['div', {
79
- style: 'margin: "3px 5px";',
80
- // From adf-schema
62
+ style: `
63
+ margin: 3px 5px;
64
+ display: flex;
65
+ gap: 8px;
66
+ --media-card-background-color: #EBECF0;
67
+ --media-card-width: ${defaultImageCardDimensions.width}px;
68
+ --media-card-height: ${defaultImageCardDimensions.height}px;
69
+ `,
81
70
  'data-node-type': 'mediaGroup'
82
- }, ...childNodes];
71
+ }, 0];
83
72
  }
84
73
  };
85
74
  };
@@ -54,12 +54,9 @@ export function getMediaSinglePixelWidth(width, editorWidth, widthType = 'percen
54
54
  function computeMediaSingleDimensions({
55
55
  childNode,
56
56
  mediaSingleWidth,
57
- widthType
57
+ widthType,
58
+ editorWidth
58
59
  }) {
59
- // TODO: We can't retrieve the editor width from here easily.
60
- // For now we're using the default line length here, but this will be
61
- // incorrect on smaller devices.
62
- const editorWidth = 760;
63
60
  const width = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width;
64
61
  const height = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height;
65
62
  if (!mediaSingleWidth && shouldAddDefaultWrappedWidth(childNode === null || childNode === void 0 ? void 0 : childNode.attrs.layout, width, editorWidth)) {
@@ -116,13 +113,13 @@ export const mediaSingleSpecWithFixedToDOM = mediaSingleOption => {
116
113
  }
117
114
  return {
118
115
  ...mediaSingleNode,
119
- toDOM: node => {
116
+ toDOM: (node, lazyNodeViewOptions) => {
120
117
  var _mediaSingleAttrs$lay;
121
- const childNode = node.firstChild;
122
118
  const mediaSingleAttrs = node.attrs;
123
119
  const layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
124
120
  const mediaSingleWidth = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width;
125
121
  const widthType = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType;
122
+ const childNode = node.firstChild;
126
123
  const dataAttrs = getAttrsFromNodeMediaSingle(mediaSingleOption.withExtendedWidthTypes, node);
127
124
  const {
128
125
  width,
@@ -130,24 +127,32 @@ export const mediaSingleSpecWithFixedToDOM = mediaSingleOption => {
130
127
  } = computeMediaSingleDimensions({
131
128
  childNode,
132
129
  widthType,
133
- mediaSingleWidth
130
+ mediaSingleWidth,
131
+ editorWidth: (lazyNodeViewOptions === null || lazyNodeViewOptions === void 0 ? void 0 : lazyNodeViewOptions.editorLineWidth) || 760
134
132
  });
135
- const layoutStyles = computeLayoutStyles(width, layout);
133
+ const sizes = width && height ? `width: ${width}px; height: ${height}px; ${skeletonStyling}` : '';
134
+ const layoutStyles = computeLayoutStyles(mediaSingleWidth, layout);
136
135
  const style = `display: block; margin-top: ${"var(--ds-space-300, 24px)"}; margin-bottom: ${"var(--ds-space-300, 24px)"}; ${layoutStyles}`;
136
+ const layoutClass = `image-${layout}`;
137
+ const centerLayout = `display: flex; justify-content: center;`;
138
+ const endLayout = `display: flex; justify-content: end;`;
139
+ const startLayout = `display: flex; justify-content: start;`;
140
+ const layoutStyle = layout === 'align-end' ? endLayout : layout === 'align-start' ? startLayout : centerLayout;
137
141
  const content = ['div', {
138
- class: 'rich-media-item mediaSingleView-content-wrap image-center',
142
+ class: `rich-media-item mediaSingleView-content-wrap ${layoutClass}`,
139
143
  ...dataAttrs
140
144
  }, ['div', {
141
- class: 'css-13f4nzt-MediaWrapper',
142
145
  // Transparent image workaround to control styling
143
- style: `width: ${width}px; height: ${height}px; ${style} ${skeletonStyling} border-radius: ${"var(--ds-border-radius, 3px)"};`
146
+ style: `${sizes}; ${style}; max-width: 100%; border-radius: ${"var(--ds-border-radius, 3px)"}; ${layoutStyle}`
144
147
  }, ['figure', {
145
- class: 'media-single-node'
148
+ class: 'media-single-node',
149
+ style: 'margin: 0px'
146
150
  }, ['div', {}, ['div', {
147
151
  class: 'media-content-wrap'
148
152
  }, 0]]]]];
149
153
  return ['div', {
150
- class: 'mediaSingleView-content-wrap'
154
+ class: 'mediaSingleView-content-wrap',
155
+ layout
151
156
  }, content];
152
157
  }
153
158
  };
@@ -4,6 +4,23 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { media } from '@atlaskit/adf-schema';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
6
  import { getMediaAttrs } from './toDOMAttrs';
7
+ var skeletonStyling = "background: ".concat("var(--ds-background-neutral, #091E420F)", "; outline: none;");
8
+
9
+ /**
10
+ * Duplicate consts from `media-card`.
11
+ * `packages/media/media-card/src/utils/cardDimensions.ts`
12
+ *
13
+ * WHY?
14
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
15
+ * `media-card` from here or it will cause dependency issues.
16
+ *
17
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
18
+ * case we can consolidate them.
19
+ */
20
+ export var defaultImageCardDimensions = {
21
+ width: 156,
22
+ height: 125
23
+ };
7
24
 
8
25
  // @nodeSpecException:toDOM patch
9
26
  export var mediaSpecWithFixedToDOM = function mediaSpecWithFixedToDOM() {
@@ -13,7 +30,29 @@ export var mediaSpecWithFixedToDOM = function mediaSpecWithFixedToDOM() {
13
30
  return _objectSpread(_objectSpread({}, media), {}, {
14
31
  toDOM: function toDOM(node) {
15
32
  var attrs = getMediaAttrs('media', node);
16
- return ['div', attrs];
33
+ var styles = skeletonStyling;
34
+ if (node.attrs.type === 'external') {
35
+ return ['img', _objectSpread(_objectSpread({}, attrs), {}, {
36
+ src: node.attrs.url,
37
+ styles: styles
38
+ })];
39
+ }
40
+ if (node.attrs.type === 'file') {
41
+ var dataUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
42
+ var width = defaultImageCardDimensions.width;
43
+ var height = defaultImageCardDimensions.height;
44
+ return ['div', _objectSpread(_objectSpread({
45
+ width: width,
46
+ height: height
47
+ }, attrs), {}, {
48
+ // Manually kept in sync with the style of media cards. The goal is to render a plain gray
49
+ // rectangle that provides an affordance for media.
50
+ 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: ").concat(skeletonStyling, ";\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, unset);\n\t\t\t\t\t\twidth: var(--media-card-width, 0);\n\t\t\t\t\t\theight: var(--media-card-height, 0);\n\t\t\t\t\t\t")
51
+ })];
52
+ }
53
+ return ['div', _objectSpread(_objectSpread({}, attrs), {}, {
54
+ styles: styles
55
+ })];
17
56
  }
18
57
  });
19
58
  };
@@ -3,7 +3,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  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; }
4
4
  import { mediaGroup } from '@atlaskit/adf-schema';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
- var skeletonStyling = "background: ".concat("var(--ds-background-neutral, #091E420F)", ";");
7
6
 
8
7
  /**
9
8
  * Duplicate consts from `media-card`.
@@ -61,27 +60,11 @@ export var mediaGroupSpecWithFixedToDOM = function mediaGroupSpecWithFixedToDOM(
61
60
  }
62
61
  return _objectSpread(_objectSpread({}, mediaGroup), {}, {
63
62
  toDOM: function toDOM(node) {
64
- var childNodes = [];
65
- for (var i = 0; i < node.childCount; i++) {
66
- var _getDefaultCardDimens = getDefaultCardDimensions(),
67
- width = _getDefaultCardDimens.width,
68
- height = _getDefaultCardDimens.height;
69
- var nodeHolder = ['img', {
70
- width: width,
71
- height: height,
72
- // Transparent image workaround to control styling
73
- src: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
74
- style: "margin-left: ".concat(i !== 0 ? "4px" : '0', "; margin-right: 4px; border-radius: ", "var(--ds-border-radius, 3px)", "; ").concat(skeletonStyling)
75
- }];
76
- childNodes.push(nodeHolder);
77
- }
78
-
79
63
  // Margin margin that consolidates the margin in the
80
64
  return ['div', {
81
- style: 'margin: "3px 5px";',
82
- // From adf-schema
65
+ 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"),
83
66
  'data-node-type': 'mediaGroup'
84
- }].concat(childNodes);
67
+ }, 0];
85
68
  }
86
69
  });
87
70
  };
@@ -59,11 +59,8 @@ export function getMediaSinglePixelWidth(width, editorWidth) {
59
59
  function computeMediaSingleDimensions(_ref) {
60
60
  var childNode = _ref.childNode,
61
61
  mediaSingleWidth = _ref.mediaSingleWidth,
62
- widthType = _ref.widthType;
63
- // TODO: We can't retrieve the editor width from here easily.
64
- // For now we're using the default line length here, but this will be
65
- // incorrect on smaller devices.
66
- var editorWidth = 760;
62
+ widthType = _ref.widthType,
63
+ editorWidth = _ref.editorWidth;
67
64
  var width = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width;
68
65
  var height = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height;
69
66
  if (!mediaSingleWidth && shouldAddDefaultWrappedWidth(childNode === null || childNode === void 0 ? void 0 : childNode.attrs.layout, width, editorWidth)) {
@@ -119,36 +116,44 @@ export var mediaSingleSpecWithFixedToDOM = function mediaSingleSpecWithFixedToDO
119
116
  return mediaSingleNode;
120
117
  }
121
118
  return _objectSpread(_objectSpread({}, mediaSingleNode), {}, {
122
- toDOM: function toDOM(node) {
119
+ toDOM: function toDOM(node, lazyNodeViewOptions) {
123
120
  var _mediaSingleAttrs$lay;
124
- var childNode = node.firstChild;
125
121
  var mediaSingleAttrs = node.attrs;
126
122
  var layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
127
123
  var mediaSingleWidth = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width;
128
124
  var widthType = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType;
125
+ var childNode = node.firstChild;
129
126
  var dataAttrs = getAttrsFromNodeMediaSingle(mediaSingleOption.withExtendedWidthTypes, node);
130
127
  var _computeMediaSingleDi = computeMediaSingleDimensions({
131
128
  childNode: childNode,
132
129
  widthType: widthType,
133
- mediaSingleWidth: mediaSingleWidth
130
+ mediaSingleWidth: mediaSingleWidth,
131
+ editorWidth: (lazyNodeViewOptions === null || lazyNodeViewOptions === void 0 ? void 0 : lazyNodeViewOptions.editorLineWidth) || 760
134
132
  }),
135
133
  width = _computeMediaSingleDi.width,
136
134
  height = _computeMediaSingleDi.height;
137
- var layoutStyles = computeLayoutStyles(width, layout);
135
+ var sizes = width && height ? "width: ".concat(width, "px; height: ").concat(height, "px; ").concat(skeletonStyling) : '';
136
+ var layoutStyles = computeLayoutStyles(mediaSingleWidth, layout);
138
137
  var style = "display: block; margin-top: ".concat("var(--ds-space-300, 24px)", "; margin-bottom: ", "var(--ds-space-300, 24px)", "; ", layoutStyles);
138
+ var layoutClass = "image-".concat(layout);
139
+ var centerLayout = "display: flex; justify-content: center;";
140
+ var endLayout = "display: flex; justify-content: end;";
141
+ var startLayout = "display: flex; justify-content: start;";
142
+ var layoutStyle = layout === 'align-end' ? endLayout : layout === 'align-start' ? startLayout : centerLayout;
139
143
  var content = ['div', _objectSpread({
140
- class: 'rich-media-item mediaSingleView-content-wrap image-center'
144
+ class: "rich-media-item mediaSingleView-content-wrap ".concat(layoutClass)
141
145
  }, dataAttrs), ['div', {
142
- class: 'css-13f4nzt-MediaWrapper',
143
146
  // Transparent image workaround to control styling
144
- style: "width: ".concat(width, "px; height: ").concat(height, "px; ").concat(style, " ").concat(skeletonStyling, " border-radius: ", "var(--ds-border-radius, 3px)", ";")
147
+ style: "".concat(sizes, "; ").concat(style, "; max-width: 100%; border-radius: ", "var(--ds-border-radius, 3px)", "; ").concat(layoutStyle)
145
148
  }, ['figure', {
146
- class: 'media-single-node'
149
+ class: 'media-single-node',
150
+ style: 'margin: 0px'
147
151
  }, ['div', {}, ['div', {
148
152
  class: 'media-content-wrap'
149
153
  }, 0]]]]];
150
154
  return ['div', {
151
- class: 'mediaSingleView-content-wrap'
155
+ class: 'mediaSingleView-content-wrap',
156
+ layout: layout
152
157
  }, content];
153
158
  }
154
159
  });
@@ -1 +1,16 @@
1
+ /**
2
+ * Duplicate consts from `media-card`.
3
+ * `packages/media/media-card/src/utils/cardDimensions.ts`
4
+ *
5
+ * WHY?
6
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
7
+ * `media-card` from here or it will cause dependency issues.
8
+ *
9
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
10
+ * case we can consolidate them.
11
+ */
12
+ export declare const defaultImageCardDimensions: {
13
+ width: number;
14
+ height: number;
15
+ };
1
16
  export declare const mediaSpecWithFixedToDOM: () => import("prosemirror-model").NodeSpec;
@@ -1,3 +1,4 @@
1
+ import type { NodeSpec } from '@atlaskit/editor-prosemirror/model';
1
2
  export declare const wrappedLayouts: string[];
2
3
  /**
3
4
  * Duplicate of method from `@atlaskit/editor-common/utils`.
@@ -26,4 +27,4 @@ export declare function getMediaSinglePixelWidth(width: number, editorWidth: num
26
27
  export declare const mediaSingleSpecWithFixedToDOM: (mediaSingleOption: {
27
28
  withCaption?: boolean;
28
29
  withExtendedWidthTypes: boolean;
29
- }) => import("prosemirror-model").NodeSpec;
30
+ }) => NodeSpec;
@@ -1 +1,16 @@
1
+ /**
2
+ * Duplicate consts from `media-card`.
3
+ * `packages/media/media-card/src/utils/cardDimensions.ts`
4
+ *
5
+ * WHY?
6
+ * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
7
+ * `media-card` from here or it will cause dependency issues.
8
+ *
9
+ * In the long term likely `toDOM` will move back out of `adf-schema` in which
10
+ * case we can consolidate them.
11
+ */
12
+ export declare const defaultImageCardDimensions: {
13
+ width: number;
14
+ height: number;
15
+ };
1
16
  export declare const mediaSpecWithFixedToDOM: () => import("prosemirror-model").NodeSpec;
@@ -1,3 +1,4 @@
1
+ import type { NodeSpec } from '@atlaskit/editor-prosemirror/model';
1
2
  export declare const wrappedLayouts: string[];
2
3
  /**
3
4
  * Duplicate of method from `@atlaskit/editor-common/utils`.
@@ -26,4 +27,4 @@ export declare function getMediaSinglePixelWidth(width: number, editorWidth: num
26
27
  export declare const mediaSingleSpecWithFixedToDOM: (mediaSingleOption: {
27
28
  withCaption?: boolean;
28
29
  withExtendedWidthTypes: boolean;
29
- }) => import("prosemirror-model").NodeSpec;
30
+ }) => NodeSpec;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "1.28.3",
3
+ "version": "1.28.5",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -36,8 +36,8 @@
36
36
  "@atlaskit/adf-schema": "^40.8.1",
37
37
  "@atlaskit/analytics-namespaced-context": "^6.11.0",
38
38
  "@atlaskit/analytics-next": "^10.1.0",
39
- "@atlaskit/button": "^19.2.0",
40
- "@atlaskit/editor-common": "^87.10.0",
39
+ "@atlaskit/button": "^20.0.0",
40
+ "@atlaskit/editor-common": "^87.11.0",
41
41
  "@atlaskit/editor-palette": "1.6.0",
42
42
  "@atlaskit/editor-plugin-analytics": "^1.7.0",
43
43
  "@atlaskit/editor-plugin-annotation": "1.19.0",
@@ -54,14 +54,14 @@
54
54
  "@atlaskit/editor-shared-styles": "^2.13.0",
55
55
  "@atlaskit/editor-tables": "^2.8.0",
56
56
  "@atlaskit/form": "^10.5.0",
57
- "@atlaskit/icon": "^22.12.0",
57
+ "@atlaskit/icon": "^22.13.0",
58
58
  "@atlaskit/media-card": "^78.0.0",
59
59
  "@atlaskit/media-client": "^27.3.0",
60
60
  "@atlaskit/media-client-react": "^2.0.0",
61
61
  "@atlaskit/media-common": "^11.3.0",
62
62
  "@atlaskit/media-filmstrip": "^47.2.0",
63
- "@atlaskit/media-picker": "^66.4.0",
64
- "@atlaskit/media-ui": "^25.10.0",
63
+ "@atlaskit/media-picker": "^66.5.0",
64
+ "@atlaskit/media-ui": "^25.11.0",
65
65
  "@atlaskit/media-viewer": "^48.7.0",
66
66
  "@atlaskit/platform-feature-flags": "^0.3.0",
67
67
  "@atlaskit/primitives": "^12.0.0",