@atlaskit/editor-plugin-media 2.3.7 → 2.3.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 (68) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/mediaPlugin.js +7 -0
  3. package/dist/cjs/pm-plugins/pixel-resizing/commands.js +22 -0
  4. package/dist/cjs/pm-plugins/pixel-resizing/index.js +31 -0
  5. package/dist/cjs/pm-plugins/pixel-resizing/reducer.js +28 -0
  6. package/dist/cjs/pm-plugins/pixel-resizing/ui/constants.js +11 -0
  7. package/dist/cjs/pm-plugins/pixel-resizing/ui/index.js +124 -0
  8. package/dist/cjs/{ui/PixelEntry/index.js → pm-plugins/pixel-resizing/ui/pixel-entry.js} +168 -13
  9. package/dist/cjs/ui/toolbar/commands.js +29 -22
  10. package/dist/cjs/ui/toolbar/index.js +63 -97
  11. package/dist/cjs/ui/toolbar/linking.js +1 -1
  12. package/dist/cjs/ui/toolbar/pixel-resizing.js +47 -0
  13. package/dist/es2019/mediaPlugin.js +7 -0
  14. package/dist/es2019/pm-plugins/pixel-resizing/commands.js +16 -0
  15. package/dist/es2019/pm-plugins/pixel-resizing/index.js +27 -0
  16. package/dist/es2019/pm-plugins/pixel-resizing/reducer.js +20 -0
  17. package/dist/es2019/pm-plugins/pixel-resizing/ui/constants.js +5 -0
  18. package/dist/es2019/pm-plugins/pixel-resizing/ui/index.js +126 -0
  19. package/dist/es2019/{ui/PixelEntry/index.js → pm-plugins/pixel-resizing/ui/pixel-entry.js} +170 -19
  20. package/dist/es2019/ui/toolbar/commands.js +9 -2
  21. package/dist/es2019/ui/toolbar/index.js +55 -91
  22. package/dist/es2019/ui/toolbar/linking.js +1 -1
  23. package/dist/es2019/ui/toolbar/pixel-resizing.js +37 -0
  24. package/dist/esm/mediaPlugin.js +7 -0
  25. package/dist/esm/pm-plugins/pixel-resizing/commands.js +16 -0
  26. package/dist/esm/pm-plugins/pixel-resizing/index.js +25 -0
  27. package/dist/esm/pm-plugins/pixel-resizing/reducer.js +21 -0
  28. package/dist/esm/pm-plugins/pixel-resizing/ui/constants.js +5 -0
  29. package/dist/esm/pm-plugins/pixel-resizing/ui/index.js +120 -0
  30. package/dist/esm/{ui/PixelEntry/index.js → pm-plugins/pixel-resizing/ui/pixel-entry.js} +172 -17
  31. package/dist/esm/ui/toolbar/commands.js +28 -21
  32. package/dist/esm/ui/toolbar/index.js +55 -89
  33. package/dist/esm/ui/toolbar/linking.js +1 -1
  34. package/dist/esm/ui/toolbar/pixel-resizing.js +40 -0
  35. package/dist/types/pm-plugins/pixel-resizing/commands.d.ts +4 -0
  36. package/dist/types/pm-plugins/pixel-resizing/index.d.ts +13 -0
  37. package/dist/types/pm-plugins/pixel-resizing/reducer.d.ts +12 -0
  38. package/dist/types/pm-plugins/pixel-resizing/ui/constants.d.ts +3 -0
  39. package/dist/types/pm-plugins/pixel-resizing/ui/index.d.ts +21 -0
  40. package/dist/types/pm-plugins/pixel-resizing/ui/pixel-entry.d.ts +4 -0
  41. package/dist/types/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/types.d.ts +18 -0
  42. package/dist/types/ui/toolbar/commands.d.ts +2 -1
  43. package/dist/types/ui/toolbar/pixel-resizing.d.ts +4 -0
  44. package/dist/types-ts4.5/pm-plugins/pixel-resizing/commands.d.ts +4 -0
  45. package/dist/types-ts4.5/pm-plugins/pixel-resizing/index.d.ts +13 -0
  46. package/dist/types-ts4.5/pm-plugins/pixel-resizing/reducer.d.ts +12 -0
  47. package/dist/types-ts4.5/pm-plugins/pixel-resizing/ui/constants.d.ts +3 -0
  48. package/dist/types-ts4.5/pm-plugins/pixel-resizing/ui/index.d.ts +21 -0
  49. package/dist/types-ts4.5/pm-plugins/pixel-resizing/ui/pixel-entry.d.ts +4 -0
  50. package/dist/types-ts4.5/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/types.d.ts +18 -0
  51. package/dist/types-ts4.5/ui/toolbar/commands.d.ts +2 -1
  52. package/dist/types-ts4.5/ui/toolbar/pixel-resizing.d.ts +4 -0
  53. package/package.json +8 -8
  54. package/dist/cjs/ui/PixelEntry/constants.js +0 -7
  55. package/dist/es2019/ui/PixelEntry/constants.js +0 -1
  56. package/dist/esm/ui/PixelEntry/constants.js +0 -1
  57. package/dist/types/ui/PixelEntry/constants.d.ts +0 -1
  58. package/dist/types/ui/PixelEntry/index.d.ts +0 -7
  59. package/dist/types-ts4.5/ui/PixelEntry/constants.d.ts +0 -1
  60. package/dist/types-ts4.5/ui/PixelEntry/index.d.ts +0 -7
  61. /package/dist/cjs/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/styles.js +0 -0
  62. /package/dist/cjs/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/types.js +0 -0
  63. /package/dist/es2019/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/styles.js +0 -0
  64. /package/dist/es2019/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/types.js +0 -0
  65. /package/dist/esm/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/styles.js +0 -0
  66. /package/dist/esm/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/types.js +0 -0
  67. /package/dist/types/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/styles.d.ts +0 -0
  68. /package/dist/types-ts4.5/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/styles.d.ts +0 -0
