@atlaskit/editor-plugin-media 1.34.7 → 1.34.9

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 (31) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/cjs/nodeviews/mediaSingle.js +11 -3
  3. package/dist/cjs/toDOM-fixes/media.js +25 -6
  4. package/dist/cjs/toDOM-fixes/mediaGroup.js +1 -1
  5. package/dist/cjs/toDOM-fixes/mediaSingle.js +189 -137
  6. package/dist/cjs/ui/CaptionPlaceholder/index.js +42 -7
  7. package/dist/cjs/ui/PixelEntry/index.js +8 -3
  8. package/dist/cjs/ui/PixelEntry/styles.js +3 -6
  9. package/dist/es2019/nodeviews/mediaSingle.js +11 -3
  10. package/dist/es2019/toDOM-fixes/media.js +24 -16
  11. package/dist/es2019/toDOM-fixes/mediaGroup.js +3 -3
  12. package/dist/es2019/toDOM-fixes/mediaSingle.js +194 -136
  13. package/dist/es2019/ui/CaptionPlaceholder/index.js +39 -6
  14. package/dist/es2019/ui/PixelEntry/index.js +10 -5
  15. package/dist/es2019/ui/PixelEntry/styles.js +2 -5
  16. package/dist/esm/nodeviews/mediaSingle.js +11 -3
  17. package/dist/esm/toDOM-fixes/media.js +25 -5
  18. package/dist/esm/toDOM-fixes/mediaGroup.js +1 -1
  19. package/dist/esm/toDOM-fixes/mediaSingle.js +188 -135
  20. package/dist/esm/ui/CaptionPlaceholder/index.js +38 -6
  21. package/dist/esm/ui/PixelEntry/index.js +10 -5
  22. package/dist/esm/ui/PixelEntry/styles.js +2 -5
  23. package/dist/types/nodeviews/mediaSingle.d.ts +1 -1
  24. package/dist/types/toDOM-fixes/mediaSingle.d.ts +41 -26
  25. package/dist/types/ui/CaptionPlaceholder/index.d.ts +4 -2
  26. package/dist/types/ui/PixelEntry/styles.d.ts +0 -1
  27. package/dist/types-ts4.5/nodeviews/mediaSingle.d.ts +1 -1
  28. package/dist/types-ts4.5/toDOM-fixes/mediaSingle.d.ts +41 -26
  29. package/dist/types-ts4.5/ui/CaptionPlaceholder/index.d.ts +4 -2
  30. package/dist/types-ts4.5/ui/PixelEntry/styles.d.ts +0 -1
  31. package/package.json +5 -9
@@ -2,9 +2,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
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 { media } from '@atlaskit/adf-schema';
5
+ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
5
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
7
  import { getMediaAttrs } from './toDOMAttrs';
7
- var skeletonStyling = "background: ".concat("var(--ds-background-neutral, #091E420F)", "; outline: none;");
8
8
 
