@atlaskit/editor-core 167.0.3 → 169.1.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 +38 -0
- package/dist/cjs/create-editor/create-plugins-list.js +7 -0
- package/dist/cjs/plugins/analytics/types/toolbar-button.js +2 -0
- package/dist/cjs/plugins/annotation/pm-plugins/inline-comment.js +2 -2
- package/dist/cjs/plugins/breakout/index.js +7 -0
- package/dist/cjs/plugins/breakout/ui/LayoutButton.js +3 -1
- package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +6 -1
- package/dist/cjs/plugins/card/styles.js +4 -2
- package/dist/cjs/plugins/card/toolbar.js +6 -1
- package/dist/cjs/plugins/code-block/styles.js +17 -41
- package/dist/cjs/plugins/code-block/ui/class-names.js +5 -2
- package/dist/cjs/plugins/collab-edit/index.js +2 -2
- package/dist/cjs/plugins/collab-edit/provider/channel.js +2 -2
- package/dist/cjs/plugins/copy-button/commands.js +85 -0
- package/dist/cjs/plugins/copy-button/index.js +27 -0
- package/dist/cjs/plugins/copy-button/pm-plugins/main.js +38 -0
- package/dist/cjs/plugins/copy-button/pm-plugins/plugin-key.js +11 -0
- package/dist/cjs/plugins/copy-button/utils.js +51 -0
- package/dist/cjs/plugins/extension/context-panel.js +2 -2
- package/dist/cjs/plugins/extension/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +4 -2
- package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +2 -2
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -2
- package/dist/cjs/plugins/indentation/messages.js +23 -0
- package/dist/cjs/plugins/index.js +16 -0
- package/dist/cjs/plugins/list/index.js +0 -43
- package/dist/cjs/plugins/macro/actions.js +2 -2
- package/dist/cjs/plugins/media/nodeviews/mediaInline.js +2 -2
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -2
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/index.js +2 -2
- package/dist/cjs/plugins/panel/toolbar.js +10 -2
- package/dist/cjs/plugins/table/commands/hover.js +2 -2
- package/dist/cjs/plugins/table/toolbar.js +5 -1
- package/dist/cjs/plugins/table/utils/decoration.js +5 -1
- package/dist/cjs/plugins/toolbar-lists-indentation/index.js +65 -0
- package/dist/cjs/plugins/toolbar-lists-indentation/types.js +5 -0
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +122 -0
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +173 -0
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +58 -0
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +48 -0
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +4 -5
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +17 -51
- package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +2 -2
- package/dist/cjs/ui/ConfigPanel/Fields/CustomSelect.js +2 -2
- package/dist/cjs/ui/ConfigPanel/Fields/UserSelect.js +2 -2
- package/dist/cjs/ui/ConfigPanel/transformers.js +2 -2
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +12 -39
- package/dist/cjs/ui/ElementBrowser/components/ElementList/ElementList.js +31 -87
- package/dist/cjs/utils/clipboard.js +67 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/create-plugins-list.js +8 -1
- package/dist/es2019/plugins/analytics/types/toolbar-button.js +2 -0
- package/dist/es2019/plugins/breakout/index.js +7 -0
- package/dist/es2019/plugins/breakout/ui/LayoutButton.js +3 -1
- package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +6 -1
- package/dist/es2019/plugins/card/styles.js +5 -0
- package/dist/es2019/plugins/card/toolbar.js +5 -1
- package/dist/es2019/plugins/code-block/styles.js +18 -95
- package/dist/es2019/plugins/code-block/ui/class-names.js +3 -2
- package/dist/es2019/plugins/copy-button/commands.js +64 -0
- package/dist/es2019/plugins/copy-button/index.js +15 -0
- package/dist/es2019/plugins/copy-button/pm-plugins/main.js +28 -0
- package/dist/es2019/plugins/copy-button/pm-plugins/plugin-key.js +2 -0
- package/dist/es2019/plugins/copy-button/utils.js +29 -0
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +4 -2
- package/dist/es2019/plugins/indentation/messages.js +14 -0
- package/dist/es2019/plugins/index.js +3 -1
- package/dist/es2019/plugins/list/index.js +1 -44
- package/dist/es2019/plugins/panel/toolbar.js +9 -2
- package/dist/es2019/plugins/table/commands/hover.js +2 -2
- package/dist/es2019/plugins/table/toolbar.js +5 -2
- package/dist/es2019/plugins/table/utils/decoration.js +5 -1
- package/dist/es2019/plugins/toolbar-lists-indentation/index.js +53 -0
- package/dist/es2019/plugins/toolbar-lists-indentation/types.js +1 -0
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +94 -0
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +149 -0
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +49 -0
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +35 -0
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +11 -10
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +17 -48
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +10 -30
- package/dist/es2019/ui/ElementBrowser/components/ElementList/ElementList.js +34 -93
- package/dist/es2019/utils/clipboard.js +26 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +1 -1
- package/dist/esm/create-editor/ErrorBoundary.js +1 -1
- package/dist/esm/create-editor/create-plugins-list.js +8 -1
- package/dist/esm/editor.js +2 -1
- package/dist/esm/plugins/analytics/types/toolbar-button.js +2 -0
- package/dist/esm/plugins/annotation/pm-plugins/inline-comment.js +1 -1
- package/dist/esm/plugins/breakout/index.js +7 -0
- package/dist/esm/plugins/breakout/ui/LayoutButton.js +3 -1
- package/dist/esm/plugins/card/pm-plugins/util/resolve.js +6 -1
- package/dist/esm/plugins/card/styles.js +2 -1
- package/dist/esm/plugins/card/toolbar.js +5 -1
- package/dist/esm/plugins/code-block/styles.js +16 -35
- package/dist/esm/plugins/code-block/ui/class-names.js +3 -2
- package/dist/esm/plugins/collab-edit/index.js +1 -1
- package/dist/esm/plugins/collab-edit/provider/channel.js +1 -1
- package/dist/esm/plugins/copy-button/commands.js +66 -0
- package/dist/esm/plugins/copy-button/index.js +17 -0
- package/dist/esm/plugins/copy-button/pm-plugins/main.js +26 -0
- package/dist/esm/plugins/copy-button/pm-plugins/plugin-key.js +2 -0
- package/dist/esm/plugins/copy-button/utils.js +31 -0
- package/dist/esm/plugins/custom-autoformat/doc.js +1 -1
- package/dist/esm/plugins/custom-autoformat/index.js +1 -1
- package/dist/esm/plugins/extension/actions.js +1 -1
- package/dist/esm/plugins/extension/context-panel.js +1 -1
- package/dist/esm/plugins/extension/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/extension/ui/Extension/ExtensionComponent.js +1 -1
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +4 -2
- package/dist/esm/plugins/feedback-dialog/index.js +1 -1
- package/dist/esm/plugins/feedback-dialog/loadJiraCollectorDialogScript.js +1 -1
- package/dist/esm/plugins/find-replace/utils/batch-decorations.js +1 -1
- package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +1 -1
- package/dist/esm/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -1
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -1
- package/dist/esm/plugins/image-upload/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/indentation/messages.js +14 -0
- package/dist/esm/plugins/index.js +3 -1
- package/dist/esm/plugins/list/index.js +1 -41
- package/dist/esm/plugins/macro/actions.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaInline.js +2 -1
- package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaNodeView/media.js +1 -1
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/esm/plugins/media/picker-facade.js +1 -1
- package/dist/esm/plugins/media/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/media/toolbar/utils.js +1 -1
- package/dist/esm/plugins/media/ui/MediaPicker/PickerFacadeProvider.js +1 -1
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/index.js +1 -1
- package/dist/esm/plugins/media/utils/check-media-type.js +1 -1
- package/dist/esm/plugins/panel/toolbar.js +9 -2
- package/dist/esm/plugins/paste/handlers.js +1 -1
- package/dist/esm/plugins/paste/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/quick-insert/index.js +1 -1
- package/dist/esm/plugins/table/commands/hover.js +2 -2
- package/dist/esm/plugins/table/toolbar.js +5 -2
- package/dist/esm/plugins/table/utils/decoration.js +5 -1
- package/dist/esm/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.js +1 -1
- package/dist/esm/plugins/toolbar-lists-indentation/index.js +51 -0
- package/dist/esm/plugins/toolbar-lists-indentation/types.js +1 -0
- package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +96 -0
- package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +153 -0
- package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +47 -0
- package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +39 -0
- package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +6 -8
- package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +18 -51
- package/dist/esm/ui/ConfigPanel/ConfigPanel.js +1 -1
- package/dist/esm/ui/ConfigPanel/Fields/CustomSelect.js +1 -1
- package/dist/esm/ui/ConfigPanel/Fields/UserSelect.js +1 -1
- package/dist/esm/ui/ConfigPanel/FormErrorBoundary.js +1 -1
- package/dist/esm/ui/ConfigPanel/transformers.js +1 -1
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +12 -35
- package/dist/esm/ui/ElementBrowser/components/ElementList/ElementList.js +31 -89
- package/dist/esm/ui/LinkSearch/index.js +1 -1
- package/dist/esm/ui/ToolbarFeedback/index.js +1 -1
- package/dist/esm/utils/action.js +1 -1
- package/dist/esm/utils/clipboard.js +56 -1
- package/dist/esm/utils/extensions.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/analytics/types/toolbar-button.d.ts +3 -1
- package/dist/types/plugins/card/styles.d.ts +1 -0
- package/dist/types/plugins/copy-button/commands.d.ts +4 -0
- package/dist/types/plugins/copy-button/index.d.ts +3 -0
- package/dist/types/plugins/copy-button/pm-plugins/main.d.ts +3 -0
- package/dist/types/plugins/copy-button/pm-plugins/plugin-key.d.ts +2 -0
- package/dist/types/plugins/copy-button/utils.d.ts +7 -0
- package/dist/types/plugins/indentation/messages.d.ts +12 -0
- package/dist/types/plugins/index.d.ts +2 -0
- package/dist/types/plugins/panel/toolbar.d.ts +1 -1
- package/dist/types/plugins/table/commands/hover.d.ts +1 -1
- package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
- package/dist/types/plugins/text-formatting/utils.d.ts +1 -1
- package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +5 -0
- package/dist/types/plugins/toolbar-lists-indentation/types.d.ts +16 -0
- package/dist/types/plugins/toolbar-lists-indentation/ui/Toolbar.d.ts +4 -0
- package/dist/types/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.d.ts +9 -0
- package/dist/types/plugins/{list/ui/ToolbarLists → toolbar-lists-indentation/ui}/index.d.ts +4 -10
- package/dist/types/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +6 -0
- package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +0 -25
- package/dist/types/types/feature-flags.d.ts +18 -0
- package/dist/types/ui/ElementBrowser/components/ElementList/ElementList.d.ts +11 -0
- package/dist/types/utils/clipboard.d.ts +1 -0
- package/package.json +25 -25
- package/report.api.md +6747 -0
- package/dist/cjs/plugins/list/ui/ToolbarLists/index.js +0 -266
- package/dist/es2019/plugins/list/ui/ToolbarLists/index.js +0 -220
- package/dist/esm/plugins/list/ui/ToolbarLists/index.js +0 -241
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { findSelectedNodeOfType, findParentNodeOfType } from 'prosemirror-utils';
|
|
2
|
+
import { pluginKey } from './pm-plugins/plugin-key';
|
|
3
|
+
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
4
|
+
import { DOMSerializer } from 'prosemirror-model';
|
|
5
|
+
import { copyHTMLToClipboard } from '../../utils/clipboard';
|
|
6
|
+
export const copy = nodeType => (state, dispatch) => {
|
|
7
|
+
const {
|
|
8
|
+
tr,
|
|
9
|
+
schema
|
|
10
|
+
} = state; // This command should only be triggered by the Copy button in the floating toolbar
|
|
11
|
+
// which is only visible when selection is inside the target node
|
|
12
|
+
|
|
13
|
+
let node = findSelectedNodeOfType(nodeType)(tr.selection);
|
|
14
|
+
|
|
15
|
+
if (!node) {
|
|
16
|
+
node = findParentNodeOfType(nodeType)(tr.selection);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!node) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const domNode = DOMSerializer.fromSchema(schema).serializeNode(node.node);
|
|
24
|
+
const div = document.createElement('div');
|
|
25
|
+
div.appendChild(domNode); // The "0 0" refers to the start and end depth of the slice
|
|
26
|
+
// since we're coping the block node only, it will always be 0 0
|
|
27
|
+
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
28
|
+
|
|
29
|
+
div.firstChild.setAttribute('data-pm-slice', '0 0 []');
|
|
30
|
+
copyHTMLToClipboard(div.innerHTML);
|
|
31
|
+
const copyToClipboardTr = tr;
|
|
32
|
+
copyToClipboardTr.setMeta(pluginKey, {
|
|
33
|
+
copied: true
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (dispatch) {
|
|
37
|
+
dispatch(copyToClipboardTr);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
export const resetCopiedState = (nodeType, onMouseLeave) => (state, dispatch) => {
|
|
43
|
+
let customTr = state.tr; // Avoid multipe dispatch
|
|
44
|
+
// https://product-fabric.atlassian.net/wiki/spaces/E/pages/2241659456/All+about+dispatch+and+why+there+shouldn+t+be+multiple#How-do-I-avoid-them%3F
|
|
45
|
+
|
|
46
|
+
const customDispatch = tr => {
|
|
47
|
+
customTr = tr;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
onMouseLeave ? onMouseLeave(state, customDispatch) : hoverDecoration(nodeType, false)(state, customDispatch);
|
|
51
|
+
const copyButtonState = pluginKey.getState(state);
|
|
52
|
+
|
|
53
|
+
if (copyButtonState !== null && copyButtonState !== void 0 && copyButtonState.copied) {
|
|
54
|
+
customTr.setMeta(pluginKey, {
|
|
55
|
+
copied: false
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (dispatch) {
|
|
60
|
+
dispatch(customTr);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return true;
|
|
64
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { pluginKey } from './plugin-key';
|
|
3
|
+
export function copyButtonPlugin() {
|
|
4
|
+
return new SafePlugin({
|
|
5
|
+
state: {
|
|
6
|
+
init() {
|
|
7
|
+
return {
|
|
8
|
+
copied: false
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
apply(tr, pluginState) {
|
|
13
|
+
const meta = tr.getMeta(pluginKey);
|
|
14
|
+
|
|
15
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.copied) !== undefined) {
|
|
16
|
+
return {
|
|
17
|
+
copied: meta.copied
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return pluginState;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
},
|
|
25
|
+
key: pluginKey
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export default copyButtonPlugin;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import CopyIcon from '@atlaskit/icon/glyph/copy';
|
|
2
|
+
import commonMessages from '../../messages';
|
|
3
|
+
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
4
|
+
import { copy, resetCopiedState } from './commands';
|
|
5
|
+
import { pluginKey } from './pm-plugins/plugin-key';
|
|
6
|
+
export const getCopyButtonConfig = (state, formatMessage, nodeType, onMouseEnter, onMouseLeave) => {
|
|
7
|
+
const copyButtonState = pluginKey.getState(state);
|
|
8
|
+
return {
|
|
9
|
+
id: 'editor.floatingToolbar.copy',
|
|
10
|
+
type: 'button',
|
|
11
|
+
appearance: 'subtle',
|
|
12
|
+
icon: CopyIcon,
|
|
13
|
+
onClick: copy(nodeType),
|
|
14
|
+
title: formatMessage(copyButtonState !== null && copyButtonState !== void 0 && copyButtonState.copied ? commonMessages.copiedToClipboard : commonMessages.copyToClipboard),
|
|
15
|
+
onMouseEnter: onMouseEnter || hoverDecoration(nodeType, true, 'ak-editor-selected-node'),
|
|
16
|
+
onMouseLeave: resetCopiedState(nodeType, onMouseLeave),
|
|
17
|
+
onFocus: hoverDecoration(nodeType, true, 'ak-editor-selected-node'),
|
|
18
|
+
onBlur: hoverDecoration(nodeType, false),
|
|
19
|
+
hideTooltipOnClick: false,
|
|
20
|
+
tabIndex: null // TODO select and delete styling needs to be removed when keyboard cursor moves away
|
|
21
|
+
// problem already exist with delete as well
|
|
22
|
+
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export const showCopyButton = state => {
|
|
26
|
+
return state && // Check if the Copy button plugin is enabled
|
|
27
|
+
// @ts-ignore pluginKey.key
|
|
28
|
+
state.plugins.find(p => p.key === pluginKey.key);
|
|
29
|
+
};
|
|
@@ -12,7 +12,7 @@ const safeNumberFeatureFlag = value => {
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
export function createFeatureFlagsFromProps(props) {
|
|
15
|
-
var _props$allowTextColor, _props$allowLayouts, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$allowTables, _props$featureFlags3, _props$featureFlags4, _props$allowTables2, _props$featureFlags5, _props$featureFlags6, _props$allowTables3, _props$featureFlags7, _props$featureFlags8, _props$allowTables4, _props$featureFlags9, _props$featureFlags10, _props$allowTables5, _props$allowExtension, _props$featureFlags11, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22, _props$featureFlags23, _props$featureFlags24, _props$featureFlags25, _props$featureFlags26, _props$featureFlags27, _props$featureFlags28, _props$featureFlags29, _props$featureFlags30, _props$featureFlags31, _props$featureFlags32, _props$featureFlags33, _props$collabEdit, _props$collabEdit2, _props$featureFlags34, _props$featureFlags35, _props$featureFlags36, _props$featureFlags37;
|
|
15
|
+
var _props$allowTextColor, _props$allowLayouts, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$allowTables, _props$featureFlags3, _props$featureFlags4, _props$allowTables2, _props$featureFlags5, _props$featureFlags6, _props$allowTables3, _props$featureFlags7, _props$featureFlags8, _props$allowTables4, _props$featureFlags9, _props$featureFlags10, _props$allowTables5, _props$allowExtension, _props$featureFlags11, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22, _props$featureFlags23, _props$featureFlags24, _props$featureFlags25, _props$featureFlags26, _props$featureFlags27, _props$featureFlags28, _props$featureFlags29, _props$featureFlags30, _props$featureFlags31, _props$featureFlags32, _props$featureFlags33, _props$collabEdit, _props$collabEdit2, _props$featureFlags34, _props$featureFlags35, _props$featureFlags36, _props$featureFlags37, _props$featureFlags38, _props$featureFlags39, _props$featureFlags40, _props$featureFlags41;
|
|
16
16
|
|
|
17
17
|
const normalizedFeatureFlags = normalizeFeatureFlags(props.featureFlags);
|
|
18
18
|
return { ...normalizedFeatureFlags,
|
|
@@ -50,6 +50,8 @@ export function createFeatureFlagsFromProps(props) {
|
|
|
50
50
|
useNativeCollabPlugin: Boolean(typeof ((_props$collabEdit = props.collabEdit) === null || _props$collabEdit === void 0 ? void 0 : _props$collabEdit.useNativePlugin) === 'boolean' ? !!((_props$collabEdit2 = props.collabEdit) !== null && _props$collabEdit2 !== void 0 && _props$collabEdit2.useNativePlugin) : false),
|
|
51
51
|
chromeCursorHandlerFixedVersion: typeof ((_props$featureFlags34 = props.featureFlags) === null || _props$featureFlags34 === void 0 ? void 0 : _props$featureFlags34.chromeCursorHandlerFixedVersion) === 'string' ? Number(props.featureFlags.chromeCursorHandlerFixedVersion) || undefined : undefined,
|
|
52
52
|
viewChangingExperimentToolbarStyle: typeof ((_props$featureFlags35 = props.featureFlags) === null || _props$featureFlags35 === void 0 ? void 0 : _props$featureFlags35['view-changing-experiment-toolbar-style']) === 'string' ? props.featureFlags['view-changing-experiment-toolbar-style'] || undefined : undefined,
|
|
53
|
-
showHoverPreview: Boolean(typeof ((_props$featureFlags36 = props.featureFlags) === null || _props$featureFlags36 === void 0 ? void 0 : _props$featureFlags36.showHoverPreview) === 'boolean' ? !!((_props$featureFlags37 = props.featureFlags) !== null && _props$featureFlags37 !== void 0 && _props$featureFlags37.showHoverPreview) : false)
|
|
53
|
+
showHoverPreview: Boolean(typeof ((_props$featureFlags36 = props.featureFlags) === null || _props$featureFlags36 === void 0 ? void 0 : _props$featureFlags36.showHoverPreview) === 'boolean' ? !!((_props$featureFlags37 = props.featureFlags) !== null && _props$featureFlags37 !== void 0 && _props$featureFlags37.showHoverPreview) : false),
|
|
54
|
+
indentationButtonsInTheToolbar: Boolean(typeof ((_props$featureFlags38 = props.featureFlags) === null || _props$featureFlags38 === void 0 ? void 0 : _props$featureFlags38['indentation-buttons-in-the-toolbar']) === 'boolean' ? !!((_props$featureFlags39 = props.featureFlags) !== null && _props$featureFlags39 !== void 0 && _props$featureFlags39['indentation-buttons-in-the-toolbar']) : false),
|
|
55
|
+
floatingToolbarCopyButton: Boolean(typeof ((_props$featureFlags40 = props.featureFlags) === null || _props$featureFlags40 === void 0 ? void 0 : _props$featureFlags40.floatingToolbarCopyButton) === 'boolean' ? !!((_props$featureFlags41 = props.featureFlags) !== null && _props$featureFlags41 !== void 0 && _props$featureFlags41.floatingToolbarCopyButton) : false)
|
|
54
56
|
};
|
|
55
57
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Common Translations will live here
|
|
2
|
+
import { defineMessages } from 'react-intl-next';
|
|
3
|
+
export const messages = defineMessages({
|
|
4
|
+
indent: {
|
|
5
|
+
id: 'fabric.editor.indent',
|
|
6
|
+
defaultMessage: 'Indent',
|
|
7
|
+
description: 'Indent a list item, paragraph or heading'
|
|
8
|
+
},
|
|
9
|
+
outdent: {
|
|
10
|
+
id: 'fabric.editor.outdent',
|
|
11
|
+
defaultMessage: 'Outdent',
|
|
12
|
+
description: 'Outdent a list item, paragraph or heading'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
@@ -15,6 +15,7 @@ export { default as insertBlockPlugin } from './insert-block';
|
|
|
15
15
|
export { default as jiraIssuePlugin } from './jira-issue';
|
|
16
16
|
export { default as layoutPlugin } from './layout';
|
|
17
17
|
export { default as listPlugin } from './list';
|
|
18
|
+
export { default as toolbarListsIndentationPlugin } from './toolbar-lists-indentation';
|
|
18
19
|
export { default as macroPlugin } from './macro';
|
|
19
20
|
export { default as maxContentSizePlugin } from './max-content-size';
|
|
20
21
|
export { default as mediaPlugin } from './media';
|
|
@@ -63,4 +64,5 @@ export { default as undoRedoPlugin } from './undo-redo';
|
|
|
63
64
|
export { default as avatarGroupPlugin } from './avatar-group';
|
|
64
65
|
export { default as viewUpdateSubscriptionPlugin } from './view-update-subscription';
|
|
65
66
|
export { default as beforePrimaryToolbarPlugin } from './before-primaryToolbar';
|
|
66
|
-
export { default as codeBidiWarningPlugin } from './code-bidi-warning';
|
|
67
|
+
export { default as codeBidiWarningPlugin } from './code-bidi-warning';
|
|
68
|
+
export { default as copyButtonPlugin } from './copy-button';
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { orderedList, bulletList, listItem } from '@atlaskit/adf-schema';
|
|
3
|
-
import
|
|
4
|
-
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
3
|
+
import { createPlugin } from './pm-plugins/main';
|
|
5
4
|
import inputRulePlugin from './pm-plugins/input-rules';
|
|
6
5
|
import keymapPlugin from './pm-plugins/keymap';
|
|
7
|
-
import WithPluginState from '../../ui/WithPluginState';
|
|
8
6
|
import { messages } from './messages';
|
|
9
7
|
import { addAnalytics, ACTION, EVENT_TYPE, INPUT_METHOD, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '../analytics';
|
|
10
8
|
import { tooltip, toggleBulletList, toggleOrderedList } from '../../keymaps';
|
|
11
9
|
import { IconList, IconListNumber } from '../quick-insert/assets';
|
|
12
|
-
import { ToolbarSize } from '../../ui/Toolbar/types';
|
|
13
10
|
|
|
14
11
|
const listPlugin = () => ({
|
|
15
12
|
name: 'list',
|
|
@@ -93,47 +90,7 @@ const listPlugin = () => ({
|
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
}]
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
primaryToolbarComponent({
|
|
99
|
-
editorView,
|
|
100
|
-
popupsMountPoint,
|
|
101
|
-
popupsBoundariesElement,
|
|
102
|
-
popupsScrollableElement,
|
|
103
|
-
toolbarSize,
|
|
104
|
-
disabled,
|
|
105
|
-
isToolbarReducedSpacing
|
|
106
|
-
}) {
|
|
107
|
-
const isSmall = toolbarSize < ToolbarSize.L;
|
|
108
|
-
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
109
|
-
plugins: {
|
|
110
|
-
listState: pluginKey
|
|
111
|
-
},
|
|
112
|
-
render: ({
|
|
113
|
-
listState: listState
|
|
114
|
-
}) => {
|
|
115
|
-
if (!listState) {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return /*#__PURE__*/React.createElement(ToolbarLists, {
|
|
120
|
-
isSmall: isSmall,
|
|
121
|
-
isSeparator: true,
|
|
122
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
123
|
-
disabled: disabled,
|
|
124
|
-
editorView: editorView,
|
|
125
|
-
popupsMountPoint: popupsMountPoint,
|
|
126
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
127
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
128
|
-
bulletListActive: listState.bulletListActive,
|
|
129
|
-
bulletListDisabled: listState.bulletListDisabled,
|
|
130
|
-
orderedListActive: listState.orderedListActive,
|
|
131
|
-
orderedListDisabled: listState.orderedListDisabled
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
93
|
}
|
|
136
|
-
|
|
137
94
|
});
|
|
138
95
|
|
|
139
96
|
export default listPlugin;
|
|
@@ -16,6 +16,7 @@ import { DEFAULT_BORDER_COLOR } from '../../ui/ColorPalette/Palettes';
|
|
|
16
16
|
import { PanelType } from '@atlaskit/adf-schema';
|
|
17
17
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, withAnalytics } from '../analytics';
|
|
18
18
|
import { messages } from './message';
|
|
19
|
+
import { getCopyButtonConfig, showCopyButton } from '../copy-button/utils';
|
|
19
20
|
export const panelIconMap = {
|
|
20
21
|
[PanelType.INFO]: {
|
|
21
22
|
shortName: ':info:',
|
|
@@ -42,7 +43,7 @@ export const panelIconMap = {
|
|
|
42
43
|
id: 'atlassian-tip'
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
|
-
export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, activePanelType, activePanelColor, activePanelIcon) => {
|
|
46
|
+
export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, activePanelType, activePanelColor, activePanelIcon, state) => {
|
|
46
47
|
// TODO: ED-14403 investigate why these titles are not getting translated for the tooltips
|
|
47
48
|
const items = [{
|
|
48
49
|
id: 'editor.panel.info',
|
|
@@ -231,6 +232,12 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
|
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
|
|
235
|
+
if (state && showCopyButton(state)) {
|
|
236
|
+
items.push({
|
|
237
|
+
type: 'separator'
|
|
238
|
+
}, getCopyButtonConfig(state, formatMessage, panelNodeType));
|
|
239
|
+
}
|
|
240
|
+
|
|
234
241
|
items.push({
|
|
235
242
|
type: 'separator'
|
|
236
243
|
}, {
|
|
@@ -267,7 +274,7 @@ export const getToolbarConfig = (state, intl, options = {}, providerFactory) =>
|
|
|
267
274
|
}; // force toolbar to be turned on
|
|
268
275
|
|
|
269
276
|
|
|
270
|
-
const items = getToolbarItems(formatMessage, nodeType, options.allowCustomPanel || false, options.allowCustomPanel && options.allowCustomPanelEdit || false, providerFactory, panelType, options.allowCustomPanel ? panelColor : undefined, options.allowCustomPanel ? panelIcon || isStandardPanel(panelType) : undefined);
|
|
277
|
+
const items = getToolbarItems(formatMessage, nodeType, options.allowCustomPanel || false, options.allowCustomPanel && options.allowCustomPanelEdit || false, providerFactory, panelType, options.allowCustomPanel ? panelColor : undefined, options.allowCustomPanel ? panelIcon || isStandardPanel(panelType) : undefined, state);
|
|
271
278
|
|
|
272
279
|
const getDomRef = editorView => {
|
|
273
280
|
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
@@ -70,7 +70,7 @@ export const hoverRows = (hoveredRows, isInDanger) => createCommand(state => {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
}, tr => tr.setMeta('addToHistory', false));
|
|
73
|
-
export const hoverTable = isInDanger => createCommand(state => {
|
|
73
|
+
export const hoverTable = (isInDanger, isSelected) => createCommand(state => {
|
|
74
74
|
const table = findTable(state.selection);
|
|
75
75
|
|
|
76
76
|
if (!table) {
|
|
@@ -86,7 +86,7 @@ export const hoverTable = isInDanger => createCommand(state => {
|
|
|
86
86
|
return false;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
const decorations = createControlsHoverDecoration(cells, 'table', isInDanger);
|
|
89
|
+
const decorations = createControlsHoverDecoration(cells, 'table', isInDanger, isSelected);
|
|
90
90
|
return {
|
|
91
91
|
type: 'HOVER_TABLE',
|
|
92
92
|
data: {
|
|
@@ -14,7 +14,8 @@ import { splitCell } from '@atlaskit/editor-tables/utils';
|
|
|
14
14
|
import tableMessages from './ui/messages';
|
|
15
15
|
import { messages as ContextualMenuMessages } from './ui/FloatingContextualMenu/ContextualMenu';
|
|
16
16
|
import { findParentDomRefOfType } from 'prosemirror-utils';
|
|
17
|
-
import { closestElement } from '../../utils/dom';
|
|
17
|
+
import { closestElement } from '../../utils/dom';
|
|
18
|
+
import { getCopyButtonConfig, showCopyButton } from '../copy-button/utils'; // TODO: ED-14403 investigate why these translations don't work
|
|
18
19
|
|
|
19
20
|
export const messages = defineMessages({
|
|
20
21
|
tableOptions: {
|
|
@@ -244,7 +245,9 @@ export const getToolbarConfig = config => (state, intl) => {
|
|
|
244
245
|
items: [menu, separator(menu.hidden), ...cellItems, {
|
|
245
246
|
type: 'extensions-placeholder',
|
|
246
247
|
separator: 'end'
|
|
247
|
-
}, {
|
|
248
|
+
}, ...(state && showCopyButton(state) ? [getCopyButtonConfig(state, intl.formatMessage, nodeType, hoverTable(false, true), clearHoverSelection()), {
|
|
249
|
+
type: 'separator'
|
|
250
|
+
}] : []), {
|
|
248
251
|
id: 'editor.table.delete',
|
|
249
252
|
type: 'button',
|
|
250
253
|
appearance: 'danger',
|
|
@@ -13,13 +13,17 @@ export const createCellHoverDecoration = (cells, type) => cells.map(cell => Deco
|
|
|
13
13
|
}, {
|
|
14
14
|
key: TableDecorations.CELL_CONTROLS_HOVER
|
|
15
15
|
}));
|
|
16
|
-
export const createControlsHoverDecoration = (cells, type, danger) => cells.map(cell => {
|
|
16
|
+
export const createControlsHoverDecoration = (cells, type, danger, selected) => cells.map(cell => {
|
|
17
17
|
const classes = [ClassName.HOVERED_CELL];
|
|
18
18
|
|
|
19
19
|
if (danger) {
|
|
20
20
|
classes.push(ClassName.HOVERED_CELL_IN_DANGER);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
if (selected) {
|
|
24
|
+
classes.push(ClassName.SELECTED_CELL);
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
classes.push(type === 'column' ? ClassName.HOVERED_COLUMN : type === 'row' ? ClassName.HOVERED_ROW : ClassName.HOVERED_TABLE);
|
|
24
28
|
let key;
|
|
25
29
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ToolbarListsIndentation from './ui';
|
|
3
|
+
import WithPluginState from '../../ui/WithPluginState';
|
|
4
|
+
import { ToolbarSize } from '../../ui/Toolbar/types';
|
|
5
|
+
import { pluginKey as listPluginKey } from '../list/pm-plugins/main';
|
|
6
|
+
|
|
7
|
+
const toolbarListsIndentationPlugin = ({
|
|
8
|
+
showIndentationButtons
|
|
9
|
+
}) => ({
|
|
10
|
+
name: 'toolbarListsIndentation',
|
|
11
|
+
|
|
12
|
+
primaryToolbarComponent({
|
|
13
|
+
editorView,
|
|
14
|
+
popupsMountPoint,
|
|
15
|
+
popupsBoundariesElement,
|
|
16
|
+
popupsScrollableElement,
|
|
17
|
+
toolbarSize,
|
|
18
|
+
disabled,
|
|
19
|
+
isToolbarReducedSpacing
|
|
20
|
+
}) {
|
|
21
|
+
const isSmall = toolbarSize < ToolbarSize.L;
|
|
22
|
+
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
23
|
+
plugins: {
|
|
24
|
+
listState: listPluginKey
|
|
25
|
+
},
|
|
26
|
+
render: ({
|
|
27
|
+
listState: listState
|
|
28
|
+
}) => {
|
|
29
|
+
if (!listState) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
|
|
34
|
+
isSmall: isSmall,
|
|
35
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
36
|
+
disabled: disabled,
|
|
37
|
+
editorView: editorView,
|
|
38
|
+
popupsMountPoint: popupsMountPoint,
|
|
39
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
40
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
41
|
+
bulletListActive: listState.bulletListActive,
|
|
42
|
+
bulletListDisabled: listState.bulletListDisabled,
|
|
43
|
+
orderedListActive: listState.orderedListActive,
|
|
44
|
+
orderedListDisabled: listState.orderedListDisabled,
|
|
45
|
+
showIndentationButtons: !!showIndentationButtons
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export default toolbarListsIndentationPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
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 } from '../../../keymaps';
|
|
9
|
+
import ToolbarButton, { TOOLBAR_BUTTON } from '../../../ui/ToolbarButton';
|
|
10
|
+
import { messages } from '../../list/messages';
|
|
11
|
+
import { messages as indentationMessages } from '../../indentation/messages';
|
|
12
|
+
import { buttonGroupStyle, separatorStyles } from '../../../ui/styles';
|
|
13
|
+
export function Toolbar(props) {
|
|
14
|
+
const {
|
|
15
|
+
formatMessage
|
|
16
|
+
} = useIntl();
|
|
17
|
+
const {
|
|
18
|
+
disabled,
|
|
19
|
+
isReducedSpacing,
|
|
20
|
+
bulletListActive,
|
|
21
|
+
bulletListDisabled,
|
|
22
|
+
orderedListActive,
|
|
23
|
+
orderedListDisabled,
|
|
24
|
+
showIndentationButtons,
|
|
25
|
+
onItemActivated
|
|
26
|
+
} = props;
|
|
27
|
+
const labelUnorderedList = formatMessage(messages.unorderedList);
|
|
28
|
+
const labelOrderedList = formatMessage(messages.orderedList);
|
|
29
|
+
|
|
30
|
+
const handleOnItemActivated = buttonName => event => onItemActivated({
|
|
31
|
+
editorView: props.editorView,
|
|
32
|
+
buttonName
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return jsx("span", {
|
|
36
|
+
css: buttonGroupStyle
|
|
37
|
+
}, jsx(ToolbarButton, {
|
|
38
|
+
buttonId: TOOLBAR_BUTTON.BULLET_LIST,
|
|
39
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
40
|
+
onClick: handleOnItemActivated('bullet_list'),
|
|
41
|
+
selected: bulletListActive,
|
|
42
|
+
"aria-pressed": bulletListActive,
|
|
43
|
+
"aria-label": labelUnorderedList,
|
|
44
|
+
disabled: bulletListDisabled || disabled,
|
|
45
|
+
title: jsx(ToolTipContent, {
|
|
46
|
+
description: labelUnorderedList,
|
|
47
|
+
keymap: toggleBulletListKeymap
|
|
48
|
+
}),
|
|
49
|
+
iconBefore: jsx(BulletListIcon, {
|
|
50
|
+
label: ""
|
|
51
|
+
})
|
|
52
|
+
}), jsx(ToolbarButton, {
|
|
53
|
+
buttonId: TOOLBAR_BUTTON.ORDERED_LIST,
|
|
54
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
55
|
+
onClick: handleOnItemActivated('ordered_list'),
|
|
56
|
+
selected: orderedListActive,
|
|
57
|
+
"aria-pressed": orderedListActive,
|
|
58
|
+
"aria-label": labelOrderedList,
|
|
59
|
+
disabled: orderedListDisabled || disabled,
|
|
60
|
+
title: jsx(ToolTipContent, {
|
|
61
|
+
description: labelOrderedList,
|
|
62
|
+
keymap: toggleOrderedListKeymap
|
|
63
|
+
}),
|
|
64
|
+
iconBefore: jsx(NumberListIcon, {
|
|
65
|
+
label: ""
|
|
66
|
+
})
|
|
67
|
+
}), showIndentationButtons && jsx(ToolbarButton, {
|
|
68
|
+
buttonId: TOOLBAR_BUTTON.INDENT,
|
|
69
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
70
|
+
onClick: handleOnItemActivated('indent'),
|
|
71
|
+
iconBefore: jsx(IndentIcon, {
|
|
72
|
+
label: ""
|
|
73
|
+
}),
|
|
74
|
+
disabled: true,
|
|
75
|
+
title: jsx(ToolTipContent, {
|
|
76
|
+
description: formatMessage(indentationMessages.indent),
|
|
77
|
+
keymap: toggleIndentKeymap
|
|
78
|
+
})
|
|
79
|
+
}), showIndentationButtons && jsx(ToolbarButton, {
|
|
80
|
+
buttonId: TOOLBAR_BUTTON.OUTDENT,
|
|
81
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
82
|
+
onClick: handleOnItemActivated('outdent'),
|
|
83
|
+
iconBefore: jsx(OutdentIcon, {
|
|
84
|
+
label: ""
|
|
85
|
+
}),
|
|
86
|
+
disabled: true,
|
|
87
|
+
title: jsx(ToolTipContent, {
|
|
88
|
+
description: formatMessage(indentationMessages.outdent),
|
|
89
|
+
keymap: toggleOutdentKeymap
|
|
90
|
+
})
|
|
91
|
+
}), jsx("span", {
|
|
92
|
+
css: separatorStyles
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
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 DropdownMenu from '../../../ui/DropdownMenu';
|
|
9
|
+
import ToolbarButton from '../../../ui/ToolbarButton';
|
|
10
|
+
import { wrapperStyle, expandIconWrapperStyle, shortcutStyle, separatorStyles } from '../../../ui/styles';
|
|
11
|
+
import { messages as listMessages } from '../../list/messages';
|
|
12
|
+
import { messages as indentationMessages } from '../../indentation/messages';
|
|
13
|
+
export function ToolbarDropdown(props) {
|
|
14
|
+
const {
|
|
15
|
+
formatMessage
|
|
16
|
+
} = useIntl();
|
|
17
|
+
const {
|
|
18
|
+
disabled,
|
|
19
|
+
isReducedSpacing,
|
|
20
|
+
bulletListActive,
|
|
21
|
+
orderedListActive,
|
|
22
|
+
popupsMountPoint,
|
|
23
|
+
popupsBoundariesElement,
|
|
24
|
+
popupsScrollableElement,
|
|
25
|
+
onItemActivated
|
|
26
|
+
} = props;
|
|
27
|
+
const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);
|
|
28
|
+
const labelLists = formatMessage(listMessages.lists);
|
|
29
|
+
|
|
30
|
+
const onOpenChange = attrs => {
|
|
31
|
+
setIsDropdownOpen(attrs.isDropdownOpen);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const handleTriggerClick = () => {
|
|
35
|
+
onOpenChange({
|
|
36
|
+
isDropdownOpen: !isDropdownOpen
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const items = useItems(props);
|
|
41
|
+
|
|
42
|
+
const handleOnItemActivated = ({
|
|
43
|
+
item
|
|
44
|
+
}) => {
|
|
45
|
+
setIsDropdownOpen(false);
|
|
46
|
+
return onItemActivated({
|
|
47
|
+
editorView: props.editorView,
|
|
48
|
+
buttonName: item.value.name
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return jsx("span", {
|
|
53
|
+
css: wrapperStyle
|
|
54
|
+
}, jsx(DropdownMenu, {
|
|
55
|
+
items: items,
|
|
56
|
+
onItemActivated: handleOnItemActivated,
|
|
57
|
+
mountTo: popupsMountPoint,
|
|
58
|
+
boundariesElement: popupsBoundariesElement,
|
|
59
|
+
scrollableElement: popupsScrollableElement,
|
|
60
|
+
isOpen: isDropdownOpen,
|
|
61
|
+
onOpenChange: onOpenChange,
|
|
62
|
+
fitHeight: 188,
|
|
63
|
+
fitWidth: 175,
|
|
64
|
+
shouldUseDefaultRole: true
|
|
65
|
+
}, jsx(ToolbarButton, {
|
|
66
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
67
|
+
selected: bulletListActive || orderedListActive,
|
|
68
|
+
"aria-expanded": isDropdownOpen,
|
|
69
|
+
"aria-haspopup": true,
|
|
70
|
+
"aria-label": labelLists,
|
|
71
|
+
disabled: disabled,
|
|
72
|
+
onClick: handleTriggerClick,
|
|
73
|
+
title: labelLists,
|
|
74
|
+
iconBefore: jsx("span", {
|
|
75
|
+
css: wrapperStyle
|
|
76
|
+
}, jsx(BulletListIcon, {
|
|
77
|
+
label: labelLists
|
|
78
|
+
}), jsx("span", {
|
|
79
|
+
css: expandIconWrapperStyle
|
|
80
|
+
}, jsx(ExpandIcon, {
|
|
81
|
+
label: ""
|
|
82
|
+
})))
|
|
83
|
+
})), jsx("span", {
|
|
84
|
+
css: separatorStyles
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function useItems(props) {
|
|
89
|
+
const {
|
|
90
|
+
formatMessage
|
|
91
|
+
} = useIntl();
|
|
92
|
+
const labelUnorderedList = formatMessage(listMessages.unorderedList);
|
|
93
|
+
const labelOrderedList = formatMessage(listMessages.orderedList);
|
|
94
|
+
let items = [{
|
|
95
|
+
key: 'unorderedList',
|
|
96
|
+
content: labelUnorderedList,
|
|
97
|
+
value: {
|
|
98
|
+
name: 'bullet_list'
|
|
99
|
+
},
|
|
100
|
+
isDisabled: props.bulletListDisabled,
|
|
101
|
+
isActive: Boolean(props.bulletListActive),
|
|
102
|
+
elemAfter: jsx("div", {
|
|
103
|
+
css: shortcutStyle
|
|
104
|
+
}, tooltip(toggleBulletListKeymap))
|
|
105
|
+
}, {
|
|
106
|
+
key: 'orderedList',
|
|
107
|
+
content: labelOrderedList,
|
|
108
|
+
value: {
|
|
109
|
+
name: 'ordered_list'
|
|
110
|
+
},
|
|
111
|
+
isDisabled: props.orderedListDisabled,
|
|
112
|
+
isActive: Boolean(props.orderedListActive),
|
|
113
|
+
elemAfter: jsx("div", {
|
|
114
|
+
css: shortcutStyle
|
|
115
|
+
}, tooltip(toggleOrderedListKeymap))
|
|
116
|
+
}];
|
|
117
|
+
|
|
118
|
+
if (props.showIndentationButtons) {
|
|
119
|
+
const labelIndent = formatMessage(indentationMessages.indent);
|
|
120
|
+
const labelOutdent = formatMessage(indentationMessages.outdent);
|
|
121
|
+
items.push({
|
|
122
|
+
key: 'indent',
|
|
123
|
+
content: labelIndent,
|
|
124
|
+
value: {
|
|
125
|
+
name: 'indent'
|
|
126
|
+
},
|
|
127
|
+
isDisabled: true,
|
|
128
|
+
isActive: false,
|
|
129
|
+
elemAfter: jsx("div", {
|
|
130
|
+
css: shortcutStyle
|
|
131
|
+
}, tooltip(toggleIndentKeymap))
|
|
132
|
+
}, {
|
|
133
|
+
key: 'outdent',
|
|
134
|
+
content: labelOutdent,
|
|
135
|
+
value: {
|
|
136
|
+
name: 'outdent'
|
|
137
|
+
},
|
|
138
|
+
isDisabled: true,
|
|
139
|
+
isActive: false,
|
|
140
|
+
elemAfter: jsx("div", {
|
|
141
|
+
css: shortcutStyle
|
|
142
|
+
}, tooltip(toggleOutdentKeymap))
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return [{
|
|
147
|
+
items
|
|
148
|
+
}];
|
|
149
|
+
}
|