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