@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
@@ -24,7 +24,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
24
24
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
25
25
  import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
26
26
  import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
27
- import CaptionPlaceholder from '../ui/CaptionPlaceholder';
27
+ import { CaptionPlaceholder, CaptionPlaceholderButton } from '../ui/CaptionPlaceholder';
28
28
  import { CommentBadge, CommentBadgeNextWrapper } from '../ui/CommentBadge';
29
29
  import ResizableMediaSingle from '../ui/ResizableMediaSingle';
30
30
  import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaSingleNext';
@@ -47,6 +47,8 @@ export default class MediaSingleNode extends Component {
47
47
  isCopying: false
48
48
  });
49
49
  _defineProperty(this, "mediaSingleWrapperRef", /*#__PURE__*/React.createRef());
50
+ // platform_editor_typography_migration_ugc clean up
51
+ // remove HTMLSpanElement type
50
52
  _defineProperty(this, "captionPlaceHolderRef", /*#__PURE__*/React.createRef());
51
53
  _defineProperty(this, "createOrUpdateMediaNodeUpdater", props => {
52
54
  const node = this.props.node.firstChild;
@@ -422,10 +424,16 @@ export default class MediaSingleNode extends Component {
422
424
  isDrafting: isCurrentNodeDrafting
423
425
  }), jsx("div", {
424
426
  ref: this.props.forwardRef
425
- }), shouldShowPlaceholder && jsx(CaptionPlaceholder, {
427
+ }), shouldShowPlaceholder && (editorExperiment('typography_migration_ugc', true) ? jsx(CaptionPlaceholderButton
428
+ // platform_editor_typography_migration_ugc clean up
429
+ // remove typecasting
430
+ , {
426
431
  ref: this.captionPlaceHolderRef,
427
432
  onClick: this.clickPlaceholder
428
- }));
433
+ }) : jsx(CaptionPlaceholder, {
434
+ ref: this.captionPlaceHolderRef,
435
+ onClick: this.clickPlaceholder
436
+ })));
429
437
  return jsx(Fragment, null, canResize ? fg('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, _extends({}, resizableMediaSingleProps, {
430
438
  showLegacyNotification: widthType !== 'pixel'
431
439
  }), MediaChildren) : jsx(ResizableMediaSingle, _extends({}, resizableMediaSingleProps, {
@@ -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];
@@ -1,109 +1,208 @@
1
1
  import { mediaSingleSpec } from '@atlaskit/adf-schema';
2
+ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { N20, N50 } from '@atlaskit/theme/colors';
2
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
3
6
  import { getAttrsFromNodeMediaSingle } from './toDOMAttrs';
4
- const skeletonStyling = `background: ${"var(--ds-background-neutral, #091E420F)"}; outline: none;`;
5
- export const wrappedLayouts = ['wrap-left', 'wrap-right', 'align-end', 'align-start'];
6
-
7
- /**
8
- * Duplicate of method from `@atlaskit/editor-common/utils`.
9
- * `packages/editor/editor-common/src/utils/rich-media-utils.ts`
10
- *
11
- * WHY?
12
- * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
13
- * `@atlaskit/editor-common` from here or it will cause dependency issues.
14
- *
15
- * In the long term likely `toDOM` will move back out of `adf-schema` in which
16
- * case we can consolidate them.
17
- */
18
- export const shouldAddDefaultWrappedWidth = (layout, width, lineLength) => {
19
- return wrappedLayouts.indexOf(layout) > -1 && lineLength && width && width > 0.5 * lineLength;
7
+ const WRAPPED_LAYOUTS = ['wrap-left', 'wrap-right'];
8
+ const ALIGNED_LAYOUTS = ['align-end', 'align-start'];
9
+ const LEGACY_LAYOUTS = ['full-width', 'wide'];
10
+ const DEFAULT_IMAGE_WIDTH = 250;
11
+ const DEFAULT_IMAGE_HEIGHT = 200;
12
+ const GUTTER_SIZE = '24px';
13
+ const HALF_GUTTER_SIZE = '12px';
14
+ export const mediaWidthCSSCalc = ({
15
+ mediaSingleDimensionWidth,
16
+ layout,
17
+ baseWidth,
18
+ isPixelWidth,
19
+ isExtendedResizeExperience
20
+ }) => {
21
+ const hasMediaDimensionWidth = typeof mediaSingleDimensionWidth === 'number';
22
+ const isMediaWrapped = WRAPPED_LAYOUTS.includes(layout);
23
+ const isMediaAligned = ALIGNED_LAYOUTS.includes(layout);
24
+ const isMediaLegacyLayout = LEGACY_LAYOUTS.includes(layout);
25
+ const shouldUseAlignedLayoutCalc = isMediaAligned && !hasMediaDimensionWidth;
26
+ const shouldUseWrappedLayoutCalc = isMediaWrapped && !hasMediaDimensionWidth;
27
+ const shouldUseBreakoutWideLogic = layout === 'wide';
28
+ const shouldUseBreakoutFullWidthLogic = layout === 'full-width';
29
+ const shouldUseProportionalCalc = !isExtendedResizeExperience && !isPixelWidth && hasMediaDimensionWidth && !isMediaLegacyLayout && !isMediaWrapped;
30
+ const shouldUseHalfContainerCalc = shouldUseProportionalCalc && isMediaAligned && mediaSingleDimensionWidth >= 100;
31
+ const shouldHardCodePixelWidth = isExtendedResizeExperience && isPixelWidth && hasMediaDimensionWidth;
32
+ const containerWidthPlusGutter = `(min(100cqw, 100%) + ${GUTTER_SIZE})`;
33
+ const fullContainerWidth = 'var(--ak-editor-max-container-width, 100cqw)';
34
+ const applyContainerWidthBoundaries = calc => {
35
+ // Safe measure to avoid bleeding
36
+ return `min(${calc}, ${fullContainerWidth})`;
37
+ };
38
+ let cssCalc = '';
39
+ if (shouldUseAlignedLayoutCalc) {
40
+ cssCalc = `min(calc(${containerWidthPlusGutter} * 0.5 - ${GUTTER_SIZE}), ${baseWidth}px)`;
41
+ } else if (shouldUseWrappedLayoutCalc) {
42
+ cssCalc = `100%`;
43
+ } else if (shouldUseHalfContainerCalc) {
44
+ cssCalc = `min(min(${baseWidth}px, calc(50cqw - ${HALF_GUTTER_SIZE})), 100%)`;
45
+ } else if (shouldUseProportionalCalc) {
46
+ cssCalc = `calc(${containerWidthPlusGutter} * var(--ak-editor-media-single--proportion, 1px) - ${GUTTER_SIZE})`;
47
+ } else if (shouldHardCodePixelWidth) {
48
+ cssCalc = `min(${mediaSingleDimensionWidth}px, ${fullContainerWidth})`;
49
+ } else if (shouldUseBreakoutWideLogic) {
50
+ 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))))`;
51
+ } else if (shouldUseBreakoutFullWidthLogic) {
52
+ 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))))`;
53
+ } else {
54
+ cssCalc = `max(min(${baseWidth}px, min(100cqw, 100%)), ${GUTTER_SIZE})`;
55
+ }
56
+ return applyContainerWidthBoundaries(cssCalc);
20
57
  };