@@ -0,0 +1,16 @@
1
+ import { createCommand } from './index';
2
+ export var openPixelEditor = function openPixelEditor() {
3
+ return createCommand({
4
+ type: 'openPixelEditor'
5
+ });
6
+ };
7
+ export var closePixelEditor = function closePixelEditor() {
8
+ return createCommand({
9
+ type: 'closePixelEditor'
10
+ });
11
+ };
12
+ export var closePixelEditorAndSave = function closePixelEditorAndSave(saveTransform) {
13
+ return createCommand({
14
+ type: 'closePixelEditor'
15
+ }, saveTransform);
16
+ };
@@ -0,0 +1,25 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { pluginFactory } from '@atlaskit/editor-common/utils';
3
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ import reducer from './reducer';
5
+ var pluginKey = new PluginKey('mediaPixelResizingPlugin');
6
+ var _pluginFactory = pluginFactory(pluginKey, reducer, {
7
+ onSelectionChanged: function onSelectionChanged() {
8
+ return {
9
+ isPixelEditorOpen: false
10
+ };
11
+ }
12
+ }),
13
+ createPluginState = _pluginFactory.createPluginState,
14
+ createCommand = _pluginFactory.createCommand,
15
+ getPluginState = _pluginFactory.getPluginState;
16
+ export var createPlugin = function createPlugin(_ref) {
17
+ var dispatch = _ref.dispatch;
18
+ return new SafePlugin({
19
+ state: createPluginState(dispatch, {
20
+ isPixelEditorOpen: false
21
+ }),
22
+ key: pluginKey
23
+ });
24
+ };
25
+ export { createCommand, getPluginState };
@@ -0,0 +1,21 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
+ 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
+ export default (function (state, action) {
5
+ switch (action.type) {
6
+ case 'openPixelEditor':
7
+ {
8
+ return _objectSpread(_objectSpread({}, state), {}, {
9
+ isPixelEditorOpen: true
10
+ });
11
+ }
12
+ case 'closePixelEditor':
13
+ {
14
+ return _objectSpread(_objectSpread({}, state), {}, {
15
+ isPixelEditorOpen: false
16
+ });
17
+ }
18
+ default:
19
+ return state;
20
+ }
21
+ });
@@ -0,0 +1,5 @@
1
+ export var PIXELENTRY_MIGRATION_BUTTON_TESTID = 'pixel-entry-convert-pixels-btn';
2
+
3
+ // pixel resizing toolbar width (with `platform_editor_controls` enabled)
4
+ export var PIXEL_RESIZING_TOOLBAR_WIDTH = 240;
5
+ export var PIXEL_VIEW_MODE_TOOLBAR_WIDTH = 204;
@@ -0,0 +1,120 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
+ 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
+ /**
5
+ * @jsxRuntime classic
6
+ * @jsx jsx
7
+ */
8
+ import { useCallback } from 'react';
9
+
10
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
11
+ import { jsx } from '@emotion/react';
12
+ import { pixelEntryMessages as messages } from '@atlaskit/editor-common/media';
13
+ import { calcMinWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
14
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
15
+ import { hasParentNode } from '@atlaskit/editor-prosemirror/utils';
16
+ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
17
+ import { Text } from '@atlaskit/primitives';
18
+ import { updateMediaSingleWidthTr } from '../../../ui/toolbar/commands';
19
+ import { getPixelWidthOfElement, calcNewLayout } from '../../../ui/toolbar/utils';
20
+ import { isVideo } from '../../utils/media-single';
21
+ import { closePixelEditorAndSave } from '../commands';
22
+ import { PixelEntryComponent } from './pixel-entry';
23
+ import { pixelSizingFullWidthLabelStyles } from './styles';
24
+ export var PixelEntry = function PixelEntry(_ref) {
25
+ var _pluginInjectionApi$w, _pluginInjectionApi$m;
26
+ var editorView = _ref.editorView,
27
+ selectedMediaSingleNode = _ref.selectedMediaSingleNode,
28
+ pluginInjectionApi = _ref.pluginInjectionApi,
29
+ intl = _ref.intl,
30
+ pluginState = _ref.pluginState,
31
+ hoverDecoration = _ref.hoverDecoration,
32
+ isEditorFullWidthEnabled = _ref.isEditorFullWidthEnabled;
33
+ var state = editorView.state,
34
+ dispatch = editorView.dispatch;
35
+ var mediaSingle = state.schema.nodes.mediaSingle;
36
+ var contentWidth = (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w = pluginInjectionApi.width.sharedState.currentState()) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.lineLength) || akEditorDefaultLayoutWidth;
37
+ var _selectedMediaSingleN = selectedMediaSingleNode.node.attrs,
38
+ mediaSingleWidth = _selectedMediaSingleN.width,
39
+ widthType = _selectedMediaSingleN.widthType,
40
+ layout = _selectedMediaSingleN.layout;
41
+
42
+ // hasParentNode will return falsey value if selection depth === 0
43
+ var isNested = hasParentNode(function (n) {
44
+ return n.type !== state.schema.nodes.doc;
45
+ })(state.selection);
46
+ var updateNodeWithTr = useCallback(function (width, validation) {
47
+ var _pluginInjectionApi$a;
48
+ var newLayout = calcNewLayout(width, layout, contentWidth, isEditorFullWidthEnabled, isNested);
49
+ return updateMediaSingleWidthTr(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, state, width, validation, 'floatingToolBar', newLayout);
50
+ }, [layout, contentWidth, isEditorFullWidthEnabled, isNested, state, pluginInjectionApi]);
51
+ var selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
52
+ if (!selectedMediaNode) {
53
+ return null;
54
+ }
55
+ var _selectedMediaNode$at = selectedMediaNode.attrs,
56
+ mediaWidth = _selectedMediaNode$at.width,
57
+ mediaHeight = _selectedMediaNode$at.height;
58
+ var maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 || (_pluginInjectionApi$m = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
59
+ var maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
60
+ var isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
61
+ var minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
62
+ var hasPixelType = widthType === 'pixel';
63
+ var pixelWidthFromElement = getPixelWidthOfElement(editorView, selectedMediaSingleNode.pos + 1,
64
+ // get pos of media node
65
+ mediaWidth || DEFAULT_IMAGE_WIDTH);
66
+ var pixelWidth = hasPixelType ? mediaSingleWidth : pixelWidthFromElement;
67
+ return jsx(PixelEntryComponent, {
68
+ intl: intl,
69
+ width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
70
+ showMigration: !pluginState.isResizing && !hasPixelType,
71
+ mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
72
+ mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
73
+ minWidth: minWidth,
74
+ maxWidth: maxWidth,
75
+ onChange: function onChange(valid) {
76
+ if (valid) {
77
+ hoverDecoration === null || hoverDecoration === void 0 || hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
78
+ } else {
79
+ hoverDecoration === null || hoverDecoration === void 0 || hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
80
+ }
81
+ },
82
+ onSubmit: function onSubmit(_ref2) {
83
+ var width = _ref2.width,
84
+ validation = _ref2.validation;
85
+ var tr = updateNodeWithTr(width, validation);
86
+ if (tr) {
87
+ dispatch(tr);
88
+ }
89
+ },
90
+ onMigrate: function onMigrate() {
91
+ var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
92
+ width: pixelWidthFromElement,
93
+ widthType: 'pixel'
94
+ }));
95
+ tr.setMeta('scrollIntoView', false);
96
+ tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
97
+ dispatch(tr);
98
+ },
99
+ onCloseAndSave: function onCloseAndSave(_ref3) {
100
+ var width = _ref3.width,
101
+ validation = _ref3.validation;
102
+ var tr = updateNodeWithTr(width, validation);
103
+ if (tr) {
104
+ return closePixelEditorAndSave(function () {
105
+ return tr;
106
+ })(state, dispatch);
107
+ }
108
+ },
109
+ isViewMode: pluginState.isResizing
110
+ });
111
+ };
112
+ export var FullWidthDisplay = function FullWidthDisplay(_ref4) {
113
+ var formatMessage = _ref4.intl.formatMessage;
114
+ return (
115
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
116
+ jsx("div", {
117
+ css: pixelSizingFullWidthLabelStyles
118
+ }, jsx(Text, null, formatMessage(messages.fullWidthLabel)))
119
+ );
120
+ };
@@ -4,22 +4,25 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  * @jsxRuntime classic
5
5
  * @jsx jsx
6
6
  */
7
- import { useCallback, useEffect, useMemo, useState } from 'react';
7
+ import { useCallback, useEffect, useMemo, useState, useRef, Fragment } from 'react';
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
- import { jsx } from '@emotion/react';
9
+ import { jsx, css } from '@emotion/react';
10
10
  import Button from '@atlaskit/button';
11
+ import { IconButton } from '@atlaskit/button/new';
11
12
  import { pixelEntryMessages as messages } from '@atlaskit/editor-common/media';
12
13
  import Form, { Field } from '@atlaskit/form';
13
- import { Box, Text, xcss } from '@atlaskit/primitives';
14
+ import CloseIcon from '@atlaskit/icon/core/close';
15
+ import { Inline, Box, Text, xcss } from '@atlaskit/primitives';
14
16
  import Textfield from '@atlaskit/textfield';
17
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
18
  import Tooltip from '@atlaskit/tooltip';
16
- import { PIXELENTRY_MIGRATION_BUTTON_TESTID } from './constants';
17
- import { pixelEntryForm, pixelEntryHiddenSubmit, pixelSizingFullWidthLabelStyles, pixelSizingHeightInput, pixelSizingInput, pixelSizingWidthInput, pixelSizingWrapper } from './styles';
19
+ import { PIXEL_RESIZING_TOOLBAR_WIDTH, PIXEL_VIEW_MODE_TOOLBAR_WIDTH, PIXELENTRY_MIGRATION_BUTTON_TESTID } from './constants';
20
+ import { pixelEntryForm, pixelEntryHiddenSubmit, pixelSizingHeightInput, pixelSizingInput, pixelSizingWidthInput, pixelSizingWrapper } from './styles';
18
21
  var pixelSizingLabel = xcss({
19
22
  gridArea: 'label',
20
23
  lineHeight: "var(--ds-space-300, 24px)"
21
24
  });
