@atlaskit/editor-core 221.3.2 → 221.3.3

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 (35) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/ui/Appearance/Comment/Comment.js +344 -6
  3. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea.js +402 -10
  4. package/dist/cjs/version-wrapper.js +1 -1
  5. package/dist/es2019/ui/Appearance/Comment/Comment.js +337 -4
  6. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea.js +400 -8
  7. package/dist/es2019/version-wrapper.js +1 -1
  8. package/dist/esm/ui/Appearance/Comment/Comment.js +339 -6
  9. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea.js +398 -10
  10. package/dist/esm/version-wrapper.js +1 -1
  11. package/dist/types/ui/Appearance/Comment/Comment.d.ts +20 -2
  12. package/dist/types/ui/Appearance/FullPage/FullPageContentArea.d.ts +54 -6
  13. package/package.json +3 -3
  14. package/dist/cjs/ui/Appearance/Comment/Comment-compiled.compiled.css +0 -30
  15. package/dist/cjs/ui/Appearance/Comment/Comment-compiled.js +0 -275
  16. package/dist/cjs/ui/Appearance/Comment/Comment-emotion.js +0 -357
  17. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +0 -96
  18. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-compiled.js +0 -190
  19. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-emotion.js +0 -413
  20. package/dist/es2019/ui/Appearance/Comment/Comment-compiled.compiled.css +0 -30
  21. package/dist/es2019/ui/Appearance/Comment/Comment-compiled.js +0 -262
  22. package/dist/es2019/ui/Appearance/Comment/Comment-emotion.js +0 -344
  23. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +0 -96
  24. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-compiled.js +0 -179
  25. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-emotion.js +0 -405
  26. package/dist/esm/ui/Appearance/Comment/Comment-compiled.compiled.css +0 -30
  27. package/dist/esm/ui/Appearance/Comment/Comment-compiled.js +0 -268
  28. package/dist/esm/ui/Appearance/Comment/Comment-emotion.js +0 -346
  29. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +0 -96
  30. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-compiled.js +0 -183
  31. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-emotion.js +0 -403
  32. package/dist/types/ui/Appearance/Comment/Comment-compiled.d.ts +0 -30
  33. package/dist/types/ui/Appearance/Comment/Comment-emotion.d.ts +0 -20
  34. package/dist/types/ui/Appearance/FullPage/FullPageContentArea-compiled.d.ts +0 -56
  35. package/dist/types/ui/Appearance/FullPage/FullPageContentArea-emotion.d.ts +0 -56
