@atlaskit/editor-core 219.4.1 → 219.5.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,29 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 219.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`5184c3aa86e89`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5184c3aa86e89) -
8
+ Pin the primary toolbar to the top while in Markdown Mode source or preview view, where the
9
+ floating toolbar would be useless (no PM selection to anchor to). Behind the new
10
+ `platform_editor_toolbar_mode_override` feature gate.
11
+ - `editor-plugin-toolbar`: adds `commands.setContextualFormattingModeOverride` and a
12
+ `contextualFormattingModeOverride` field on shared state. Any plugin can compose the command
13
+ onto its own transaction to push a runtime override.
14
+ - `editor-plugin-markdown-mode`: pushes the override on `setView` and on initial mount; uses the
15
+ current view to short-circuit `useIsToolbarDockedToTop` so the in-toolbar toggle renders in the
16
+ correct slot.
17
+ - `editor-plugin-selection-toolbar`: `PinButton` hides when the override forces `'always-pinned'`
18
+ (the toggle is meaningless in that state).
19
+ - `editor-core` (`FullPage.tsx`, `FullPageToolbarNext.tsx`): the primary-toolbar mount gate
20
+ consults the runtime override so the toolbar still mounts when the override is
21
+ `'always-pinned'`, even if the user's docking preference is `'none'`.
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies
26
+
3
27
  ## 219.4.1
4
28
 
5
29
  ### Patch Changes
