@atlaskit/editor-plugin-toolbar 0.4.1 → 0.4.3

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,21 @@
1
1
  # @atlaskit/editor-plugin-toolbar
2
2
 
3
+ ## 0.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`463f3da1f7822`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/463f3da1f7822) -
8
+ [ux] ED-29040 add new option to disable selection toolbar when the toolbar is pinned
9
+ - Updated dependencies
10
+
11
+ ## 0.4.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [`265c1bf0cefa4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/265c1bf0cefa4) -
16
+ Sorted type and interface props to improve Atlaskit docs
17
+ - Updated dependencies
18
+
3
19
  ## 0.4.1
4
20
 
5
21
  ### Patch Changes
@@ -2,9 +2,9 @@
2
2
  "extends": "../../../../tsconfig.entry-points.confluence.json",
3
3
  "compilerOptions": {
4
4
  "target": "es5",
5
- "composite": true,
6
5
  "outDir": "../../../../../confluence/tsDist/@atlaskit__editor-plugin-toolbar",
7
- "rootDir": "../"
6
+ "rootDir": "../",
7
+ "composite": true
8
8
  },
9
9
  "include": [
10
10
  "../src/**/*.ts",
@@ -45,4 +45,4 @@
45
45
  "path": "../../editor-common/afm-cc/tsconfig.json"
46
46
  }
47
47
  ]
48
- }
48
+ }
@@ -21,9 +21,11 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
21
21
  var api = _ref.api,
22
22
  _ref$config = _ref.config,
23
23
  config = _ref$config === void 0 ? {
24
- disableSelectionToolbar: false
24
+ disableSelectionToolbar: false,
25
+ disableSelectionToolbarWhenPinned: false
25
26
  } : _ref$config;
26
- var disableSelectionToolbar = config.disableSelectionToolbar;
27
+ var disableSelectionToolbar = config.disableSelectionToolbar,
28
+ disableSelectionToolbarWhenPinned = config.disableSelectionToolbarWhenPinned;
27
29
  var registry = (0, _editorToolbarModel.createComponentRegistry)();
28
30
  registry.register((0, _toolbarComponents.getToolbarComponents)(api, disableSelectionToolbar));
29
31
  return {
@@ -117,7 +119,8 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
117
119
  return /*#__PURE__*/_react.default.createElement(_SelectionToolbar.SelectionToolbar, {
118
120
  api: api,
119
121
  editorView: editorView,
120
- mountPoint: popupsMountPoint
122
+ mountPoint: popupsMountPoint,
123
+ disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
121
124
  });
122
125
  } : undefined
123
126
  };
@@ -27,7 +27,8 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
27
27
  var _api$toolbar, _api$toolbar$getCompo;
28
28
  var api = _ref.api,
29
29
  editorView = _ref.editorView,