21
- const MEDIA_SINGLE_GUTTER_SIZE = 24;
22
- const DEFAULT_EMBED_CARD_WIDTH = 680;
23
- const akEditorMediaResizeHandlerPaddingWide = 12;
24
-
25
- /**
26
- * Duplicate of method from `@atlaskit/editor-common/media-single`.
27
- * `packages/editor/editor-common/src/media-single/utils.ts`
28
- *
29
- * WHY?
30
- * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
31
- * `@atlaskit/editor-common` from here or it will cause dependency issues.
32
- *
33
- * In the long term likely `toDOM` will move back out of `adf-schema` in which
34
- * case we can consolidate them.
35
- */
36
- export function getMediaSinglePixelWidth(width, editorWidth, widthType = 'percentage', gutterOffset = 0) {
37
- if (widthType === 'pixel') {
38
- return width;
58
+ export const mediaContentWrapperWidthCSSCalc = ({
59
+ isMediaWrapped,
60
+ isExternalMedia,
61
+ isPixelWidth,
62
+ childMediaWidth,
63
+ mediaSingleDimensionWidth
64
+ }) => {
65
+ if (isExternalMedia || !isMediaWrapped) {
66
+ return 'unset';
39
67
  }
40
- return Math.ceil((editorWidth + gutterOffset) * (width / 100) - gutterOffset);
41
- }
42
-
43
- /**
44
- * Duplicate logic from `@atlaskit/editor-common/ui` for MediaSingle.
45
- * `packages/editor/editor-common/src/ui/MediaSingle/index.tsx`
46
- *
47
- * WHY?
48
- * This will eventually move to `@atlaskit/adf-schema` and we cannot reference
49
- * `@atlaskit/editor-common` from here or it will cause dependency issues.
50
- *
51
- * In the long term likely `toDOM` will move back out of `adf-schema` in which
52
- * case we can consolidate them.
53
- */
54
- function computeMediaSingleDimensions({
55
- childNode,
56
- mediaSingleWidth,
57
- widthType,
58
- editorWidth
59
- }) {
60
- const width = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width;
61
- const height = childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height;
62
- if (!mediaSingleWidth && shouldAddDefaultWrappedWidth(childNode === null || childNode === void 0 ? void 0 : childNode.attrs.layout, width, editorWidth)) {
63
- mediaSingleWidth = widthType === 'pixel' ? editorWidth / 2 : 50;
68
+ const hasMediaDimensionWidth = typeof mediaSingleDimensionWidth === 'number';
69
+ if (!hasMediaDimensionWidth) {
70
+ return `calc((100% / 2) - ${HALF_GUTTER_SIZE})`;
64
71
  }
65
- const isHeightOnly = width === undefined;
66
- if (mediaSingleWidth) {
67
- const pxWidth = getMediaSinglePixelWidth(mediaSingleWidth, editorWidth, widthType, MEDIA_SINGLE_GUTTER_SIZE);
68
- if (isHeightOnly) {
69
- return {
70
- width: pxWidth - akEditorMediaResizeHandlerPaddingWide,
71
- height
72
- };
73
- } else {
74
- return {
75
- width: pxWidth,
76
- height: height / width * pxWidth
77
- };
78
- }
79
- } else if (isHeightOnly) {
80
- return {
81
- width: DEFAULT_EMBED_CARD_WIDTH - akEditorMediaResizeHandlerPaddingWide,
82
- height
83
- };
72
+ if (isPixelWidth) {
73
+ return `min(calc((var(--ak-editor-max-container-width, 100%) / 2) - ${HALF_GUTTER_SIZE}), ${mediaSingleDimensionWidth}px)`;
84
74
  }
85
- return {
86
- height,
87
- width
88
- };
89
- }
90
- function computeLayoutStyles(width, layout) {
75
+ const hasChildMediaWidth = typeof childMediaWidth === 'number';
76
+ if (hasChildMediaWidth) {
77
+ return `min(calc(100% * (${mediaSingleDimensionWidth} / 100) - ${HALF_GUTTER_SIZE}), ${childMediaWidth}px)`;
78
+ }
79
+ return `calc(100% * (${mediaSingleDimensionWidth} / 100) - ${HALF_GUTTER_SIZE})`;
80
+ };
81
+ export const mediaProportionalWidthCSSCalc = ({
82
+ isPixelWidth,
83
+ isExtendedResizeExperience,
84
+ mediaSingleDimensionWidth,
85
+ isMediaWrapped
86
+ }) => {
87
+ const hasMediaWidth = typeof mediaSingleDimensionWidth === 'number';
88
+ if (isPixelWidth || isExtendedResizeExperience || !hasMediaWidth) {
89
+ return 'unset';
90
+ }
91
+ if (isMediaWrapped) {
92
+ return mediaSingleDimensionWidth >= 50 ? '1' : `${1 - mediaSingleDimensionWidth / 100}`;
93
+ }
94
+ return `${mediaSingleDimensionWidth / 100}`;
95
+ };
96
+ export const mediaJustifyContentCSS = ({
97
+ layout
98
+ }) => {
91
99
  switch (layout) {
92
100
  case 'align-end':
93
- return `margin-left: auto; margin-right: 0; width: ${width}px;`;
101
+ case 'wrap-right':
102
+ return 'end';
94
103
  case 'align-start':
95
- return `margin-left: 0; margin-right: auto; width: ${width}px;`;
96
- case 'center':
97
- return 'margin-left: auto; margin-right: auto;';
98
- case 'full-width':
99
- case 'wide':
100
- return 'width: 100%; margin-top: 56px; margin-bottom: 56px;';
101
104
  case 'wrap-left':
102
- return 'float: left;';
103
- case 'wrap-right':
104
- return 'float: right;';
105
+ return 'start';
106
+ default:
107
+ return 'center';
105
108
  }
106
- }
109
+ };
110
+ export const prepareWrapperContentDOM = ({
111
+ layout,
112
+ dataAttrs,
113
+ childMediaWidth,
114
+ childMediaHeight,
115
+ mediaSingleDimensionWidth,
116
+ isPixelWidth,
117
+ isExtendedResizeExperience
118
+ }) => {
119
+ const layoutStyleJustifyContent = mediaJustifyContentCSS({
120
+ layout
121
+ });
122
+ const mediaWidthCalc = mediaWidthCSSCalc({
123
+ layout,
124
+ mediaSingleDimensionWidth,
125
+ baseWidth: childMediaWidth,
126
+ isPixelWidth,
127
+ isExtendedResizeExperience
128
+ });
129
+ const paddingBottom = `calc((${childMediaHeight} / ${childMediaWidth}) * 100%)`;
130
+ return ['div', {
131
+ class: `rich-media-item mediaSingleView-content-wrap image-${layout}`,
132
+ style: convertToInlineCss({
133
+ display: 'flex',
134
+ justifyContent: layoutStyleJustifyContent,
135
+ transform: 'unset',
136
+ marginLeft: '0'
137
+ }),
138
+ ...dataAttrs
139
+ }, ['div', {
140
+ style: convertToInlineCss({
141
+ borderRadius: "var(--ds-border-radius, 3px)",
142
+ width: mediaWidthCalc,
143
+ minWidth: mediaWidthCalc,
144
+ color: `var(--ds-icon, ${N50})`
145
+ })
146
+ }, ['figure', {
147
+ class: 'media-single-node',
148
+ style: convertToInlineCss({
149
+ '--ak-editor-media-padding-bottom': paddingBottom,
150
+ margin: '0px'
151
+ })
152
+ }, ['div', {}, ['div', {
153
+ class: 'media-content-wrap'
154
+ }, 0]]]]];
155
+ };
156
+ export const toDOM = node => {
157
+ var _mediaSingleAttrs$lay;
158
+ const mediaSingleAttrs = node.attrs;
159
+ const isPixelWidth = (mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType) === 'pixel';
160
+ const layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
161
+ const childNode = node.firstChild;
162
+ const isExternalMedia = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.type) === 'external';
163
+ const childMediaWidth = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width) || DEFAULT_IMAGE_WIDTH;
164
+ const childMediaHeight = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height) || DEFAULT_IMAGE_HEIGHT;
165
+ const dataAttrs = getAttrsFromNodeMediaSingle(fg('platform.editor.media.extended-resize-experience'), node);
166
+ const content = prepareWrapperContentDOM({
167
+ layout,
168
+ dataAttrs,
169
+ childMediaWidth,
170
+ childMediaHeight,
171
+ mediaSingleDimensionWidth: mediaSingleAttrs.width,
172
+ isPixelWidth,
173
+ isExtendedResizeExperience: fg('platform.editor.media.extended-resize-experience')
174
+ });
175
+ const isMediaWrapped = WRAPPED_LAYOUTS.includes(layout);
176
+ const proportionCalc = mediaProportionalWidthCSSCalc({
177
+ isPixelWidth,
178
+ isMediaWrapped,
179
+ mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width,
180
+ isExtendedResizeExperience: fg('platform.editor.media.extended-resize-experience')
181
+ });
182
+ const contentWrapperWidth = mediaContentWrapperWidthCSSCalc({
183
+ isMediaWrapped,
184
+ isExternalMedia,
185
+ isPixelWidth,
186
+ childMediaWidth,
187
+ mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width
188
+ });
189
+ return ['div', {
190
+ class: 'mediaSingleView-content-wrap',
191
+ layout,
192
+ style: convertToInlineCss({
193
+ '--ak-editor-media-single--proportion': proportionCalc,
194
+ '--ak-editor-media-card-display': 'block',
195
+ '--ak-editor-media-single--gutter-size': GUTTER_SIZE,
196
+ '--ak-editor-media-margin-right': '0',
197
+ '--ak-editor-media-card-background-color': `var(--ds-background-neutral, ${N20})`,
198
+ marginTop: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
199
+ marginBottom: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
200
+ marginRight: isMediaWrapped ? layout === 'wrap-right' ? 'auto' : HALF_GUTTER_SIZE : 0,
201
+ marginLeft: isMediaWrapped ? layout === 'wrap-left' ? 'auto' : HALF_GUTTER_SIZE : 0,
202
+ width: contentWrapperWidth
203
+ })
204
+ }, content];
205
+ };
107
206
 
