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

Add autocomplete for Phriction documents on "[[ ..." in Remarkup

Summary: Depends on D19107. Ref T13077. The underlying datasource may need some adjustment but this appears to work properly locally.

Test Plan: Typed `[[ por` locally, was suggested "Porcupine Facts". Typed `[[ / ]]`, saw it render as a reference to the wiki root instead of the install root.

Maniphest Tasks: T13077

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

+45 -11
+8 -8
resources/celerity/map.php
··· 528 528 'rsrc/js/phui/behavior-phui-tab-group.js' => '0a0b10e9', 529 529 'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8', 530 530 'rsrc/js/phuix/PHUIXActionView.js' => '442efd08', 531 - 'rsrc/js/phuix/PHUIXAutocomplete.js' => 'e0731603', 531 + 'rsrc/js/phuix/PHUIXAutocomplete.js' => 'bb19ed2c', 532 532 'rsrc/js/phuix/PHUIXButtonView.js' => '8a91e1ac', 533 533 'rsrc/js/phuix/PHUIXDropdownMenu.js' => '04b2ae03', 534 534 'rsrc/js/phuix/PHUIXExample.js' => '68af71ca', ··· 881 881 'phui-workpanel-view-css' => 'a3a63478', 882 882 'phuix-action-list-view' => 'b5c256b8', 883 883 'phuix-action-view' => '442efd08', 884 - 'phuix-autocomplete' => 'e0731603', 884 + 'phuix-autocomplete' => 'bb19ed2c', 885 885 'phuix-button-view' => '8a91e1ac', 886 886 'phuix-dropdown-menu' => '04b2ae03', 887 887 'phuix-form-control-view' => '16ad6224', ··· 1868 1868 'javelin-uri', 1869 1869 'phabricator-notification', 1870 1870 ), 1871 + 'bb19ed2c' => array( 1872 + 'javelin-install', 1873 + 'javelin-dom', 1874 + 'phuix-icon-view', 1875 + 'phabricator-prefab', 1876 + ), 1871 1877 'bcaccd64' => array( 1872 1878 'javelin-behavior', 1873 1879 'javelin-behavior-device', ··· 2032 2038 'javelin-typeahead', 2033 2039 'javelin-typeahead-ondemand-source', 2034 2040 'javelin-dom', 2035 - ), 2036 - 'e0731603' => array( 2037 - 'javelin-install', 2038 - 'javelin-dom', 2039 - 'phuix-icon-view', 2040 - 'phabricator-prefab', 2041 2041 ), 2042 2042 'e1d25dfb' => array( 2043 2043 'javelin-behavior',
+2
src/applications/phriction/typeahead/PhrictionDocumentDatasource.php
··· 68 68 $title = $content->getTitle(); 69 69 70 70 $sprite = 'phabricator-search-icon phui-font-fa phui-icon-view fa-book'; 71 + $autocomplete = '[[ '.$slug.' ]]'; 71 72 72 73 $result = id(new PhabricatorTypeaheadResult()) 73 74 ->setName($title) ··· 77 78 ->setDisplayType($slug) 78 79 ->setPriorityType('wiki') 79 80 ->setImageSprite($sprite) 81 + ->setAutocomplete($autocomplete) 80 82 ->setClosed($closed); 81 83 82 84 $results[] = $result;
+14
src/view/form/control/PhabricatorRemarkupControl.php
··· 72 72 'autocomplete' => 1, 73 73 )); 74 74 75 + $phriction_datasource = new PhrictionDocumentDatasource(); 76 + 75 77 Javelin::initBehavior( 76 78 'phabricator-remarkup-assist', 77 79 array( ··· 117 119 '-', 118 120 '/', 119 121 ), 122 + ), 123 + 91 => array( // "[" 124 + 'datasourceURI' => $phriction_datasource->getDatasourceURI(), 125 + 'headerIcon' => 'fa-book', 126 + 'headerText' => pht('Find Document:'), 127 + 'hintText' => $phriction_datasource->getPlaceholderText(), 128 + 'cancel' => array( 129 + ':', // Cancel on "http:" and similar. 130 + '|', 131 + ']', 132 + ), 133 + 'prefix' => '^\\[*', 120 134 ), 121 135 ), 122 136 ));
+21 -3
webroot/rsrc/js/phuix/PHUIXAutocomplete.js
··· 335 335 _getCancelCharacters: function() { 336 336 // The "." character does not cancel because of projects named 337 337 // "node.js" or "blog.mycompany.com". 338 - return ['#', '@', ',', '!', '?', '{', '}']; 338 + var defaults = ['#', '@', ',', '!', '?', '{', '}']; 339 + 340 + return this._map[this._active].cancel || defaults; 339 341 }, 340 342 341 343 _getTerminators: function() { ··· 498 500 this._cursorHead, 499 501 this._cursorTail); 500 502 501 - this._value = text; 502 - 503 503 var pixels = JX.TextAreaUtils.getPixelDimensions( 504 504 area, 505 505 range.start, ··· 516 516 } 517 517 518 518 var trim = this._trim(text); 519 + 520 + // If this rule has a prefix pattern, like the "[[ document ]]" rule, 521 + // require it match and throw it away before we begin suggesting 522 + // results. The autocomplete remains active, it's just dormant until 523 + // the user gives us more to work with. 524 + var prefix = this._map[this._active].prefix; 525 + if (prefix) { 526 + var pattern = new RegExp(prefix); 527 + if (!trim.match(pattern)) { 528 + return; 529 + } 530 + trim = trim.replace(pattern, ''); 531 + trim = trim.trim(); 532 + } 533 + 534 + // Store the current value now that we've finished mutating the text. 535 + // This needs to match what we pass to the typeahead datasource. 536 + this._value = trim; 519 537 520 538 // Deactivate immediately if a user types a character that we are 521 539 // reasonably sure means they don't want to use the autocomplete. For