mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 15:30:58 +01:00
Prevent Send on Enter in Fullscreen Remarkup Mode
Summary: Fixes T12138. Test for the presence of being in fullscreen mode, and disable send on enter if present. Side note, I'd love a first class "hasClass" type Javelin function. Test Plan: - Go to Conpherence - Type some smack, see it send on enter - Go fullscreen like a boss - Let the words flow - Close fullscreen, then send on enter. - (might be nice someday to add a "submit" button to fullscreen editor) Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12138 Differential Revision: https://secure.phabricator.com/D17590
This commit is contained in:
parent
dee9c33be2
commit
4a84954957
5 changed files with 75 additions and 54 deletions
|
@ -8,9 +8,9 @@
|
|||
return array(
|
||||
'names' => array(
|
||||
'conpherence.pkg.css' => '82aca405',
|
||||
'conpherence.pkg.js' => '6249a1cf',
|
||||
'conpherence.pkg.js' => '281b1a73',
|
||||
'core.pkg.css' => '1bf8fa70',
|
||||
'core.pkg.js' => '021685f1',
|
||||
'core.pkg.js' => 'fbc1c380',
|
||||
'darkconsole.pkg.js' => 'e7393ebb',
|
||||
'differential.pkg.css' => '90b30783',
|
||||
'differential.pkg.js' => 'ddfeb49b',
|
||||
|
@ -375,7 +375,7 @@ return array(
|
|||
'rsrc/js/application/conpherence/behavior-durable-column.js' => 'aa3bd034',
|
||||
'rsrc/js/application/conpherence/behavior-menu.js' => '7524fcfa',
|
||||
'rsrc/js/application/conpherence/behavior-participant-pane.js' => '8604caa8',
|
||||
'rsrc/js/application/conpherence/behavior-pontificate.js' => 'f2e58483',
|
||||
'rsrc/js/application/conpherence/behavior-pontificate.js' => '55616e04',
|
||||
'rsrc/js/application/conpherence/behavior-quicksand-blacklist.js' => '7927a7d3',
|
||||
'rsrc/js/application/conpherence/behavior-toggle-widget.js' => '3dbf94d5',
|
||||
'rsrc/js/application/countdown/timer.js' => 'e4cc26b3',
|
||||
|
@ -503,7 +503,7 @@ return array(
|
|||
'rsrc/js/core/behavior-object-selector.js' => 'e0ec7f2f',
|
||||
'rsrc/js/core/behavior-oncopy.js' => '2926fff2',
|
||||
'rsrc/js/core/behavior-phabricator-nav.js' => '08675c6d',
|
||||
'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => 'a0777ea3',
|
||||
'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => '0ca788bd',
|
||||
'rsrc/js/core/behavior-read-only-warning.js' => 'ba158207',
|
||||
'rsrc/js/core/behavior-refresh-csrf.js' => 'ab2f381b',
|
||||
'rsrc/js/core/behavior-remarkup-preview.js' => '4b700e9e',
|
||||
|
@ -600,7 +600,7 @@ return array(
|
|||
'javelin-behavior-config-reorder-fields' => 'b6993408',
|
||||
'javelin-behavior-conpherence-menu' => '7524fcfa',
|
||||
'javelin-behavior-conpherence-participant-pane' => '8604caa8',
|
||||
'javelin-behavior-conpherence-pontificate' => 'f2e58483',
|
||||
'javelin-behavior-conpherence-pontificate' => '55616e04',
|
||||
'javelin-behavior-conpherence-search' => '9bbf3762',
|
||||
'javelin-behavior-countdown-timer' => 'e4cc26b3',
|
||||
'javelin-behavior-dark-console' => 'f411b6ae',
|
||||
|
@ -664,7 +664,7 @@ return array(
|
|||
'javelin-behavior-phabricator-notification-example' => '8ce821c5',
|
||||
'javelin-behavior-phabricator-object-selector' => 'e0ec7f2f',
|
||||
'javelin-behavior-phabricator-oncopy' => '2926fff2',
|
||||
'javelin-behavior-phabricator-remarkup-assist' => 'a0777ea3',
|
||||
'javelin-behavior-phabricator-remarkup-assist' => '0ca788bd',
|
||||
'javelin-behavior-phabricator-reveal-content' => '60821bc7',
|
||||
'javelin-behavior-phabricator-search-typeahead' => '06c32383',
|
||||
'javelin-behavior-phabricator-show-older-transactions' => '94c65b72',
|
||||
|
@ -988,6 +988,17 @@ return array(
|
|||
'javelin-dom',
|
||||
'javelin-router',
|
||||
),
|
||||
'0ca788bd' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
'phabricator-phtize',
|
||||
'phabricator-textareautils',
|
||||
'javelin-workflow',
|
||||
'javelin-vector',
|
||||
'phuix-autocomplete',
|
||||
'javelin-mask',
|
||||
),
|
||||
'0f764c35' => array(
|
||||
'javelin-install',
|
||||
'javelin-util',
|
||||
|
@ -1298,6 +1309,14 @@ return array(
|
|||
'javelin-request',
|
||||
'javelin-typeahead-source',
|
||||
),
|
||||
'55616e04' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-dom',
|
||||
'javelin-util',
|
||||
'javelin-workflow',
|
||||
'javelin-stratcom',
|
||||
'conpherence-thread-manager',
|
||||
),
|
||||
'558829c2' => array(
|
||||
'javelin-stratcom',
|
||||
'javelin-behavior',
|
||||
|
@ -1686,17 +1705,6 @@ return array(
|
|||
'javelin-dom',
|
||||
'javelin-vector',
|
||||
),
|
||||
'a0777ea3' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
'phabricator-phtize',
|
||||
'phabricator-textareautils',
|
||||
'javelin-workflow',
|
||||
'javelin-vector',
|
||||
'phuix-autocomplete',
|
||||
'javelin-mask',
|
||||
),
|
||||
'a0b57eb8' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-dom',
|
||||
|
@ -2165,14 +2173,6 @@ return array(
|
|||
'f12cbc9f' => array(
|
||||
'phui-oi-list-view-css',
|
||||
),
|
||||
'f2e58483' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-dom',
|
||||
'javelin-util',
|
||||
'javelin-workflow',
|
||||
'javelin-stratcom',
|
||||
'conpherence-thread-manager',
|
||||
),
|
||||
'f411b6ae' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
|
|
|
@ -184,6 +184,7 @@ final class ConpherenceViewController extends
|
|||
id(new PhabricatorRemarkupControl())
|
||||
->setUser($user)
|
||||
->setName('text')
|
||||
->setSendOnEnter(true)
|
||||
->setValue($draft->getDraft()));
|
||||
|
||||
$status_view = phutil_tag(
|
||||
|
|
|
@ -5,6 +5,7 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
|
|||
private $disableMacro = false;
|
||||
private $disableFullScreen = false;
|
||||
private $canPin;
|
||||
private $sendOnEnter = false;
|
||||
|
||||
public function setDisableMacros($disable) {
|
||||
$this->disableMacro = $disable;
|
||||
|
@ -25,6 +26,15 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
|
|||
return $this->canPin;
|
||||
}
|
||||
|
||||
public function setSendOnEnter($soe) {
|
||||
$this->sendOnEnter = $soe;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSendOnEnter() {
|
||||
return $this->sendOnEnter;
|
||||
}
|
||||
|
||||
protected function renderInput() {
|
||||
$id = $this->getID();
|
||||
if (!$id) {
|
||||
|
@ -78,6 +88,7 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
|
|||
),
|
||||
'canPin' => $this->getCanPin(),
|
||||
'disabled' => $this->getDisabled(),
|
||||
'sendOnEnter' => $this->getSendOnEnter(),
|
||||
'rootID' => $root_id,
|
||||
'autocompleteMap' => (object)array(
|
||||
64 => array( // "@"
|
||||
|
|
|
@ -22,27 +22,4 @@ JX.behavior('conpherence-pontificate', function() {
|
|||
'conpherence-pontificate',
|
||||
_sendMessage);
|
||||
|
||||
// Send on enter if the shift key is not held.
|
||||
JX.Stratcom.listen(
|
||||
'keydown',
|
||||
'conpherence-pontificate',
|
||||
function(e) {
|
||||
if (e.getSpecialKey() != 'return') {
|
||||
return;
|
||||
}
|
||||
|
||||
var raw = e.getRawEvent();
|
||||
if (raw.shiftKey) {
|
||||
// If the shift key is pressed, let the browser write a newline into
|
||||
// the textarea.
|
||||
return;
|
||||
}
|
||||
|
||||
// From here on, interpret this as a "send" action, not a literal
|
||||
// newline.
|
||||
e.kill();
|
||||
|
||||
_sendMessage(e);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -37,7 +37,7 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
|
|||
|
||||
// First, disable any active mode.
|
||||
if (edit_root) {
|
||||
if (edit_mode == 'fa-arrows-alt') {
|
||||
if (edit_mode == 'fullscreen') {
|
||||
JX.DOM.alterClass(edit_root, 'remarkup-control-fullscreen-mode', false);
|
||||
JX.DOM.alterClass(document.body, 'remarkup-fullscreen-mode', false);
|
||||
JX.Mask.hide('jx-light-mask');
|
||||
|
@ -58,7 +58,7 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
|
|||
edit_mode = mode;
|
||||
|
||||
// Now, apply the new mode.
|
||||
if (mode == 'fa-arrows-alt') {
|
||||
if (mode == 'fullscreen') {
|
||||
JX.DOM.alterClass(edit_root, 'remarkup-control-fullscreen-mode', true);
|
||||
JX.DOM.alterClass(document.body, 'remarkup-fullscreen-mode', true);
|
||||
JX.Mask.show('jx-light-mask');
|
||||
|
@ -118,7 +118,7 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
|
|||
if (!edit_root) {
|
||||
return;
|
||||
}
|
||||
if (edit_mode != 'fa-arrows-alt') {
|
||||
if (edit_mode != 'fullscreen') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (edit_mode != 'fa-arrows-alt') {
|
||||
if (edit_mode != 'fullscreen') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -261,10 +261,10 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
|
|||
break;
|
||||
case 'fa-arrows-alt':
|
||||
set_pinned_mode(root, false);
|
||||
if (edit_mode == 'fa-arrows-alt') {
|
||||
if (edit_mode == 'fullscreen') {
|
||||
set_edit_mode(root, 'normal');
|
||||
} else {
|
||||
set_edit_mode(root, 'fa-arrows-alt');
|
||||
set_edit_mode(root, 'fullscreen');
|
||||
}
|
||||
break;
|
||||
case 'fa-eye':
|
||||
|
@ -385,4 +385,36 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
|
|||
.register();
|
||||
}
|
||||
|
||||
if (config.sendOnEnter) {
|
||||
// Send on enter if the shift key is not held.
|
||||
JX.DOM.listen(area, 'keydown', null,
|
||||
function(e) {
|
||||
if (e.getSpecialKey() != 'return') {
|
||||
return;
|
||||
}
|
||||
|
||||
var raw = e.getRawEvent();
|
||||
if (raw.shiftKey) {
|
||||
// If the shift key is pressed, let the browser write a newline into
|
||||
// the textarea.
|
||||
return;
|
||||
}
|
||||
|
||||
if (edit_mode == 'fullscreen') {
|
||||
// Don't send on enter in fullscreen
|
||||
return;
|
||||
}
|
||||
|
||||
// From here on, interpret this as a "send" action, not a literal
|
||||
// newline.
|
||||
e.kill();
|
||||
|
||||
// This allows 'workflow' and similar actions to take effect.
|
||||
// Such as pontificate in Conpherence
|
||||
var form = e.getNode('tag:form');
|
||||
var r = JX.DOM.invoke(form, 'didSyntheticSubmit');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue