@atlaskit/editor-core 187.14.11 → 187.15.0

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 (36) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/floating-toolbar/ui/Separator.js +2 -13
  3. package/dist/cjs/plugins/media/toolbar/index.js +59 -4
  4. package/dist/cjs/plugins/media/ui/PixelEntry/index.js +152 -0
  5. package/dist/cjs/plugins/media/ui/PixelEntry/messages.js +40 -0
  6. package/dist/cjs/plugins/media/ui/PixelEntry/styles.js +25 -0
  7. package/dist/cjs/plugins/media/ui/PixelEntry/types.js +5 -0
  8. package/dist/cjs/version-wrapper.js +1 -1
  9. package/dist/cjs/version.json +1 -1
  10. package/dist/es2019/plugins/floating-toolbar/ui/Separator.js +2 -14
  11. package/dist/es2019/plugins/media/toolbar/index.js +62 -0
  12. package/dist/es2019/plugins/media/ui/PixelEntry/index.js +133 -0
  13. package/dist/es2019/plugins/media/ui/PixelEntry/messages.js +33 -0
  14. package/dist/es2019/plugins/media/ui/PixelEntry/styles.js +44 -0
  15. package/dist/es2019/plugins/media/ui/PixelEntry/types.js +1 -0
  16. package/dist/es2019/version-wrapper.js +1 -1
  17. package/dist/es2019/version.json +1 -1
  18. package/dist/esm/plugins/floating-toolbar/ui/Separator.js +2 -12
  19. package/dist/esm/plugins/media/toolbar/index.js +59 -4
  20. package/dist/esm/plugins/media/ui/PixelEntry/index.js +140 -0
  21. package/dist/esm/plugins/media/ui/PixelEntry/messages.js +33 -0
  22. package/dist/esm/plugins/media/ui/PixelEntry/styles.js +11 -0
  23. package/dist/esm/plugins/media/ui/PixelEntry/types.js +1 -0
  24. package/dist/esm/version-wrapper.js +1 -1
  25. package/dist/esm/version.json +1 -1
  26. package/dist/types/plugins/floating-toolbar/ui/Separator.d.ts +2 -4
  27. package/dist/types/plugins/media/ui/PixelEntry/index.d.ts +4 -0
  28. package/dist/types/plugins/media/ui/PixelEntry/messages.d.ts +32 -0
  29. package/dist/types/plugins/media/ui/PixelEntry/styles.d.ts +7 -0
  30. package/dist/types/plugins/media/ui/PixelEntry/types.d.ts +35 -0
  31. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Separator.d.ts +2 -4
  32. package/dist/types-ts4.5/plugins/media/ui/PixelEntry/index.d.ts +4 -0
  33. package/dist/types-ts4.5/plugins/media/ui/PixelEntry/messages.d.ts +32 -0
  34. package/dist/types-ts4.5/plugins/media/ui/PixelEntry/styles.d.ts +7 -0
  35. package/dist/types-ts4.5/plugins/media/ui/PixelEntry/types.d.ts +35 -0
  36. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`1a15910366d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1a15910366d) - [ux] New pixel entry component for image resizing floating bar
8
+
9
+ ## 187.14.12
10
+
11
+ ### Patch Changes
12
+
13
+ - [`7b8e8b52110`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7b8e8b52110) - [ED-16733] Editor Media Extraction: Moving Floating Toolbar Separator to editor-common
14
+ - Updated dependencies
15
+
3
16
  ## 187.14.11
4
17
 
5
18
  ### Patch Changes
@@ -1,20 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
- var _react = require("@emotion/react");
10
- var _colors = require("@atlaskit/theme/colors");
11
- var _templateObject;
12
- /** @jsx jsx */
13
- var separator = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n background: ", ";\n width: 1px;\n height: 20px;\n margin: 0 4px;\n align-self: center;\n"])), "var(--ds-border, ".concat(_colors.N30, ")"));
14
- var _default = function _default() {
15
- return (0, _react.jsx)("div", {
16
- css: separator,
17
- className: "separator"
18
- });
19
- };
7
+ var _ui = require("@atlaskit/editor-common/ui");
8
+ var _default = _ui.FloatingToolbarSeparator;
20
9
  exports.default = _default;
@@ -33,6 +33,9 @@ var _styles = require("../nodeviews/styles");
33
33
  var _ImageBorder = _interopRequireDefault(require("../ui/ImageBorder"));
34
34
  var _currentMediaNode = require("../utils/current-media-node");
35
35
  var _imageBorder = require("./imageBorder");
36
+ var _PixelEntry = require("../ui/PixelEntry");
37
+ var _mediaSingle = require("@atlaskit/editor-common/media-single");
38
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
36
39
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
37
40
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
38
41
  var remove = function remove(state, dispatch) {
@@ -255,6 +258,58 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
255
258
  type: 'separator'
256
259
  });
257
260
  }
261
+
262
+ // Pixel Entry Toolbar Support
263
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') && allowResizing) {
264
+ toolbarButtons.push({
265
+ type: 'custom',
266
+ fallback: [],
267
+ render: function render(editorView) {
268
+ if (!editorView) {
269
+ return null;
270
+ }
271
+ var state = editorView.state,
272
+ dispatch = editorView.dispatch;
273
+ var selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
274
+ if (!selectedMediaSingleNode) {
275
+ return null;
276
+ }
277
+ var selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
278
+ if (!selectedMediaNode) {
279
+ return null;
280
+ }
281
+ var singleMediaWidth = selectedMediaSingleNode.node.attrs.width;
282
+ var _selectedMediaNode$at = selectedMediaNode.attrs,
283
+ mediaWidth = _selectedMediaNode$at.width,
284
+ mediaHeight = _selectedMediaNode$at.height;
285
+ return /*#__PURE__*/_react.default.createElement(_PixelEntry.PixelEntry, {
286
+ intl: intl,
287
+ width: singleMediaWidth,
288
+ mediaWidth: mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH,
289
+ mediaHeight: mediaHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT,
290
+ validate: function validate(value) {
291
+ if (value !== '' && !isNaN(value) && value >= _mediaSingle.MEDIA_SINGLE_MIN_PIXEL_WIDTH && value <= _editorSharedStyles.akEditorFullWidthLayoutWidth) {
292
+ return true;
293
+ }
294
+ return false;
295
+ },
296
+ onSubmit: function onSubmit(_ref) {
297
+ var width = _ref.width;
298
+ var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
299
+ width: width,
300
+ widthType: 'pixel'
301
+ }));
302
+ dispatch(tr);
303
+ }
304
+ });
305
+ }
306
+ });
307
+ if (!pluginState.isResizing) {
308
+ toolbarButtons.push({
309
+ type: 'separator'
310
+ });
311
+ }
312
+ }
258
313
  if (allowLinking && (0, _linking.shouldShowMediaLinkToolbar)(state)) {
259
314
  toolbarButtons.push({
260
315
  type: 'custom',
@@ -303,8 +358,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
303
358
  type: 'separator'
304
359
  });
305
360
  }
306
- var _ref = (_pluginInjectionApi$d7 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d7 !== void 0 ? _pluginInjectionApi$d7 : {},
307
- hoverDecoration = _ref.hoverDecoration;
361
+ var _ref2 = (_pluginInjectionApi$d7 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d7 !== void 0 ? _pluginInjectionApi$d7 : {},
362
+ hoverDecoration = _ref2.hoverDecoration;
308
363
  var removeButton = {
309
364
  id: 'editor.media.delete',
310
365
  type: 'button',
@@ -348,8 +403,8 @@ var floatingToolbar = function floatingToolbar(state, intl) {
348
403
  getEditorFeatureFlags = options.getEditorFeatureFlags;
349
404
  var mediaPluginState = _pluginKey.stateKey.getState(state);
350
405
  var mediaLinkingState = (0, _linking2.getMediaLinkingState)(state);
351
- var _ref2 = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {},
352
- hoverDecoration = _ref2.hoverDecoration;
406
+ var _ref3 = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {},
407
+ hoverDecoration = _ref3.hoverDecoration;
353
408
  if (!mediaPluginState || mediaPluginState.isResizing) {
354
409
  return;
355
410
  }
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.PixelEntry = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+ var _react = require("@emotion/react");
12
+ var _react2 = require("react");
13
+ var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
14
+ var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
15
+ var _button = _interopRequireDefault(require("@atlaskit/button"));
16
+ var _form = _interopRequireWildcard(require("@atlaskit/form"));
17
+ var _styles = require("./styles");
18
+ var _messages = require("./messages");
19
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+ /** @jsx jsx */
22
+
23
+ var PixelEntry = function PixelEntry(_ref) {
24
+ var width = _ref.width,
25
+ mediaWidth = _ref.mediaWidth,
26
+ mediaHeight = _ref.mediaHeight,
27
+ onSubmit = _ref.onSubmit,
28
+ validate = _ref.validate,
29
+ formatMessage = _ref.intl.formatMessage;
30
+ var ratioWidth = (0, _react2.useMemo)(function () {
31
+ return mediaHeight / mediaWidth;
32
+ }, [mediaHeight, mediaWidth]);
33
+ var ratioHeight = (0, _react2.useMemo)(function () {
34
+ return mediaWidth / mediaHeight;
35
+ }, [mediaHeight, mediaWidth]);
36
+ var _useState = (0, _react2.useState)(width),
37
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
38
+ computedWidth = _useState2[0],
39
+ setComputedWidth = _useState2[1];
40
+ var _useState3 = (0, _react2.useState)(Math.round(ratioWidth * width)),
41
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
42
+ computedHeight = _useState4[0],
43
+ setComputedHeight = _useState4[1];
44
+
45
+ // Handle update to width from outside component
46
+ (0, _react2.useEffect)(function () {
47
+ setComputedWidth(width);
48
+ setComputedHeight(Math.round(ratioWidth * width));
49
+ }, [width, ratioWidth]);
50
+
51
+ // Handle submit when user presses enter in form
52
+ var handleOnSubmit = function handleOnSubmit(data) {
53
+ if (onSubmit) {
54
+ if (data.inputWidth === '') {
55
+ return;
56
+ }
57
+ onSubmit({
58
+ width: data.inputWidth
59
+ });
60
+ }
61
+ };
62
+
63
+ // Syncronous validation returning undefined for valid and string for invalid
64
+ var handleValidateWidth = (0, _react2.useCallback)(function (value) {
65
+ if (!value || !validate) {
66
+ return;
67
+ }
68
+ if (validate) {
69
+ return validate(value) === true ? undefined : formatMessage(_messages.messages.validationFailedMessage);
70
+ }
71
+ return;
72
+ }, [validate, formatMessage]);
73
+
74
+ // Handle updating computed fields based on
75
+ var handleOnChange = (0, _react2.useCallback)(function (type) {
76
+ return function (event) {
77
+ var value = parseInt(event.currentTarget.value);
78
+ var newInputValue = isNaN(value) ? '' : parseInt(event.currentTarget.value);
79
+ switch (type) {
80
+ case 'inputWidth':
81
+ {
82
+ setComputedWidth(newInputValue);
83
+ if (!isNaN(value)) {
84
+ setComputedHeight(Math.round(ratioWidth * value));
85
+ }
86
+ break;
87
+ }
88
+ case 'inputHeight':
89
+ {
90
+ setComputedHeight(newInputValue);
91
+ if (!isNaN(value)) {
92
+ setComputedWidth(Math.round(ratioHeight * value));
93
+ }
94
+ break;
95
+ }
96
+ }
97
+ };
98
+ }, [ratioHeight, ratioWidth]);
99
+ return (0, _react.jsx)("div", {
100
+ css: _styles.pixelEntryForm
101
+ }, (0, _react.jsx)(_form.default, {
102
+ onSubmit: handleOnSubmit
103
+ }, function (_ref2) {
104
+ var formProps = _ref2.formProps;
105
+ return (0, _react.jsx)("form", formProps, (0, _react.jsx)("div", {
106
+ css: _styles.pixelSizingWrapper
107
+ }, (0, _react.jsx)(_form.Field, {
108
+ key: "inputWidth",
109
+ name: "inputWidth",
110
+ validate: handleValidateWidth,
111
+ defaultValue: computedWidth
112
+ }, function (_ref3) {
113
+ var fieldProps = _ref3.fieldProps;
114
+ return (0, _react.jsx)(_tooltip.default, {
115
+ hideTooltipOnMouseDown: true,
116
+ content: formatMessage(_messages.messages.inputWidthTooltip),
117
+ position: "top"
118
+ }, (0, _react.jsx)(_textfield.default, (0, _extends2.default)({}, fieldProps, {
119
+ css: [_styles.pixelSizingWidthInput, _styles.pixelSizingInput],
120
+ appearance: "none",
121
+ isCompact: true,
122
+ onChange: handleOnChange('inputWidth'),
123
+ pattern: "\\d*",
124
+ "aria-label": formatMessage(_messages.messages.inputWidthAriaLabel)
125
+ })));
126
+ }), (0, _react.jsx)("span", {
127
+ css: _styles.pixelSizingLabel
128
+ }, "x"), (0, _react.jsx)(_form.Field, {
129
+ key: "inputHeight",
130
+ name: "inputHeight",
131
+ defaultValue: computedHeight
132
+ }, function (_ref4) {
133
+ var fieldProps = _ref4.fieldProps;
134
+ return (0, _react.jsx)(_tooltip.default, {
135
+ hideTooltipOnMouseDown: true,
136
+ content: formatMessage(_messages.messages.inputHeightTooltip),
137
+ position: "top"
138
+ }, (0, _react.jsx)(_textfield.default, (0, _extends2.default)({}, fieldProps, {
139
+ css: [_styles.pixelSizingHeightInput, _styles.pixelSizingInput],
140
+ appearance: "none",
141
+ isCompact: true,
142
+ onChange: handleOnChange('inputHeight'),
143
+ pattern: "\\d*",
144
+ "aria-label": formatMessage(_messages.messages.inputHeightAriaLabel)
145
+ })));
146
+ }), (0, _react.jsx)(_button.default, {
147
+ css: _styles.pixelEntryHiddenSubmit,
148
+ type: "submit"
149
+ }, formatMessage(_messages.messages.submitButtonText))));
150
+ }));
151
+ };
152
+ exports.PixelEntry = PixelEntry;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.messages = void 0;
7
+ var _reactIntlNext = require("react-intl-next");
8
+ var messages = (0, _reactIntlNext.defineMessages)({
9
+ validationFailedMessage: {
10
+ id: 'fabric.editor.media.pixelEntry.validationFailedMessage',
11
+ defaultMessage: 'Validation for width failed',
12
+ description: 'The passed in validator function returned false'
13
+ },
14
+ inputWidthTooltip: {
15
+ id: 'fabric.editor.media.pixelEntry.inputWidthTooltip',
16
+ defaultMessage: 'Width',
17
+ description: 'The tooltip displayed ontop of the width input'
18
+ },
19
+ inputWidthAriaLabel: {
20
+ id: 'fabric.editor.media.pixelEntry.inputWidthAriaLabel',
21
+ defaultMessage: 'width input',
22
+ description: 'The width input aria label'
23
+ },
24
+ inputHeightTooltip: {
25
+ id: 'fabric.editor.media.pixelEntry.inputHeightTooltip',
26
+ defaultMessage: 'Height',
27
+ description: 'The tooltip displayed ontop of the height input'
28
+ },
29
+ inputHeightAriaLabel: {
30
+ id: 'fabric.editor.media.pixelEntry.inputHeightAriaLabel',
31
+ defaultMessage: 'height input',
32
+ description: 'The width input aria label'
33
+ },
34
+ submitButtonText: {
35
+ id: 'fabric.editor.media.pixelEntry.submitButtonText',
36
+ defaultMessage: 'Submit',
37
+ description: 'The text give to the hidden submit button'
38
+ }
39
+ });
40
+ exports.messages = messages;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.pixelSizingWrapper = exports.pixelSizingWidthInput = exports.pixelSizingLabel = exports.pixelSizingInput = exports.pixelSizingHeightInput = exports.pixelEntryHiddenSubmit = exports.pixelEntryForm = void 0;
8
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
+ var _react = require("@emotion/react");
10
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
11
+ var PIXEL_SIZING_WRAPPER_MINIMUM_WIDTH = 120;
12
+ var pixelSizingWrapper = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: grid;\n grid-template-columns: 1fr 1em 1fr 0;\n grid-template-rows: auto;\n grid-template-areas: 'widthinput label heightinput submit';\n width: ", "px;\n text-align: center;\n height: ", ";\n\n // Atlaskit fieldset does not allow style override\n & > * {\n margin-top: 0 !important;\n }\n"])), PIXEL_SIZING_WRAPPER_MINIMUM_WIDTH, "var(--ds-space-300, 24px)");
13
+ exports.pixelSizingWrapper = pixelSizingWrapper;
14
+ var pixelEntryForm = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n form {\n width: 100%;\n }\n"])));
15
+ exports.pixelEntryForm = pixelEntryForm;
16
+ var pixelSizingInput = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: ", ";\n & input {\n text-align: center;\n }\n"])), "var(--ds-space-300, 24px)");
17
+ exports.pixelSizingInput = pixelSizingInput;
18
+ var pixelSizingLabel = (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n grid-area: label;\n line-height: ", ";\n"])), "var(--ds-space-300, 24px)");
19
+ exports.pixelSizingLabel = pixelSizingLabel;
20
+ var pixelSizingWidthInput = (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n grid-area: widthinput;\n"])));
21
+ exports.pixelSizingWidthInput = pixelSizingWidthInput;
22
+ var pixelSizingHeightInput = (0, _react.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n grid-area: heightinput;\n"])));
23
+ exports.pixelSizingHeightInput = pixelSizingHeightInput;
24
+ var pixelEntryHiddenSubmit = (0, _react.css)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n grid-area: submit;\n visibility: hidden;\n width: 0;\n height: 0;\n"])));
25
+ exports.pixelEntryHiddenSubmit = pixelEntryHiddenSubmit;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "187.14.11";
9
+ var version = "187.15.0";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.14.11",
3
+ "version": "187.15.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,14 +1,2 @@
1
- /** @jsx jsx */
2
- import { css, jsx } from '@emotion/react';
3
- import { N30 } from '@atlaskit/theme/colors';
4
- const separator = css`
5
- background: ${`var(--ds-border, ${N30})`};
6
- width: 1px;
7
- height: 20px;
8
- margin: 0 4px;
9
- align-self: center;
10
- `;
11
- export default (() => jsx("div", {
12
- css: separator,
13
- className: "separator"
14
- }));
1
+ import { FloatingToolbarSeparator } from '@atlaskit/editor-common/ui';
2
+ export default FloatingToolbarSeparator;
@@ -24,6 +24,9 @@ import { MediaInlineNodeSelector, MediaSingleNodeSelector } from '../nodeviews/s
24
24
  import ImageBorderItem from '../ui/ImageBorder';
25
25
  import { currentMediaNodeBorderMark } from '../utils/current-media-node';
26
26
  import { shouldShowImageBorder } from './imageBorder';
27
+ import { PixelEntry } from '../ui/PixelEntry';
28
+ import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
29
+ import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
27
30
  const remove = (state, dispatch) => {
28
31
  if (dispatch) {
29
32
  dispatch(removeSelectedNode(state.tr));
@@ -256,6 +259,65 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
256
259
  type: 'separator'
257
260
  });
258
261
  }
262
+
263
+ // Pixel Entry Toolbar Support
264
+ if (getBooleanFF('platform.editor.media.extended-resize-experience') && allowResizing) {
265
+ toolbarButtons.push({
266
+ type: 'custom',
267
+ fallback: [],
268
+ render: editorView => {
269
+ if (!editorView) {
270
+ return null;
271
+ }
272
+ const {
273
+ state,
274
+ dispatch
275
+ } = editorView;
276
+ const selectedMediaSingleNode = getSelectedMediaSingle(state);
277
+ if (!selectedMediaSingleNode) {
278
+ return null;
279
+ }
280
+ const selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
281
+ if (!selectedMediaNode) {
282
+ return null;
283
+ }
284
+ const {
285
+ width: singleMediaWidth
286
+ } = selectedMediaSingleNode.node.attrs;
287
+ const {
288
+ width: mediaWidth,
289
+ height: mediaHeight
290
+ } = selectedMediaNode.attrs;
291
+ return /*#__PURE__*/React.createElement(PixelEntry, {
292
+ intl: intl,
293
+ width: singleMediaWidth,
294
+ mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
295
+ mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
296
+ validate: value => {
297
+ if (value !== '' && !isNaN(value) && value >= MEDIA_SINGLE_MIN_PIXEL_WIDTH && value <= akEditorFullWidthLayoutWidth) {
298
+ return true;
299
+ }
300
+ return false;
301
+ },
302
+ onSubmit: ({
303
+ width
304
+ }) => {
305
+ const tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, {
306
+ ...selectedMediaSingleNode.node.attrs,
307
+ width,
308
+ widthType: 'pixel'
309
+ });
310
+ dispatch(tr);
311
+ }
312
+ });
313
+ }
314
+ });
315
+ if (!pluginState.isResizing) {
316
+ toolbarButtons.push({
317
+ type: 'separator'
318
+ });
319
+ }
320
+ }
259
321
  if (allowLinking && shouldShowMediaLinkToolbar(state)) {
260
322
  toolbarButtons.push({
261
323
  type: 'custom',
@@ -0,0 +1,133 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ /** @jsx jsx */
3
+ import { jsx } from '@emotion/react';
4
+ import { useCallback, useEffect, useMemo, useState } from 'react';
5
+ import Textfield from '@atlaskit/textfield';
6
+ import Tooltip from '@atlaskit/tooltip';
7
+ import Button from '@atlaskit/button';
8
+ import Form, { Field } from '@atlaskit/form';
9
+ import { pixelSizingInput, pixelSizingLabel, pixelSizingWidthInput, pixelSizingHeightInput, pixelSizingWrapper, pixelEntryForm, pixelEntryHiddenSubmit } from './styles';
10
+ import { messages } from './messages';
11
+ export const PixelEntry = ({
12
+ width,
13
+ mediaWidth,
14
+ mediaHeight,
15
+ onSubmit,
16
+ validate,
17
+ intl: {
18
+ formatMessage
19
+ }
20
+ }) => {
21
+ const ratioWidth = useMemo(() => {
22
+ return mediaHeight / mediaWidth;
23
+ }, [mediaHeight, mediaWidth]);
24
+ const ratioHeight = useMemo(() => {
25
+ return mediaWidth / mediaHeight;
26
+ }, [mediaHeight, mediaWidth]);
27
+ const [computedWidth, setComputedWidth] = useState(width);
28
+ const [computedHeight, setComputedHeight] = useState(Math.round(ratioWidth * width));
29
+
30
+ // Handle update to width from outside component
31
+ useEffect(() => {
32
+ setComputedWidth(width);
33
+ setComputedHeight(Math.round(ratioWidth * width));
34
+ }, [width, ratioWidth]);
35
+
36
+ // Handle submit when user presses enter in form
37
+ const handleOnSubmit = data => {
38
+ if (onSubmit) {
39
+ if (data.inputWidth === '') {
40
+ return;
41
+ }
42
+ onSubmit({
43
+ width: data.inputWidth
44
+ });
45
+ }
46
+ };
47
+
48
+ // Syncronous validation returning undefined for valid and string for invalid
49
+ const handleValidateWidth = useCallback(value => {
50
+ if (!value || !validate) {
51
+ return;
52
+ }
53
+ if (validate) {
54
+ return validate(value) === true ? undefined : formatMessage(messages.validationFailedMessage);
55
+ }
56
+ return;
57
+ }, [validate, formatMessage]);
58
+
59
+ // Handle updating computed fields based on
60
+ const handleOnChange = useCallback(type => event => {
61
+ const value = parseInt(event.currentTarget.value);
62
+ const newInputValue = isNaN(value) ? '' : parseInt(event.currentTarget.value);
63
+ switch (type) {
64
+ case 'inputWidth':
65
+ {
66
+ setComputedWidth(newInputValue);
67
+ if (!isNaN(value)) {
68
+ setComputedHeight(Math.round(ratioWidth * value));
69
+ }
70
+ break;
71
+ }
72
+ case 'inputHeight':
73
+ {
74
+ setComputedHeight(newInputValue);
75
+ if (!isNaN(value)) {
76
+ setComputedWidth(Math.round(ratioHeight * value));
77
+ }
78
+ break;
79
+ }
80
+ }
81
+ }, [ratioHeight, ratioWidth]);
82
+ return jsx("div", {
83
+ css: pixelEntryForm
84
+ }, jsx(Form, {
85
+ onSubmit: handleOnSubmit
86
+ }, ({
87
+ formProps
88
+ }) => {
89
+ return jsx("form", formProps, jsx("div", {
90
+ css: pixelSizingWrapper
91
+ }, jsx(Field, {
92
+ key: "inputWidth",
93
+ name: "inputWidth",
94
+ validate: handleValidateWidth,
95
+ defaultValue: computedWidth
96
+ }, ({
97
+ fieldProps
98
+ }) => jsx(Tooltip, {
99
+ hideTooltipOnMouseDown: true,
100
+ content: formatMessage(messages.inputWidthTooltip),
101
+ position: "top"
102
+ }, jsx(Textfield, _extends({}, fieldProps, {
103
+ css: [pixelSizingWidthInput, pixelSizingInput],
104
+ appearance: "none",
105
+ isCompact: true,
106
+ onChange: handleOnChange('inputWidth'),
107
+ pattern: "\\d*",
108
+ "aria-label": formatMessage(messages.inputWidthAriaLabel)
109
+ })))), jsx("span", {
110
+ css: pixelSizingLabel
111
+ }, "x"), jsx(Field, {
112
+ key: "inputHeight",
113
+ name: "inputHeight",
114
+ defaultValue: computedHeight
115
+ }, ({
116
+ fieldProps
117
+ }) => jsx(Tooltip, {
118
+ hideTooltipOnMouseDown: true,
119
+ content: formatMessage(messages.inputHeightTooltip),
120
+ position: "top"
121
+ }, jsx(Textfield, _extends({}, fieldProps, {
122
+ css: [pixelSizingHeightInput, pixelSizingInput],
123
+ appearance: "none",
124
+ isCompact: true,
125
+ onChange: handleOnChange('inputHeight'),
126
+ pattern: "\\d*",
127
+ "aria-label": formatMessage(messages.inputHeightAriaLabel)
128
+ })))), jsx(Button, {
129
+ css: pixelEntryHiddenSubmit,
130
+ type: "submit"
131
+ }, formatMessage(messages.submitButtonText))));
132
+ }));
133
+ };
@@ -0,0 +1,33 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export const messages = defineMessages({
3
+ validationFailedMessage: {
4
+ id: 'fabric.editor.media.pixelEntry.validationFailedMessage',
5
+ defaultMessage: 'Validation for width failed',
6
+ description: 'The passed in validator function returned false'
7
+ },
8
+ inputWidthTooltip: {
9
+ id: 'fabric.editor.media.pixelEntry.inputWidthTooltip',
10
+ defaultMessage: 'Width',
11
+ description: 'The tooltip displayed ontop of the width input'
12
+ },
13
+ inputWidthAriaLabel: {
14
+ id: 'fabric.editor.media.pixelEntry.inputWidthAriaLabel',
15
+ defaultMessage: 'width input',
16
+ description: 'The width input aria label'
17
+ },
18
+ inputHeightTooltip: {
19
+ id: 'fabric.editor.media.pixelEntry.inputHeightTooltip',
20
+ defaultMessage: 'Height',
21
+ description: 'The tooltip displayed ontop of the height input'
22
+ },
23
+ inputHeightAriaLabel: {
24
+ id: 'fabric.editor.media.pixelEntry.inputHeightAriaLabel',
25
+ defaultMessage: 'height input',
26
+ description: 'The width input aria label'
27
+ },
28
+ submitButtonText: {
29
+ id: 'fabric.editor.media.pixelEntry.submitButtonText',
30
+ defaultMessage: 'Submit',
31
+ description: 'The text give to the hidden submit button'
32
+ }
33
+ });
@@ -0,0 +1,44 @@
1
+ import { css } from '@emotion/react';
2
+ const PIXEL_SIZING_WRAPPER_MINIMUM_WIDTH = 120;
3
+ export const pixelSizingWrapper = css`
4
+ display: grid;
5
+ grid-template-columns: 1fr 1em 1fr 0;
6
+ grid-template-rows: auto;
7
+ grid-template-areas: 'widthinput label heightinput submit';
8
+ width: ${PIXEL_SIZING_WRAPPER_MINIMUM_WIDTH}px;
9
+ text-align: center;
10
+ height: ${"var(--ds-space-300, 24px)"};
11
+
12
+ // Atlaskit fieldset does not allow style override
13
+ & > * {
14
+ margin-top: 0 !important;
15
+ }
16
+ `;
17
+ export const pixelEntryForm = css`
18
+ form {
19
+ width: 100%;
20
+ }
21
+ `;
22
+ export const pixelSizingInput = css`
23
+ width: 100%;
24
+ height: ${"var(--ds-space-300, 24px)"};
25
+ & input {
26
+ text-align: center;
27
+ }
28
+ `;
29
+ export const pixelSizingLabel = css`
30
+ grid-area: label;
31
+ line-height: ${"var(--ds-space-300, 24px)"};
32
+ `;
33
+ export const pixelSizingWidthInput = css`
34
+ grid-area: widthinput;
35
+ `;
36
+ export const pixelSizingHeightInput = css`
37
+ grid-area: heightinput;
38
+ `;
39
+ export const pixelEntryHiddenSubmit = css`
40
+ grid-area: submit;
41
+ visibility: hidden;
42
+ width: 0;
43
+ height: 0;
44
+ `;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.14.11";
2
+ export const version = "187.15.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.14.11",
3
+ "version": "187.15.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,12 +1,2 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject;
3
- /** @jsx jsx */
4
- import { css, jsx } from '@emotion/react';
5
- import { N30 } from '@atlaskit/theme/colors';
6
- var separator = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n width: 1px;\n height: 20px;\n margin: 0 4px;\n align-self: center;\n"])), "var(--ds-border, ".concat(N30, ")"));
7
- export default (function () {
8
- return jsx("div", {
9
- css: separator,
10
- className: "separator"
11
- });
12
- });
1
+ import { FloatingToolbarSeparator } from '@atlaskit/editor-common/ui';
2
+ export default FloatingToolbarSeparator;
@@ -28,6 +28,9 @@ import { MediaInlineNodeSelector, MediaSingleNodeSelector } from '../nodeviews/s
28
28
  import ImageBorderItem from '../ui/ImageBorder';
29
29
  import { currentMediaNodeBorderMark } from '../utils/current-media-node';
30
30
  import { shouldShowImageBorder } from './imageBorder';
31
+ import { PixelEntry } from '../ui/PixelEntry';
32
+ import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
33
+ import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
31
34
  var remove = function remove(state, dispatch) {
32
35
  if (dispatch) {
33
36
  dispatch(removeSelectedNode(state.tr));
@@ -248,6 +251,58 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
248
251
  type: 'separator'
249
252
  });
250
253
  }
254
+
255
+ // Pixel Entry Toolbar Support
256
+ if (getBooleanFF('platform.editor.media.extended-resize-experience') && allowResizing) {
257
+ toolbarButtons.push({
258
+ type: 'custom',
259
+ fallback: [],
260
+ render: function render(editorView) {
261
+ if (!editorView) {
262
+ return null;
263
+ }
264
+ var state = editorView.state,
265
+ dispatch = editorView.dispatch;
266
+ var selectedMediaSingleNode = getSelectedMediaSingle(state);
267
+ if (!selectedMediaSingleNode) {
268
+ return null;
269
+ }
270
+ var selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
271
+ if (!selectedMediaNode) {
272
+ return null;
273
+ }
274
+ var singleMediaWidth = selectedMediaSingleNode.node.attrs.width;
275
+ var _selectedMediaNode$at = selectedMediaNode.attrs,
276
+ mediaWidth = _selectedMediaNode$at.width,
277
+ mediaHeight = _selectedMediaNode$at.height;
278
+ return /*#__PURE__*/React.createElement(PixelEntry, {
279
+ intl: intl,
280
+ width: singleMediaWidth,
281
+ mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
282
+ mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
283
+ validate: function validate(value) {
284
+ if (value !== '' && !isNaN(value) && value >= MEDIA_SINGLE_MIN_PIXEL_WIDTH && value <= akEditorFullWidthLayoutWidth) {
285
+ return true;
286
+ }
287
+ return false;
288
+ },
289
+ onSubmit: function onSubmit(_ref) {
290
+ var width = _ref.width;
291
+ var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
292
+ width: width,
293
+ widthType: 'pixel'
294
+ }));
295
+ dispatch(tr);
296
+ }
297
+ });
298
+ }
299
+ });
300
+ if (!pluginState.isResizing) {
301
+ toolbarButtons.push({
302
+ type: 'separator'
303
+ });
304
+ }
305
+ }
251
306
  if (allowLinking && shouldShowMediaLinkToolbar(state)) {
252
307
  toolbarButtons.push({
253
308
  type: 'custom',
@@ -296,8 +351,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
296
351
  type: 'separator'
297
352
  });
298
353
  }
299
- var _ref = (_pluginInjectionApi$d7 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d7 !== void 0 ? _pluginInjectionApi$d7 : {},
300
- hoverDecoration = _ref.hoverDecoration;
354
+ var _ref2 = (_pluginInjectionApi$d7 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d7 !== void 0 ? _pluginInjectionApi$d7 : {},
355
+ hoverDecoration = _ref2.hoverDecoration;
301
356
  var removeButton = {
302
357
  id: 'editor.media.delete',
303
358
  type: 'button',
@@ -341,8 +396,8 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
341
396
  getEditorFeatureFlags = options.getEditorFeatureFlags;
342
397
  var mediaPluginState = stateKey.getState(state);
343
398
  var mediaLinkingState = getMediaLinkingState(state);
344
- var _ref2 = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {},
345
- hoverDecoration = _ref2.hoverDecoration;
399
+ var _ref3 = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {},
400
+ hoverDecoration = _ref3.hoverDecoration;
346
401
  if (!mediaPluginState || mediaPluginState.isResizing) {
347
402
  return;
348
403
  }
@@ -0,0 +1,140 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ /** @jsx jsx */
4
+ import { jsx } from '@emotion/react';
5
+ import { useCallback, useEffect, useMemo, useState } from 'react';
6
+ import Textfield from '@atlaskit/textfield';
7
+ import Tooltip from '@atlaskit/tooltip';
8
+ import Button from '@atlaskit/button';
9
+ import Form, { Field } from '@atlaskit/form';
10
+ import { pixelSizingInput, pixelSizingLabel, pixelSizingWidthInput, pixelSizingHeightInput, pixelSizingWrapper, pixelEntryForm, pixelEntryHiddenSubmit } from './styles';
11
+ import { messages } from './messages';
12
+ export var PixelEntry = function PixelEntry(_ref) {
13
+ var width = _ref.width,
14
+ mediaWidth = _ref.mediaWidth,
15
+ mediaHeight = _ref.mediaHeight,
16
+ onSubmit = _ref.onSubmit,
17
+ validate = _ref.validate,
18
+ formatMessage = _ref.intl.formatMessage;
19
+ var ratioWidth = useMemo(function () {
20
+ return mediaHeight / mediaWidth;
21
+ }, [mediaHeight, mediaWidth]);
22
+ var ratioHeight = useMemo(function () {
23
+ return mediaWidth / mediaHeight;
24
+ }, [mediaHeight, mediaWidth]);
25
+ var _useState = useState(width),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ computedWidth = _useState2[0],
28
+ setComputedWidth = _useState2[1];
29
+ var _useState3 = useState(Math.round(ratioWidth * width)),
30
+ _useState4 = _slicedToArray(_useState3, 2),
31
+ computedHeight = _useState4[0],
32
+ setComputedHeight = _useState4[1];
33
+
34
+ // Handle update to width from outside component
35
+ useEffect(function () {
36
+ setComputedWidth(width);
37
+ setComputedHeight(Math.round(ratioWidth * width));
38
+ }, [width, ratioWidth]);
39
+
40
+ // Handle submit when user presses enter in form
41
+ var handleOnSubmit = function handleOnSubmit(data) {
42
+ if (onSubmit) {
43
+ if (data.inputWidth === '') {
44
+ return;
45
+ }
46
+ onSubmit({
47
+ width: data.inputWidth
48
+ });
49
+ }
50
+ };
51
+
52
+ // Syncronous validation returning undefined for valid and string for invalid
53
+ var handleValidateWidth = useCallback(function (value) {
54
+ if (!value || !validate) {
55
+ return;
56
+ }
57
+ if (validate) {
58
+ return validate(value) === true ? undefined : formatMessage(messages.validationFailedMessage);
59
+ }
60
+ return;
61
+ }, [validate, formatMessage]);
62
+
63
+ // Handle updating computed fields based on
64
+ var handleOnChange = useCallback(function (type) {
65
+ return function (event) {
66
+ var value = parseInt(event.currentTarget.value);
67
+ var newInputValue = isNaN(value) ? '' : parseInt(event.currentTarget.value);
68
+ switch (type) {
69
+ case 'inputWidth':
70
+ {
71
+ setComputedWidth(newInputValue);
72
+ if (!isNaN(value)) {
73
+ setComputedHeight(Math.round(ratioWidth * value));
74
+ }
75
+ break;
76
+ }
77
+ case 'inputHeight':
78
+ {
79
+ setComputedHeight(newInputValue);
80
+ if (!isNaN(value)) {
81
+ setComputedWidth(Math.round(ratioHeight * value));
82
+ }
83
+ break;
84
+ }
85
+ }
86
+ };
87
+ }, [ratioHeight, ratioWidth]);
88
+ return jsx("div", {
89
+ css: pixelEntryForm
90
+ }, jsx(Form, {
91
+ onSubmit: handleOnSubmit
92
+ }, function (_ref2) {
93
+ var formProps = _ref2.formProps;
94
+ return jsx("form", formProps, jsx("div", {
95
+ css: pixelSizingWrapper
96
+ }, jsx(Field, {
97
+ key: "inputWidth",
98
+ name: "inputWidth",
99
+ validate: handleValidateWidth,
100
+ defaultValue: computedWidth
101
+ }, function (_ref3) {
102
+ var fieldProps = _ref3.fieldProps;
103
+ return jsx(Tooltip, {
104
+ hideTooltipOnMouseDown: true,
105
+ content: formatMessage(messages.inputWidthTooltip),
106
+ position: "top"
107
+ }, jsx(Textfield, _extends({}, fieldProps, {
108
+ css: [pixelSizingWidthInput, pixelSizingInput],
109
+ appearance: "none",
110
+ isCompact: true,
111
+ onChange: handleOnChange('inputWidth'),
112
+ pattern: "\\d*",
113
+ "aria-label": formatMessage(messages.inputWidthAriaLabel)
114
+ })));
115
+ }), jsx("span", {
116
+ css: pixelSizingLabel
117
+ }, "x"), jsx(Field, {
118
+ key: "inputHeight",
119
+ name: "inputHeight",
120
+ defaultValue: computedHeight
121
+ }, function (_ref4) {
122
+ var fieldProps = _ref4.fieldProps;
123
+ return jsx(Tooltip, {
124
+ hideTooltipOnMouseDown: true,
125
+ content: formatMessage(messages.inputHeightTooltip),
126
+ position: "top"
127
+ }, jsx(Textfield, _extends({}, fieldProps, {
128
+ css: [pixelSizingHeightInput, pixelSizingInput],
129
+ appearance: "none",
130
+ isCompact: true,
131
+ onChange: handleOnChange('inputHeight'),
132
+ pattern: "\\d*",
133
+ "aria-label": formatMessage(messages.inputHeightAriaLabel)
134
+ })));
135
+ }), jsx(Button, {
136
+ css: pixelEntryHiddenSubmit,
137
+ type: "submit"
138
+ }, formatMessage(messages.submitButtonText))));
139
+ }));
140
+ };
@@ -0,0 +1,33 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var messages = defineMessages({
3
+ validationFailedMessage: {
4
+ id: 'fabric.editor.media.pixelEntry.validationFailedMessage',
5
+ defaultMessage: 'Validation for width failed',
6
+ description: 'The passed in validator function returned false'
7
+ },
8
+ inputWidthTooltip: {
9
+ id: 'fabric.editor.media.pixelEntry.inputWidthTooltip',
10
+ defaultMessage: 'Width',
11
+ description: 'The tooltip displayed ontop of the width input'
12
+ },
13
+ inputWidthAriaLabel: {
14
+ id: 'fabric.editor.media.pixelEntry.inputWidthAriaLabel',
15
+ defaultMessage: 'width input',
16
+ description: 'The width input aria label'
17
+ },
18
+ inputHeightTooltip: {
19
+ id: 'fabric.editor.media.pixelEntry.inputHeightTooltip',
20
+ defaultMessage: 'Height',
21
+ description: 'The tooltip displayed ontop of the height input'
22
+ },
23
+ inputHeightAriaLabel: {
24
+ id: 'fabric.editor.media.pixelEntry.inputHeightAriaLabel',
25
+ defaultMessage: 'height input',
26
+ description: 'The width input aria label'
27
+ },
28
+ submitButtonText: {
29
+ id: 'fabric.editor.media.pixelEntry.submitButtonText',
30
+ defaultMessage: 'Submit',
31
+ description: 'The text give to the hidden submit button'
32
+ }
33
+ });
@@ -0,0 +1,11 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
3
+ import { css } from '@emotion/react';
4
+ var PIXEL_SIZING_WRAPPER_MINIMUM_WIDTH = 120;
5
+ export var pixelSizingWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: grid;\n grid-template-columns: 1fr 1em 1fr 0;\n grid-template-rows: auto;\n grid-template-areas: 'widthinput label heightinput submit';\n width: ", "px;\n text-align: center;\n height: ", ";\n\n // Atlaskit fieldset does not allow style override\n & > * {\n margin-top: 0 !important;\n }\n"])), PIXEL_SIZING_WRAPPER_MINIMUM_WIDTH, "var(--ds-space-300, 24px)");
6
+ export var pixelEntryForm = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n form {\n width: 100%;\n }\n"])));
7
+ export var pixelSizingInput = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 100%;\n height: ", ";\n & input {\n text-align: center;\n }\n"])), "var(--ds-space-300, 24px)");
8
+ export var pixelSizingLabel = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n grid-area: label;\n line-height: ", ";\n"])), "var(--ds-space-300, 24px)");
9
+ export var pixelSizingWidthInput = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n grid-area: widthinput;\n"])));
10
+ export var pixelSizingHeightInput = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n grid-area: heightinput;\n"])));
11
+ export var pixelEntryHiddenSubmit = css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n grid-area: submit;\n visibility: hidden;\n width: 0;\n height: 0;\n"])));
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.14.11";
2
+ export var version = "187.15.0";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.14.11",
3
+ "version": "187.15.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,2 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- declare const _default: () => jsx.JSX.Element;
4
- export default _default;
1
+ import { FloatingToolbarSeparator } from '@atlaskit/editor-common/ui';
2
+ export default FloatingToolbarSeparator;
@@ -0,0 +1,4 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import type { PixelEntryProps } from './types';
4
+ export declare const PixelEntry: ({ width, mediaWidth, mediaHeight, onSubmit, validate, intl: { formatMessage }, }: PixelEntryProps) => jsx.JSX.Element;
@@ -0,0 +1,32 @@
1
+ export declare const messages: {
2
+ validationFailedMessage: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ inputWidthTooltip: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ inputWidthAriaLabel: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ inputHeightTooltip: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ inputHeightAriaLabel: {
23
+ id: string;
24
+ defaultMessage: string;
25
+ description: string;
26
+ };
27
+ submitButtonText: {
28
+ id: string;
29
+ defaultMessage: string;
30
+ description: string;
31
+ };
32
+ };
@@ -0,0 +1,7 @@
1
+ export declare const pixelSizingWrapper: import("@emotion/react").SerializedStyles;
2
+ export declare const pixelEntryForm: import("@emotion/react").SerializedStyles;
3
+ export declare const pixelSizingInput: import("@emotion/react").SerializedStyles;
4
+ export declare const pixelSizingLabel: import("@emotion/react").SerializedStyles;
5
+ export declare const pixelSizingWidthInput: import("@emotion/react").SerializedStyles;
6
+ export declare const pixelSizingHeightInput: import("@emotion/react").SerializedStyles;
7
+ export declare const pixelEntryHiddenSubmit: import("@emotion/react").SerializedStyles;
@@ -0,0 +1,35 @@
1
+ import type { IntlShape } from 'react-intl-next';
2
+ export type PixelEntryProps = {
3
+ /**
4
+ * IntlShape passed in for translations
5
+ */
6
+ intl: IntlShape;
7
+ /**
8
+ * The current pixel width
9
+ */
10
+ width: number;
11
+ /**
12
+ * The original media width used to calculate the height
13
+ */
14
+ mediaWidth: number;
15
+ /**
16
+ * The original media height used to calculate the width
17
+ */
18
+ mediaHeight: number;
19
+ /**
20
+ * The submit function that is called when the form is valid and the submit key is pressed
21
+ */
22
+ onSubmit?: (value: PixelEntryFormData) => void;
23
+ /**
24
+ * An optional validate function that is called before onSubmit is called.
25
+ * The value passed through the validator currently comes from the width input only.
26
+ */
27
+ validate?: (value: number | '') => boolean;
28
+ };
29
+ export type PixelEntryFormValues = {
30
+ inputWidth: number | '';
31
+ inputHeight: number | '';
32
+ };
33
+ export type PixelEntryFormData = {
34
+ width: number;
35
+ };
@@ -1,4 +1,2 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- declare const _default: () => jsx.JSX.Element;
4
- export default _default;
1
+ import { FloatingToolbarSeparator } from '@atlaskit/editor-common/ui';
2
+ export default FloatingToolbarSeparator;
@@ -0,0 +1,4 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import type { PixelEntryProps } from './types';
4
+ export declare const PixelEntry: ({ width, mediaWidth, mediaHeight, onSubmit, validate, intl: { formatMessage }, }: PixelEntryProps) => jsx.JSX.Element;
@@ -0,0 +1,32 @@
1
+ export declare const messages: {
2
+ validationFailedMessage: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ inputWidthTooltip: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ inputWidthAriaLabel: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ inputHeightTooltip: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ inputHeightAriaLabel: {
23
+ id: string;
24
+ defaultMessage: string;
25
+ description: string;
26
+ };
27
+ submitButtonText: {
28
+ id: string;
29
+ defaultMessage: string;
30
+ description: string;
31
+ };
32
+ };
@@ -0,0 +1,7 @@
1
+ export declare const pixelSizingWrapper: import("@emotion/react").SerializedStyles;
2
+ export declare const pixelEntryForm: import("@emotion/react").SerializedStyles;
3
+ export declare const pixelSizingInput: import("@emotion/react").SerializedStyles;
4
+ export declare const pixelSizingLabel: import("@emotion/react").SerializedStyles;
5
+ export declare const pixelSizingWidthInput: import("@emotion/react").SerializedStyles;
6
+ export declare const pixelSizingHeightInput: import("@emotion/react").SerializedStyles;
7
+ export declare const pixelEntryHiddenSubmit: import("@emotion/react").SerializedStyles;
@@ -0,0 +1,35 @@
1
+ import type { IntlShape } from 'react-intl-next';
2
+ export type PixelEntryProps = {
3
+ /**
4
+ * IntlShape passed in for translations
5
+ */
6
+ intl: IntlShape;
7
+ /**
8
+ * The current pixel width
9
+ */
10
+ width: number;
11
+ /**
12
+ * The original media width used to calculate the height
13
+ */
14
+ mediaWidth: number;
15
+ /**
16
+ * The original media height used to calculate the width
17
+ */
18
+ mediaHeight: number;
19
+ /**
20
+ * The submit function that is called when the form is valid and the submit key is pressed
21
+ */
22
+ onSubmit?: (value: PixelEntryFormData) => void;
23
+ /**
24
+ * An optional validate function that is called before onSubmit is called.
25
+ * The value passed through the validator currently comes from the width input only.
26
+ */
27
+ validate?: (value: number | '') => boolean;
28
+ };
29
+ export type PixelEntryFormValues = {
30
+ inputWidth: number | '';
31
+ inputHeight: number | '';
32
+ };
33
+ export type PixelEntryFormData = {
34
+ width: number;
35
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.14.11",
3
+ "version": "187.15.0",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -55,7 +55,7 @@
55
55
  "@atlaskit/code": "^14.6.0",
56
56
  "@atlaskit/date": "^0.10.0",
57
57
  "@atlaskit/datetime-picker": "^12.7.0",
58
- "@atlaskit/editor-common": "^74.40.0",
58
+ "@atlaskit/editor-common": "^74.41.0",
59
59
  "@atlaskit/editor-json-transformer": "^8.10.0",
60
60
  "@atlaskit/editor-markdown-transformer": "^5.2.5",
61
61
  "@atlaskit/editor-palette": "1.5.1",