@atlaskit/editor-core 240.1.0 → 241.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/create-editor/ReactEditorView/shouldUseOptimisticToolbarState.js +40 -0
- package/dist/cjs/create-editor/ReactEditorView.js +13 -5
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/ReactEditorView/shouldUseOptimisticToolbarState.js +35 -0
- package/dist/es2019/create-editor/ReactEditorView.js +13 -5
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/ReactEditorView/shouldUseOptimisticToolbarState.js +35 -0
- package/dist/esm/create-editor/ReactEditorView.js +13 -5
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/ReactEditorView/shouldUseOptimisticToolbarState.d.ts +4 -0
- package/package.json +48 -48
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 241.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 240.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`4185658461508`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4185658461508) -
|
|
14
|
+
Under platform_editor_ssr_toolbar_optimistic, defer early editor state creation and exposure when
|
|
15
|
+
the full-page toolbar is undocked or hidden, preserving docked and custom toolbar initialization.
|
|
16
|
+
Keep experiment evaluation consistent with mount cleanup so shared state follows the mounted
|
|
17
|
+
editor.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 240.1.0
|
|
4
21
|
|
|
5
22
|
### Minor 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,
|
|
254
|
-
|
|
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
|
|
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,
|
|
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;
|
|
@@ -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.
|
|
9
|
+
var version = exports.version = "240.1.1";
|
|
@@ -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 (
|
|
229
|
-
|
|
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
|
|
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 (
|
|
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;
|
|
@@ -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 (
|
|
245
|
-
|
|
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
|
|
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 (
|
|
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;
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "241.0.0",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -50,15 +50,15 @@
|
|
|
50
50
|
"@atlaskit/button": "^25.6.0",
|
|
51
51
|
"@atlaskit/css": "^1.1.0",
|
|
52
52
|
"@atlaskit/editor-json-transformer": "^10.0.0",
|
|
53
|
-
"@atlaskit/editor-plugin-block-menu": "^
|
|
54
|
-
"@atlaskit/editor-plugin-connectivity": "^
|
|
55
|
-
"@atlaskit/editor-plugin-quick-insert": "^
|
|
56
|
-
"@atlaskit/editor-plugin-selection-extension": "^
|
|
57
|
-
"@atlaskit/editor-plugin-user-preferences": "^
|
|
53
|
+
"@atlaskit/editor-plugin-block-menu": "^29.0.0",
|
|
54
|
+
"@atlaskit/editor-plugin-connectivity": "^30.0.0",
|
|
55
|
+
"@atlaskit/editor-plugin-quick-insert": "^30.0.0",
|
|
56
|
+
"@atlaskit/editor-plugin-selection-extension": "^33.0.0",
|
|
57
|
+
"@atlaskit/editor-plugin-user-preferences": "^28.0.0",
|
|
58
58
|
"@atlaskit/editor-plugins": "^16.2.0",
|
|
59
59
|
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
60
60
|
"@atlaskit/editor-shared-styles": "^4.6.0",
|
|
61
|
-
"@atlaskit/editor-ssr-renderer": "^
|
|
61
|
+
"@atlaskit/editor-ssr-renderer": "^25.0.0",
|
|
62
62
|
"@atlaskit/editor-toolbar": "^2.8.0",
|
|
63
63
|
"@atlaskit/editor-toolbar-model": "^1.2.0",
|
|
64
64
|
"@atlaskit/emoji": "^73.1.0",
|
|
@@ -75,10 +75,10 @@
|
|
|
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.
|
|
78
|
+
"@atlaskit/react-ufo": "^8.3.0",
|
|
79
79
|
"@atlaskit/task-decision": "^21.13.0",
|
|
80
|
-
"@atlaskit/tmp-editor-statsig": "^246.
|
|
81
|
-
"@atlaskit/tokens": "^20.
|
|
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",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"uuid": "^11.1.1"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
|
-
"@atlaskit/editor-common": "^
|
|
98
|
+
"@atlaskit/editor-common": "^134.0.0",
|
|
99
99
|
"@atlaskit/link-provider": "^6.0.0",
|
|
100
100
|
"@atlaskit/media-core": "^39.0.0",
|
|
101
101
|
"react": "^18.2.0 || ^19.2.0",
|
|
@@ -112,44 +112,44 @@
|
|
|
112
112
|
"@atlaskit/analytics-gas-types": "^6.2.0",
|
|
113
113
|
"@atlaskit/analytics-listeners": "^11.4.0",
|
|
114
114
|
"@atlaskit/code": "^20.0.0",
|
|
115
|
-
"@atlaskit/collab-provider": "^
|
|
115
|
+
"@atlaskit/collab-provider": "^39.0.0",
|
|
116
116
|
"@atlaskit/docs": "^12.3.0",
|
|
117
117
|
"@atlaskit/drawer": "^14.3.0",
|
|
118
|
-
"@atlaskit/editor-plugin-alignment": "^
|
|
119
|
-
"@atlaskit/editor-plugin-annotation": "^
|
|
120
|
-
"@atlaskit/editor-plugin-base": "^
|
|
121
|
-
"@atlaskit/editor-plugin-card": "^
|
|
122
|
-
"@atlaskit/editor-plugin-code-block-advanced": "^
|
|
123
|
-
"@atlaskit/editor-plugin-collab-edit": "^
|
|
124
|
-
"@atlaskit/editor-plugin-content-insertion": "^
|
|
125
|
-
"@atlaskit/editor-plugin-editor-viewmode": "^
|
|
126
|
-
"@atlaskit/editor-plugin-extension": "^
|
|
127
|
-
"@atlaskit/editor-plugin-grid": "^
|
|
128
|
-
"@atlaskit/editor-plugin-guideline": "^
|
|
129
|
-
"@atlaskit/editor-plugin-highlight": "^
|
|
130
|
-
"@atlaskit/editor-plugin-hyperlink": "^
|
|
131
|
-
"@atlaskit/editor-plugin-insert-block": "^
|
|
132
|
-
"@atlaskit/editor-plugin-layout": "^
|
|
133
|
-
"@atlaskit/editor-plugin-limited-mode": "^
|
|
134
|
-
"@atlaskit/editor-plugin-list": "^
|
|
135
|
-
"@atlaskit/editor-plugin-media": "^
|
|
136
|
-
"@atlaskit/editor-plugin-media-insert": "^
|
|
137
|
-
"@atlaskit/editor-plugin-paste": "^
|
|
138
|
-
"@atlaskit/editor-plugin-selection-marker": "^
|
|
139
|
-
"@atlaskit/editor-plugin-show-diff": "^
|
|
140
|
-
"@atlaskit/editor-plugin-synced-block": "^
|
|
141
|
-
"@atlaskit/editor-plugin-table": "^
|
|
142
|
-
"@atlaskit/editor-plugin-tasks-and-decisions": "^
|
|
143
|
-
"@atlaskit/editor-plugin-text-color": "^
|
|
144
|
-
"@atlaskit/editor-plugin-text-formatting": "^
|
|
145
|
-
"@atlaskit/editor-plugin-toolbar": "^
|
|
146
|
-
"@atlaskit/editor-plugin-toolbar-lists-indentation": "^
|
|
147
|
-
"@atlaskit/editor-plugin-track-changes": "^
|
|
148
|
-
"@atlaskit/editor-synced-block-provider": "^
|
|
149
|
-
"@atlaskit/editor-synced-block-renderer": "^
|
|
118
|
+
"@atlaskit/editor-plugin-alignment": "^31.0.0",
|
|
119
|
+
"@atlaskit/editor-plugin-annotation": "^30.0.0",
|
|
120
|
+
"@atlaskit/editor-plugin-base": "^31.0.0",
|
|
121
|
+
"@atlaskit/editor-plugin-card": "^36.0.0",
|
|
122
|
+
"@atlaskit/editor-plugin-code-block-advanced": "^30.0.0",
|
|
123
|
+
"@atlaskit/editor-plugin-collab-edit": "^31.0.0",
|
|
124
|
+
"@atlaskit/editor-plugin-content-insertion": "^30.0.0",
|
|
125
|
+
"@atlaskit/editor-plugin-editor-viewmode": "^32.0.0",
|
|
126
|
+
"@atlaskit/editor-plugin-extension": "^33.0.0",
|
|
127
|
+
"@atlaskit/editor-plugin-grid": "^30.0.0",
|
|
128
|
+
"@atlaskit/editor-plugin-guideline": "^30.0.0",
|
|
129
|
+
"@atlaskit/editor-plugin-highlight": "^30.0.0",
|
|
130
|
+
"@atlaskit/editor-plugin-hyperlink": "^32.0.0",
|
|
131
|
+
"@atlaskit/editor-plugin-insert-block": "^31.0.0",
|
|
132
|
+
"@atlaskit/editor-plugin-layout": "^31.0.0",
|
|
133
|
+
"@atlaskit/editor-plugin-limited-mode": "^27.0.0",
|
|
134
|
+
"@atlaskit/editor-plugin-list": "^32.0.0",
|
|
135
|
+
"@atlaskit/editor-plugin-media": "^32.0.0",
|
|
136
|
+
"@atlaskit/editor-plugin-media-insert": "^48.0.0",
|
|
137
|
+
"@atlaskit/editor-plugin-paste": "^31.0.0",
|
|
138
|
+
"@atlaskit/editor-plugin-selection-marker": "^30.0.0",
|
|
139
|
+
"@atlaskit/editor-plugin-show-diff": "^28.0.0",
|
|
140
|
+
"@atlaskit/editor-plugin-synced-block": "^28.0.0",
|
|
141
|
+
"@atlaskit/editor-plugin-table": "^42.0.0",
|
|
142
|
+
"@atlaskit/editor-plugin-tasks-and-decisions": "^33.0.0",
|
|
143
|
+
"@atlaskit/editor-plugin-text-color": "^30.0.0",
|
|
144
|
+
"@atlaskit/editor-plugin-text-formatting": "^30.0.0",
|
|
145
|
+
"@atlaskit/editor-plugin-toolbar": "^27.0.0",
|
|
146
|
+
"@atlaskit/editor-plugin-toolbar-lists-indentation": "^31.0.0",
|
|
147
|
+
"@atlaskit/editor-plugin-track-changes": "^29.0.0",
|
|
148
|
+
"@atlaskit/editor-synced-block-provider": "^26.0.0",
|
|
149
|
+
"@atlaskit/editor-synced-block-renderer": "^28.0.0",
|
|
150
150
|
"@atlaskit/editor-tables": "^3.2.0",
|
|
151
151
|
"@atlaskit/editor-test-helpers": "workspace:^",
|
|
152
|
-
"@atlaskit/form": "^18.
|
|
152
|
+
"@atlaskit/form": "^18.3.0",
|
|
153
153
|
"@atlaskit/link-provider": "^6.0.0",
|
|
154
154
|
"@atlaskit/linking-common": "^13.0.0",
|
|
155
155
|
"@atlaskit/logo": "^23.3.0",
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
"@atlaskit/portal": "^7.1.0",
|
|
165
165
|
"@atlaskit/profilecard": "^27.3.0",
|
|
166
166
|
"@atlaskit/radio": "^10.2.0",
|
|
167
|
-
"@atlaskit/renderer": "^
|
|
167
|
+
"@atlaskit/renderer": "^153.0.0",
|
|
168
168
|
"@atlaskit/section-message": "^10.2.0",
|
|
169
169
|
"@atlaskit/spinner": "^20.4.0",
|
|
170
170
|
"@atlaskit/synchrony-test-helpers": "workspace:^",
|
|
@@ -175,12 +175,12 @@
|
|
|
175
175
|
"@atlassian/a11y-jest-testing": "^0.17.0",
|
|
176
176
|
"@atlassian/a11y-playwright-testing": "^0.13.0",
|
|
177
177
|
"@atlassian/adf-schema-json": "^1.35.0",
|
|
178
|
-
"@atlassian/editor-rovo-bridge": "^
|
|
178
|
+
"@atlassian/editor-rovo-bridge": "^29.0.0",
|
|
179
179
|
"@atlassian/experiment-test-utils": "^0.2.0",
|
|
180
180
|
"@atlassian/feature-flags-storybook-utils": "^0.5.0",
|
|
181
181
|
"@atlassian/feature-flags-test-utils": "^1.3.0",
|
|
182
182
|
"@atlassian/search-client": "^3.9.0",
|
|
183
|
-
"@atlassian/search-provider": "^
|
|
183
|
+
"@atlassian/search-provider": "^31.0.0",
|
|
184
184
|
"@atlassian/structured-docs-types": "workspace:^",
|
|
185
185
|
"@atlassian/testing-library": "^0.12.0",
|
|
186
186
|
"@atlassian/user-profile-card": "^1.47.0",
|