@@ -80,14 +80,20 @@ var FullPageEditor = exports.FullPageEditor = function FullPageEditor(props) {
80
80
  var scrollContentContainerRef = (0, _react.useRef)(null);
81
81
  var showKeyline = useShowKeyline(scrollContentContainerRef);
82
82
  var editorAPI = props.editorAPI;
83
- var state = (0, _hooks.useSharedPluginStateWithSelector)(editorAPI, ['primaryToolbar', 'interaction', 'editorViewMode'], function (states) {
84
- var _states$primaryToolba, _states$interactionSt, _states$editorViewMod;
83
+ var state = (0, _hooks.useSharedPluginStateWithSelector)(editorAPI, ['primaryToolbar', 'interaction', 'editorViewMode', 'toolbar'], function (states) {
84
+ var _states$primaryToolba, _states$interactionSt, _states$editorViewMod, _states$toolbarState;
85
85
  return {
86
86
  primaryToolbarComponents: (_states$primaryToolba = states.primaryToolbarState) === null || _states$primaryToolba === void 0 ? void 0 : _states$primaryToolba.components,
87
87
  interactionState: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState,
88
- editorViewMode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
88
+ editorViewMode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode,
89
+ contextualFormattingModeOverride: (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.contextualFormattingModeOverride
89
90
  };
90
91
  });
92
+ // Markdown Mode forces `'always-pinned'` while in source / preview view
93
+ // (no PM selection to anchor a floating toolbar to). The user's docking
94
+ // pref alone is not enough to decide whether to mount the primary toolbar
95
+ // in that case — the override has to short-circuit the hide gate below.
96
+ var forcePrimaryToolbarPinned = state.contextualFormattingModeOverride === 'always-pinned' && (0, _platformFeatureFlags.fg)('platform_editor_toolbar_mode_override');
91
97
  var interactionState = state.interactionState;
92
98
  var primaryToolbarState = (0, _getPrimaryToolbarComponents.getPrimaryToolbarComponents)(editorAPI, state.primaryToolbarComponents);
93
99
  var hasHadInteraction = interactionState !== 'hasNotHadInteraction';
@@ -130,14 +136,14 @@ var FullPageEditor = exports.FullPageEditor = function FullPageEditor(props) {
130
136
  })) {
131
137
  if ((0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin')) {
132
138
  // need to check if the toolbarDockingPosition is set to 'none' or 'top'
133
- if (toolbarDockingPosition === 'none') {
139
+ if (toolbarDockingPosition === 'none' && !forcePrimaryToolbarPinned) {
134
140
  primaryToolbarComponents = [];
135
141
  if (!hasCustomComponents(customPrimaryToolbarComponents)) {
136
142
  isEditorToolbarHidden = true;
137
143
  }
138
144
  }
139
145
  } else {
140
- if (toolbarDocking === 'none') {
146
+ if (toolbarDocking === 'none' && !forcePrimaryToolbarPinned) {
141
147
  primaryToolbarComponents = [];
142
148
  if (!hasCustomComponents(customPrimaryToolbarComponents)) {
143
149
  isEditorToolbarHidden = true;
@@ -13,8 +13,10 @@ var _react = _interopRequireWildcard(require("react"));
13
13
  var _reactIntl = require("react-intl");
14
14
  var _contextPanel = require("@atlaskit/editor-common/context-panel");
15
15
  var _coreUtils = require("@atlaskit/editor-common/core-utils");
16
+ var _hooks = require("@atlaskit/editor-common/hooks");
16
17
  var _toolbar = require("@atlaskit/editor-common/toolbar");
17
18
  var _uiMenu = require("@atlaskit/editor-common/ui-menu");
19
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
20
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
19
21
  var _toolbar2 = require("../../../utils/toolbar");
20
22
  var _ExcludeFromHydration = _interopRequireDefault(require("../../ExcludeFromHydration"));
@@ -84,7 +86,12 @@ var FullPageToolbarNext = exports.FullPageToolbarNext = function FullPageToolbar
84
86
  customPrimaryToolbarComponents = _ref4.customPrimaryToolbarComponents,
85
87
  disabled = _ref4.disabled;
86
88
  var components = editorAPI === null || editorAPI === void 0 || (_editorAPI$toolbar = editorAPI.toolbar) === null || _editorAPI$toolbar === void 0 ? void 0 : _editorAPI$toolbar.actions.getComponents();
87
- var contextualFormattingEnabled = editorAPI === null || editorAPI === void 0 || (_editorAPI$toolbar2 = editorAPI.toolbar) === null || _editorAPI$toolbar2 === void 0 ? void 0 : _editorAPI$toolbar2.actions.contextualFormattingMode();
89
+ var runtimeOverride = (0, _hooks.useSharedPluginStateWithSelector)(editorAPI, ['toolbar'], function (states) {
90
+ var _states$toolbarState;
91
+ return (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.contextualFormattingModeOverride;
92
+ });
93
+ var effectiveRuntimeOverride = runtimeOverride !== undefined && (0, _platformFeatureFlags.fg)('platform_editor_toolbar_mode_override') ? runtimeOverride : undefined;
94
+ var contextualFormattingEnabled = effectiveRuntimeOverride !== null && effectiveRuntimeOverride !== void 0 ? effectiveRuntimeOverride : editorAPI === null || editorAPI === void 0 || (_editorAPI$toolbar2 = editorAPI.toolbar) === null || _editorAPI$toolbar2 === void 0 ? void 0 : _editorAPI$toolbar2.actions.contextualFormattingMode();
88
95
  var intl = (0, _reactIntl.useIntl)();
89
96
  var toolbar = components === null || components === void 0 ? void 0 : components.find(function (component) {
90
97
  return component.key === _toolbar.TOOLBARS.PRIMARY_TOOLBAR;
@@ -5,4 +5,4 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/editor-core";
8
- var version = exports.version = "219.4.0";
8
+ var version = exports.version = "219.4.1";
@@ -62,14 +62,20 @@ export const FullPageEditor = props => {
62
62
  const scrollContentContainerRef = useRef(null);
63
63
  const showKeyline = useShowKeyline(scrollContentContainerRef);
64
64
  const editorAPI = props.editorAPI;
65
- const state = useSharedPluginStateWithSelector(editorAPI, ['primaryToolbar', 'interaction', 'editorViewMode'], states => {
66
- var _states$primaryToolba, _states$interactionSt, _states$editorViewMod;
65
+ const state = useSharedPluginStateWithSelector(editorAPI, ['primaryToolbar', 'interaction', 'editorViewMode', 'toolbar'], states => {
66
+ var _states$primaryToolba, _states$interactionSt, _states$editorViewMod, _states$toolbarState;
67
67
  return {
68
68
  primaryToolbarComponents: (_states$primaryToolba = states.primaryToolbarState) === null || _states$primaryToolba === void 0 ? void 0 : _states$primaryToolba.components,
69
69
  interactionState: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState,
70
- editorViewMode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
70
+ editorViewMode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode,
71
+ contextualFormattingModeOverride: (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.contextualFormattingModeOverride
71
72
  };
72
73
  });
74
+ // Markdown Mode forces `'always-pinned'` while in source / preview view
75
+ // (no PM selection to anchor a floating toolbar to). The user's docking
76
+ // pref alone is not enough to decide whether to mount the primary toolbar
77
+ // in that case — the override has to short-circuit the hide gate below.
78
+ const forcePrimaryToolbarPinned = state.contextualFormattingModeOverride === 'always-pinned' && fg('platform_editor_toolbar_mode_override');
73
79
  const interactionState = state.interactionState;
74
80
  const primaryToolbarState = getPrimaryToolbarComponents(editorAPI, state.primaryToolbarComponents);
75
81
  const hasHadInteraction = interactionState !== 'hasNotHadInteraction';
@@ -115,14 +121,14 @@ export const FullPageEditor = props => {
115
121
  })) {
116
122
  if (fg('platform_editor_use_preferences_plugin')) {
117
123
  // need to check if the toolbarDockingPosition is set to 'none' or 'top'
118
- if (toolbarDockingPosition === 'none') {
124
+ if (toolbarDockingPosition === 'none' && !forcePrimaryToolbarPinned) {
119
125
  primaryToolbarComponents = [];
120
126
  if (!hasCustomComponents(customPrimaryToolbarComponents)) {
121
127
  isEditorToolbarHidden = true;
122
128
  }
123
129
  }
124
130
  } else {
125
- if (toolbarDocking === 'none') {
131
+ if (toolbarDocking === 'none' && !forcePrimaryToolbarPinned) {
126
132
  primaryToolbarComponents = [];
127
133
  if (!hasCustomComponents(customPrimaryToolbarComponents)) {
128
134
  isEditorToolbarHidden = true;
@@ -5,8 +5,10 @@ import React, { useCallback } from 'react';
5
5
  import { useIntl } from 'react-intl';
6
6
  import { ContextPanelConsumer } from '@atlaskit/editor-common/context-panel';
7
7
  import { isSSR } from '@atlaskit/editor-common/core-utils';
8
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
8
9
  import { shouldShowPrimaryToolbar, TOOLBARS } from '@atlaskit/editor-common/toolbar';
9
10
  import { ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
10
12
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
13
  import { isToolbar } from '../../../utils/toolbar';
12
14
  import ExcludeFromHydration from '../../ExcludeFromHydration';
@@ -79,7 +81,12 @@ export const FullPageToolbarNext = ({
79
81
  }) => {
80
82
  var _editorAPI$toolbar, _editorAPI$toolbar2, _useToolbarPortal;
81
83
  const components = editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$toolbar = editorAPI.toolbar) === null || _editorAPI$toolbar === void 0 ? void 0 : _editorAPI$toolbar.actions.getComponents();
82
- const contextualFormattingEnabled = editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$toolbar2 = editorAPI.toolbar) === null || _editorAPI$toolbar2 === void 0 ? void 0 : _editorAPI$toolbar2.actions.contextualFormattingMode();
84
+ const runtimeOverride = useSharedPluginStateWithSelector(editorAPI, ['toolbar'], states => {
85
+ var _states$toolbarState;
86
+ return (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.contextualFormattingModeOverride;
87
+ });
88
+ const effectiveRuntimeOverride = runtimeOverride !== undefined && fg('platform_editor_toolbar_mode_override') ? runtimeOverride : undefined;
89
+ const contextualFormattingEnabled = effectiveRuntimeOverride !== null && effectiveRuntimeOverride !== void 0 ? effectiveRuntimeOverride : editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$toolbar2 = editorAPI.toolbar) === null || _editorAPI$toolbar2 === void 0 ? void 0 : _editorAPI$toolbar2.actions.contextualFormattingMode();
83
90
  const intl = useIntl();
84
91
  const toolbar = components === null || components === void 0 ? void 0 : components.find(component => component.key === TOOLBARS.PRIMARY_TOOLBAR);
85
92
  const primaryToolbarDockingConfigEnabled = shouldShowPrimaryToolbar(contextualFormattingEnabled, toolbarDockingPosition);
@@ -1,2 +1,2 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "219.4.0";
2
+ export const version = "219.4.1";
@@ -70,14 +70,20 @@ export var FullPageEditor = function FullPageEditor(props) {
70
70
  var scrollContentContainerRef = useRef(null);
71
71
  var showKeyline = useShowKeyline(scrollContentContainerRef);
72
72
  var editorAPI = props.editorAPI;
73
- var state = useSharedPluginStateWithSelector(editorAPI, ['primaryToolbar', 'interaction', 'editorViewMode'], function (states) {
74
- var _states$primaryToolba, _states$interactionSt, _states$editorViewMod;
73
+ var state = useSharedPluginStateWithSelector(editorAPI, ['primaryToolbar', 'interaction', 'editorViewMode', 'toolbar'], function (states) {
74
+ var _states$primaryToolba, _states$interactionSt, _states$editorViewMod, _states$toolbarState;
75
75
  return {
76
76
  primaryToolbarComponents: (_states$primaryToolba = states.primaryToolbarState) === null || _states$primaryToolba === void 0 ? void 0 : _states$primaryToolba.components,
77
77
  interactionState: (_states$interactionSt = states.interactionState) === null || _states$interactionSt === void 0 ? void 0 : _states$interactionSt.interactionState,
78
- editorViewMode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode
78
+ editorViewMode: (_states$editorViewMod = states.editorViewModeState) === null || _states$editorViewMod === void 0 ? void 0 : _states$editorViewMod.mode,
79
+ contextualFormattingModeOverride: (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.contextualFormattingModeOverride
79
80
  };
80
81
  });
82
+ // Markdown Mode forces `'always-pinned'` while in source / preview view
83
+ // (no PM selection to anchor a floating toolbar to). The user's docking
84
+ // pref alone is not enough to decide whether to mount the primary toolbar
85
+ // in that case — the override has to short-circuit the hide gate below.
86
+ var forcePrimaryToolbarPinned = state.contextualFormattingModeOverride === 'always-pinned' && fg('platform_editor_toolbar_mode_override');
81
87
  var interactionState = state.interactionState;
82
88
  var primaryToolbarState = getPrimaryToolbarComponents(editorAPI, state.primaryToolbarComponents);
83
89
  var hasHadInteraction = interactionState !== 'hasNotHadInteraction';
@@ -120,14 +126,14 @@ export var FullPageEditor = function FullPageEditor(props) {
120
126
  })) {
121
127
  if (fg('platform_editor_use_preferences_plugin')) {
122
128
  // need to check if the toolbarDockingPosition is set to 'none' or 'top'
123
- if (toolbarDockingPosition === 'none') {
129
+ if (toolbarDockingPosition === 'none' && !forcePrimaryToolbarPinned) {
124
130
  primaryToolbarComponents = [];
125
131
  if (!hasCustomComponents(customPrimaryToolbarComponents)) {
126
132
  isEditorToolbarHidden = true;
127
133
  }
128
134
  }
129
135
  } else {
130
- if (toolbarDocking === 'none') {
136
+ if (toolbarDocking === 'none' && !forcePrimaryToolbarPinned) {
131
137
  primaryToolbarComponents = [];
132
138
  if (!hasCustomComponents(customPrimaryToolbarComponents)) {
133
139
  isEditorToolbarHidden = true;
@@ -5,8 +5,10 @@ import React, { useCallback } from 'react';
5
5
  import { useIntl } from 'react-intl';
6
6
  import { ContextPanelConsumer } from '@atlaskit/editor-common/context-panel';
7
7
  import { isSSR } from '@atlaskit/editor-common/core-utils';
8
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
8
9
  import { shouldShowPrimaryToolbar, TOOLBARS } from '@atlaskit/editor-common/toolbar';
9
10
  import { ToolbarArrowKeyNavigationProvider } from '@atlaskit/editor-common/ui-menu';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
10
12
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
13
  import { isToolbar } from '../../../utils/toolbar';
12
14
  import ExcludeFromHydration from '../../ExcludeFromHydration';
@@ -75,7 +77,12 @@ export var FullPageToolbarNext = function FullPageToolbarNext(_ref4) {
75
77
  customPrimaryToolbarComponents = _ref4.customPrimaryToolbarComponents,
76
78
  disabled = _ref4.disabled;
77
79
  var components = editorAPI === null || editorAPI === void 0 || (_editorAPI$toolbar = editorAPI.toolbar) === null || _editorAPI$toolbar === void 0 ? void 0 : _editorAPI$toolbar.actions.getComponents();
78
- var contextualFormattingEnabled = editorAPI === null || editorAPI === void 0 || (_editorAPI$toolbar2 = editorAPI.toolbar) === null || _editorAPI$toolbar2 === void 0 ? void 0 : _editorAPI$toolbar2.actions.contextualFormattingMode();
80
+ var runtimeOverride = useSharedPluginStateWithSelector(editorAPI, ['toolbar'], function (states) {
81
+ var _states$toolbarState;
82
+ return (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.contextualFormattingModeOverride;
83
+ });
84
+ var effectiveRuntimeOverride = runtimeOverride !== undefined && fg('platform_editor_toolbar_mode_override') ? runtimeOverride : undefined;
85
+ var contextualFormattingEnabled = effectiveRuntimeOverride !== null && effectiveRuntimeOverride !== void 0 ? effectiveRuntimeOverride : editorAPI === null || editorAPI === void 0 || (_editorAPI$toolbar2 = editorAPI.toolbar) === null || _editorAPI$toolbar2 === void 0 ? void 0 : _editorAPI$toolbar2.actions.contextualFormattingMode();
79
86
  var intl = useIntl();
80
87
  var toolbar = components === null || components === void 0 ? void 0 : components.find(function (component) {
81
88
  return component.key === TOOLBARS.PRIMARY_TOOLBAR;
@@ -1,2 +1,2 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "219.4.0";
2
+ export var version = "219.4.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "219.4.1",
3
+ "version": "219.5.0",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -74,7 +74,7 @@
74
74
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
75
75
  "@atlaskit/react-ufo": "^5.19.0",
76
76
  "@atlaskit/task-decision": "^20.0.0",
77
- "@atlaskit/tmp-editor-statsig": "^77.2.0",
77
+ "@atlaskit/tmp-editor-statsig": "^77.3.0",
78
78
  "@atlaskit/tokens": "^13.0.0",
79
79
  "@atlaskit/tooltip": "^22.0.0",
80
80
  "@atlaskit/width-detector": "^5.1.0",
@@ -92,7 +92,7 @@
92
92
  "uuid": "^3.1.0"
93
93
  },
94
94
  "peerDependencies": {
95
- "@atlaskit/editor-common": "^114.25.0",
95
+ "@atlaskit/editor-common": "^114.26.0",
96
96
  "@atlaskit/link-provider": "^4.4.0",
97
97
  "@atlaskit/media-core": "^37.0.0",
98
98
  "react": "^18.2.0",
@@ -182,6 +182,9 @@
182
182
  "type": "boolean",
183
183
  "referenceOnly": true
184
184
  },
185
+ "platform_editor_toolbar_mode_override": {
186
+ "type": "boolean"
187
+ },
185
188
  "platform_editor_toolbar_responsive_fixes": {
186
189
  "type": "boolean"
187
190
  },