@atlaskit/editor-core 192.5.0 → 192.7.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 192.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#77607](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/77607) [`78ab76808037`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/78ab76808037) - Fixed bug where save button state was not updated correctly for when media upload is in progress or finish uploading
8
+
9
+ ## 192.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#63691](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/63691) [`02293e70771b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/02293e70771b) - add allowWidthDetector option to be used to skip width detector in renderer, to make media single works in inline extension like excerpt include
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 192.5.0
4
20
 
5
21
  ### Minor Changes
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.CommentEditorWithIntl = void 0;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
12
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
@@ -13,7 +14,6 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
13
14
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
17
17
  var _react = _interopRequireWildcard(require("react"));
18
18
  var _react2 = require("@emotion/react");
19
19
  var _classnames = _interopRequireDefault(require("classnames"));
@@ -37,17 +37,49 @@ var _PluginSlot = _interopRequireDefault(require("../../PluginSlot"));
37
37
  var _Toolbar = _interopRequireDefault(require("../../Toolbar"));
38
38
  var _WithFlash = _interopRequireDefault(require("../../WithFlash"));
39
39
  var _Toolbar2 = require("./Toolbar");
40
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
41
- /** @jsx jsx */
42
40
  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); }
43
41
  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; }
44
42
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
45
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
43
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /* eslint-disable @atlaskit/design-system/ensure-design-token-usage/preview */ /** @jsx jsx */
46
44
  var CommentEditorMargin = 14;