9
9
  /**
10
10
  * Duplicate consts from `media-card`.
@@ -30,11 +30,15 @@ export var mediaSpecWithFixedToDOM = function mediaSpecWithFixedToDOM() {
30
30
  return _objectSpread(_objectSpread({}, media), {}, {
31
31
  toDOM: function toDOM(node) {
32
32
  var attrs = getMediaAttrs('media', node);
33
- var styles = skeletonStyling;
34
33
  if (node.attrs.type === 'external') {
35
34
  return ['img', _objectSpread(_objectSpread({}, attrs), {}, {
36
35
  src: node.attrs.url,
37
- styles: styles
36
+ style: convertToInlineCss({
37
+ backgroundColor: "var(--ds-background-neutral, #091E420F)",
38
+ outline: 'none',
39
+ width: "var(--ak-editor-media-card-width, 100%)",
40
+ height: "var(--ak-editor-media-card-height, 100%)"
41
+ })
38
42
  })];
39
43
  }
40
44
  if (node.attrs.type === 'file') {
@@ -47,11 +51,27 @@ export var mediaSpecWithFixedToDOM = function mediaSpecWithFixedToDOM() {
47
51
  }, attrs), {}, {
48
52
  // Manually kept in sync with the style of media cards. The goal is to render a plain gray
49
53
  // 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: 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")
54
+
55
+ style: convertToInlineCss({
56
+ display: 'var(--ak-editor-media-card-display, inline-block)',
57
+ backgroundImage: "url(\"".concat(dataUrl, "\")"),
58
+ marginLeft: '0',
59
+ marginRight: 'var(--ak-editor-media-margin-right, 4px)',
60
+ borderRadius: '3px',
61
+ outline: 'none',
62
+ flexBasis: "".concat(defaultImageCardDimensions.width, "px"),
63
+ backgroundColor: 'var(--ak-editor-media-card-background-color)',
64
+ width: "var(--ak-editor-media-card-width, 100%)",
65
+ height: "var(--ak-editor-media-card-height, 0)",
66
+ paddingBottom: "var(--ak-editor-media-padding-bottom, 0)"
67
+ })
51
68
  })];
52
69
  }
53
70
  return ['div', _objectSpread(_objectSpread({}, attrs), {}, {
54
- styles: styles
71
+ styles: convertToInlineCss({
72
+ backgroundColor: "var(--ak-editor-media-card-background-color, ".concat("var(--ds-background-neutral, #091E420F)", ")"),
73
+ outline: 'none'
74
+ })
55
75
  })];
56
76
  }
57
77
  });
@@ -62,7 +62,7 @@ export var mediaGroupSpecWithFixedToDOM = function mediaGroupSpecWithFixedToDOM(
62
62
  toDOM: function toDOM(node) {
63
63
  // Margin margin that consolidates the margin in the
64
64
  return ['div', {
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"),
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--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"),
66
66
  'data-node-type': 'mediaGroup'
67
67
  }, 0];
68
68
  }
@@ -2,112 +2,204 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
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 { mediaSingleSpec } from '@atlaskit/adf-schema';
5
+ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
7
+ import { N20, N50 } from '@atlaskit/theme/colors';
5
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
9
  import { getAttrsFromNodeMediaSingle } from './toDOMAttrs';
7
- var skeletonStyling = "background: ".concat("var(--ds-background-neutral, #091E420F)", "; outline: none;");
8
- export var wrappedLayouts = ['wrap-left', 'wrap-right', 'align-end', 'align-start'];
9
-
10
- /**
11
- * Duplicate of method from `@atlaskit/editor-common/utils`.
12
- * `packages/editor/editor-common/src/utils/rich-media-utils.ts`
13
- *
14
- * WHY?
15
- * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
16
- * `@atlaskit/editor-common` from here or it will cause dependency issues.
17
- *
18
- * In the long term likely `toDOM` will move back out of `adf-schema` in which
19
- * case we can consolidate them.
20
- */
21
- export var shouldAddDefaultWrappedWidth = function shouldAddDefaultWrappedWidth(layout, width, lineLength) {
22
- return wrappedLayouts.indexOf(layout) > -1 && lineLength && width && width > 0.5 * lineLength;
10
+ var WRAPPED_LAYOUTS = ['wrap-left', 'wrap-right'];
11
+ var ALIGNED_LAYOUTS = ['align-end', 'align-start'];
12
+ var LEGACY_LAYOUTS = ['full-width', 'wide'];
13
+ var DEFAULT_IMAGE_WIDTH = 250;
14
+ var DEFAULT_IMAGE_HEIGHT = 200;
15
+ var GUTTER_SIZE = '24px';
16
+ var HALF_GUTTER_SIZE = '12px';
17
+ export var mediaWidthCSSCalc = function mediaWidthCSSCalc(_ref) {
18
+ var mediaSingleDimensionWidth = _ref.mediaSingleDimensionWidth,
19
+ layout = _ref.layout,
20
+ baseWidth = _ref.baseWidth,
21
+ isPixelWidth = _ref.isPixelWidth,
22
+ isExtendedResizeExperience = _ref.isExtendedResizeExperience;
23
+ var hasMediaDimensionWidth = typeof mediaSingleDimensionWidth === 'number';
24
+ var isMediaWrapped = WRAPPED_LAYOUTS.includes(layout);
25
+ var isMediaAligned = ALIGNED_LAYOUTS.includes(layout);
26
+ var isMediaLegacyLayout = LEGACY_LAYOUTS.includes(layout);
27
+ var shouldUseAlignedLayoutCalc = isMediaAligned && !hasMediaDimensionWidth;
28
+ var shouldUseWrappedLayoutCalc = isMediaWrapped && !hasMediaDimensionWidth;
29
+ var shouldUseBreakoutWideLogic = layout === 'wide';
30
+ var shouldUseBreakoutFullWidthLogic = layout === 'full-width';
31
+ var shouldUseProportionalCalc = !isExtendedResizeExperience && !isPixelWidth && hasMediaDimensionWidth && !isMediaLegacyLayout && !isMediaWrapped;
32
+ var shouldUseHalfContainerCalc = shouldUseProportionalCalc && isMediaAligned && mediaSingleDimensionWidth >= 100;
33
+ var shouldHardCodePixelWidth = isExtendedResizeExperience && isPixelWidth && hasMediaDimensionWidth;
34
+ var containerWidthPlusGutter = "(min(100cqw, 100%) + ".concat(GUTTER_SIZE, ")");
35
+ var fullContainerWidth = 'var(--ak-editor-max-container-width, 100cqw)';
36
+ var applyContainerWidthBoundaries = function applyContainerWidthBoundaries(calc) {
37
+ // Safe measure to avoid bleeding
38
+ return "min(".concat(calc, ", ").concat(fullContainerWidth, ")");
39
+ };
40
+ var cssCalc = '';
41
+ if (shouldUseAlignedLayoutCalc) {
42
+ cssCalc = "min(calc(".concat(containerWidthPlusGutter, " * 0.5 - ").concat(GUTTER_SIZE, "), ").concat(baseWidth, "px)");
43
+ } else if (shouldUseWrappedLayoutCalc) {
44
+ cssCalc = "100%";
45
+ } else if (shouldUseHalfContainerCalc) {
46
+ cssCalc = "min(min(".concat(baseWidth, "px, calc(50cqw - ").concat(HALF_GUTTER_SIZE, ")), 100%)");
47
+ } else if (shouldUseProportionalCalc) {
48
+ cssCalc = "calc(".concat(containerWidthPlusGutter, " * var(--ak-editor-media-single--proportion, 1px) - ").concat(GUTTER_SIZE, ")");
49
+ } else if (shouldHardCodePixelWidth) {
50
+ cssCalc = "min(".concat(mediaSingleDimensionWidth, "px, ").concat(fullContainerWidth, ")");
51
+ } else if (shouldUseBreakoutWideLogic) {
52
+ 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))))";
53
+ } else if (shouldUseBreakoutFullWidthLogic) {
54
+ 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))))";
55
+ } else {
56
+ cssCalc = "max(min(".concat(baseWidth, "px, min(100cqw, 100%)), ").concat(GUTTER_SIZE, ")");
57
+ }
58
+ return applyContainerWidthBoundaries(cssCalc);
23
59
  };
