diff --git a/.webpack/js.js b/.webpack/js.js index bfb0af36..f828becd 100644 --- a/.webpack/js.js +++ b/.webpack/js.js @@ -93,6 +93,7 @@ module.exports = { [modules + '/cloud']: `${dirModules}/cloud.js`, [modules + '/user-menu']: `${dirModules}/user-menu/index.js`, [modules + '/polyfill']: `${dirModules}/polyfill.js`, + [modules + '/command-line']: `${dirModules}/command-line.js`, }, output: { filename: '[name].js', diff --git a/HELP.md b/HELP.md index 74f237e8..e9c45ce0 100644 --- a/HELP.md +++ b/HELP.md @@ -172,6 +172,7 @@ Then, start the server again with `cloudcmd` and reload the page. | `*` | select/unselect all | `+` | expand selection | `-` | shrink selection +| `:` | open Command Line | `Ctrl + X` | cut to buffer | `Ctrl + C` | copy to buffer | `Ctrl + V` | paste from buffer diff --git a/client/key/index.js b/client/key/index.js index 748b5c48..7a45028e 100644 --- a/client/key/index.js +++ b/client/key/index.js @@ -499,6 +499,11 @@ async function switchKey(event) { break; + case KEY.COLON: + CloudCmd.CommandLine.show(); + event.preventDefault(); + break; + /* чистим хранилище */ case KEY.D: if (ctrlMeta) { diff --git a/client/key/key.js b/client/key/key.js index 0ca7963f..b160beef 100644 --- a/client/key/key.js +++ b/client/key/key.js @@ -25,8 +25,6 @@ module.exports = { SEMICOLON : 52, - COLON : 54, - A : 65, C : 67, @@ -70,6 +68,7 @@ module.exports = { F9 : 120, F10 : 121, + COLON : 186, EQUAL : 187, HYPHEN : 189, DOT : 190, diff --git a/client/modules/command-line.js b/client/modules/command-line.js new file mode 100644 index 00000000..e4aeb94b --- /dev/null +++ b/client/modules/command-line.js @@ -0,0 +1,38 @@ +'use strict'; + +/* global CloudCmd */ + +CloudCmd.CommandLine = exports; + +const Images = require('../dom/images'); +const Dialog = require('../dom/dialog'); + +module.exports.init = () => {}; + +module.exports.show = show; +module.exports.hide = hide; + +async function show() { + const [, cmd] = await Dialog.prompt('Command Line', ''); + const TERMINAL = '^(t|terminal)'; + + if (RegExp(`${TERMINAL}$`).test(cmd)) { + return await CloudCmd.Terminal.show(); + } + + if (RegExp(TERMINAL).test(cmd)) { + const command = cmd.replace(RegExp(`${TERMINAL} `), ''); + const exitCode = await CloudCmd.TerminalRun.show({ + command: `bash -c '${command}'`, + }); + + if (exitCode === -1) + await Dialog.alert(`☝️ Looks like Terminal is disabled, start Cloud Coammnder with '--terminal' flag.`); + + return; + } +} + +function hide() { +} + diff --git a/json/modules.json b/json/modules.json index 17691e0b..6ed586d1 100644 --- a/json/modules.json +++ b/json/modules.json @@ -11,6 +11,7 @@ "markdown", "config", "contact", + "command-line", "upload", "operation", "konsole", diff --git a/package.json b/package.json index cc0d23ac..6802b55a 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "cloudcmd", "version": "16.4.1", "type": "commonjs", + "commitType": "colon", "author": "coderaiser (https://github.com/coderaiser)", "description": "File manager for the web with console and editor", "homepage": "http://cloudcmd.io",