diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 82d56b8c04..9853c35217 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -119,7 +119,7 @@ return array( 'rsrc/css/font/font-lato.css' => 'c7ccd872', 'rsrc/css/font/phui-font-icon-base.css' => '870a7360', 'rsrc/css/layout/phabricator-filetree-view.css' => 'b912ad97', - 'rsrc/css/layout/phabricator-source-code-view.css' => 'c5edc888', + 'rsrc/css/layout/phabricator-source-code-view.css' => '09368218', 'rsrc/css/phui/button/phui-button-bar.css' => 'f1ff5494', 'rsrc/css/phui/button/phui-button-simple.css' => '8e1baf68', 'rsrc/css/phui/button/phui-button.css' => '1863cc6e', @@ -471,7 +471,7 @@ return array( 'rsrc/js/core/behavior-keyboard-pager.js' => 'a8da01f0', 'rsrc/js/core/behavior-keyboard-shortcuts.js' => '01fca1f0', 'rsrc/js/core/behavior-lightbox-attachments.js' => '6b31879a', - 'rsrc/js/core/behavior-line-linker.js' => '69837bed', + 'rsrc/js/core/behavior-line-linker.js' => '36165eb1', 'rsrc/js/core/behavior-more.js' => 'a80d0378', 'rsrc/js/core/behavior-object-selector.js' => '77c1f0b0', 'rsrc/js/core/behavior-oncopy.js' => '2926fff2', @@ -634,7 +634,7 @@ return array( 'javelin-behavior-phabricator-gesture-example' => '558829c2', 'javelin-behavior-phabricator-keyboard-pager' => 'a8da01f0', 'javelin-behavior-phabricator-keyboard-shortcuts' => '01fca1f0', - 'javelin-behavior-phabricator-line-linker' => '69837bed', + 'javelin-behavior-phabricator-line-linker' => '36165eb1', 'javelin-behavior-phabricator-nav' => '94b7c320', 'javelin-behavior-phabricator-notification-example' => '8ce821c5', 'javelin-behavior-phabricator-object-selector' => '77c1f0b0', @@ -780,7 +780,7 @@ return array( 'phabricator-search-results-css' => '505dd8cf', 'phabricator-shaped-request' => '7cbe244b', 'phabricator-slowvote-css' => 'a94b7230', - 'phabricator-source-code-view-css' => 'c5edc888', + 'phabricator-source-code-view-css' => '09368218', 'phabricator-standard-page-view' => '34ee718b', 'phabricator-textareautils' => '320810c8', 'phabricator-title' => '485aaa6c', @@ -1098,6 +1098,12 @@ return array( 'javelin-dom', 'javelin-vector', ), + '36165eb1' => array( + 'javelin-behavior', + 'javelin-stratcom', + 'javelin-dom', + 'javelin-history', + ), '3ab51e2c' => array( 'javelin-behavior', 'javelin-behavior-device', @@ -1407,12 +1413,6 @@ return array( 'javelin-dom', 'phuix-button-view', ), - '69837bed' => array( - 'javelin-behavior', - 'javelin-stratcom', - 'javelin-dom', - 'javelin-history', - ), '69adf288' => array( 'javelin-install', ), diff --git a/src/view/layout/PhabricatorSourceCodeView.php b/src/view/layout/PhabricatorSourceCodeView.php index e6fb1803bc..eec571e5f3 100644 --- a/src/view/layout/PhabricatorSourceCodeView.php +++ b/src/view/layout/PhabricatorSourceCodeView.php @@ -66,7 +66,6 @@ final class PhabricatorSourceCodeView extends AphrontView { require_celerity_resource('phabricator-source-code-view-css'); require_celerity_resource('syntax-highlighting-css'); - Javelin::initBehavior('phabricator-oncopy', array()); if ($this->canClickHighlight) { Javelin::initBehavior('phabricator-line-linker'); } @@ -78,11 +77,11 @@ final class PhabricatorSourceCodeView extends AphrontView { $lines = $this->lines; if ($this->truncatedFirstLines) { $lines[] = phutil_tag( - 'span', - array( - 'class' => 'c', - ), - pht('...')); + 'span', + array( + 'class' => 'c', + ), + pht('...')); } else if ($this->truncatedFirstBytes) { $last_key = last_key($lines); $lines[$last_key] = hsprintf( @@ -98,9 +97,6 @@ final class PhabricatorSourceCodeView extends AphrontView { $base_uri = (string)$this->uri; foreach ($lines as $line) { - // NOTE: See phabricator-oncopy behavior. - $content_line = hsprintf("\xE2\x80\x8B%s", $line); - $row_attributes = array(); if (isset($this->highlights[$line_number])) { $row_attributes['class'] = 'phabricator-source-highlight'; @@ -117,8 +113,8 @@ final class PhabricatorSourceCodeView extends AphrontView { 'a', array( 'href' => $line_href, - ), - $line_number); + 'data-n' => $line_number, + )); } else { $tag_number = phutil_tag( 'span', @@ -172,7 +168,7 @@ final class PhabricatorSourceCodeView extends AphrontView { array( 'class' => 'phabricator-source-code', ), - $content_line), + $line), )); $line_number++; diff --git a/webroot/rsrc/css/layout/phabricator-source-code-view.css b/webroot/rsrc/css/layout/phabricator-source-code-view.css index 07448c9c63..6f2864d067 100644 --- a/webroot/rsrc/css/layout/phabricator-source-code-view.css +++ b/webroot/rsrc/css/layout/phabricator-source-code-view.css @@ -25,16 +25,11 @@ text-align: right; border-right: 1px solid {$paste.border}; color: {$sh-yellowtext}; +} - /* When the user selects rows of source, don't visibly select the line - numbers beside them. We use JS to strip the line numbers out when the user - copies the text. */ - -moz-user-select: -moz-none; - -khtml-user-select: none; - -webkit-user-select: none; - -ms-user-select: none; - user-select: none; - white-space: nowrap; +.phabricator-source-line > a::before { + /* Render the line numbers as a pseudo-element so they don't get copied. */ + content: attr(data-n); } th.phabricator-source-line a, diff --git a/webroot/rsrc/js/core/behavior-line-linker.js b/webroot/rsrc/js/core/behavior-line-linker.js index e3eedfd50f..c2aec18d8b 100644 --- a/webroot/rsrc/js/core/behavior-line-linker.js +++ b/webroot/rsrc/js/core/behavior-line-linker.js @@ -29,7 +29,7 @@ JX.behavior('phabricator-line-linker', function() { } } - return +(th.textContent || th.innerText); + return null; } JX.Stratcom.listen(