24
- var MEDIA_SINGLE_GUTTER_SIZE = 24;
25
- var DEFAULT_EMBED_CARD_WIDTH = 680;
26
- var akEditorMediaResizeHandlerPaddingWide = 12;
27
-
28
- /**
29
- * Duplicate of method from `@atlaskit/editor-common/media-single`.
30
- * `packages/editor/editor-common/src/media-single/utils.ts`
31
- *
32
- * WHY?
33
- * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
34
- * `@atlaskit/editor-common` from here or it will cause dependency issues.
35
- *
36
- * In the long term likely `toDOM` will move back out of `adf-schema` in which
37
- * case we can consolidate them.
38
- */
39
- export function getMediaSinglePixelWidth(width, editorWidth) {
40
- var widthType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'percentage';
41
- var gutterOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
42
- if (widthType === 'pixel') {
43
- return width;
60
+ export var mediaContentWrapperWidthCSSCalc = function mediaContentWrapperWidthCSSCalc(_ref2) {
61
+ var isMediaWrapped = _ref2.isMediaWrapped,
62
+ isExternalMedia = _ref2.isExternalMedia,
63
+ isPixelWidth = _ref2.isPixelWidth,
64
+ childMediaWidth = _ref2.childMediaWidth,
65
+ mediaSingleDimensionWidth = _ref2.mediaSingleDimensionWidth;
66
+ if (isExternalMedia || !isMediaWrapped) {
67
+ return 'unset';
44
68
  }
45
- return Math.ceil((editorWidth + gutterOffset) * (width / 100) - gutterOffset);
46
- }
47
-
48
- /**
49
- * Duplicate logic from `@atlaskit/editor-common/ui` for MediaSingle.
50
- * `packages/editor/editor-common/src/ui/MediaSingle/index.tsx`
51
- *
52
- * WHY?
53
- * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
54
- * `@atlaskit/editor-common` from here or it will cause dependency issues.
55
- *
56
- * In the long term likely `toDOM` will move back out of `adf-schema` in which
57
- * case we can consolidate them.
58
- */
59
- function computeMediaSingleDimensions(_ref) {
60
- var childNode = _ref.childNode,
61
- mediaSingleWidth = _ref.mediaSingleWidth,
62
- widthType = _ref.widthType,
63
- editorWidth = _ref.editorWidth;
64
- var width = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width;
65
- var height = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height;
66
- if (!mediaSingleWidth && shouldAddDefaultWrappedWidth(childNode === null || childNode === void 0 ? void 0 : childNode.attrs.layout, width, editorWidth)) {
67
- mediaSingleWidth = widthType === 'pixel' ? editorWidth / 2 : 50;
69
+ var hasMediaDimensionWidth = typeof mediaSingleDimensionWidth === 'number';
70
+ if (!hasMediaDimensionWidth) {
71
+ return "calc((100% / 2) - ".concat(HALF_GUTTER_SIZE, ")");
68
72
  }
69
- var isHeightOnly = width === undefined;
70
- if (mediaSingleWidth) {
71
- var pxWidth = getMediaSinglePixelWidth(mediaSingleWidth, editorWidth, widthType, MEDIA_SINGLE_GUTTER_SIZE);
72
- if (isHeightOnly) {
73
- return {
74
- width: pxWidth - akEditorMediaResizeHandlerPaddingWide,
75
- height: height
76
- };
77
- } else {
78
- return {
79
- width: pxWidth,
80
- height: height / width * pxWidth
81
- };
82
- }
83
- } else if (isHeightOnly) {
84
- return {
85
- width: DEFAULT_EMBED_CARD_WIDTH - akEditorMediaResizeHandlerPaddingWide,
86
- height: height
87
- };
73
+ if (isPixelWidth) {
74
+ return "min(calc((var(--ak-editor-max-container-width, 100%) / 2) - ".concat(HALF_GUTTER_SIZE, "), ").concat(mediaSingleDimensionWidth, "px)");
88
75
  }
89
- return {
90
- height: height,
91
- width: width
92
- };
93
- }
94
- function computeLayoutStyles(width, layout) {
76
+ var hasChildMediaWidth = typeof childMediaWidth === 'number';
77
+ if (hasChildMediaWidth) {
78
+ return "min(calc(100% * (".concat(mediaSingleDimensionWidth, " / 100) - ").concat(HALF_GUTTER_SIZE, "), ").concat(childMediaWidth, "px)");
79
+ }
80
+ return "calc(100% * (".concat(mediaSingleDimensionWidth, " / 100) - ").concat(HALF_GUTTER_SIZE, ")");
81
+ };
82
+ export var mediaProportionalWidthCSSCalc = function mediaProportionalWidthCSSCalc(_ref3) {
83
+ var isPixelWidth = _ref3.isPixelWidth,
84
+ isExtendedResizeExperience = _ref3.isExtendedResizeExperience,
85
+ mediaSingleDimensionWidth = _ref3.mediaSingleDimensionWidth,
86
+ isMediaWrapped = _ref3.isMediaWrapped;
87
+ var hasMediaWidth = typeof mediaSingleDimensionWidth === 'number';
88
+ if (isPixelWidth || isExtendedResizeExperience || !hasMediaWidth) {
89
+ return 'unset';
90
+ }
91
+ if (isMediaWrapped) {
92
+ return mediaSingleDimensionWidth >= 50 ? '1' : "".concat(1 - mediaSingleDimensionWidth / 100);
93
+ }
94
+ return "".concat(mediaSingleDimensionWidth / 100);
95
+ };
96
+ export var mediaJustifyContentCSS = function mediaJustifyContentCSS(_ref4) {
97
+ var layout = _ref4.layout;
95
98
  switch (layout) {
96
99
  case 'align-end':
97
- return "margin-left: auto; margin-right: 0; width: ".concat(width, "px;");
100
+ case 'wrap-right':
101
+ return 'end';
98
102
  case 'align-start':
99
- return "margin-left: 0; margin-right: auto; width: ".concat(width, "px;");
100
- case 'center':
101
- return 'margin-left: auto; margin-right: auto;';
102
- case 'full-width':
103
- case 'wide':
104
- return 'width: 100%; margin-top: 56px; margin-bottom: 56px;';
105
103
  case 'wrap-left':
106
- return 'float: left;';
107
- case 'wrap-right':
108
- return 'float: right;';
104
+ return 'start';
105
+ default:
106
+ return 'center';
109
107
  }
110
- }
108
+ };
109
+ export var prepareWrapperContentDOM = function prepareWrapperContentDOM(_ref5) {
110
+ var layout = _ref5.layout,
111
+ dataAttrs = _ref5.dataAttrs,
112
+ childMediaWidth = _ref5.childMediaWidth,
113
+ childMediaHeight = _ref5.childMediaHeight,
114
+ mediaSingleDimensionWidth = _ref5.mediaSingleDimensionWidth,
115
+ isPixelWidth = _ref5.isPixelWidth,
116
+ isExtendedResizeExperience = _ref5.isExtendedResizeExperience;
117
+ var layoutStyleJustifyContent = mediaJustifyContentCSS({
118
+ layout: layout
119
+ });
120
+ var mediaWidthCalc = mediaWidthCSSCalc({
121
+ layout: layout,
122
+ mediaSingleDimensionWidth: mediaSingleDimensionWidth,
123
+ baseWidth: childMediaWidth,
124
+ isPixelWidth: isPixelWidth,
125
+ isExtendedResizeExperience: isExtendedResizeExperience
126
+ });
127
+ var paddingBottom = "calc((".concat(childMediaHeight, " / ").concat(childMediaWidth, ") * 100%)");
128
+ return ['div', _objectSpread({
129
+ class: "rich-media-item mediaSingleView-content-wrap image-".concat(layout),
130
+ style: convertToInlineCss({
131
+ display: 'flex',
132
+ justifyContent: layoutStyleJustifyContent,
133
+ transform: 'unset',
134
+ marginLeft: '0'
135
+ })
136
+ }, dataAttrs), ['div', {
137
+ style: convertToInlineCss({
138
+ borderRadius: "var(--ds-border-radius, 3px)",
139
+ width: mediaWidthCalc,
140
+ minWidth: mediaWidthCalc,
141
+ color: "var(--ds-icon, ".concat(N50, ")")
142
+ })
143
+ }, ['figure', {
144
+ class: 'media-single-node',
145
+ style: convertToInlineCss({
146
+ '--ak-editor-media-padding-bottom': paddingBottom,
147
+ margin: '0px'
148
+ })
149
+ }, ['div', {}, ['div', {
150
+ class: 'media-content-wrap'
151
+ }, 0]]]]];
152
+ };
153
+ export var toDOM = function toDOM(node) {
154
+ var _mediaSingleAttrs$lay;
155
+ var mediaSingleAttrs = node.attrs;
156
+ var isPixelWidth = (mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType) === 'pixel';
157
+ var layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
158
+ var childNode = node.firstChild;
159
+ var isExternalMedia = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.type) === 'external';
160
+ var childMediaWidth = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width) || DEFAULT_IMAGE_WIDTH;
161
+ var childMediaHeight = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height) || DEFAULT_IMAGE_HEIGHT;
162
+ var dataAttrs = getAttrsFromNodeMediaSingle(fg('platform.editor.media.extended-resize-experience'), node);
163
+ var content = prepareWrapperContentDOM({
164
+ layout: layout,
165
+ dataAttrs: dataAttrs,
166
+ childMediaWidth: childMediaWidth,
167
+ childMediaHeight: childMediaHeight,
168
+ mediaSingleDimensionWidth: mediaSingleAttrs.width,
169
+ isPixelWidth: isPixelWidth,
170
+ isExtendedResizeExperience: fg('platform.editor.media.extended-resize-experience')
171
+ });
172
+ var isMediaWrapped = WRAPPED_LAYOUTS.includes(layout);
173
+ var proportionCalc = mediaProportionalWidthCSSCalc({
174
+ isPixelWidth: isPixelWidth,
175
+ isMediaWrapped: isMediaWrapped,
176
+ mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width,
177
+ isExtendedResizeExperience: fg('platform.editor.media.extended-resize-experience')
178
+ });
179
+ var contentWrapperWidth = mediaContentWrapperWidthCSSCalc({
180
+ isMediaWrapped: isMediaWrapped,
181
+ isExternalMedia: isExternalMedia,
182
+ isPixelWidth: isPixelWidth,
183
+ childMediaWidth: childMediaWidth,
184
+ mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width
185
+ });
186
+ return ['div', {
187
+ class: 'mediaSingleView-content-wrap',
188
+ layout: layout,
189
+ style: convertToInlineCss({
190
+ '--ak-editor-media-single--proportion': proportionCalc,
191
+ '--ak-editor-media-card-display': 'block',
192
+ '--ak-editor-media-single--gutter-size': GUTTER_SIZE,
193
+ '--ak-editor-media-margin-right': '0',
194
+ '--ak-editor-media-card-background-color': "var(--ds-background-neutral, ".concat(N20, ")"),
195
+ marginTop: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
196
+ marginBottom: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
197
+ marginRight: isMediaWrapped ? layout === 'wrap-right' ? 'auto' : HALF_GUTTER_SIZE : 0,
198
+ marginLeft: isMediaWrapped ? layout === 'wrap-left' ? 'auto' : HALF_GUTTER_SIZE : 0,
199
+ width: contentWrapperWidth
200
+ })
201
+ }, content];
202
+ };
111
203
 
