@atlaskit/editor-plugin-selection-toolbar 11.1.3 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atlaskit/editor-plugin-selection-toolbar
2
2
 
3
+ ## 11.2.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
  ## 11.1.3
4
28
 
5
29
  ### Patch Changes
@@ -7,15 +7,27 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.PinButton = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactIntl = require("react-intl");
10
+ var _hooks = require("@atlaskit/editor-common/hooks");
10
11
  var _messages = require("@atlaskit/editor-common/messages");
11
12
  var _toolbar = require("@atlaskit/editor-common/toolbar");
12
13
  var _editorToolbar = require("@atlaskit/editor-toolbar");
14
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
15
  var PinButton = exports.PinButton = function PinButton(_ref) {
14
16
  var api = _ref.api;
15
17
  var intl = (0, _reactIntl.useIntl)();
16
18
  var message = intl.formatMessage(_messages.selectionToolbarMessages.toolbarPositionPinedAtTop);
17
19
  var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
18
20
  isDisabled = _useEditorToolbar.isOffline;
21
+ // Pin/unpin is meaningless when a runtime override forces `'always-pinned'`
22
+ // (e.g. Markdown Mode source / preview view). Subscribe so we re-render and
23
+ // hide ourselves on flip.
24
+ var runtimeOverride = (0, _hooks.useSharedPluginStateWithSelector)(api, ['toolbar'], function (states) {
25
+ var _states$toolbarState;
26
+ return (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.contextualFormattingModeOverride;
27
+ });
28
+ if (runtimeOverride === 'always-pinned' && (0, _platformFeatureFlags.fg)('platform_editor_toolbar_mode_override')) {
29
+ return null;
30
+ }
19
31
  var onClick = function onClick() {
20
32
  var _api$userPreferences;
21
33
  if (!api || isDisabled) {
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
2
  import { useIntl } from 'react-intl';
3
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
4
  import { selectionToolbarMessages } from '@atlaskit/editor-common/messages';
4
5
  import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
5
6
  import { PinnedIcon, ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
6
8
  export const PinButton = ({
7
9
  api
8
10
  }) => {
@@ -11,6 +13,16 @@ export const PinButton = ({
11
13
  const {
12
14
  isOffline: isDisabled
13
15
  } = useEditorToolbar();
16
+ // Pin/unpin is meaningless when a runtime override forces `'always-pinned'`
17
+ // (e.g. Markdown Mode source / preview view). Subscribe so we re-render and
18
+ // hide ourselves on flip.
19
+ const runtimeOverride = useSharedPluginStateWithSelector(api, ['toolbar'], states => {
20
+ var _states$toolbarState;
21
+ return (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.contextualFormattingModeOverride;
22
+ });
23
+ if (runtimeOverride === 'always-pinned' && fg('platform_editor_toolbar_mode_override')) {
24
+ return null;
25
+ }
14
26
  const onClick = () => {
15
27
  var _api$userPreferences;
16
28
  if (!api || isDisabled) {
@@ -1,14 +1,26 @@
1
1
  import React from 'react';
2
2
  import { useIntl } from 'react-intl';
3
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
4
  import { selectionToolbarMessages } from '@atlaskit/editor-common/messages';
4
5
  import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
5
6
  import { PinnedIcon, ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
6
8
  export var PinButton = function PinButton(_ref) {
7
9
  var api = _ref.api;
8
10
  var intl = useIntl();
9
11
  var message = intl.formatMessage(selectionToolbarMessages.toolbarPositionPinedAtTop);
10
12
  var _useEditorToolbar = useEditorToolbar(),
11
13
  isDisabled = _useEditorToolbar.isOffline;
14
+ // Pin/unpin is meaningless when a runtime override forces `'always-pinned'`
15
+ // (e.g. Markdown Mode source / preview view). Subscribe so we re-render and
16
+ // hide ourselves on flip.
17
+ var runtimeOverride = useSharedPluginStateWithSelector(api, ['toolbar'], function (states) {
18
+ var _states$toolbarState;
19
+ return (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.contextualFormattingModeOverride;
20
+ });
21
+ if (runtimeOverride === 'always-pinned' && fg('platform_editor_toolbar_mode_override')) {
22
+ return null;
23
+ }
12
24
  var onClick = function onClick() {
13
25
  var _api$userPreferences;
14
26
  if (!api || isDisabled) {
@@ -3,4 +3,4 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
4
4
  export declare const PinButton: ({ api, }: {
5
5
  api?: ExtractInjectionAPI<SelectionToolbarPlugin>;
6
- }) => React.JSX.Element;
6
+ }) => React.JSX.Element | null;
@@ -3,4 +3,4 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
4
4
  export declare const PinButton: ({ api, }: {
5
5
  api?: ExtractInjectionAPI<SelectionToolbarPlugin>;
6
- }) => React.JSX.Element;
6
+ }) => React.JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-toolbar",
3
- "version": "11.1.3",
3
+ "version": "11.2.0",
4
4
  "description": "@atlaskit/editor-plugin-selection-toolbar for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  "@atlaskit/editor-plugin-connectivity": "^10.0.0",
36
36
  "@atlaskit/editor-plugin-editor-viewmode": "^12.0.0",
37
37
  "@atlaskit/editor-plugin-primary-toolbar": "^11.0.0",
38
- "@atlaskit/editor-plugin-toolbar": "^7.0.0",
38
+ "@atlaskit/editor-plugin-toolbar": "^7.1.0",
39
39
  "@atlaskit/editor-plugin-user-intent": "^8.1.0",
40
40
  "@atlaskit/editor-plugin-user-preferences": "^8.1.0",
41
41
  "@atlaskit/editor-prosemirror": "^7.3.0",
@@ -45,13 +45,13 @@
45
45
  "@atlaskit/icon-lab": "^6.7.0",
46
46
  "@atlaskit/menu": "^8.5.0",
47
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
48
- "@atlaskit/tmp-editor-statsig": "^77.0.0",
48
+ "@atlaskit/tmp-editor-statsig": "^77.3.0",
49
49
  "@atlaskit/tokens": "^13.0.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "bind-event-listener": "^3.0.0"
52
52
  },
53
53
  "peerDependencies": {
54
- "@atlaskit/editor-common": "^114.20.0",
54
+ "@atlaskit/editor-common": "^114.26.0",
55
55
  "react": "^18.2.0",
56
56
  "react-dom": "^18.2.0",
57
57
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -95,6 +95,9 @@
95
95
  }
96
96
  },
97
97
  "platform-feature-flags": {
98
+ "platform_editor_toolbar_mode_override": {
99
+ "type": "boolean"
100
+ },
98
101
  "platform_editor_user_preferences_provider_update": {
99
102
  "type": "boolean"
100
103
  },