@atlaskit/editor-plugin-selection-toolbar 5.0.7 → 6.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,23 @@
1
1
  # @atlaskit/editor-plugin-selection-toolbar
2
2
 
3
+ ## 6.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`4edb2aee0da9c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4edb2aee0da9c) -
8
+ Add conditionalHooksFactory and migrate usage of useSharedPluginStateSelector to useEditorToolbar
9
+ and useSharedPluginStateWithSelector
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 6.0.0
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 5.0.7
4
22
 
5
23
  ### Patch Changes
@@ -6,15 +6,32 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.MenuSection = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _toolbar = require("@atlaskit/editor-common/toolbar");
9
10
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
10
11
  var _editorToolbar = require("@atlaskit/editor-toolbar");
12
+ var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
13
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
14
+ var usePluginState = (0, _platformFeatureFlagsReact.conditionalHooksFactory)(function () {
15
+ return (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true);
16
+ }, function (api) {
17
+ var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
18
+ editorViewMode = _useEditorToolbar.editorViewMode;
19
+ return {
20
+ editorViewMode: editorViewMode
21
+ };
22
+ }, function (api) {
23
+ var editorViewMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
24
+ return {
25
+ editorViewMode: editorViewMode
26
+ };
27
+ });
11
28
  var MenuSection = exports.MenuSection = function MenuSection(_ref) {
12
29
  var children = _ref.children,
13
30
  api = _ref.api;
14
- var viewMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
15
- var isEdit = viewMode === 'edit';
16
- if (!isEdit) {
17
- return null;
18
- }
19
- return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, null, children);
31
+ var _usePluginState = usePluginState(api),
32
+ editorViewMode = _usePluginState.editorViewMode;
33
+ var isEdit = editorViewMode === 'edit';
34
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
35
+ hasSeparator: isEdit
36
+ }, children);
20
37
  };
@@ -8,21 +8,44 @@ exports.PinMenuItem = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactIntlNext = require("react-intl-next");
10
10
  var _messages = require("@atlaskit/editor-common/messages");
11
+ var _toolbar = require("@atlaskit/editor-common/toolbar");
11
12
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
12
13
  var _editorToolbar = require("@atlaskit/editor-toolbar");
14
+ var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
15
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
16
  var shouldShowPinMenuItem = function shouldShowPinMenuItem(editMode) {
14
17
  return editMode !== 'view';
15
18
  };
19
+ var usePluginState = (0, _platformFeatureFlagsReact.conditionalHooksFactory)(function () {
20
+ return (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true);
21
+ }, function (api) {
22
+ var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
23
+ editorViewMode = _useEditorToolbar.editorViewMode,
24
+ editorToolbarDockingPreference = _useEditorToolbar.editorToolbarDockingPreference;
25
+ return {
26
+ editorViewMode: editorViewMode,
27
+ editorToolbarDockingPreference: editorToolbarDockingPreference
28
+ };
29
+ }, function (api) {
30
+ var editorViewMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
31
+ var editorToolbarDockingPreference = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userPreferences.preferences.toolbarDockingPosition');
32
+ return {
33
+ editorViewMode: editorViewMode,
34
+ editorToolbarDockingPreference: editorToolbarDockingPreference
35
+ };
36
+ });
37
+
16
38
  /**
17
39
  * The menu-item version of pin only appears in selection toolbar - the primary toolbar will have its own component
18
40
  */
19
41
  var PinMenuItem = exports.PinMenuItem = function PinMenuItem(_ref) {
20
42
  var api = _ref.api;
21
43
  var intl = (0, _reactIntlNext.useIntl)();
22
- var editMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
23
- var toolbarDocking = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userPreferences.preferences.toolbarDockingPosition');
24
- var isToolbarDocked = toolbarDocking === 'top';
25
- if (!shouldShowPinMenuItem(editMode)) {
44
+ var _usePluginState = usePluginState(api),
45
+ editorViewMode = _usePluginState.editorViewMode,
46
+ editorToolbarDockingPreference = _usePluginState.editorToolbarDockingPreference;
47
+ var isToolbarDocked = editorToolbarDockingPreference === 'top';
48
+ if (!shouldShowPinMenuItem(editorViewMode)) {
26
49
  return null;
27
50
  }
28
51
  var onClick = function onClick() {
@@ -1,14 +1,31 @@
1
1
  import React from 'react';
2
+ import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
2
3
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
3
4
  import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
5
+ import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
+ const usePluginState = conditionalHooksFactory(() => expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true), api => {
8
+ const {
9
+ editorViewMode
10
+ } = useEditorToolbar();
11
+ return {
12
+ editorViewMode
13
+ };
14
+ }, api => {
15
+ const editorViewMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
16
+ return {
17
+ editorViewMode
18
+ };
19
+ });
4
20
  export const MenuSection = ({
5
21
  children,
6
22
  api
7
23
  }) => {
8
- const viewMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
9
- const isEdit = viewMode === 'edit';
10
- if (!isEdit) {
11
- return null;
12
- }
13
- return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children);
24
+ const {
25
+ editorViewMode
26
+ } = usePluginState(api);
27
+ const isEdit = editorViewMode === 'edit';
28
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
29
+ hasSeparator: isEdit
30
+ }, children);
14
31
  };
