@atlaskit/editor-plugin-alignment 3.1.12 → 3.1.14

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,20 @@
1
1
  # @atlaskit/editor-plugin-alignment
2
2
 
3
+ ## 3.1.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [#151999](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/151999)
8
+ [`daf7c638efb95`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/daf7c638efb95) -
9
+ Refactor to use sharedPluginStateHookMigratorFactory
10
+ - Updated dependencies
11
+
12
+ ## 3.1.13
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 3.1.12
4
19
 
5
20
  ### Patch Changes
@@ -20,21 +20,27 @@ var FloatingToolbarSettings = {
20
20
  disabled: false,
21
21
  isToolbarReducedSpacing: true
22
22
  };
23
+ var useFloatingToolbarComponentPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
24
+ var align = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'alignment.align');
25
+ var isEnabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'alignment.isEnabled');
26
+ return {
27
+ align: align,
28
+ isEnabled: isEnabled
29
+ };
30
+ }, function (api) {
31
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['alignment']),
32
+ alignmentState = _useSharedPluginState.alignmentState;
33
+ return {
34
+ align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
35
+ isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
36
+ };
37
+ });
23
38
  function FloatingToolbarComponent(_ref) {
24
39
  var api = _ref.api,
25
40
  editorView = _ref.editorView;
26
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['alignment'], {
27
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
28
- }),
29
- alignmentState = _useSharedPluginState.alignmentState;
30
- var alignSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'alignment.align', {
31
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
32
- });
33
- var align = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? alignSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align;
34
- var isEnabledSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'alignment.isEnabled', {
35
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
36
- });
37
- var isEnabled = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isEnabledSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled;
41
+ var _useFloatingToolbarCo = useFloatingToolbarComponentPluginState(api),
42
+ align = _useFloatingToolbarCo.align,
43
+ isEnabled = _useFloatingToolbarCo.isEnabled;
38
44
  var changeAlignmentCallback = (0, _react.useCallback)(function (align) {
39
45
  return (0, _editorCommands.changeAlignment)(align, api, _analytics.INPUT_METHOD.FLOATING_TB)(editorView.state, editorView.dispatch);
40
46
  }, [editorView, api]);
@@ -11,12 +11,26 @@ var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
12
  var _types = require("@atlaskit/editor-common/types");
13
13
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
14
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
15
14
  var _editorCommands = require("../editor-commands");
16
15
  var _types2 = require("../pm-plugins/types");
17
16
  var _ToolbarAlignment = _interopRequireDefault(require("./ToolbarAlignment"));