22
- export var PixelEntry = function PixelEntry(_ref) {
25
+ export var PixelEntryComponent = function PixelEntryComponent(_ref) {
23
26
  var width = _ref.width,
24
27
  mediaWidth = _ref.mediaWidth,
25
28
  mediaHeight = _ref.mediaHeight,
@@ -29,7 +32,9 @@ export var PixelEntry = function PixelEntry(_ref) {
29
32
  onChange = _ref.onChange,
30
33
  formatMessage = _ref.intl.formatMessage,
31
34
  showMigration = _ref.showMigration,
32
- onMigrate = _ref.onMigrate;
35
+ onMigrate = _ref.onMigrate,
36
+ onCloseAndSave = _ref.onCloseAndSave,
37
+ isViewMode = _ref.isViewMode;
33
38
  var ratioWidth = useMemo(function () {
34
39
  return mediaHeight / mediaWidth;
35
40
  }, [mediaHeight, mediaWidth]);
@@ -82,6 +87,37 @@ export var PixelEntry = function PixelEntry(_ref) {
82
87
  }
83
88
  };
84
89
 
90
+ // Handle submit when user presses enter or click close button in PixelEntryComponentNext
91
+ var handleCloseAndSave = useCallback(function (data) {
92
+ if (data.inputWidth === '' || data.inputHeight === '') {
93
+ return;
94
+ }
95
+ if (onCloseAndSave) {
96
+ var widthToBeSubmitted = data.inputWidth;
97
+ var validation = 'valid';
98
+ if (data.inputWidth < minWidth) {
99
+ widthToBeSubmitted = minWidth;
100
+ validation = 'less-than-min';
101
+ }
102
+ if (data.inputWidth > maxWidth) {
103
+ widthToBeSubmitted = maxWidth;
104
+ validation = 'greater-than-max';
105
+ }
106
+
107
+ // If user keeps submitting an invalid input, node width attribute will be updated with the same value
108
+ // and won't upadte the state in useEffect (since width is the same)
109
+ // Thus, we set the state here to always display the correct dimension
110
+ if (validation !== 'valid') {
111
+ setComputedWidth(widthToBeSubmitted);
112
+ setComputedHeight(Math.round(ratioWidth * widthToBeSubmitted));
113
+ }
114
+ onCloseAndSave({
115
+ width: widthToBeSubmitted,
116
+ validation: validation
117
+ });
118
+ }
119
+ }, [maxWidth, minWidth, onCloseAndSave, ratioWidth]);
120
+
85
121
  // Handle updating computed fields based on
86
122
  var handleOnChange = useCallback(function (type) {
87
123
  return function (event) {
@@ -119,6 +155,17 @@ export var PixelEntry = function PixelEntry(_ref) {
119
155
  testId: PIXELENTRY_MIGRATION_BUTTON_TESTID
120
156
  }, formatMessage(messages.migrationButtonText)));
121
157
  }
158
+ if (editorExperiment('platform_editor_controls', 'variant1')) {
159
+ return jsx(PixelEntryComponentNext, {
160
+ maxWidth: maxWidth,
161
+ formatMessage: formatMessage,
162
+ handleFieldChange: handleOnChange,
163
+ computedWidth: computedWidth,
164
+ computedHeight: computedHeight,
165
+ handleCloseAndSave: handleCloseAndSave,
166
+ isViewMode: isViewMode
167
+ });
168
+ }
122
169
  return (
123
170
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
124
171
  jsx("div", {
@@ -148,7 +195,7 @@ export var PixelEntry = function PixelEntry(_ref) {
148
195
  // Ignored via go/ees005
149
196
  // eslint-disable-next-line react/jsx-props-no-spreading
150
197
  , _extends({}, fieldProps, {
151
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
198
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/no-unsafe-style-overrides -- Ignored via go/DSP-18766
152
199
  css: [pixelSizingWidthInput, pixelSizingInput],
153
200
  appearance: "none",
154
201
  isCompact: true,
@@ -175,7 +222,7 @@ export var PixelEntry = function PixelEntry(_ref) {
175
222
  // Ignored via go/ees005
176
223
  // eslint-disable-next-line react/jsx-props-no-spreading
177
224
  , _extends({}, fieldProps, {
178
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
225
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/no-unsafe-style-overrides -- Ignored via go/DSP-18766
179
226
  css: [pixelSizingHeightInput, pixelSizingInput],
180
227
  appearance: "none",
181
228
  isCompact: true,
@@ -191,12 +238,120 @@ export var PixelEntry = function PixelEntry(_ref) {
191
238
  }))
192
239
  );
193
240
  };
194
- export var FullWidthDisplay = function FullWidthDisplay(_ref5) {
195
- var formatMessage = _ref5.intl.formatMessage;
196
- return (
197
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
198
- jsx("div", {
199
- css: pixelSizingFullWidthLabelStyles
200
- }, jsx(Text, null, formatMessage(messages.fullWidthLabel)))
201
- );
241
+ var pixelEntryWrapperStyles = xcss({
242
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
243
+ width: "".concat(PIXEL_RESIZING_TOOLBAR_WIDTH, "px")
244
+ });
245
+ var pixelEntryWrapperViewModeStyles = xcss({
246
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
247
+ width: "".concat(PIXEL_VIEW_MODE_TOOLBAR_WIDTH, "px")
248
+ });
249
+ var fieldStyles = css({
250
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
251
+ '[data-ds--text-field--input]': {
252
+ paddingBlock: "var(--ds-space-0, 0px)",
253
+ paddingInline: "var(--ds-space-100, 8px)"
254
+ },
255
+ flex: '1'
256
+ });
257
+ var dividerStyles = xcss({
258
+ width: '1px',
259
+ height: "var(--ds-space-500, 40px)",
260
+ background: "var(--ds-border, #091E4224)",
261
+ marginInlineEnd: 'space.050'
262
+ });
263
+ export var PixelEntryComponentNext = function PixelEntryComponentNext(_ref5) {
264
+ var maxWidth = _ref5.maxWidth,
265
+ formatMessage = _ref5.formatMessage,
266
+ handleFieldChange = _ref5.handleFieldChange,
267
+ computedWidth = _ref5.computedWidth,
268
+ computedHeight = _ref5.computedHeight,
269
+ handleCloseAndSave = _ref5.handleCloseAndSave,
270
+ isViewMode = _ref5.isViewMode;
271
+ var widthInputRef = useRef(null);
272
+ useEffect(function () {
273
+ if (widthInputRef.current) {
274
+ if (isViewMode) {
275
+ widthInputRef.current.blur();
276
+ } else {
277
+ widthInputRef.current.focus();
278
+ }
279
+ }
280
+ }, [isViewMode, widthInputRef]);
281
+ var handleKeyDown = useCallback(function (event) {
282
+ if (event.key === 'Enter') {
283
+ handleCloseAndSave({
284
+ inputWidth: computedWidth,
285
+ inputHeight: computedHeight
286
+ });
287
+ }
288
+ }, [computedWidth, computedHeight, handleCloseAndSave]);
289
+ return jsx(Box, {
290
+ xcss: [pixelEntryWrapperStyles, isViewMode && pixelEntryWrapperViewModeStyles]
291
+ }, jsx(Inline, {
292
+ alignBlock: "center",
293
+ spread: "space-between"
294
+ }, jsx(Box, {
295
+ paddingInlineStart: "space.100"
296
+ }, jsx(Text, {
297
+ color: "color.text.subtlest"
298
+ }, formatMessage(messages.inputWidthLabel))), jsx("div", {
299
+ css: fieldStyles
300
+ }, jsx(Tooltip, {
301
+ hideTooltipOnMouseDown: true,
302
+ hideTooltipOnClick: true,
303
+ position: "top",
304
+ content: formatMessage(messages.inputWidthTooltip, {
305
+ maxWidth: maxWidth
306
+ })
307
+ }, jsx(Textfield, {
308
+ name: "inputWidth",
309
+ value: computedWidth,
310
+ ref: widthInputRef,
311
+ height: "var(--ds-space-250, 20px)",
312
+ appearance: "none",
313
+ pattern: "\\d*",
314
+ "aria-label": formatMessage(messages.inputWidthAriaLabel, {
315
+ maxWidth: maxWidth
316
+ }),
317
+ onChange: handleFieldChange('inputWidth'),
318
+ onKeyDown: handleKeyDown
319
+ }))), jsx(Box, {
320
+ paddingInlineStart: "space.100"
321
+ }, jsx(Text, {
322
+ color: "color.text.subtlest"
323
+ }, formatMessage(messages.inputHeightTooltip))), jsx("div", {
324
+ css: fieldStyles
325
+ }, jsx(Tooltip, {
326
+ hideTooltipOnMouseDown: true,
327
+ hideTooltipOnClick: true,
328
+ content: formatMessage(messages.inputHeightTooltip),
329
+ position: "top"
330
+ }, jsx(Textfield, {
331
+ name: "inputHeight",
332
+ value: computedHeight,
333
+ height: "var(--ds-space-250, 20px)",
334
+ appearance: "none",
335
+ pattern: "\\d*",
336
+ "aria-label": formatMessage(messages.inputHeightAriaLabel),
337
+ onChange: handleFieldChange('inputHeight'),
338
+ onKeyDown: handleKeyDown
339
+ }))), !isViewMode && jsx(Fragment, null, jsx(Box, {
340
+ xcss: dividerStyles
341
+ }), jsx(IconButton, {
342
+ icon: function icon() {
343
+ return jsx(CloseIcon, {
344
+ label: "",
345
+ color: "var(--ds-icon-subtlest, #626F86)"
346
+ });
347
+ },
348
+ label: formatMessage(messages.closePixelEntry),
349
+ appearance: "subtle",
350
+ onClick: function onClick() {
351
+ handleCloseAndSave({
352
+ inputWidth: computedWidth,
353
+ inputHeight: computedHeight
354
+ });
355
+ }
356
+ }))));
202
357
  };
@@ -252,32 +252,39 @@ export var setBorderMark = function setBorderMark(editorAnalyticsAPI) {
252
252
  };
253
253
  };
254
254
  };
255
+ export var updateMediaSingleWidthTr = function updateMediaSingleWidthTr(editorAnalyticsAPI, state, width, validation, inputMethod, layout) {
256
+ var selectedMediaSingleNode = getSelectedMediaSingle(state);
257
+ if (!selectedMediaSingleNode) {
258
+ return null;
259
+ }
260
+ var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
261
+ width: width,
262
+ widthType: 'pixel',
263
+ layout: layout
264
+ }));
265
+ tr.setMeta('scrollIntoView', false);
266
+ tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
267
+ var $pos = state.doc.resolve(selectedMediaSingleNode.pos);
268
+ var parentNodeType = $pos ? $pos.parent.type.name : undefined;
269
+ var payload = getMediaInputResizeAnalyticsEvent('mediaSingle', {
270
+ width: width,
271
+ layout: layout,
272
+ validation: validation,
273
+ inputMethod: inputMethod,
274
+ parentNode: parentNodeType
275
+ });
276
+ if (payload) {
277
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
278
+ }
279
+ return tr;
280
+ };
255
281
  export var updateMediaSingleWidth = function updateMediaSingleWidth(editorAnalyticsAPI) {
256
282
  return function (width, validation, inputMethod, layout) {
257
283
  return function (state, dispatch) {
258
- var selectedMediaSingleNode = getSelectedMediaSingle(state);
259
- if (!selectedMediaSingleNode) {
284
+ var tr = updateMediaSingleWidthTr(editorAnalyticsAPI, state, width, validation, inputMethod, layout);
285
+ if (!tr) {
260
286
  return false;
261
287
  }
262
- var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
263
- width: width,
264
- widthType: 'pixel',
265
- layout: layout
266
- }));
267
- tr.setMeta('scrollIntoView', false);
268
- tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
269
- var $pos = state.doc.resolve(selectedMediaSingleNode.pos);
270
- var parentNodeType = $pos ? $pos.parent.type.name : undefined;
271
- var payload = getMediaInputResizeAnalyticsEvent('mediaSingle', {
272
- width: width,
273
- layout: layout,
274
- validation: validation,
275
- inputMethod: inputMethod,
276
- parentNode: parentNodeType
277
- });
278
- if (payload) {
279
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
280
- }
281
288
  if (dispatch) {
282
289
  dispatch(tr);
283
290
  }