47
- var commentEditorStyle = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n\n .less-margin .ProseMirror {\n margin: ", " ", "\n ", ";\n }\n\n min-width: 272px;\n /* Border + Toolbar + Footer + (Paragraph + ((Paragraph + Margin) * (DefaultLines - 1)) */\n /* calc(2px + 40px + 24px + ( 20px + (32px * 2))) */\n\n height: auto;\n background-color: ", ";\n border: 1px solid ", ";\n box-sizing: border-box;\n border-radius: ", "px;\n\n max-width: inherit;\n word-wrap: break-word;\n"])), "var(--ds-space-150, 12px)", "var(--ds-space-100, 8px)", "var(--ds-space-100, 8px)", "var(--ds-background-input, white)", "var(--ds-border, ".concat(_colors.N40, ")"), (0, _constants.borderRadius)());
48
- var ContentArea = (0, _ContentStyles.createEditorContentStyle)((0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n flex-grow: 1;\n overflow-x: ", ";\n line-height: 24px;\n\n /** Hack for Bitbucket to ensure entire editorView gets drop event; see ED-3294 **/\n /** Hack for table controls. Otherwise margin collapse and controls are misplaced. **/\n .ProseMirror {\n margin: ", ";\n }\n\n .gridParent {\n margin-left: ", "px;\n margin-right: ", "px;\n width: calc(100% + ", "px);\n }\n\n padding: ", ";\n\n ", ";\n"])), (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-sticky-scrollbar') ? 'clip' : 'hidden', "var(--ds-space-150, 12px)", CommentEditorMargin - _styles.GRID_GUTTER, CommentEditorMargin - _styles.GRID_GUTTER, CommentEditorMargin - _styles.GRID_GUTTER, "var(--ds-space-250, 20px)", _commonStyles.tableCommentEditorStyles));
45
+ var commentEditorStyle = (0, _react2.css)({
46
+ display: 'flex',
47
+ flexDirection: 'column',
48
+ '.less-margin .ProseMirror': {
49
+ margin: "var(--ds-space-150, 12px)".concat(" ", "var(--ds-space-100, 8px)", " ", "var(--ds-space-100, 8px)")
50
+ },
51
+ minWidth: '272px',
52
+ height: 'auto',
53
+ backgroundColor: "var(--ds-background-input, white)",
54
+ border: "1px solid ".concat("var(--ds-border, ".concat(_colors.N40, ")")),
55
+ boxSizing: 'border-box',
56
+ borderRadius: "".concat((0, _constants.borderRadius)(), "px"),
57
+ maxWidth: 'inherit',
58
+ wordWrap: 'break-word'
59
+ });
60
+ var ContentArea = (0, _ContentStyles.createEditorContentStyle)((0, _react2.css)({
61
+ flexGrow: 1,
62
+ overflowX: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-sticky-scrollbar') ? 'clip' : 'hidden',
63
+ lineHeight: '24px',
64
+ '.ProseMirror': {
65
+ margin: "var(--ds-space-150, 12px)"
66
+ },
67
+ '.gridParent': {
68
+ marginLeft: "".concat(CommentEditorMargin - _styles.GRID_GUTTER, "px"),
69
+ marginRight: "".concat(CommentEditorMargin - _styles.GRID_GUTTER, "px"),
70
+ width: "calc(100% + ".concat(CommentEditorMargin - _styles.GRID_GUTTER, "px)")
71
+ },
72
+ padding: "var(--ds-space-250, 20px)"
73
+ }, _commonStyles.tableCommentEditorStyles));
49
74
  ContentArea.displayName = 'ContentArea';
50
- var secondaryToolbarStyle = (0, _react2.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n box-sizing: border-box;\n justify-content: flex-end;\n align-items: center;\n display: flex;\n padding: ", " ", ";\n"])), "var(--ds-space-150, 12px)", "var(--ds-space-025, 2px)");
75
+ var secondaryToolbarStyle = (0, _react2.css)({
76
+ boxSizing: 'border-box',
77
+ justifyContent: 'flex-end',
78
+ alignItems: 'center',
79
+ display: 'flex',
80
+ padding: "var(--ds-space-150, 12px)".concat(" ", "var(--ds-space-025, 2px)")
81
+ });
82
+ var appearance = 'comment';
51
83
  var Editor = /*#__PURE__*/function (_React$Component) {
52
84
  (0, _inherits2.default)(Editor, _React$Component);
53
85
  var _super = _createSuper(Editor);
@@ -114,7 +146,9 @@ var Editor = /*#__PURE__*/function (_React$Component) {
114
146
  return (0, _react2.jsx)(_WithFlash.default, {
115
147
  animate: maxContentSizeReached
116
148
  }, (0, _react2.jsx)("div", {
117
- css: [commentEditorStyle, (0, _react2.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n min-height: ", "px;\n "])), minHeight)],
149
+ css: [commentEditorStyle, (0, _react2.css)({
150
+ minHeight: "".concat(minHeight, "px")
151
+ })],
118
152
  className: "akEditor",
119
153
  ref: _this.wrapperElementRef
120
154
  }, (0, _react2.jsx)(_Toolbar2.MainToolbar, {
@@ -153,7 +187,9 @@ var Editor = /*#__PURE__*/function (_React$Component) {
153
187
  ref: function ref(_ref3) {
154
188
  return _this.containerElement = _ref3;
155
189
  },
156
- css: maxHeight ? (0, _react2.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n max-height: ", "px;\n "])), maxHeight) : null,
190
+ css: maxHeight ? (0, _react2.css)({
191
+ maxHeight: "".concat(maxHeight, "px")
192
+ }) : null,
157
193
  className: (0, _classnames.default)('ak-editor-content-area', {
158
194
  'less-margin': width < _editorSharedStyles.akEditorMobileBreakoutPoint
159
195
  }),
@@ -219,4 +255,165 @@ function RenderWithPluginState(_ref4) {
219
255
  mediaState: mediaState !== null && mediaState !== void 0 ? mediaState : undefined
220
256
  }));
221
257
  }
222
- var CommentEditorWithIntl = exports.CommentEditorWithIntl = (0, _reactIntlNext.injectIntl)(Editor);
258
+ var EditorNext = function EditorNext(props) {
259
+ var api = (0, _context.usePresetContext)();
260
+ var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(api, ['media', 'maxContentSize']),
261
+ mediaState = _useSharedPluginState2.mediaState,
262
+ maxContentSizeState = _useSharedPluginState2.maxContentSizeState;
263
+ var editorDOMElement = props.editorDOMElement,
264
+ editorView = props.editorView,
265
+ editorActions = props.editorActions,
266
+ eventDispatcher = props.eventDispatcher,
267
+ providerFactory = props.providerFactory,
268
+ contentComponents = props.contentComponents,
269
+ customContentComponents = props.customContentComponents,
270
+ customPrimaryToolbarComponents = props.customPrimaryToolbarComponents,
271
+ primaryToolbarComponents = props.primaryToolbarComponents,
272
+ customSecondaryToolbarComponents = props.customSecondaryToolbarComponents,
273
+ popupsMountPoint = props.popupsMountPoint,
274
+ popupsBoundariesElement = props.popupsBoundariesElement,
275
+ popupsScrollableElement = props.popupsScrollableElement,
276
+ maxHeight = props.maxHeight,
277
+ _props$minHeight = props.minHeight,
278
+ minHeight = _props$minHeight === void 0 ? 150 : _props$minHeight,
279
+ onSave = props.onSave,
280
+ onCancel = props.onCancel,
281
+ disabled = props.disabled,
282
+ dispatchAnalyticsEvent = props.dispatchAnalyticsEvent,
283
+ intl = props.intl,
284
+ useStickyToolbar = props.useStickyToolbar,
285
+ pluginHooks = props.pluginHooks,
286
+ featureFlags = props.featureFlags,
287
+ innerRef = props.innerRef;
288
+ var maxContentSizeReached = Boolean(maxContentSizeState === null || maxContentSizeState === void 0 ? void 0 : maxContentSizeState.maxContentSizeReached);
289
+ var showSecondaryToolbar = !!onSave || !!onCancel || !!customSecondaryToolbarComponents;
290
+ var containerElement = null;
291
+
292
+ // Wrapper container for toolbar and content area
293
+ var wrapperElementRef = (0, _react.useMemo)(function () {
294
+ return innerRef || /*#__PURE__*/_react.default.createRef();
295
+ }, [innerRef]);
296
+ var _useState = (0, _react.useState)(disabled),
297
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
298
+ saveButtonDisabled = _useState2[0],
299
+ setSaveButtonDisabled = _useState2[1];
300
+ (0, _react.useEffect)(function () {
301
+ if (mediaState) {
302
+ mediaState.subscribeToUploadInProgressState(setSaveButtonDisabled);
303
+ }
304
+ return function () {
305
+ return mediaState === null || mediaState === void 0 ? void 0 : mediaState.unsubscribeFromUploadInProgressState(setSaveButtonDisabled);
306
+ };
307
+ }, [mediaState]);
308
+ var handleSave = (0, _react.useCallback)(function () {
309
+ if (editorView && onSave) {
310
+ onSave(editorView);
311
+ }
312
+ }, [editorView, onSave]);
313
+ var handleCancel = (0, _react.useCallback)(function () {
314
+ if (editorView && onCancel) {
315
+ onCancel(editorView);
316
+ }
317
+ }, [editorView, onCancel]);
318
+ var isShortcutToFocusToolbar = (0, _react.useCallback)(function (event) {
319
+ //Alt + F9 to reach first element in this main toolbar
320
+ return event.altKey && (event.key === 'F9' || event.keyCode === 120);
321
+ }, []);
322
+ var isTwoLineToolbarEnabled = !!customPrimaryToolbarComponents && !!(featureFlags !== null && featureFlags !== void 0 && featureFlags.twoLineEditorToolbar);
323
+ var handleEscape = (0, _react.useCallback)(function (event) {
324
+ if (!(editorView !== null && editorView !== void 0 && editorView.hasFocus())) {
325
+ editorView === null || editorView === void 0 || editorView.focus();
326
+ }
327
+ event.preventDefault();
328
+ event.stopPropagation();
329
+ }, [editorView]);
330
+ return (0, _react2.jsx)(_WithFlash.default, {
331
+ animate: maxContentSizeReached
332
+ }, (0, _react2.jsx)("div", {
333
+ css: [commentEditorStyle, (0, _react2.css)({
334
+ minHeight: "".concat(minHeight, "px")
335
+ })],
336
+ className: "akEditor",
337
+ ref: wrapperElementRef
338
+ }, (0, _react2.jsx)(_Toolbar2.MainToolbar, {
339
+ useStickyToolbar: useStickyToolbar,
340
+ twoLineEditorToolbar: isTwoLineToolbarEnabled
341
+ }, (0, _react2.jsx)(_uiMenu.ToolbarArrowKeyNavigationProvider, {
342
+ editorView: editorView,
343
+ childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
344
+ isShortcutToFocusToolbar: isShortcutToFocusToolbar,
345
+ handleEscape: handleEscape,
346
+ editorAppearance: appearance,
347
+ useStickyToolbar: useStickyToolbar,
348
+ intl: intl
349
+ }, (0, _react2.jsx)(_Toolbar.default, {
350
+ editorView: editorView,
351
+ editorActions: editorActions,
352
+ eventDispatcher: eventDispatcher,
353
+ providerFactory: providerFactory,
354
+ appearance: appearance,
355
+ items: primaryToolbarComponents,
356
+ popupsMountPoint: popupsMountPoint,
357
+ popupsBoundariesElement: popupsBoundariesElement,
358
+ popupsScrollableElement: popupsScrollableElement,
359
+ disabled: !!disabled,
360
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
361
+ containerElement: containerElement,
362
+ twoLineEditorToolbar: isTwoLineToolbarEnabled
363
+ }), (0, _react2.jsx)("div", {
364
+ css: (0, _Toolbar2.mainToolbarCustomComponentsSlotStyle)(isTwoLineToolbarEnabled)
365
+ }, customPrimaryToolbarComponents))), (0, _react2.jsx)(_Addon.ClickAreaBlock, {
366
+ editorView: editorView,
367
+ editorDisabled: disabled
368
+ }, (0, _react2.jsx)(_ui.WidthConsumer, null, function (_ref5) {
369
+ var width = _ref5.width;
370
+ return (0, _react2.jsx)(ContentArea, {
371
+ ref: function ref(_ref6) {
372
+ return containerElement = _ref6;
373
+ },
374
+ css: maxHeight ? (0, _react2.css)({
375
+ maxHeight: "".concat(maxHeight, "px")
376
+ }) : null,
377
+ className: (0, _classnames.default)('ak-editor-content-area', {
378
+ 'less-margin': width < _editorSharedStyles.akEditorMobileBreakoutPoint
379
+ }),
380
+ featureFlags: featureFlags
381
+ }, customContentComponents && 'before' in customContentComponents ? customContentComponents.before : customContentComponents, (0, _react2.jsx)(_PluginSlot.default, {
382
+ editorView: editorView,
383
+ editorActions: editorActions,
384
+ eventDispatcher: eventDispatcher,
385
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
386
+ providerFactory: providerFactory,
387
+ appearance: appearance,
388
+ items: contentComponents,
389
+ popupsMountPoint: popupsMountPoint,
390
+ popupsBoundariesElement: popupsBoundariesElement,
391
+ popupsScrollableElement: popupsScrollableElement,
392
+ containerElement: containerElement,
393
+ disabled: !!disabled,
394
+ wrapperElement: wrapperElementRef.current,
395
+ pluginHooks: pluginHooks
396
+ }), editorDOMElement, customContentComponents && 'after' in customContentComponents ? customContentComponents.after : null);
397
+ }))), showSecondaryToolbar && (0, _react2.jsx)("div", {
398
+ css: secondaryToolbarStyle,
399
+ "data-testid": "ak-editor-secondary-toolbar"
400
+ }, (0, _react2.jsx)(_buttonGroup.default, null, !!onSave && (0, _react2.jsx)(_customThemeButton.default, {
401
+ appearance: "primary",
402
+ onClick: handleSave,
403
+ testId: "comment-save-button",
404
+ isDisabled: disabled || saveButtonDisabled
405
+ }, intl.formatMessage(_messages.default.saveButton)), !!onCancel && (0, _react2.jsx)(_customThemeButton.default, {
406
+ appearance: "subtle",
407
+ onClick: handleCancel,
408
+ isDisabled: disabled
409
+ }, intl.formatMessage(_messages.default.cancelButton))), (0, _react2.jsx)("span", {
410
+ style: {
411
+ flexGrow: 1
412
+ }
413
+ }), customSecondaryToolbarComponents));
414
+ };
415
+ EditorNext.displayName = 'CommentEditorAppearance';
416
+ var CommentEditorNextWithIntl = (0, _reactIntlNext.injectIntl)(EditorNext);
417
+ var CommentEditorOldWithIntl = (0, _reactIntlNext.injectIntl)(Editor);
418
+ var ExportComp = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.alluploadsfinished-dispatch-update_ivtow') ? CommentEditorNextWithIntl : CommentEditorOldWithIntl;
419
+ var CommentEditorWithIntl = exports.CommentEditorWithIntl = ExportComp;
@@ -82,6 +82,12 @@ var editorContentAreaContainerStyle = function editorContentAreaContainerStyle(c
82
82
  '.pm-table-container, .code-block, .extension-container': {
83
83
  maxWidth: "".concat(containerWidth - TOTAL_PADDING - _consts.tableMarginFullWidthMode * 2, "px")
84
84
  },
85
+ '.extension-container.inline': {
86
+ maxWidth: '100%'
87
+ },
88
+ 'td .extension-container.inline': {
89
+ maxWidth: 'inherit'
90
+ },
85
91
  '.multiBodiedExtension--container': {
86
92
  maxWidth: "".concat(containerWidth - TOTAL_PADDING - _consts.tableMarginFullWidthMode * 2, "px")
87
93
  },
@@ -5,4 +5,4 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/editor-core";
8
- var version = exports.version = "192.5.0";
8
+ var version = exports.version = "192.7.0";
@@ -1,6 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage/preview */
2
3
  /** @jsx jsx */
3
- import React, { Fragment } from 'react';
4
+ import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
4
5
  import { css, jsx } from '@emotion/react';
5
6
  import classnames from 'classnames';
6
7
  import { injectIntl } from 'react-intl-next';
@@ -24,57 +25,44 @@ import Toolbar from '../../Toolbar';
24
25
  import WithFlash from '../../WithFlash';
25
26
  import { MainToolbar, mainToolbarCustomComponentsSlotStyle } from './Toolbar';
26
27
  const CommentEditorMargin = 14;
27
- const commentEditorStyle = css`
28
- display: flex;
29
- flex-direction: column;
30
-
31
- .less-margin .ProseMirror {
32
- margin: ${"var(--ds-space-150, 12px)"} ${"var(--ds-space-100, 8px)"}
33
- ${"var(--ds-space-100, 8px)"};
34
- }
35
-
36
- min-width: 272px;
37
- /* Border + Toolbar + Footer + (Paragraph + ((Paragraph + Margin) * (DefaultLines - 1)) */
38
- /* calc(2px + 40px + 24px + ( 20px + (32px * 2))) */
39
-
40
- height: auto;
41
- background-color: ${"var(--ds-background-input, white)"};
42
- border: 1px solid ${`var(--ds-border, ${N40})`};
43
- box-sizing: border-box;
44
- border-radius: ${borderRadius()}px;
45
-
46
- max-width: inherit;
47
- word-wrap: break-word;
48
- `;
49
- const ContentArea = createEditorContentStyle(css`
50
- flex-grow: 1;
51
- overflow-x: ${getBooleanFF('platform.editor.table-sticky-scrollbar') ? 'clip' : 'hidden'};
52
- line-height: 24px;
53
-
54
- /** Hack for Bitbucket to ensure entire editorView gets drop event; see ED-3294 **/
55
- /** Hack for table controls. Otherwise margin collapse and controls are misplaced. **/
56
- .ProseMirror {
57
- margin: ${"var(--ds-space-150, 12px)"};
58
- }
59
-
60
- .gridParent {
61
- margin-left: ${CommentEditorMargin - GRID_GUTTER}px;
62
- margin-right: ${CommentEditorMargin - GRID_GUTTER}px;
63
- width: calc(100% + ${CommentEditorMargin - GRID_GUTTER}px);
64
- }
65
-
66
- padding: ${"var(--ds-space-250, 20px)"};
67
-
68
- ${tableCommentEditorStyles};
69
- `);
28
+ const commentEditorStyle = css({
29
+ display: 'flex',
30
+ flexDirection: 'column',
31
+ '.less-margin .ProseMirror': {
32
+ margin: `${"var(--ds-space-150, 12px)"} ${"var(--ds-space-100, 8px)"} ${"var(--ds-space-100, 8px)"}`
33
+ },
34
+ minWidth: '272px',
35
+ height: 'auto',
36
+ backgroundColor: "var(--ds-background-input, white)",
37
+ border: `1px solid ${`var(--ds-border, ${N40})`}`,
38
+ boxSizing: 'border-box',
39
+ borderRadius: `${borderRadius()}px`,
40
+ maxWidth: 'inherit',
41
+ wordWrap: 'break-word'
42
+ });
43
+ const ContentArea = createEditorContentStyle(css({
44
+ flexGrow: 1,
45
+ overflowX: getBooleanFF('platform.editor.table-sticky-scrollbar') ? 'clip' : 'hidden',
46
+ lineHeight: '24px',
47
+ '.ProseMirror': {
48
+ margin: "var(--ds-space-150, 12px)"
49
+ },
50
+ '.gridParent': {
51
+ marginLeft: `${CommentEditorMargin - GRID_GUTTER}px`,
52
+ marginRight: `${CommentEditorMargin - GRID_GUTTER}px`,
53
+ width: `calc(100% + ${CommentEditorMargin - GRID_GUTTER}px)`
54
+ },
55
+ padding: "var(--ds-space-250, 20px)"
56
+ }, tableCommentEditorStyles));
70
57
  ContentArea.displayName = 'ContentArea';
71
- const secondaryToolbarStyle = css`
72
- box-sizing: border-box;
73
- justify-content: flex-end;
74
- align-items: center;
75
- display: flex;
76
- padding: ${"var(--ds-space-150, 12px)"} ${"var(--ds-space-025, 2px)"};
77
- `;
58
+ const secondaryToolbarStyle = css({
59
+ boxSizing: 'border-box',
60
+ justifyContent: 'flex-end',
61
+ alignItems: 'center',
62
+ display: 'flex',
63
+ padding: `${"var(--ds-space-150, 12px)"} ${"var(--ds-space-025, 2px)"}`
64
+ });
65
+ const appearance = 'comment';
78
66
  class Editor extends React.Component {
79
67
  constructor(props) {
80
68
  super(props);
@@ -138,9 +126,9 @@ class Editor extends React.Component {
138
126
  return jsx(WithFlash, {
139
127
  animate: maxContentSizeReached
140
128
  }, jsx("div", {
141
- css: [commentEditorStyle, css`
142
- min-height: ${minHeight}px;
143
- `],
129
+ css: [commentEditorStyle, css({
130
+ minHeight: `${minHeight}px`
131
+ })],
144
132
  className: "akEditor",
145
133
  ref: this.wrapperElementRef
146
134
  }, jsx(MainToolbar, {
@@ -178,9 +166,9 @@ class Editor extends React.Component {
178
166
  }) => {
179
167
  return jsx(ContentArea, {
180
168
  ref: ref => this.containerElement = ref,
181
- css: maxHeight ? css`
182
- max-height: ${maxHeight}px;
183
- ` : null,
169
+ css: maxHeight ? css({
170
+ maxHeight: `${maxHeight}px`
171
+ }) : null,
184
172
  className: classnames('ak-editor-content-area', {
185
173
  'less-margin': width < akEditorMobileBreakoutPoint
186
174
  }),
@@ -243,4 +231,159 @@ function RenderWithPluginState({
243
231
  mediaState: mediaState !== null && mediaState !== void 0 ? mediaState : undefined
244
232
  }));
245
233
  }
246
- export const CommentEditorWithIntl = injectIntl(Editor);
234
+ const EditorNext = props => {
235
+ const api = usePresetContext();
236
+ const {
237
+ mediaState,
238
+ maxContentSizeState
239
+ } = useSharedPluginState(api, ['media', 'maxContentSize']);
240
+ const {
241
+ editorDOMElement,
242
+ editorView,
243
+ editorActions,
244
+ eventDispatcher,
245
+ providerFactory,
246
+ contentComponents,
247
+ customContentComponents,
248
+ customPrimaryToolbarComponents,
249
+ primaryToolbarComponents,
250
+ customSecondaryToolbarComponents,
251
+ popupsMountPoint,
252
+ popupsBoundariesElement,
253
+ popupsScrollableElement,
254
+ maxHeight,
255
+ minHeight = 150,
256
+ onSave,
257
+ onCancel,
258
+ disabled,
259
+ dispatchAnalyticsEvent,
260
+ intl,
261
+ useStickyToolbar,
262
+ pluginHooks,
263
+ featureFlags,
264
+ innerRef
265
+ } = props;
266
+ const maxContentSizeReached = Boolean(maxContentSizeState === null || maxContentSizeState === void 0 ? void 0 : maxContentSizeState.maxContentSizeReached);
267
+ const showSecondaryToolbar = !!onSave || !!onCancel || !!customSecondaryToolbarComponents;
268
+ let containerElement = null;
269
+
270
+ // Wrapper container for toolbar and content area
271
+ const wrapperElementRef = useMemo(() => innerRef || /*#__PURE__*/React.createRef(), [innerRef]);
272
+ const [saveButtonDisabled, setSaveButtonDisabled] = useState(disabled);
273
+ useEffect(() => {
274
+ if (mediaState) {
275
+ mediaState.subscribeToUploadInProgressState(setSaveButtonDisabled);
276
+ }
277
+ return () => mediaState === null || mediaState === void 0 ? void 0 : mediaState.unsubscribeFromUploadInProgressState(setSaveButtonDisabled);
278
+ }, [mediaState]);
279
+ const handleSave = useCallback(() => {
280
+ if (editorView && onSave) {
281
+ onSave(editorView);
282
+ }
283
+ }, [editorView, onSave]);
284
+ const handleCancel = useCallback(() => {
285
+ if (editorView && onCancel) {
286
+ onCancel(editorView);
287
+ }
288
+ }, [editorView, onCancel]);
289
+ const isShortcutToFocusToolbar = useCallback(event => {
290
+ //Alt + F9 to reach first element in this main toolbar
291
+ return event.altKey && (event.key === 'F9' || event.keyCode === 120);
292
+ }, []);
293
+ const isTwoLineToolbarEnabled = !!customPrimaryToolbarComponents && !!(featureFlags !== null && featureFlags !== void 0 && featureFlags.twoLineEditorToolbar);
294
+ const handleEscape = useCallback(event => {
295
+ if (!(editorView !== null && editorView !== void 0 && editorView.hasFocus())) {
296
+ editorView === null || editorView === void 0 ? void 0 : editorView.focus();
297
+ }
298
+ event.preventDefault();
299
+ event.stopPropagation();
300
+ }, [editorView]);
301
+ return jsx(WithFlash, {
302
+ animate: maxContentSizeReached
303
+ }, jsx("div", {
304
+ css: [commentEditorStyle, css({
305
+ minHeight: `${minHeight}px`
306
+ })],
307
+ className: "akEditor",
308
+ ref: wrapperElementRef
309
+ }, jsx(MainToolbar, {
310
+ useStickyToolbar: useStickyToolbar,
311
+ twoLineEditorToolbar: isTwoLineToolbarEnabled
312
+ }, jsx(ToolbarArrowKeyNavigationProvider, {
313
+ editorView: editorView,
314
+ childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
315
+ isShortcutToFocusToolbar: isShortcutToFocusToolbar,
316
+ handleEscape: handleEscape,
317
+ editorAppearance: appearance,
318
+ useStickyToolbar: useStickyToolbar,
319
+ intl: intl
320
+ }, jsx(Toolbar, {
321
+ editorView: editorView,
322
+ editorActions: editorActions,
323
+ eventDispatcher: eventDispatcher,
324
+ providerFactory: providerFactory,
325
+ appearance: appearance,
326
+ items: primaryToolbarComponents,
327
+ popupsMountPoint: popupsMountPoint,
328
+ popupsBoundariesElement: popupsBoundariesElement,
329
+ popupsScrollableElement: popupsScrollableElement,
330
+ disabled: !!disabled,
331
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
332
+ containerElement: containerElement,
333
+ twoLineEditorToolbar: isTwoLineToolbarEnabled
334
+ }), jsx("div", {
335
+ css: mainToolbarCustomComponentsSlotStyle(isTwoLineToolbarEnabled)
336
+ }, customPrimaryToolbarComponents))), jsx(ClickAreaBlock, {
337
+ editorView: editorView,
338
+ editorDisabled: disabled
339
+ }, jsx(WidthConsumer, null, ({
340
+ width
341
+ }) => {
342
+ return jsx(ContentArea, {
343
+ ref: ref => containerElement = ref,
344
+ css: maxHeight ? css({
345
+ maxHeight: `${maxHeight}px`
346
+ }) : null,
347
+ className: classnames('ak-editor-content-area', {
348
+ 'less-margin': width < akEditorMobileBreakoutPoint
349
+ }),
350
+ featureFlags: featureFlags
351
+ }, customContentComponents && 'before' in customContentComponents ? customContentComponents.before : customContentComponents, jsx(PluginSlot, {
352
+ editorView: editorView,
353
+ editorActions: editorActions,
354
+ eventDispatcher: eventDispatcher,
355
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
356
+ providerFactory: providerFactory,
357
+ appearance: appearance,
358
+ items: contentComponents,
359
+ popupsMountPoint: popupsMountPoint,
360
+ popupsBoundariesElement: popupsBoundariesElement,
361
+ popupsScrollableElement: popupsScrollableElement,
362
+ containerElement: containerElement,
363
+ disabled: !!disabled,
364
+ wrapperElement: wrapperElementRef.current,
365
+ pluginHooks: pluginHooks
366
+ }), editorDOMElement, customContentComponents && 'after' in customContentComponents ? customContentComponents.after : null);
367
+ }))), showSecondaryToolbar && jsx("div", {
368
+ css: secondaryToolbarStyle,
369
+ "data-testid": "ak-editor-secondary-toolbar"
370
+ }, jsx(ButtonGroup, null, !!onSave && jsx(Button, {
371
+ appearance: "primary",
372
+ onClick: handleSave,
373
+ testId: "comment-save-button",
374
+ isDisabled: disabled || saveButtonDisabled
375
+ }, intl.formatMessage(messages.saveButton)), !!onCancel && jsx(Button, {
376
+ appearance: "subtle",
377
+ onClick: handleCancel,
378
+ isDisabled: disabled
379
+ }, intl.formatMessage(messages.cancelButton))), jsx("span", {
380
+ style: {
381
+ flexGrow: 1
382
+ }
383
+ }), customSecondaryToolbarComponents));
384
+ };
385
+ EditorNext.displayName = 'CommentEditorAppearance';
386
+ const CommentEditorNextWithIntl = injectIntl(EditorNext);
387
+ const CommentEditorOldWithIntl = injectIntl(Editor);
388
+ const ExportComp = getBooleanFF('platform.editor.media.alluploadsfinished-dispatch-update_ivtow') ? CommentEditorNextWithIntl : CommentEditorOldWithIntl;
389
+ export const CommentEditorWithIntl = ExportComp;
@@ -72,6 +72,12 @@ const editorContentAreaContainerStyle = containerWidth => css({
72
72
  '.pm-table-container, .code-block, .extension-container': {
73
73
  maxWidth: `${containerWidth - TOTAL_PADDING - tableMarginFullWidthMode * 2}px`
74
74
  },
75
+ '.extension-container.inline': {
76
+ maxWidth: '100%'
77
+ },
78
+ 'td .extension-container.inline': {
79
+ maxWidth: 'inherit'
80
+ },
75
81
  '.multiBodiedExtension--container': {
76
82
  maxWidth: `${containerWidth - TOTAL_PADDING - tableMarginFullWidthMode * 2}px`
77
83
  },
@@ -1,2 +1,2 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "192.5.0";
2
+ export const version = "192.7.0";