@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.
Files changed (58) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/create-editor/ReactEditorView.js +66 -9
  3. package/dist/cjs/ui/Appearance/Comment/Comment-compiled.compiled.css +30 -0
  4. package/dist/cjs/ui/Appearance/Comment/Comment-compiled.js +275 -0
  5. package/dist/cjs/ui/Appearance/Comment/Comment-emotion.js +357 -0
  6. package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -344
  7. package/dist/cjs/ui/Appearance/FullPage/FullPage.js +1 -1
  8. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +96 -0
  9. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-compiled.js +190 -0
  10. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-emotion.js +413 -0
  11. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea.js +10 -402
  12. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbarNext.js +21 -2
  13. package/dist/cjs/ui/EditorContentContainer/EditorContentContainer-compiled.js +6 -5
  14. package/dist/cjs/ui/EditorContentContainer/EditorContentContainer-emotion.js +6 -4
  15. package/dist/cjs/ui/EditorContentContainer/styles/backgroundColorStyles.js +17 -6
  16. package/dist/cjs/ui/EditorContentContainer/styles/expandStyles.js +2 -2
  17. package/dist/cjs/version-wrapper.js +1 -1
  18. package/dist/es2019/create-editor/ReactEditorView.js +60 -9
  19. package/dist/es2019/ui/Appearance/Comment/Comment-compiled.compiled.css +30 -0
  20. package/dist/es2019/ui/Appearance/Comment/Comment-compiled.js +262 -0
  21. package/dist/es2019/ui/Appearance/Comment/Comment-emotion.js +344 -0
  22. package/dist/es2019/ui/Appearance/Comment/Comment.js +4 -337
  23. package/dist/es2019/ui/Appearance/FullPage/FullPage.js +1 -1
  24. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +96 -0
  25. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-compiled.js +179 -0
  26. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-emotion.js +405 -0
  27. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea.js +8 -400
  28. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbarNext.js +21 -2
  29. package/dist/es2019/ui/EditorContentContainer/EditorContentContainer-compiled.js +6 -5
  30. package/dist/es2019/ui/EditorContentContainer/EditorContentContainer-emotion.js +8 -6
  31. package/dist/es2019/ui/EditorContentContainer/styles/backgroundColorStyles.js +16 -5
  32. package/dist/es2019/ui/EditorContentContainer/styles/expandStyles.js +1 -1
  33. package/dist/es2019/version-wrapper.js +1 -1
  34. package/dist/esm/create-editor/ReactEditorView.js +66 -9
  35. package/dist/esm/ui/Appearance/Comment/Comment-compiled.compiled.css +30 -0
  36. package/dist/esm/ui/Appearance/Comment/Comment-compiled.js +268 -0
  37. package/dist/esm/ui/Appearance/Comment/Comment-emotion.js +346 -0
  38. package/dist/esm/ui/Appearance/Comment/Comment.js +6 -339
  39. package/dist/esm/ui/Appearance/FullPage/FullPage.js +1 -1
  40. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +96 -0
  41. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-compiled.js +183 -0
  42. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-emotion.js +403 -0
  43. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea.js +10 -398
  44. package/dist/esm/ui/Appearance/FullPage/FullPageToolbarNext.js +21 -2
  45. package/dist/esm/ui/EditorContentContainer/EditorContentContainer-compiled.js +6 -5
  46. package/dist/esm/ui/EditorContentContainer/EditorContentContainer-emotion.js +8 -6
  47. package/dist/esm/ui/EditorContentContainer/styles/backgroundColorStyles.js +16 -5
  48. package/dist/esm/ui/EditorContentContainer/styles/expandStyles.js +1 -1
  49. package/dist/esm/version-wrapper.js +1 -1
  50. package/dist/types/ui/Appearance/Comment/Comment-compiled.d.ts +30 -0
  51. package/dist/types/ui/Appearance/Comment/Comment-emotion.d.ts +20 -0
  52. package/dist/types/ui/Appearance/Comment/Comment.d.ts +2 -20
  53. package/dist/types/ui/Appearance/FullPage/FullPageContentArea-compiled.d.ts +56 -0
  54. package/dist/types/ui/Appearance/FullPage/FullPageContentArea-emotion.d.ts +56 -0
  55. package/dist/types/ui/Appearance/FullPage/FullPageContentArea.d.ts +6 -54
  56. package/dist/types/ui/EditorContentContainer/styles/backgroundColorStyles.d.ts +7 -0
  57. package/dist/types/ui/EditorContentContainer/styles/expandStyles.d.ts +1 -1
  58. package/package.json +8 -8
