@atlaskit/editor-core 189.4.1 → 189.4.3

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/plugins/index.js +0 -7
  3. package/dist/cjs/presets/universal.js +2 -1
  4. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
  5. package/dist/cjs/version-wrapper.js +1 -1
  6. package/dist/es2019/plugins/index.js +0 -1
  7. package/dist/es2019/presets/universal.js +2 -1
  8. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
  9. package/dist/es2019/version-wrapper.js +1 -1
  10. package/dist/esm/plugins/index.js +0 -1
  11. package/dist/esm/presets/universal.js +2 -1
  12. package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
  13. package/dist/esm/version-wrapper.js +1 -1
  14. package/dist/types/plugins/index.d.ts +0 -1
  15. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  16. package/package.json +16 -7
  17. package/dist/cjs/plugins/toolbar-lists-indentation/index.js +0 -91
  18. package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -56
  19. package/dist/cjs/plugins/toolbar-lists-indentation/types.js +0 -5
  20. package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -135
  21. package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -168
  22. package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +0 -63
  23. package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -53
  24. package/dist/es2019/plugins/toolbar-lists-indentation/index.js +0 -86
  25. package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -53
  26. package/dist/es2019/plugins/toolbar-lists-indentation/types.js +0 -1
  27. package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -123
  28. package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -158
  29. package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +0 -58
  30. package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -46
  31. package/dist/esm/plugins/toolbar-lists-indentation/index.js +0 -83
  32. package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -50
  33. package/dist/esm/plugins/toolbar-lists-indentation/types.js +0 -1
  34. package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -124
  35. package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -161
  36. package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +0 -56
  37. package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -47
  38. package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +0 -33
  39. package/dist/types/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +0 -19
  40. package/dist/types/plugins/toolbar-lists-indentation/types.d.ts +0 -20
  41. package/dist/types/plugins/toolbar-lists-indentation/ui/Toolbar.d.ts +0 -4
  42. package/dist/types/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.d.ts +0 -9
  43. package/dist/types/plugins/toolbar-lists-indentation/ui/index.d.ts +0 -26
  44. package/dist/types/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +0 -9
  45. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/index.d.ts +0 -33
  46. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +0 -19
  47. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/types.d.ts +0 -20
  48. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/Toolbar.d.ts +0 -4
  49. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.d.ts +0 -9
  50. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/index.d.ts +0 -26
  51. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +0 -9