108
207
  // @nodeSpecException:toDOM patch
109
208
  export const mediaSingleSpecWithFixedToDOM = mediaSingleOption => {
@@ -113,47 +212,6 @@ export const mediaSingleSpecWithFixedToDOM = mediaSingleOption => {
113
212
  }
114
213
  return {
115
214
  ...mediaSingleNode,
116
- toDOM: (node, lazyNodeViewOptions) => {
117
- var _mediaSingleAttrs$lay;
118
- const mediaSingleAttrs = node.attrs;
119
- const layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
120
- const mediaSingleWidth = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width;
121
- const widthType = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType;
122
- const childNode = node.firstChild;
123
- const dataAttrs = getAttrsFromNodeMediaSingle(mediaSingleOption.withExtendedWidthTypes, node);
124
- const {
125
- width,
126
- height
127
- } = computeMediaSingleDimensions({
128
- childNode,
129
- widthType,
130
- mediaSingleWidth,
131
- editorWidth: (lazyNodeViewOptions === null || lazyNodeViewOptions === void 0 ? void 0 : lazyNodeViewOptions.editorLineWidth) || 760
132
- });
133
- const sizes = width && height ? `width: ${width}px; height: ${height}px; ${skeletonStyling}` : '';
134
- const layoutStyles = computeLayoutStyles(mediaSingleWidth, layout);
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;
141
- const content = ['div', {
142
- class: `rich-media-item mediaSingleView-content-wrap ${layoutClass}`,
143
- ...dataAttrs
144
- }, ['div', {
145
- // Transparent image workaround to control styling
146
- style: `${sizes}; ${style}; max-width: 100%; border-radius: ${"var(--ds-border-radius, 3px)"}; ${layoutStyle}`
147
- }, ['figure', {
148
- class: 'media-single-node',
149
- style: 'margin: 0px'
150
- }, ['div', {}, ['div', {
151
- class: 'media-content-wrap'
152
- }, 0]]]]];
153
- return ['div', {
154
- class: 'mediaSingleView-content-wrap',
155
- layout
156
- }, content];
157
- }
215
+ toDOM
158
216
  };
159
217
  };
