@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.

Use pseudoelements, not Zero Width Space, to implement copy/paste behavior in Paste/Diffusion

Summary:
Depends on D19348. Ref T13105. When copying text from Paste or Diffusion, we'd like to copy only source, not line numbers.

We currently accomplish this with zero-width spaces plus a trigger that fires on "copy" in Paste and Diffusion. This is quite gross.

In the new-style Harbormaster logs, we use an approach that seems slightly better: CSS psuedoelements.

This isn't a complete solution (see also PHI504 / T5032) but puts us in a slightly better place.

Use it in Paste/Files/Diffusion too.

This gives us good behavior in all browsers in Files and Paste.

This gives us good behavior in Chrome and Firefox in Diffusion. Safari will copy (but not visually select) blame information in Diffusion. I think we can live with that for now.

Test Plan: Selected and copy/pasted stuff in Diffusion, Files, and Paste. Got good behavior everywhere except Safari + Diffusion.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13105

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

+23 -32
+10 -10
resources/celerity/map.php
··· 119 119 'rsrc/css/font/font-lato.css' => 'c7ccd872', 120 120 'rsrc/css/font/phui-font-icon-base.css' => '870a7360', 121 121 'rsrc/css/layout/phabricator-filetree-view.css' => 'b912ad97', 122 - 'rsrc/css/layout/phabricator-source-code-view.css' => 'c5edc888', 122 + 'rsrc/css/layout/phabricator-source-code-view.css' => '09368218', 123 123 'rsrc/css/phui/button/phui-button-bar.css' => 'f1ff5494', 124 124 'rsrc/css/phui/button/phui-button-simple.css' => '8e1baf68', 125 125 'rsrc/css/phui/button/phui-button.css' => '1863cc6e', ··· 471 471 'rsrc/js/core/behavior-keyboard-pager.js' => 'a8da01f0', 472 472 'rsrc/js/core/behavior-keyboard-shortcuts.js' => '01fca1f0', 473 473 'rsrc/js/core/behavior-lightbox-attachments.js' => '6b31879a', 474 - 'rsrc/js/core/behavior-line-linker.js' => '69837bed', 474 + 'rsrc/js/core/behavior-line-linker.js' => '36165eb1', 475 475 'rsrc/js/core/behavior-more.js' => 'a80d0378', 476 476 'rsrc/js/core/behavior-object-selector.js' => '77c1f0b0', 477 477 'rsrc/js/core/behavior-oncopy.js' => '2926fff2', ··· 634 634 'javelin-behavior-phabricator-gesture-example' => '558829c2', 635 635 'javelin-behavior-phabricator-keyboard-pager' => 'a8da01f0', 636 636 'javelin-behavior-phabricator-keyboard-shortcuts' => '01fca1f0', 637 - 'javelin-behavior-phabricator-line-linker' => '69837bed', 637 + 'javelin-behavior-phabricator-line-linker' => '36165eb1', 638 638 'javelin-behavior-phabricator-nav' => '94b7c320', 639 639 'javelin-behavior-phabricator-notification-example' => '8ce821c5', 640 640 'javelin-behavior-phabricator-object-selector' => '77c1f0b0', ··· 780 780 'phabricator-search-results-css' => '505dd8cf', 781 781 'phabricator-shaped-request' => '7cbe244b', 782 782 'phabricator-slowvote-css' => 'a94b7230', 783 - 'phabricator-source-code-view-css' => 'c5edc888', 783 + 'phabricator-source-code-view-css' => '09368218', 784 784 'phabricator-standard-page-view' => '34ee718b', 785 785 'phabricator-textareautils' => '320810c8', 786 786 'phabricator-title' => '485aaa6c', ··· 1098 1098 'javelin-dom', 1099 1099 'javelin-vector', 1100 1100 ), 1101 + '36165eb1' => array( 1102 + 'javelin-behavior', 1103 + 'javelin-stratcom', 1104 + 'javelin-dom', 1105 + 'javelin-history', 1106 + ), 1101 1107 '3ab51e2c' => array( 1102 1108 'javelin-behavior', 1103 1109 'javelin-behavior-device', ··· 1406 1412 'javelin-install', 1407 1413 'javelin-dom', 1408 1414 'phuix-button-view', 1409 - ), 1410 - '69837bed' => array( 1411 - 'javelin-behavior', 1412 - 'javelin-stratcom', 1413 - 'javelin-dom', 1414 - 'javelin-history', 1415 1415 ), 1416 1416 '69adf288' => array( 1417 1417 'javelin-install',
+8 -12
src/view/layout/PhabricatorSourceCodeView.php
··· 66 66 require_celerity_resource('phabricator-source-code-view-css'); 67 67 require_celerity_resource('syntax-highlighting-css'); 68 68 69 - Javelin::initBehavior('phabricator-oncopy', array()); 70 69 if ($this->canClickHighlight) { 71 70 Javelin::initBehavior('phabricator-line-linker'); 72 71 } ··· 78 77 $lines = $this->lines; 79 78 if ($this->truncatedFirstLines) { 80 79 $lines[] = phutil_tag( 81 - 'span', 82 - array( 83 - 'class' => 'c', 84 - ), 85 - pht('...')); 80 + 'span', 81 + array( 82 + 'class' => 'c', 83 + ), 84 + pht('...')); 86 85 } else if ($this->truncatedFirstBytes) { 87 86 $last_key = last_key($lines); 88 87 $lines[$last_key] = hsprintf( ··· 98 97 99 98 $base_uri = (string)$this->uri; 100 99 foreach ($lines as $line) { 101 - // NOTE: See phabricator-oncopy behavior. 102 - $content_line = hsprintf("\xE2\x80\x8B%s", $line); 103 - 104 100 $row_attributes = array(); 105 101 if (isset($this->highlights[$line_number])) { 106 102 $row_attributes['class'] = 'phabricator-source-highlight'; ··· 117 113 'a', 118 114 array( 119 115 'href' => $line_href, 120 - ), 121 - $line_number); 116 + 'data-n' => $line_number, 117 + )); 122 118 } else { 123 119 $tag_number = phutil_tag( 124 120 'span', ··· 172 168 array( 173 169 'class' => 'phabricator-source-code', 174 170 ), 175 - $content_line), 171 + $line), 176 172 )); 177 173 178 174 $line_number++;
+4 -9
webroot/rsrc/css/layout/phabricator-source-code-view.css
··· 25 25 text-align: right; 26 26 border-right: 1px solid {$paste.border}; 27 27 color: {$sh-yellowtext}; 28 + } 28 29 29 - /* When the user selects rows of source, don't visibly select the line 30 - numbers beside them. We use JS to strip the line numbers out when the user 31 - copies the text. */ 32 - -moz-user-select: -moz-none; 33 - -khtml-user-select: none; 34 - -webkit-user-select: none; 35 - -ms-user-select: none; 36 - user-select: none; 37 - white-space: nowrap; 30 + .phabricator-source-line > a::before { 31 + /* Render the line numbers as a pseudo-element so they don't get copied. */ 32 + content: attr(data-n); 38 33 } 39 34 40 35 th.phabricator-source-line a,
+1 -1
webroot/rsrc/js/core/behavior-line-linker.js
··· 29 29 } 30 30 } 31 31 32 - return +(th.textContent || th.innerText); 32 + return null; 33 33 } 34 34 35 35 JX.Stratcom.listen(