@atlaskit/editor-plugin-toolbar 3.3.3 → 3.4.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 +13 -0
- package/afm-products/tsconfig.json +60 -0
- package/dist/cjs/toolbarPlugin.js +7 -2
- package/dist/cjs/ui/Section.js +10 -2
- package/dist/cjs/ui/toolbar-components.js +28 -4
- package/dist/es2019/toolbarPlugin.js +6 -2
- package/dist/es2019/ui/Section.js +10 -2
- package/dist/es2019/ui/toolbar-components.js +28 -4
- package/dist/esm/toolbarPlugin.js +7 -2
- package/dist/esm/ui/Section.js +10 -2
- package/dist/esm/ui/toolbar-components.js +28 -4
- package/dist/types/toolbarPluginType.d.ts +13 -0
- package/dist/types/types/index.d.ts +53 -0
- package/dist/types/ui/toolbar-components.d.ts +2 -1
- package/dist/types-ts4.5/toolbarPluginType.d.ts +13 -0
- package/dist/types-ts4.5/types/index.d.ts +53 -0
- package/dist/types-ts4.5/ui/toolbar-components.d.ts +2 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-toolbar
|
|
2
2
|
|
|
3
|
+
## 3.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`301c7dd0ccdd2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/301c7dd0ccdd2) -
|
|
8
|
+
Adds new `contextualFormattingEnabled` plugin option to editor-plugin-toolbar. This has 3 options
|
|
9
|
+
(always-inline, always-pinned and controlled) to allow direct control over toolbar placement in
|
|
10
|
+
the editor.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 3.3.3
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.entry-points.products.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"outDir": "../../../../../tsDist/@atlaskit__editor-plugin-toolbar/app",
|
|
6
|
+
"rootDir": "../",
|
|
7
|
+
"composite": true
|
|
8
|
+
},
|
|
9
|
+
"include": [
|
|
10
|
+
"../src/**/*.ts",
|
|
11
|
+
"../src/**/*.tsx"
|
|
12
|
+
],
|
|
13
|
+
"exclude": [
|
|
14
|
+
"../src/**/__tests__/*",
|
|
15
|
+
"../src/**/*.test.*",
|
|
16
|
+
"../src/**/test.*",
|
|
17
|
+
"../src/**/examples.*"
|
|
18
|
+
],
|
|
19
|
+
"references": [
|
|
20
|
+
{
|
|
21
|
+
"path": "../../../helpers/browser-apis/afm-products/tsconfig.json"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "../../editor-plugin-analytics/afm-products/tsconfig.json"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "../../editor-plugin-connectivity/afm-products/tsconfig.json"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "../../editor-plugin-editor-viewmode/afm-products/tsconfig.json"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"path": "../../editor-plugin-selection/afm-products/tsconfig.json"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "../../editor-plugin-user-intent/afm-products/tsconfig.json"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"path": "../../editor-plugin-user-preferences/afm-products/tsconfig.json"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "../../editor-toolbar/afm-products/tsconfig.json"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"path": "../../editor-toolbar-model/afm-products/tsconfig.json"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"path": "../../../platform/feature-flags/afm-products/tsconfig.json"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"path": "../../../platform/feature-flags-react/afm-products/tsconfig.json"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"path": "../../tmp-editor-statsig/afm-products/tsconfig.json"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"path": "../../editor-common/afm-products/tsconfig.json"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
@@ -78,9 +78,11 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
78
78
|
var popupsMountPointRef = {};
|
|
79
79
|
var editorViewDomRef = {};
|
|
80
80
|
var disableSelectionToolbar = config.disableSelectionToolbar,
|
|
81
|
-
disableSelectionToolbarWhenPinned = config.disableSelectionToolbarWhenPinned
|
|
81
|
+
disableSelectionToolbarWhenPinned = config.disableSelectionToolbarWhenPinned,
|
|
82
|
+
_config$contextualFor = config.contextualFormattingEnabled,
|
|
83
|
+
contextualFormattingEnabled = _config$contextualFor === void 0 ? 'always-pinned' : _config$contextualFor;
|
|
82
84
|
var registry = (0, _editorToolbarModel.createComponentRegistry)();
|
|
83
|
-
registry.register((0, _toolbarComponents.getToolbarComponents)(api, disableSelectionToolbar));
|
|
85
|
+
registry.register((0, _toolbarComponents.getToolbarComponents)(contextualFormattingEnabled, api, disableSelectionToolbar));
|
|
84
86
|
return {
|
|
85
87
|
name: 'toolbar',
|
|
86
88
|
actions: {
|
|
@@ -94,6 +96,9 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
94
96
|
},
|
|
95
97
|
getComponents: function getComponents() {
|
|
96
98
|
return registry.components;
|
|
99
|
+
},
|
|
100
|
+
contextualFormattingMode: function contextualFormattingMode() {
|
|
101
|
+
return contextualFormattingEnabled;
|
|
97
102
|
}
|
|
98
103
|
},
|
|
99
104
|
getSharedState: function getSharedState(editorState) {
|
package/dist/cjs/ui/Section.js
CHANGED
|
@@ -9,14 +9,22 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
10
10
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
11
11
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
13
|
var _platformFeatureFlagsReact = require("@atlaskit/platform-feature-flags-react");
|
|
13
14
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
15
|
var shouldShowSection = function shouldShowSection(editMode, toolbar, toolbarDocking, disableSelectionToolbar) {
|
|
15
16
|
if (editMode === 'view') {
|
|
16
17
|
return false;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This check is no longer needed with plugin config changes, the selection toolbar will not be registered and so
|
|
22
|
+
* no components will render
|
|
23
|
+
*/
|
|
24
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_toolbar_aifc_placement_config')) {
|
|
25
|
+
if (disableSelectionToolbar) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
20
28
|
}
|
|
21
29
|
if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === _toolbar.TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
|
|
22
30
|
return true;
|
|
@@ -10,6 +10,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
12
12
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
15
|
var _consts = require("./consts");
|
|
15
16
|
var _OverflowMenu = require("./OverflowMenu");
|
|
@@ -17,8 +18,8 @@ var _OverflowSection = require("./OverflowSection");
|
|
|
17
18
|
var _PrimaryToolbar = require("./PrimaryToolbar");
|
|
18
19
|
var _Section = require("./Section");
|
|
19
20
|
var _TextCollapsedMenu = require("./TextCollapsedMenu");
|
|
20
|
-
var
|
|
21
|
-
|
|
21
|
+
var getInlineTextToolbarComponents = function getInlineTextToolbarComponents() {
|
|
22
|
+
return [{
|
|
22
23
|
type: 'toolbar',
|
|
23
24
|
key: _toolbar.TOOLBARS.INLINE_TEXT_TOOLBAR,
|
|
24
25
|
component: function component(_ref) {
|
|
@@ -29,7 +30,10 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
|
|
|
29
30
|
testId: (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_5', 'isEnabled', true) ? 'editor-floating-toolbar' : undefined
|
|
30
31
|
}, children);
|
|
31
32
|
}
|
|
32
|
-
}
|
|
33
|
+
}];
|
|
34
|
+
};
|
|
35
|
+
var getPrimaryToolbarComponents = function getPrimaryToolbarComponents() {
|
|
36
|
+
return [{
|
|
33
37
|
type: 'toolbar',
|
|
34
38
|
key: _toolbar.TOOLBARS.PRIMARY_TOOLBAR,
|
|
35
39
|
component: (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? _PrimaryToolbar.PrimaryToolbar : function (_ref2) {
|
|
@@ -39,7 +43,10 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
|
|
|
39
43
|
testId: "primary-toolbar"
|
|
40
44
|
}, children);
|
|
41
45
|
}
|
|
42
|
-
}
|
|
46
|
+
}];
|
|
47
|
+
};
|
|
48
|
+
var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(contextualFormattingEnabled, api, disableSelectionToolbar) {
|
|
49
|
+
var components = [{
|
|
43
50
|
type: _toolbar.TEXT_SECTION.type,
|
|
44
51
|
key: _toolbar.TEXT_SECTION.key,
|
|
45
52
|
parents: [{
|
|
@@ -249,5 +256,22 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
|
|
|
249
256
|
}
|
|
250
257
|
});
|
|
251
258
|
}
|
|
259
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_aifc_placement_config')) {
|
|
260
|
+
switch (contextualFormattingEnabled) {
|
|
261
|
+
case 'always-inline':
|
|
262
|
+
components.unshift.apply(components, (0, _toConsumableArray2.default)(getInlineTextToolbarComponents()));
|
|
263
|
+
break;
|
|
264
|
+
case 'always-pinned':
|
|
265
|
+
components.unshift.apply(components, (0, _toConsumableArray2.default)(getPrimaryToolbarComponents()));
|
|
266
|
+
break;
|
|
267
|
+
case 'controlled':
|
|
268
|
+
components.unshift.apply(components, (0, _toConsumableArray2.default)(getInlineTextToolbarComponents()));
|
|
269
|
+
components.unshift.apply(components, (0, _toConsumableArray2.default)(getPrimaryToolbarComponents()));
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
components.unshift.apply(components, (0, _toConsumableArray2.default)(getInlineTextToolbarComponents()));
|
|
274
|
+
components.unshift.apply(components, (0, _toConsumableArray2.default)(getPrimaryToolbarComponents()));
|
|
275
|
+
}
|
|
252
276
|
return components;
|
|
253
277
|
};
|
|
@@ -64,10 +64,11 @@ export const toolbarPlugin = ({
|
|
|
64
64
|
const editorViewDomRef = {};
|
|
65
65
|
const {
|
|
66
66
|
disableSelectionToolbar,
|
|
67
|
-
disableSelectionToolbarWhenPinned
|
|
67
|
+
disableSelectionToolbarWhenPinned,
|
|
68
|
+
contextualFormattingEnabled = 'always-pinned'
|
|
68
69
|
} = config;
|
|
69
70
|
const registry = createComponentRegistry();
|
|
70
|
-
registry.register(getToolbarComponents(api, disableSelectionToolbar));
|
|
71
|
+
registry.register(getToolbarComponents(contextualFormattingEnabled, api, disableSelectionToolbar));
|
|
71
72
|
return {
|
|
72
73
|
name: 'toolbar',
|
|
73
74
|
actions: {
|
|
@@ -80,6 +81,9 @@ export const toolbarPlugin = ({
|
|
|
80
81
|
},
|
|
81
82
|
getComponents: () => {
|
|
82
83
|
return registry.components;
|
|
84
|
+
},
|
|
85
|
+
contextualFormattingMode: () => {
|
|
86
|
+
return contextualFormattingEnabled;
|
|
83
87
|
}
|
|
84
88
|
},
|
|
85
89
|
getSharedState(editorState) {
|
|
@@ -2,14 +2,22 @@ import React from 'react';
|
|
|
2
2
|
import { TOOLBARS, useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
3
3
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
4
|
import { ToolbarSection, SeparatorPosition } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
6
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
const shouldShowSection = (editMode, toolbar, toolbarDocking, disableSelectionToolbar) => {
|
|
8
9
|
if (editMode === 'view') {
|
|
9
10
|
return false;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This check is no longer needed with plugin config changes, the selection toolbar will not be registered and so
|
|
15
|
+
* no components will render
|
|
16
|
+
*/
|
|
17
|
+
if (!fg('platform_editor_toolbar_aifc_placement_config')) {
|
|
18
|
+
if (disableSelectionToolbar) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
13
21
|
}
|
|
14
22
|
if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
|
|
15
23
|
return true;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { INSERT_BLOCK_SECTION, LINKING_SECTION, OVERFLOW_GROUP, OVERFLOW_GROUP_PRIMARY_TOOLBAR, OVERFLOW_GROUP_PRIMARY_TOOLBAR_RANK, OVERFLOW_GROUP_RANK, OVERFLOW_MENU, OVERFLOW_MENU_PRIMARY_TOOLBAR, OVERFLOW_SECTION, OVERFLOW_SECTION_PRIMARY_TOOLBAR, OVERFLOW_SECTION_PRIMARY_TOOLBAR_RANK, OVERFLOW_SECTION_RANK, PIN_SECTION, TEXT_COLLAPSED_GROUP, TEXT_SECTION, TEXT_SECTION_PRIMARY_TOOLBAR, TEXT_SECTION_COLLAPSED, TEXT_COLLAPSED_MENU, TOOLBAR_RANK, TOOLBARS } from '@atlaskit/editor-common/toolbar';
|
|
4
4
|
import { PrimaryToolbar as PrimaryToolbarBase, Show, Toolbar } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
7
|
import { SELECTION_TOOLBAR_LABEL } from './consts';
|
|
7
8
|
import { OverflowMenu } from './OverflowMenu';
|
|
@@ -9,8 +10,8 @@ import { OverflowSection } from './OverflowSection';
|
|
|
9
10
|
import { PrimaryToolbar } from './PrimaryToolbar';
|
|
10
11
|
import { Section } from './Section';
|
|
11
12
|
import { TextCollapsedMenu } from './TextCollapsedMenu';
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const getInlineTextToolbarComponents = () => {
|
|
14
|
+
return [{
|
|
14
15
|
type: 'toolbar',
|
|
15
16
|
key: TOOLBARS.INLINE_TEXT_TOOLBAR,
|
|
16
17
|
component: ({
|
|
@@ -22,7 +23,10 @@ export const getToolbarComponents = (api, disableSelectionToolbar) => {
|
|
|
22
23
|
testId: expValEquals('platform_editor_toolbar_aifc_patch_5', 'isEnabled', true) ? 'editor-floating-toolbar' : undefined
|
|
23
24
|
}, children);
|
|
24
25
|
}
|
|
25
|
-
}
|
|
26
|
+
}];
|
|
27
|
+
};
|
|
28
|
+
const getPrimaryToolbarComponents = () => {
|
|
29
|
+
return [{
|
|
26
30
|
type: 'toolbar',
|
|
27
31
|
key: TOOLBARS.PRIMARY_TOOLBAR,
|
|
28
32
|
component: expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? PrimaryToolbar : ({
|
|
@@ -31,7 +35,10 @@ export const getToolbarComponents = (api, disableSelectionToolbar) => {
|
|
|
31
35
|
label: "Primary Toolbar",
|
|
32
36
|
testId: "primary-toolbar"
|
|
33
37
|
}, children)
|
|
34
|
-
}
|
|
38
|
+
}];
|
|
39
|
+
};
|
|
40
|
+
export const getToolbarComponents = (contextualFormattingEnabled, api, disableSelectionToolbar) => {
|
|
41
|
+
const components = [{
|
|
35
42
|
type: TEXT_SECTION.type,
|
|
36
43
|
key: TEXT_SECTION.key,
|
|
37
44
|
parents: [{
|
|
@@ -245,5 +252,22 @@ export const getToolbarComponents = (api, disableSelectionToolbar) => {
|
|
|
245
252
|
}
|
|
246
253
|
});
|
|
247
254
|
}
|
|
255
|
+
if (fg('platform_editor_toolbar_aifc_placement_config')) {
|
|
256
|
+
switch (contextualFormattingEnabled) {
|
|
257
|
+
case 'always-inline':
|
|
258
|
+
components.unshift(...getInlineTextToolbarComponents());
|
|
259
|
+
break;
|
|
260
|
+
case 'always-pinned':
|
|
261
|
+
components.unshift(...getPrimaryToolbarComponents());
|
|
262
|
+
break;
|
|
263
|
+
case 'controlled':
|
|
264
|
+
components.unshift(...getInlineTextToolbarComponents());
|
|
265
|
+
components.unshift(...getPrimaryToolbarComponents());
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
components.unshift(...getInlineTextToolbarComponents());
|
|
270
|
+
components.unshift(...getPrimaryToolbarComponents());
|
|
271
|
+
}
|
|
248
272
|
return components;
|
|
249
273
|
};
|
|
@@ -71,9 +71,11 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
71
71
|
var popupsMountPointRef = {};
|
|
72
72
|
var editorViewDomRef = {};
|
|
73
73
|
var disableSelectionToolbar = config.disableSelectionToolbar,
|
|
74
|
-
disableSelectionToolbarWhenPinned = config.disableSelectionToolbarWhenPinned
|
|
74
|
+
disableSelectionToolbarWhenPinned = config.disableSelectionToolbarWhenPinned,
|
|
75
|
+
_config$contextualFor = config.contextualFormattingEnabled,
|
|
76
|
+
contextualFormattingEnabled = _config$contextualFor === void 0 ? 'always-pinned' : _config$contextualFor;
|
|
75
77
|
var registry = createComponentRegistry();
|
|
76
|
-
registry.register(getToolbarComponents(api, disableSelectionToolbar));
|
|
78
|
+
registry.register(getToolbarComponents(contextualFormattingEnabled, api, disableSelectionToolbar));
|
|
77
79
|
return {
|
|
78
80
|
name: 'toolbar',
|
|
79
81
|
actions: {
|
|
@@ -87,6 +89,9 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
87
89
|
},
|
|
88
90
|
getComponents: function getComponents() {
|
|
89
91
|
return registry.components;
|
|
92
|
+
},
|
|
93
|
+
contextualFormattingMode: function contextualFormattingMode() {
|
|
94
|
+
return contextualFormattingEnabled;
|
|
90
95
|
}
|
|
91
96
|
},
|
|
92
97
|
getSharedState: function getSharedState(editorState) {
|
package/dist/esm/ui/Section.js
CHANGED
|
@@ -2,14 +2,22 @@ import React from 'react';
|
|
|
2
2
|
import { TOOLBARS, useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
3
3
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
4
|
import { ToolbarSection, SeparatorPosition } from '@atlaskit/editor-toolbar';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { conditionalHooksFactory } from '@atlaskit/platform-feature-flags-react';
|
|
6
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
var shouldShowSection = function shouldShowSection(editMode, toolbar, toolbarDocking, disableSelectionToolbar) {
|
|
8
9
|
if (editMode === 'view') {
|
|
9
10
|
return false;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This check is no longer needed with plugin config changes, the selection toolbar will not be registered and so
|
|
15
|
+
* no components will render
|
|
16
|
+
*/
|
|
17
|
+
if (!fg('platform_editor_toolbar_aifc_placement_config')) {
|
|
18
|
+
if (disableSelectionToolbar) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
13
21
|
}
|
|
14
22
|
if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
|
|
15
23
|
return true;
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { INSERT_BLOCK_SECTION, LINKING_SECTION, OVERFLOW_GROUP, OVERFLOW_GROUP_PRIMARY_TOOLBAR, OVERFLOW_GROUP_PRIMARY_TOOLBAR_RANK, OVERFLOW_GROUP_RANK, OVERFLOW_MENU, OVERFLOW_MENU_PRIMARY_TOOLBAR, OVERFLOW_SECTION, OVERFLOW_SECTION_PRIMARY_TOOLBAR, OVERFLOW_SECTION_PRIMARY_TOOLBAR_RANK, OVERFLOW_SECTION_RANK, PIN_SECTION, TEXT_COLLAPSED_GROUP, TEXT_SECTION, TEXT_SECTION_PRIMARY_TOOLBAR, TEXT_SECTION_COLLAPSED, TEXT_COLLAPSED_MENU, TOOLBAR_RANK, TOOLBARS } from '@atlaskit/editor-common/toolbar';
|
|
5
5
|
import { PrimaryToolbar as PrimaryToolbarBase, Show, Toolbar } from '@atlaskit/editor-toolbar';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
import { SELECTION_TOOLBAR_LABEL } from './consts';
|
|
8
9
|
import { OverflowMenu } from './OverflowMenu';
|
|
@@ -10,8 +11,8 @@ import { OverflowSection } from './OverflowSection';
|
|
|
10
11
|
import { PrimaryToolbar } from './PrimaryToolbar';
|
|
11
12
|
import { Section } from './Section';
|
|
12
13
|
import { TextCollapsedMenu } from './TextCollapsedMenu';
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
var getInlineTextToolbarComponents = function getInlineTextToolbarComponents() {
|
|
15
|
+
return [{
|
|
15
16
|
type: 'toolbar',
|
|
16
17
|
key: TOOLBARS.INLINE_TEXT_TOOLBAR,
|
|
17
18
|
component: function component(_ref) {
|
|
@@ -22,7 +23,10 @@ export var getToolbarComponents = function getToolbarComponents(api, disableSele
|
|
|
22
23
|
testId: expValEquals('platform_editor_toolbar_aifc_patch_5', 'isEnabled', true) ? 'editor-floating-toolbar' : undefined
|
|
23
24
|
}, children);
|
|
24
25
|
}
|
|
25
|
-
}
|
|
26
|
+
}];
|
|
27
|
+
};
|
|
28
|
+
var getPrimaryToolbarComponents = function getPrimaryToolbarComponents() {
|
|
29
|
+
return [{
|
|
26
30
|
type: 'toolbar',
|
|
27
31
|
key: TOOLBARS.PRIMARY_TOOLBAR,
|
|
28
32
|
component: expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? PrimaryToolbar : function (_ref2) {
|
|
@@ -32,7 +36,10 @@ export var getToolbarComponents = function getToolbarComponents(api, disableSele
|
|
|
32
36
|
testId: "primary-toolbar"
|
|
33
37
|
}, children);
|
|
34
38
|
}
|
|
35
|
-
}
|
|
39
|
+
}];
|
|
40
|
+
};
|
|
41
|
+
export var getToolbarComponents = function getToolbarComponents(contextualFormattingEnabled, api, disableSelectionToolbar) {
|
|
42
|
+
var components = [{
|
|
36
43
|
type: TEXT_SECTION.type,
|
|
37
44
|
key: TEXT_SECTION.key,
|
|
38
45
|
parents: [{
|
|
@@ -242,5 +249,22 @@ export var getToolbarComponents = function getToolbarComponents(api, disableSele
|
|
|
242
249
|
}
|
|
243
250
|
});
|
|
244
251
|
}
|
|
252
|
+
if (fg('platform_editor_toolbar_aifc_placement_config')) {
|
|
253
|
+
switch (contextualFormattingEnabled) {
|
|
254
|
+
case 'always-inline':
|
|
255
|
+
components.unshift.apply(components, _toConsumableArray(getInlineTextToolbarComponents()));
|
|
256
|
+
break;
|
|
257
|
+
case 'always-pinned':
|
|
258
|
+
components.unshift.apply(components, _toConsumableArray(getPrimaryToolbarComponents()));
|
|
259
|
+
break;
|
|
260
|
+
case 'controlled':
|
|
261
|
+
components.unshift.apply(components, _toConsumableArray(getInlineTextToolbarComponents()));
|
|
262
|
+
components.unshift.apply(components, _toConsumableArray(getPrimaryToolbarComponents()));
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
components.unshift.apply(components, _toConsumableArray(getInlineTextToolbarComponents()));
|
|
267
|
+
components.unshift.apply(components, _toConsumableArray(getPrimaryToolbarComponents()));
|
|
268
|
+
}
|
|
245
269
|
return components;
|
|
246
270
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ContextualFormattingEnabledOptions } from '@atlaskit/editor-common/toolbar';
|
|
1
2
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
4
|
import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
@@ -19,6 +20,18 @@ export type EditorToolbarPluginState = {
|
|
|
19
20
|
};
|
|
20
21
|
export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
|
|
21
22
|
actions: {
|
|
23
|
+
/**
|
|
24
|
+
* Returns the current contextual formatting toolbar mode configuration.
|
|
25
|
+
*
|
|
26
|
+
* This method retrieves the active setting that determines the behavior and placement
|
|
27
|
+
* of the contextual formatting toolbar in the editor.
|
|
28
|
+
*
|
|
29
|
+
* @returns The active contextual formatting mode:
|
|
30
|
+
* - `always-inline`: Formatting controls appear in a floating toolbar near selected text
|
|
31
|
+
* - `always-pinned`: Formatting controls are pinned to the top toolbar (default)
|
|
32
|
+
* - `controlled`: Both inline and primary toolbars are available
|
|
33
|
+
*/
|
|
34
|
+
contextualFormattingMode: () => ContextualFormattingEnabledOptions;
|
|
22
35
|
getComponents: () => Array<RegisterComponent>;
|
|
23
36
|
registerComponents: RegisterComponentsAction;
|
|
24
37
|
};
|
|
@@ -1,5 +1,58 @@
|
|
|
1
|
+
import type { ContextualFormattingEnabledOptions } from '@atlaskit/editor-common/toolbar';
|
|
1
2
|
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
2
3
|
export type ToolbarPluginOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Controls which toolbars are available for in the editor.
|
|
6
|
+
*
|
|
7
|
+
* The contextual formatting toolbar provides text formatting options (bold, italic, links, etc.)
|
|
8
|
+
* that appear contextually based on user selection and interaction.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This option determines where and when the formatting toolbar is displayed:
|
|
12
|
+
* - **Primary Toolbar**: The toolbar mounted at the top of the editor that is always visible
|
|
13
|
+
* - **Inline Text Toolbar**: A floating toolbar that appears near the selected text
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* // Always show formatting controls in a floating (inline) toolbar near selection
|
|
18
|
+
* const toolbarPlugin = createToolbarPlugin({
|
|
19
|
+
* contextualFormattingEnabled: 'always-inline',
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // Always show formatting controls pinned to the top (primary) toolbar
|
|
26
|
+
* const toolbarPlugin = createToolbarPlugin({
|
|
27
|
+
* contextualFormattingEnabled: 'always-pinned',
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* // Allow dynamic control of toolbar placement (both inline and primary available)
|
|
34
|
+
* const toolbarPlugin = createToolbarPlugin({
|
|
35
|
+
* contextualFormattingEnabled: 'controlled',
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
contextualFormattingEnabled?: ContextualFormattingEnabledOptions;
|
|
42
|
+
/**
|
|
43
|
+
* @private
|
|
44
|
+
* @deprecated
|
|
45
|
+
* @description
|
|
46
|
+
* This option is deprecated and will be removed in the future, replaced with `contextualFormattingEnabled`.
|
|
47
|
+
*
|
|
48
|
+
* To disable the selection toolbar (so only the primary toolbar is shown), use `contextualFormattingEnabled: 'always-pinned'`.
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const toolbarPlugin = createToolbarPlugin({
|
|
52
|
+
* contextualFormattingEnabled: 'always-inline',
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
3
56
|
disableSelectionToolbar?: boolean;
|
|
4
57
|
disableSelectionToolbarWhenPinned?: boolean;
|
|
5
58
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { ContextualFormattingEnabledOptions } from '@atlaskit/editor-common/toolbar';
|
|
1
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
3
|
import { type RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
3
4
|
import type { ToolbarPlugin } from '../toolbarPluginType';
|
|
4
|
-
export declare const getToolbarComponents: (api?: ExtractInjectionAPI<ToolbarPlugin>, disableSelectionToolbar?: boolean) => RegisterComponent[];
|
|
5
|
+
export declare const getToolbarComponents: (contextualFormattingEnabled: ContextualFormattingEnabledOptions, api?: ExtractInjectionAPI<ToolbarPlugin>, disableSelectionToolbar?: boolean) => RegisterComponent[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ContextualFormattingEnabledOptions } from '@atlaskit/editor-common/toolbar';
|
|
1
2
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
4
|
import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
@@ -19,6 +20,18 @@ export type EditorToolbarPluginState = {
|
|
|
19
20
|
};
|
|
20
21
|
export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
|
|
21
22
|
actions: {
|
|
23
|
+
/**
|
|
24
|
+
* Returns the current contextual formatting toolbar mode configuration.
|
|
25
|
+
*
|
|
26
|
+
* This method retrieves the active setting that determines the behavior and placement
|
|
27
|
+
* of the contextual formatting toolbar in the editor.
|
|
28
|
+
*
|
|
29
|
+
* @returns The active contextual formatting mode:
|
|
30
|
+
* - `always-inline`: Formatting controls appear in a floating toolbar near selected text
|
|
31
|
+
* - `always-pinned`: Formatting controls are pinned to the top toolbar (default)
|
|
32
|
+
* - `controlled`: Both inline and primary toolbars are available
|
|
33
|
+
*/
|
|
34
|
+
contextualFormattingMode: () => ContextualFormattingEnabledOptions;
|
|
22
35
|
getComponents: () => Array<RegisterComponent>;
|
|
23
36
|
registerComponents: RegisterComponentsAction;
|
|
24
37
|
};
|
|
@@ -1,5 +1,58 @@
|
|
|
1
|
+
import type { ContextualFormattingEnabledOptions } from '@atlaskit/editor-common/toolbar';
|
|
1
2
|
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
2
3
|
export type ToolbarPluginOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Controls which toolbars are available for in the editor.
|
|
6
|
+
*
|
|
7
|
+
* The contextual formatting toolbar provides text formatting options (bold, italic, links, etc.)
|
|
8
|
+
* that appear contextually based on user selection and interaction.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This option determines where and when the formatting toolbar is displayed:
|
|
12
|
+
* - **Primary Toolbar**: The toolbar mounted at the top of the editor that is always visible
|
|
13
|
+
* - **Inline Text Toolbar**: A floating toolbar that appears near the selected text
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* // Always show formatting controls in a floating (inline) toolbar near selection
|
|
18
|
+
* const toolbarPlugin = createToolbarPlugin({
|
|
19
|
+
* contextualFormattingEnabled: 'always-inline',
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* // Always show formatting controls pinned to the top (primary) toolbar
|
|
26
|
+
* const toolbarPlugin = createToolbarPlugin({
|
|
27
|
+
* contextualFormattingEnabled: 'always-pinned',
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* // Allow dynamic control of toolbar placement (both inline and primary available)
|
|
34
|
+
* const toolbarPlugin = createToolbarPlugin({
|
|
35
|
+
* contextualFormattingEnabled: 'controlled',
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
contextualFormattingEnabled?: ContextualFormattingEnabledOptions;
|
|
42
|
+
/**
|
|
43
|
+
* @private
|
|
44
|
+
* @deprecated
|
|
45
|
+
* @description
|
|
46
|
+
* This option is deprecated and will be removed in the future, replaced with `contextualFormattingEnabled`.
|
|
47
|
+
*
|
|
48
|
+
* To disable the selection toolbar (so only the primary toolbar is shown), use `contextualFormattingEnabled: 'always-pinned'`.
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const toolbarPlugin = createToolbarPlugin({
|
|
52
|
+
* contextualFormattingEnabled: 'always-inline',
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
3
56
|
disableSelectionToolbar?: boolean;
|
|
4
57
|
disableSelectionToolbarWhenPinned?: boolean;
|
|
5
58
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { ContextualFormattingEnabledOptions } from '@atlaskit/editor-common/toolbar';
|
|
1
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
3
|
import { type RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
3
4
|
import type { ToolbarPlugin } from '../toolbarPluginType';
|
|
4
|
-
export declare const getToolbarComponents: (api?: ExtractInjectionAPI<ToolbarPlugin>, disableSelectionToolbar?: boolean) => RegisterComponent[];
|
|
5
|
+
export declare const getToolbarComponents: (contextualFormattingEnabled: ContextualFormattingEnabledOptions, api?: ExtractInjectionAPI<ToolbarPlugin>, disableSelectionToolbar?: boolean) => RegisterComponent[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-toolbar",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@atlaskit/editor-common": "^110.
|
|
49
|
+
"@atlaskit/editor-common": "^110.18.0",
|
|
50
50
|
"react": "^18.2.0"
|
|
51
51
|
},
|
|
52
52
|
"platform-feature-flags": {
|
|
@@ -55,6 +55,9 @@
|
|
|
55
55
|
},
|
|
56
56
|
"platform_editor_toolbar_aifc_user_intent_fix": {
|
|
57
57
|
"type": "boolean"
|
|
58
|
+
},
|
|
59
|
+
"platform_editor_toolbar_aifc_placement_config": {
|
|
60
|
+
"type": "boolean"
|
|
58
61
|
}
|
|
59
62
|
},
|
|
60
63
|
"techstack": {
|