112
204
  // @nodeSpecException:toDOM patch
113
205
  export var mediaSingleSpecWithFixedToDOM = function mediaSingleSpecWithFixedToDOM(mediaSingleOption) {
@@ -116,45 +208,6 @@ export var mediaSingleSpecWithFixedToDOM = function mediaSingleSpecWithFixedToDO
116
208
  return mediaSingleNode;
117
209
  }
118
210
  return _objectSpread(_objectSpread({}, mediaSingleNode), {}, {
119
- toDOM: function toDOM(node, lazyNodeViewOptions) {
120
- var _mediaSingleAttrs$lay;
121
- var mediaSingleAttrs = node.attrs;
122
- var layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
123
- var mediaSingleWidth = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width;
124
- var widthType = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType;
125
- var childNode = node.firstChild;
126
- var dataAttrs = getAttrsFromNodeMediaSingle(mediaSingleOption.withExtendedWidthTypes, node);
127
- var _computeMediaSingleDi = computeMediaSingleDimensions({
128
- childNode: childNode,
129
- widthType: widthType,
130
- mediaSingleWidth: mediaSingleWidth,
131
- editorWidth: (lazyNodeViewOptions === null || lazyNodeViewOptions === void 0 ? void 0 : lazyNodeViewOptions.editorLineWidth) || 760
132
- }),
133
- width = _computeMediaSingleDi.width,
134
- height = _computeMediaSingleDi.height;
135
- var sizes = width && height ? "width: ".concat(width, "px; height: ").concat(height, "px; ").concat(skeletonStyling) : '';
136
- var layoutStyles = computeLayoutStyles(mediaSingleWidth, layout);
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;
143
- var content = ['div', _objectSpread({
144
- class: "rich-media-item mediaSingleView-content-wrap ".concat(layoutClass)
145
- }, dataAttrs), ['div', {
146
- // Transparent image workaround to control styling
147
- style: "".concat(sizes, "; ").concat(style, "; max-width: 100%; border-radius: ", "var(--ds-border-radius, 3px)", "; ").concat(layoutStyle)
148
- }, ['figure', {
149
- class: 'media-single-node',
150
- style: 'margin: 0px'
151
- }, ['div', {}, ['div', {
152
- class: 'media-content-wrap'
153
- }, 0]]]]];
154
- return ['div', {
155
- class: 'mediaSingleView-content-wrap',
156
- layout: layout
157
- }, content];
158
- }
211
+ toDOM: toDOM
159
212
  });