@@ -2,13 +2,14 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
- import React from 'react';
5
+ import React, { useCallback } from 'react';
6
6
 
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
8
  import { css, jsx } from '@emotion/react';
9
9
  import { FormattedMessage } from 'react-intl-next';
10
10
  import { captionMessages as messages } from '@atlaskit/editor-common/media';
11
11
  import { CAPTION_PLACEHOLDER_ID } from '@atlaskit/editor-common/media-single';
12
+ import { Pressable, Text, xcss } from '@atlaskit/primitives';
12
13
  import { N200 } from '@atlaskit/theme/colors';
13
14
  // eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
14
15
  const placeholder = css`
@@ -18,14 +19,46 @@ const placeholder = css`
18
19
  margin-top: ${"var(--ds-space-100, 8px)"} !important;
19
20
  display: block;
20
21
  `;
21
- export default /*#__PURE__*/React.forwardRef(({
22
+ const placeholderButton = xcss({
23
+ width: '100%',
24
+ marginTop: 'space.100'
25
+ });
26
+
27
+ // platform_editor_typography_migration_ugc clean up
28
+ // Remove this component
29
+ export const CaptionPlaceholder = /*#__PURE__*/React.forwardRef(({
30
+ onClick
31
+ }, ref) => {
32
+ return (
33
+ // eslint-disable-next-line @atlaskit/design-system/use-primitives-text
34
+ jsx("span", {
35
+ ref: ref,
36
+ css: placeholder,
37
+ onClick: onClick,
38
+ "data-id": CAPTION_PLACEHOLDER_ID,
39
+ "data-testid": "caption-placeholder"
40
+ }, jsx(FormattedMessage, messages.placeholder))
41
+ );
42
+ });
43
+ export const CaptionPlaceholderButton = /*#__PURE__*/React.forwardRef(({
22
44
  onClick
23
45
  }, ref) => {
24
- return jsx("span", {
46
+ const handleMouseDown = useCallback(e => {
47
+ // In firefox, button is focused when mouse down, which make editor lose focus
48
+ // Hence we want to disabled it so that user can type in caption directly after click
49
+ e.preventDefault();
50
+ }, []);
51
+ return jsx(Pressable, {
25
52
  ref: ref,
26
- css: placeholder,
53
+ backgroundColor: "color.background.neutral.subtle",
27
54
  onClick: onClick,
55
+ onMouseDown: handleMouseDown,
28
56
  "data-id": CAPTION_PLACEHOLDER_ID,
29
- "data-testid": "caption-placeholder"
30
- }, jsx(FormattedMessage, messages.placeholder));
57
+ testId: "caption-placeholder",
58
+ padding: "space.0",
59
+ xcss: placeholderButton
60
+ }, jsx(Text, {
61
+ color: "color.text.subtlest",
62
+ size: "large"
63
+ }, jsx(FormattedMessage, messages.placeholder)));
31
64
  });
@@ -9,11 +9,15 @@ import { jsx } from '@emotion/react';
9
9
  import Button from '@atlaskit/button';
10
10
  import { pixelEntryMessages as messages } from '@atlaskit/editor-common/media';
11
11
  import Form, { Field } from '@atlaskit/form';
12
- import { Text } from '@atlaskit/primitives';
12
+ import { Box, Text, xcss } from '@atlaskit/primitives';
13
13
  import Textfield from '@atlaskit/textfield';
14
14
  import Tooltip from '@atlaskit/tooltip';
15
15
  import { PIXELENTRY_MIGRATION_BUTTON_TESTID } from './constants';
16
- import { pixelEntryForm, pixelEntryHiddenSubmit, pixelSizingFullWidthLabelStyles, pixelSizingHeightInput, pixelSizingInput, pixelSizingLabel, pixelSizingWidthInput, pixelSizingWrapper } from './styles';
16
+ import { pixelEntryForm, pixelEntryHiddenSubmit, pixelSizingFullWidthLabelStyles, pixelSizingHeightInput, pixelSizingInput, pixelSizingWidthInput, pixelSizingWrapper } from './styles';
17
+ const pixelSizingLabel = xcss({
18
+ gridArea: 'label',
19
+ lineHeight: "var(--ds-space-300, 24px)"
20
+ });
17
21
  export const PixelEntry = ({
18
22
  width,
19
23
  mediaWidth,
@@ -142,9 +146,10 @@ export const PixelEntry = ({
142
146
  "aria-label": formatMessage(messages.inputWidthAriaLabel, {
143
147
  maxWidth
144
148
  })
145
- })))), jsx("span", {
146
- css: pixelSizingLabel
147
- }, "x"), jsx(Field, {
149
+ })))), jsx(Box, {
150
+ as: "span",
151
+ xcss: pixelSizingLabel
152
+ }, "\xD7"), jsx(Field, {
148
153
  key: "inputHeight",
149
154
  name: "inputHeight",
150
155
  defaultValue: computedHeight
@@ -17,6 +17,7 @@ export const pixelSizingWrapper = css`
17
17
  margin-top: 0 !important;
