@atlaskit/editor-plugin-block-type 5.1.16 → 5.1.18
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 +14 -0
- package/dist/cjs/pm-plugins/ui/FloatingToolbarComponent.js +30 -34
- package/dist/cjs/pm-plugins/ui/PrimaryToolbarComponent.js +30 -35
- package/dist/es2019/pm-plugins/ui/FloatingToolbarComponent.js +32 -35
- package/dist/es2019/pm-plugins/ui/PrimaryToolbarComponent.js +32 -36
- package/dist/esm/pm-plugins/ui/FloatingToolbarComponent.js +31 -35
- package/dist/esm/pm-plugins/ui/PrimaryToolbarComponent.js +31 -36
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# @atlaskit/editor-plugin-block-type
|
2
2
|
|
3
|
+
## 5.1.18
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#152650](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/152650)
|
8
|
+
[`d5514d2d48aef`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d5514d2d48aef) -
|
9
|
+
Refactor to use sharedPluginStateHookMigratorFactory
|
10
|
+
|
11
|
+
## 5.1.17
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- Updated dependencies
|
16
|
+
|
3
17
|
## 5.1.16
|
4
18
|
|
5
19
|
### Patch Changes
|
@@ -20,42 +20,38 @@ var FloatingToolbarSettings = {
|
|
20
20
|
isToolbarReducedSpacing: true,
|
21
21
|
shouldUseDefaultRole: false
|
22
22
|
};
|
23
|
+
var useFloatingToolbarComponentPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
|
24
|
+
var currentBlockType = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.currentBlockType');
|
25
|
+
var blockTypesDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.blockTypesDisabled');
|
26
|
+
var availableBlockTypes = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypes');
|
27
|
+
var availableBlockTypesInDropdown = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypesInDropdown');
|
28
|
+
var formattingIsPresent = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.formattingIsPresent');
|
29
|
+
return {
|
30
|
+
currentBlockType: currentBlockType,
|
31
|
+
blockTypesDisabled: blockTypesDisabled,
|
32
|
+
availableBlockTypes: availableBlockTypes,
|
33
|
+
availableBlockTypesInDropdown: availableBlockTypesInDropdown,
|
34
|
+
formattingIsPresent: formattingIsPresent
|
35
|
+
};
|
36
|
+
}, function (api) {
|
37
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockType']),
|
38
|
+
blockTypeState = _useSharedPluginState.blockTypeState;
|
39
|
+
return {
|
40
|
+
currentBlockType: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType,
|
41
|
+
blockTypesDisabled: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled,
|
42
|
+
availableBlockTypes: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes,
|
43
|
+
availableBlockTypesInDropdown: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown,
|
44
|
+
formattingIsPresent: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent
|
45
|
+
};
|
46
|
+
});
|
23
47
|
function FloatingToolbarComponent(_ref) {
|
24
48
|
var api = _ref.api;
|
25
|
-
var
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
var currentBlockTypeSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.currentBlockType', {
|
32
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
33
|
-
});
|
34
|
-
var currentBlockType = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
|
35
|
-
|
36
|
-
// blockTypesDisabled
|
37
|
-
var blockTypesDisabledSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.blockTypesDisabled', {
|
38
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
39
|
-
});
|
40
|
-
var blockTypesDisabled = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
|
41
|
-
|
42
|
-
// availableBlockTypes
|
43
|
-
var availableBlockTypesSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypes', {
|
44
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
45
|
-
});
|
46
|
-
var availableBlockTypes = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
|
47
|
-
|
48
|
-
// availableBlockTypesInDropdown
|
49
|
-
var availableBlockTypesInDropdownSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypesInDropdown', {
|
50
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
51
|
-
});
|
52
|
-
var availableBlockTypesInDropdown = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
|
53
|
-
|
54
|
-
// formattingIsPresent
|
55
|
-
var formattingIsPresentSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.formattingIsPresent', {
|
56
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
57
|
-
});
|
58
|
-
var formattingIsPresent = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
|
49
|
+
var _useFloatingToolbarCo = useFloatingToolbarComponentPluginState(api),
|
50
|
+
currentBlockType = _useFloatingToolbarCo.currentBlockType,
|
51
|
+
blockTypesDisabled = _useFloatingToolbarCo.blockTypesDisabled,
|
52
|
+
availableBlockTypes = _useFloatingToolbarCo.availableBlockTypes,
|
53
|
+
availableBlockTypesInDropdown = _useFloatingToolbarCo.availableBlockTypesInDropdown,
|
54
|
+
formattingIsPresent = _useFloatingToolbarCo.formattingIsPresent;
|
59
55
|
var boundSetBlockType = (0, _react.useCallback)(function (name) {
|
60
56
|
var _api$core, _api$blockType;
|
61
57
|
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, _analytics.INPUT_METHOD.FLOATING_TB));
|
@@ -9,8 +9,31 @@ var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
10
10
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
11
11
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
12
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
13
12
|
var _ToolbarBlockType = _interopRequireDefault(require("./ToolbarBlockType"));
|
13
|
+
var usePrimaryToolbarComponentPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
|
14
|
+
var currentBlockType = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.currentBlockType');
|
15
|
+
var blockTypesDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.blockTypesDisabled');
|
16
|
+
var availableBlockTypes = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypes');
|
17
|
+
var availableBlockTypesInDropdown = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypesInDropdown');
|
18
|
+
var formattingIsPresent = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.formattingIsPresent');
|
19
|
+
return {
|
20
|
+
currentBlockType: currentBlockType,
|
21
|
+
blockTypesDisabled: blockTypesDisabled,
|
22
|
+
availableBlockTypes: availableBlockTypes,
|
23
|
+
availableBlockTypesInDropdown: availableBlockTypesInDropdown,
|
24
|
+
formattingIsPresent: formattingIsPresent
|
25
|
+
};
|
26
|
+
}, function (api) {
|
27
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['blockType']),
|
28
|
+
blockTypeState = _useSharedPluginState.blockTypeState;
|
29
|
+
return {
|
30
|
+
currentBlockType: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType,
|
31
|
+
blockTypesDisabled: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled,
|
32
|
+
availableBlockTypes: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes,
|
33
|
+
availableBlockTypesInDropdown: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown,
|
34
|
+
formattingIsPresent: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent
|
35
|
+
};
|
36
|
+
});
|
14
37
|
function PrimaryToolbarComponent(_ref) {
|
15
38
|
var api = _ref.api,
|
16
39
|
isSmall = _ref.isSmall,
|
@@ -20,40 +43,12 @@ function PrimaryToolbarComponent(_ref) {
|
|
20
43
|
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
21
44
|
popupsScrollableElement = _ref.popupsScrollableElement,
|
22
45
|
shouldUseDefaultRole = _ref.shouldUseDefaultRole;
|
23
|
-
var
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
var currentBlockTypeSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.currentBlockType', {
|
30
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
31
|
-
});
|
32
|
-
var currentBlockType = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
|
33
|
-
|
34
|
-
// blockTypesDisabled
|
35
|
-
var blockTypesDisabledSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.blockTypesDisabled', {
|
36
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
37
|
-
});
|
38
|
-
var blockTypesDisabled = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
|
39
|
-
|
40
|
-
// availableBlockTypes
|
41
|
-
var availableBlockTypesSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypes', {
|
42
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
43
|
-
});
|
44
|
-
var availableBlockTypes = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
|
45
|
-
|
46
|
-
// availableBlockTypesInDropdown
|
47
|
-
var availableBlockTypesInDropdownSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.availableBlockTypesInDropdown', {
|
48
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
49
|
-
});
|
50
|
-
var availableBlockTypesInDropdown = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
|
51
|
-
|
52
|
-
// formattingIsPresent
|
53
|
-
var formattingIsPresentSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'blockType.formattingIsPresent', {
|
54
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
55
|
-
});
|
56
|
-
var formattingIsPresent = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
|
46
|
+
var _usePrimaryToolbarCom = usePrimaryToolbarComponentPluginState(api),
|
47
|
+
currentBlockType = _usePrimaryToolbarCom.currentBlockType,
|
48
|
+
blockTypesDisabled = _usePrimaryToolbarCom.blockTypesDisabled,
|
49
|
+
availableBlockTypes = _usePrimaryToolbarCom.availableBlockTypes,
|
50
|
+
availableBlockTypesInDropdown = _usePrimaryToolbarCom.availableBlockTypesInDropdown,
|
51
|
+
formattingIsPresent = _usePrimaryToolbarCom.formattingIsPresent;
|
57
52
|
var boundSetBlockType = function boundSetBlockType(name, fromBlockQuote) {
|
58
53
|
var _api$core, _api$blockType;
|
59
54
|
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, _analytics.INPUT_METHOD.TOOLBAR, fromBlockQuote));
|
@@ -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 ToolbarBlockType from './ToolbarBlockType';
|
@@ -10,44 +10,41 @@ const FloatingToolbarSettings = {
|
|
10
10
|
isToolbarReducedSpacing: true,
|
11
11
|
shouldUseDefaultRole: false
|
12
12
|
};
|
13
|
+
const useFloatingToolbarComponentPluginState = sharedPluginStateHookMigratorFactory(api => {
|
14
|
+
const currentBlockType = useSharedPluginStateSelector(api, 'blockType.currentBlockType');
|
15
|
+
const blockTypesDisabled = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled');
|
16
|
+
const availableBlockTypes = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes');
|
17
|
+
const availableBlockTypesInDropdown = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown');
|
18
|
+
const formattingIsPresent = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent');
|
19
|
+
return {
|
20
|
+
currentBlockType,
|
21
|
+
blockTypesDisabled,
|
22
|
+
availableBlockTypes,
|
23
|
+
availableBlockTypesInDropdown,
|
24
|
+
formattingIsPresent
|
25
|
+
};
|
26
|
+
}, api => {
|
27
|
+
const {
|
28
|
+
blockTypeState
|
29
|
+
} = useSharedPluginState(api, ['blockType']);
|
30
|
+
return {
|
31
|
+
currentBlockType: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType,
|
32
|
+
blockTypesDisabled: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled,
|
33
|
+
availableBlockTypes: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes,
|
34
|
+
availableBlockTypesInDropdown: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown,
|
35
|
+
formattingIsPresent: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent
|
36
|
+
};
|
37
|
+
});
|
13
38
|
export function FloatingToolbarComponent({
|
14
39
|
api
|
15
40
|
}) {
|
16
41
|
const {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
const currentBlockTypeSelector = useSharedPluginStateSelector(api, 'blockType.currentBlockType', {
|
24
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
25
|
-
});
|
26
|
-
const currentBlockType = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
|
27
|
-
|
28
|
-
// blockTypesDisabled
|
29
|
-
const blockTypesDisabledSelector = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled', {
|
30
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
31
|
-
});
|
32
|
-
const blockTypesDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
|
33
|
-
|
34
|
-
// availableBlockTypes
|
35
|
-
const availableBlockTypesSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes', {
|
36
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
37
|
-
});
|
38
|
-
const availableBlockTypes = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
|
39
|
-
|
40
|
-
// availableBlockTypesInDropdown
|
41
|
-
const availableBlockTypesInDropdownSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown', {
|
42
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
43
|
-
});
|
44
|
-
const availableBlockTypesInDropdown = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
|
45
|
-
|
46
|
-
// formattingIsPresent
|
47
|
-
const formattingIsPresentSelector = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent', {
|
48
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
49
|
-
});
|
50
|
-
const formattingIsPresent = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
|
42
|
+
currentBlockType,
|
43
|
+
blockTypesDisabled,
|
44
|
+
availableBlockTypes,
|
45
|
+
availableBlockTypesInDropdown,
|
46
|
+
formattingIsPresent
|
47
|
+
} = useFloatingToolbarComponentPluginState(api);
|
51
48
|
const boundSetBlockType = useCallback(name => {
|
52
49
|
var _api$core, _api$blockType, _api$blockType$comman;
|
53
50
|
return api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : (_api$blockType$comman = _api$blockType.commands) === null || _api$blockType$comman === void 0 ? void 0 : _api$blockType$comman.setTextLevel(name, INPUT_METHOD.FLOATING_TB));
|
@@ -1,9 +1,33 @@
|
|
1
1
|
import React 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
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
6
5
|
import ToolbarBlockType from './ToolbarBlockType';
|
6
|
+
const usePrimaryToolbarComponentPluginState = sharedPluginStateHookMigratorFactory(api => {
|
7
|
+
const currentBlockType = useSharedPluginStateSelector(api, 'blockType.currentBlockType');
|
8
|
+
const blockTypesDisabled = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled');
|
9
|
+
const availableBlockTypes = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes');
|
10
|
+
const availableBlockTypesInDropdown = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown');
|
11
|
+
const formattingIsPresent = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent');
|
12
|
+
return {
|
13
|
+
currentBlockType,
|
14
|
+
blockTypesDisabled,
|
15
|
+
availableBlockTypes,
|
16
|
+
availableBlockTypesInDropdown,
|
17
|
+
formattingIsPresent
|
18
|
+
};
|
19
|
+
}, api => {
|
20
|
+
const {
|
21
|
+
blockTypeState
|
22
|
+
} = useSharedPluginState(api, ['blockType']);
|
23
|
+
return {
|
24
|
+
currentBlockType: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType,
|
25
|
+
blockTypesDisabled: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled,
|
26
|
+
availableBlockTypes: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes,
|
27
|
+
availableBlockTypesInDropdown: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown,
|
28
|
+
formattingIsPresent: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent
|
29
|
+
};
|
30
|
+
});
|
7
31
|
export function PrimaryToolbarComponent({
|
8
32
|
api,
|
9
33
|
isSmall,
|
@@ -15,40 +39,12 @@ export function PrimaryToolbarComponent({
|
|
15
39
|
shouldUseDefaultRole
|
16
40
|
}) {
|
17
41
|
const {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const currentBlockTypeSelector = useSharedPluginStateSelector(api, 'blockType.currentBlockType', {
|
25
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
26
|
-
});
|
27
|
-
const currentBlockType = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
|
28
|
-
|
29
|
-
// blockTypesDisabled
|
30
|
-
const blockTypesDisabledSelector = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled', {
|
31
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
32
|
-
});
|
33
|
-
const blockTypesDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
|
34
|
-
|
35
|
-
// availableBlockTypes
|
36
|
-
const availableBlockTypesSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes', {
|
37
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
38
|
-
});
|
39
|
-
const availableBlockTypes = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
|
40
|
-
|
41
|
-
// availableBlockTypesInDropdown
|
42
|
-
const availableBlockTypesInDropdownSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown', {
|
43
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
44
|
-
});
|
45
|
-
const availableBlockTypesInDropdown = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
|
46
|
-
|
47
|
-
// formattingIsPresent
|
48
|
-
const formattingIsPresentSelector = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent', {
|
49
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
50
|
-
});
|
51
|
-
const formattingIsPresent = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
|
42
|
+
currentBlockType,
|
43
|
+
blockTypesDisabled,
|
44
|
+
availableBlockTypes,
|
45
|
+
availableBlockTypesInDropdown,
|
46
|
+
formattingIsPresent
|
47
|
+
} = usePrimaryToolbarComponentPluginState(api);
|
52
48
|
const boundSetBlockType = (name, fromBlockQuote) => {
|
53
49
|
var _api$core, _api$blockType, _api$blockType$comman;
|
54
50
|
return api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : (_api$blockType$comman = _api$blockType.commands) === null || _api$blockType$comman === void 0 ? void 0 : _api$blockType$comman.setTextLevel(name, INPUT_METHOD.TOOLBAR, fromBlockQuote));
|
@@ -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 ToolbarBlockType from './ToolbarBlockType';
|
@@ -10,42 +10,38 @@ var FloatingToolbarSettings = {
|
|
10
10
|
isToolbarReducedSpacing: true,
|
11
11
|
shouldUseDefaultRole: false
|
12
12
|
};
|
13
|
+
var useFloatingToolbarComponentPluginState = sharedPluginStateHookMigratorFactory(function (api) {
|
14
|
+
var currentBlockType = useSharedPluginStateSelector(api, 'blockType.currentBlockType');
|
15
|
+
var blockTypesDisabled = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled');
|
16
|
+
var availableBlockTypes = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes');
|
17
|
+
var availableBlockTypesInDropdown = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown');
|
18
|
+
var formattingIsPresent = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent');
|
19
|
+
return {
|
20
|
+
currentBlockType: currentBlockType,
|
21
|
+
blockTypesDisabled: blockTypesDisabled,
|
22
|
+
availableBlockTypes: availableBlockTypes,
|
23
|
+
availableBlockTypesInDropdown: availableBlockTypesInDropdown,
|
24
|
+
formattingIsPresent: formattingIsPresent
|
25
|
+
};
|
26
|
+
}, function (api) {
|
27
|
+
var _useSharedPluginState = useSharedPluginState(api, ['blockType']),
|
28
|
+
blockTypeState = _useSharedPluginState.blockTypeState;
|
29
|
+
return {
|
30
|
+
currentBlockType: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType,
|
31
|
+
blockTypesDisabled: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled,
|
32
|
+
availableBlockTypes: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes,
|
33
|
+
availableBlockTypesInDropdown: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown,
|
34
|
+
formattingIsPresent: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent
|
35
|
+
};
|
36
|
+
});
|
13
37
|
export function FloatingToolbarComponent(_ref) {
|
14
38
|
var api = _ref.api;
|
15
|
-
var
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
var currentBlockTypeSelector = useSharedPluginStateSelector(api, 'blockType.currentBlockType', {
|
22
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
23
|
-
});
|
24
|
-
var currentBlockType = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
|
25
|
-
|
26
|
-
// blockTypesDisabled
|
27
|
-
var blockTypesDisabledSelector = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled', {
|
28
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
29
|
-
});
|
30
|
-
var blockTypesDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
|
31
|
-
|
32
|
-
// availableBlockTypes
|
33
|
-
var availableBlockTypesSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes', {
|
34
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
35
|
-
});
|
36
|
-
var availableBlockTypes = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
|
37
|
-
|
38
|
-
// availableBlockTypesInDropdown
|
39
|
-
var availableBlockTypesInDropdownSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown', {
|
40
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
41
|
-
});
|
42
|
-
var availableBlockTypesInDropdown = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
|
43
|
-
|
44
|
-
// formattingIsPresent
|
45
|
-
var formattingIsPresentSelector = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent', {
|
46
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
47
|
-
});
|
48
|
-
var formattingIsPresent = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
|
39
|
+
var _useFloatingToolbarCo = useFloatingToolbarComponentPluginState(api),
|
40
|
+
currentBlockType = _useFloatingToolbarCo.currentBlockType,
|
41
|
+
blockTypesDisabled = _useFloatingToolbarCo.blockTypesDisabled,
|
42
|
+
availableBlockTypes = _useFloatingToolbarCo.availableBlockTypes,
|
43
|
+
availableBlockTypesInDropdown = _useFloatingToolbarCo.availableBlockTypesInDropdown,
|
44
|
+
formattingIsPresent = _useFloatingToolbarCo.formattingIsPresent;
|
49
45
|
var boundSetBlockType = useCallback(function (name) {
|
50
46
|
var _api$core, _api$blockType;
|
51
47
|
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, INPUT_METHOD.FLOATING_TB));
|
@@ -1,9 +1,32 @@
|
|
1
1
|
import React 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
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
6
5
|
import ToolbarBlockType from './ToolbarBlockType';
|
6
|
+
var usePrimaryToolbarComponentPluginState = sharedPluginStateHookMigratorFactory(function (api) {
|
7
|
+
var currentBlockType = useSharedPluginStateSelector(api, 'blockType.currentBlockType');
|
8
|
+
var blockTypesDisabled = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled');
|
9
|
+
var availableBlockTypes = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes');
|
10
|
+
var availableBlockTypesInDropdown = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown');
|
11
|
+
var formattingIsPresent = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent');
|
12
|
+
return {
|
13
|
+
currentBlockType: currentBlockType,
|
14
|
+
blockTypesDisabled: blockTypesDisabled,
|
15
|
+
availableBlockTypes: availableBlockTypes,
|
16
|
+
availableBlockTypesInDropdown: availableBlockTypesInDropdown,
|
17
|
+
formattingIsPresent: formattingIsPresent
|
18
|
+
};
|
19
|
+
}, function (api) {
|
20
|
+
var _useSharedPluginState = useSharedPluginState(api, ['blockType']),
|
21
|
+
blockTypeState = _useSharedPluginState.blockTypeState;
|
22
|
+
return {
|
23
|
+
currentBlockType: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType,
|
24
|
+
blockTypesDisabled: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled,
|
25
|
+
availableBlockTypes: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes,
|
26
|
+
availableBlockTypesInDropdown: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown,
|
27
|
+
formattingIsPresent: blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent
|
28
|
+
};
|
29
|
+
});
|
7
30
|
export function PrimaryToolbarComponent(_ref) {
|
8
31
|
var api = _ref.api,
|
9
32
|
isSmall = _ref.isSmall,
|
@@ -13,40 +36,12 @@ export function PrimaryToolbarComponent(_ref) {
|
|
13
36
|
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
14
37
|
popupsScrollableElement = _ref.popupsScrollableElement,
|
15
38
|
shouldUseDefaultRole = _ref.shouldUseDefaultRole;
|
16
|
-
var
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
var currentBlockTypeSelector = useSharedPluginStateSelector(api, 'blockType.currentBlockType', {
|
23
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
24
|
-
});
|
25
|
-
var currentBlockType = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? currentBlockTypeSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.currentBlockType;
|
26
|
-
|
27
|
-
// blockTypesDisabled
|
28
|
-
var blockTypesDisabledSelector = useSharedPluginStateSelector(api, 'blockType.blockTypesDisabled', {
|
29
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
30
|
-
});
|
31
|
-
var blockTypesDisabled = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? blockTypesDisabledSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.blockTypesDisabled;
|
32
|
-
|
33
|
-
// availableBlockTypes
|
34
|
-
var availableBlockTypesSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypes', {
|
35
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
36
|
-
});
|
37
|
-
var availableBlockTypes = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypes;
|
38
|
-
|
39
|
-
// availableBlockTypesInDropdown
|
40
|
-
var availableBlockTypesInDropdownSelector = useSharedPluginStateSelector(api, 'blockType.availableBlockTypesInDropdown', {
|
41
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
42
|
-
});
|
43
|
-
var availableBlockTypesInDropdown = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? availableBlockTypesInDropdownSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.availableBlockTypesInDropdown;
|
44
|
-
|
45
|
-
// formattingIsPresent
|
46
|
-
var formattingIsPresentSelector = useSharedPluginStateSelector(api, 'blockType.formattingIsPresent', {
|
47
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
48
|
-
});
|
49
|
-
var formattingIsPresent = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? formattingIsPresentSelector : blockTypeState === null || blockTypeState === void 0 ? void 0 : blockTypeState.formattingIsPresent;
|
39
|
+
var _usePrimaryToolbarCom = usePrimaryToolbarComponentPluginState(api),
|
40
|
+
currentBlockType = _usePrimaryToolbarCom.currentBlockType,
|
41
|
+
blockTypesDisabled = _usePrimaryToolbarCom.blockTypesDisabled,
|
42
|
+
availableBlockTypes = _usePrimaryToolbarCom.availableBlockTypes,
|
43
|
+
availableBlockTypesInDropdown = _usePrimaryToolbarCom.availableBlockTypesInDropdown,
|
44
|
+
formattingIsPresent = _usePrimaryToolbarCom.formattingIsPresent;
|
50
45
|
var boundSetBlockType = function boundSetBlockType(name, fromBlockQuote) {
|
51
46
|
var _api$core, _api$blockType;
|
52
47
|
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 || (_api$blockType = _api$blockType.commands) === null || _api$blockType === void 0 ? void 0 : _api$blockType.setTextLevel(name, INPUT_METHOD.TOOLBAR, fromBlockQuote));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atlaskit/editor-plugin-block-type",
|
3
|
-
"version": "5.1.
|
3
|
+
"version": "5.1.18",
|
4
4
|
"description": "BlockType plugin for @atlaskit/editor-core",
|
5
5
|
"author": "Atlassian Pty Ltd",
|
6
6
|
"license": "Apache-2.0",
|
@@ -36,20 +36,20 @@
|
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
38
|
"@atlaskit/adf-schema": "^47.6.0",
|
39
|
-
"@atlaskit/editor-common": "^104.
|
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.
|
42
|
+
"@atlaskit/editor-plugin-selection-toolbar": "^3.6.0",
|
43
43
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
44
44
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
45
45
|
"@atlaskit/editor-tables": "^2.9.0",
|
46
|
-
"@atlaskit/icon": "^
|
47
|
-
"@atlaskit/icon-lab": "^4.
|
46
|
+
"@atlaskit/icon": "^26.0.0",
|
47
|
+
"@atlaskit/icon-lab": "^4.12.0",
|
48
48
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
49
49
|
"@atlaskit/primitives": "^14.7.0",
|
50
50
|
"@atlaskit/prosemirror-input-rules": "^3.3.0",
|
51
51
|
"@atlaskit/theme": "^18.0.0",
|
52
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
52
|
+
"@atlaskit/tmp-editor-statsig": "^4.19.0",
|
53
53
|
"@atlaskit/tokens": "^4.8.0",
|
54
54
|
"@babel/runtime": "^7.0.0",
|
55
55
|
"@emotion/react": "^11.7.1"
|