diff --git a/packages/xod-client-electron/src/view/containers/App.jsx b/packages/xod-client-electron/src/view/containers/App.jsx index a0d192268..d7512ba6a 100644 --- a/packages/xod-client-electron/src/view/containers/App.jsx +++ b/packages/xod-client-electron/src/view/containers/App.jsx @@ -575,7 +575,19 @@ class App extends client.App { items.cut, items.copy, items.paste, - items.selectall, + onClick(items.selectall, () => { + // We can't use `role: 'selectall'` here, cause it ignores `onClick`. + // So we have to handle all cases manually: + + // - select all in inputs + if (client.isInput(document.activeElement)) { + document.activeElement.select(); + return; + } + + // - select entities on Patch + this.props.actions.selectAll(); + }), items.separator, onClick(items.insertNode, () => this.props.actions.showSuggester(null)), onClick(items.insertComment, this.props.actions.addComment), diff --git a/packages/xod-client/src/core/containers/App.jsx b/packages/xod-client/src/core/containers/App.jsx index fd0e0b052..99781703d 100644 --- a/packages/xod-client/src/core/containers/App.jsx +++ b/packages/xod-client/src/core/containers/App.jsx @@ -20,6 +20,7 @@ import PopupProjectPreferences from '../../project/components/PopupProjectPrefer import PopupPublishProject from '../../project/components/PopupPublishProject'; import * as actions from '../actions'; +import { selectAll } from '../../editor/actions'; import { NO_PATCH_TO_TRANSPILE } from '../../editor/messages'; import formatErrorMessage from '../formatErrorMessage'; @@ -177,6 +178,7 @@ App.propTypes = { }; App.actions = { + selectAll, updateCompileLimit: actions.updateCompileLimit, createProject: actions.createProject, requestPublishProject: actions.requestPublishProject, diff --git a/packages/xod-client/src/editor/actions.js b/packages/xod-client/src/editor/actions.js index 84ec7ca65..c4406361d 100644 --- a/packages/xod-client/src/editor/actions.js +++ b/packages/xod-client/src/editor/actions.js @@ -113,6 +113,16 @@ export const setEditorSelection = entities => ({ payload: { entities }, }); +export const selectAll = () => (dispatch, getState) => { + const state = getState(); + const selection = { + nodes: R.values(ProjectSelectors.getCurrentPatchNodes(state)), + links: R.values(ProjectSelectors.getCurrentPatchLinks(state)), + comments: R.values(ProjectSelectors.getCurrentPatchComments(state)), + }; + return dispatch(setEditorSelection(selection)); +}; + export const addAndSelectNode = ( typeId, position, diff --git a/packages/xod-client/src/editor/containers/Patch/index.jsx b/packages/xod-client/src/editor/containers/Patch/index.jsx index 1f6ab754a..ecb9d3494 100644 --- a/packages/xod-client/src/editor/containers/Patch/index.jsx +++ b/packages/xod-client/src/editor/containers/Patch/index.jsx @@ -334,6 +334,7 @@ const mapDispatchToProps = dispatch => ({ resizeNode: ProjectActions.resizeNode, deselectAll: EditorActions.deselectAll, deleteSelection: EditorActions.deleteSelection, + selectAll: EditorActions.selectAll, selectLink: EditorActions.selectLink, selectNode: EditorActions.selectNode, selectComment: EditorActions.selectComment, diff --git a/packages/xod-client/src/editor/containers/Patch/modes/selecting.jsx b/packages/xod-client/src/editor/containers/Patch/modes/selecting.jsx index da97fa348..f3083b80c 100644 --- a/packages/xod-client/src/editor/containers/Patch/modes/selecting.jsx +++ b/packages/xod-client/src/editor/containers/Patch/modes/selecting.jsx @@ -198,12 +198,8 @@ const selectingMode = { }, onSelectAll({ props }, event) { if (isInputTarget(event)) return; - event.preventDefault(); - - props.actions.setSelection( - R.compose(R.map(R.values), R.pick(['nodes', 'links', 'comments']))(props) - ); + props.actions.selectAll(); }, onBackgroundClick(api, event) { // to prevent misclicks when selecting multiple entities diff --git a/packages/xod-client/src/utils/menu.js b/packages/xod-client/src/utils/menu.js index 9223df028..9d465de4d 100644 --- a/packages/xod-client/src/utils/menu.js +++ b/packages/xod-client/src/utils/menu.js @@ -80,7 +80,6 @@ const rawItems = { selectall: { label: 'Select All', command: COMMAND.SELECT_ALL, - role: 'selectall', }, projectPreferences: { label: 'Project Preferences',