@atlaskit/editor-plugin-toolbar 0.0.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @atlaskit/editor-plugin-toolbar
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#199487](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/199487)
8
+ [`54098ba4cc83c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/54098ba4cc83c) -
9
+ Add LinkSection and TextSection and add logic to hide them when toolbar is pinned. Add
10
+ UserPreferencesPlugin and EditorViewModePlugin as a dependency to editor-plugin-toolbar.
11
+
12
+ ### Patch Changes
13
+
14
+ - [#199353](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/199353)
15
+ [`22cab8325fc62`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/22cab8325fc62) -
16
+ [ux] [ED-28760] Fix editor lose focus and hence editing flow is interrupted. This is done for 2
17
+ components
18
+
19
+ - Dropdown
20
+ - Create context ToolbarUIContext for toolbar consumers to access consumer specific state and
21
+ callbacks
22
+ - Define onDropdownOpenChanged callback for selection toolbars so that editor regains focus
23
+ after dropdown is closed
24
+ - Button
25
+ - Call preventDefault on mouseDown to prevent button takes away focus
26
+
27
+ - Updated dependencies
28
+
29
+ ## 0.1.0
30
+
31
+ ### Minor Changes
32
+
33
+ - [#196043](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/196043)
34
+ [`c6cb0ed855827`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c6cb0ed855827) -
35
+ Add new ShowMoreHorizontal Icon, add new ranks to support overflow menu, add pin as a menu item
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies
40
+
3
41
  ## 0.0.6
4
42
 
5
43
  ### Patch Changes
@@ -17,12 +17,18 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
+ {
21
+ "path": "../../editor-plugin-editor-viewmode/afm-cc/tsconfig.json"
22
+ },
20
23
  {
21
24
  "path": "../../editor-plugin-selection/afm-cc/tsconfig.json"
22
25
  },
23
26
  {
24
27
  "path": "../../editor-plugin-user-intent/afm-cc/tsconfig.json"
25
28
  },
29
+ {
30
+ "path": "../../editor-plugin-user-preferences/afm-cc/tsconfig.json"
31
+ },
26
32
  {
27
33
  "path": "../../editor-toolbar/afm-cc/tsconfig.json"
28
34
  },
@@ -17,12 +17,18 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
+ {
21
+ "path": "../../editor-plugin-editor-viewmode/afm-dev-agents/tsconfig.json"
22
+ },
20
23
  {
21
24
  "path": "../../editor-plugin-selection/afm-dev-agents/tsconfig.json"
22
25
  },
23
26
  {
24
27
  "path": "../../editor-plugin-user-intent/afm-dev-agents/tsconfig.json"
25
28
  },
29
+ {
30
+ "path": "../../editor-plugin-user-preferences/afm-dev-agents/tsconfig.json"
31
+ },
26
32
  {
27
33
  "path": "../../editor-toolbar/afm-dev-agents/tsconfig.json"
28
34
  },
@@ -17,12 +17,18 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
+ {
21
+ "path": "../../editor-plugin-editor-viewmode/afm-jira/tsconfig.json"
22
+ },
20
23
  {
21
24
  "path": "../../editor-plugin-selection/afm-jira/tsconfig.json"
22
25
  },
23
26
  {
24
27
  "path": "../../editor-plugin-user-intent/afm-jira/tsconfig.json"
25
28
  },
29
+ {
30
+ "path": "../../editor-plugin-user-preferences/afm-jira/tsconfig.json"
31
+ },
26
32
  {
27
33
  "path": "../../editor-toolbar/afm-jira/tsconfig.json"
28
34
  },
@@ -17,12 +17,18 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
+ {
21
+ "path": "../../editor-plugin-editor-viewmode/afm-post-office/tsconfig.json"
22
+ },
20
23
  {
21
24
  "path": "../../editor-plugin-selection/afm-post-office/tsconfig.json"
22
25
  },
23
26
  {
24
27
  "path": "../../editor-plugin-user-intent/afm-post-office/tsconfig.json"
25
28
  },
29
+ {
30
+ "path": "../../editor-plugin-user-preferences/afm-post-office/tsconfig.json"
31
+ },
26
32
  {
27
33
  "path": "../../editor-toolbar/afm-post-office/tsconfig.json"
28
34
  },
@@ -17,12 +17,18 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
+ {
21
+ "path": "../../editor-plugin-editor-viewmode/afm-rovo-extension/tsconfig.json"
22
+ },
20
23
  {
21
24
  "path": "../../editor-plugin-selection/afm-rovo-extension/tsconfig.json"
22
25
  },
23
26
  {
24
27
  "path": "../../editor-plugin-user-intent/afm-rovo-extension/tsconfig.json"
25
28
  },
29
+ {
30
+ "path": "../../editor-plugin-user-preferences/afm-rovo-extension/tsconfig.json"
31
+ },
26
32
  {
27
33
  "path": "../../editor-toolbar/afm-rovo-extension/tsconfig.json"
28
34
  },
@@ -17,12 +17,18 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
+ {
21
+ "path": "../../editor-plugin-editor-viewmode/afm-townsquare/tsconfig.json"
22
+ },
20
23
  {
21
24
  "path": "../../editor-plugin-selection/afm-townsquare/tsconfig.json"
22
25
  },
23
26
  {
24
27
  "path": "../../editor-plugin-user-intent/afm-townsquare/tsconfig.json"
25
28
  },
29
+ {
30
+ "path": "../../editor-plugin-user-preferences/afm-townsquare/tsconfig.json"
31
+ },
26
32
  {
27
33
  "path": "../../editor-toolbar/afm-townsquare/tsconfig.json"
28
34
  },
@@ -12,7 +12,7 @@ var _toolbarComponents = require("./ui/toolbar-components");
12
12
  var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
13
13
  var api = _ref.api;
14
14
  var registry = (0, _editorToolbarModel.createComponentRegistry)();
15
- registry.register((0, _toolbarComponents.getToolbarComponents)());
15
+ registry.register((0, _toolbarComponents.getToolbarComponents)(api));
16
16
  return {
17
17
  name: 'toolbar',
18
18
  actions: {
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.OverflowMenu = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactIntlNext = require("react-intl-next");
10
+ var _messages = require("@atlaskit/editor-common/messages");
11
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
12
+ var OverflowMenu = exports.OverflowMenu = function OverflowMenu(_ref) {
13
+ var children = _ref.children;
14
+ var intl = (0, _reactIntlNext.useIntl)();
15
+ var tooltipContent = intl.formatMessage(_messages.toolbarMessages.selectionToolbarOverflowMenuTooltip);
16
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarTooltip, {
17
+ content: tooltipContent,
18
+ position: "top"
19
+ }, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownMenu, {
20
+ label: tooltipContent,
21
+ iconBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.ShowMoreHorizontalIcon, {
22
+ label: ""
23
+ })
24
+ }, children));
25
+ };
@@ -45,6 +45,8 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
45
45
  }
46
46
  }, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarProvider, {
47
47
  editorView: editorView
48
+ }, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarUIProvider, {
49
+ api: api
48
50
  }, /*#__PURE__*/_react.default.createElement(_editorToolbarModel.ToolbarModelRenderer, {
49
51
  toolbar: toolbar,
50
52
  components: components,
@@ -53,7 +55,7 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
53
55
  menuSection: _editorToolbar.ToolbarDropdownItemSection,
54
56
  group: _editorToolbar.ToolbarButtonGroup
55
57
  }
56
- })));
58
+ }))));
57
59
  };
58
60
  var getDomRefFromSelection = function getDomRefFromSelection(view
59
61
  // dispatchAnalyticsEvent?: DispatchAnalyticsEvent,
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.TextSection = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _toolbar = require("@atlaskit/editor-common/toolbar");
10
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
11
+ var _editorToolbar = require("@atlaskit/editor-toolbar");
12
+ var shouldShowTextSection = function shouldShowTextSection(editMode, toolbar, toolbarDocking) {
13
+ if (editMode === 'view') {
14
+ return false;
15
+ }
16
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === _toolbar.TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
17
+ return true;
18
+ }
19
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === _toolbar.TOOLBARS.PRIMARY_TOOLBAR && toolbarDocking !== 'none') {
20
+ return true;
21
+ }
22
+ return false;
23
+ };
24
+ var TextSection = exports.TextSection = function TextSection(_ref) {
25
+ var children = _ref.children,
26
+ parents = _ref.parents,
27
+ api = _ref.api;
28
+ var editMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
29
+ var toolbarDocking = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userPreferences.preferences.toolbarDockingPosition');
30
+ var toolbar = parents.find(function (parent) {
31
+ return parent.type === 'toolbar';
32
+ });
33
+ if (!shouldShowTextSection(editMode, toolbar, toolbarDocking)) {
34
+ return null;
35
+ }
36
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarSection, {
37
+ testId: "text-section"
38
+ }, children);
39
+ };
@@ -9,7 +9,9 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _toolbar = require("@atlaskit/editor-common/toolbar");
10
10
  var _editorToolbar = require("@atlaskit/editor-toolbar");
11
11
  var _consts = require("./consts");
12
- var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents() {
12
+ var _OverflowMenu = require("./OverflowMenu");
13
+ var _TextSection = require("./TextSection");
14
+ var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(api) {
13
15
  return [{
14
16
  type: 'toolbar',
15
17
  key: _toolbar.TOOLBARS.INLINE_TEXT_TOOLBAR,
@@ -20,12 +22,61 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
20
22
  }, children);
21
23
  }
22
24
  }, {
23
- type: 'section',
24
- key: 'text-section',
25
+ type: 'toolbar',
26
+ key: _toolbar.TOOLBARS.PRIMARY_TOOLBAR,
27
+ component: function component(_ref2) {
28
+ var children = _ref2.children;
29
+ return /*#__PURE__*/_react.default.createElement(_editorToolbar.PrimaryToolbar, {
30
+ label: "Primary Toolbar"
31
+ }, children);
32
+ }
33
+ }, {
34
+ type: _toolbar.TEXT_SECTION.type,
35
+ key: _toolbar.TEXT_SECTION.key,
36
+ parents: [{
37
+ type: 'toolbar',
38
+ key: _toolbar.TOOLBARS.INLINE_TEXT_TOOLBAR,
39
+ rank: _toolbar.TOOLBAR_RANK[_toolbar.TEXT_SECTION.key]
40
+ }, {
41
+ type: 'toolbar',
42
+ key: _toolbar.TOOLBARS.PRIMARY_TOOLBAR,
43
+ rank: _toolbar.TOOLBAR_RANK[_toolbar.TEXT_SECTION.key]
44
+ }],
45
+ component: function component(_ref3) {
46
+ var children = _ref3.children,
47
+ parents = _ref3.parents;
48
+ return /*#__PURE__*/_react.default.createElement(_TextSection.TextSection, {
49
+ parents: parents,
50
+ api: api
51
+ }, children);
52
+ }
53
+ }, {
54
+ type: _toolbar.OVERFLOW_SECTION.type,
55
+ key: _toolbar.OVERFLOW_SECTION.key,
25
56
  parents: [{
26
57
  type: 'toolbar',
27
- key: 'inline-text-toolbar',
28
- rank: 200
58
+ key: _toolbar.TOOLBARS.INLINE_TEXT_TOOLBAR,
59
+ rank: _toolbar.TOOLBAR_RANK[_toolbar.OVERFLOW_SECTION.key]
60
+ }]
61
+ }, {
62
+ type: _toolbar.OVERFLOW_GROUP.type,
63
+ key: _toolbar.OVERFLOW_GROUP.key,
64
+ parents: [{
65
+ type: _toolbar.OVERFLOW_SECTION.type,
66
+ key: _toolbar.OVERFLOW_SECTION.key,
67
+ rank: _toolbar.OVERFLOW_SECTION_RANK[_toolbar.OVERFLOW_GROUP.key]
29
68
  }]
69
+ }, {
70
+ type: _toolbar.OVERFLOW_MENU.type,
71
+ key: _toolbar.OVERFLOW_MENU.key,
72
+ parents: [{
73
+ type: _toolbar.OVERFLOW_GROUP.type,
74
+ key: _toolbar.OVERFLOW_GROUP.key,
75
+ rank: _toolbar.OVERFLOW_GROUP_RANK[_toolbar.OVERFLOW_MENU.key]
76
+ }],
77
+ component: function component(_ref4) {
78
+ var children = _ref4.children;
79
+ return /*#__PURE__*/_react.default.createElement(_OverflowMenu.OverflowMenu, null, children);
80
+ }
30
81
  }];
31
82
  };
@@ -6,7 +6,7 @@ export const toolbarPlugin = ({
6
6
  api
7
7
  }) => {
8
8
  const registry = createComponentRegistry();
9
- registry.register(getToolbarComponents());
9
+ registry.register(getToolbarComponents(api));
10
10
  return {
11
11
  name: 'toolbar',
12
12
  actions: {
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { toolbarMessages } from '@atlaskit/editor-common/messages';
4
+ import { ShowMoreHorizontalIcon, ToolbarDropdownMenu, ToolbarTooltip } from '@atlaskit/editor-toolbar';
5
+ export const OverflowMenu = ({
6
+ children
7
+ }) => {
8
+ const intl = useIntl();
9
+ const tooltipContent = intl.formatMessage(toolbarMessages.selectionToolbarOverflowMenuTooltip);
10
+ return /*#__PURE__*/React.createElement(ToolbarTooltip, {
11
+ content: tooltipContent,
12
+ position: "top"
13
+ }, /*#__PURE__*/React.createElement(ToolbarDropdownMenu, {
14
+ label: tooltipContent,
15
+ iconBefore: /*#__PURE__*/React.createElement(ShowMoreHorizontalIcon, {
16
+ label: ""
17
+ })
18
+ }, children));
19
+ };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { isSSR } from '@atlaskit/editor-common/core-utils';
3
- import { EditorToolbarProvider } from '@atlaskit/editor-common/toolbar';
3
+ import { EditorToolbarProvider, EditorToolbarUIProvider } from '@atlaskit/editor-common/toolbar';
4
4
  import { Popup } from '@atlaskit/editor-common/ui';
5
5
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
6
  import { calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
@@ -35,6 +35,8 @@ export const SelectionToolbar = ({
35
35
  onPositionCalculated: position => calculateToolbarPositionTrackHead(TOOLBAR_LABEL)(editorView, position)
36
36
  }, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
37
37
  editorView: editorView
38
+ }, /*#__PURE__*/React.createElement(EditorToolbarUIProvider, {
39
+ api: api
38
40
  }, /*#__PURE__*/React.createElement(ToolbarModelRenderer, {
39
41
  toolbar: toolbar,
40
42
  components: components,
@@ -43,7 +45,7 @@ export const SelectionToolbar = ({
43
45
  menuSection: ToolbarDropdownItemSection,
44
46
  group: ToolbarButtonGroup
45
47
  }
46
- })));
48
+ }))));
47
49
  };
48
50
  const getDomRefFromSelection = (view
49
51
  // dispatchAnalyticsEvent?: DispatchAnalyticsEvent,
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { TOOLBARS } from '@atlaskit/editor-common/toolbar';
3
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
+ import { ToolbarSection } from '@atlaskit/editor-toolbar';
5
+ const shouldShowTextSection = (editMode, toolbar, toolbarDocking) => {
6
+ if (editMode === 'view') {
7
+ return false;
8
+ }
9
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
10
+ return true;
11
+ }
12
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.PRIMARY_TOOLBAR && toolbarDocking !== 'none') {
13
+ return true;
14
+ }
15
+ return false;
16
+ };
17
+ export const TextSection = ({
18
+ children,
19
+ parents,
20
+ api
21
+ }) => {
22
+ const editMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
23
+ const toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
24
+ const toolbar = parents.find(parent => parent.type === 'toolbar');
25
+ if (!shouldShowTextSection(editMode, toolbar, toolbarDocking)) {
26
+ return null;
27
+ }
28
+ return /*#__PURE__*/React.createElement(ToolbarSection, {
29
+ testId: "text-section"
30
+ }, children);
31
+ };
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
- import { TOOLBARS } from '@atlaskit/editor-common/toolbar';
3
- import { Toolbar } from '@atlaskit/editor-toolbar';
2
+ import { OVERFLOW_GROUP, OVERFLOW_GROUP_RANK, OVERFLOW_MENU, OVERFLOW_SECTION, OVERFLOW_SECTION_RANK, TEXT_SECTION, TOOLBAR_RANK, TOOLBARS } from '@atlaskit/editor-common/toolbar';
3
+ import { PrimaryToolbar, Toolbar } from '@atlaskit/editor-toolbar';
4
4
  import { TOOLBAR_LABEL } from './consts';
5
- export const getToolbarComponents = () => {
5
+ import { OverflowMenu } from './OverflowMenu';
6
+ import { TextSection } from './TextSection';
7
+ export const getToolbarComponents = api => {
6
8
  return [{
7
9
  type: 'toolbar',
8
10
  key: TOOLBARS.INLINE_TEXT_TOOLBAR,
@@ -14,12 +16,62 @@ export const getToolbarComponents = () => {
14
16
  }, children);
15
17
  }
16
18
  }, {
17
- type: 'section',
18
- key: 'text-section',
19
+ type: 'toolbar',
20
+ key: TOOLBARS.PRIMARY_TOOLBAR,
21
+ component: ({
22
+ children
23
+ }) => /*#__PURE__*/React.createElement(PrimaryToolbar, {
24
+ label: "Primary Toolbar"
25
+ }, children)
26
+ }, {
27
+ type: TEXT_SECTION.type,
28
+ key: TEXT_SECTION.key,
19
29
  parents: [{
20
30
  type: 'toolbar',
21
- key: 'inline-text-toolbar',
22
- rank: 200
31
+ key: TOOLBARS.INLINE_TEXT_TOOLBAR,
32
+ rank: TOOLBAR_RANK[TEXT_SECTION.key]
33
+ }, {
34
+ type: 'toolbar',
35
+ key: TOOLBARS.PRIMARY_TOOLBAR,
36
+ rank: TOOLBAR_RANK[TEXT_SECTION.key]
37
+ }],
38
+ component: ({
39
+ children,
40
+ parents
41
+ }) => {
42
+ return /*#__PURE__*/React.createElement(TextSection, {
43
+ parents: parents,
44
+ api: api
45
+ }, children);
46
+ }
47
+ }, {
48
+ type: OVERFLOW_SECTION.type,
49
+ key: OVERFLOW_SECTION.key,
50
+ parents: [{
51
+ type: 'toolbar',
52
+ key: TOOLBARS.INLINE_TEXT_TOOLBAR,
53
+ rank: TOOLBAR_RANK[OVERFLOW_SECTION.key]
23
54
  }]
55
+ }, {
56
+ type: OVERFLOW_GROUP.type,
57
+ key: OVERFLOW_GROUP.key,
58
+ parents: [{
59
+ type: OVERFLOW_SECTION.type,
60
+ key: OVERFLOW_SECTION.key,
61
+ rank: OVERFLOW_SECTION_RANK[OVERFLOW_GROUP.key]
62
+ }]
63
+ }, {
64
+ type: OVERFLOW_MENU.type,
65
+ key: OVERFLOW_MENU.key,
66
+ parents: [{
67
+ type: OVERFLOW_GROUP.type,
68
+ key: OVERFLOW_GROUP.key,
69
+ rank: OVERFLOW_GROUP_RANK[OVERFLOW_MENU.key]
70
+ }],
71
+ component: ({
72
+ children
73
+ }) => {
74
+ return /*#__PURE__*/React.createElement(OverflowMenu, null, children);
75
+ }
24
76
  }];
25
77
  };
@@ -5,7 +5,7 @@ import { getToolbarComponents } from './ui/toolbar-components';
5
5
  export var toolbarPlugin = function toolbarPlugin(_ref) {
6
6
  var api = _ref.api;
7
7
  var registry = createComponentRegistry();
8
- registry.register(getToolbarComponents());
8
+ registry.register(getToolbarComponents(api));
9
9
  return {
10
10
  name: 'toolbar',
11
11
  actions: {
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { toolbarMessages } from '@atlaskit/editor-common/messages';
4
+ import { ShowMoreHorizontalIcon, ToolbarDropdownMenu, ToolbarTooltip } from '@atlaskit/editor-toolbar';
5
+ export var OverflowMenu = function OverflowMenu(_ref) {
6
+ var children = _ref.children;
7
+ var intl = useIntl();
8
+ var tooltipContent = intl.formatMessage(toolbarMessages.selectionToolbarOverflowMenuTooltip);
9
+ return /*#__PURE__*/React.createElement(ToolbarTooltip, {
10
+ content: tooltipContent,
11
+ position: "top"
12
+ }, /*#__PURE__*/React.createElement(ToolbarDropdownMenu, {
13
+ label: tooltipContent,
14
+ iconBefore: /*#__PURE__*/React.createElement(ShowMoreHorizontalIcon, {
15
+ label: ""
16
+ })
17
+ }, children));
18
+ };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { isSSR } from '@atlaskit/editor-common/core-utils';
3
- import { EditorToolbarProvider } from '@atlaskit/editor-common/toolbar';
3
+ import { EditorToolbarProvider, EditorToolbarUIProvider } from '@atlaskit/editor-common/toolbar';
4
4
  import { Popup } from '@atlaskit/editor-common/ui';
5
5
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
6
  import { calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
@@ -38,6 +38,8 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
38
38
  }
39
39
  }, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
40
40
  editorView: editorView
41
+ }, /*#__PURE__*/React.createElement(EditorToolbarUIProvider, {
42
+ api: api
41
43
  }, /*#__PURE__*/React.createElement(ToolbarModelRenderer, {
42
44
  toolbar: toolbar,
43
45
  components: components,
@@ -46,7 +48,7 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
46
48
  menuSection: ToolbarDropdownItemSection,
47
49
  group: ToolbarButtonGroup
48
50
  }
49
- })));
51
+ }))));
50
52
  };
51
53
  var getDomRefFromSelection = function getDomRefFromSelection(view
52
54
  // dispatchAnalyticsEvent?: DispatchAnalyticsEvent,
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { TOOLBARS } from '@atlaskit/editor-common/toolbar';
3
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
+ import { ToolbarSection } from '@atlaskit/editor-toolbar';
5
+ var shouldShowTextSection = function shouldShowTextSection(editMode, toolbar, toolbarDocking) {
6
+ if (editMode === 'view') {
7
+ return false;
8
+ }
9
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
10
+ return true;
11
+ }
12
+ if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.PRIMARY_TOOLBAR && toolbarDocking !== 'none') {
13
+ return true;
14
+ }
15
+ return false;
16
+ };
17
+ export var TextSection = function TextSection(_ref) {
18
+ var children = _ref.children,
19
+ parents = _ref.parents,
20
+ api = _ref.api;
21
+ var editMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
22
+ var toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
23
+ var toolbar = parents.find(function (parent) {
24
+ return parent.type === 'toolbar';
25
+ });
26
+ if (!shouldShowTextSection(editMode, toolbar, toolbarDocking)) {
27
+ return null;
28
+ }
29
+ return /*#__PURE__*/React.createElement(ToolbarSection, {
30
+ testId: "text-section"
31
+ }, children);
32
+ };
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
- import { TOOLBARS } from '@atlaskit/editor-common/toolbar';
3
- import { Toolbar } from '@atlaskit/editor-toolbar';
2
+ import { OVERFLOW_GROUP, OVERFLOW_GROUP_RANK, OVERFLOW_MENU, OVERFLOW_SECTION, OVERFLOW_SECTION_RANK, TEXT_SECTION, TOOLBAR_RANK, TOOLBARS } from '@atlaskit/editor-common/toolbar';
3
+ import { PrimaryToolbar, Toolbar } from '@atlaskit/editor-toolbar';
4
4
  import { TOOLBAR_LABEL } from './consts';
5
- export var getToolbarComponents = function getToolbarComponents() {
5
+ import { OverflowMenu } from './OverflowMenu';
6
+ import { TextSection } from './TextSection';
7
+ export var getToolbarComponents = function getToolbarComponents(api) {
6
8
  return [{
7
9
  type: 'toolbar',
8
10
  key: TOOLBARS.INLINE_TEXT_TOOLBAR,
@@ -13,12 +15,61 @@ export var getToolbarComponents = function getToolbarComponents() {
13
15
  }, children);
14
16
  }
15
17
  }, {
16
- type: 'section',
17
- key: 'text-section',
18
+ type: 'toolbar',
19
+ key: TOOLBARS.PRIMARY_TOOLBAR,
20
+ component: function component(_ref2) {
21
+ var children = _ref2.children;
22
+ return /*#__PURE__*/React.createElement(PrimaryToolbar, {
23
+ label: "Primary Toolbar"
24
+ }, children);
25
+ }
26
+ }, {
27
+ type: TEXT_SECTION.type,
28
+ key: TEXT_SECTION.key,
29
+ parents: [{
30
+ type: 'toolbar',
31
+ key: TOOLBARS.INLINE_TEXT_TOOLBAR,
32
+ rank: TOOLBAR_RANK[TEXT_SECTION.key]
33
+ }, {
34
+ type: 'toolbar',
35
+ key: TOOLBARS.PRIMARY_TOOLBAR,
36
+ rank: TOOLBAR_RANK[TEXT_SECTION.key]
37
+ }],
38
+ component: function component(_ref3) {
39
+ var children = _ref3.children,
40
+ parents = _ref3.parents;
41
+ return /*#__PURE__*/React.createElement(TextSection, {
42
+ parents: parents,
43
+ api: api
44
+ }, children);
45
+ }
46
+ }, {
47
+ type: OVERFLOW_SECTION.type,
48
+ key: OVERFLOW_SECTION.key,
18
49
  parents: [{
19
50
  type: 'toolbar',
20
- key: 'inline-text-toolbar',
21
- rank: 200
51
+ key: TOOLBARS.INLINE_TEXT_TOOLBAR,
52
+ rank: TOOLBAR_RANK[OVERFLOW_SECTION.key]
53
+ }]
54
+ }, {
55
+ type: OVERFLOW_GROUP.type,
56
+ key: OVERFLOW_GROUP.key,
57
+ parents: [{
58
+ type: OVERFLOW_SECTION.type,
59
+ key: OVERFLOW_SECTION.key,
60
+ rank: OVERFLOW_SECTION_RANK[OVERFLOW_GROUP.key]
22
61
  }]
62
+ }, {
63
+ type: OVERFLOW_MENU.type,
64
+ key: OVERFLOW_MENU.key,
65
+ parents: [{
66
+ type: OVERFLOW_GROUP.type,
67
+ key: OVERFLOW_GROUP.key,
68
+ rank: OVERFLOW_GROUP_RANK[OVERFLOW_MENU.key]
69
+ }],
70
+ component: function component(_ref4) {
71
+ var children = _ref4.children;
72
+ return /*#__PURE__*/React.createElement(OverflowMenu, null, children);
73
+ }
23
74
  }];
24
75
  };
@@ -1,9 +1,16 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
2
3
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
3
4
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
5
+ import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
4
6
  import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
5
7
  export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
6
- dependencies: [OptionalPlugin<UserIntentPlugin>, OptionalPlugin<SelectionPlugin>];
8
+ dependencies: [
9
+ OptionalPlugin<UserIntentPlugin>,
10
+ OptionalPlugin<SelectionPlugin>,
11
+ OptionalPlugin<UserPreferencesPlugin>,
12
+ OptionalPlugin<EditorViewModePlugin>
13
+ ];
7
14
  actions: {
8
15
  registerComponents: (toolbarComponents: Array<RegisterComponent>) => void;
9
16
  getComponents: () => Array<RegisterComponent>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const OverflowMenu: ({ children }: {
3
+ children: React.ReactNode;
4
+ }) => React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
4
+ import type { ToolbarPlugin } from '../toolbarPluginType';
5
+ type TextSectionProps = {
6
+ children: React.ReactNode;
7
+ parents: ToolbarComponentTypes;
8
+ api?: ExtractInjectionAPI<ToolbarPlugin>;
9
+ };
10
+ export declare const TextSection: ({ children, parents, api }: TextSectionProps) => React.JSX.Element | null;
11
+ export {};
@@ -1,2 +1,4 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
2
  import { type RegisterComponent } from '@atlaskit/editor-toolbar-model';
2
- export declare const getToolbarComponents: () => RegisterComponent[];
3
+ import type { ToolbarPlugin } from '../toolbarPluginType';
4
+ export declare const getToolbarComponents: (api?: ExtractInjectionAPI<ToolbarPlugin>) => RegisterComponent[];
@@ -1,11 +1,15 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
2
3
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
3
4
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
5
+ import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
4
6
  import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
5
7
  export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
6
8
  dependencies: [
7
9
  OptionalPlugin<UserIntentPlugin>,
8
- OptionalPlugin<SelectionPlugin>
10
+ OptionalPlugin<SelectionPlugin>,
11
+ OptionalPlugin<UserPreferencesPlugin>,
12
+ OptionalPlugin<EditorViewModePlugin>
9
13
  ];
10
14
  actions: {
11
15
  registerComponents: (toolbarComponents: Array<RegisterComponent>) => void;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const OverflowMenu: ({ children }: {
3
+ children: React.ReactNode;
4
+ }) => React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
+ import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
4
+ import type { ToolbarPlugin } from '../toolbarPluginType';
5
+ type TextSectionProps = {
6
+ children: React.ReactNode;
7
+ parents: ToolbarComponentTypes;
8
+ api?: ExtractInjectionAPI<ToolbarPlugin>;
9
+ };
10
+ export declare const TextSection: ({ children, parents, api }: TextSectionProps) => React.JSX.Element | null;
11
+ export {};
@@ -1,2 +1,4 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
2
  import { type RegisterComponent } from '@atlaskit/editor-toolbar-model';
2
- export declare const getToolbarComponents: () => RegisterComponent[];
3
+ import type { ToolbarPlugin } from '../toolbarPluginType';
4
+ export declare const getToolbarComponents: (api?: ExtractInjectionAPI<ToolbarPlugin>) => RegisterComponent[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-toolbar",
3
- "version": "0.0.6",
3
+ "version": "0.2.0",
4
4
  "description": "Toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,15 +31,18 @@
31
31
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
+ "@atlaskit/editor-plugin-editor-viewmode": "^5.0.0",
34
35
  "@atlaskit/editor-plugin-selection": "^3.0.0",
35
36
  "@atlaskit/editor-plugin-user-intent": "^1.1.0",
37
+ "@atlaskit/editor-plugin-user-preferences": "^1.2.0",
36
38
  "@atlaskit/editor-prosemirror": "7.0.0",
37
- "@atlaskit/editor-toolbar": "^0.0.10",
38
- "@atlaskit/editor-toolbar-model": "^0.0.4",
39
- "@babel/runtime": "^7.0.0"
39
+ "@atlaskit/editor-toolbar": "^0.2.0",
40
+ "@atlaskit/editor-toolbar-model": "^0.1.0",
41
+ "@babel/runtime": "^7.0.0",
42
+ "react-intl-next": "npm:react-intl@^5.18.1"
40
43
  },
41
44
  "peerDependencies": {
42
- "@atlaskit/editor-common": "^107.18.0",
45
+ "@atlaskit/editor-common": "^107.20.0",
43
46
  "react": "^18.2.0"
44
47
  },
45
48
  "techstack": {