@@ -39,14 +39,25 @@ export const backgroundColorStyles = css({
39
39
  paddingBottom: 2,
40
40
  boxDecorationBreak: 'clone'
41
41
  },
42
- // Don't show text highlight styling when there is a hyperlink
43
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
44
- 'a .fabric-background-color-mark': {
45
- backgroundColor: 'unset'
46
- },
47
42
  // Don't show text highlight styling when there is an inline comment
48
43
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
49
44
  '.fabric-background-color-mark .ak-editor-annotation': {
50
45
  backgroundColor: 'unset'
51
46
  }
47
+ });
48
+
49
+ /**
50
+ * @deprecated This style has been migrated to Compiled CSS, under experiment platform_editor_core_static_css
51
+ * If you need to make changes here, also update the corresponding style in
52
+ * packages/editor/editor-core/src/ui/EditorContentContainer/EditorContentContainer-compiled.tsx
53
+ * See EDITOR-7600 for more details: https://hello.jira.atlassian.cloud/jira/browse/EDITOR-7600
54
+ */
55
+ // Don't show text highlight styling when there is a hyperlink.
56
+ // Conditionally applied when the highlight-on-links experiment is off.
57
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles, @atlaskit/volt-strict-mode/no-multiple-exports
58
+ export const highlightLinksUnsetStyles = css({
59
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
60
+ 'a .fabric-background-color-mark': {
61
+ backgroundColor: 'unset'
62
+ }
52
63
  });
@@ -340,7 +340,7 @@ export const expandStylesMixin_fg_platform_editor_nested_dnd_styles_changes = cs
340
340
  * See EDITOR-7600 for more details: https://hello.jira.atlassian.cloud/jira/browse/EDITOR-7600
341
341
  */