@@ -1,275 +0,0 @@
1
- /* Comment-compiled.tsx generated by @compiled/babel-plugin v0.39.1 */
2
- "use strict";
3
-
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
- Object.defineProperty(exports, "__esModule", {
7
- value: true
8
- });
9
- exports.CommentEditorWithIntlCompiled = void 0;
10
- require("./Comment-compiled.compiled.css");
11
- var _runtime = require("@compiled/react/runtime");
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
14
- var _react = _interopRequireWildcard(require("react"));
15
- var _classnames = _interopRequireDefault(require("classnames"));
16
- var _reactIntl = require("react-intl");
17
- var _buttonGroup = _interopRequireDefault(require("@atlaskit/button/button-group"));
18
- var _new = _interopRequireDefault(require("@atlaskit/button/new"));
19
- var _hooks = require("@atlaskit/editor-common/hooks");
20
- var _messages = _interopRequireDefault(require("@atlaskit/editor-common/messages"));
21
- var _ui = require("@atlaskit/editor-common/ui");
22
- var _uiMenu = require("@atlaskit/editor-common/ui-menu");
23
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
24
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
25
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
26
- var _ClickAreaBlock = _interopRequireDefault(require("../../Addon/ClickAreaBlock"));
27
- var _contentComponentWrapper = require("../../Addon/ClickAreaBlock/contentComponentWrapper");
28
- var _EditorContentContainer = _interopRequireDefault(require("../../EditorContentContainer/EditorContentContainer"));
29
- var _PluginSlot = _interopRequireDefault(require("../../PluginSlot"));
30
- var _getPrimaryToolbarComponents = require("../../Toolbar/getPrimaryToolbarComponents");
31
- var _ToolbarWithSizeDetector = require("../../Toolbar/ToolbarWithSizeDetector");
32
- var _WithFlash = _interopRequireDefault(require("../../WithFlash"));
33
- var _CommentToolbar = require("./CommentToolbar");
34
- var _Toolbar = require("./Toolbar");
35
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
36
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
37
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
38
- * Compiled branch of the `platform_editor_core_non_ecc_static_css` experiment.
39
- * Used via `componentWithCondition` in `Comment.tsx`.
40
- *
41
- * Cleanup: delete this file once the experiment has shipped.
42
- */ // Ignored via go/ees005
43
- // eslint-disable-next-line import/no-named-as-default
44
- var commentEditorCompiledStyles = {
45
- commentEditorOld: "_19itno8c _2rkofajl _1e0c1txw _2lx21bp4 _1ul9clpc _4t3i1wug _bfhk1j9a _vchhusvi _p12f1kw7 _slp31hna _13dfutpp _gzr8u2gc _ghozu2gc _oafwu2gc",
46
- commentEditor: "_19itno8c _2rko1qi0 _1e0c1txw _2lx21bp4 _1ul9clpc _4t3i1wug _bfhk1j9a _vchhusvi _p12f1kw7 _slp31hna _13dfutpp _gzr8u2gc _ghozu2gc _oafwu2gc",
47
- modernisedEditor: "_2rkopb1k",
48
- secondaryToolbar: "_vchhusvi _1bahesu3 _4cvr1h6o _1e0c1txw _ca0qutpp _u5f3v77o _n3tdutpp _19bvv77o",
49
- mainToolbarCustomComponentsSlotNew: "_1e0c1txw _1bahesu3 _4cvr1h6o _16jlkb7n _u5f3v47k _p7r11txw _t1edidpf",
50
- mainToolbarCustomComponentsSlotPaddingOverride: "_u5f3idpf",
51
- mainToolbarCustomComponentsSlotTwoLineToolbar: "_xugcidpf",
52
- contentAreaMaxHeight: "_c71lmz22 _18m91wug"
53
- };
54
- var appearance = 'comment';
55
- var CommentEditorWithIntlCompiled = exports.CommentEditorWithIntlCompiled = function CommentEditorWithIntlCompiled(props) {
56
- var _editorAPI$blockMenu$, _editorAPI$blockMenu;
57
- var editorAPI = props.editorAPI;
58
-
59
- // Get useStandardNodeWidth from block menu plugin shared state
60
- // Only access editorAPI when the experiment is enabled to avoid performance impact
61
- var useStandardNodeWidth = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && ((_editorAPI$blockMenu$ = editorAPI === null || editorAPI === void 0 || (_editorAPI$blockMenu = editorAPI.blockMenu) === null || _editorAPI$blockMenu === void 0 || (_editorAPI$blockMenu = _editorAPI$blockMenu.sharedState) === null || _editorAPI$blockMenu === void 0 || (_editorAPI$blockMenu = _editorAPI$blockMenu.currentState()) === null || _editorAPI$blockMenu === void 0 ? void 0 : _editorAPI$blockMenu.useStandardNodeWidth) !== null && _editorAPI$blockMenu$ !== void 0 ? _editorAPI$blockMenu$ : false);
62
- var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(editorAPI, ['maxContentSize', 'primaryToolbar', 'editorViewMode'], function (states) {
63
- var _states$maxContentSiz, _states$primaryToolba, _states$editorViewMod;
64
- return {
65
- maxContentSizeReached: !!((_states$maxContentSiz = states.maxContentSizeState) !== null && _states$maxContentSiz !== void 0 && _states$maxContentSiz.maxContentSizeReached),
66
- primaryToolbarComponentsState: (_states$primaryToolba = states.primaryToolbarState) === null || _states$primaryToolba === void 0 ? void 0 : _states$primaryToolba.components,
67
- editorViewMode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
68
- };
69
- }),
70
- editorViewMode = _useSharedPluginState.editorViewMode,
71
- primaryToolbarComponentsState = _useSharedPluginState.primaryToolbarComponentsState,
72
- maxContentSizeReached = _useSharedPluginState.maxContentSizeReached;
73
- var primaryToolbarState = (0, _getPrimaryToolbarComponents.getPrimaryToolbarComponents)(editorAPI, primaryToolbarComponentsState);
74
- var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(editorAPI, ['media']),
75
- mediaState = _useSharedPluginState2.mediaState;
76
- var intl = (0, _reactIntl.useIntl)();
77
- var editorDOMElement = props.editorDOMElement,
78
- editorView = props.editorView,
79
- editorActions = props.editorActions,
80
- eventDispatcher = props.eventDispatcher,
81
- providerFactory = props.providerFactory,
82
- contentComponents = props.contentComponents,
83
- customContentComponents = props.customContentComponents,
84
- customPrimaryToolbarComponents = props.customPrimaryToolbarComponents,
85
- primaryToolbarComponentsProp = props.primaryToolbarComponents,
86
- customSecondaryToolbarComponents = props.customSecondaryToolbarComponents,
87
- popupsMountPoint = props.popupsMountPoint,
88
- popupsBoundariesElement = props.popupsBoundariesElement,
89
- popupsScrollableElement = props.popupsScrollableElement,
90
- maxHeight = props.maxHeight,
91
- _props$minHeight = props.minHeight,
92
- minHeight = _props$minHeight === void 0 ? 150 : _props$minHeight,
93
- onSave = props.onSave,
94
- onCancel = props.onCancel,
95
- disabled = props.disabled,
96
- dispatchAnalyticsEvent = props.dispatchAnalyticsEvent,
97
- useStickyToolbar = props.useStickyToolbar,
98
- pluginHooks = props.pluginHooks,
99
- featureFlags = props.featureFlags,
100
- innerRef = props.innerRef,
101
- isEditorModernisationEnabled = props.isEditorModernisationEnabled;
102
- var showSecondaryToolbar = !!onSave || !!onCancel || !!customSecondaryToolbarComponents;
103
- var containerElement = _react.default.useRef(null);
104
-
105
- // Wrapper container for toolbar and content area
106
- var wrapperElementRef = (0, _react.useMemo)(function () {
107
- return innerRef || /*#__PURE__*/_react.default.createRef();
108
- }, [innerRef]);
109
- var _useState = (0, _react.useState)(false),
110
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
111
- saveButtonDisabled = _useState2[0],
112
- setSaveButtonDisabled = _useState2[1];
113
- (0, _react.useEffect)(function () {
114
- if (mediaState) {
115
- mediaState.subscribeToUploadInProgressState(setSaveButtonDisabled);
116
- }
117
- return function () {
118
- return mediaState === null || mediaState === void 0 ? void 0 : mediaState.unsubscribeFromUploadInProgressState(setSaveButtonDisabled);
119
- };
120
- }, [mediaState]);
121
- var handleSave = (0, _react.useCallback)(function () {
122
- if (editorView && onSave) {
123
- onSave(editorView);
124
- }
125
- }, [editorView, onSave]);
126
- var handleCancel = (0, _react.useCallback)(function () {
127
- if (editorView && onCancel) {
128
- onCancel(editorView);
129
- }
130
- }, [editorView, onCancel]);
131
- var isShortcutToFocusToolbar = (0, _react.useCallback)(function (event) {
132
- //Alt + F9 to reach first element in this main toolbar
133
- return event.altKey && (event.key === 'F9' || event.keyCode === 120);
134
- }, []);
135
-
136
- // When primary toolbar components is undefined, do not show two line editor toolbar
137
- var isTwoLineToolbarEnabled = !!customPrimaryToolbarComponents;
138
- var handleEscape = (0, _react.useCallback)(function (event) {
139
- if (!(editorView !== null && editorView !== void 0 && editorView.hasFocus())) {
140
- editorView === null || editorView === void 0 || editorView.focus();
141
- }
142
- event.preventDefault();
143
- event.stopPropagation();
144
- }, [editorView]);
145
- var primaryToolbarComponents = primaryToolbarComponentsProp;
146
- if (Array.isArray(primaryToolbarState === null || primaryToolbarState === void 0 ? void 0 : primaryToolbarState.components) && Array.isArray(primaryToolbarComponents)) {
147
- primaryToolbarComponents = primaryToolbarState.components.concat(primaryToolbarComponents);
148
- }
149
- var isToolbarAIFCEnabled = Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar);
150
- var wrapperStyle = (0, _react.useMemo)(function () {
151
- return _objectSpread({
152
- minHeight: "".concat(minHeight, "px")
153
- }, maxHeight ? {
154
- '--comment-editor-max-height': "".concat(maxHeight, "px")
155
- } : {});
156
- }, [minHeight, maxHeight]);
157
- var customToolbarSlot = /*#__PURE__*/_react.default.createElement("div", {
158
- className: (0, _runtime.ax)([commentEditorCompiledStyles.mainToolbarCustomComponentsSlotNew, isTwoLineToolbarEnabled && commentEditorCompiledStyles.mainToolbarCustomComponentsSlotTwoLineToolbar, isToolbarAIFCEnabled && commentEditorCompiledStyles.mainToolbarCustomComponentsSlotPaddingOverride])
159
- }, customPrimaryToolbarComponents);
160
- return /*#__PURE__*/_react.default.createElement(_WithFlash.default, {
161
- animate: maxContentSizeReached
162
- }, /*#__PURE__*/_react.default.createElement(_ui.WidthProvider, null, /*#__PURE__*/_react.default.createElement("div", {
163
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- dynamic minHeight/maxHeight from props
164
- style: wrapperStyle
165
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
166
- ,
167
- className: (0, _runtime.ax)([(0, _expValEquals.expValEquals)('platform_editor_comment_editor_border_radius', 'isEnabled', true) ? commentEditorCompiledStyles.commentEditor : commentEditorCompiledStyles.commentEditorOld, isEditorModernisationEnabled && commentEditorCompiledStyles.modernisedEditor, "akEditor"]),
168
- ref: wrapperElementRef
169
- }, /*#__PURE__*/_react.default.createElement(_Toolbar.MainToolbar, {
170
- isEditorModernisationEnabled: isEditorModernisationEnabled,
171
- useStickyToolbar: useStickyToolbar,
172
- twoLineEditorToolbar: isTwoLineToolbarEnabled,
173
- isNewToolbarEnabled: isToolbarAIFCEnabled
174
- }, isToolbarAIFCEnabled ? /*#__PURE__*/_react.default.createElement(_uiMenu.ToolbarArrowKeyNavigationProvider, {
175
- editorView: editorView,
176
- childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
177
- isShortcutToFocusToolbar: isShortcutToFocusToolbar,
178
- handleEscape: handleEscape,
179
- editorAppearance: appearance,
180
- useStickyToolbar: useStickyToolbar,
181
- intl: intl
182
- }, /*#__PURE__*/_react.default.createElement(_CommentToolbar.CommentToolbar, {
183
- editorAPI: editorAPI,
184
- editorView: editorView,
185
- editorAppearance: appearance,
186
- disabled: !!disabled,
187
- popupsBoundariesElement: popupsBoundariesElement,
188
- popupsScrollableElement: popupsScrollableElement,
189
- popupsMountPoint: popupsMountPoint
190
- }), customPrimaryToolbarComponents ? customToolbarSlot : null) : /*#__PURE__*/_react.default.createElement(_uiMenu.ToolbarArrowKeyNavigationProvider, {
191
- editorView: editorView,
192
- childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
193
- isShortcutToFocusToolbar: isShortcutToFocusToolbar,
194
- handleEscape: handleEscape,
195
- editorAppearance: appearance,
196
- useStickyToolbar: useStickyToolbar,
197
- intl: intl
198
- }, /*#__PURE__*/_react.default.createElement(_ToolbarWithSizeDetector.ToolbarWithSizeDetector
199
- // Ignored via go/ees005
200
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
201
- , {
202
- editorView: editorView,
203
- editorActions: editorActions
204
- // Ignored via go/ees005
205
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
206
- ,
207
- eventDispatcher: eventDispatcher
208
- // Ignored via go/ees005
209
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
210
- ,
211
- providerFactory: providerFactory,
212
- appearance: appearance,
213
- items: primaryToolbarComponents,
214
- popupsMountPoint: popupsMountPoint,
215
- popupsBoundariesElement: popupsBoundariesElement,
216
- popupsScrollableElement: popupsScrollableElement,
217
- disabled: !!disabled,
218
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
219
- containerElement: containerElement.current,
220
- twoLineEditorToolbar: isTwoLineToolbarEnabled
221
- }), customToolbarSlot)), /*#__PURE__*/_react.default.createElement(_ClickAreaBlock.default, {
222
- editorView: editorView,
223
- editorDisabled: disabled
224
- }, /*#__PURE__*/_react.default.createElement(_ui.WidthConsumer, null, function (_ref) {
225
- var width = _ref.width;
226
- return /*#__PURE__*/_react.default.createElement(_EditorContentContainer.default, {
227
- ref: containerElement,
228
- isScrollable: maxHeight ? true : undefined
229
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
230
- ,
231
- className: (0, _runtime.ax)([maxHeight && commentEditorCompiledStyles.contentAreaMaxHeight, (0, _classnames.default)('ak-editor-content-area', {
232
- 'less-margin': width < _editorSharedStyles.akEditorMobileBreakoutPoint
233
- })]),
234
- featureFlags: featureFlags,
235
- viewMode: editorViewMode,
236
- appearance: appearance,
237
- useStandardNodeWidth: useStandardNodeWidth
238
- }, customContentComponents && 'before' in customContentComponents ? (0, _contentComponentWrapper.contentComponentClickWrapper)(customContentComponents.before) : (0, _contentComponentWrapper.contentComponentClickWrapper)(customContentComponents), /*#__PURE__*/_react.default.createElement(_PluginSlot.default, {
239
- editorView: editorView,
240
- editorActions: editorActions,
241
- eventDispatcher: eventDispatcher,
242
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
243
- providerFactory: providerFactory,
244
- appearance: appearance,
245
- items: contentComponents,
246
- popupsMountPoint: popupsMountPoint,
247
- popupsBoundariesElement: popupsBoundariesElement,
248
- popupsScrollableElement: popupsScrollableElement,
249
- containerElement: containerElement.current,
250
- disabled: !!disabled,
251
- wrapperElement: wrapperElementRef.current,
252
- pluginHooks: pluginHooks
253
- }), editorDOMElement, customContentComponents && 'after' in customContentComponents ? (0, _contentComponentWrapper.contentComponentClickWrapper)(customContentComponents.after) : null);
254
- }))), showSecondaryToolbar && /*#__PURE__*/_react.default.createElement("div", {
255
- "data-testid": "ak-editor-secondary-toolbar",
256
- className: (0, _runtime.ax)([commentEditorCompiledStyles.secondaryToolbar])
257
- }, /*#__PURE__*/_react.default.createElement(_buttonGroup.default, null, !!onSave && /*#__PURE__*/_react.default.createElement(_new.default, {
258
- appearance: "primary",
259
- onClick: handleSave,
260
- testId: "comment-save-button",
261
- isDisabled: disabled || saveButtonDisabled,
262
- interactionName: "editor-comment-save-button"
263
- }, intl.formatMessage(_messages.default.saveButton)), !!onCancel && /*#__PURE__*/_react.default.createElement(_new.default, {
264
- appearance: "subtle",
265
- onClick: handleCancel,
266
- testId: "comment-cancel-button",
267
- isDisabled: disabled,
268
- interactionName: "editor-comment-cancel-button"
269
- }, intl.formatMessage(_messages.default.cancelButton))), /*#__PURE__*/_react.default.createElement("span", {
270
- style: {
271
- flexGrow: 1
272
- }
273
- }), customSecondaryToolbarComponents)));
274
- };
275
- CommentEditorWithIntlCompiled.displayName = 'CommentEditorAppearance';
@@ -1,357 +0,0 @@
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.CommentEditorWithIntlEmotion = void 0;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var _react = _interopRequireWildcard(require("react"));
12
- var _react2 = require("@emotion/react");
13
- var _classnames = _interopRequireDefault(require("classnames"));
14
- var _reactIntl = require("react-intl");
15
- var _buttonGroup = _interopRequireDefault(require("@atlaskit/button/button-group"));
16
- var _new = _interopRequireDefault(require("@atlaskit/button/new"));
17
- var _hooks = require("@atlaskit/editor-common/hooks");
18
- var _messages = _interopRequireDefault(require("@atlaskit/editor-common/messages"));
19
- var _ui = require("@atlaskit/editor-common/ui");
20
- var _uiMenu = require("@atlaskit/editor-common/ui-menu");
21
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
22
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
23
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
24
- var _ClickAreaBlock = _interopRequireDefault(require("../../Addon/ClickAreaBlock"));
25
- var _contentComponentWrapper = require("../../Addon/ClickAreaBlock/contentComponentWrapper");
26
- var _EditorContentContainer = _interopRequireDefault(require("../../EditorContentContainer/EditorContentContainer"));
27
- var _PluginSlot = _interopRequireDefault(require("../../PluginSlot"));
28
- var _getPrimaryToolbarComponents = require("../../Toolbar/getPrimaryToolbarComponents");
29
- var _ToolbarWithSizeDetector = require("../../Toolbar/ToolbarWithSizeDetector");
30
- var _WithFlash = _interopRequireDefault(require("../../WithFlash"));
31
- var _CommentToolbar = require("./CommentToolbar");
32
- var _Toolbar = require("./Toolbar");
33
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
34
- /**
35
- * @jsxRuntime classic
36
- * @jsx jsx
37
- */
38
- /**
39
- * Emotion fallback branch of the `platform_editor_core_non_ecc_static_css` experiment.
40
- * Used via `componentWithCondition` in `Comment.tsx`.
41
- *
42
- * Cleanup: delete this file once the experiment has shipped.
43
- */
44
-
45
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
46
-
47
- // Ignored via go/ees005
48
- // eslint-disable-next-line import/no-named-as-default
49
-
50
- var MAXIMUM_TWO_LINE_TOOLBAR_BREAKPOINT = 490;
51
-
52
- // Remove when platform_editor_comment_editor_border_radius is cleaned up
53
- var commentEditorStylesOld = (0, _react2.css)({
54
- display: 'flex',
55
- flexDirection: 'column',
56
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
57
- '.less-margin > .ProseMirror': {
58
- margin: "var(--ds-space-150, 12px)".concat(" ", "var(--ds-space-100, 8px)", " ", "var(--ds-space-100, 8px)")
59
- },
60
- minWidth: '272px',
61
- height: 'auto',
62
- backgroundColor: "var(--ds-background-input, #FFFFFF)",
63
- border: "var(--ds-border-width, 1px)".concat(" solid ", "var(--ds-border-input, #8C8F97)"),
64
- boxSizing: 'border-box',
65
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
66
- borderRadius: "var(--ds-radius-small, 3px)",
67
- maxWidth: 'inherit',
68
- wordWrap: 'break-word'
69
- });
70
- var commentEditorStyles = (0, _react2.css)({
71
- display: 'flex',
72
- flexDirection: 'column',
73
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
74
- '.less-margin > .ProseMirror': {
75
- margin: "var(--ds-space-150, 12px)".concat(" ", "var(--ds-space-100, 8px)", " ", "var(--ds-space-100, 8px)")
76
- },
77
- minWidth: '272px',
78
- height: 'auto',
79
- backgroundColor: "var(--ds-background-input, #FFFFFF)",
80
- border: "var(--ds-border-width, 1px)".concat(" solid ", "var(--ds-border-input, #8C8F97)"),
81
- boxSizing: 'border-box',
82
- borderRadius: "var(--ds-radius-medium, 6px)",
83
- maxWidth: 'inherit',
84
- wordWrap: 'break-word'
85
- });
86
- var modernisedEditorStyles = (0, _react2.css)({
87
- borderRadius: "var(--ds-radius-xlarge, 12px)"
88
- });
89
- var secondaryToolbarStyles = (0, _react2.css)({
90
- boxSizing: 'border-box',
91
- justifyContent: 'flex-end',
92
- alignItems: 'center',
93
- display: 'flex',
94
- padding: "var(--ds-space-150, 12px)".concat(" ", "var(--ds-space-025, 2px)")
95
- });
96
- var mainToolbarCustomComponentsSlotStyleNew = (0, _react2.css)({
97
- display: 'flex',
98
- justifyContent: 'flex-end',
99
- alignItems: 'center',
100
- flexGrow: 1,
101
- paddingRight: "var(--ds-space-250, 20px)",
102
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
103
- '> div': {
104
- display: 'flex',
105
- flexShrink: 0
106
- }
107
- });
108
- var mainToolbarCustomComponentsSlotStylePaddingOverride = (0, _react2.css)({
109
- paddingRight: 0
110
- });
111
- var mainToolbarCustomComponentsSlotStyleTwoLineToolbarNew = (0, _react2.css)((0, _defineProperty2.default)({}, "@media (max-width: ".concat(MAXIMUM_TWO_LINE_TOOLBAR_BREAKPOINT, "px)"), {
112
- paddingRight: 0
113
- }));
114
- var appearance = 'comment';
115
- var CommentEditorWithIntlEmotion = exports.CommentEditorWithIntlEmotion = function CommentEditorWithIntlEmotion(props) {
116
- var _editorAPI$blockMenu$, _editorAPI$blockMenu;
117
- var editorAPI = props.editorAPI;
118
-
119
- // Get useStandardNodeWidth from block menu plugin shared state
120
- // Only access editorAPI when the experiment is enabled to avoid performance impact
121
- var useStandardNodeWidth = (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && ((_editorAPI$blockMenu$ = editorAPI === null || editorAPI === void 0 || (_editorAPI$blockMenu = editorAPI.blockMenu) === null || _editorAPI$blockMenu === void 0 || (_editorAPI$blockMenu = _editorAPI$blockMenu.sharedState) === null || _editorAPI$blockMenu === void 0 || (_editorAPI$blockMenu = _editorAPI$blockMenu.currentState()) === null || _editorAPI$blockMenu === void 0 ? void 0 : _editorAPI$blockMenu.useStandardNodeWidth) !== null && _editorAPI$blockMenu$ !== void 0 ? _editorAPI$blockMenu$ : false);
122
- var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(editorAPI, ['maxContentSize', 'primaryToolbar', 'editorViewMode'], function (states) {
123
- var _states$maxContentSiz, _states$primaryToolba, _states$editorViewMod;
124
- return {
125
- maxContentSizeReached: !!((_states$maxContentSiz = states.maxContentSizeState) !== null && _states$maxContentSiz !== void 0 && _states$maxContentSiz.maxContentSizeReached),
126
- primaryToolbarComponentsState: (_states$primaryToolba = states.primaryToolbarState) === null || _states$primaryToolba === void 0 ? void 0 : _states$primaryToolba.components,
127
- editorViewMode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
128
- };
129
- }),
130
- editorViewMode = _useSharedPluginState.editorViewMode,
131
- primaryToolbarComponentsState = _useSharedPluginState.primaryToolbarComponentsState,
132
- maxContentSizeReached = _useSharedPluginState.maxContentSizeReached;
133
- var primaryToolbarState = (0, _getPrimaryToolbarComponents.getPrimaryToolbarComponents)(editorAPI, primaryToolbarComponentsState);
134
- var _useSharedPluginState2 = (0, _hooks.useSharedPluginState)(editorAPI, ['media']),
135
- mediaState = _useSharedPluginState2.mediaState;
136
- var intl = (0, _reactIntl.useIntl)();
137
- var editorDOMElement = props.editorDOMElement,
138
- editorView = props.editorView,
139
- editorActions = props.editorActions,
140
- eventDispatcher = props.eventDispatcher,
141
- providerFactory = props.providerFactory,
142
- contentComponents = props.contentComponents,
143
- customContentComponents = props.customContentComponents,
144
- customPrimaryToolbarComponents = props.customPrimaryToolbarComponents,
145
- primaryToolbarComponentsProp = props.primaryToolbarComponents,
146
- customSecondaryToolbarComponents = props.customSecondaryToolbarComponents,
147
- popupsMountPoint = props.popupsMountPoint,
148
- popupsBoundariesElement = props.popupsBoundariesElement,
149
- popupsScrollableElement = props.popupsScrollableElement,
150
- maxHeight = props.maxHeight,
151
- _props$minHeight = props.minHeight,
152
- minHeight = _props$minHeight === void 0 ? 150 : _props$minHeight,
153
- onSave = props.onSave,
154
- onCancel = props.onCancel,
155
- disabled = props.disabled,
156
- dispatchAnalyticsEvent = props.dispatchAnalyticsEvent,
157
- useStickyToolbar = props.useStickyToolbar,
158
- pluginHooks = props.pluginHooks,
159
- featureFlags = props.featureFlags,
160
- innerRef = props.innerRef,
161
- isEditorModernisationEnabled = props.isEditorModernisationEnabled;
162
- var showSecondaryToolbar = !!onSave || !!onCancel || !!customSecondaryToolbarComponents;
163
- var containerElement = _react.default.useRef(null);
164
-
165
- // Wrapper container for toolbar and content area
166
- var wrapperElementRef = (0, _react.useMemo)(function () {
167
- return innerRef || /*#__PURE__*/_react.default.createRef();
168
- }, [innerRef]);
169
- var _useState = (0, _react.useState)(false),
170
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
171
- saveButtonDisabled = _useState2[0],
172
- setSaveButtonDisabled = _useState2[1];
173
- (0, _react.useEffect)(function () {
174
- if (mediaState) {
175
- mediaState.subscribeToUploadInProgressState(setSaveButtonDisabled);
176
- }
177
- return function () {
178
- return mediaState === null || mediaState === void 0 ? void 0 : mediaState.unsubscribeFromUploadInProgressState(setSaveButtonDisabled);
179
- };
180
- }, [mediaState]);
181
- var handleSave = (0, _react.useCallback)(function () {
182
- if (editorView && onSave) {
183
- onSave(editorView);
184
- }
185
- }, [editorView, onSave]);
186
- var handleCancel = (0, _react.useCallback)(function () {
187
- if (editorView && onCancel) {
188
- onCancel(editorView);
189
- }
190
- }, [editorView, onCancel]);
191
- var isShortcutToFocusToolbar = (0, _react.useCallback)(function (event) {
192
- //Alt + F9 to reach first element in this main toolbar
193
- return event.altKey && (event.key === 'F9' || event.keyCode === 120);
194
- }, []);
195
-
196
- // When primary toolbar components is undefined, do not show two line editor toolbar
197
- var isTwoLineToolbarEnabled = !!customPrimaryToolbarComponents;
198
- var handleEscape = (0, _react.useCallback)(function (event) {
199
- if (!(editorView !== null && editorView !== void 0 && editorView.hasFocus())) {
200
- editorView === null || editorView === void 0 || editorView.focus();
201
- }
202
- event.preventDefault();
203
- event.stopPropagation();
204
- }, [editorView]);
205
- var primaryToolbarComponents = primaryToolbarComponentsProp;
206
- if (Array.isArray(primaryToolbarState === null || primaryToolbarState === void 0 ? void 0 : primaryToolbarState.components) && Array.isArray(primaryToolbarComponents)) {
207
- primaryToolbarComponents = primaryToolbarState.components.concat(primaryToolbarComponents);
208
- }
209
- var isToolbarAIFCEnabled = Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar);
210
- var memoizedContentAreaStyles = (0, _react.useMemo)(function () {
211
- return [maxHeight ?
212
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
213
- (0, _react2.css)({
214
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
215
- maxHeight: "".concat(maxHeight, "px"),
216
- // When maxHeight is set, content area should have overflow-y explicitly set as auto
217
- // As we have overflow-x: clip for the content area, and when maxHeight prop is set, overflow-y will be computed as visible by default.
218
- // This will cause the content area to have content overflowing the container
219
- // so need to set overflow-y as auto to make sure the content area is scrollable
220
- overflowY: 'auto'
221
- }) : null];
222
- }, [maxHeight]);
223
- var contentAreaStyles = (0, _expValEquals.expValEquals)('platform_editor_perf_lint_cleanup', 'isEnabled', true) ? memoizedContentAreaStyles : [maxHeight ?
224
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
225
- (0, _react2.css)({
226
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
227
- maxHeight: "".concat(maxHeight, "px"),
228
- // When maxHeight is set, content area should have overflow-y explicitly set as auto
229
- // As we have overflow-x: clip for the content area, and when maxHeight prop is set, overflow-y will be computed as visible by default.
230
- // This will cause the content area to have content overflowing the container
231
- // so need to set overflow-y as auto to make sure the content area is scrollable
232
- overflowY: 'auto'
233
- }) : null];
234
- var customToolbarSlot = (0, _react2.jsx)("div", {
235
- css: [mainToolbarCustomComponentsSlotStyleNew, isTwoLineToolbarEnabled && mainToolbarCustomComponentsSlotStyleTwoLineToolbarNew, isToolbarAIFCEnabled && mainToolbarCustomComponentsSlotStylePaddingOverride]
236
- }, customPrimaryToolbarComponents);
237
- return (0, _react2.jsx)(_WithFlash.default, {
238
- animate: maxContentSizeReached
239
- }, (0, _react2.jsx)(_ui.WidthProvider, null, (0, _react2.jsx)("div", {
240
- css: [(0, _expValEquals.expValEquals)('platform_editor_comment_editor_border_radius', 'isEnabled', true) ? commentEditorStyles : commentEditorStylesOld, isEditorModernisationEnabled && modernisedEditorStyles,
241
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
242
- (0, _react2.css)({
243
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
244
- minHeight: "".concat(minHeight, "px")
245
- })]
246
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
247
- ,
248
- className: "akEditor",
249
- ref: wrapperElementRef
250
- }, (0, _react2.jsx)(_Toolbar.MainToolbar, {
251
- isEditorModernisationEnabled: isEditorModernisationEnabled,
252
- useStickyToolbar: useStickyToolbar,
253
- twoLineEditorToolbar: isTwoLineToolbarEnabled,
254
- isNewToolbarEnabled: isToolbarAIFCEnabled
255
- }, isToolbarAIFCEnabled ? (0, _react2.jsx)(_uiMenu.ToolbarArrowKeyNavigationProvider, {
256
- editorView: editorView,
257
- childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
258
- isShortcutToFocusToolbar: isShortcutToFocusToolbar,
259
- handleEscape: handleEscape,
260
- editorAppearance: appearance,
261
- useStickyToolbar: useStickyToolbar,
262
- intl: intl
263
- }, (0, _react2.jsx)(_CommentToolbar.CommentToolbar, {
264
- editorAPI: editorAPI,
265
- editorView: editorView,
266
- editorAppearance: appearance,
267
- disabled: !!disabled,
268
- popupsBoundariesElement: popupsBoundariesElement,
269
- popupsScrollableElement: popupsScrollableElement,
270
- popupsMountPoint: popupsMountPoint
271
- }), customPrimaryToolbarComponents ? customToolbarSlot : null) : (0, _react2.jsx)(_uiMenu.ToolbarArrowKeyNavigationProvider, {
272
- editorView: editorView,
273
- childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
274
- isShortcutToFocusToolbar: isShortcutToFocusToolbar,
275
- handleEscape: handleEscape,
276
- editorAppearance: appearance,
277
- useStickyToolbar: useStickyToolbar,
278
- intl: intl
279
- }, (0, _react2.jsx)(_ToolbarWithSizeDetector.ToolbarWithSizeDetector
280
- // Ignored via go/ees005
281
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
282
- , {
283
- editorView: editorView,
284
- editorActions: editorActions
285
- // Ignored via go/ees005
286
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
287
- ,
288
- eventDispatcher: eventDispatcher
289
- // Ignored via go/ees005
290
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
291
- ,
292
- providerFactory: providerFactory,
293
- appearance: appearance,
294
- items: primaryToolbarComponents,
295
- popupsMountPoint: popupsMountPoint,
296
- popupsBoundariesElement: popupsBoundariesElement,
297
- popupsScrollableElement: popupsScrollableElement,
298
- disabled: !!disabled,
299
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
300
- containerElement: containerElement.current,
301
- twoLineEditorToolbar: isTwoLineToolbarEnabled
302
- }), customToolbarSlot)), (0, _react2.jsx)(_ClickAreaBlock.default, {
303
- editorView: editorView,
304
- editorDisabled: disabled
305
- }, (0, _react2.jsx)(_ui.WidthConsumer, null, function (_ref) {
306
- var width = _ref.width;
307
- return (0, _react2.jsx)(_EditorContentContainer.default, {
308
- ref: containerElement,
309
- css: contentAreaStyles,
310
- isScrollable: maxHeight ? true : undefined
311
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
312
- ,
313
- className: (0, _classnames.default)('ak-editor-content-area', {
314
- 'less-margin': width < _editorSharedStyles.akEditorMobileBreakoutPoint
315
- }),
316
- featureFlags: featureFlags,
317
- viewMode: editorViewMode,
318
- appearance: appearance,
319
- useStandardNodeWidth: useStandardNodeWidth
320
- }, customContentComponents && 'before' in customContentComponents ? (0, _contentComponentWrapper.contentComponentClickWrapper)(customContentComponents.before) : (0, _contentComponentWrapper.contentComponentClickWrapper)(customContentComponents), (0, _react2.jsx)(_PluginSlot.default, {
321
- editorView: editorView,
322
- editorActions: editorActions,
323
- eventDispatcher: eventDispatcher,
324
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
325
- providerFactory: providerFactory,
326
- appearance: appearance,
327
- items: contentComponents,
328
- popupsMountPoint: popupsMountPoint,
329
- popupsBoundariesElement: popupsBoundariesElement,
330
- popupsScrollableElement: popupsScrollableElement,
331
- containerElement: containerElement.current,
332
- disabled: !!disabled,
333
- wrapperElement: wrapperElementRef.current,
334
- pluginHooks: pluginHooks
335
- }), editorDOMElement, customContentComponents && 'after' in customContentComponents ? (0, _contentComponentWrapper.contentComponentClickWrapper)(customContentComponents.after) : null);
336
- }))), showSecondaryToolbar && (0, _react2.jsx)("div", {
337
- css: secondaryToolbarStyles,
338
- "data-testid": "ak-editor-secondary-toolbar"
339
- }, (0, _react2.jsx)(_buttonGroup.default, null, !!onSave && (0, _react2.jsx)(_new.default, {
340
- appearance: "primary",
341
- onClick: handleSave,
342
- testId: "comment-save-button",
343
- isDisabled: disabled || saveButtonDisabled,
344
- interactionName: "editor-comment-save-button"
345
- }, intl.formatMessage(_messages.default.saveButton)), !!onCancel && (0, _react2.jsx)(_new.default, {
346
- appearance: "subtle",
347
- onClick: handleCancel,
348
- testId: "comment-cancel-button",
349
- isDisabled: disabled,
350
- interactionName: "editor-comment-cancel-button"
351
- }, intl.formatMessage(_messages.default.cancelButton))), (0, _react2.jsx)("span", {
352
- style: {
353
- flexGrow: 1
354
- }
355
- }), customSecondaryToolbarComponents)));
356
- };
357
- CommentEditorWithIntlEmotion.displayName = 'CommentEditorAppearance';