@atlaskit/editor-core 192.6.0 → 193.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/create-editor/create-plugins-list.js +0 -1
- package/dist/cjs/preset-universal.js +8 -1
- package/dist/cjs/presets/default.js +1 -2
- package/dist/cjs/presets/universal.js +1 -1
- package/dist/cjs/ui/Addon/ClickAreaBlock/index.js +5 -3
- package/dist/cjs/ui/Addon/ClickAreaInline/index.js +4 -3
- package/dist/cjs/ui/Appearance/Comment/Comment.js +207 -10
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/create-plugins-list.js +0 -1
- package/dist/es2019/preset-universal.js +2 -1
- package/dist/es2019/presets/default.js +1 -2
- package/dist/es2019/presets/universal.js +1 -1
- package/dist/es2019/ui/Addon/ClickAreaBlock/index.js +4 -4
- package/dist/es2019/ui/Addon/ClickAreaInline/index.js +3 -3
- package/dist/es2019/ui/Appearance/Comment/Comment.js +201 -58
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/create-plugins-list.js +0 -1
- package/dist/esm/preset-universal.js +2 -1
- package/dist/esm/presets/default.js +1 -2
- package/dist/esm/presets/universal.js +1 -1
- package/dist/esm/ui/Addon/ClickAreaBlock/index.js +4 -3
- package/dist/esm/ui/Addon/ClickAreaInline/index.js +3 -3
- package/dist/esm/ui/Appearance/Comment/Comment.js +208 -9
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/create-preset.d.ts +110 -74
- package/dist/types/preset-universal.d.ts +1 -0
- package/dist/types/presets/default.d.ts +52 -156
- package/dist/types/presets/universal.d.ts +110 -74
- package/dist/types/presets/useUniversalPreset.d.ts +110 -74
- package/dist/types-ts4.5/create-editor/create-preset.d.ts +130 -85
- package/dist/types-ts4.5/preset-universal.d.ts +1 -0
- package/dist/types-ts4.5/presets/default.d.ts +54 -180
- package/dist/types-ts4.5/presets/universal.d.ts +130 -85
- package/dist/types-ts4.5/presets/useUniversalPreset.d.ts +130 -85
- package/docs/4-annotations.tsx +1 -1
- package/package.json +25 -9
- package/docs/editor-use-only.tsx +0 -50
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage/preview */
|
|
2
3
|
/** @jsx jsx */
|
|
3
|
-
import React, { Fragment } from 'react';
|
|
4
|
+
import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
5
|
import { css, jsx } from '@emotion/react';
|
|
5
6
|
import classnames from 'classnames';
|
|
6
7
|
import { injectIntl } from 'react-intl-next';
|
|
@@ -24,57 +25,44 @@ import Toolbar from '../../Toolbar';
|
|
|
24
25
|
import WithFlash from '../../WithFlash';
|
|
25
26
|
import { MainToolbar, mainToolbarCustomComponentsSlotStyle } from './Toolbar';
|
|
26
27
|
const CommentEditorMargin = 14;
|
|
27
|
-
const commentEditorStyle = css
|
|
28
|
-
display: flex
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
.ProseMirror {
|
|
57
|
-
margin: ${"var(--ds-space-150, 12px)"};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.gridParent {
|
|
61
|
-
margin-left: ${CommentEditorMargin - GRID_GUTTER}px;
|
|
62
|
-
margin-right: ${CommentEditorMargin - GRID_GUTTER}px;
|
|
63
|
-
width: calc(100% + ${CommentEditorMargin - GRID_GUTTER}px);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
padding: ${"var(--ds-space-250, 20px)"};
|
|
67
|
-
|
|
68
|
-
${tableCommentEditorStyles};
|
|
69
|
-
`);
|
|
28
|
+
const commentEditorStyle = css({
|
|
29
|
+
display: 'flex',
|
|
30
|
+
flexDirection: 'column',
|
|
31
|
+
'.less-margin .ProseMirror': {
|
|
32
|
+
margin: `${"var(--ds-space-150, 12px)"} ${"var(--ds-space-100, 8px)"} ${"var(--ds-space-100, 8px)"}`
|
|
33
|
+
},
|
|
34
|
+
minWidth: '272px',
|
|
35
|
+
height: 'auto',
|
|
36
|
+
backgroundColor: "var(--ds-background-input, white)",
|
|
37
|
+
border: `1px solid ${`var(--ds-border, ${N40})`}`,
|
|
38
|
+
boxSizing: 'border-box',
|
|
39
|
+
borderRadius: `${borderRadius()}px`,
|
|
40
|
+
maxWidth: 'inherit',
|
|
41
|
+
wordWrap: 'break-word'
|
|
42
|
+
});
|
|
43
|
+
const ContentArea = createEditorContentStyle(css({
|
|
44
|
+
flexGrow: 1,
|
|
45
|
+
overflowX: getBooleanFF('platform.editor.table-sticky-scrollbar') ? 'clip' : 'hidden',
|
|
46
|
+
lineHeight: '24px',
|
|
47
|
+
'.ProseMirror': {
|
|
48
|
+
margin: "var(--ds-space-150, 12px)"
|
|
49
|
+
},
|
|
50
|
+
'.gridParent': {
|
|
51
|
+
marginLeft: `${CommentEditorMargin - GRID_GUTTER}px`,
|
|
52
|
+
marginRight: `${CommentEditorMargin - GRID_GUTTER}px`,
|
|
53
|
+
width: `calc(100% + ${CommentEditorMargin - GRID_GUTTER}px)`
|
|
54
|
+
},
|
|
55
|
+
padding: "var(--ds-space-250, 20px)"
|
|
56
|
+
}, tableCommentEditorStyles));
|
|
70
57
|
ContentArea.displayName = 'ContentArea';
|
|
71
|
-
const secondaryToolbarStyle = css
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
display: flex
|
|
76
|
-
padding:
|
|
77
|
-
|
|
58
|
+
const secondaryToolbarStyle = css({
|
|
59
|
+
boxSizing: 'border-box',
|
|
60
|
+
justifyContent: 'flex-end',
|
|
61
|
+
alignItems: 'center',
|
|
62
|
+
display: 'flex',
|
|
63
|
+
padding: `${"var(--ds-space-150, 12px)"} ${"var(--ds-space-025, 2px)"}`
|
|
64
|
+
});
|
|
65
|
+
const appearance = 'comment';
|
|
78
66
|
class Editor extends React.Component {
|
|
79
67
|
constructor(props) {
|
|
80
68
|
super(props);
|
|
@@ -138,9 +126,9 @@ class Editor extends React.Component {
|
|
|
138
126
|
return jsx(WithFlash, {
|
|
139
127
|
animate: maxContentSizeReached
|
|
140
128
|
}, jsx("div", {
|
|
141
|
-
css: [commentEditorStyle, css
|
|
142
|
-
|
|
143
|
-
|
|
129
|
+
css: [commentEditorStyle, css({
|
|
130
|
+
minHeight: `${minHeight}px`
|
|
131
|
+
})],
|
|
144
132
|
className: "akEditor",
|
|
145
133
|
ref: this.wrapperElementRef
|
|
146
134
|
}, jsx(MainToolbar, {
|
|
@@ -178,9 +166,9 @@ class Editor extends React.Component {
|
|
|
178
166
|
}) => {
|
|
179
167
|
return jsx(ContentArea, {
|
|
180
168
|
ref: ref => this.containerElement = ref,
|
|
181
|
-
css: maxHeight ? css
|
|
182
|
-
|
|
183
|
-
|
|
169
|
+
css: maxHeight ? css({
|
|
170
|
+
maxHeight: `${maxHeight}px`
|
|
171
|
+
}) : null,
|
|
184
172
|
className: classnames('ak-editor-content-area', {
|
|
185
173
|
'less-margin': width < akEditorMobileBreakoutPoint
|
|
186
174
|
}),
|
|
@@ -243,4 +231,159 @@ function RenderWithPluginState({
|
|
|
243
231
|
mediaState: mediaState !== null && mediaState !== void 0 ? mediaState : undefined
|
|
244
232
|
}));
|
|
245
233
|
}
|
|
246
|
-
|
|
234
|
+
const EditorNext = props => {
|
|
235
|
+
const api = usePresetContext();
|
|
236
|
+
const {
|
|
237
|
+
mediaState,
|
|
238
|
+
maxContentSizeState
|
|
239
|
+
} = useSharedPluginState(api, ['media', 'maxContentSize']);
|
|
240
|
+
const {
|
|
241
|
+
editorDOMElement,
|
|
242
|
+
editorView,
|
|
243
|
+
editorActions,
|
|
244
|
+
eventDispatcher,
|
|
245
|
+
providerFactory,
|
|
246
|
+
contentComponents,
|
|
247
|
+
customContentComponents,
|
|
248
|
+
customPrimaryToolbarComponents,
|
|
249
|
+
primaryToolbarComponents,
|
|
250
|
+
customSecondaryToolbarComponents,
|
|
251
|
+
popupsMountPoint,
|
|
252
|
+
popupsBoundariesElement,
|
|
253
|
+
popupsScrollableElement,
|
|
254
|
+
maxHeight,
|
|
255
|
+
minHeight = 150,
|
|
256
|
+
onSave,
|
|
257
|
+
onCancel,
|
|
258
|
+
disabled,
|
|
259
|
+
dispatchAnalyticsEvent,
|
|
260
|
+
intl,
|
|
261
|
+
useStickyToolbar,
|
|
262
|
+
pluginHooks,
|
|
263
|
+
featureFlags,
|
|
264
|
+
innerRef
|
|
265
|
+
} = props;
|
|
266
|
+
const maxContentSizeReached = Boolean(maxContentSizeState === null || maxContentSizeState === void 0 ? void 0 : maxContentSizeState.maxContentSizeReached);
|
|
267
|
+
const showSecondaryToolbar = !!onSave || !!onCancel || !!customSecondaryToolbarComponents;
|
|
268
|
+
let containerElement = null;
|
|
269
|
+
|
|
270
|
+
// Wrapper container for toolbar and content area
|
|
271
|
+
const wrapperElementRef = useMemo(() => innerRef || /*#__PURE__*/React.createRef(), [innerRef]);
|
|
272
|
+
const [saveButtonDisabled, setSaveButtonDisabled] = useState(disabled);
|
|
273
|
+
useEffect(() => {
|
|
274
|
+
if (mediaState) {
|
|
275
|
+
mediaState.subscribeToUploadInProgressState(setSaveButtonDisabled);
|
|
276
|
+
}
|
|
277
|
+
return () => mediaState === null || mediaState === void 0 ? void 0 : mediaState.unsubscribeFromUploadInProgressState(setSaveButtonDisabled);
|
|
278
|
+
}, [mediaState]);
|
|
279
|
+
const handleSave = useCallback(() => {
|
|
280
|
+
if (editorView && onSave) {
|
|
281
|
+
onSave(editorView);
|
|
282
|
+
}
|
|
283
|
+
}, [editorView, onSave]);
|
|
284
|
+
const handleCancel = useCallback(() => {
|
|
285
|
+
if (editorView && onCancel) {
|
|
286
|
+
onCancel(editorView);
|
|
287
|
+
}
|
|
288
|
+
}, [editorView, onCancel]);
|
|
289
|
+
const isShortcutToFocusToolbar = useCallback(event => {
|
|
290
|
+
//Alt + F9 to reach first element in this main toolbar
|
|
291
|
+
return event.altKey && (event.key === 'F9' || event.keyCode === 120);
|
|
292
|
+
}, []);
|
|
293
|
+
const isTwoLineToolbarEnabled = !!customPrimaryToolbarComponents && !!(featureFlags !== null && featureFlags !== void 0 && featureFlags.twoLineEditorToolbar);
|
|
294
|
+
const handleEscape = useCallback(event => {
|
|
295
|
+
if (!(editorView !== null && editorView !== void 0 && editorView.hasFocus())) {
|
|
296
|
+
editorView === null || editorView === void 0 ? void 0 : editorView.focus();
|
|
297
|
+
}
|
|
298
|
+
event.preventDefault();
|
|
299
|
+
event.stopPropagation();
|
|
300
|
+
}, [editorView]);
|
|
301
|
+
return jsx(WithFlash, {
|
|
302
|
+
animate: maxContentSizeReached
|
|
303
|
+
}, jsx("div", {
|
|
304
|
+
css: [commentEditorStyle, css({
|
|
305
|
+
minHeight: `${minHeight}px`
|
|
306
|
+
})],
|
|
307
|
+
className: "akEditor",
|
|
308
|
+
ref: wrapperElementRef
|
|
309
|
+
}, jsx(MainToolbar, {
|
|
310
|
+
useStickyToolbar: useStickyToolbar,
|
|
311
|
+
twoLineEditorToolbar: isTwoLineToolbarEnabled
|
|
312
|
+
}, jsx(ToolbarArrowKeyNavigationProvider, {
|
|
313
|
+
editorView: editorView,
|
|
314
|
+
childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
|
|
315
|
+
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
316
|
+
handleEscape: handleEscape,
|
|
317
|
+
editorAppearance: appearance,
|
|
318
|
+
useStickyToolbar: useStickyToolbar,
|
|
319
|
+
intl: intl
|
|
320
|
+
}, jsx(Toolbar, {
|
|
321
|
+
editorView: editorView,
|
|
322
|
+
editorActions: editorActions,
|
|
323
|
+
eventDispatcher: eventDispatcher,
|
|
324
|
+
providerFactory: providerFactory,
|
|
325
|
+
appearance: appearance,
|
|
326
|
+
items: primaryToolbarComponents,
|
|
327
|
+
popupsMountPoint: popupsMountPoint,
|
|
328
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
329
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
330
|
+
disabled: !!disabled,
|
|
331
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
332
|
+
containerElement: containerElement,
|
|
333
|
+
twoLineEditorToolbar: isTwoLineToolbarEnabled
|
|
334
|
+
}), jsx("div", {
|
|
335
|
+
css: mainToolbarCustomComponentsSlotStyle(isTwoLineToolbarEnabled)
|
|
336
|
+
}, customPrimaryToolbarComponents))), jsx(ClickAreaBlock, {
|
|
337
|
+
editorView: editorView,
|
|
338
|
+
editorDisabled: disabled
|
|
339
|
+
}, jsx(WidthConsumer, null, ({
|
|
340
|
+
width
|
|
341
|
+
}) => {
|
|
342
|
+
return jsx(ContentArea, {
|
|
343
|
+
ref: ref => containerElement = ref,
|
|
344
|
+
css: maxHeight ? css({
|
|
345
|
+
maxHeight: `${maxHeight}px`
|
|
346
|
+
}) : null,
|
|
347
|
+
className: classnames('ak-editor-content-area', {
|
|
348
|
+
'less-margin': width < akEditorMobileBreakoutPoint
|
|
349
|
+
}),
|
|
350
|
+
featureFlags: featureFlags
|
|
351
|
+
}, customContentComponents && 'before' in customContentComponents ? customContentComponents.before : customContentComponents, jsx(PluginSlot, {
|
|
352
|
+
editorView: editorView,
|
|
353
|
+
editorActions: editorActions,
|
|
354
|
+
eventDispatcher: eventDispatcher,
|
|
355
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
356
|
+
providerFactory: providerFactory,
|
|
357
|
+
appearance: appearance,
|
|
358
|
+
items: contentComponents,
|
|
359
|
+
popupsMountPoint: popupsMountPoint,
|
|
360
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
361
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
362
|
+
containerElement: containerElement,
|
|
363
|
+
disabled: !!disabled,
|
|
364
|
+
wrapperElement: wrapperElementRef.current,
|
|
365
|
+
pluginHooks: pluginHooks
|
|
366
|
+
}), editorDOMElement, customContentComponents && 'after' in customContentComponents ? customContentComponents.after : null);
|
|
367
|
+
}))), showSecondaryToolbar && jsx("div", {
|
|
368
|
+
css: secondaryToolbarStyle,
|
|
369
|
+
"data-testid": "ak-editor-secondary-toolbar"
|
|
370
|
+
}, jsx(ButtonGroup, null, !!onSave && jsx(Button, {
|
|
371
|
+
appearance: "primary",
|
|
372
|
+
onClick: handleSave,
|
|
373
|
+
testId: "comment-save-button",
|
|
374
|
+
isDisabled: disabled || saveButtonDisabled
|
|
375
|
+
}, intl.formatMessage(messages.saveButton)), !!onCancel && jsx(Button, {
|
|
376
|
+
appearance: "subtle",
|
|
377
|
+
onClick: handleCancel,
|
|
378
|
+
isDisabled: disabled
|
|
379
|
+
}, intl.formatMessage(messages.cancelButton))), jsx("span", {
|
|
380
|
+
style: {
|
|
381
|
+
flexGrow: 1
|
|
382
|
+
}
|
|
383
|
+
}), customSecondaryToolbarComponents));
|
|
384
|
+
};
|
|
385
|
+
EditorNext.displayName = 'CommentEditorAppearance';
|
|
386
|
+
const CommentEditorNextWithIntl = injectIntl(EditorNext);
|
|
387
|
+
const CommentEditorOldWithIntl = injectIntl(Editor);
|
|
388
|
+
const ExportComp = getBooleanFF('platform.editor.media.alluploadsfinished-dispatch-update_ivtow') ? CommentEditorNextWithIntl : CommentEditorOldWithIntl;
|
|
389
|
+
export const CommentEditorWithIntl = ExportComp;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "
|
|
2
|
+
export const version = "193.0.0";
|
|
@@ -68,7 +68,6 @@ export function getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEve
|
|
|
68
68
|
textFormatting: _objectSpread(_objectSpread({}, props.textFormatting || {}), {}, {
|
|
69
69
|
responsiveToolbarMenu: ((_props$textFormatting = props.textFormatting) === null || _props$textFormatting === void 0 ? void 0 : _props$textFormatting.responsiveToolbarMenu) != null ? props.textFormatting.responsiveToolbarMenu : props.allowUndoRedoButtons
|
|
70
70
|
}),
|
|
71
|
-
annotationProviders: props.annotationProviders,
|
|
72
71
|
submitEditor: props.onSave,
|
|
73
72
|
quickInsert: {
|
|
74
73
|
enableElementBrowser: props.elementBrowser && props.elementBrowser.showModal,
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default as useUniversalPreset } from './presets/useUniversalPreset';
|
|
1
|
+
export { default as useUniversalPreset } from './presets/useUniversalPreset';
|
|
2
|
+
export { default as createUniversalPreset } from './presets/universal';
|
|
@@ -5,7 +5,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
|
|
6
6
|
import { EditorPresetBuilder } from '@atlaskit/editor-common/preset';
|
|
7
7
|
import { analyticsPlugin } from '@atlaskit/editor-plugins/analytics';
|
|
8
|
-
import { annotationPlugin } from '@atlaskit/editor-plugins/annotation';
|
|
9
8
|
import { basePlugin } from '@atlaskit/editor-plugins/base';
|
|
10
9
|
import { betterTypeHistoryPlugin } from '@atlaskit/editor-plugins/better-type-history';
|
|
11
10
|
import { blockTypePlugin } from '@atlaskit/editor-plugins/block-type';
|
|
@@ -51,7 +50,7 @@ export function createDefaultPreset(options) {
|
|
|
51
50
|
contextIdentifierProvider: options.contextIdentifierProvider
|
|
52
51
|
}]).add([basePlugin, options.base]).add(decorationsPlugin).add([typeAheadPlugin, options.typeAhead || {
|
|
53
52
|
createAnalyticsEvent: options.createAnalyticsEvent
|
|
54
|
-
}]).maybeAdd(historyPlugin, Boolean(isMobile || options.allowUndoRedoButtons)).maybeAdd(undoRedoPlugin, Boolean((_options$featureFlags = (_options$featureFlags2 = options.featureFlags) === null || _options$featureFlags2 === void 0 ? void 0 : _options$featureFlags2.undoRedoButtons) !== null && _options$featureFlags !== void 0 ? _options$featureFlags : options.allowUndoRedoButtons)).add([blockTypePlugin, options.blockType]).add(clearMarksOnEmptyDocPlugin).maybeAdd([
|
|
53
|
+
}]).maybeAdd(historyPlugin, Boolean(isMobile || options.allowUndoRedoButtons)).maybeAdd(undoRedoPlugin, Boolean((_options$featureFlags = (_options$featureFlags2 = options.featureFlags) === null || _options$featureFlags2 === void 0 ? void 0 : _options$featureFlags2.undoRedoButtons) !== null && _options$featureFlags !== void 0 ? _options$featureFlags : options.allowUndoRedoButtons)).add([blockTypePlugin, options.blockType]).add(clearMarksOnEmptyDocPlugin).maybeAdd([selectionToolbarPlugin, {
|
|
55
54
|
preferenceToolbarAboveSelection: false
|
|
56
55
|
}], function () {
|
|
57
56
|
if (getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd')) {
|
|
@@ -96,7 +96,7 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
|
|
|
96
96
|
__livePage: props.__livePage
|
|
97
97
|
}], Boolean(props.allowExpand)).maybeAdd(guidelinePlugin, Boolean(!isMobile && !isComment && !isChromeless && (props.media || props.allowTables))).maybeAdd([gridPlugin, {
|
|
98
98
|
shouldCalcBreakoutGridLines: isFullPage
|
|
99
|
-
}], Boolean(props.media)).maybeAdd([mediaPlugin, _objectSpread(_objectSpread({}, props.media), {}, {
|
|
99
|
+
}], Boolean(props.media)).maybeAdd([annotationPlugin, props.annotationProviders], Boolean(props.annotationProviders)).maybeAdd([mediaPlugin, _objectSpread(_objectSpread({}, props.media), {}, {
|
|
100
100
|
allowLazyLoading: !isMobile,
|
|
101
101
|
allowBreakoutSnapPoints: isFullPage,
|
|
102
102
|
allowAdvancedToolBarOptions: typeof ((_props$media = props.media) === null || _props$media === void 0 ? void 0 : _props$media.allowAdvancedToolBarOptions) !== 'undefined' ? (_props$media2 = props.media) === null || _props$media2 === void 0 ? void 0 : _props$media2.allowAdvancedToolBarOptions : isFullPage || isComment,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject;
|
|
3
1
|
/** @jsx jsx */
|
|
4
2
|
import React from 'react';
|
|
5
3
|
import { css, jsx } from '@emotion/react';
|
|
6
4
|
import { clickAreaClickHandler } from '../click-area-helper';
|
|
7
|
-
var clickWrapper = css(
|
|
5
|
+
var clickWrapper = css({
|
|
6
|
+
flexGrow: 1,
|
|
7
|
+
height: '100%'
|
|
8
|
+
});
|
|
8
9
|
export var ClickAreaBlock = function ClickAreaBlock(_ref) {
|
|
9
10
|
var editorView = _ref.editorView,
|
|
10
11
|
editorDisabled = _ref.editorDisabled,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject;
|
|
3
1
|
/** @jsx jsx */
|
|
4
2
|
import React from 'react';
|
|
5
3
|
import { css, jsx } from '@emotion/react';
|
|
6
4
|
import { createParagraphAtEnd } from '@atlaskit/editor-common/commands';
|
|
7
|
-
var clickArea = css(
|
|
5
|
+
var clickArea = css({
|
|
6
|
+
flexGrow: 1
|
|
7
|
+
});
|
|
8
8
|
export var ClickAreaInline = function ClickAreaInline(_ref) {
|
|
9
9
|
var editorView = _ref.editorView,
|
|
10
10
|
children = _ref.children;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
@@ -5,12 +6,11 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
9
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
10
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
10
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage/preview */
|
|
12
12
|
/** @jsx jsx */
|
|
13
|
-
import React, { Fragment } from 'react';
|
|
13
|
+
import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
14
14
|
import { css, jsx } from '@emotion/react';
|
|
15
15
|
import classnames from 'classnames';
|
|
16
16
|
import { injectIntl } from 'react-intl-next';
|
|
@@ -34,10 +34,44 @@ import Toolbar from '../../Toolbar';
|
|
|
34
34
|
import WithFlash from '../../WithFlash';
|
|
35
35
|
import { MainToolbar, mainToolbarCustomComponentsSlotStyle } from './Toolbar';
|
|
36
36
|
var CommentEditorMargin = 14;
|
|
37
|
-
var commentEditorStyle = css(
|
|
38
|
-
|
|
37
|
+
var commentEditorStyle = css({
|
|
38
|
+
display: 'flex',
|
|
39
|
+
flexDirection: 'column',
|
|
40
|
+
'.less-margin .ProseMirror': {
|
|
41
|
+
margin: "var(--ds-space-150, 12px)".concat(" ", "var(--ds-space-100, 8px)", " ", "var(--ds-space-100, 8px)")
|
|
42
|
+
},
|
|
43
|
+
minWidth: '272px',
|
|
44
|
+
height: 'auto',
|
|
45
|
+
backgroundColor: "var(--ds-background-input, white)",
|
|
46
|
+
border: "1px solid ".concat("var(--ds-border, ".concat(N40, ")")),
|
|
47
|
+
boxSizing: 'border-box',
|
|
48
|
+
borderRadius: "".concat(borderRadius(), "px"),
|
|
49
|
+
maxWidth: 'inherit',
|
|
50
|
+
wordWrap: 'break-word'
|
|
51
|
+
});
|
|
52
|
+
var ContentArea = createEditorContentStyle(css({
|
|
53
|
+
flexGrow: 1,
|
|
54
|
+
overflowX: getBooleanFF('platform.editor.table-sticky-scrollbar') ? 'clip' : 'hidden',
|
|
55
|
+
lineHeight: '24px',
|
|
56
|
+
'.ProseMirror': {
|
|
57
|
+
margin: "var(--ds-space-150, 12px)"
|
|
58
|
+
},
|
|
59
|
+
'.gridParent': {
|
|
60
|
+
marginLeft: "".concat(CommentEditorMargin - GRID_GUTTER, "px"),
|
|
61
|
+
marginRight: "".concat(CommentEditorMargin - GRID_GUTTER, "px"),
|
|
62
|
+
width: "calc(100% + ".concat(CommentEditorMargin - GRID_GUTTER, "px)")
|
|
63
|
+
},
|
|
64
|
+
padding: "var(--ds-space-250, 20px)"
|
|
65
|
+
}, tableCommentEditorStyles));
|
|
39
66
|
ContentArea.displayName = 'ContentArea';
|
|
40
|
-
var secondaryToolbarStyle = css(
|
|
67
|
+
var secondaryToolbarStyle = css({
|
|
68
|
+
boxSizing: 'border-box',
|
|
69
|
+
justifyContent: 'flex-end',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
display: 'flex',
|
|
72
|
+
padding: "var(--ds-space-150, 12px)".concat(" ", "var(--ds-space-025, 2px)")
|
|
73
|
+
});
|
|
74
|
+
var appearance = 'comment';
|
|
41
75
|
var Editor = /*#__PURE__*/function (_React$Component) {
|
|
42
76
|
_inherits(Editor, _React$Component);
|
|
43
77
|
var _super = _createSuper(Editor);
|
|
@@ -104,7 +138,9 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
104
138
|
return jsx(WithFlash, {
|
|
105
139
|
animate: maxContentSizeReached
|
|
106
140
|
}, jsx("div", {
|
|
107
|
-
css: [commentEditorStyle, css(
|
|
141
|
+
css: [commentEditorStyle, css({
|
|
142
|
+
minHeight: "".concat(minHeight, "px")
|
|
143
|
+
})],
|
|
108
144
|
className: "akEditor",
|
|
109
145
|
ref: _this.wrapperElementRef
|
|
110
146
|
}, jsx(MainToolbar, {
|
|
@@ -143,7 +179,9 @@ var Editor = /*#__PURE__*/function (_React$Component) {
|
|
|
143
179
|
ref: function ref(_ref3) {
|
|
144
180
|
return _this.containerElement = _ref3;
|
|
145
181
|
},
|
|
146
|
-
css: maxHeight ? css(
|
|
182
|
+
css: maxHeight ? css({
|
|
183
|
+
maxHeight: "".concat(maxHeight, "px")
|
|
184
|
+
}) : null,
|
|
147
185
|
className: classnames('ak-editor-content-area', {
|
|
148
186
|
'less-margin': width < akEditorMobileBreakoutPoint
|
|
149
187
|
}),
|
|
@@ -209,4 +247,165 @@ function RenderWithPluginState(_ref4) {
|
|
|
209
247
|
mediaState: mediaState !== null && mediaState !== void 0 ? mediaState : undefined
|
|
210
248
|
}));
|
|
211
249
|
}
|
|
212
|
-
|
|
250
|
+
var EditorNext = function EditorNext(props) {
|
|
251
|
+
var api = usePresetContext();
|
|
252
|
+
var _useSharedPluginState2 = useSharedPluginState(api, ['media', 'maxContentSize']),
|
|
253
|
+
mediaState = _useSharedPluginState2.mediaState,
|
|
254
|
+
maxContentSizeState = _useSharedPluginState2.maxContentSizeState;
|
|
255
|
+
var editorDOMElement = props.editorDOMElement,
|
|
256
|
+
editorView = props.editorView,
|
|
257
|
+
editorActions = props.editorActions,
|
|
258
|
+
eventDispatcher = props.eventDispatcher,
|
|
259
|
+
providerFactory = props.providerFactory,
|
|
260
|
+
contentComponents = props.contentComponents,
|
|
261
|
+
customContentComponents = props.customContentComponents,
|
|
262
|
+
customPrimaryToolbarComponents = props.customPrimaryToolbarComponents,
|
|
263
|
+
primaryToolbarComponents = props.primaryToolbarComponents,
|
|
264
|
+
customSecondaryToolbarComponents = props.customSecondaryToolbarComponents,
|
|
265
|
+
popupsMountPoint = props.popupsMountPoint,
|
|
266
|
+
popupsBoundariesElement = props.popupsBoundariesElement,
|
|
267
|
+
popupsScrollableElement = props.popupsScrollableElement,
|
|
268
|
+
maxHeight = props.maxHeight,
|
|
269
|
+
_props$minHeight = props.minHeight,
|
|
270
|
+
minHeight = _props$minHeight === void 0 ? 150 : _props$minHeight,
|
|
271
|
+
onSave = props.onSave,
|
|
272
|
+
onCancel = props.onCancel,
|
|
273
|
+
disabled = props.disabled,
|
|
274
|
+
dispatchAnalyticsEvent = props.dispatchAnalyticsEvent,
|
|
275
|
+
intl = props.intl,
|
|
276
|
+
useStickyToolbar = props.useStickyToolbar,
|
|
277
|
+
pluginHooks = props.pluginHooks,
|
|
278
|
+
featureFlags = props.featureFlags,
|
|
279
|
+
innerRef = props.innerRef;
|
|
280
|
+
var maxContentSizeReached = Boolean(maxContentSizeState === null || maxContentSizeState === void 0 ? void 0 : maxContentSizeState.maxContentSizeReached);
|
|
281
|
+
var showSecondaryToolbar = !!onSave || !!onCancel || !!customSecondaryToolbarComponents;
|
|
282
|
+
var containerElement = null;
|
|
283
|
+
|
|
284
|
+
// Wrapper container for toolbar and content area
|
|
285
|
+
var wrapperElementRef = useMemo(function () {
|
|
286
|
+
return innerRef || /*#__PURE__*/React.createRef();
|
|
287
|
+
}, [innerRef]);
|
|
288
|
+
var _useState = useState(disabled),
|
|
289
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
290
|
+
saveButtonDisabled = _useState2[0],
|
|
291
|
+
setSaveButtonDisabled = _useState2[1];
|
|
292
|
+
useEffect(function () {
|
|
293
|
+
if (mediaState) {
|
|
294
|
+
mediaState.subscribeToUploadInProgressState(setSaveButtonDisabled);
|
|
295
|
+
}
|
|
296
|
+
return function () {
|
|
297
|
+
return mediaState === null || mediaState === void 0 ? void 0 : mediaState.unsubscribeFromUploadInProgressState(setSaveButtonDisabled);
|
|
298
|
+
};
|
|
299
|
+
}, [mediaState]);
|
|
300
|
+
var handleSave = useCallback(function () {
|
|
301
|
+
if (editorView && onSave) {
|
|
302
|
+
onSave(editorView);
|
|
303
|
+
}
|
|
304
|
+
}, [editorView, onSave]);
|
|
305
|
+
var handleCancel = useCallback(function () {
|
|
306
|
+
if (editorView && onCancel) {
|
|
307
|
+
onCancel(editorView);
|
|
308
|
+
}
|
|
309
|
+
}, [editorView, onCancel]);
|
|
310
|
+
var isShortcutToFocusToolbar = useCallback(function (event) {
|
|
311
|
+
//Alt + F9 to reach first element in this main toolbar
|
|
312
|
+
return event.altKey && (event.key === 'F9' || event.keyCode === 120);
|
|
313
|
+
}, []);
|
|
314
|
+
var isTwoLineToolbarEnabled = !!customPrimaryToolbarComponents && !!(featureFlags !== null && featureFlags !== void 0 && featureFlags.twoLineEditorToolbar);
|
|
315
|
+
var handleEscape = useCallback(function (event) {
|
|
316
|
+
if (!(editorView !== null && editorView !== void 0 && editorView.hasFocus())) {
|
|
317
|
+
editorView === null || editorView === void 0 || editorView.focus();
|
|
318
|
+
}
|
|
319
|
+
event.preventDefault();
|
|
320
|
+
event.stopPropagation();
|
|
321
|
+
}, [editorView]);
|
|
322
|
+
return jsx(WithFlash, {
|
|
323
|
+
animate: maxContentSizeReached
|
|
324
|
+
}, jsx("div", {
|
|
325
|
+
css: [commentEditorStyle, css({
|
|
326
|
+
minHeight: "".concat(minHeight, "px")
|
|
327
|
+
})],
|
|
328
|
+
className: "akEditor",
|
|
329
|
+
ref: wrapperElementRef
|
|
330
|
+
}, jsx(MainToolbar, {
|
|
331
|
+
useStickyToolbar: useStickyToolbar,
|
|
332
|
+
twoLineEditorToolbar: isTwoLineToolbarEnabled
|
|
333
|
+
}, jsx(ToolbarArrowKeyNavigationProvider, {
|
|
334
|
+
editorView: editorView,
|
|
335
|
+
childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
|
|
336
|
+
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
337
|
+
handleEscape: handleEscape,
|
|
338
|
+
editorAppearance: appearance,
|
|
339
|
+
useStickyToolbar: useStickyToolbar,
|
|
340
|
+
intl: intl
|
|
341
|
+
}, jsx(Toolbar, {
|
|
342
|
+
editorView: editorView,
|
|
343
|
+
editorActions: editorActions,
|
|
344
|
+
eventDispatcher: eventDispatcher,
|
|
345
|
+
providerFactory: providerFactory,
|
|
346
|
+
appearance: appearance,
|
|
347
|
+
items: primaryToolbarComponents,
|
|
348
|
+
popupsMountPoint: popupsMountPoint,
|
|
349
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
350
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
351
|
+
disabled: !!disabled,
|
|
352
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
353
|
+
containerElement: containerElement,
|
|
354
|
+
twoLineEditorToolbar: isTwoLineToolbarEnabled
|
|
355
|
+
}), jsx("div", {
|
|
356
|
+
css: mainToolbarCustomComponentsSlotStyle(isTwoLineToolbarEnabled)
|
|
357
|
+
}, customPrimaryToolbarComponents))), jsx(ClickAreaBlock, {
|
|
358
|
+
editorView: editorView,
|
|
359
|
+
editorDisabled: disabled
|
|
360
|
+
}, jsx(WidthConsumer, null, function (_ref5) {
|
|
361
|
+
var width = _ref5.width;
|
|
362
|
+
return jsx(ContentArea, {
|
|
363
|
+
ref: function ref(_ref6) {
|
|
364
|
+
return containerElement = _ref6;
|
|
365
|
+
},
|
|
366
|
+
css: maxHeight ? css({
|
|
367
|
+
maxHeight: "".concat(maxHeight, "px")
|
|
368
|
+
}) : null,
|
|
369
|
+
className: classnames('ak-editor-content-area', {
|
|
370
|
+
'less-margin': width < akEditorMobileBreakoutPoint
|
|
371
|
+
}),
|
|
372
|
+
featureFlags: featureFlags
|
|
373
|
+
}, customContentComponents && 'before' in customContentComponents ? customContentComponents.before : customContentComponents, jsx(PluginSlot, {
|
|
374
|
+
editorView: editorView,
|
|
375
|
+
editorActions: editorActions,
|
|
376
|
+
eventDispatcher: eventDispatcher,
|
|
377
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
378
|
+
providerFactory: providerFactory,
|
|
379
|
+
appearance: appearance,
|
|
380
|
+
items: contentComponents,
|
|
381
|
+
popupsMountPoint: popupsMountPoint,
|
|
382
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
383
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
384
|
+
containerElement: containerElement,
|
|
385
|
+
disabled: !!disabled,
|
|
386
|
+
wrapperElement: wrapperElementRef.current,
|
|
387
|
+
pluginHooks: pluginHooks
|
|
388
|
+
}), editorDOMElement, customContentComponents && 'after' in customContentComponents ? customContentComponents.after : null);
|
|
389
|
+
}))), showSecondaryToolbar && jsx("div", {
|
|
390
|
+
css: secondaryToolbarStyle,
|
|
391
|
+
"data-testid": "ak-editor-secondary-toolbar"
|
|
392
|
+
}, jsx(ButtonGroup, null, !!onSave && jsx(Button, {
|
|
393
|
+
appearance: "primary",
|
|
394
|
+
onClick: handleSave,
|
|
395
|
+
testId: "comment-save-button",
|
|
396
|
+
isDisabled: disabled || saveButtonDisabled
|
|
397
|
+
}, intl.formatMessage(messages.saveButton)), !!onCancel && jsx(Button, {
|
|
398
|
+
appearance: "subtle",
|
|
399
|
+
onClick: handleCancel,
|
|
400
|
+
isDisabled: disabled
|
|
401
|
+
}, intl.formatMessage(messages.cancelButton))), jsx("span", {
|
|
402
|
+
style: {
|
|
403
|
+
flexGrow: 1
|
|
404
|
+
}
|
|
405
|
+
}), customSecondaryToolbarComponents));
|
|
406
|
+
};
|
|
407
|
+
EditorNext.displayName = 'CommentEditorAppearance';
|
|
408
|
+
var CommentEditorNextWithIntl = injectIntl(EditorNext);
|
|
409
|
+
var CommentEditorOldWithIntl = injectIntl(Editor);
|
|
410
|
+
var ExportComp = getBooleanFF('platform.editor.media.alluploadsfinished-dispatch-update_ivtow') ? CommentEditorNextWithIntl : CommentEditorOldWithIntl;
|
|
411
|
+
export var CommentEditorWithIntl = ExportComp;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "
|
|
2
|
+
export var version = "193.0.0";
|