@@ -1,11 +1,32 @@
1
1
  import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { selectionToolbarMessages } from '@atlaskit/editor-common/messages';
4
+ import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
4
5
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
6
  import { PinIcon, PinnedIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
7
+ import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
8
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
9
  const shouldShowPinMenuItem = editMode => {
7
10
  return editMode !== 'view';
8
11
  };
12
+ const usePluginState = conditionalHooksFactory(() => expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true), api => {
13
+ const {
14
+ editorViewMode,
15
+ editorToolbarDockingPreference
16
+ } = useEditorToolbar();
17
+ return {
18
+ editorViewMode,
19
+ editorToolbarDockingPreference
20
+ };
21
+ }, api => {
22
+ const editorViewMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
23
+ const editorToolbarDockingPreference = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
24
+ return {
25
+ editorViewMode,
26
+ editorToolbarDockingPreference
27
+ };
28
+ });
29
+
9
30
  /**
10
31
  * The menu-item version of pin only appears in selection toolbar - the primary toolbar will have its own component
11
32
  */
@@ -13,10 +34,12 @@ export const PinMenuItem = ({
13
34
  api
14
35
  }) => {
15
36
  const intl = useIntl();
16
- const editMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
17
- const toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
18
- const isToolbarDocked = toolbarDocking === 'top';
19
- if (!shouldShowPinMenuItem(editMode)) {
37
+ const {
38
+ editorViewMode,
39
+ editorToolbarDockingPreference
40
+ } = usePluginState(api);
41
+ const isToolbarDocked = editorToolbarDockingPreference === 'top';
42
+ if (!shouldShowPinMenuItem(editorViewMode)) {
20
43
  return null;
21
44
  }
22
45
  const onClick = () => {
@@ -1,13 +1,30 @@
1
1
  import React from 'react';
2
+ import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
2
3
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
3
4
  import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
5
+ import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
+ var usePluginState = conditionalHooksFactory(function () {
8
+ return expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true);
9
+ }, function (api) {
10
+ var _useEditorToolbar = useEditorToolbar(),
11
+ editorViewMode = _useEditorToolbar.editorViewMode;
12
+ return {
13
+ editorViewMode: editorViewMode
14
+ };
15
+ }, function (api) {
16
+ var editorViewMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
17
+ return {
18
+ editorViewMode: editorViewMode
19
+ };
20
+ });
4
21
  export var MenuSection = function MenuSection(_ref) {
5
22
  var children = _ref.children,
6
23
  api = _ref.api;
7
- var viewMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
8
- var isEdit = viewMode === 'edit';
9
- if (!isEdit) {
10
- return null;
11
- }
12
- return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, children);
24
+ var _usePluginState = usePluginState(api),
25
+ editorViewMode = _usePluginState.editorViewMode;
26
+ var isEdit = editorViewMode === 'edit';
27
+ return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
28
+ hasSeparator: isEdit
29
+ }, children);
13
30
  };
@@ -1,21 +1,44 @@
1
1
  import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { selectionToolbarMessages } from '@atlaskit/editor-common/messages';
4
+ import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
4
5
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
6
  import { PinIcon, PinnedIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
7
+ import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
8
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
9
  var shouldShowPinMenuItem = function shouldShowPinMenuItem(editMode) {
7
10
  return editMode !== 'view';
8
11
  };
12
+ var usePluginState = conditionalHooksFactory(function () {
13
+ return expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true);
14
+ }, function (api) {
15
+ var _useEditorToolbar = useEditorToolbar(),
16
+ editorViewMode = _useEditorToolbar.editorViewMode,
17
+ editorToolbarDockingPreference = _useEditorToolbar.editorToolbarDockingPreference;
18
+ return {
19
+ editorViewMode: editorViewMode,
20
+ editorToolbarDockingPreference: editorToolbarDockingPreference
21
+ };
22
+ }, function (api) {
23
+ var editorViewMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
24
+ var editorToolbarDockingPreference = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
25
+ return {
26
+ editorViewMode: editorViewMode,
27
+ editorToolbarDockingPreference: editorToolbarDockingPreference
28
+ };
29
+ });
30
+
9
31
  /**
10
32
  * The menu-item version of pin only appears in selection toolbar - the primary toolbar will have its own component
11
33
  */