160
213
  };
@@ -4,23 +4,55 @@ var _templateObject;
4
4
  * @jsxRuntime classic
5
5
  * @jsx jsx
6
6
  */
7
- import React from 'react';
7
+ import React, { useCallback } from 'react';
8
8
 
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
10
  import { css, jsx } from '@emotion/react';
11
11
  import { FormattedMessage } from 'react-intl-next';
12
12
  import { captionMessages as messages } from '@atlaskit/editor-common/media';
13
13
  import { CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
14
+ import { Pressable, Text, xcss } from '@atlaskit/primitives';
14
15
  import { N200 } from '@atlaskit/theme/colors';
15
16
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
16
17
  var placeholder = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\tcolor: ", ";\n\twidth: 100%;\n\ttext-align: center;\n\tmargin-top: ", " !important;\n\tdisplay: block;\n"])), "var(--ds-text-subtlest, ".concat(N200, ")"), "var(--ds-space-100, 8px)");
17
- export default /*#__PURE__*/React.forwardRef(function (_ref, ref) {
18
+ var placeholderButton = xcss({
19
+ width: '100%',
20
+ marginTop: 'space.100'
21
+ });
22
+
23
+ // platform_editor_typography_migration_ugc clean up
24
+ // Remove this component
25
+ export var CaptionPlaceholder = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
18
26
  var onClick = _ref.onClick;
19
- return jsx("span", {
27
+ return (
28
+ // eslint-disable-next-line @atlaskit/design-system/use-primitives-text
29
+ jsx("span", {
30
+ ref: ref,
31
+ css: placeholder,
32
+ onClick: onClick,
33
+ "data-id": CAPTION_PLACEHOLDER_ID,
34
+ "data-testid": "caption-placeholder"
35
+ }, jsx(FormattedMessage, messages.placeholder))
36
+ );
37
+ });
38
+ export var CaptionPlaceholderButton = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
39
+ var onClick = _ref2.onClick;
40
+ var handleMouseDown = useCallback(function (e) {
41
+ // In firefox, button is focused when mouse down, which make editor lose focus
42
+ // Hence we want to disabled it so that user can type in caption directly after click
43
+ e.preventDefault();
44
+ }, []);
45
+ return jsx(Pressable, {
20
46
  ref: ref,
21
- css: placeholder,
47
+ backgroundColor: "color.background.neutral.subtle",
22
48
  onClick: onClick,
49
+ onMouseDown: handleMouseDown,
23
50
  "data-id": CAPTION_PLACEHOLDER_ID,
24
- "data-testid": "caption-placeholder"
25
- }, jsx(FormattedMessage, messages.placeholder));
51
+ testId: "caption-placeholder",
52
+ padding: "space.0",
53
+ xcss: placeholderButton
54
+ }, jsx(Text, {
55
+ color: "color.text.subtlest",
56
+ size: "large"
57
+ }, jsx(FormattedMessage, messages.placeholder)));
26
58
  });
