@atlaskit/editor-core 221.3.0 → 221.3.2
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 +22 -0
- package/dist/cjs/create-editor/ReactEditorView.js +66 -9
- package/dist/cjs/ui/Appearance/Comment/Comment-compiled.compiled.css +30 -0
- package/dist/cjs/ui/Appearance/Comment/Comment-compiled.js +275 -0
- package/dist/cjs/ui/Appearance/Comment/Comment-emotion.js +357 -0
- package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -344
- package/dist/cjs/ui/Appearance/FullPage/FullPage.js +1 -1
- package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +96 -0
- package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-compiled.js +190 -0
- package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-emotion.js +413 -0
- package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea.js +10 -402
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbarNext.js +21 -2
- package/dist/cjs/ui/EditorContentContainer/EditorContentContainer-compiled.js +6 -5
- package/dist/cjs/ui/EditorContentContainer/EditorContentContainer-emotion.js +6 -4
- package/dist/cjs/ui/EditorContentContainer/styles/backgroundColorStyles.js +17 -6
- package/dist/cjs/ui/EditorContentContainer/styles/expandStyles.js +2 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/ReactEditorView.js +60 -9
- package/dist/es2019/ui/Appearance/Comment/Comment-compiled.compiled.css +30 -0
- package/dist/es2019/ui/Appearance/Comment/Comment-compiled.js +262 -0
- package/dist/es2019/ui/Appearance/Comment/Comment-emotion.js +344 -0
- package/dist/es2019/ui/Appearance/Comment/Comment.js +4 -337
- package/dist/es2019/ui/Appearance/FullPage/FullPage.js +1 -1
- package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +96 -0
- package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-compiled.js +179 -0
- package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-emotion.js +405 -0
- package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea.js +8 -400
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbarNext.js +21 -2
- package/dist/es2019/ui/EditorContentContainer/EditorContentContainer-compiled.js +6 -5
- package/dist/es2019/ui/EditorContentContainer/EditorContentContainer-emotion.js +8 -6
- package/dist/es2019/ui/EditorContentContainer/styles/backgroundColorStyles.js +16 -5
- package/dist/es2019/ui/EditorContentContainer/styles/expandStyles.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/ReactEditorView.js +66 -9
- package/dist/esm/ui/Appearance/Comment/Comment-compiled.compiled.css +30 -0
- package/dist/esm/ui/Appearance/Comment/Comment-compiled.js +268 -0
- package/dist/esm/ui/Appearance/Comment/Comment-emotion.js +346 -0
- package/dist/esm/ui/Appearance/Comment/Comment.js +6 -339
- package/dist/esm/ui/Appearance/FullPage/FullPage.js +1 -1
- package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +96 -0
- package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-compiled.js +183 -0
- package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-emotion.js +403 -0
- package/dist/esm/ui/Appearance/FullPage/FullPageContentArea.js +10 -398
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbarNext.js +21 -2
- package/dist/esm/ui/EditorContentContainer/EditorContentContainer-compiled.js +6 -5
- package/dist/esm/ui/EditorContentContainer/EditorContentContainer-emotion.js +8 -6
- package/dist/esm/ui/EditorContentContainer/styles/backgroundColorStyles.js +16 -5
- package/dist/esm/ui/EditorContentContainer/styles/expandStyles.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/ui/Appearance/Comment/Comment-compiled.d.ts +30 -0
- package/dist/types/ui/Appearance/Comment/Comment-emotion.d.ts +20 -0
- package/dist/types/ui/Appearance/Comment/Comment.d.ts +2 -20
- package/dist/types/ui/Appearance/FullPage/FullPageContentArea-compiled.d.ts +56 -0
- package/dist/types/ui/Appearance/FullPage/FullPageContentArea-emotion.d.ts +56 -0
- package/dist/types/ui/Appearance/FullPage/FullPageContentArea.d.ts +6 -54
- package/dist/types/ui/EditorContentContainer/styles/backgroundColorStyles.d.ts +7 -0
- package/dist/types/ui/EditorContentContainer/styles/expandStyles.d.ts +1 -1
- package/package.json +8 -8
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.textHighlightPaddingStyles = exports.backgroundColorStyles = void 0;
|
|
6
|
+
exports.textHighlightPaddingStyles = exports.highlightLinksUnsetStyles = exports.backgroundColorStyles = void 0;
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
8
|
/* eslint-disable @atlaskit/ui-styling-standard/use-compiled,
|
|
9
9
|
@repo/internal/deprecations/deprecation-ticket-required,
|
|
@@ -46,14 +46,25 @@ var backgroundColorStyles = exports.backgroundColorStyles = (0, _react.css)({
|
|
|
46
46
|
paddingBottom: 2,
|
|
47
47
|
boxDecorationBreak: 'clone'
|
|
48
48
|
},
|
|
49
|
-
// Don't show text highlight styling when there is a hyperlink
|
|
50
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
51
|
-
'a .fabric-background-color-mark': {
|
|
52
|
-
backgroundColor: 'unset'
|
|
53
|
-
},
|
|
54
49
|
// Don't show text highlight styling when there is an inline comment
|
|
55
50
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
56
51
|
'.fabric-background-color-mark .ak-editor-annotation': {
|
|
57
52
|
backgroundColor: 'unset'
|
|
58
53
|
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated This style has been migrated to Compiled CSS, under experiment platform_editor_core_static_css
|
|
58
|
+
* If you need to make changes here, also update the corresponding style in
|
|
59
|
+
* packages/editor/editor-core/src/ui/EditorContentContainer/EditorContentContainer-compiled.tsx
|
|
60
|
+
* See EDITOR-7600 for more details: https://hello.jira.atlassian.cloud/jira/browse/EDITOR-7600
|
|
61
|
+
*/
|
|
62
|
+
// Don't show text highlight styling when there is a hyperlink.
|
|
63
|
+
// Conditionally applied when the highlight-on-links experiment is off.
|
|
64
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/volt-strict-mode/no-multiple-exports
|
|
65
|
+
var highlightLinksUnsetStyles = exports.highlightLinksUnsetStyles = (0, _react.css)({
|
|
66
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
67
|
+
'a .fabric-background-color-mark': {
|
|
68
|
+
backgroundColor: 'unset'
|
|
69
|
+
}
|
|
59
70
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getDenseExpandTitleStyles = exports.expandStylesMixin_without_fg_platform_editor_nested_dnd_styles_changes = exports.expandStylesMixin_fg_platform_visual_refresh_icons = exports.expandStylesMixin_fg_platform_editor_nested_dnd_styles_changes = exports.
|
|
6
|
+
exports.getDenseExpandTitleStyles = exports.expandStylesMixin_without_fg_platform_editor_nested_dnd_styles_changes = exports.expandStylesMixin_fg_platform_visual_refresh_icons = exports.expandStylesMixin_fg_platform_editor_nested_dnd_styles_changes = exports.expandStylesMixin_chromeless_expand_fix = exports.expandStylesBase = exports.expandStyles = void 0;
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
8
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
9
9
|
/* eslint-disable @atlaskit/ui-styling-standard/use-compiled,
|
|
@@ -347,7 +347,7 @@ var expandStylesMixin_fg_platform_editor_nested_dnd_styles_changes = exports.exp
|
|
|
347
347
|
* See EDITOR-7600 for more details: https://hello.jira.atlassian.cloud/jira/browse/EDITOR-7600
|
|
348
348
|
*/
|
|
349
349
|
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
350
|
-
var
|
|
350
|
+
var expandStylesMixin_chromeless_expand_fix = exports.expandStylesMixin_chromeless_expand_fix = (0, _react.css)({
|
|
351
351
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
352
352
|
'.ProseMirror > .ak-editor-expand': {
|
|
353
353
|
marginLeft: 0,
|
|
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.name = void 0;
|
|
7
7
|
var name = exports.name = "@atlaskit/editor-core";
|
|
8
8
|
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
9
|
-
var version = exports.version = "221.
|
|
9
|
+
var version = exports.version = "221.3.1";
|
|
@@ -21,6 +21,8 @@ import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
|
21
21
|
import { EditorState, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
22
22
|
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
23
23
|
import { EditorSSRRenderer } from '@atlaskit/editor-ssr-renderer';
|
|
24
|
+
import { createSSREditorState } from '@atlaskit/editor-ssr-renderer/create-ssr-editor-state';
|
|
25
|
+
import { createSSRPMPlugins } from '@atlaskit/editor-ssr-renderer/create-ssr-pm-plugins';
|
|
24
26
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
25
27
|
import { getInteractionId } from '@atlaskit/react-ufo/interaction-id-context';
|
|
26
28
|
import { abortAll, getActiveInteraction } from '@atlaskit/react-ufo/interaction-metrics';
|
|
@@ -87,7 +89,12 @@ export function ReactEditorView(props) {
|
|
|
87
89
|
onEditorCreated,
|
|
88
90
|
onEditorDestroyed
|
|
89
91
|
} = props;
|
|
90
|
-
|
|
92
|
+
|
|
93
|
+
// Holds the best available EditorState before the ProseMirror EditorView has mounted.
|
|
94
|
+
// On SSR: set to the SSR-rendered state so toolbar plugins can read it via getEditorState().
|
|
95
|
+
// On client first render: set to initialEditorState for the same reason.
|
|
96
|
+
// Cleared to undefined once createEditorView runs and viewRef.current becomes available.
|
|
97
|
+
const preMountEditorStateRef = useRef(undefined);
|
|
91
98
|
const editorRef = useRef(null);
|
|
92
99
|
const viewRef = useRef();
|
|
93
100
|
const focusTimeoutId = useRef();
|
|
@@ -111,8 +118,8 @@ export function ReactEditorView(props) {
|
|
|
111
118
|
const contentTransformer = useRef(undefined);
|
|
112
119
|
const featureFlags = useMemo(() => createFeatureFlagsFromProps(editorPropFeatureFlags), [editorPropFeatureFlags]);
|
|
113
120
|
const getEditorState = useCallback(() => {
|
|
114
|
-
var
|
|
115
|
-
return (
|
|
121
|
+
var _preMountEditorStateR, _viewRef$current;
|
|
122
|
+
return (_preMountEditorStateR = preMountEditorStateRef.current) !== null && _preMountEditorStateR !== void 0 ? _preMountEditorStateR : (_viewRef$current = viewRef.current) === null || _viewRef$current === void 0 ? void 0 : _viewRef$current.state;
|
|
116
123
|
}, []);
|
|
117
124
|
const getEditorView = useCallback(() => viewRef.current, []);
|
|
118
125
|
const dispatch = useMemo(() => createDispatch(eventDispatcher), [eventDispatcher]);
|
|
@@ -228,12 +235,17 @@ export function ReactEditorView(props) {
|
|
|
228
235
|
// so we can save some CPU time here.
|
|
229
236
|
return undefined;
|
|
230
237
|
}
|
|
231
|
-
|
|
238
|
+
const state = createEditorState({
|
|
232
239
|
props,
|
|
233
240
|
doc: defaultValue,
|
|
234
241
|
// ED-4759: Don't set selection at end for full-page editor - should be at start.
|
|
235
242
|
selectionAtStart: isFullPage(nextAppearance)
|
|
236
243
|
});
|
|
244
|
+
if (expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
|
|
245
|
+
// CSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
|
|
246
|
+
preMountEditorStateRef.current = state;
|
|
247
|
+
}
|
|
248
|
+
return state;
|
|
237
249
|
},
|
|
238
250
|
// This is only used for the initial state - afterwards we will have `viewRef` available for use
|
|
239
251
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -622,6 +634,10 @@ export function ReactEditorView(props) {
|
|
|
622
634
|
mount: node
|
|
623
635
|
}, getDirectEditorProps());
|
|
624
636
|
viewRef.current = view;
|
|
637
|
+
if (expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
|
|
638
|
+
// clears pre-mount state as soon as the final view is mounted
|
|
639
|
+
preMountEditorStateRef.current = undefined;
|
|
640
|
+
}
|
|
625
641
|
measureRender(measurements.PROSEMIRROR_RENDERED, ({
|
|
626
642
|
duration,
|
|
627
643
|
startTime,
|
|
@@ -960,18 +976,51 @@ export function ReactEditorView(props) {
|
|
|
960
976
|
const schema = profileSSROperation(`${SSR_TRACE_SEGMENT_NAME}/createSchema`, doCreateSchema, onSSRMeasure);
|
|
961
977
|
const doBuildDoc = () => buildDoc(schema);
|
|
962
978
|
const doc = profileSSROperation(`${SSR_TRACE_SEGMENT_NAME}/buildDoc`, doBuildDoc, onSSRMeasure);
|
|
979
|
+
|
|
980
|
+
// When the platform_editor_ssr_toolbar_optimistic is on, we create SSR-safe PM plugins and EditorState
|
|
981
|
+
// HERE in ssrDeps — before any children render — so that FullPageToolbarNext can read correct
|
|
982
|
+
// plugin state via useSharedPluginStateWithSelector → currentState() → getEditorState().
|
|
983
|
+
//
|
|
984
|
+
// We also pass these pre-built pmPlugins and editorState to EditorSSRRenderer so it can
|
|
985
|
+
// skip redundant creation (avoids double createPluginsList + EditorState.create).
|
|
986
|
+
if (expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
|
|
987
|
+
const ssrPMPlugins = profileSSROperation(`${SSR_TRACE_SEGMENT_NAME}/createSSRPMPlugins`, () => createSSRPMPlugins({
|
|
988
|
+
plugins,
|
|
989
|
+
schema,
|
|
990
|
+
portalProviderAPI: props.portalProviderAPI,
|
|
991
|
+
getIntl: () => props.intl
|
|
992
|
+
}), onSSRMeasure);
|
|
993
|
+
const ssrState = profileSSROperation(`${SSR_TRACE_SEGMENT_NAME}/createSSREditorState`, () => createSSREditorState({
|
|
994
|
+
doc,
|
|
995
|
+
schema,
|
|
996
|
+
pmPlugins: ssrPMPlugins
|
|
997
|
+
}), onSSRMeasure);
|
|
998
|
+
return {
|
|
999
|
+
plugins,
|
|
1000
|
+
schema,
|
|
1001
|
+
doc,
|
|
1002
|
+
ssrPMPlugins,
|
|
1003
|
+
ssrEditorState: ssrState
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
963
1006
|
return {
|
|
964
1007
|
plugins,
|
|
965
1008
|
schema,
|
|
966
|
-
doc
|
|
1009
|
+
doc,
|
|
1010
|
+
ssrPMPlugins: undefined,
|
|
1011
|
+
ssrEditorState: undefined
|
|
967
1012
|
};
|
|
968
|
-
}, [allowBlockType, buildDoc, props.preset, onSSRMeasure]);
|
|
1013
|
+
}, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl]);
|
|
1014
|
+
// SSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
|
|
1015
|
+
if (ssrDeps !== null && ssrDeps !== void 0 && ssrDeps.ssrEditorState) {
|
|
1016
|
+
preMountEditorStateRef.current = ssrDeps.ssrEditorState;
|
|
1017
|
+
}
|
|
969
1018
|
const {
|
|
970
1019
|
assistiveLabel,
|
|
971
1020
|
assistiveDescribedBy
|
|
972
1021
|
} = props.editorProps;
|
|
973
1022
|
const handleSsrEditorStateChanged = useCallback(state => {
|
|
974
|
-
|
|
1023
|
+
preMountEditorStateRef.current = state;
|
|
975
1024
|
// Notify listeners about the initial SSR state
|
|
976
1025
|
pluginInjectionAPI.current.onEditorViewUpdated({
|
|
977
1026
|
newEditorState: state,
|
|
@@ -1016,11 +1065,13 @@ export function ReactEditorView(props) {
|
|
|
1016
1065
|
id: EDIT_AREA_ID,
|
|
1017
1066
|
"aria-describedby": assistiveDescribedBy,
|
|
1018
1067
|
"data-editor-id": editorId.current,
|
|
1019
|
-
onSSRMeasure: onSSRMeasure
|
|
1068
|
+
onSSRMeasure: onSSRMeasure,
|
|
1069
|
+
prebuiltPMPlugins: ssrDeps.ssrPMPlugins,
|
|
1070
|
+
prebuiltEditorState: ssrDeps.ssrEditorState
|
|
1020
1071
|
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
1021
1072
|
,
|
|
1022
1073
|
onEditorStateChanged: expValEquals('platform_editor_perf_lint_cleanup', 'isEnabled', true) ? handleSsrEditorStateChanged : state => {
|
|
1023
|
-
|
|
1074
|
+
preMountEditorStateRef.current = state;
|
|
1024
1075
|
// Notify listeners about the initial SSR state
|
|
1025
1076
|
pluginInjectionAPI.current.onEditorViewUpdated({
|
|
1026
1077
|
newEditorState: state,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
._19itno8c{border:var(--ds-border-width,1px) solid var(--ds-border-input,#8c8f97)}
|
|
3
|
+
._2rko1qi0{border-radius:var(--ds-radius-medium,6px)}
|
|
4
|
+
._2rkofajl{border-radius:var(--ds-radius-small,3px)}
|
|
5
|
+
._2rkopb1k{border-radius:var(--ds-radius-xlarge,9pt)}._13dfutpp .less-margin>.ProseMirror{margin-top:var(--ds-space-150,9pt)}
|
|
6
|
+
._16jlkb7n{flex-grow:1}
|
|
7
|
+
._18m91wug{overflow-y:auto}
|
|
8
|
+
._19bvv77o{padding-left:var(--ds-space-025,2px)}
|
|
9
|
+
._1bahesu3{justify-content:flex-end}
|
|
10
|
+
._1e0c1txw{display:flex}
|
|
11
|
+
._1ul9clpc{min-width:17pc}
|
|
12
|
+
._2lx21bp4{flex-direction:column}
|
|
13
|
+
._4cvr1h6o{align-items:center}
|
|
14
|
+
._4t3i1wug{height:auto}
|
|
15
|
+
._bfhk1j9a{background-color:var(--ds-background-input,#fff)}
|
|
16
|
+
._c71lmz22{max-height:var(--comment-editor-max-height)}
|
|
17
|
+
._ca0qutpp{padding-top:var(--ds-space-150,9pt)}
|
|
18
|
+
._ghozu2gc .less-margin>.ProseMirror{margin-bottom:var(--ds-space-100,8px)}
|
|
19
|
+
._gzr8u2gc .less-margin>.ProseMirror{margin-right:var(--ds-space-100,8px)}
|
|
20
|
+
._n3tdutpp{padding-bottom:var(--ds-space-150,9pt)}
|
|
21
|
+
._oafwu2gc .less-margin>.ProseMirror{margin-left:var(--ds-space-100,8px)}
|
|
22
|
+
._p12f1kw7{max-width:inherit}
|
|
23
|
+
._p7r11txw >div{display:flex}
|
|
24
|
+
._slp31hna{word-wrap:break-word}
|
|
25
|
+
._t1edidpf >div{flex-shrink:0}
|
|
26
|
+
._u5f3idpf{padding-right:0}
|
|
27
|
+
._u5f3v47k{padding-right:var(--ds-space-250,20px)}
|
|
28
|
+
._u5f3v77o{padding-right:var(--ds-space-025,2px)}
|
|
29
|
+
._vchhusvi{box-sizing:border-box}
|
|
30
|
+
@media (max-width:490px){._xugcidpf{padding-right:0}}
|
|
@@ -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';
|