@atlaskit/editor-core 240.0.2 → 240.1.1

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,23 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 240.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4185658461508`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4185658461508) -
8
+ Under platform_editor_ssr_toolbar_optimistic, defer early editor state creation and exposure when
9
+ the full-page toolbar is undocked or hidden, preserving docked and custom toolbar initialization.
10
+ Keep experiment evaluation consistent with mount cleanup so shared state follows the mounted
11
+ editor.
12
+ - Updated dependencies
13
+
14
+ ## 240.1.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [`87c07de9c4550`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/87c07de9c4550) -
19
+ Remove the remaining Emotion usage and dependency from editor-core.
20
+
3
21
  ## 240.0.2
4
22
 
5
23
  ### Patch Changes
@@ -0,0 +1,40 @@
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
+ };
@@ -62,6 +62,7 @@ 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");
65
66
  var _useDispatchTransaction = require("./ReactEditorView/useDispatchTransaction");
66
67
  var _useFireFullWidthEvent = require("./ReactEditorView/useFireFullWidthEvent");
67
68
  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); }
@@ -85,6 +86,7 @@ function ReactEditorView(props) {
85
86
  editorPropFeatureFlags = _props$editorProps.featureFlags,
86
87
  errorReporterHandler = _props$editorProps.errorReporterHandler,
87
88
  defaultValue = _props$editorProps.defaultValue,
89
+ primaryToolbarComponents = _props$editorProps.primaryToolbarComponents,
88
90
  shouldFocus = _props$editorProps.shouldFocus,
89
91
  onEditorCreated = props.onEditorCreated,
90
92
  onEditorDestroyed = props.onEditorDestroyed;
@@ -250,8 +252,11 @@ function ReactEditorView(props) {
250
252
  // Match SSR's start selection so the optimistic toolbar hydrates with the same block type.
251
253
  selectionAtStart: (0, _isFullPage.isFullPage)(nextAppearance) || nextAppearance === 'max' && (0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)
252
254
  });
253
- if ((0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
254
- // CSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
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.
255
260
  preMountEditorStateRef.current = state;
256
261
  }
257
262
  return state;
@@ -924,13 +929,16 @@ function ReactEditorView(props) {
924
929
  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';
925
930
  var ariaReadonly = isViewMode && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_viewmode_aria_readonly_a11y') ? 'true' : undefined;
926
931
 
927
- // When the platform_editor_ssr_toolbar_optimistic is on, we create SSR-safe PM plugins and EditorState
932
+ // When the optimistic toolbar needs initial state, create SSR-safe PM plugins and EditorState
928
933
  // HERE in ssrDeps — before any children render — so that FullPageToolbarNext can read correct
929
934
  // plugin state via useSharedPluginStateWithSelector → currentState() → getEditorState().
930
935
  //
931
936
  // We also pass these pre-built pmPlugins and editorState to EditorSSRRenderer so it can
932
937
  // skip redundant creation (avoids double createPluginsList + EditorState.create).
933
- if ((0, _expValEquals.expValEquals)('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
938
+ if ((0, _shouldUseOptimisticToolbarState.shouldUseOptimisticToolbarState)(pluginInjectionAPI.current.api(), {
939
+ appearance: nextAppearance,
940
+ primaryToolbarComponents: primaryToolbarComponents
941
+ })) {
934
942
  var ssrPMPlugins = (0, _profileSSROperation.profileSSROperation)("".concat(SSR_TRACE_SEGMENT_NAME, "/createSSRPMPlugins"), function () {
935
943
  return (0, _createSsrPmPlugins.createSSRPMPlugins)({
936
944
  plugins: plugins,
@@ -965,7 +973,7 @@ function ReactEditorView(props) {
965
973
  ssrPMPlugins: undefined,
966
974
  ssrEditorState: undefined
967
975
  };
968
- }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl]);
976
+ }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl, nextAppearance, primaryToolbarComponents]);
969
977
  // SSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
970
978
  if (ssrDeps !== null && ssrDeps !== void 0 && ssrDeps.ssrEditorState) {
971
979
  preMountEditorStateRef.current = ssrDeps.ssrEditorState;
@@ -13,16 +13,12 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
13
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
14
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
15
15
  var _react = _interopRequireDefault(require("react"));
16
- var _react2 = require("@emotion/react");
17
16
  var _composableEditor = require("./composable-editor");
18
17
  var _useUniversalPreset = _interopRequireDefault(require("./presets/useUniversalPreset"));
19
18
  var _editorDeprecationWarnings = _interopRequireDefault(require("./utils/editorDeprecationWarnings"));
20
19
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
21
20
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } // Disable no-re-export rule for entry point files
22
- /* eslint-disable @atlaskit/editor/no-re-export */ /**
23
- * @jsxRuntime classic
24
- * @jsx jsx
25
- */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
21
+ /* eslint-disable @atlaskit/editor/no-re-export */
26
22
  var ComposableEditorWrapper = function ComposableEditorWrapper(_ref) {
27
23
  var props = _ref.props,
28
24
  initialPluginConfiguration = _ref.initialPluginConfiguration;
@@ -32,7 +28,7 @@ var ComposableEditorWrapper = function ComposableEditorWrapper(_ref) {
32
28
  });
33
29
  // Ignored via go/ees005
34
30
  // eslint-disable-next-line react/jsx-props-no-spreading
35
- return (0, _react2.jsx)(_composableEditor.ComposableEditor, (0, _extends2.default)({
31
+ return /*#__PURE__*/_react.default.createElement(_composableEditor.ComposableEditor, (0, _extends2.default)({
36
32
  preset: preset
37
33
  }, props));
38
34
  };
@@ -58,7 +54,7 @@ var Editor = exports.default = /*#__PURE__*/function (_React$Component) {
58
54
  return (0, _createClass2.default)(Editor, [{
59
55
  key: "render",
60
56
  value: function render() {
61
- return (0, _react2.jsx)(ComposableEditorWrapper, {
57
+ return /*#__PURE__*/_react.default.createElement(ComposableEditorWrapper, {
62
58
  props: this.props,
63
59
  initialPluginConfiguration: this.props.initialPluginConfiguration
64
60
  });
@@ -354,7 +354,7 @@ var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerC
354
354
  /**
355
355
  * EditorContentStyles is a wrapper component that applies styles to its children
356
356
  * based on the provided feature flags, view mode, and other props.
357
- * It uses Emotion for styling and supports scrollable content.
357
+ * It uses Compiled for styling and supports scrollable content.
358
358
  *
359
359
  * This will be used in near future to replace the current editor content styles from index.tsx
360
360
  */
@@ -379,7 +379,7 @@ var EditorContentContainerCompiled = exports.EditorContentContainerCompiled = /*
379
379
 
380
380
  // Under the static-CSS experiment, --ak-editor-base-font-size is set earlier on the
381
381
  // root div in editor-internal.tsx and inherited via the CSS cascade — do not set it here.
382
- // For the legacy path, compute it from the Emotion theme as before.
382
+ // For the legacy font-size path, derive it from the editor theme.
383
383
  var style = _react.default.useMemo(function () {
384
384
  return _objectSpread(_objectSpread({
385
385
  '--ak-editor--table-overflow-shadow': tableOverflowShadow
@@ -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 = "240.0.1";
9
+ var version = exports.version = "240.1.0";
@@ -0,0 +1,35 @@
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
+ };
@@ -51,6 +51,7 @@ 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';
54
55
  import { useDispatchTransaction } from './ReactEditorView/useDispatchTransaction';
55
56
  import { useFireFullWidthEvent } from './ReactEditorView/useFireFullWidthEvent';
56
57
  const EDIT_AREA_ID = 'ak-editor-textarea';
@@ -69,6 +70,7 @@ export function ReactEditorView(props) {
69
70
  featureFlags: editorPropFeatureFlags,
70
71
  errorReporterHandler,
71
72
  defaultValue,
73
+ primaryToolbarComponents,
72
74
  shouldFocus
73
75
  },
74
76
  onEditorCreated,
@@ -225,8 +227,11 @@ export function ReactEditorView(props) {
225
227
  // Match SSR's start selection so the optimistic toolbar hydrates with the same block type.
226
228
  selectionAtStart: isFullPage(nextAppearance) || nextAppearance === 'max' && expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)
227
229
  });
228
- if (expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
229
- // CSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
230
+ if (shouldUseOptimisticToolbarState(pluginInjectionAPI.current.api(), {
231
+ appearance: nextAppearance,
232
+ primaryToolbarComponents
233
+ })) {
234
+ // Only expose state before mount when the initial toolbar needs it.
230
235
  preMountEditorStateRef.current = state;
231
236
  }
232
237
  return state;
@@ -866,13 +871,16 @@ export function ReactEditorView(props) {
866
871
  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';
867
872
  const ariaReadonly = isViewMode && isExperimentEnabled('platform_editor_viewmode_aria_readonly_a11y') ? 'true' : undefined;
868
873
 
869
- // When the platform_editor_ssr_toolbar_optimistic is on, we create SSR-safe PM plugins and EditorState
874
+ // When the optimistic toolbar needs initial state, create SSR-safe PM plugins and EditorState
870
875
  // HERE in ssrDeps — before any children render — so that FullPageToolbarNext can read correct
871
876
  // plugin state via useSharedPluginStateWithSelector → currentState() → getEditorState().
872
877
  //
873
878
  // We also pass these pre-built pmPlugins and editorState to EditorSSRRenderer so it can
874
879
  // skip redundant creation (avoids double createPluginsList + EditorState.create).
875
- if (expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
880
+ if (shouldUseOptimisticToolbarState(pluginInjectionAPI.current.api(), {
881
+ appearance: nextAppearance,
882
+ primaryToolbarComponents
883
+ })) {
876
884
  const ssrPMPlugins = profileSSROperation(`${SSR_TRACE_SEGMENT_NAME}/createSSRPMPlugins`, () => createSSRPMPlugins({
877
885
  plugins,
878
886
  schema,
@@ -901,7 +909,7 @@ export function ReactEditorView(props) {
901
909
  ssrPMPlugins: undefined,
902
910
  ssrEditorState: undefined
903
911
  };
904
- }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl]);
912
+ }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl, nextAppearance, primaryToolbarComponents]);
905
913
  // SSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
906
914
  if (ssrDeps !== null && ssrDeps !== void 0 && ssrDeps.ssrEditorState) {
907
915
  preMountEditorStateRef.current = ssrDeps.ssrEditorState;
@@ -3,14 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  // Disable no-re-export rule for entry point files
4
4
  /* eslint-disable @atlaskit/editor/no-re-export */
5
5
 
6
- /**
7
- * @jsxRuntime classic
8
- * @jsx jsx
9
- */
10
6
  import React from 'react';
11
-
12
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
13
- import { jsx } from '@emotion/react';
14
7
  import { ComposableEditor } from './composable-editor';
15
8
  import useUniversalPreset from './presets/useUniversalPreset';
16
9
  import editorDeprecationWarnings from './utils/editorDeprecationWarnings';
@@ -24,7 +17,7 @@ const ComposableEditorWrapper = ({
24
17
  });
25
18
  // Ignored via go/ees005
26
19
  // eslint-disable-next-line react/jsx-props-no-spreading
27
- return jsx(ComposableEditor, _extends({
20
+ return /*#__PURE__*/React.createElement(ComposableEditor, _extends({
28
21
  preset: preset
29
22
  }, props));
30
23
  };
@@ -44,7 +37,7 @@ export default class Editor extends React.Component {
44
37
  editorDeprecationWarnings(props);
45
38
  }
46
39
  render() {
47
- return jsx(ComposableEditorWrapper, {
40
+ return /*#__PURE__*/React.createElement(ComposableEditorWrapper, {
48
41
  props: this.props,
49
42
  initialPluginConfiguration: this.props.initialPluginConfiguration
50
43
  });
@@ -406,7 +406,7 @@ const isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowe
406
406
  /**
407
407
  * EditorContentStyles is a wrapper component that applies styles to its children
408
408
  * based on the provided feature flags, view mode, and other props.
409
- * It uses Emotion for styling and supports scrollable content.
409
+ * It uses Compiled for styling and supports scrollable content.
410
410
  *
411
411
  * This will be used in near future to replace the current editor content styles from index.tsx
412
412
  */
@@ -434,7 +434,7 @@ export const EditorContentContainerCompiled = /*#__PURE__*/React.forwardRef((pro
434
434
 
435
435
  // Under the static-CSS experiment, --ak-editor-base-font-size is set earlier on the
436
436
  // root div in editor-internal.tsx and inherited via the CSS cascade — do not set it here.
437
- // For the legacy path, compute it from the Emotion theme as before.
437
+ // For the legacy font-size path, derive it from the editor theme.
438
438
  const style = React.useMemo(() => ({
439
439
  '--ak-editor--table-overflow-shadow': tableOverflowShadow,
440
440
  ...tableCellBackgroundColorVariablesForCompiled,
@@ -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 = "240.0.1";
3
+ export const version = "240.1.0";
@@ -0,0 +1,35 @@
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
+ };
@@ -59,6 +59,7 @@ 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';
62
63
  import { useDispatchTransaction } from './ReactEditorView/useDispatchTransaction';
63
64
  import { useFireFullWidthEvent } from './ReactEditorView/useFireFullWidthEvent';
64
65
  var EDIT_AREA_ID = 'ak-editor-textarea';
@@ -76,6 +77,7 @@ export function ReactEditorView(props) {
76
77
  editorPropFeatureFlags = _props$editorProps.featureFlags,
77
78
  errorReporterHandler = _props$editorProps.errorReporterHandler,
78
79
  defaultValue = _props$editorProps.defaultValue,
80
+ primaryToolbarComponents = _props$editorProps.primaryToolbarComponents,
79
81
  shouldFocus = _props$editorProps.shouldFocus,
80
82
  onEditorCreated = props.onEditorCreated,
81
83
  onEditorDestroyed = props.onEditorDestroyed;
@@ -241,8 +243,11 @@ export function ReactEditorView(props) {
241
243
  // Match SSR's start selection so the optimistic toolbar hydrates with the same block type.
242
244
  selectionAtStart: isFullPage(nextAppearance) || nextAppearance === 'max' && expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)
243
245
  });
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
+ if (shouldUseOptimisticToolbarState(pluginInjectionAPI.current.api(), {
247
+ appearance: nextAppearance,
248
+ primaryToolbarComponents: primaryToolbarComponents
249
+ })) {
250
+ // Only expose state before mount when the initial toolbar needs it.
246
251
  preMountEditorStateRef.current = state;
247
252
  }
248
253
  return state;
@@ -915,13 +920,16 @@ export function ReactEditorView(props) {
915
920
  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';
916
921
  var ariaReadonly = isViewMode && isExperimentEnabled('platform_editor_viewmode_aria_readonly_a11y') ? 'true' : undefined;
917
922
 
918
- // When the platform_editor_ssr_toolbar_optimistic is on, we create SSR-safe PM plugins and EditorState
923
+ // When the optimistic toolbar needs initial state, create SSR-safe PM plugins and EditorState
919
924
  // HERE in ssrDeps — before any children render — so that FullPageToolbarNext can read correct
920
925
  // plugin state via useSharedPluginStateWithSelector → currentState() → getEditorState().
921
926
  //
922
927
  // We also pass these pre-built pmPlugins and editorState to EditorSSRRenderer so it can
923
928
  // skip redundant creation (avoids double createPluginsList + EditorState.create).
924
- if (expValEquals('platform_editor_ssr_toolbar_optimistic', 'isEnabled', true)) {
929
+ if (shouldUseOptimisticToolbarState(pluginInjectionAPI.current.api(), {
930
+ appearance: nextAppearance,
931
+ primaryToolbarComponents: primaryToolbarComponents
932
+ })) {
925
933
  var ssrPMPlugins = profileSSROperation("".concat(SSR_TRACE_SEGMENT_NAME, "/createSSRPMPlugins"), function () {
926
934
  return createSSRPMPlugins({
927
935
  plugins: plugins,
@@ -956,7 +964,7 @@ export function ReactEditorView(props) {
956
964
  ssrPMPlugins: undefined,
957
965
  ssrEditorState: undefined
958
966
  };
959
- }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl]);
967
+ }, [allowBlockType, buildDoc, props.preset, onSSRMeasure, props.portalProviderAPI, props.intl, nextAppearance, primaryToolbarComponents]);
960
968
  // SSR only, synchronously set preMountEditorStateRef so it's ready to be consumed by children including toolbar
961
969
  if (ssrDeps !== null && ssrDeps !== void 0 && ssrDeps.ssrEditorState) {
962
970
  preMountEditorStateRef.current = ssrDeps.ssrEditorState;
@@ -10,14 +10,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
10
10
  // Disable no-re-export rule for entry point files
11
11
  /* eslint-disable @atlaskit/editor/no-re-export */
12
12
 
13
- /**
14
- * @jsxRuntime classic
15
- * @jsx jsx
16
- */
17
13
  import React from 'react';
18
-
19
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
20
- import { jsx } from '@emotion/react';
21
14
  import { ComposableEditor } from './composable-editor';
22
15
  import useUniversalPreset from './presets/useUniversalPreset';
23
16
  import editorDeprecationWarnings from './utils/editorDeprecationWarnings';
@@ -30,7 +23,7 @@ var ComposableEditorWrapper = function ComposableEditorWrapper(_ref) {
30
23
  });
31
24
  // Ignored via go/ees005
32
25
  // eslint-disable-next-line react/jsx-props-no-spreading
33
- return jsx(ComposableEditor, _extends({
26
+ return /*#__PURE__*/React.createElement(ComposableEditor, _extends({
34
27
  preset: preset
35
28
  }, props));
36
29
  };
@@ -56,7 +49,7 @@ var Editor = /*#__PURE__*/function (_React$Component) {
56
49
  return _createClass(Editor, [{
57
50
  key: "render",
58
51
  value: function render() {
59
- return jsx(ComposableEditorWrapper, {
52
+ return /*#__PURE__*/React.createElement(ComposableEditorWrapper, {
60
53
  props: this.props,
61
54
  initialPluginConfiguration: this.props.initialPluginConfiguration
62
55
  });
@@ -9,7 +9,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
9
9
 
10
10
  // Because we migrated with using cssMapScope API for non atomic css, so these atomic css related eslint suppression no longer needs to be fixed.
11
11
  /* eslint-disable @atlaskit/platform/use-motion-token-values, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/design-system/no-invalid-css-map, @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/platform/expand-spacing-shorthand, @atlaskit/platform/expand-border-shorthand, @atlaskit/platform/expand-background-shorthand */
12
-
13
12
  import React from 'react';
14
13
  // eslint-disable-next-line import/order
15
14
  import { getBrowserInfo } from '@atlaskit/editor-common/browser';
@@ -354,7 +353,7 @@ var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerC
354
353
  /**
355
354
  * EditorContentStyles is a wrapper component that applies styles to its children
356
355
  * based on the provided feature flags, view mode, and other props.
357
- * It uses Emotion for styling and supports scrollable content.
356
+ * It uses Compiled for styling and supports scrollable content.
358
357
  *
359
358
  * This will be used in near future to replace the current editor content styles from index.tsx
360
359
  */
@@ -379,7 +378,7 @@ export var EditorContentContainerCompiled = /*#__PURE__*/React.forwardRef(functi
379
378
 
380
379
  // Under the static-CSS experiment, --ak-editor-base-font-size is set earlier on the
381
380
  // root div in editor-internal.tsx and inherited via the CSS cascade — do not set it here.
382
- // For the legacy path, compute it from the Emotion theme as before.
381
+ // For the legacy font-size path, derive it from the editor theme.
383
382
  var style = React.useMemo(function () {
384
383
  return _objectSpread(_objectSpread({
385
384
  '--ak-editor--table-overflow-shadow': tableOverflowShadow
@@ -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 = "240.0.1";
3
+ export var version = "240.1.0";
@@ -0,0 +1,4 @@
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;
@@ -1,9 +1,5 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
1
+ import type { JSX } from 'react';
5
2
  import React from 'react';
6
- import { jsx } from '@emotion/react';
7
3
  import type { InitialPluginConfiguration } from './preset-universal';
8
4
  import type { EditorProps } from './types/editor-props';
9
5
  interface EditorPropsWithInitialPluginConfiguration extends EditorProps {
@@ -19,6 +15,6 @@ interface EditorPropsWithInitialPluginConfiguration extends EditorProps {
19
15
  export default class Editor extends React.Component<EditorPropsWithInitialPluginConfiguration> {
20
16
  static defaultProps: EditorProps;
21
17
  constructor(props: EditorPropsWithInitialPluginConfiguration);
22
- render(): jsx.JSX.Element;
18
+ render(): JSX.Element;
23
19
  }
24
20
  export {};
@@ -22,7 +22,7 @@ export type EditorContentContainerProps = {
22
22
  /**
23
23
  * EditorContentStyles is a wrapper component that applies styles to its children
24
24
  * based on the provided feature flags, view mode, and other props.
25
- * It uses Emotion for styling and supports scrollable content.
25
+ * It uses Compiled for styling and supports scrollable content.
26
26
  *
27
27
  * This will be used in near future to replace the current editor content styles from index.tsx
28
28
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "240.0.2",
3
+ "version": "240.1.1",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -75,15 +75,14 @@
75
75
  "@atlaskit/popup": "^10.0.0",
76
76
  "@atlaskit/primitives": "^22.6.0",
77
77
  "@atlaskit/react-compiler-gating": "^0.2.0",
78
- "@atlaskit/react-ufo": "^8.2.0",
78
+ "@atlaskit/react-ufo": "^8.3.0",
79
79
  "@atlaskit/task-decision": "^21.13.0",
80
- "@atlaskit/tmp-editor-statsig": "^246.0.0",
81
- "@atlaskit/tokens": "^20.7.0",
80
+ "@atlaskit/tmp-editor-statsig": "^246.1.0",
81
+ "@atlaskit/tokens": "^20.8.0",
82
82
  "@atlaskit/tooltip": "^24.4.0",
83
83
  "@atlaskit/width-detector": "^7.2.0",
84
84
  "@babel/runtime": "^7.0.0",
85
85
  "@compiled/react": "^1.0.2",
86
- "@emotion/react": "^11.7.1",
87
86
  "@types/react-loadable": "^5.4.1",
88
87
  "@types/rison": "^0.0.6",
89
88
  "classnames": "^2.2.5",
@@ -117,9 +116,9 @@
117
116
  "@atlaskit/docs": "^12.3.0",
118
117
  "@atlaskit/drawer": "^14.3.0",
119
118
  "@atlaskit/editor-plugin-alignment": "^30.0.0",
120
- "@atlaskit/editor-plugin-annotation": "^29.0.0",
119
+ "@atlaskit/editor-plugin-annotation": "^29.2.0",
121
120
  "@atlaskit/editor-plugin-base": "^30.0.0",
122
- "@atlaskit/editor-plugin-card": "^35.1.0",
121
+ "@atlaskit/editor-plugin-card": "^35.2.0",
123
122
  "@atlaskit/editor-plugin-code-block-advanced": "^29.0.0",
124
123
  "@atlaskit/editor-plugin-collab-edit": "^30.0.0",
125
124
  "@atlaskit/editor-plugin-content-insertion": "^29.0.0",
@@ -176,7 +175,7 @@
176
175
  "@atlassian/a11y-jest-testing": "^0.17.0",
177
176
  "@atlassian/a11y-playwright-testing": "^0.13.0",
178
177
  "@atlassian/adf-schema-json": "^1.35.0",
179
- "@atlassian/editor-rovo-bridge": "^28.0.0",
178
+ "@atlassian/editor-rovo-bridge": "^28.2.0",
180
179
  "@atlassian/experiment-test-utils": "^0.2.0",
181
180
  "@atlassian/feature-flags-storybook-utils": "^0.5.0",
182
181
  "@atlassian/feature-flags-test-utils": "^1.3.0",
@@ -185,7 +184,6 @@
185
184
  "@atlassian/structured-docs-types": "workspace:^",
186
185
  "@atlassian/testing-library": "^0.12.0",
187
186
  "@atlassian/user-profile-card": "^1.47.0",
188
- "@emotion/jest": "^11.8.0",
189
187
  "@testing-library/react": "^16.3.0",
190
188
  "@types/diff": "^5.0.2",
191
189
  "@types/is-number": "^7.0.0",
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.inputStyle = void 0;
7
- var _react = require("@emotion/react");
8
- var _constants = require("@atlaskit/editor-shared-styles/constants");
9
- /* eslint-disable @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766 */
10
-
11
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
12
- var inputStyle = exports.inputStyle = (0, _react.css)({
13
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
14
- 'input&': {
15
- backgroundColor: "var(--ds-background-input, #FFFFFF)",
16
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
17
- border: "1px solid ".concat("var(--ds-border-input, #8C8F97)"),
18
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
19
- borderRadius: "var(--ds-radius-small, 3px)",
20
- boxSizing: 'border-box',
21
- height: '40px',
22
- paddingLeft: "var(--ds-space-250, 20px)",
23
- paddingTop: "var(--ds-space-150, 12px)",
24
- paddingBottom: "var(--ds-space-150, 12px)",
25
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
26
- fontSize: (0, _constants.relativeFontSizeToBase16)(14),
27
- width: '100%',
28
- fontWeight: "var(--ds-font-weight-regular, 400)",
29
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
30
- lineHeight: 1.42857142857143,
31
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
32
- letterSpacing: '-0.005em',
33
- color: "var(--ds-text-subtlest, #6B6E76)",
34
- '&:hover': {
35
- backgroundColor: "var(--ds-background-input-hovered, #F8F8F8)",
36
- borderColor: "var(--ds-border-input, #8C8F97)",
37
- cursor: 'text'
38
- }
39
- }
40
- });
@@ -1,34 +0,0 @@
1
- /* eslint-disable @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766 */
2
-
3
- import { css } from '@emotion/react';
4
- import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles/constants';
5
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
6
- export const inputStyle = css({
7
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
8
- 'input&': {
9
- backgroundColor: "var(--ds-background-input, #FFFFFF)",
10
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
11
- border: `1px solid ${"var(--ds-border-input, #8C8F97)"}`,
12
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
13
- borderRadius: "var(--ds-radius-small, 3px)",
14
- boxSizing: 'border-box',
15
- height: '40px',
16
- paddingLeft: "var(--ds-space-250, 20px)",
17
- paddingTop: "var(--ds-space-150, 12px)",
18
- paddingBottom: "var(--ds-space-150, 12px)",
19
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
20
- fontSize: relativeFontSizeToBase16(14),
21
- width: '100%',
22
- fontWeight: "var(--ds-font-weight-regular, 400)",
23
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
24
- lineHeight: 1.42857142857143,
25
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
26
- letterSpacing: '-0.005em',
27
- color: "var(--ds-text-subtlest, #6B6E76)",
28
- '&:hover': {
29
- backgroundColor: "var(--ds-background-input-hovered, #F8F8F8)",
30
- borderColor: "var(--ds-border-input, #8C8F97)",
31
- cursor: 'text'
32
- }
33
- }
34
- });
@@ -1,34 +0,0 @@
1
- /* eslint-disable @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766 */
2
-
3
- import { css } from '@emotion/react';
4
- import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles/constants';
5
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
6
- export var inputStyle = css({
7
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
8
- 'input&': {
9
- backgroundColor: "var(--ds-background-input, #FFFFFF)",
10
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
11
- border: "1px solid ".concat("var(--ds-border-input, #8C8F97)"),
12
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
13
- borderRadius: "var(--ds-radius-small, 3px)",
14
- boxSizing: 'border-box',
15
- height: '40px',
16
- paddingLeft: "var(--ds-space-250, 20px)",
17
- paddingTop: "var(--ds-space-150, 12px)",
18
- paddingBottom: "var(--ds-space-150, 12px)",
19
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
20
- fontSize: relativeFontSizeToBase16(14),
21
- width: '100%',
22
- fontWeight: "var(--ds-font-weight-regular, 400)",
23
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
24
- lineHeight: 1.42857142857143,
25
- // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
26
- letterSpacing: '-0.005em',
27
- color: "var(--ds-text-subtlest, #6B6E76)",
28
- '&:hover': {
29
- backgroundColor: "var(--ds-background-input-hovered, #F8F8F8)",
30
- borderColor: "var(--ds-border-input, #8C8F97)",
31
- cursor: 'text'
32
- }
33
- }
34
- });
@@ -1,2 +0,0 @@
1
- import type { SerializedStyles } from '@emotion/react';
2
- export declare const inputStyle: SerializedStyles;