30
- mountPoint = _ref.mountPoint;
30
+ mountPoint = _ref.mountPoint,
31
+ disableSelectionToolbarWhenPinned = _ref.disableSelectionToolbarWhenPinned;
31
32
  var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['toolbar'], function (state) {
32
33
  var _state$toolbarState;
33
34
  return {
@@ -47,6 +48,7 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
47
48
  var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
48
49
  var isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof _state.TextSelection;
49
50
  var isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
51
+ var toolbarDocking = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userPreferences.preferences.toolbarDockingPosition');
50
52
  var onPositionCalculated = (0, _react.useCallback)(function (position) {
51
53
  var toolbarTitle = _consts.SELECTION_TOOLBAR_LABEL;
52
54
 
@@ -59,7 +61,7 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
59
61
  var calc = _utils.calculateToolbarPositionTrackHead;
60
62
  return calc(toolbarTitle)(editorView, position);
61
63
  }, [editorView]);
62
- if (!components || !toolbar) {
64
+ if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && toolbarDocking === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
63
65
  return null;
64
66
  }
65
67
  if (!(isTextSelection || isCellSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) || (0, _coreUtils.isSSR)()) {
@@ -10,11 +10,13 @@ import { isEventInContainer } from './ui/utils/toolbar';
10
10
  export const toolbarPlugin = ({
11
11
  api,
12
12
  config = {
13
- disableSelectionToolbar: false
13
+ disableSelectionToolbar: false,
14
+ disableSelectionToolbarWhenPinned: false
14
15
  }
15
16
  }) => {
16
17
  const {
17
- disableSelectionToolbar
18
+ disableSelectionToolbar,
19
+ disableSelectionToolbarWhenPinned
18
20
  } = config;
19
21
  const registry = createComponentRegistry();
20
22
  registry.register(getToolbarComponents(api, disableSelectionToolbar));
@@ -113,7 +115,8 @@ export const toolbarPlugin = ({
113
115
  return /*#__PURE__*/React.createElement(SelectionToolbar, {
114
116
  api: api,
115
117
  editorView: editorView,
116
- mountPoint: popupsMountPoint
118
+ mountPoint: popupsMountPoint,
119
+ disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
117
120
  });
118
121
  } : undefined
119
122
  };
@@ -18,7 +18,8 @@ const isToolbarComponent = component => {
18
18
  export const SelectionToolbar = ({
19
19
  api,
20
20
  editorView,
21
- mountPoint
21
+ mountPoint,
22
+ disableSelectionToolbarWhenPinned
22
23
  }) => {
23
24
  var _api$toolbar, _api$toolbar$actions, _api$toolbar$actions$;
24
25
  const {
@@ -39,6 +40,7 @@ export const SelectionToolbar = ({
39
40
  const selection = useSharedPluginStateSelector(api, 'selection.selection');
40
41
  const isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof TextSelection;
41
42
  const isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
43
+ const toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
42
44
  const onPositionCalculated = useCallback(position => {
43
45
  const toolbarTitle = SELECTION_TOOLBAR_LABEL;
44
46
 
@@ -51,7 +53,7 @@ export const SelectionToolbar = ({
51
53
  const calc = calculateToolbarPositionTrackHead;
52
54
  return calc(toolbarTitle)(editorView, position);
53
55
  }, [editorView]);
54
- if (!components || !toolbar) {
56
+ if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && toolbarDocking === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
55
57
  return null;
56
58
  }
57
59
  if (!(isTextSelection || isCellSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isSSR()) {
@@ -14,9 +14,11 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
14
14
  var api = _ref.api,
15
15
  _ref$config = _ref.config,
16
16
  config = _ref$config === void 0 ? {
17
- disableSelectionToolbar: false
17
+ disableSelectionToolbar: false,
18
+ disableSelectionToolbarWhenPinned: false
18
19
  } : _ref$config;
19
- var disableSelectionToolbar = config.disableSelectionToolbar;
20
+ var disableSelectionToolbar = config.disableSelectionToolbar,
21
+ disableSelectionToolbarWhenPinned = config.disableSelectionToolbarWhenPinned;
20
22
  var registry = createComponentRegistry();
21
23
  registry.register(getToolbarComponents(api, disableSelectionToolbar));
22
24
  return {
@@ -110,7 +112,8 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
110
112
  return /*#__PURE__*/React.createElement(SelectionToolbar, {
111
113
  api: api,
112
114
  editorView: editorView,
113
- mountPoint: popupsMountPoint
115
+ mountPoint: popupsMountPoint,
116
+ disableSelectionToolbarWhenPinned: disableSelectionToolbarWhenPinned !== null && disableSelectionToolbarWhenPinned !== void 0 ? disableSelectionToolbarWhenPinned : false
114
117
  });
115
118
  } : undefined
116
119
  };
@@ -19,7 +19,8 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
19
19
  var _api$toolbar, _api$toolbar$getCompo;
20
20
  var api = _ref.api,
21
21
  editorView = _ref.editorView,
22
- mountPoint = _ref.mountPoint;
22
+ mountPoint = _ref.mountPoint,
23
+ disableSelectionToolbarWhenPinned = _ref.disableSelectionToolbarWhenPinned;
23
24
  var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['toolbar'], function (state) {
24
25
  var _state$toolbarState;
25
26
  return {
@@ -39,6 +40,7 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
39
40
  var selection = useSharedPluginStateSelector(api, 'selection.selection');
40
41
  var isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof TextSelection;
41
42
  var isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
43
+ var toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
42
44
  var onPositionCalculated = useCallback(function (position) {
43
45
  var toolbarTitle = SELECTION_TOOLBAR_LABEL;
44
46
 
@@ -51,7 +53,7 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
51
53
  var calc = calculateToolbarPositionTrackHead;
52
54
  return calc(toolbarTitle)(editorView, position);
53
55
  }, [editorView]);
54
- if (!components || !toolbar) {
56
+ if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && toolbarDocking === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
55
57
  return null;
56
58
  }
57
59
  if (!(isTextSelection || isCellSelection) || currentUserIntent === 'dragging' || !shouldShowToolbar || currentUserIntent === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isSSR()) {
@@ -7,9 +7,9 @@ import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-prefere
7
7
  import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
8
8
  import type { ToolbarPluginOptions } from './types';
9
9
  export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
10
- pluginConfiguration?: ToolbarPluginOptions;
11
- sharedState: {
12
- shouldShowToolbar: boolean;
10
+ actions: {
11
+ getComponents: () => Array<RegisterComponent>;
12
+ registerComponents: (toolbarComponents: Array<RegisterComponent>) => void;
13
13
  };
14
14
  dependencies: [
15
15
  OptionalPlugin<UserIntentPlugin>,
@@ -18,8 +18,8 @@ export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
18
18
  OptionalPlugin<EditorViewModePlugin>,
19
19
  OptionalPlugin<ConnectivityPlugin>
20
20
  ];
21
- actions: {
22
- registerComponents: (toolbarComponents: Array<RegisterComponent>) => void;
23
- getComponents: () => Array<RegisterComponent>;
21
+ pluginConfiguration?: ToolbarPluginOptions;
22
+ sharedState: {
23
+ shouldShowToolbar: boolean;
24
24
  };
25
25
  }>;
@@ -1,3 +1,4 @@
1
1
  export type ToolbarPluginOptions = {
2
2
  disableSelectionToolbar?: boolean;
3
+ disableSelectionToolbarWhenPinned?: boolean;
3
4
  };
@@ -3,13 +3,13 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
4
4
  import type { ToolbarPlugin } from '../toolbarPluginType';
5
5
  type SectionProps = {
6
+ api?: ExtractInjectionAPI<ToolbarPlugin>;
6
7
  children: React.ReactNode;
8
+ disableSelectionToolbar?: boolean;
9
+ isSharedSection?: boolean;
7
10
  parents: ToolbarComponentTypes;
8
- api?: ExtractInjectionAPI<ToolbarPlugin>;
9
- testId?: string;
10
11
  showSeparatorInFullPagePrimaryToolbar?: boolean;
11
- isSharedSection?: boolean;
12
- disableSelectionToolbar?: boolean;
12
+ testId?: string;
13
13
  };
14
14
  export declare const Section: ({ children, parents, api, testId, showSeparatorInFullPagePrimaryToolbar, isSharedSection, disableSelectionToolbar, }: SectionProps) => React.JSX.Element | null;
15
15
  export {};
@@ -3,9 +3,10 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { ToolbarPlugin } from '../../toolbarPluginType';
5
5
  type SelectionToolbarProps = {
6
- editorView: EditorView;
7
6
  api?: ExtractInjectionAPI<ToolbarPlugin>;
7
+ editorView: EditorView;
8
8
  mountPoint: HTMLElement | undefined;
9
+ disableSelectionToolbarWhenPinned: boolean;
9
10
  };
10
- export declare const SelectionToolbar: ({ api, editorView, mountPoint }: SelectionToolbarProps) => React.JSX.Element | null;
11
+ export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned }: SelectionToolbarProps) => React.JSX.Element | null;
11
12
  export {};
@@ -7,9 +7,9 @@ import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-prefere
7
7
  import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
8
8
  import type { ToolbarPluginOptions } from './types';
9
9
  export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
10
- pluginConfiguration?: ToolbarPluginOptions;
11
- sharedState: {
12
- shouldShowToolbar: boolean;
10
+ actions: {
11
+ getComponents: () => Array<RegisterComponent>;
12
+ registerComponents: (toolbarComponents: Array<RegisterComponent>) => void;
13
13
  };
14
14
  dependencies: [
15
15
  OptionalPlugin<UserIntentPlugin>,
@@ -18,8 +18,8 @@ export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
18
18
  OptionalPlugin<EditorViewModePlugin>,
19
19
  OptionalPlugin<ConnectivityPlugin>
20
20
  ];
21
- actions: {
22
- registerComponents: (toolbarComponents: Array<RegisterComponent>) => void;
23
- getComponents: () => Array<RegisterComponent>;
21
+ pluginConfiguration?: ToolbarPluginOptions;
22
+ sharedState: {
23
+ shouldShowToolbar: boolean;
24
24
  };
25
25
  }>;
@@ -1,3 +1,4 @@
1
1
  export type ToolbarPluginOptions = {
2
2
  disableSelectionToolbar?: boolean;
3
+ disableSelectionToolbarWhenPinned?: boolean;
3
4
  };
@@ -3,13 +3,13 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
4
4
  import type { ToolbarPlugin } from '../toolbarPluginType';
5
5
  type SectionProps = {
6
+ api?: ExtractInjectionAPI<ToolbarPlugin>;
6
7
  children: React.ReactNode;
8
+ disableSelectionToolbar?: boolean;
9
+ isSharedSection?: boolean;
7
10
  parents: ToolbarComponentTypes;
8
- api?: ExtractInjectionAPI<ToolbarPlugin>;
9
- testId?: string;
10
11
  showSeparatorInFullPagePrimaryToolbar?: boolean;
11
- isSharedSection?: boolean;
12
- disableSelectionToolbar?: boolean;
12
+ testId?: string;
13
13
  };
14
14
  export declare const Section: ({ children, parents, api, testId, showSeparatorInFullPagePrimaryToolbar, isSharedSection, disableSelectionToolbar, }: SectionProps) => React.JSX.Element | null;
15
15
  export {};
@@ -3,9 +3,10 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { ToolbarPlugin } from '../../toolbarPluginType';
5
5
  type SelectionToolbarProps = {
6
- editorView: EditorView;
7
6
  api?: ExtractInjectionAPI<ToolbarPlugin>;
7
+ editorView: EditorView;
8
8
  mountPoint: HTMLElement | undefined;
9
+ disableSelectionToolbarWhenPinned: boolean;
9
10
  };
10
- export declare const SelectionToolbar: ({ api, editorView, mountPoint }: SelectionToolbarProps) => React.JSX.Element | null;
11
+ export declare const SelectionToolbar: ({ api, editorView, mountPoint, disableSelectionToolbarWhenPinned }: SelectionToolbarProps) => React.JSX.Element | null;
11
12
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-toolbar",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -39,13 +39,13 @@
39
39
  "@atlaskit/editor-prosemirror": "7.0.0",
40
40
  "@atlaskit/editor-toolbar": "^0.3.0",
41
41
  "@atlaskit/editor-toolbar-model": "^0.1.0",
42
- "@atlaskit/tmp-editor-statsig": "^11.5.0",
42
+ "@atlaskit/tmp-editor-statsig": "^11.8.0",
43
43
  "@babel/runtime": "^7.0.0",
44
44
  "bind-event-listener": "^3.0.0",
45
45
  "react-intl-next": "npm:react-intl@^5.18.1"
46
46
  },
47
47
  "peerDependencies": {
48
- "@atlaskit/editor-common": "^107.28.0",
48
+ "@atlaskit/editor-common": "^107.31.0",
49
49
  "react": "^18.2.0"
50
50
  },
51
51
  "techstack": {