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

Allow disabling line highlighting on click in `PhabricatorSourceCodeView`

Summary:
There may be times when we don't want lines in some embeded source
code to be highlighted on click, this adds that functionality.

Also use the functionalty in `PasteEmbedView`

Test Plan:
- View paste, make sure everything works.
- Embed paste in comment, make sure everything works apart from click hl

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T3881

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

authored by

Gareth Evans and committed by
epriestley
487152e6 c373baa7

+26 -10
+2 -1
src/applications/paste/view/PasteEmbedView.php
··· 58 58 $body_attributes, 59 59 id(new PhabricatorSourceCodeView()) 60 60 ->setLines($lines) 61 - ->setHighlights($this->highlights)); 61 + ->setHighlights($this->highlights) 62 + ->disableHighlightOnClick()); 62 63 63 64 return phutil_tag( 64 65 'div',
+24 -9
src/view/layout/PhabricatorSourceCodeView.php
··· 6 6 private $limit; 7 7 private $uri; 8 8 private $highlights = array(); 9 + private $canClickHighlight = true; 9 10 10 11 public function setLimit($limit) { 11 12 $this->limit = $limit; ··· 27 28 return $this; 28 29 } 29 30 31 + public function disableHighlightOnClick() { 32 + $this->canClickHighlight = false; 33 + return $this; 34 + } 35 + 30 36 public function render() { 31 37 require_celerity_resource('phabricator-source-code-view-css'); 32 38 require_celerity_resource('syntax-highlighting-css'); 33 39 34 40 Javelin::initBehavior('phabricator-oncopy', array()); 35 - Javelin::initBehavior('phabricator-line-linker'); 41 + if ($this->canClickHighlight) { 42 + Javelin::initBehavior('phabricator-line-linker'); 43 + } 36 44 37 45 $line_number = 1; 38 46 ··· 61 69 $row_attributes['class'] = 'phabricator-source-highlight'; 62 70 } 63 71 64 - $line_uri = $this->uri . "$" . $line_number; 65 - $line_href = (string) new PhutilURI($line_uri); 72 + if ($this->canClickHighlight) { 73 + $line_uri = $this->uri . "$" . $line_number; 74 + $line_href = (string) new PhutilURI($line_uri); 66 75 67 - $tag_number = javelin_tag( 68 - 'a', 69 - array( 70 - 'href' => $line_href 71 - ), 72 - $line_number); 76 + $tag_number = javelin_tag( 77 + 'a', 78 + array( 79 + 'href' => $line_href 80 + ), 81 + $line_number); 82 + } else { 83 + $tag_number = javelin_tag( 84 + 'span', 85 + array(), 86 + $line_number); 87 + } 73 88 74 89 $rows[] = phutil_tag( 75 90 'tr',