@atlaskit/editor-core 192.6.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 +6 -0
- package/dist/cjs/ui/Appearance/Comment/Comment.js +207 -10
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/ui/Appearance/Comment/Comment.js +201 -58
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/ui/Appearance/Comment/Comment.js +208 -9
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/create-preset.d.ts +45 -9
- package/dist/types/presets/default.d.ts +40 -8
- package/dist/types/presets/universal.d.ts +45 -9
- package/dist/types/presets/useUniversalPreset.d.ts +45 -9
- package/dist/types-ts4.5/create-editor/create-preset.d.ts +54 -9
- package/dist/types-ts4.5/presets/default.d.ts +48 -8
- package/dist/types-ts4.5/presets/universal.d.ts +54 -9
- package/dist/types-ts4.5/presets/useUniversalPreset.d.ts +54 -9
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 192.6.0
|
|
4
10
|
|
|
5
11
|
### 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)(
|
|
48
|
-
|
|
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)(
|
|
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)(
|
|
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)(
|
|
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
|
|
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;
|
|
@@ -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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
display: flex
|
|
76
|
-
padding:
|
|
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
|
-
|
|
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
|
-
|
|
183
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "192.
|
|
2
|
+
export const version = "192.7.0";
|