@@ -1,158 +0,0 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- import React from 'react';
4
- import { useIntl } from 'react-intl-next';
5
- import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
6
- import BulletListIcon from '@atlaskit/icon/glyph/editor/bullet-list';
7
- import { toggleBulletList as toggleBulletListKeymap, toggleOrderedList as toggleOrderedListKeymap, indent as toggleIndentKeymap, outdent as toggleOutdentKeymap, tooltip } from '../../../keymaps';
8
- import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
9
- import ToolbarButton from '../../../ui/ToolbarButton';
10
- import { shortcutStyle } from '../../../ui/styles';
11
- import { expandIconWrapperStyle } from '@atlaskit/editor-common/styles';
12
- import { wrapperStyle, separatorStyles } from '@atlaskit/editor-common/styles';
13
- import { listMessages, indentationMessages } from '@atlaskit/editor-common/messages';
14
- export function ToolbarDropdown(props) {
15
- const {
16
- formatMessage
17
- } = useIntl();
18
- const {
19
- disabled,
20
- isReducedSpacing,
21
- bulletListActive,
22
- orderedListActive,
23
- popupsMountPoint,
24
- popupsBoundariesElement,
25
- popupsScrollableElement,
26
- onItemActivated
27
- } = props;
28
- const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);
29
- const [isOpenedByKeyboard, setOpenedByKeyboard] = React.useState(false);
30
- const labelLists = formatMessage(listMessages.lists);
31
- const onOpenChange = attrs => {
32
- setIsDropdownOpen(attrs.isDropdownOpen);
33
- };
34
- const handleTriggerClick = () => {
35
- onOpenChange({
36
- isDropdownOpen: !isDropdownOpen
37
- });
38
- };
39
- const handleOnKeyDown = event => {
40
- if (event.key === 'Enter' || event.key === ' ') {
41
- event.preventDefault();
42
- setIsDropdownOpen(!isDropdownOpen);
43
- setOpenedByKeyboard(true);
44
- }
45
- };
46
- const items = useItems(props);
47
- const handleOnItemActivated = ({
48
- item,
49
- shouldCloseMenu = true
50
- }) => {
51
- setIsDropdownOpen(!shouldCloseMenu);
52
- return onItemActivated({
53
- editorView: props.editorView,
54
- buttonName: item.value.name
55
- });
56
- };
57
- return jsx("span", {
58
- css: wrapperStyle
59
- }, jsx(DropdownMenu, {
60
- items: items,
61
- onItemActivated: handleOnItemActivated,
62
- mountTo: popupsMountPoint,
63
- boundariesElement: popupsBoundariesElement,
64
- scrollableElement: popupsScrollableElement,
65
- isOpen: isDropdownOpen,
66
- onOpenChange: onOpenChange,
67
- fitHeight: 188,
68
- fitWidth: 175,
69
- shouldUseDefaultRole: true,
70
- shouldFocusFirstItem: () => {
71
- if (isOpenedByKeyboard) {
72
- setOpenedByKeyboard(false);
73
- }
74
- return isOpenedByKeyboard;
75
- }
76
- }, jsx(ToolbarButton, {
77
- spacing: isReducedSpacing ? 'none' : 'default',
78
- selected: bulletListActive || orderedListActive,
79
- "aria-expanded": isDropdownOpen,
80
- "aria-haspopup": true,
81
- "aria-label": labelLists,
82
- disabled: disabled,
83
- onClick: handleTriggerClick,
84
- onKeyDown: handleOnKeyDown,
85
- title: labelLists,
86
- iconBefore: jsx("span", {
87
- css: wrapperStyle
88
- }, jsx(BulletListIcon, {
89
- label: labelLists
90
- }), jsx("span", {
91
- css: expandIconWrapperStyle
92
- }, jsx(ExpandIcon, {
93
- label: ""
94
- })))
95
- })), jsx("span", {
96
- css: separatorStyles
97
- }));
98
- }
99
- function useItems(props) {
100
- const {
101
- formatMessage
102
- } = useIntl();
103
- const labelUnorderedList = formatMessage(listMessages.unorderedList);
104
- const labelOrderedList = formatMessage(listMessages.orderedList);
105
- let items = [{
106
- key: 'unorderedList',
107
- content: labelUnorderedList,
108
- value: {
109
- name: 'bullet_list'
110
- },
111
- isDisabled: props.bulletListDisabled,
112
- isActive: Boolean(props.bulletListActive),
113
- elemAfter: jsx("div", {
114
- css: shortcutStyle
115
- }, tooltip(toggleBulletListKeymap))
116
- }, {
117
- key: 'orderedList',
118
- content: labelOrderedList,
119
- value: {
120
- name: 'ordered_list'
121
- },
122
- isDisabled: props.orderedListDisabled,
123
- isActive: Boolean(props.orderedListActive),
124
- elemAfter: jsx("div", {
125
- css: shortcutStyle
126
- }, tooltip(toggleOrderedListKeymap))
127
- }];
128
- if (props.showIndentationButtons) {
129
- const labelIndent = formatMessage(indentationMessages.indent);
130
- const labelOutdent = formatMessage(indentationMessages.outdent);
131
- items.push({
132
- key: 'outdent',
133
- content: labelOutdent,
134
- value: {
135
- name: 'outdent'
136
- },
137
- isDisabled: props.outdentDisabled,
138
- isActive: false,
139
- elemAfter: jsx("div", {
140
- css: shortcutStyle
141
- }, tooltip(toggleOutdentKeymap))
142
- }, {
143
- key: 'indent',
144
- content: labelIndent,
145
- value: {
146
- name: 'indent'
147
- },
148
- isDisabled: props.indentDisabled,
149
- isActive: false,
150
- elemAfter: jsx("div", {
151
- css: shortcutStyle
152
- }, tooltip(toggleIndentKeymap))
153
- });
154
- }
155
- return [{
156
- items
157
- }];
158
- }
@@ -1,58 +0,0 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- import { onItemActivated } from './onItemActivated';
4
- import { ToolbarDropdown } from './ToolbarDropdown';
5
- import { Toolbar } from './Toolbar';
6
- export default function ToolbarListsIndentation(props) {
7
- const {
8
- disabled,
9
- isSmall,
10
- isReducedSpacing,
11
- bulletListActive,
12
- bulletListDisabled,
13
- orderedListActive,
14
- orderedListDisabled,
15
- showIndentationButtons,
16
- popupsMountPoint,
17
- popupsBoundariesElement,
18
- popupsScrollableElement,
19
- indentDisabled,
20
- outdentDisabled,
21
- indentationStateNode,
22
- featureFlags,
23
- pluginInjectionApi
24
- } = props;
25
- if (isSmall) {
26
- return jsx(ToolbarDropdown, {
27
- editorView: props.editorView,
28
- isReducedSpacing: isReducedSpacing,
29
- popupsMountPoint: popupsMountPoint,
30
- popupsBoundariesElement: popupsBoundariesElement,
31
- popupsScrollableElement: popupsScrollableElement,
32
- bulletListActive: bulletListActive,
33
- bulletListDisabled: bulletListDisabled,
34
- showIndentationButtons: showIndentationButtons,
35
- orderedListActive: orderedListActive,
36
- orderedListDisabled: orderedListDisabled,
37
- indentDisabled: indentDisabled,
38
- outdentDisabled: outdentDisabled,
39
- disabled: disabled,
40
- onItemActivated: onItemActivated(pluginInjectionApi, indentationStateNode),
41
- featureFlags: featureFlags
42
- });
43
- }
44
- return jsx(Toolbar, {
45
- editorView: props.editorView,
46
- isReducedSpacing: isReducedSpacing,
47
- bulletListActive: bulletListActive,
48
- bulletListDisabled: bulletListDisabled,
49
- showIndentationButtons: showIndentationButtons,
50
- orderedListActive: orderedListActive,
51
- orderedListDisabled: orderedListDisabled,
52
- indentDisabled: indentDisabled,
53
- outdentDisabled: outdentDisabled,
54
- disabled: disabled,
55
- onItemActivated: onItemActivated(pluginInjectionApi, indentationStateNode),
56
- featureFlags: featureFlags
57
- });
58
- }
@@ -1,46 +0,0 @@
1
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
- export const onItemActivated = (pluginInjectionApi, indentationStateNode) => ({
3
- buttonName,
4
- editorView
5
- }) => {
6
- switch (buttonName) {
7
- case 'bullet_list':
8
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.toggleBulletList(INPUT_METHOD.TOOLBAR));
9
- break;
10
- case 'ordered_list':
11
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.toggleOrderedList(INPUT_METHOD.TOOLBAR));
12
- break;
13
- case 'indent':
14
- {
15
- const node = indentationStateNode;
16
- if (node === 'paragraph_heading') {
17
- var _pluginInjectionApi$i;
18
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$i = pluginInjectionApi.indentation) === null || _pluginInjectionApi$i === void 0 ? void 0 : _pluginInjectionApi$i.actions.indentParagraphOrHeading(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
19
- }
20
- if (node === 'list') {
21
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.indentList(INPUT_METHOD.TOOLBAR));
22
- }
23
- if (node === 'taskList') {
24
- var _pluginInjectionApi$t;
25
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$t = pluginInjectionApi.taskDecision) === null || _pluginInjectionApi$t === void 0 ? void 0 : _pluginInjectionApi$t.actions.indentTaskList(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
26
- }
27
- break;
28
- }
29
- case 'outdent':
30
- {
31
- const node = indentationStateNode;
32
- if (node === 'paragraph_heading') {
33
- var _pluginInjectionApi$i2;
34
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$i2 = pluginInjectionApi.indentation) === null || _pluginInjectionApi$i2 === void 0 ? void 0 : _pluginInjectionApi$i2.actions.outdentParagraphOrHeading(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
35
- }
36
- if (node === 'list') {
37
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.outdentList(INPUT_METHOD.TOOLBAR));
38
- }
39
- if (node === 'taskList') {
40
- var _pluginInjectionApi$t2;
41
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$t2 = pluginInjectionApi.taskDecision) === null || _pluginInjectionApi$t2 === void 0 ? void 0 : _pluginInjectionApi$t2.actions.outdentTaskList(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
42
- }
43
- break;
44
- }
45
- }
46
- };
@@ -1,83 +0,0 @@
1
- import React from 'react';
2
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
- import ToolbarListsIndentation from './ui';
4
- import { ToolbarSize } from '../../ui/Toolbar/types';
5
- import { getIndentationButtonsState } from './pm-plugins/indentation-buttons';
6
- var toolbarListsIndentationPlugin = function toolbarListsIndentationPlugin(_ref) {
7
- var _api$featureFlags;
8
- var config = _ref.config,
9
- api = _ref.api;
10
- var _ref2 = config !== null && config !== void 0 ? config : {},
11
- _ref2$showIndentation = _ref2.showIndentationButtons,
12
- showIndentationButtons = _ref2$showIndentation === void 0 ? false : _ref2$showIndentation,
13
- _ref2$allowHeadingAnd = _ref2.allowHeadingAndParagraphIndentation,
14
- allowHeadingAndParagraphIndentation = _ref2$allowHeadingAnd === void 0 ? false : _ref2$allowHeadingAnd;
15
- var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
16
- return {
17
- name: 'toolbarListsIndentation',
18
- primaryToolbarComponent: function primaryToolbarComponent(_ref3) {
19
- var editorView = _ref3.editorView,
20
- popupsMountPoint = _ref3.popupsMountPoint,
21
- popupsBoundariesElement = _ref3.popupsBoundariesElement,
22
- popupsScrollableElement = _ref3.popupsScrollableElement,
23
- toolbarSize = _ref3.toolbarSize,
24
- disabled = _ref3.disabled,
25
- isToolbarReducedSpacing = _ref3.isToolbarReducedSpacing;
26
- var isSmall = toolbarSize < ToolbarSize.L;
27
- return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
28
- featureFlags: featureFlags,
29
- popupsMountPoint: popupsMountPoint,
30
- popupsBoundariesElement: popupsBoundariesElement,
31
- popupsScrollableElement: popupsScrollableElement,
32
- isSmall: isSmall,
33
- isToolbarReducedSpacing: isToolbarReducedSpacing,
34
- disabled: disabled,
35
- editorView: editorView,
36
- showIndentationButtons: showIndentationButtons,
37
- pluginInjectionApi: api,
38
- allowHeadingAndParagraphIndentation: allowHeadingAndParagraphIndentation
39
- });
40
- }
41
- };
42
- };
43
- export function PrimaryToolbarComponent(_ref4) {
44
- var featureFlags = _ref4.featureFlags,
45
- popupsMountPoint = _ref4.popupsMountPoint,
46
- popupsBoundariesElement = _ref4.popupsBoundariesElement,
47
- popupsScrollableElement = _ref4.popupsScrollableElement,
48
- isSmall = _ref4.isSmall,
49
- isToolbarReducedSpacing = _ref4.isToolbarReducedSpacing,
50
- disabled = _ref4.disabled,
51
- editorView = _ref4.editorView,
52
- showIndentationButtons = _ref4.showIndentationButtons,
53
- pluginInjectionApi = _ref4.pluginInjectionApi,
54
- allowHeadingAndParagraphIndentation = _ref4.allowHeadingAndParagraphIndentation;
55
- var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['list', 'indentation', 'taskDecision']),
56
- listState = _useSharedPluginState.listState,
57
- indentationState = _useSharedPluginState.indentationState,
58
- taskDecisionState = _useSharedPluginState.taskDecisionState;
59
- var toolbarListsIndentationState = getIndentationButtonsState(editorView.state, allowHeadingAndParagraphIndentation, taskDecisionState, indentationState, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.actions.isInsideListItem);
60
- if (!listState) {
61
- return null;
62
- }
63
- return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
64
- featureFlags: featureFlags,
65
- isSmall: isSmall,
66
- isReducedSpacing: isToolbarReducedSpacing,
67
- disabled: disabled,
68
- editorView: editorView,
69
- popupsMountPoint: popupsMountPoint,
70
- popupsBoundariesElement: popupsBoundariesElement,
71
- popupsScrollableElement: popupsScrollableElement,
72
- bulletListActive: listState.bulletListActive,
73
- bulletListDisabled: listState.bulletListDisabled,
74
- orderedListActive: listState.orderedListActive,
75
- orderedListDisabled: listState.orderedListDisabled,
76
- showIndentationButtons: !!showIndentationButtons,
77
- indentDisabled: toolbarListsIndentationState.indentDisabled,
78
- outdentDisabled: toolbarListsIndentationState.outdentDisabled,
79
- indentationStateNode: toolbarListsIndentationState === null || toolbarListsIndentationState === void 0 ? void 0 : toolbarListsIndentationState.node,
80
- pluginInjectionApi: pluginInjectionApi
81
- });
82
- }
83
- export default toolbarListsIndentationPlugin;
@@ -1,50 +0,0 @@
1
- import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
2
- import { getListItemAttributes } from '@atlaskit/editor-common/lists';
3
- import { MAX_INDENTATION_LEVEL } from '@atlaskit/editor-common/indentation';
4
- export function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndentation, taskDecisionState, indentationState, isInsideListItem) {
5
- var _indentationState$isI;
6
- var state = {
7
- indentDisabled: true,
8
- outdentDisabled: true,
9
- node: null
10
- };
11
- var selection = editorState.selection;
12
-
13
- // Handle bullet and numbered lists seperately as they do
14
- // not use the indentation mark.
15
- // Check for lists before paragraphs and headings in case
16
- // the selection is in a list nested in a layout column.
17
- if (isInsideListItem !== null && isInsideListItem !== void 0 && isInsideListItem(editorState.tr)) {
18
- var _getListItemAttribute = getListItemAttributes(selection.$head),
19
- indentLevel = _getListItemAttribute.indentLevel,
20
- itemIndex = _getListItemAttribute.itemIndex;
21
- return {
22
- // List indent levels are zero indexed so we need to subtract 1
23
- indentDisabled: itemIndex === 0 || indentLevel >= MAX_INDENTATION_LEVEL - 1,
24
- outdentDisabled: false,
25
- node: 'list'
26
- };
27
- }
28
-
29
- // Handle tasks seperately as they do not use the indentation mark
30
- // and have different behaviour for outdent compared to lists
31
- if (taskDecisionState !== null && taskDecisionState !== void 0 && taskDecisionState.isInsideTask) {
32
- return {
33
- indentDisabled: taskDecisionState.indentDisabled,
34
- outdentDisabled: taskDecisionState.outdentDisabled,
35
- node: 'taskList'
36
- };
37
- }
38
- var isTopLevelParagraphOrHeading = selection.$from.depth === 1;
39
- var isInLayoutNode = hasParentNodeOfType(editorState.schema.nodes.layoutColumn)(selection) &&
40
- // depth of non-nested paragraphs and headings in layouts will always be 3
41
- selection.$from.depth === 3;
42
- if (allowHeadingAndParagraphIndentation && ((_indentationState$isI = indentationState === null || indentationState === void 0 ? void 0 : indentationState.isIndentationAllowed) !== null && _indentationState$isI !== void 0 ? _indentationState$isI : false) && (isTopLevelParagraphOrHeading || isInLayoutNode) && indentationState) {
43
- return {
44
- indentDisabled: indentationState.indentDisabled,
45
- outdentDisabled: indentationState.outdentDisabled,
46
- node: 'paragraph_heading'
47
- };
48
- }
49
- return state;
50
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,124 +0,0 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- import { useIntl } from 'react-intl-next';
4
- import BulletListIcon from '@atlaskit/icon/glyph/editor/bullet-list';
5
- import NumberListIcon from '@atlaskit/icon/glyph/editor/number-list';
6
- import IndentIcon from '@atlaskit/icon/glyph/editor/indent';
7
- import OutdentIcon from '@atlaskit/icon/glyph/editor/outdent';
8
- import { toggleBulletList as toggleBulletListKeymap, toggleOrderedList as toggleOrderedListKeymap, indent as toggleIndentKeymap, outdent as toggleOutdentKeymap, ToolTipContent, tooltip } from '../../../keymaps';
9
- import ToolbarButton, { TOOLBAR_BUTTON } from '../../../ui/ToolbarButton';
10
- import { listMessages as messages, indentationMessages } from '@atlaskit/editor-common/messages';
11
- import { separatorStyles, buttonGroupStyle } from '@atlaskit/editor-common/styles';
12
- import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
13
- import { useEffect, useRef } from 'react';
14
- export function Toolbar(props) {
15
- var _useIntl = useIntl(),
16
- formatMessage = _useIntl.formatMessage;
17
- var indentButtonRef = useRef(null);
18
- var outdentButtonRef = useRef(null);
19
- var disabled = props.disabled,
20
- isReducedSpacing = props.isReducedSpacing,
21
- bulletListActive = props.bulletListActive,
22
- bulletListDisabled = props.bulletListDisabled,
23
- orderedListActive = props.orderedListActive,
24
- orderedListDisabled = props.orderedListDisabled,
25
- showIndentationButtons = props.showIndentationButtons,
26
- indentDisabled = props.indentDisabled,
27
- outdentDisabled = props.outdentDisabled,
28
- onItemActivated = props.onItemActivated;
29
- var labelUnorderedList = formatMessage(messages.unorderedList);
30
- var labelOrderedList = formatMessage(messages.orderedList);
31
- var indentMessage = formatMessage(indentationMessages.indent);
32
- var outdentMessage = formatMessage(indentationMessages.outdent);
33
- var isIndentButtonFocused = document.activeElement === indentButtonRef.current;
34
- var isOutdentButtonFocused = document.activeElement === outdentButtonRef.current;
35
- var handleOnItemActivated = function handleOnItemActivated(buttonName) {
36
- return function (event) {
37
- return onItemActivated({
38
- editorView: props.editorView,
39
- buttonName: buttonName
40
- });
41
- };
42
- };
43
- useEffect(function () {
44
- if (isIndentButtonFocused && indentDisabled && outdentButtonRef.current) {
45
- outdentButtonRef.current.focus();
46
- }
47
- }, [indentButtonRef, indentDisabled, isIndentButtonFocused]);
48
- useEffect(function () {
49
- if (isOutdentButtonFocused && outdentDisabled && indentButtonRef.current) {
50
- indentButtonRef.current.focus();
51
- }
52
- }, [outdentButtonRef, outdentDisabled, isOutdentButtonFocused]);
53
- return jsx("span", {
54
- css: buttonGroupStyle
55
- }, jsx(ToolbarButton, {
56
- buttonId: TOOLBAR_BUTTON.BULLET_LIST,
57
- testId: labelUnorderedList,
58
- spacing: isReducedSpacing ? 'none' : 'default',
59
- onClick: handleOnItemActivated('bullet_list'),
60
- selected: bulletListActive,
61
- "aria-pressed": bulletListActive,
62
- "aria-label": tooltip(toggleBulletListKeymap, labelUnorderedList),
63
- "aria-keyshortcuts": getAriaKeyshortcuts(toggleBulletListKeymap),
64
- disabled: bulletListDisabled || disabled,
65
- title: jsx(ToolTipContent, {
66
- description: labelUnorderedList,
67
- keymap: toggleBulletListKeymap
68
- }),
69
- iconBefore: jsx(BulletListIcon, {
70
- label: ""
71
- })
72
- }), jsx(ToolbarButton, {
73
- buttonId: TOOLBAR_BUTTON.ORDERED_LIST,
74
- testId: labelOrderedList,
75
- spacing: isReducedSpacing ? 'none' : 'default',
76
- onClick: handleOnItemActivated('ordered_list'),
77
- selected: orderedListActive,
78
- "aria-pressed": orderedListActive,
79
- "aria-label": tooltip(toggleOrderedListKeymap, labelOrderedList),
80
- "aria-keyshortcuts": getAriaKeyshortcuts(toggleOrderedListKeymap),
81
- disabled: orderedListDisabled || disabled,
82
- title: jsx(ToolTipContent, {
83
- description: labelOrderedList,
84
- keymap: toggleOrderedListKeymap
85
- }),
86
- iconBefore: jsx(NumberListIcon, {
87
- label: ""
88
- })
89
- }), showIndentationButtons && jsx(ToolbarButton, {
90
- buttonId: TOOLBAR_BUTTON.OUTDENT,
91
- testId: TOOLBAR_BUTTON.OUTDENT,
92
- ref: outdentButtonRef,
93
- spacing: isReducedSpacing ? 'none' : 'default',
94
- onClick: handleOnItemActivated('outdent'),
95
- iconBefore: jsx(OutdentIcon, {
96
- label: ""
97
- }),
98
- disabled: outdentDisabled || disabled,
99
- "aria-label": tooltip(toggleOutdentKeymap, outdentMessage),
100
- "aria-keyshortcuts": getAriaKeyshortcuts(toggleOutdentKeymap),
101
- title: jsx(ToolTipContent, {
102
- description: outdentMessage,
103
- keymap: toggleOutdentKeymap
104
- })
105
- }), showIndentationButtons && jsx(ToolbarButton, {
106
- buttonId: TOOLBAR_BUTTON.INDENT,
107
- testId: TOOLBAR_BUTTON.INDENT,
108
- ref: indentButtonRef,
109
- spacing: isReducedSpacing ? 'none' : 'default',
110
- onClick: handleOnItemActivated('indent'),
111
- iconBefore: jsx(IndentIcon, {
112
- label: ""
113
- }),
114
- disabled: indentDisabled || disabled,
115
- "aria-label": tooltip(toggleIndentKeymap, indentMessage),
116
- "aria-keyshortcuts": getAriaKeyshortcuts(toggleIndentKeymap),
117
- title: jsx(ToolTipContent, {
118
- description: indentMessage,
119
- keymap: toggleIndentKeymap
120
- })
121
- }), jsx("span", {
122
- css: separatorStyles
123
- }));
124
- }
@@ -1,161 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- /** @jsx jsx */
3
- import { jsx } from '@emotion/react';
4
- import React from 'react';
5
- import { useIntl } from 'react-intl-next';
6
- import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
7
- import BulletListIcon from '@atlaskit/icon/glyph/editor/bullet-list';
8
- import { toggleBulletList as toggleBulletListKeymap, toggleOrderedList as toggleOrderedListKeymap, indent as toggleIndentKeymap, outdent as toggleOutdentKeymap, tooltip } from '../../../keymaps';
9
- import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
10
- import ToolbarButton from '../../../ui/ToolbarButton';
11
- import { shortcutStyle } from '../../../ui/styles';
12
- import { expandIconWrapperStyle } from '@atlaskit/editor-common/styles';
13
- import { wrapperStyle, separatorStyles } from '@atlaskit/editor-common/styles';
14
- import { listMessages, indentationMessages } from '@atlaskit/editor-common/messages';
15
- export function ToolbarDropdown(props) {
16
- var _useIntl = useIntl(),
17
- formatMessage = _useIntl.formatMessage;
18
- var disabled = props.disabled,
19
- isReducedSpacing = props.isReducedSpacing,
20
- bulletListActive = props.bulletListActive,
21
- orderedListActive = props.orderedListActive,
22
- popupsMountPoint = props.popupsMountPoint,
23
- popupsBoundariesElement = props.popupsBoundariesElement,
24
- popupsScrollableElement = props.popupsScrollableElement,
25
- onItemActivated = props.onItemActivated;
26
- var _React$useState = React.useState(false),
27
- _React$useState2 = _slicedToArray(_React$useState, 2),
28
- isDropdownOpen = _React$useState2[0],
29
- setIsDropdownOpen = _React$useState2[1];
30
- var _React$useState3 = React.useState(false),
31
- _React$useState4 = _slicedToArray(_React$useState3, 2),
32
- isOpenedByKeyboard = _React$useState4[0],
33
- setOpenedByKeyboard = _React$useState4[1];
34
- var labelLists = formatMessage(listMessages.lists);
35
- var onOpenChange = function onOpenChange(attrs) {
36
- setIsDropdownOpen(attrs.isDropdownOpen);
37
- };
38
- var handleTriggerClick = function handleTriggerClick() {
39
- onOpenChange({
40
- isDropdownOpen: !isDropdownOpen
41
- });
42
- };
43
- var handleOnKeyDown = function handleOnKeyDown(event) {
44
- if (event.key === 'Enter' || event.key === ' ') {
45
- event.preventDefault();
46
- setIsDropdownOpen(!isDropdownOpen);
47
- setOpenedByKeyboard(true);
48
- }
49
- };
50
- var items = useItems(props);
51
- var handleOnItemActivated = function handleOnItemActivated(_ref) {
52
- var item = _ref.item,
53
- _ref$shouldCloseMenu = _ref.shouldCloseMenu,
54
- shouldCloseMenu = _ref$shouldCloseMenu === void 0 ? true : _ref$shouldCloseMenu;
55
- setIsDropdownOpen(!shouldCloseMenu);
56
- return onItemActivated({
57
- editorView: props.editorView,
58
- buttonName: item.value.name
59
- });
60
- };
61
- return jsx("span", {
62
- css: wrapperStyle
63
- }, jsx(DropdownMenu, {
64
- items: items,
65
- onItemActivated: handleOnItemActivated,
66
- mountTo: popupsMountPoint,
67
- boundariesElement: popupsBoundariesElement,
68
- scrollableElement: popupsScrollableElement,
69
- isOpen: isDropdownOpen,
70
- onOpenChange: onOpenChange,
71
- fitHeight: 188,
72
- fitWidth: 175,
73
- shouldUseDefaultRole: true,
74
- shouldFocusFirstItem: function shouldFocusFirstItem() {
75
- if (isOpenedByKeyboard) {
76
- setOpenedByKeyboard(false);
77
- }
78
- return isOpenedByKeyboard;
79
- }
80
- }, jsx(ToolbarButton, {
81
- spacing: isReducedSpacing ? 'none' : 'default',
82
- selected: bulletListActive || orderedListActive,
83
- "aria-expanded": isDropdownOpen,
84
- "aria-haspopup": true,
85
- "aria-label": labelLists,
86
- disabled: disabled,
87
- onClick: handleTriggerClick,
88
- onKeyDown: handleOnKeyDown,
89
- title: labelLists,
90
- iconBefore: jsx("span", {
91
- css: wrapperStyle
92
- }, jsx(BulletListIcon, {
93
- label: labelLists
94
- }), jsx("span", {
95
- css: expandIconWrapperStyle
96
- }, jsx(ExpandIcon, {
97
- label: ""
98
- })))
99
- })), jsx("span", {
100
- css: separatorStyles
101
- }));
102
- }
103
- function useItems(props) {
104
- var _useIntl2 = useIntl(),
105
- formatMessage = _useIntl2.formatMessage;
106
- var labelUnorderedList = formatMessage(listMessages.unorderedList);
107
- var labelOrderedList = formatMessage(listMessages.orderedList);
108
- var items = [{
109
- key: 'unorderedList',
110
- content: labelUnorderedList,
111
- value: {
112
- name: 'bullet_list'
113
- },
114
- isDisabled: props.bulletListDisabled,
115
- isActive: Boolean(props.bulletListActive),
116
- elemAfter: jsx("div", {
117
- css: shortcutStyle
118
- }, tooltip(toggleBulletListKeymap))
119
- }, {
120
- key: 'orderedList',
121
- content: labelOrderedList,
122
- value: {
123
- name: 'ordered_list'
124
- },
125
- isDisabled: props.orderedListDisabled,
126
- isActive: Boolean(props.orderedListActive),
127
- elemAfter: jsx("div", {
128
- css: shortcutStyle
129
- }, tooltip(toggleOrderedListKeymap))
130
- }];
131
- if (props.showIndentationButtons) {
132
- var labelIndent = formatMessage(indentationMessages.indent);
133
- var labelOutdent = formatMessage(indentationMessages.outdent);
134
- items.push({
135
- key: 'outdent',
136
- content: labelOutdent,
137
- value: {
138
- name: 'outdent'
139
- },
140
- isDisabled: props.outdentDisabled,
141
- isActive: false,
142
- elemAfter: jsx("div", {
143
- css: shortcutStyle
144
- }, tooltip(toggleOutdentKeymap))
145
- }, {
146
- key: 'indent',
147
- content: labelIndent,
148
- value: {
149
- name: 'indent'
150
- },
151
- isDisabled: props.indentDisabled,
152
- isActive: false,
153
- elemAfter: jsx("div", {
154
- css: shortcutStyle
155
- }, tooltip(toggleIndentKeymap))
156
- });
157
- }
158
- return [{
159
- items: items
160
- }];
161
- }