@atlaskit/editor-core 221.4.1 → 221.5.1

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