@@ -10,11 +10,15 @@ import { jsx } from '@emotion/react';
10
10
  import Button from '@atlaskit/button';
11
11
  import { pixelEntryMessages as messages } from '@atlaskit/editor-common/media';
12
12
  import Form, { Field } from '@atlaskit/form';
13
- import { Text } from '@atlaskit/primitives';
13
+ import { Box, Text, xcss } from '@atlaskit/primitives';
14
14
  import Textfield from '@atlaskit/textfield';
15
15
  import Tooltip from '@atlaskit/tooltip';
16
16
  import { PIXELENTRY_MIGRATION_BUTTON_TESTID } from './constants';
17
- import { pixelEntryForm, pixelEntryHiddenSubmit, pixelSizingFullWidthLabelStyles, pixelSizingHeightInput, pixelSizingInput, pixelSizingLabel, pixelSizingWidthInput, pixelSizingWrapper } from './styles';
17
+ import { pixelEntryForm, pixelEntryHiddenSubmit, pixelSizingFullWidthLabelStyles, pixelSizingHeightInput, pixelSizingInput, pixelSizingWidthInput, pixelSizingWrapper } from './styles';
18
+ var pixelSizingLabel = xcss({
19
+ gridArea: 'label',
20
+ lineHeight: "var(--ds-space-300, 24px)"
21
+ });
18
22
  export var PixelEntry = function PixelEntry(_ref) {
19
23
  var width = _ref.width,
20
24
  mediaWidth = _ref.mediaWidth,
@@ -148,9 +152,10 @@ export var PixelEntry = function PixelEntry(_ref) {
148
152
  maxWidth: maxWidth
149
153
  })
