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