@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't select {F...} text after adding it to textareas

Summary:
Fixes T10039. We add text to textareas in two cases:

- Users clicking assitance buttons in Remarkup text areas.
- Drag-and-drop file uploads.

In case (1), it makes sense to highlight the text (it shows the user what we inserted, and lets them undo the action easily if it isn't what they wanted).

In case (2), it does not. Users almost never want to delete or edit a file reference. It is slightly nice to have the reference as a visual callout, but I don't think this is a big deal.

Change the behavior so that we highlight only for remarkup buttons, not for drag-and-drop files.

Test Plan:
- Clicked an "isnert quote" button on remarkup assist area, got highlighted example text.
- Dragged and dropped a file, got text inserted with no highlight.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10039

Differential Revision: https://secure.phabricator.com/D14851

+46 -39
+28 -28
resources/celerity/map.php
··· 8 8 return array( 9 9 'names' => array( 10 10 'core.pkg.css' => '4cf32aa0', 11 - 'core.pkg.js' => 'e0379ae5', 11 + 'core.pkg.js' => '821768c9', 12 12 'darkconsole.pkg.js' => 'e7393ebb', 13 13 'differential.pkg.css' => '2de124c9', 14 - 'differential.pkg.js' => '6223dd9d', 14 + 'differential.pkg.js' => '64e69521', 15 15 'diffusion.pkg.css' => 'f45955ed', 16 16 'diffusion.pkg.js' => 'ca1c8b5a', 17 17 'maniphest.pkg.css' => '4845691a', ··· 459 459 'rsrc/js/core/Notification.js' => 'ccf1cbf8', 460 460 'rsrc/js/core/Prefab.js' => '666c80c5', 461 461 'rsrc/js/core/ShapedRequest.js' => '7cbe244b', 462 - 'rsrc/js/core/TextAreaUtils.js' => '5c93c52c', 462 + 'rsrc/js/core/TextAreaUtils.js' => '9e54692d', 463 463 'rsrc/js/core/Title.js' => 'df5e11d2', 464 464 'rsrc/js/core/ToolTip.js' => '1d298e3a', 465 465 'rsrc/js/core/behavior-active-nav.js' => 'e379b58e', ··· 469 469 'rsrc/js/core/behavior-crop.js' => 'fa0f4fc2', 470 470 'rsrc/js/core/behavior-dark-console.js' => 'f411b6ae', 471 471 'rsrc/js/core/behavior-device.js' => 'a205cf28', 472 - 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6d49590e', 472 + 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '4f6a4b4e', 473 473 'rsrc/js/core/behavior-error-log.js' => '6882e80a', 474 474 'rsrc/js/core/behavior-fancy-datepicker.js' => '8ae55229', 475 475 'rsrc/js/core/behavior-file-tree.js' => '88236f00', ··· 487 487 'rsrc/js/core/behavior-object-selector.js' => '49b73b36', 488 488 'rsrc/js/core/behavior-oncopy.js' => '2926fff2', 489 489 'rsrc/js/core/behavior-phabricator-nav.js' => '56a1ca03', 490 - 'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => 'c14b5995', 490 + 'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => '461fd61b', 491 491 'rsrc/js/core/behavior-refresh-csrf.js' => 'ab2f381b', 492 492 'rsrc/js/core/behavior-remarkup-preview.js' => 'f7379f45', 493 493 'rsrc/js/core/behavior-reorder-applications.js' => '76b9fc3e', ··· 565 565 'javelin-behavior-aphlict-status' => 'ea681761', 566 566 'javelin-behavior-aphront-basic-tokenizer' => 'b3a4b884', 567 567 'javelin-behavior-aphront-crop' => 'fa0f4fc2', 568 - 'javelin-behavior-aphront-drag-and-drop-textarea' => '6d49590e', 568 + 'javelin-behavior-aphront-drag-and-drop-textarea' => '4f6a4b4e', 569 569 'javelin-behavior-aphront-form-disable-on-submit' => '5c54cbf3', 570 570 'javelin-behavior-aphront-more' => 'a80d0378', 571 571 'javelin-behavior-audio-source' => '59b251eb', ··· 640 640 'javelin-behavior-phabricator-notification-example' => '8ce821c5', 641 641 'javelin-behavior-phabricator-object-selector' => '49b73b36', 642 642 'javelin-behavior-phabricator-oncopy' => '2926fff2', 643 - 'javelin-behavior-phabricator-remarkup-assist' => 'c14b5995', 643 + 'javelin-behavior-phabricator-remarkup-assist' => '461fd61b', 644 644 'javelin-behavior-phabricator-reveal-content' => '60821bc7', 645 645 'javelin-behavior-phabricator-search-typeahead' => '048330fa', 646 646 'javelin-behavior-phabricator-show-older-transactions' => 'dbbf48b6', ··· 766 766 'phabricator-slowvote-css' => 'da0afb1b', 767 767 'phabricator-source-code-view-css' => 'cbeef983', 768 768 'phabricator-standard-page-view' => '3c99cdf4', 769 - 'phabricator-textareautils' => '5c93c52c', 769 + 'phabricator-textareautils' => '9e54692d', 770 770 'phabricator-title' => 'df5e11d2', 771 771 'phabricator-tooltip' => '1d298e3a', 772 772 'phabricator-ui-example-css' => '528b19de', ··· 1100 1100 'javelin-behavior', 1101 1101 'javelin-dom', 1102 1102 ), 1103 + '461fd61b' => array( 1104 + 'javelin-behavior', 1105 + 'javelin-stratcom', 1106 + 'javelin-dom', 1107 + 'phabricator-phtize', 1108 + 'phabricator-textareautils', 1109 + 'javelin-workflow', 1110 + 'javelin-vector', 1111 + ), 1103 1112 '469c0d9e' => array( 1104 1113 'javelin-behavior', 1105 1114 'javelin-dom', ··· 1137 1146 'javelin-stratcom', 1138 1147 'javelin-dom', 1139 1148 ), 1149 + '4f6a4b4e' => array( 1150 + 'javelin-behavior', 1151 + 'javelin-dom', 1152 + 'phabricator-drag-and-drop-file-upload', 1153 + 'phabricator-textareautils', 1154 + ), 1140 1155 '4fdb476d' => array( 1141 1156 'javelin-behavior', 1142 1157 'javelin-stratcom', ··· 1238 1253 'javelin-stratcom', 1239 1254 'javelin-dom', 1240 1255 ), 1241 - '5c93c52c' => array( 1242 - 'javelin-install', 1243 - 'javelin-dom', 1244 - 'javelin-vector', 1245 - ), 1246 1256 '5d7c9f33' => array( 1247 1257 'javelin-behavior', 1248 1258 'javelin-stratcom', ··· 1336 1346 'javelin-dom', 1337 1347 'javelin-typeahead', 1338 1348 'javelin-uri', 1339 - ), 1340 - '6d49590e' => array( 1341 - 'javelin-behavior', 1342 - 'javelin-dom', 1343 - 'phabricator-drag-and-drop-file-upload', 1344 - 'phabricator-textareautils', 1345 1349 ), 1346 1350 '70baed2f' => array( 1347 1351 'javelin-install', ··· 1557 1561 'javelin-dom', 1558 1562 'javelin-reactor-dom', 1559 1563 ), 1564 + '9e54692d' => array( 1565 + 'javelin-install', 1566 + 'javelin-dom', 1567 + 'javelin-vector', 1568 + ), 1560 1569 '9f36c42d' => array( 1561 1570 'javelin-behavior', 1562 1571 'javelin-stratcom', ··· 1764 1773 'bff6884b' => array( 1765 1774 'javelin-install', 1766 1775 'javelin-dom', 1767 - ), 1768 - 'c14b5995' => array( 1769 - 'javelin-behavior', 1770 - 'javelin-stratcom', 1771 - 'javelin-dom', 1772 - 'phabricator-phtize', 1773 - 'phabricator-textareautils', 1774 - 'javelin-workflow', 1775 - 'javelin-vector', 1776 1776 ), 1777 1777 'c1700f6f' => array( 1778 1778 'javelin-install',
+9 -2
webroot/rsrc/js/core/TextAreaUtils.js
··· 38 38 } 39 39 }, 40 40 41 - setSelectionText : function(area, text) { 41 + setSelectionText : function(area, text, select) { 42 42 var v = area.value; 43 43 var r = JX.TextAreaUtils.getSelectionRange(area); 44 44 45 45 v = v.substring(0, r.start) + text + v.substring(r.end, v.length); 46 46 area.value = v; 47 47 48 - JX.TextAreaUtils.setSelectionRange(area, r.start, r.start + text.length); 48 + var start = r.start; 49 + var end = r.start + text.length; 50 + 51 + if (!select) { 52 + start = end; 53 + } 54 + 55 + JX.TextAreaUtils.setSelectionRange(area, start, end); 49 56 }, 50 57 51 58 /**
+8 -8
webroot/rsrc/js/core/behavior-drag-and-drop-textarea.js
··· 11 11 var target = JX.$(config.target); 12 12 13 13 function onupload(f) { 14 - var text = JX.TextAreaUtils.getSelectionText(target); 15 14 var ref = '{F' + f.getID() + '}'; 16 15 17 - // If the user has dragged and dropped multiple files, we'll get an event 18 - // each time an upload completes. Rather than overwriting the first 19 - // reference, append the new reference if the selected text looks like an 20 - // existing file reference. 21 - if (text.match(/^\{F/)) { 22 - ref = text + '\n\n' + ref; 16 + // If we're inserting immediately after a "}" (usually, another file 17 + // reference), put some newlines before our token so that multiple file 18 + // uploads get laid out more nicely. 19 + var range = JX.TextAreaUtils.getSelectionRange(target); 20 + var before = target.value.substring(0, range.start); 21 + if (before.match(/\}$/)) { 22 + ref = '\n\n' + ref; 23 23 } 24 24 25 - JX.TextAreaUtils.setSelectionText(target, ref); 25 + JX.TextAreaUtils.setSelectionText(target, ref, false); 26 26 } 27 27 28 28 if (JX.PhabricatorDragAndDropFileUpload.isSupported()) {
+1 -1
webroot/rsrc/js/core/behavior-phabricator-remarkup-assist.js
··· 81 81 82 82 function update(area, l, m, r) { 83 83 // Replace the selection with the entire assisted text. 84 - JX.TextAreaUtils.setSelectionText(area, l + m + r); 84 + JX.TextAreaUtils.setSelectionText(area, l + m + r, true); 85 85 86 86 // Now, select just the middle part. For instance, if the user clicked 87 87 // "B" to create bold text, we insert '**bold**' but just select the word