150
154
  })));
151
- }), jsx("span", {
152
- css: pixelSizingLabel
153
- }, "x"), jsx(Field, {
155
+ }), jsx(Box, {
156
+ as: "span",
157
+ xcss: pixelSizingLabel
158
+ }, "\xD7"), jsx(Field, {
154
159
  key: "inputHeight",
155
160
  name: "inputHeight",
156
161
  defaultValue: computedHeight
@@ -6,6 +6,7 @@ var PIXEL_SIZING_WRAPPER_MINIMUM_WIDTH = 120;
6
6
 
7
7
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
8
8
  export var pixelSizingWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\tdisplay: grid;\n\tgrid-template-columns: 1fr 1em 1fr 0;\n\tgrid-template-rows: auto;\n\tgrid-template-areas: 'widthinput label heightinput submit';\n\twidth: ", "px;\n\ttext-align: center;\n\theight: ", ";\n\n\t// Atlaskit fieldset does not allow style override\n\t& > * {\n\t\tmargin-top: 0 !important;\n\t}\n"])), PIXEL_SIZING_WRAPPER_MINIMUM_WIDTH, "var(--ds-space-300, 24px)");
9
+
9
10
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
10
11
  export var pixelEntryForm = css({
11
12
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
@@ -23,11 +24,7 @@ export var pixelSizingInput = css({
23
24
  textAlign: 'center'
24
25
  }
25
26
  });
26
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
27
- export var pixelSizingLabel = css({
28
- gridArea: 'label',
29
- lineHeight: "var(--ds-space-300, 24px)"
30
- });
27
+
31
28
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
32
29
  export var pixelSizingWidthInput = css({
33
30
  gridArea: 'widthinput'
@@ -34,7 +34,7 @@ export default class MediaSingleNode extends Component<MediaSingleNodeProps, Med
34
34
  mediaNodeUpdater: MediaNodeUpdater | null;
35
35
  state: MediaSingleNodeState;
36
36
  mediaSingleWrapperRef: React.RefObject<HTMLDivElement>;
37
- captionPlaceHolderRef: React.RefObject<HTMLSpanElement>;
37
+ captionPlaceHolderRef: React.RefObject<HTMLButtonElement | HTMLSpanElement>;
38
38
  createOrUpdateMediaNodeUpdater: (props: MediaSingleNodeProps) => void;
39
39
  UNSAFE_componentWillReceiveProps(nextProps: MediaSingleNodeProps): void;
40
40
  setViewMediaClientConfig: (props: MediaSingleNodeProps) => Promise<void>;
@@ -1,30 +1,45 @@
1
- import type { NodeSpec } from '@atlaskit/editor-prosemirror/model';
2
- export declare const wrappedLayouts: string[];
3
- /**
4
- * Duplicate of method from `@atlaskit/editor-common/utils`.
5
- * `packages/editor/editor-common/src/utils/rich-media-utils.ts`
6
- *
7
- * WHY?
8
- * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
9
- * `@atlaskit/editor-common` from here or it will cause dependency issues.
10
- *
11
- * In the long term likely `toDOM` will move back out of `adf-schema` in which
12
- * case we can consolidate them.
13
- */
14
- export declare const shouldAddDefaultWrappedWidth: (layout: string, width?: number, lineLength?: number) => boolean | 0 | undefined;
15
- /**
16
- * Duplicate of method from `@atlaskit/editor-common/media-single`.
17
- * `packages/editor/editor-common/src/media-single/utils.ts`
18
- *
19
- * WHY?
20
- * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
21
- * `@atlaskit/editor-common` from here or it will cause dependency issues.
22
- *
23
- * In the long term likely `toDOM` will move back out of `adf-schema` in which
24
- * case we can consolidate them.
25
- */
26
- export declare function getMediaSinglePixelWidth(width: number, editorWidth: number, widthType?: string, gutterOffset?: number): number;
1
+ import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema/schema';
2
+ import type { DOMOutputSpec, NodeSpec, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ type MediaWidthCSSCalcProps = {
4
+ layout: MediaSingleLayout;
5
+ mediaSingleDimensionWidth: number | undefined;
6
+ baseWidth: number | undefined;
7
+ isPixelWidth: boolean;
8
+ isExtendedResizeExperience: boolean;
9
+ };
10
+ export declare const mediaWidthCSSCalc: ({ mediaSingleDimensionWidth, layout, baseWidth, isPixelWidth, isExtendedResizeExperience, }: MediaWidthCSSCalcProps) => string;
11
+ type MediaContentWrapperWidthCSSCalcProps = {
12
+ isMediaWrapped: boolean;
13
+ isExternalMedia: boolean;
14
+ isPixelWidth: boolean;
15
+ childMediaWidth: number | undefined;
16
+ mediaSingleDimensionWidth: number | undefined;
17
+ };
18
+ export declare const mediaContentWrapperWidthCSSCalc: ({ isMediaWrapped, isExternalMedia, isPixelWidth, childMediaWidth, mediaSingleDimensionWidth, }: MediaContentWrapperWidthCSSCalcProps) => string;
19
+ type MediaProportionalWidthCSSCalcProps = {
20
+ isPixelWidth: boolean;
21
+ isExtendedResizeExperience: boolean;
22
+ isMediaWrapped: boolean;
23
+ mediaSingleDimensionWidth: number | undefined;
24
+ };
25
+ export declare const mediaProportionalWidthCSSCalc: ({ isPixelWidth, isExtendedResizeExperience, mediaSingleDimensionWidth, isMediaWrapped, }: MediaProportionalWidthCSSCalcProps) => string;
26
+ type MediaJustifyContentCSSProps = {
27
+ layout: MediaSingleLayout;
28
+ };
29
+ export declare const mediaJustifyContentCSS: ({ layout }: MediaJustifyContentCSSProps) => string;
30
+ type PrepareWrapperContentDOMProps = {
31
+ layout: MediaSingleLayout;
32
+ dataAttrs: Record<string, unknown>;
33
+ childMediaWidth: number;
34
+ childMediaHeight: number;
35
+ mediaSingleDimensionWidth: number;
36
+ isPixelWidth: boolean;
37
+ isExtendedResizeExperience: boolean;
38
+ };
39
+ export declare const prepareWrapperContentDOM: ({ layout, dataAttrs, childMediaWidth, childMediaHeight, mediaSingleDimensionWidth, isPixelWidth, isExtendedResizeExperience, }: PrepareWrapperContentDOMProps) => DOMOutputSpec;
40
+ export declare const toDOM: (node: PMNode) => DOMOutputSpec;
27
41
  export declare const mediaSingleSpecWithFixedToDOM: (mediaSingleOption: {
28
42
  withCaption?: boolean;
29
43
  withExtendedWidthTypes: boolean;
30
44
  }) => NodeSpec;
45
+ export {};
@@ -3,7 +3,9 @@
3
3
  * @jsx jsx
4
4
  */
5
5
  import React from 'react';
6
- declare const _default: React.ForwardRefExoticComponent<{
6
+ export declare const CaptionPlaceholder: React.ForwardRefExoticComponent<{
7
7
  onClick: () => void;
8
8
  } & React.RefAttributes<HTMLSpanElement>>;
9
- export default _default;
9
+ export declare const CaptionPlaceholderButton: React.ForwardRefExoticComponent<{
10
+ onClick: () => void;
11
+ } & React.RefAttributes<HTMLButtonElement>>;
@@ -1,7 +1,6 @@
1
1
  export declare const pixelSizingWrapper: import("@emotion/react").SerializedStyles;
2
2
  export declare const pixelEntryForm: import("@emotion/react").SerializedStyles;
3
3
  export declare const pixelSizingInput: import("@emotion/react").SerializedStyles;
4
- export declare const pixelSizingLabel: import("@emotion/react").SerializedStyles;
5
4
  export declare const pixelSizingWidthInput: import("@emotion/react").SerializedStyles;
6
5
  export declare const pixelSizingHeightInput: import("@emotion/react").SerializedStyles;
7
6
  export declare const pixelEntryHiddenSubmit: import("@emotion/react").SerializedStyles;