@atlaskit/editor-plugin-selection-toolbar 9.0.15 → 9.1.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,12 @@
1
1
  # @atlaskit/editor-plugin-selection-toolbar
2
2
 
3
+ ## 9.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`87752e143e30f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/87752e143e30f) -
8
+ PGXT-9997 introduce an option to disable the pin option in the selection toolbar
9
+
3
10
  ## 9.0.15
4
11
 
5
12
  ### Patch Changes
@@ -43,7 +43,8 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
43
43
  var primaryToolbarComponent;
44
44
  var isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
45
45
  var userPreferencesProvider = config.userPreferencesProvider,
46
- contextualFormattingEnabled = config.contextualFormattingEnabled;
46
+ contextualFormattingEnabled = config.contextualFormattingEnabled,
47
+ disablePin = config.disablePin;
47
48
  if (isToolbarAIFCEnabled) {
48
49
  var _api$toolbar;
49
50
  /**
@@ -51,7 +52,7 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
51
52
  */
52
53
  if ((api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.contextualFormattingMode()) === 'controlled') {
53
54
  var _api$toolbar2;
54
- api === null || api === void 0 || (_api$toolbar2 = api.toolbar) === null || _api$toolbar2 === void 0 || _api$toolbar2.actions.registerComponents((0, _toolbarComponents.getToolbarComponents)(api, true));
55
+ api === null || api === void 0 || (_api$toolbar2 = api.toolbar) === null || _api$toolbar2 === void 0 || _api$toolbar2.actions.registerComponents((0, _toolbarComponents.getToolbarComponents)(api, true, disablePin));
55
56
  }
56
57
  } else {
57
58
  if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1', {
@@ -29,14 +29,15 @@ var usePluginState = function usePluginState(_api) {
29
29
  * The menu-item version of pin only appears in selection toolbar - the primary toolbar will have its own component
30
30
  */
31
31
  var PinMenuItem = exports.PinMenuItem = function PinMenuItem(_ref) {
32
- var api = _ref.api;
32
+ var api = _ref.api,
33
+ disablePin = _ref.disablePin;
33
34
  var intl = (0, _reactIntlNext.useIntl)();
34
35
  var _usePluginState = usePluginState(api),
35
36
  editorViewMode = _usePluginState.editorViewMode,
36
37
  editorToolbarDockingPreference = _usePluginState.editorToolbarDockingPreference,
37
38
  isDisabled = _usePluginState.isOffline;
38
39
  var isToolbarDocked = editorToolbarDockingPreference === 'top';
39
- if (!shouldShowPinMenuItem(editorViewMode)) {
40
+ if (disablePin || !shouldShowPinMenuItem(editorViewMode)) {
40
41
  return null;
41
42
  }
42
43
  var onClick = function onClick() {
@@ -10,7 +10,7 @@ var _toolbar = require("@atlaskit/editor-common/toolbar");
10
10
  var _MenuSection = require("./MenuSection");
11
11
  var _PinButton = require("./PinButton");
12
12
  var _PinMenuItem = require("./PinMenuItem");
13
- var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(api, contextualFormattingEnabled) {
13
+ var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(api, contextualFormattingEnabled, disablePin) {
14
14
  var components = [{
15
15
  type: _toolbar.PIN_MENU_SECTION.type,
16
16
  key: _toolbar.PIN_MENU_SECTION.key,
@@ -35,7 +35,8 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
35
35
  }],
36
36
  component: function component() {
37
37
  return /*#__PURE__*/_react.default.createElement(_PinMenuItem.PinMenuItem, {
38
- api: api
38
+ api: api,
39
+ disablePin: disablePin
39
40
  });
40
41
  }
41
42
  }];
@@ -34,7 +34,8 @@ export const selectionToolbarPlugin = ({
34
34
  const isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
35
35
  const {
36
36
  userPreferencesProvider,
37
- contextualFormattingEnabled
37
+ contextualFormattingEnabled,
38
+ disablePin
38
39
  } = config;
39
40
  if (isToolbarAIFCEnabled) {
40
41
  var _api$toolbar;
@@ -43,7 +44,7 @@ export const selectionToolbarPlugin = ({
43
44
  */
44
45
  if ((api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.contextualFormattingMode()) === 'controlled') {
45
46
  var _api$toolbar2;
46
- api === null || api === void 0 ? void 0 : (_api$toolbar2 = api.toolbar) === null || _api$toolbar2 === void 0 ? void 0 : _api$toolbar2.actions.registerComponents(getToolbarComponents(api, true));
47
+ api === null || api === void 0 ? void 0 : (_api$toolbar2 = api.toolbar) === null || _api$toolbar2 === void 0 ? void 0 : _api$toolbar2.actions.registerComponents(getToolbarComponents(api, true, disablePin));
47
48
  }
48
49
  } else {
49
50
  if (editorExperiment('platform_editor_controls', 'variant1', {
@@ -23,7 +23,8 @@ const usePluginState = _api => {
23
23
  * The menu-item version of pin only appears in selection toolbar - the primary toolbar will have its own component
24
24
  */
25
25
  export const PinMenuItem = ({
26
- api
26
+ api,
27
+ disablePin
27
28
  }) => {
28
29
  const intl = useIntl();
29
30
  const {
@@ -32,7 +33,7 @@ export const PinMenuItem = ({
32
33
  isOffline: isDisabled
33
34
  } = usePluginState(api);
34
35
  const isToolbarDocked = editorToolbarDockingPreference === 'top';
35
- if (!shouldShowPinMenuItem(editorViewMode)) {
36
+ if (disablePin || !shouldShowPinMenuItem(editorViewMode)) {
36
37
  return null;
37
38
  }
38
39
  const onClick = () => {
@@ -3,7 +3,7 @@ import { OVERFLOW_MENU, OVERFLOW_MENU_RANK, PIN_BUTTON, PIN_GROUP, PIN_MENU_ITEM
3
3
  import { MenuSection } from './MenuSection';
4
4
  import { PinButton } from './PinButton';
5
5
  import { PinMenuItem } from './PinMenuItem';
6
- export const getToolbarComponents = (api, contextualFormattingEnabled) => {
6
+ export const getToolbarComponents = (api, contextualFormattingEnabled, disablePin) => {
7
7
  const components = [{
8
8
  type: PIN_MENU_SECTION.type,
9
9
  key: PIN_MENU_SECTION.key,
@@ -29,7 +29,8 @@ export const getToolbarComponents = (api, contextualFormattingEnabled) => {
29
29
  }],
30
30
  component: () => {
31
31
  return /*#__PURE__*/React.createElement(PinMenuItem, {
32
- api: api
32
+ api: api,
33
+ disablePin: disablePin
33
34
  });
34
35
  }
35
36
  }];
@@ -36,7 +36,8 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
36
36
  var primaryToolbarComponent;
37
37
  var isToolbarAIFCEnabled = Boolean(api === null || api === void 0 ? void 0 : api.toolbar);
38
38
  var userPreferencesProvider = config.userPreferencesProvider,
39
- contextualFormattingEnabled = config.contextualFormattingEnabled;
39
+ contextualFormattingEnabled = config.contextualFormattingEnabled,
40
+ disablePin = config.disablePin;
40
41
  if (isToolbarAIFCEnabled) {
41
42
  var _api$toolbar;
42
43
  /**
@@ -44,7 +45,7 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(_ref) {
44
45
  */
45
46
  if ((api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.contextualFormattingMode()) === 'controlled') {
46
47
  var _api$toolbar2;
47
- api === null || api === void 0 || (_api$toolbar2 = api.toolbar) === null || _api$toolbar2 === void 0 || _api$toolbar2.actions.registerComponents(getToolbarComponents(api, true));
48
+ api === null || api === void 0 || (_api$toolbar2 = api.toolbar) === null || _api$toolbar2 === void 0 || _api$toolbar2.actions.registerComponents(getToolbarComponents(api, true, disablePin));
48
49
  }
49
50
  } else {
50
51
  if (editorExperiment('platform_editor_controls', 'variant1', {
@@ -22,14 +22,15 @@ var usePluginState = function usePluginState(_api) {
22
22
  * The menu-item version of pin only appears in selection toolbar - the primary toolbar will have its own component
23
23
  */
24
24
  export var PinMenuItem = function PinMenuItem(_ref) {
25
- var api = _ref.api;
25
+ var api = _ref.api,
26
+ disablePin = _ref.disablePin;
26
27
  var intl = useIntl();
27
28
  var _usePluginState = usePluginState(api),
28
29
  editorViewMode = _usePluginState.editorViewMode,
29
30
  editorToolbarDockingPreference = _usePluginState.editorToolbarDockingPreference,
30
31
  isDisabled = _usePluginState.isOffline;
31
32
  var isToolbarDocked = editorToolbarDockingPreference === 'top';
32
- if (!shouldShowPinMenuItem(editorViewMode)) {
33
+ if (disablePin || !shouldShowPinMenuItem(editorViewMode)) {
33
34
  return null;
34
35
  }
35
36
  var onClick = function onClick() {
@@ -3,7 +3,7 @@ import { OVERFLOW_MENU, OVERFLOW_MENU_RANK, PIN_BUTTON, PIN_GROUP, PIN_MENU_ITEM
3
3
  import { MenuSection } from './MenuSection';
4
4
  import { PinButton } from './PinButton';
5
5
  import { PinMenuItem } from './PinMenuItem';
6
- export var getToolbarComponents = function getToolbarComponents(api, contextualFormattingEnabled) {
6
+ export var getToolbarComponents = function getToolbarComponents(api, contextualFormattingEnabled, disablePin) {
7
7
  var components = [{
8
8
  type: PIN_MENU_SECTION.type,
9
9
  key: PIN_MENU_SECTION.key,
@@ -28,7 +28,8 @@ export var getToolbarComponents = function getToolbarComponents(api, contextualF
28
28
  }],
29
29
  component: function component() {
30
30
  return /*#__PURE__*/React.createElement(PinMenuItem, {
31
- api: api
31
+ api: api,
32
+ disablePin: disablePin
32
33
  });
33
34
  }
34
35
  }];
@@ -16,6 +16,12 @@ export type SelectionToolbarPluginOptions = {
16
16
  * allows more control over toolbar placement.
17
17
  */
18
18
  contextualFormattingEnabled?: boolean;
19
+ /**
20
+ * When true, hides the pin/unpin option from the toolbar menu.
21
+ * Use this in contexts where toolbar docking should be permanently fixed
22
+ * @defaults false
23
+ */
24
+ disablePin?: boolean;
19
25
  /** @defaults false */
20
26
  preferenceToolbarAboveSelection?: boolean;
21
27
  userPreferencesProvider?: UserPreferencesProvider;
@@ -3,9 +3,10 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
4
4
  type PinMenuItemProps = {
5
5
  api?: ExtractInjectionAPI<SelectionToolbarPlugin>;
6
+ disablePin?: boolean;
6
7
  };
7
8
  /**
8
9
  * The menu-item version of pin only appears in selection toolbar - the primary toolbar will have its own component
9
10
  */
10
- export declare const PinMenuItem: ({ api }: PinMenuItemProps) => React.JSX.Element | null;
11
+ export declare const PinMenuItem: ({ api, disablePin }: PinMenuItemProps) => React.JSX.Element | null;
11
12
  export {};
@@ -1,4 +1,4 @@
1
1
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
3
3
  import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
4
- export declare const getToolbarComponents: (api?: ExtractInjectionAPI<SelectionToolbarPlugin>, contextualFormattingEnabled?: boolean) => RegisterComponent[];
4
+ export declare const getToolbarComponents: (api?: ExtractInjectionAPI<SelectionToolbarPlugin>, contextualFormattingEnabled?: boolean, disablePin?: boolean) => RegisterComponent[];
@@ -16,6 +16,12 @@ export type SelectionToolbarPluginOptions = {
16
16
  * allows more control over toolbar placement.
17
17
  */
18
18
  contextualFormattingEnabled?: boolean;
19
+ /**
20
+ * When true, hides the pin/unpin option from the toolbar menu.
21
+ * Use this in contexts where toolbar docking should be permanently fixed
22
+ * @defaults false
23
+ */
24
+ disablePin?: boolean;
19
25
  /** @defaults false */
20
26
  preferenceToolbarAboveSelection?: boolean;
21
27
  userPreferencesProvider?: UserPreferencesProvider;
@@ -3,9 +3,10 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
4
4
  type PinMenuItemProps = {
5
5
  api?: ExtractInjectionAPI<SelectionToolbarPlugin>;
6
+ disablePin?: boolean;
6
7
  };
7
8
  /**
8
9
  * The menu-item version of pin only appears in selection toolbar - the primary toolbar will have its own component
9
10
  */
10
- export declare const PinMenuItem: ({ api }: PinMenuItemProps) => React.JSX.Element | null;
11
+ export declare const PinMenuItem: ({ api, disablePin }: PinMenuItemProps) => React.JSX.Element | null;
11
12
  export {};
@@ -1,4 +1,4 @@
1
1
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
3
3
  import type { SelectionToolbarPlugin } from '../selectionToolbarPluginType';
4
- export declare const getToolbarComponents: (api?: ExtractInjectionAPI<SelectionToolbarPlugin>, contextualFormattingEnabled?: boolean) => RegisterComponent[];
4
+ export declare const getToolbarComponents: (api?: ExtractInjectionAPI<SelectionToolbarPlugin>, contextualFormattingEnabled?: boolean, disablePin?: boolean) => RegisterComponent[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-toolbar",
3
- "version": "9.0.15",
3
+ "version": "9.1.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",