342
342
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
343
- export const expandStylesMixin_experiment_platform_editor_chromeless_expand_fix = css({
343
+ export const expandStylesMixin_chromeless_expand_fix = css({
344
344
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
345
345
  '.ProseMirror > .ak-editor-expand': {
346
346
  marginLeft: 0,
@@ -1,3 +1,3 @@
1
1
  export const name = "@atlaskit/editor-core";
2
2
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
3
- export const version = "221.2.1";
3
+ export const version = "221.3.1";
@@ -29,6 +29,8 @@ import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
29
29
  import { EditorState, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
30
30
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
31
31
  import { EditorSSRRenderer } from '@atlaskit/editor-ssr-renderer';
32
+ import { createSSREditorState } from '@atlaskit/editor-ssr-renderer/create-ssr-editor-state';
33
+ import { createSSRPMPlugins } from '@atlaskit/editor-ssr-renderer/create-ssr-pm-plugins';
32
34
  import { fg } from '@atlaskit/platform-feature-flags';
33
35
  import { getInteractionId } from '@atlaskit/react-ufo/interaction-id-context';
34
36
  import { abortAll, getActiveInteraction } from '@atlaskit/react-ufo/interaction-metrics';
@@ -105,7 +107,12 @@ export function ReactEditorView(props) {
105
107
  __livePage = _props$editorProps.__livePage,
106
108
  onEditorCreated = props.onEditorCreated,
107
109
  onEditorDestroyed = props.onEditorDestroyed;
108
- var ssrEditorStateRef = useRef(undefined);
110
+
111
+ // Holds the best available EditorState before the ProseMirror EditorView has mounted.
112
+ // On SSR: set to the SSR-rendered state so toolbar plugins can read it via getEditorState().
113
+ // On client first render: set to initialEditorState for the same reason.
114
+ // Cleared to undefined once createEditorView runs and viewRef.current becomes available.
115
+ var preMountEditorStateRef = useRef(undefined);
109
116
  var editorRef = useRef(null);
110
117
  var viewRef = useRef();
111
118
  var focusTimeoutId = useRef();
@@ -133,8 +140,8 @@ export function ReactEditorView(props) {
133
140
  return createFeatureFlagsFromProps(editorPropFeatureFlags);
134
141
  }, [editorPropFeatureFlags]);
135
142
  var getEditorState = useCallback(function () {
136
- var _ssrEditorStateRef$cu, _viewRef$current;
137
- return (_ssrEditorStateRef$cu = ssrEditorStateRef.current) !== null && _ssrEditorStateRef$cu !== void 0 ? _ssrEditorStateRef$cu : (_viewRef$current = viewRef.current) === null || _viewRef$current === void 0 ? void 0 : _viewRef$current.state;
143
+ var _preMountEditorStateR, _viewRef$current;
144
+ return (_preMountEditorStateR = preMountEditorStateRef.current) !== null && _preMountEditorStateR !== void 0 ? _preMountEditorStateR : (_viewRef$current = viewRef.current) === null || _viewRef$current === void 0 ? void 0 : _viewRef$current.state;
138
145
  }, []);
139
146
  var getEditorView = useCallback(function () {
140
147
  return viewRef.current;
@@ -257,12 +264,17 @@ export function ReactEditorView(props) {
257
264
  // so we can save some CPU time here.
258
265
  return undefined;
259
266
  }
260
- return createEditorState({
267
+ var state = createEditorState({
261
268
  props: props,
262
269
  doc: defaultValue,
263
270
  // ED-4759: Don't set selection at end for full-page editor - should be at start.
264
271
  selectionAtStart: isFullPage(nextAppearance)
265
272
  });
273
+ if (expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
274
+ // CSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
275
+ preMountEditorStateRef.current = state;
276
+ }
277
+ return state;
266
278
  },
267
279
  // This is only used for the initial state - afterwards we will have `viewRef` available for use
268
280
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -663,6 +675,10 @@ export function ReactEditorView(props) {
663
675
  mount: node
664
676
  }, getDirectEditorProps());
665
677
  viewRef.current = view;
678
+ if (expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
679
+ // clears pre-mount state as soon as the final view is mounted
680
+ preMountEditorStateRef.current = undefined;
681
+ }
666
682
  measureRender(measurements.PROSEMIRROR_RENDERED, function (_ref3) {
667
683
  var duration = _ref3.duration,
668
684
  startTime = _ref3.startTime,
@@ -1028,17 +1044,56 @@ export function ReactEditorView(props) {
1028
1044
  return buildDoc(schema);
1029
1045
  };
1030
1046
  var doc = profileSSROperation("".concat(SSR_TRACE_SEGMENT_NAME, "/buildDoc"), doBuildDoc, onSSRMeasure);
1047
+
1048
+ // When the platform_editor_ssr_toolbar_optimistic is on, we create SSR-safe PM plugins and EditorState
1049
+ // HERE in ssrDeps — before any children render — so that FullPageToolbarNext can read correct
1050
+ // plugin state via useSharedPluginStateWithSelector → currentState() → getEditorState().
1051
+ //
1052
+ // We also pass these pre-built pmPlugins and editorState to EditorSSRRenderer so it can
1053
+ // skip redundant creation (avoids double createPluginsList + EditorState.create).
1054
+ if (expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
1055
+ var ssrPMPlugins = profileSSROperation("".concat(SSR_TRACE_SEGMENT_NAME, "/createSSRPMPlugins"), function () {
1056
+ return createSSRPMPlugins({
1057
+ plugins: plugins,
1058
+ schema: schema,
1059
+ portalProviderAPI: props.portalProviderAPI,
1060
+ getIntl: function getIntl() {
1061
+ return props.intl;
1062
+ }
1063
+ });
1064
+ }, onSSRMeasure);
1065
+ var ssrState = profileSSROperation("".concat(SSR_TRACE_SEGMENT_NAME, "/createSSREditorState"), function () {
1066
+ return createSSREditorState({
1067
+ doc: doc,
1068
+ schema: schema,
1069
+ pmPlugins: ssrPMPlugins
1070
+ });
1071
+ }, onSSRMeasure);
1072
+ return {
1073
+ plugins: plugins,
1074
+ schema: schema,
1075
+ doc: doc,
1076
+ ssrPMPlugins: ssrPMPlugins,
1077
+ ssrEditorState: ssrState
1078
+ };
1079
+ }
1031
1080
  return {
1032
1081
  plugins: plugins,
1033
1082
  schema: schema,
1034
- doc: doc
1083
+ doc: doc,
1084
+ ssrPMPlugins: undefined,
1085
+ ssrEditorState: undefined
1035
1086
  };
1036
- }, [allowBlockType, buildDoc, props.preset, onSSRMeasure]);
1087
+ }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl]);
1088
+ // SSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
1089
+ if (ssrDeps !== null && ssrDeps !== void 0 && ssrDeps.ssrEditorState) {
1090
+ preMountEditorStateRef.current = ssrDeps.ssrEditorState;
1091
+ }
1037
1092
  var _props$editorProps3 = props.editorProps,
1038
1093
  assistiveLabel = _props$editorProps3.assistiveLabel,
1039
1094
  assistiveDescribedBy = _props$editorProps3.assistiveDescribedBy;
1040
1095
  var handleSsrEditorStateChanged = useCallback(function (state) {
1041
- ssrEditorStateRef.current = state;
1096
+ preMountEditorStateRef.current = state;
1042
1097
  // Notify listeners about the initial SSR state
1043
1098
  pluginInjectionAPI.current.onEditorViewUpdated({
1044
1099
  newEditorState: state,
@@ -1085,11 +1140,13 @@ export function ReactEditorView(props) {
1085
1140
  id: EDIT_AREA_ID,
1086
1141
  "aria-describedby": assistiveDescribedBy,
1087
1142
  "data-editor-id": editorId.current,
1088
- onSSRMeasure: onSSRMeasure
1143
+ onSSRMeasure: onSSRMeasure,
1144
+ prebuiltPMPlugins: ssrDeps.ssrPMPlugins,
1145
+ prebuiltEditorState: ssrDeps.ssrEditorState
1089
1146
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
1090
1147
  ,
1091
1148
  onEditorStateChanged: expValEquals('platform_editor_perf_lint_cleanup', 'isEnabled', true) ? handleSsrEditorStateChanged : function (state) {
1092
- ssrEditorStateRef.current = state;
1149
+ preMountEditorStateRef.current = state;
1093
1150
  // Notify listeners about the initial SSR state
1094
1151
  pluginInjectionAPI.current.onEditorViewUpdated({
1095
1152
  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,268 @@
1
+ /* Comment-compiled.tsx generated by @compiled/babel-plugin v0.39.1 */
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import "./Comment-compiled.compiled.css";
5
+ import { ax, ix } from "@compiled/react/runtime";
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ /**
9
+ * Compiled branch of the `platform_editor_core_non_ecc_static_css` experiment.
10
+ * Used via `componentWithCondition` in `Comment.tsx`.
11
+ *
12
+ * Cleanup: delete this file once the experiment has shipped.
13
+ */
14
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
15
+ import classnames from 'classnames';
16
+ import { useIntl } from 'react-intl';
17
+ import ButtonGroup from '@atlaskit/button/button-group';
18
+ import Button from '@atlaskit/button/new';
19
+ import { useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
20
+ import messages from '@atlaskit/editor-common/messages';
21
+ import { WidthConsumer, WidthProvider } from '@atlaskit/editor-common/ui';
22
+ import { ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
23
+ import { akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
24
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
25
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
26
+ // Ignored via go/ees005
27
+ // eslint-disable-next-line import/no-named-as-default
28
+ import ClickAreaBlock from '../../Addon/ClickAreaBlock';
29
+ import { contentComponentClickWrapper } from '../../Addon/ClickAreaBlock/contentComponentWrapper';
30
+ import EditorContentContainer from '../../EditorContentContainer/EditorContentContainer';
31
+ import PluginSlot from '../../PluginSlot';
32
+ import { getPrimaryToolbarComponents } from '../../Toolbar/getPrimaryToolbarComponents';
33
+ import { ToolbarWithSizeDetector as Toolbar } from '../../Toolbar/ToolbarWithSizeDetector';
34
+ import WithFlash from '../../WithFlash';
35
+ import { CommentToolbar } from './CommentToolbar';
36
+ import { MainToolbar } from './Toolbar';
37
+ var commentEditorCompiledStyles = {
38
+ commentEditorOld: "_19itno8c _2rkofajl _1e0c1txw _2lx21bp4 _1ul9clpc _4t3i1wug _bfhk1j9a _vchhusvi _p12f1kw7 _slp31hna _13dfutpp _gzr8u2gc _ghozu2gc _oafwu2gc",
39
+ commentEditor: "_19itno8c _2rko1qi0 _1e0c1txw _2lx21bp4 _1ul9clpc _4t3i1wug _bfhk1j9a _vchhusvi _p12f1kw7 _slp31hna _13dfutpp _gzr8u2gc _ghozu2gc _oafwu2gc",
40
+ modernisedEditor: "_2rkopb1k",
41
+ secondaryToolbar: "_vchhusvi _1bahesu3 _4cvr1h6o _1e0c1txw _ca0qutpp _u5f3v77o _n3tdutpp _19bvv77o",
42
+ mainToolbarCustomComponentsSlotNew: "_1e0c1txw _1bahesu3 _4cvr1h6o _16jlkb7n _u5f3v47k _p7r11txw _t1edidpf",
43
+ mainToolbarCustomComponentsSlotPaddingOverride: "_u5f3idpf",
44
+ mainToolbarCustomComponentsSlotTwoLineToolbar: "_xugcidpf",
45
+ contentAreaMaxHeight: "_c71lmz22 _18m91wug"
46
+ };
47
+ var appearance = 'comment';
48
+ export var CommentEditorWithIntlCompiled = function CommentEditorWithIntlCompiled(props) {
49
+ var _editorAPI$blockMenu$, _editorAPI$blockMenu;
50
+ var editorAPI = props.editorAPI;
51
+
52
+ // Get useStandardNodeWidth from block menu plugin shared state
53
+ // Only access editorAPI when the experiment is enabled to avoid performance impact
54
+ var useStandardNodeWidth = editorExperiment('platform_editor_controls', 'variant1') && ((_editorAPI$blockMenu$ = editorAPI === null || editorAPI === void 0 || (_editorAPI$blockMenu = editorAPI.blockMenu) === null || _editorAPI$blockMenu === void 0 || (_editorAPI$blockMenu = _editorAPI$blockMenu.sharedState) === null || _editorAPI$blockMenu === void 0 || (_editorAPI$blockMenu = _editorAPI$blockMenu.currentState()) === null || _editorAPI$blockMenu === void 0 ? void 0 : _editorAPI$blockMenu.useStandardNodeWidth) !== null && _editorAPI$blockMenu$ !== void 0 ? _editorAPI$blockMenu$ : false);
55
+ var _useSharedPluginState = useSharedPluginStateWithSelector(editorAPI, ['maxContentSize', 'primaryToolbar', 'editorViewMode'], function (states) {
56
+ var _states$maxContentSiz, _states$primaryToolba, _states$editorViewMod;
57
+ return {
58
+ maxContentSizeReached: !!((_states$maxContentSiz = states.maxContentSizeState) !== null && _states$maxContentSiz !== void 0 && _states$maxContentSiz.maxContentSizeReached),
59
+ primaryToolbarComponentsState: (_states$primaryToolba = states.primaryToolbarState) === null || _states$primaryToolba === void 0 ? void 0 : _states$primaryToolba.components,
60
+ editorViewMode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
61
+ };
62
+ }),
63
+ editorViewMode = _useSharedPluginState.editorViewMode,
64
+ primaryToolbarComponentsState = _useSharedPluginState.primaryToolbarComponentsState,
65
+ maxContentSizeReached = _useSharedPluginState.maxContentSizeReached;
66
+ var primaryToolbarState = getPrimaryToolbarComponents(editorAPI, primaryToolbarComponentsState);
67
+ var _useSharedPluginState2 = useSharedPluginState(editorAPI, ['media']),
68
+ mediaState = _useSharedPluginState2.mediaState;
69
+ var intl = useIntl();
70
+ var editorDOMElement = props.editorDOMElement,
71
+ editorView = props.editorView,
72
+ editorActions = props.editorActions,
73
+ eventDispatcher = props.eventDispatcher,
74
+ providerFactory = props.providerFactory,
75
+ contentComponents = props.contentComponents,
76
+ customContentComponents = props.customContentComponents,
77
+ customPrimaryToolbarComponents = props.customPrimaryToolbarComponents,
78
+ primaryToolbarComponentsProp = props.primaryToolbarComponents,
79
+ customSecondaryToolbarComponents = props.customSecondaryToolbarComponents,
80
+ popupsMountPoint = props.popupsMountPoint,
81
+ popupsBoundariesElement = props.popupsBoundariesElement,
82
+ popupsScrollableElement = props.popupsScrollableElement,
83
+ maxHeight = props.maxHeight,
84
+ _props$minHeight = props.minHeight,
85
+ minHeight = _props$minHeight === void 0 ? 150 : _props$minHeight,
86
+ onSave = props.onSave,
87
+ onCancel = props.onCancel,
88
+ disabled = props.disabled,
89
+ dispatchAnalyticsEvent = props.dispatchAnalyticsEvent,
90
+ useStickyToolbar = props.useStickyToolbar,
91
+ pluginHooks = props.pluginHooks,
92
+ featureFlags = props.featureFlags,
93
+ innerRef = props.innerRef,
94
+ isEditorModernisationEnabled = props.isEditorModernisationEnabled;
95
+ var showSecondaryToolbar = !!onSave || !!onCancel || !!customSecondaryToolbarComponents;
96
+ var containerElement = React.useRef(null);
97
+
98
+ // Wrapper container for toolbar and content area
99
+ var wrapperElementRef = useMemo(function () {
100
+ return innerRef || /*#__PURE__*/React.createRef();
101
+ }, [innerRef]);
102
+ var _useState = useState(false),
103
+ _useState2 = _slicedToArray(_useState, 2),
104
+ saveButtonDisabled = _useState2[0],
105
+ setSaveButtonDisabled = _useState2[1];
106
+ useEffect(function () {
107
+ if (mediaState) {
108
+ mediaState.subscribeToUploadInProgressState(setSaveButtonDisabled);
109
+ }
110
+ return function () {
111
+ return mediaState === null || mediaState === void 0 ? void 0 : mediaState.unsubscribeFromUploadInProgressState(setSaveButtonDisabled);
112
+ };
113
+ }, [mediaState]);
114
+ var handleSave = useCallback(function () {
115
+ if (editorView && onSave) {
116
+ onSave(editorView);
117
+ }
118
+ }, [editorView, onSave]);
119
+ var handleCancel = useCallback(function () {
120
+ if (editorView && onCancel) {
121
+ onCancel(editorView);
122
+ }
123
+ }, [editorView, onCancel]);
124
+ var isShortcutToFocusToolbar = useCallback(function (event) {
125
+ //Alt + F9 to reach first element in this main toolbar
126
+ return event.altKey && (event.key === 'F9' || event.keyCode === 120);
127
+ }, []);
128
+
129
+ // When primary toolbar components is undefined, do not show two line editor toolbar
130
+ var isTwoLineToolbarEnabled = !!customPrimaryToolbarComponents;
131
+ var handleEscape = useCallback(function (event) {
132
+ if (!(editorView !== null && editorView !== void 0 && editorView.hasFocus())) {
133
+ editorView === null || editorView === void 0 || editorView.focus();
134
+ }
135
+ event.preventDefault();
136
+ event.stopPropagation();
137
+ }, [editorView]);
138
+ var primaryToolbarComponents = primaryToolbarComponentsProp;
139
+ if (Array.isArray(primaryToolbarState === null || primaryToolbarState === void 0 ? void 0 : primaryToolbarState.components) && Array.isArray(primaryToolbarComponents)) {
140
+ primaryToolbarComponents = primaryToolbarState.components.concat(primaryToolbarComponents);
141
+ }
142
+ var isToolbarAIFCEnabled = Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar);
143
+ var wrapperStyle = useMemo(function () {
144
+ return _objectSpread({
145
+ minHeight: "".concat(minHeight, "px")
146
+ }, maxHeight ? {
147
+ '--comment-editor-max-height': "".concat(maxHeight, "px")
148
+ } : {});
149
+ }, [minHeight, maxHeight]);
150
+ var customToolbarSlot = /*#__PURE__*/React.createElement("div", {
151
+ className: ax([commentEditorCompiledStyles.mainToolbarCustomComponentsSlotNew, isTwoLineToolbarEnabled && commentEditorCompiledStyles.mainToolbarCustomComponentsSlotTwoLineToolbar, isToolbarAIFCEnabled && commentEditorCompiledStyles.mainToolbarCustomComponentsSlotPaddingOverride])
152
+ }, customPrimaryToolbarComponents);
153
+ return /*#__PURE__*/React.createElement(WithFlash, {
154
+ animate: maxContentSizeReached
155
+ }, /*#__PURE__*/React.createElement(WidthProvider, null, /*#__PURE__*/React.createElement("div", {
156
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- dynamic minHeight/maxHeight from props
157
+ style: wrapperStyle
158
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
159
+ ,
160
+ className: ax([expValEquals('platform_editor_comment_editor_border_radius', 'isEnabled', true) ? commentEditorCompiledStyles.commentEditor : commentEditorCompiledStyles.commentEditorOld, isEditorModernisationEnabled && commentEditorCompiledStyles.modernisedEditor, "akEditor"]),
161
+ ref: wrapperElementRef
162
+ }, /*#__PURE__*/React.createElement(MainToolbar, {
163
+ isEditorModernisationEnabled: isEditorModernisationEnabled,
164
+ useStickyToolbar: useStickyToolbar,
165
+ twoLineEditorToolbar: isTwoLineToolbarEnabled,
166
+ isNewToolbarEnabled: isToolbarAIFCEnabled
167
+ }, isToolbarAIFCEnabled ? /*#__PURE__*/React.createElement(ToolbarArrowKeyNavigationProvider, {
168
+ editorView: editorView,
169
+ childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
170
+ isShortcutToFocusToolbar: isShortcutToFocusToolbar,
171
+ handleEscape: handleEscape,
172
+ editorAppearance: appearance,
173
+ useStickyToolbar: useStickyToolbar,
174
+ intl: intl
175
+ }, /*#__PURE__*/React.createElement(CommentToolbar, {
176
+ editorAPI: editorAPI,
177
+ editorView: editorView,
178
+ editorAppearance: appearance,
179
+ disabled: !!disabled,
180
+ popupsBoundariesElement: popupsBoundariesElement,
181
+ popupsScrollableElement: popupsScrollableElement,
182
+ popupsMountPoint: popupsMountPoint
183
+ }), customPrimaryToolbarComponents ? customToolbarSlot : null) : /*#__PURE__*/React.createElement(ToolbarArrowKeyNavigationProvider, {
184
+ editorView: editorView,
185
+ childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
186
+ isShortcutToFocusToolbar: isShortcutToFocusToolbar,
187
+ handleEscape: handleEscape,
188
+ editorAppearance: appearance,
189
+ useStickyToolbar: useStickyToolbar,
190
+ intl: intl
191
+ }, /*#__PURE__*/React.createElement(Toolbar
192
+ // Ignored via go/ees005
193
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
194
+ , {
195
+ editorView: editorView,
196
+ editorActions: editorActions
197
+ // Ignored via go/ees005
198
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
199
+ ,
200
+ eventDispatcher: eventDispatcher
201
+ // Ignored via go/ees005
202
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
203
+ ,
204
+ providerFactory: providerFactory,
205
+ appearance: appearance,
206
+ items: primaryToolbarComponents,
207
+ popupsMountPoint: popupsMountPoint,
208
+ popupsBoundariesElement: popupsBoundariesElement,
209
+ popupsScrollableElement: popupsScrollableElement,
210
+ disabled: !!disabled,
211
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
212
+ containerElement: containerElement.current,
213
+ twoLineEditorToolbar: isTwoLineToolbarEnabled
214
+ }), customToolbarSlot)), /*#__PURE__*/React.createElement(ClickAreaBlock, {
215
+ editorView: editorView,
216
+ editorDisabled: disabled
217
+ }, /*#__PURE__*/React.createElement(WidthConsumer, null, function (_ref) {
218
+ var width = _ref.width;
219
+ return /*#__PURE__*/React.createElement(EditorContentContainer, {
220
+ ref: containerElement,
221
+ isScrollable: maxHeight ? true : undefined
222
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
223
+ ,
224
+ className: ax([maxHeight && commentEditorCompiledStyles.contentAreaMaxHeight, classnames('ak-editor-content-area', {
225
+ 'less-margin': width < akEditorMobileBreakoutPoint
226
+ })]),
227
+ featureFlags: featureFlags,
228
+ viewMode: editorViewMode,
229
+ appearance: appearance,
230
+ useStandardNodeWidth: useStandardNodeWidth
231
+ }, customContentComponents && 'before' in customContentComponents ? contentComponentClickWrapper(customContentComponents.before) : contentComponentClickWrapper(customContentComponents), /*#__PURE__*/React.createElement(PluginSlot, {
232
+ editorView: editorView,
233
+ editorActions: editorActions,
234
+ eventDispatcher: eventDispatcher,
235
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
236
+ providerFactory: providerFactory,
237
+ appearance: appearance,
238
+ items: contentComponents,
239
+ popupsMountPoint: popupsMountPoint,
240
+ popupsBoundariesElement: popupsBoundariesElement,
241
+ popupsScrollableElement: popupsScrollableElement,
242
+ containerElement: containerElement.current,
243
+ disabled: !!disabled,
244
+ wrapperElement: wrapperElementRef.current,
245
+ pluginHooks: pluginHooks
246
+ }), editorDOMElement, customContentComponents && 'after' in customContentComponents ? contentComponentClickWrapper(customContentComponents.after) : null);
247
+ }))), showSecondaryToolbar && /*#__PURE__*/React.createElement("div", {
248
+ "data-testid": "ak-editor-secondary-toolbar",
249
+ className: ax([commentEditorCompiledStyles.secondaryToolbar])
250
+ }, /*#__PURE__*/React.createElement(ButtonGroup, null, !!onSave && /*#__PURE__*/React.createElement(Button, {
251
+ appearance: "primary",
252
+ onClick: handleSave,
253
+ testId: "comment-save-button",
254
+ isDisabled: disabled || saveButtonDisabled,
255
+ interactionName: "editor-comment-save-button"
256
+ }, intl.formatMessage(messages.saveButton)), !!onCancel && /*#__PURE__*/React.createElement(Button, {
257
+ appearance: "subtle",
258
+ onClick: handleCancel,
259
+ testId: "comment-cancel-button",
260
+ isDisabled: disabled,
261
+ interactionName: "editor-comment-cancel-button"
262
+ }, intl.formatMessage(messages.cancelButton))), /*#__PURE__*/React.createElement("span", {
263
+ style: {
264
+ flexGrow: 1
265
+ }
266
+ }), customSecondaryToolbarComponents)));
267
+ };
268
+ CommentEditorWithIntlCompiled.displayName = 'CommentEditorAppearance';