18
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
19
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
+ var usePrimaryToolbarComponentPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
20
+ var align = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'alignment.align');
21
+ var isEnabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'alignment.isEnabled');
22
+ return {
23
+ align: align,
24
+ isEnabled: isEnabled
25
+ };
26
+ }, function (api) {
27
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['alignment']),
28
+ alignmentState = _useSharedPluginState.alignmentState;
29
+ return {
30
+ align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
31
+ isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
32
+ };
33
+ });
20
34
  function PrimaryToolbarComponent(_ref) {
21
35
  var api = _ref.api,
22
36
  editorView = _ref.editorView,
@@ -27,18 +41,9 @@ function PrimaryToolbarComponent(_ref) {
27
41
  isToolbarReducedSpacing = _ref.isToolbarReducedSpacing,
28
42
  _ref$toolbarSize = _ref.toolbarSize,
29
43
  toolbarSize = _ref$toolbarSize === void 0 ? _types.ToolbarSize.XXL : _ref$toolbarSize;
30
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['alignment'], {
31
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
32
- }),
33
- alignmentState = _useSharedPluginState.alignmentState;
34
- var alignSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'alignment.align', {
35
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
36
- });
37
- var align = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? alignSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align;
38
- var isEnabledSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'alignment.isEnabled', {
39
- disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
40
- });
41
- var isEnabled = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isEnabledSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled;
44
+ var _usePrimaryToolbarCom = usePrimaryToolbarComponentPluginState(api),
45
+ align = _usePrimaryToolbarCom.align,
46
+ isEnabled = _usePrimaryToolbarCom.isEnabled;
42
47
  var changeAlignmentCallback = (0, _react.useCallback)(function (align) {
43
48
  return (0, _editorCommands.changeAlignment)(align, api, _analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
44
49
  }, [editorView, api]);
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
4
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
6
  import { changeAlignment } from '../editor-commands';
@@ -10,23 +10,30 @@ const FloatingToolbarSettings = {
10
10
  disabled: false,
11
11
  isToolbarReducedSpacing: true
12
12
  };
13
+ const useFloatingToolbarComponentPluginState = sharedPluginStateHookMigratorFactory(api => {
14
+ const align = useSharedPluginStateSelector(api, 'alignment.align');
15
+ const isEnabled = useSharedPluginStateSelector(api, 'alignment.isEnabled');
16
+ return {
17
+ align,
18
+ isEnabled
19
+ };
20
+ }, api => {
21
+ const {
22
+ alignmentState
23
+ } = useSharedPluginState(api, ['alignment']);
24
+ return {
25
+ align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
26
+ isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
27
+ };
28
+ });
13
29
  export function FloatingToolbarComponent({
14
30
  api,
15
31
  editorView
16
32
  }) {
17
33
  const {
18
- alignmentState
19
- } = useSharedPluginState(api, ['alignment'], {
20
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
21
- });
22
- const alignSelector = useSharedPluginStateSelector(api, 'alignment.align', {
23
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
24
- });
25
- const align = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? alignSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align;
26
- const isEnabledSelector = useSharedPluginStateSelector(api, 'alignment.isEnabled', {
27
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
28
- });
29
- const isEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isEnabledSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled;
34
+ align,
35
+ isEnabled
36
+ } = useFloatingToolbarComponentPluginState(api);
30
37
  const changeAlignmentCallback = useCallback(align => {
31
38
  return changeAlignment(align, api, INPUT_METHOD.FLOATING_TB)(editorView.state, editorView.dispatch);
32
39
  }, [editorView, api]);
@@ -1,12 +1,27 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
4
  import { ToolbarSize } from '@atlaskit/editor-common/types';
5
5
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
6
  import { changeAlignment } from '../editor-commands';
8
7
  import { ToolbarType } from '../pm-plugins/types';
9
8
  import ToolbarAlignment from './ToolbarAlignment';
9
+ const usePrimaryToolbarComponentPluginState = sharedPluginStateHookMigratorFactory(api => {
10
+ const align = useSharedPluginStateSelector(api, 'alignment.align');
11
+ const isEnabled = useSharedPluginStateSelector(api, 'alignment.isEnabled');
12
+ return {
13
+ align,
14
+ isEnabled
15
+ };
16
+ }, api => {
17
+ const {
18
+ alignmentState
19
+ } = useSharedPluginState(api, ['alignment']);
20
+ return {
21
+ align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
22
+ isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
23
+ };
24
+ });
10
25
  export function PrimaryToolbarComponent({
11
26
  api,
12
27
  editorView,
@@ -18,18 +33,9 @@ export function PrimaryToolbarComponent({
18
33
  toolbarSize = ToolbarSize.XXL
19
34
  }) {
20
35
  const {
21
- alignmentState
22
- } = useSharedPluginState(api, ['alignment'], {
23
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
24
- });
25
- const alignSelector = useSharedPluginStateSelector(api, 'alignment.align', {
26
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
27
- });
28
- const align = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? alignSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align;
29
- const isEnabledSelector = useSharedPluginStateSelector(api, 'alignment.isEnabled', {
30
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
31
- });
32
- const isEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isEnabledSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled;
36
+ align,
37
+ isEnabled
38
+ } = usePrimaryToolbarComponentPluginState(api);
33
39
  const changeAlignmentCallback = useCallback(align => changeAlignment(align, api, INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch), [editorView, api]);
34
40
  return /*#__PURE__*/React.createElement(ToolbarAlignment, {
35
41
  align: align,
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
4
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
5
5
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
6
6
  import { changeAlignment } from '../editor-commands';
@@ -10,21 +10,27 @@ var FloatingToolbarSettings = {
10
10
  disabled: false,
11
11
  isToolbarReducedSpacing: true
12
12
  };
13
+ var useFloatingToolbarComponentPluginState = sharedPluginStateHookMigratorFactory(function (api) {
14
+ var align = useSharedPluginStateSelector(api, 'alignment.align');
15
+ var isEnabled = useSharedPluginStateSelector(api, 'alignment.isEnabled');
16
+ return {
17
+ align: align,
18
+ isEnabled: isEnabled
19
+ };
20
+ }, function (api) {
21
+ var _useSharedPluginState = useSharedPluginState(api, ['alignment']),
22
+ alignmentState = _useSharedPluginState.alignmentState;
23
+ return {
24
+ align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
25
+ isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
26
+ };
27
+ });
13
28
  export function FloatingToolbarComponent(_ref) {
14
29
  var api = _ref.api,
15
30
  editorView = _ref.editorView;
16
- var _useSharedPluginState = useSharedPluginState(api, ['alignment'], {
17
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
18
- }),
19
- alignmentState = _useSharedPluginState.alignmentState;
20
- var alignSelector = useSharedPluginStateSelector(api, 'alignment.align', {
21
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
22
- });
23
- var align = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? alignSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align;
24
- var isEnabledSelector = useSharedPluginStateSelector(api, 'alignment.isEnabled', {
25
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
26
- });
27
- var isEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isEnabledSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled;
31
+ var _useFloatingToolbarCo = useFloatingToolbarComponentPluginState(api),
32
+ align = _useFloatingToolbarCo.align,
33
+ isEnabled = _useFloatingToolbarCo.isEnabled;
28
34
  var changeAlignmentCallback = useCallback(function (align) {
29
35
  return changeAlignment(align, api, INPUT_METHOD.FLOATING_TB)(editorView.state, editorView.dispatch);
30
36
  }, [editorView, api]);
@@ -1,12 +1,26 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
4
  import { ToolbarSize } from '@atlaskit/editor-common/types';
5
5
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
6
  import { changeAlignment } from '../editor-commands';
8
7
  import { ToolbarType } from '../pm-plugins/types';
9
8
  import ToolbarAlignment from './ToolbarAlignment';
9
+ var usePrimaryToolbarComponentPluginState = sharedPluginStateHookMigratorFactory(function (api) {
10
+ var align = useSharedPluginStateSelector(api, 'alignment.align');
11
+ var isEnabled = useSharedPluginStateSelector(api, 'alignment.isEnabled');
12
+ return {
13
+ align: align,
14
+ isEnabled: isEnabled
15
+ };
16
+ }, function (api) {
17
+ var _useSharedPluginState = useSharedPluginState(api, ['alignment']),
18
+ alignmentState = _useSharedPluginState.alignmentState;
19
+ return {
20
+ align: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align,
21
+ isEnabled: alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled
22
+ };
23
+ });
10
24
  export function PrimaryToolbarComponent(_ref) {
11
25
  var api = _ref.api,
12
26
  editorView = _ref.editorView,
@@ -17,18 +31,9 @@ export function PrimaryToolbarComponent(_ref) {
17
31
  isToolbarReducedSpacing = _ref.isToolbarReducedSpacing,
18
32
  _ref$toolbarSize = _ref.toolbarSize,
19
33
  toolbarSize = _ref$toolbarSize === void 0 ? ToolbarSize.XXL : _ref$toolbarSize;
20
- var _useSharedPluginState = useSharedPluginState(api, ['alignment'], {
21
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
22
- }),
23
- alignmentState = _useSharedPluginState.alignmentState;
24
- var alignSelector = useSharedPluginStateSelector(api, 'alignment.align', {
25
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
26
- });
27
- var align = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? alignSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.align;
28
- var isEnabledSelector = useSharedPluginStateSelector(api, 'alignment.isEnabled', {
29
- disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
30
- });
31
- var isEnabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isEnabledSelector : alignmentState === null || alignmentState === void 0 ? void 0 : alignmentState.isEnabled;
34
+ var _usePrimaryToolbarCom = usePrimaryToolbarComponentPluginState(api),
35
+ align = _usePrimaryToolbarCom.align,
36
+ isEnabled = _usePrimaryToolbarCom.isEnabled;
32
37
  var changeAlignmentCallback = useCallback(function (align) {
33
38
  return changeAlignment(align, api, INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
34
39
  }, [editorView, api]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-alignment",
3
- "version": "3.1.12",
3
+ "version": "3.1.14",
4
4
  "description": "Alignment plugin for @atlaskit/editor-core",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -36,15 +36,15 @@
36
36
  "dependencies": {
37
37
  "@atlaskit/adf-schema": "^47.6.0",
38
38
  "@atlaskit/css": "^0.10.0",
39
- "@atlaskit/editor-common": "^104.0.0",
39
+ "@atlaskit/editor-common": "^104.1.0",
40
40
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
41
41
  "@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
42
- "@atlaskit/editor-plugin-selection-toolbar": "^3.5.0",
42
+ "@atlaskit/editor-plugin-selection-toolbar": "^3.6.0",
43
43
  "@atlaskit/editor-prosemirror": "7.0.0",
44
44
  "@atlaskit/editor-tables": "^2.9.0",
45
- "@atlaskit/icon": "^25.6.0",
45
+ "@atlaskit/icon": "^26.0.0",
46
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
47
- "@atlaskit/tmp-editor-statsig": "^4.16.0",
47
+ "@atlaskit/tmp-editor-statsig": "^4.19.0",
48
48
  "@atlaskit/tokens": "^4.8.0",
49
49
  "@babel/runtime": "^7.0.0",
50
50
  "@compiled/react": "^0.18.3"