12
34
  export var PinMenuItem = function PinMenuItem(_ref) {
13
35
  var api = _ref.api;
14
36
  var intl = useIntl();
15
- var editMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
16
- var toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
17
- var isToolbarDocked = toolbarDocking === 'top';
18
- if (!shouldShowPinMenuItem(editMode)) {
37
+ var _usePluginState = usePluginState(api),
38
+ editorViewMode = _usePluginState.editorViewMode,
39
+ editorToolbarDockingPreference = _usePluginState.editorToolbarDockingPreference;
40
+ var isToolbarDocked = editorToolbarDockingPreference === 'top';
41
+ if (!shouldShowPinMenuItem(editorViewMode)) {
19
42
  return null;
20
43
  }
21
44
  var onClick = function onClick() {
@@ -5,5 +5,5 @@ type MenuSectionProps = {
5
5
  api: ExtractInjectionAPI<SelectionToolbarPlugin> | undefined;
6
6
  children: React.ReactNode;
7
7
  };
8
- export declare const MenuSection: ({ children, api }: MenuSectionProps) => React.JSX.Element | null;
8
+ export declare const MenuSection: ({ children, api }: MenuSectionProps) => React.JSX.Element;
9
9
  export {};
@@ -5,5 +5,5 @@ type MenuSectionProps = {
5
5
  api: ExtractInjectionAPI<SelectionToolbarPlugin> | undefined;
6
6
  children: React.ReactNode;
7
7
  };
8
- export declare const MenuSection: ({ children, api }: MenuSectionProps) => React.JSX.Element | null;
8
+ export declare const MenuSection: ({ children, api }: MenuSectionProps) => React.JSX.Element;
9
9
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-toolbar",
3
- "version": "5.0.7",
3
+ "version": "6.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",
@@ -30,14 +30,14 @@
30
30
  "atlaskit:src": "src/index.ts",
31
31
  "dependencies": {
32
32
  "@atlaskit/css": "^0.14.0",
33
- "@atlaskit/editor-plugin-analytics": "^4.0.0",
34
- "@atlaskit/editor-plugin-block-controls": "^5.0.0",
35
- "@atlaskit/editor-plugin-connectivity": "^4.0.0",
36
- "@atlaskit/editor-plugin-editor-viewmode": "^6.0.0",
37
- "@atlaskit/editor-plugin-primary-toolbar": "^5.0.0",
38
- "@atlaskit/editor-plugin-toolbar": "^1.2.0",
39
- "@atlaskit/editor-plugin-user-intent": "^2.0.0",
40
- "@atlaskit/editor-plugin-user-preferences": "^2.0.0",
33
+ "@atlaskit/editor-plugin-analytics": "^5.0.0",
34
+ "@atlaskit/editor-plugin-block-controls": "^6.0.0",
35
+ "@atlaskit/editor-plugin-connectivity": "^5.0.0",
36
+ "@atlaskit/editor-plugin-editor-viewmode": "^7.0.0",
37
+ "@atlaskit/editor-plugin-primary-toolbar": "^6.0.0",
38
+ "@atlaskit/editor-plugin-toolbar": "^2.1.0",
39
+ "@atlaskit/editor-plugin-user-intent": "^3.0.0",
40
+ "@atlaskit/editor-plugin-user-preferences": "^3.0.0",
41
41
  "@atlaskit/editor-prosemirror": "7.0.0",
42
42
  "@atlaskit/editor-toolbar": "^0.8.0",
43
43
  "@atlaskit/editor-toolbar-model": "^0.2.0",
@@ -45,13 +45,14 @@
45
45
  "@atlaskit/icon-lab": "^5.7.0",
46
46
  "@atlaskit/menu": "^8.4.0",
47
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
48
- "@atlaskit/tmp-editor-statsig": "^12.8.0",
48
+ "@atlaskit/platform-feature-flags-react": "^0.3.0",
49
+ "@atlaskit/tmp-editor-statsig": "^12.10.0",
49
50
  "@atlaskit/tokens": "^6.3.0",
50
51
  "@babel/runtime": "^7.0.0",
51
52
  "bind-event-listener": "^3.0.0"
52
53
  },
53
54
  "peerDependencies": {
54
- "@atlaskit/editor-common": "^108.6.0",
55
+ "@atlaskit/editor-common": "^109.1.0",
55
56
  "react": "^18.2.0",
56
57
  "react-dom": "^18.2.0",
57
58
  "react-intl-next": "npm:react-intl@^5.18.1"