18
18
  }
19
19
  `;
20
+
20
21
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
21
22
  export const pixelEntryForm = css({
22
23
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
@@ -34,11 +35,7 @@ export const pixelSizingInput = css({
34
35
  textAlign: 'center'
35
36
  }
36
37
  });
37
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
38
- export const pixelSizingLabel = css({
39
- gridArea: 'label',
40
- lineHeight: "var(--ds-space-300, 24px)"
41
- });
38
+
42
39
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
43
40
  export const pixelSizingWidthInput = css({
44
41
  gridArea: 'widthinput'
@@ -37,7 +37,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
37
37
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
38
38
  import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
39
39
  import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
40
- import CaptionPlaceholder from '../ui/CaptionPlaceholder';
40
+ import { CaptionPlaceholder, CaptionPlaceholderButton } from '../ui/CaptionPlaceholder';
41
41
  import { CommentBadge, CommentBadgeNextWrapper } from '../ui/CommentBadge';
42
42
  import ResizableMediaSingle from '../ui/ResizableMediaSingle';
43
43
  import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaSingleNext';
@@ -67,6 +67,8 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
67
67
  isCopying: false
68
68
  });
69
69
  _defineProperty(_assertThisInitialized(_this), "mediaSingleWrapperRef", /*#__PURE__*/React.createRef());
70
+ // platform_editor_typography_migration_ugc clean up
71
+ // remove HTMLSpanElement type
70
72
  _defineProperty(_assertThisInitialized(_this), "captionPlaceHolderRef", /*#__PURE__*/React.createRef());
71
73
  _defineProperty(_assertThisInitialized(_this), "createOrUpdateMediaNodeUpdater", function (props) {
72
74
  var node = _this.props.node.firstChild;
@@ -499,10 +501,16 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
499
501
  isDrafting: isCurrentNodeDrafting
500
502
  }), jsx("div", {
501
503
  ref: this.props.forwardRef
502
- }), shouldShowPlaceholder && jsx(CaptionPlaceholder, {
504
+ }), shouldShowPlaceholder && (editorExperiment('typography_migration_ugc', true) ? jsx(CaptionPlaceholderButton
505
+ // platform_editor_typography_migration_ugc clean up
506
+ // remove typecasting
507
+ , {
503
508
  ref: this.captionPlaceHolderRef,
504
509
  onClick: this.clickPlaceholder
505
- }));
510
+ }) : jsx(CaptionPlaceholder, {
511
+ ref: this.captionPlaceHolderRef,
512
+ onClick: this.clickPlaceholder
513
+ })));
506
514
  return jsx(Fragment, null, canResize ? fg('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, _extends({}, resizableMediaSingleProps, {
507
515
  showLegacyNotification: widthType !== 'pixel'
508
516
  }), MediaChildren) : jsx(ResizableMediaSingle, _extends({}, resizableMediaSingleProps, {