@atlaskit/editor-core 242.1.0 → 242.2.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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 242.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`77aeba2398de1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/77aeba2398de1) -
8
+ Update i18n NPM package versions for editor,editor-extensions,activity-platform,media,elements
9
+ (Group 3)
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 242.1.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`059477aa93f45`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/059477aa93f45) -
20
+ Revert docking-based optimistic toolbar state initialization under
21
+ platform_editor_ssr_toolbar_optimistic.
22
+ - [`059477aa93f45`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/059477aa93f45) -
23
+ Add an optimistic-toolbar opt-out to plugin configuration. Exclude Live pages from
24
+ platform_editor_ssr_toolbar_optimistic, including early editor-state exposure, toolbar rendering,
25
+ and asynchronous media and mention provider initialization. Preserve the experiment for Edit pages
26
+ regardless of toolbar docking position.
27
+ - Updated dependencies
28
+
3
29
  ## 242.1.0
4
30
 
5
31
  ### Minor Changes
@@ -62,7 +62,6 @@ var _filterPluginsForReconfigure = require("./filter-plugins-for-reconfigure");
62
62
  var _messages = require("./messages");
63
63
  var _getUAPrefix = require("./ReactEditorView/getUAPrefix");
64
64
  var _handleEditorFocus = require("./ReactEditorView/handleEditorFocus");
65
- var _shouldUseOptimisticToolbarState = require("./ReactEditorView/shouldUseOptimisticToolbarState");
66
65
  var _useDispatchTransaction = require("./ReactEditorView/useDispatchTransaction");
67
66
  var _useFireFullWidthEvent = require("./ReactEditorView/useFireFullWidthEvent");
68
67
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -86,7 +85,6 @@ function ReactEditorView(props) {
86
85
  editorPropFeatureFlags = _props$editorProps.featureFlags,
87
86
  errorReporterHandler = _props$editorProps.errorReporterHandler,
88
87
  defaultValue = _props$editorProps.defaultValue,
89
- primaryToolbarComponents = _props$editorProps.primaryToolbarComponents,
90
88
  shouldFocus = _props$editorProps.shouldFocus,
91
89
  onEditorCreated = props.onEditorCreated,
92
90
  onEditorDestroyed = props.onEditorDestroyed;
@@ -96,6 +94,7 @@ function ReactEditorView(props) {
96
94
  // On client first render: set to initialEditorState for the same reason.
97
95
  // Cleared to undefined once createEditorView runs and viewRef.current becomes available.
98
96
  var preMountEditorStateRef = (0, _react.useRef)(undefined);
97
+ var isOptimisticToolbar = !props.editorProps.__livePage && (0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true);
99
98
  var editorRef = (0, _react.useRef)(null);
100
99
  var viewRef = (0, _react.useRef)();
101
100
  var focusTimeoutId = (0, _react.useRef)();
@@ -250,13 +249,10 @@ function ReactEditorView(props) {
250
249
  doc: defaultValue,
251
250
  // ED-4759: Don't set selection at end for full-page editor - should be at start.
252
251
  // Match SSR's start selection so the optimistic toolbar hydrates with the same block type.
253
- selectionAtStart: (0, _isFullPage.isFullPage)(nextAppearance) || nextAppearance === 'max' && (0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)
252
+ selectionAtStart: (0, _isFullPage.isFullPage)(nextAppearance) || nextAppearance === 'max' && isOptimisticToolbar
254
253
  });
255
- if ((0, _shouldUseOptimisticToolbarState.shouldUseOptimisticToolbarState)(pluginInjectionAPI.current.api(), {
256
- appearance: nextAppearance,
257
- primaryToolbarComponents: primaryToolbarComponents
258
- })) {
259
- // Only expose state before mount when the initial toolbar needs it.
254
+ if (isOptimisticToolbar) {
255
+ // CSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
260
256
  preMountEditorStateRef.current = state;
261
257
  }
262
258
  return state;
@@ -551,7 +547,7 @@ function ReactEditorView(props) {
551
547
  mount: node
552
548
  }, getDirectEditorProps());
553
549
  viewRef.current = view;
554
- if ((0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
550
+ if (isOptimisticToolbar) {
555
551
  // clears pre-mount state as soon as the final view is mounted
556
552
  preMountEditorStateRef.current = undefined;
557
553
  }
@@ -642,7 +638,7 @@ function ReactEditorView(props) {
642
638
  oldEditorState: undefined
643
639
  });
644
640
  return view;
645
- }, [getDirectEditorProps, dispatchAnalyticsEvent]);
641
+ }, [getDirectEditorProps, dispatchAnalyticsEvent, isOptimisticToolbar]);
646
642
  var _useState = (0, _react.useState)(undefined),
647
643
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
648
644
  editorView = _useState2[0],
@@ -925,16 +921,13 @@ function ReactEditorView(props) {
925
921
  var isViewMode = ((_pluginInjectionAPI$c6 = pluginInjectionAPI.current.api()) === null || _pluginInjectionAPI$c6 === void 0 || (_pluginInjectionAPI$c6 = _pluginInjectionAPI$c6.editorViewMode) === null || _pluginInjectionAPI$c6 === void 0 || (_pluginInjectionAPI$c6 = _pluginInjectionAPI$c6.sharedState.currentState()) === null || _pluginInjectionAPI$c6 === void 0 ? void 0 : _pluginInjectionAPI$c6.mode) === 'view';
926
922
  var ariaReadonly = isViewMode ? 'true' : undefined;
927
923
 
928
- // When the optimistic toolbar needs initial state, create SSR-safe PM plugins and EditorState
924
+ // When the platform_editor_ssr_toolbar_optimistic is on, we create SSR-safe PM plugins and EditorState
929
925
  // HERE in ssrDeps — before any children render — so that FullPageToolbarNext can read correct
930
926
  // plugin state via useSharedPluginStateWithSelector → currentState() → getEditorState().
931
927
  //
932
928
  // We also pass these pre-built pmPlugins and editorState to EditorSSRRenderer so it can
933
929
  // skip redundant creation (avoids double createPluginsList + EditorState.create).
934
- if ((0, _shouldUseOptimisticToolbarState.shouldUseOptimisticToolbarState)(pluginInjectionAPI.current.api(), {
935
- appearance: nextAppearance,
936
- primaryToolbarComponents: primaryToolbarComponents
937
- })) {
930
+ if (isOptimisticToolbar) {
938
931
  var ssrPMPlugins = (0, _profileSSROperation.profileSSROperation)("".concat(SSR_TRACE_SEGMENT_NAME, "/createSSRPMPlugins"), function () {
939
932
  return (0, _createSsrPmPlugins.createSSRPMPlugins)({
940
933
  plugins: plugins,
@@ -969,7 +962,7 @@ function ReactEditorView(props) {
969
962
  ssrPMPlugins: undefined,
970
963
  ssrEditorState: undefined
971
964
  };
972
- }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl, nextAppearance, primaryToolbarComponents]);
965
+ }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl, isOptimisticToolbar]);
973
966
  // SSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
974
967
  if (ssrDeps !== null && ssrDeps !== void 0 && ssrDeps.ssrEditorState) {
975
968
  preMountEditorStateRef.current = ssrDeps.ssrEditorState;
@@ -138,7 +138,8 @@ var FullPageEditor = exports.FullPageEditor = function FullPageEditor(props) {
138
138
  (0, _constants.FULL_PAGE_EDITOR_TOOLBAR_HEIGHT)(isToolbarAIFCEnabled)
139
139
  }
140
140
  }, !isEditorToolbarHidden && (isToolbarAIFCEnabled ? /*#__PURE__*/_react.default.createElement(_FullPageToolbarNext.FullPageToolbarNext, {
141
- disabled: (0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) ? !hasHadInteraction ? false : !!props.disabled : !!props.disabled,
141
+ disableOptimisticToolbar: props.__livePage,
142
+ disabled: !props.__livePage && (0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) ? !hasHadInteraction ? false : !!props.disabled : !!props.disabled,
142
143
  disabledWithoutInteractionLogic: !!props.disabled,
143
144
  toolbarDockingPosition: toolbarDockingPosition,
144
145
  beforeIcon: props.primaryToolbarIconBefore,
@@ -86,7 +86,9 @@ var FullPageToolbarNext = exports.FullPageToolbarNext = function FullPageToolbar
86
86
  showKeyline = _ref4.showKeyline,
87
87
  customPrimaryToolbarComponents = _ref4.customPrimaryToolbarComponents,
88
88
  disabled = _ref4.disabled,
89
- disabledWithoutInteractionLogic = _ref4.disabledWithoutInteractionLogic;
89
+ disabledWithoutInteractionLogic = _ref4.disabledWithoutInteractionLogic,
90
+ disableOptimisticToolbar = _ref4.disableOptimisticToolbar;
91
+ var isOptimisticToolbar = !disableOptimisticToolbar && (0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true);
90
92
  var components = editorAPI === null || editorAPI === void 0 || (_editorAPI$toolbar = editorAPI.toolbar) === null || _editorAPI$toolbar === void 0 ? void 0 : _editorAPI$toolbar.actions.getComponents();
91
93
  var runtimeOverride = (0, _useSharedPluginStateWithSelector.useSharedPluginStateWithSelector)(editorAPI, ['toolbar'], function (states) {
92
94
  var _states$toolbarState;
@@ -138,7 +140,7 @@ var FullPageToolbarNext = exports.FullPageToolbarNext = function FullPageToolbar
138
140
  // injection API but its components not yet populated. Bypass the early-return
139
141
  // so the toolbar chrome stays mounted for layout stability; ToolbarNext renders
140
142
  // null inside it until components arrive.
141
- var isAwaitingToolbarComponents = (0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) && !Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar);
143
+ var isAwaitingToolbarComponents = isOptimisticToolbar && !Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar);
142
144
  if (!isAwaitingToolbarComponents && !shouldShowToolbarContainer(toolbar, customPrimaryToolbarComponents)) {
143
145
  return /*#__PURE__*/_react.default.createElement(ToolbarPortal, null, null);
144
146
  }
@@ -158,7 +160,7 @@ var FullPageToolbarNext = exports.FullPageToolbarNext = function FullPageToolbar
158
160
  showKeyline: showKeyline || ContextPanelWidth > 0
159
161
  }, beforeIcon && /*#__PURE__*/_react.default.createElement("div", {
160
162
  className: (0, _runtime.ax)([styles.mainToolbarIconBefore, styles.mainToolbarIconBeforeNew])
161
- }, beforeIcon), /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(FirstChildWrapper, null, (0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) ?
163
+ }, beforeIcon), /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(FirstChildWrapper, null, isOptimisticToolbar ?
162
164
  // optimistic toolbar — render immediately on both SSR and CSR with items enabled.
163
165
  // Clicks are noops until editorView mounts.
164
166
  primaryToolbarDockingConfigEnabled && (components && visibleToolbarComponents && (0, _toolbar2.isToolbar)(toolbar) ? /*#__PURE__*/_react.default.createElement(_Toolbar.ToolbarNext, {
@@ -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 = "242.0.18";
9
+ var version = exports.version = "242.1.1";
@@ -51,7 +51,6 @@ import { filterPluginsForReconfigure } from './filter-plugins-for-reconfigure';
51
51
  import { editorMessages } from './messages';
52
52
  import { getUAPrefix } from './ReactEditorView/getUAPrefix';
53
53
  import { handleEditorFocus } from './ReactEditorView/handleEditorFocus';
54
- import { shouldUseOptimisticToolbarState } from './ReactEditorView/shouldUseOptimisticToolbarState';
55
54
  import { useDispatchTransaction } from './ReactEditorView/useDispatchTransaction';
56
55
  import { useFireFullWidthEvent } from './ReactEditorView/useFireFullWidthEvent';
57
56
  const EDIT_AREA_ID = 'ak-editor-textarea';
@@ -70,7 +69,6 @@ export function ReactEditorView(props) {
70
69
  featureFlags: editorPropFeatureFlags,
71
70
  errorReporterHandler,
72
71
  defaultValue,
73
- primaryToolbarComponents,
74
72
  shouldFocus
75
73
  },
76
74
  onEditorCreated,
@@ -82,6 +80,7 @@ export function ReactEditorView(props) {
82
80
  // On client first render: set to initialEditorState for the same reason.
83
81
  // Cleared to undefined once createEditorView runs and viewRef.current becomes available.
84
82
  const preMountEditorStateRef = useRef(undefined);
83
+ const isOptimisticToolbar = !props.editorProps.__livePage && expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true);
85
84
  const editorRef = useRef(null);
86
85
  const viewRef = useRef();
87
86
  const focusTimeoutId = useRef();
@@ -225,13 +224,10 @@ export function ReactEditorView(props) {
225
224
  doc: defaultValue,
226
225
  // ED-4759: Don't set selection at end for full-page editor - should be at start.
227
226
  // Match SSR's start selection so the optimistic toolbar hydrates with the same block type.
228
- selectionAtStart: isFullPage(nextAppearance) || nextAppearance === 'max' && expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)
227
+ selectionAtStart: isFullPage(nextAppearance) || nextAppearance === 'max' && isOptimisticToolbar
229
228
  });
230
- if (shouldUseOptimisticToolbarState(pluginInjectionAPI.current.api(), {
231
- appearance: nextAppearance,
232
- primaryToolbarComponents
233
- })) {
234
- // Only expose state before mount when the initial toolbar needs it.
229
+ if (isOptimisticToolbar) {
230
+ // CSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
235
231
  preMountEditorStateRef.current = state;
236
232
  }
237
233
  return state;
@@ -521,7 +517,7 @@ export function ReactEditorView(props) {
521
517
  mount: node
522
518
  }, getDirectEditorProps());
523
519
  viewRef.current = view;
524
- if (expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
520
+ if (isOptimisticToolbar) {
525
521
  // clears pre-mount state as soon as the final view is mounted
526
522
  preMountEditorStateRef.current = undefined;
527
523
  }
@@ -612,7 +608,7 @@ export function ReactEditorView(props) {
612
608
  oldEditorState: undefined
613
609
  });
614
610
  return view;
615
- }, [getDirectEditorProps, dispatchAnalyticsEvent]);
611
+ }, [getDirectEditorProps, dispatchAnalyticsEvent, isOptimisticToolbar]);
616
612
  const [editorView, setEditorView] = useState(undefined);
617
613
 
618
614
  // Detects if the editor is nested inside an extension - ie. it is a Legacy Content Extension (LCE)
@@ -867,16 +863,13 @@ export function ReactEditorView(props) {
867
863
  const isViewMode = ((_pluginInjectionAPI$c0 = pluginInjectionAPI.current.api()) === null || _pluginInjectionAPI$c0 === void 0 ? void 0 : (_pluginInjectionAPI$c1 = _pluginInjectionAPI$c0.editorViewMode) === null || _pluginInjectionAPI$c1 === void 0 ? void 0 : (_pluginInjectionAPI$c10 = _pluginInjectionAPI$c1.sharedState.currentState()) === null || _pluginInjectionAPI$c10 === void 0 ? void 0 : _pluginInjectionAPI$c10.mode) === 'view';
868
864
  const ariaReadonly = isViewMode ? 'true' : undefined;
869
865
 
870
- // When the optimistic toolbar needs initial state, create SSR-safe PM plugins and EditorState
866
+ // When the platform_editor_ssr_toolbar_optimistic is on, we create SSR-safe PM plugins and EditorState
871
867
  // HERE in ssrDeps — before any children render — so that FullPageToolbarNext can read correct
872
868
  // plugin state via useSharedPluginStateWithSelector → currentState() → getEditorState().
873
869
  //
874
870
  // We also pass these pre-built pmPlugins and editorState to EditorSSRRenderer so it can
875
871
  // skip redundant creation (avoids double createPluginsList + EditorState.create).
876
- if (shouldUseOptimisticToolbarState(pluginInjectionAPI.current.api(), {
877
- appearance: nextAppearance,
878
- primaryToolbarComponents
879
- })) {
872
+ if (isOptimisticToolbar) {
880
873
  const ssrPMPlugins = profileSSROperation(`${SSR_TRACE_SEGMENT_NAME}/createSSRPMPlugins`, () => createSSRPMPlugins({
881
874
  plugins,
882
875
  schema,
@@ -905,7 +898,7 @@ export function ReactEditorView(props) {
905
898
  ssrPMPlugins: undefined,
906
899
  ssrEditorState: undefined
907
900
  };
908
- }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl, nextAppearance, primaryToolbarComponents]);
901
+ }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl, isOptimisticToolbar]);
909
902
  // SSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
910
903
  if (ssrDeps !== null && ssrDeps !== void 0 && ssrDeps.ssrEditorState) {
911
904
  preMountEditorStateRef.current = ssrDeps.ssrEditorState;
@@ -124,7 +124,8 @@ export const FullPageEditor = props => {
124
124
  FULL_PAGE_EDITOR_TOOLBAR_HEIGHT(isToolbarAIFCEnabled)
125
125
  }
126
126
  }, !isEditorToolbarHidden && (isToolbarAIFCEnabled ? /*#__PURE__*/React.createElement(FullPageToolbarNext, {
127
- disabled: expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) ? !hasHadInteraction ? false : !!props.disabled : !!props.disabled,
127
+ disableOptimisticToolbar: props.__livePage,
128
+ disabled: !props.__livePage && expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) ? !hasHadInteraction ? false : !!props.disabled : !!props.disabled,
128
129
  disabledWithoutInteractionLogic: !!props.disabled,
129
130
  toolbarDockingPosition: toolbarDockingPosition,
130
131
  beforeIcon: props.primaryToolbarIconBefore,
@@ -77,9 +77,11 @@ export const FullPageToolbarNext = ({
77
77
  showKeyline,
78
78
  customPrimaryToolbarComponents,
79
79
  disabled,
80
- disabledWithoutInteractionLogic
80
+ disabledWithoutInteractionLogic,
81
+ disableOptimisticToolbar
81
82
  }) => {
82
83
  var _editorAPI$toolbar, _editorAPI$toolbar2, _useToolbarPortal;
84
+ const isOptimisticToolbar = !disableOptimisticToolbar && expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true);
83
85
  const components = editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$toolbar = editorAPI.toolbar) === null || _editorAPI$toolbar === void 0 ? void 0 : _editorAPI$toolbar.actions.getComponents();
84
86
  const runtimeOverride = useSharedPluginStateWithSelector(editorAPI, ['toolbar'], states => {
85
87
  var _states$toolbarState;
@@ -126,7 +128,7 @@ export const FullPageToolbarNext = ({
126
128
  // injection API but its components not yet populated. Bypass the early-return
127
129
  // so the toolbar chrome stays mounted for layout stability; ToolbarNext renders
128
130
  // null inside it until components arrive.
129
- const isAwaitingToolbarComponents = expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) && !Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar);
131
+ const isAwaitingToolbarComponents = isOptimisticToolbar && !Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar);
130
132
  if (!isAwaitingToolbarComponents && !shouldShowToolbarContainer(toolbar, customPrimaryToolbarComponents)) {
131
133
  return /*#__PURE__*/React.createElement(ToolbarPortal, null, null);
132
134
  }
@@ -146,7 +148,7 @@ export const FullPageToolbarNext = ({
146
148
  showKeyline: showKeyline || ContextPanelWidth > 0
147
149
  }, beforeIcon && /*#__PURE__*/React.createElement("div", {
148
150
  className: ax([styles.mainToolbarIconBefore, styles.mainToolbarIconBeforeNew])
149
- }, beforeIcon), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FirstChildWrapper, null, expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) ?
151
+ }, beforeIcon), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FirstChildWrapper, null, isOptimisticToolbar ?
150
152
  // optimistic toolbar — render immediately on both SSR and CSR with items enabled.
151
153
  // Clicks are noops until editorView mounts.
152
154
  primaryToolbarDockingConfigEnabled && (components && visibleToolbarComponents && isToolbar(toolbar) ? /*#__PURE__*/React.createElement(ToolbarNext, {
@@ -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 = "242.0.18";
3
+ export const version = "242.1.1";
@@ -59,7 +59,6 @@ import { filterPluginsForReconfigure } from './filter-plugins-for-reconfigure';
59
59
  import { editorMessages } from './messages';
60
60
  import { getUAPrefix } from './ReactEditorView/getUAPrefix';
61
61
  import { handleEditorFocus } from './ReactEditorView/handleEditorFocus';
62
- import { shouldUseOptimisticToolbarState } from './ReactEditorView/shouldUseOptimisticToolbarState';
63
62
  import { useDispatchTransaction } from './ReactEditorView/useDispatchTransaction';
64
63
  import { useFireFullWidthEvent } from './ReactEditorView/useFireFullWidthEvent';
65
64
  var EDIT_AREA_ID = 'ak-editor-textarea';
@@ -77,7 +76,6 @@ export function ReactEditorView(props) {
77
76
  editorPropFeatureFlags = _props$editorProps.featureFlags,
78
77
  errorReporterHandler = _props$editorProps.errorReporterHandler,
79
78
  defaultValue = _props$editorProps.defaultValue,
80
- primaryToolbarComponents = _props$editorProps.primaryToolbarComponents,
81
79
  shouldFocus = _props$editorProps.shouldFocus,
82
80
  onEditorCreated = props.onEditorCreated,
83
81
  onEditorDestroyed = props.onEditorDestroyed;
@@ -87,6 +85,7 @@ export function ReactEditorView(props) {
87
85
  // On client first render: set to initialEditorState for the same reason.
88
86
  // Cleared to undefined once createEditorView runs and viewRef.current becomes available.
89
87
  var preMountEditorStateRef = useRef(undefined);
88
+ var isOptimisticToolbar = !props.editorProps.__livePage && expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true);
90
89
  var editorRef = useRef(null);
91
90
  var viewRef = useRef();
92
91
  var focusTimeoutId = useRef();
@@ -241,13 +240,10 @@ export function ReactEditorView(props) {
241
240
  doc: defaultValue,
242
241
  // ED-4759: Don't set selection at end for full-page editor - should be at start.
243
242
  // Match SSR's start selection so the optimistic toolbar hydrates with the same block type.
244
- selectionAtStart: isFullPage(nextAppearance) || nextAppearance === 'max' && expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)
243
+ selectionAtStart: isFullPage(nextAppearance) || nextAppearance === 'max' && isOptimisticToolbar
245
244
  });
246
- if (shouldUseOptimisticToolbarState(pluginInjectionAPI.current.api(), {
247
- appearance: nextAppearance,
248
- primaryToolbarComponents: primaryToolbarComponents
249
- })) {
250
- // Only expose state before mount when the initial toolbar needs it.
245
+ if (isOptimisticToolbar) {
246
+ // CSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
251
247
  preMountEditorStateRef.current = state;
252
248
  }
253
249
  return state;
@@ -542,7 +538,7 @@ export function ReactEditorView(props) {
542
538
  mount: node
543
539
  }, getDirectEditorProps());
544
540
  viewRef.current = view;
545
- if (expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
541
+ if (isOptimisticToolbar) {
546
542
  // clears pre-mount state as soon as the final view is mounted
547
543
  preMountEditorStateRef.current = undefined;
548
544
  }
@@ -633,7 +629,7 @@ export function ReactEditorView(props) {
633
629
  oldEditorState: undefined
634
630
  });
635
631
  return view;
636
- }, [getDirectEditorProps, dispatchAnalyticsEvent]);
632
+ }, [getDirectEditorProps, dispatchAnalyticsEvent, isOptimisticToolbar]);
637
633
  var _useState = useState(undefined),
638
634
  _useState2 = _slicedToArray(_useState, 2),
639
635
  editorView = _useState2[0],
@@ -916,16 +912,13 @@ export function ReactEditorView(props) {
916
912
  var isViewMode = ((_pluginInjectionAPI$c6 = pluginInjectionAPI.current.api()) === null || _pluginInjectionAPI$c6 === void 0 || (_pluginInjectionAPI$c6 = _pluginInjectionAPI$c6.editorViewMode) === null || _pluginInjectionAPI$c6 === void 0 || (_pluginInjectionAPI$c6 = _pluginInjectionAPI$c6.sharedState.currentState()) === null || _pluginInjectionAPI$c6 === void 0 ? void 0 : _pluginInjectionAPI$c6.mode) === 'view';
917
913
  var ariaReadonly = isViewMode ? 'true' : undefined;
918
914
 
919
- // When the optimistic toolbar needs initial state, create SSR-safe PM plugins and EditorState
915
+ // When the platform_editor_ssr_toolbar_optimistic is on, we create SSR-safe PM plugins and EditorState
920
916
  // HERE in ssrDeps — before any children render — so that FullPageToolbarNext can read correct
921
917
  // plugin state via useSharedPluginStateWithSelector → currentState() → getEditorState().
922
918
  //
923
919
  // We also pass these pre-built pmPlugins and editorState to EditorSSRRenderer so it can
924
920
  // skip redundant creation (avoids double createPluginsList + EditorState.create).
925
- if (shouldUseOptimisticToolbarState(pluginInjectionAPI.current.api(), {
926
- appearance: nextAppearance,
927
- primaryToolbarComponents: primaryToolbarComponents
928
- })) {
921
+ if (isOptimisticToolbar) {
929
922
  var ssrPMPlugins = profileSSROperation("".concat(SSR_TRACE_SEGMENT_NAME, "/createSSRPMPlugins"), function () {
930
923
  return createSSRPMPlugins({
931
924
  plugins: plugins,
@@ -960,7 +953,7 @@ export function ReactEditorView(props) {
960
953
  ssrPMPlugins: undefined,
961
954
  ssrEditorState: undefined
962
955
  };
963
- }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl, nextAppearance, primaryToolbarComponents]);
956
+ }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl, isOptimisticToolbar]);
964
957
  // SSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
965
958
  if (ssrDeps !== null && ssrDeps !== void 0 && ssrDeps.ssrEditorState) {
966
959
  preMountEditorStateRef.current = ssrDeps.ssrEditorState;
@@ -129,7 +129,8 @@ export var FullPageEditor = function FullPageEditor(props) {
129
129
  FULL_PAGE_EDITOR_TOOLBAR_HEIGHT(isToolbarAIFCEnabled)
130
130
  }
131
131
  }, !isEditorToolbarHidden && (isToolbarAIFCEnabled ? /*#__PURE__*/React.createElement(FullPageToolbarNext, {
132
- disabled: expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) ? !hasHadInteraction ? false : !!props.disabled : !!props.disabled,
132
+ disableOptimisticToolbar: props.__livePage,
133
+ disabled: !props.__livePage && expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) ? !hasHadInteraction ? false : !!props.disabled : !!props.disabled,
133
134
  disabledWithoutInteractionLogic: !!props.disabled,
134
135
  toolbarDockingPosition: toolbarDockingPosition,
135
136
  beforeIcon: props.primaryToolbarIconBefore,
@@ -77,7 +77,9 @@ export var FullPageToolbarNext = function FullPageToolbarNext(_ref4) {
77
77
  showKeyline = _ref4.showKeyline,
78
78
  customPrimaryToolbarComponents = _ref4.customPrimaryToolbarComponents,
79
79
  disabled = _ref4.disabled,
80
- disabledWithoutInteractionLogic = _ref4.disabledWithoutInteractionLogic;
80
+ disabledWithoutInteractionLogic = _ref4.disabledWithoutInteractionLogic,
81
+ disableOptimisticToolbar = _ref4.disableOptimisticToolbar;
82
+ var isOptimisticToolbar = !disableOptimisticToolbar && expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true);
81
83
  var components = editorAPI === null || editorAPI === void 0 || (_editorAPI$toolbar = editorAPI.toolbar) === null || _editorAPI$toolbar === void 0 ? void 0 : _editorAPI$toolbar.actions.getComponents();
82
84
  var runtimeOverride = useSharedPluginStateWithSelector(editorAPI, ['toolbar'], function (states) {
83
85
  var _states$toolbarState;
@@ -129,7 +131,7 @@ export var FullPageToolbarNext = function FullPageToolbarNext(_ref4) {
129
131
  // injection API but its components not yet populated. Bypass the early-return
130
132
  // so the toolbar chrome stays mounted for layout stability; ToolbarNext renders
131
133
  // null inside it until components arrive.
132
- var isAwaitingToolbarComponents = expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) && !Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar);
134
+ var isAwaitingToolbarComponents = isOptimisticToolbar && !Boolean(editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.toolbar);
133
135
  if (!isAwaitingToolbarComponents && !shouldShowToolbarContainer(toolbar, customPrimaryToolbarComponents)) {
134
136
  return /*#__PURE__*/React.createElement(ToolbarPortal, null, null);
135
137
  }
@@ -149,7 +151,7 @@ export var FullPageToolbarNext = function FullPageToolbarNext(_ref4) {
149
151
  showKeyline: showKeyline || ContextPanelWidth > 0
150
152
  }, beforeIcon && /*#__PURE__*/React.createElement("div", {
151
153
  className: ax([styles.mainToolbarIconBefore, styles.mainToolbarIconBeforeNew])
152
- }, beforeIcon), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FirstChildWrapper, null, expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true) ?
154
+ }, beforeIcon), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FirstChildWrapper, null, isOptimisticToolbar ?
153
155
  // optimistic toolbar — render immediately on both SSR and CSR with items enabled.
154
156
  // Clicks are noops until editorView mounts.
155
157
  primaryToolbarDockingConfigEnabled && (components && visibleToolbarComponents && isToolbar(toolbar) ? /*#__PURE__*/React.createElement(ToolbarNext, {
@@ -1,3 +1,3 @@
1
1
  export var name = "@atlaskit/editor-core";
2
2
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
3
- export var version = "242.0.18";
3
+ export var version = "242.1.1";
@@ -13,6 +13,7 @@ type FullPageToolbarNextProps = {
13
13
  customPrimaryToolbarComponents?: PrimaryToolbarComponents;
14
14
  disabled: boolean;
15
15
  disabledWithoutInteractionLogic?: boolean;
16
+ disableOptimisticToolbar?: boolean;
16
17
  editorAPI?: FullPageToolbarPluginAPI;
17
18
  editorView?: EditorView;
18
19
  popupsBoundariesElement?: HTMLElement;
@@ -25,5 +26,5 @@ type FullPageToolbarPluginAPI = PublicPluginAPI<[
25
26
  ToolbarPlugin,
26
27
  OptionalPlugin<MarkdownModePlugin>
27
28
  ]>;
28
- export declare const FullPageToolbarNext: ({ editorAPI, beforeIcon, toolbarDockingPosition, editorView, popupsMountPoint, showKeyline, customPrimaryToolbarComponents, disabled, disabledWithoutInteractionLogic, }: FullPageToolbarNextProps) => JSX.Element;
29
+ export declare const FullPageToolbarNext: ({ editorAPI, beforeIcon, toolbarDockingPosition, editorView, popupsMountPoint, showKeyline, customPrimaryToolbarComponents, disabled, disabledWithoutInteractionLogic, disableOptimisticToolbar, }: FullPageToolbarNextProps) => JSX.Element;
29
30
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "242.1.0",
3
+ "version": "242.2.0",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -42,7 +42,7 @@
42
42
  "dependencies": {
43
43
  "@atlaskit/activity-provider": "^3.1.0",
44
44
  "@atlaskit/adf-schema": "^57.7.0",
45
- "@atlaskit/afm-i18n-platform-editor-editor-core": "2.294.0",
45
+ "@atlaskit/afm-i18n-platform-editor-editor-core": "2.305.0",
46
46
  "@atlaskit/analytics-namespaced-context": "^8.2.0",
47
47
  "@atlaskit/analytics-next": "^12.6.0",
48
48
  "@atlaskit/analytics-next-stable-react-context": "1.0.1",
@@ -61,21 +61,21 @@
61
61
  "@atlaskit/editor-ssr-renderer": "^25.0.0",
62
62
  "@atlaskit/editor-toolbar": "^2.10.0",
63
63
  "@atlaskit/editor-toolbar-model": "^1.2.0",
64
- "@atlaskit/emoji": "^73.4.0",
64
+ "@atlaskit/emoji": "^73.5.0",
65
65
  "@atlaskit/feature-gate-js-client": "^8.0.0",
66
66
  "@atlaskit/heading": "^8.0.0",
67
67
  "@atlaskit/icon": "^38.0.0",
68
68
  "@atlaskit/icon-lab": "^7.11.0",
69
69
  "@atlaskit/link": "^5.1.0",
70
- "@atlaskit/mention": "^30.7.0",
70
+ "@atlaskit/mention": "^30.8.0",
71
71
  "@atlaskit/platform-feature-experiments": "^0.3.0",
72
72
  "@atlaskit/platform-feature-flags": "^2.2.0",
73
73
  "@atlaskit/popup": "^10.2.0",
74
74
  "@atlaskit/primitives": "^22.7.0",
75
75
  "@atlaskit/react-compiler-gating": "^0.2.0",
76
76
  "@atlaskit/react-ufo": "^8.4.0",
77
- "@atlaskit/task-decision": "^21.14.0",
78
- "@atlaskit/tmp-editor-statsig": "^259.0.0",
77
+ "@atlaskit/task-decision": "^21.15.0",
78
+ "@atlaskit/tmp-editor-statsig": "^260.0.0",
79
79
  "@atlaskit/tokens": "^20.10.0",
80
80
  "@atlaskit/tooltip": "^24.4.0",
81
81
  "@atlaskit/width-detector": "^7.2.0",
@@ -91,7 +91,7 @@
91
91
  "uuid": "^11.1.1"
92
92
  },
93
93
  "peerDependencies": {
94
- "@atlaskit/editor-common": "^134.9.0",
94
+ "@atlaskit/editor-common": "^134.10.0",
95
95
  "@atlaskit/link-provider": "^6.1.0",
96
96
  "@atlaskit/media-core": "^39.0.0",
97
97
  "react": "^18.2.0 || ^19.2.0",
@@ -111,7 +111,7 @@
111
111
  "@atlaskit/collab-provider": "^39.1.0",
112
112
  "@atlaskit/docs": "^12.3.0",
113
113
  "@atlaskit/drawer": "^14.3.0",
114
- "@atlaskit/editor-common": "^134.9.0",
114
+ "@atlaskit/editor-common": "^134.10.0",
115
115
  "@atlaskit/editor-plugin-alignment": "^31.1.0",
116
116
  "@atlaskit/editor-plugin-annotation": "^30.0.0",
117
117
  "@atlaskit/editor-plugin-base": "^31.0.0",
@@ -125,10 +125,10 @@
125
125
  "@atlaskit/editor-plugin-guideline": "^30.0.0",
126
126
  "@atlaskit/editor-plugin-highlight": "^30.0.0",
127
127
  "@atlaskit/editor-plugin-hyperlink": "^32.0.0",
128
- "@atlaskit/editor-plugin-insert-block": "^31.0.0",
128
+ "@atlaskit/editor-plugin-insert-block": "^31.1.0",
129
129
  "@atlaskit/editor-plugin-layout": "^31.0.0",
130
130
  "@atlaskit/editor-plugin-list": "^32.0.0",
131
- "@atlaskit/editor-plugin-media": "^32.2.0",
131
+ "@atlaskit/editor-plugin-media": "^32.3.0",
132
132
  "@atlaskit/editor-plugin-media-insert": "^48.0.0",
133
133
  "@atlaskit/editor-plugin-paste": "^31.2.0",
134
134
  "@atlaskit/editor-plugin-selection-marker": "^30.0.0",
@@ -137,7 +137,7 @@
137
137
  "@atlaskit/editor-plugin-table": "^42.3.0",
138
138
  "@atlaskit/editor-plugin-tasks-and-decisions": "^33.0.0",
139
139
  "@atlaskit/editor-plugin-text-color": "^30.0.0",
140
- "@atlaskit/editor-plugin-text-formatting": "^30.2.0",
140
+ "@atlaskit/editor-plugin-text-formatting": "^31.0.0",
141
141
  "@atlaskit/editor-plugin-toolbar": "^27.0.0",
142
142
  "@atlaskit/editor-plugin-toolbar-lists-indentation": "^31.0.0",
143
143
  "@atlaskit/editor-plugin-track-changes": "^29.0.0",
@@ -153,13 +153,13 @@
153
153
  "@atlaskit/media-integration-test-helpers": "workspace:^",
154
154
  "@atlaskit/media-picker": "^73.3.0",
155
155
  "@atlaskit/media-test-helpers": "^43.0.0",
156
- "@atlaskit/media-ui": "^31.6.0",
156
+ "@atlaskit/media-ui": "^31.7.0",
157
157
  "@atlaskit/modal-dialog": "^17.2.0",
158
158
  "@atlaskit/navigation-system": "^11.7.0",
159
159
  "@atlaskit/popper": "^9.4.0",
160
160
  "@atlaskit/portal": "^7.1.0",
161
161
  "@atlaskit/profilecard": "^27.6.0",
162
- "@atlaskit/renderer": "^153.2.0",
162
+ "@atlaskit/renderer": "^153.3.0",
163
163
  "@atlaskit/section-message": "^10.2.0",
164
164
  "@atlaskit/spinner": "^20.4.0",
165
165
  "@atlaskit/synchrony-test-helpers": "workspace:^",
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.shouldUseOptimisticToolbarState = void 0;
7
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
8
- var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
9
- var _isFullPage = require("../../utils/is-full-page");
10
- /** Resolve initial toolbar usage without publishing editor state to shared-state consumers. */
11
- var shouldUseOptimisticToolbarState = exports.shouldUseOptimisticToolbarState = function shouldUseOptimisticToolbarState(editorAPI, props) {
12
- var _editorAPI$editorView, _editorAPI$userPrefer;
13
- if (!(0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
14
- return false;
15
- }
16
-
17
- // Docking applies to full-page appearances. Preserve other editors' initialization.
18
- if (!(0, _isFullPage.isFullPage)(props.appearance) && props.appearance !== 'max') {
19
- return true;
20
- }
21
- if ((editorAPI === null || editorAPI === void 0 || (_editorAPI$editorView = editorAPI.editorViewMode) === null || _editorAPI$editorView === void 0 || (_editorAPI$editorView = _editorAPI$editorView.sharedState.currentState()) === null || _editorAPI$editorView === void 0 ? void 0 : _editorAPI$editorView.mode) === 'view') {
22
- return false;
23
- }
24
-
25
- // Custom controls and the legacy toolbar can still consume the initial state.
26
- if (props.primaryToolbarComponents || !(editorAPI !== null && editorAPI !== void 0 && editorAPI.toolbar) || !(0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_controls', 'cohort', 'variant1')) {
27
- return true;
28
- }
29
- var mode = editorAPI.toolbar.actions.contextualFormattingMode();
30
- if (mode === 'always-pinned' || mode === undefined) {
31
- return true;
32
- }
33
- if (mode !== 'controlled') {
34
- return false;
35
- }
36
-
37
- // This action reads the provider/config directly, without needing a PM state.
38
- // Keep the existing behavior if the initial preference is not yet known.
39
- return ((_editorAPI$userPrefer = editorAPI.userPreferences) === null || _editorAPI$userPrefer === void 0 || (_editorAPI$userPrefer = _editorAPI$userPrefer.actions.getUserPreferences()) === null || _editorAPI$userPrefer === void 0 ? void 0 : _editorAPI$userPrefer.toolbarDockingPosition) !== 'none';
40
- };
@@ -1,35 +0,0 @@
1
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
3
- import { isFullPage } from '../../utils/is-full-page';
4
-
5
- /** Resolve initial toolbar usage without publishing editor state to shared-state consumers. */
6
- export const shouldUseOptimisticToolbarState = (editorAPI, props) => {
7
- var _editorAPI$editorView, _editorAPI$editorView2, _editorAPI$userPrefer, _editorAPI$userPrefer2;
8
- if (!expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
9
- return false;
10
- }
11
-
12
- // Docking applies to full-page appearances. Preserve other editors' initialization.
13
- if (!isFullPage(props.appearance) && props.appearance !== 'max') {
14
- return true;
15
- }
16
- if ((editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$editorView = editorAPI.editorViewMode) === null || _editorAPI$editorView === void 0 ? void 0 : (_editorAPI$editorView2 = _editorAPI$editorView.sharedState.currentState()) === null || _editorAPI$editorView2 === void 0 ? void 0 : _editorAPI$editorView2.mode) === 'view') {
17
- return false;
18
- }
19
-
20
- // Custom controls and the legacy toolbar can still consume the initial state.
21
- if (props.primaryToolbarComponents || !(editorAPI !== null && editorAPI !== void 0 && editorAPI.toolbar) || !expValEqualsNoExposure('platform_editor_controls', 'cohort', 'variant1')) {
22
- return true;
23
- }
24
- const mode = editorAPI.toolbar.actions.contextualFormattingMode();
25
- if (mode === 'always-pinned' || mode === undefined) {
26
- return true;
27
- }
28
- if (mode !== 'controlled') {
29
- return false;
30
- }
31
-
32
- // This action reads the provider/config directly, without needing a PM state.
33
- // Keep the existing behavior if the initial preference is not yet known.
34
- return ((_editorAPI$userPrefer = editorAPI.userPreferences) === null || _editorAPI$userPrefer === void 0 ? void 0 : (_editorAPI$userPrefer2 = _editorAPI$userPrefer.actions.getUserPreferences()) === null || _editorAPI$userPrefer2 === void 0 ? void 0 : _editorAPI$userPrefer2.toolbarDockingPosition) !== 'none';
35
- };
@@ -1,35 +0,0 @@
1
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
3
- import { isFullPage } from '../../utils/is-full-page';
4
-
5
- /** Resolve initial toolbar usage without publishing editor state to shared-state consumers. */
6
- export var shouldUseOptimisticToolbarState = function shouldUseOptimisticToolbarState(editorAPI, props) {
7
- var _editorAPI$editorView, _editorAPI$userPrefer;
8
- if (!expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
9
- return false;
10
- }
11
-
12
- // Docking applies to full-page appearances. Preserve other editors' initialization.
13
- if (!isFullPage(props.appearance) && props.appearance !== 'max') {
14
- return true;
15
- }
16
- if ((editorAPI === null || editorAPI === void 0 || (_editorAPI$editorView = editorAPI.editorViewMode) === null || _editorAPI$editorView === void 0 || (_editorAPI$editorView = _editorAPI$editorView.sharedState.currentState()) === null || _editorAPI$editorView === void 0 ? void 0 : _editorAPI$editorView.mode) === 'view') {
17
- return false;
18
- }
19
-
20
- // Custom controls and the legacy toolbar can still consume the initial state.
21
- if (props.primaryToolbarComponents || !(editorAPI !== null && editorAPI !== void 0 && editorAPI.toolbar) || !expValEqualsNoExposure('platform_editor_controls', 'cohort', 'variant1')) {
22
- return true;
23
- }
24
- var mode = editorAPI.toolbar.actions.contextualFormattingMode();
25
- if (mode === 'always-pinned' || mode === undefined) {
26
- return true;
27
- }
28
- if (mode !== 'controlled') {
29
- return false;
30
- }
31
-
32
- // This action reads the provider/config directly, without needing a PM state.
33
- // Keep the existing behavior if the initial preference is not yet known.
34
- return ((_editorAPI$userPrefer = editorAPI.userPreferences) === null || _editorAPI$userPrefer === void 0 || (_editorAPI$userPrefer = _editorAPI$userPrefer.actions.getUserPreferences()) === null || _editorAPI$userPrefer === void 0 ? void 0 : _editorAPI$userPrefer.toolbarDockingPosition) !== 'none';
35
- };
@@ -1,4 +0,0 @@
1
- import type { EditorPluginInjectionAPI } from '@atlaskit/editor-common/preset/plugin-injection-api';
2
- import type { EditorNextProps } from '../../types/editor-props';
3
- /** Resolve initial toolbar usage without publishing editor state to shared-state consumers. */
4
- export declare const shouldUseOptimisticToolbarState: (editorAPI: ReturnType<EditorPluginInjectionAPI['api']>, props: Pick<EditorNextProps, 'appearance' | 'primaryToolbarComponents'>) => boolean;