mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-22 12:41:19 +01:00
Allow custom hyperlinks; Pass differential.diff-id into remarkup engine config
Summary: This allows extensions to have more options for generating custom hyperlinks. Test Plan: custom-inline rules are moved before default rules. Test existing products which implement custom rules. Make sure you use "$this->getEngine()->storeText()" in rules. Reviewers: epriestley, jungejason Reviewed By: jungejason CC: aran, epriestley, emiraga, jungejason Differential Revision: 1024
This commit is contained in:
parent
e788f0f766
commit
f447e5d709
2 changed files with 16 additions and 10 deletions
|
@ -58,7 +58,9 @@ final class DifferentialRevisionCommentListView extends AphrontView {
|
||||||
|
|
||||||
require_celerity_resource('differential-revision-comment-list-css');
|
require_celerity_resource('differential-revision-comment-list-css');
|
||||||
|
|
||||||
$engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
|
$engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(array(
|
||||||
|
'differential.diff' => $this->target
|
||||||
|
));
|
||||||
|
|
||||||
$inlines = mgroup($this->inlines, 'getCommentID');
|
$inlines = mgroup($this->inlines, 'getCommentID');
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,13 @@ class PhabricatorMarkupEngine {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function newDifferentialMarkupEngine() {
|
public static function newDifferentialMarkupEngine(array $options = array()) {
|
||||||
return self::newMarkupEngine(array(
|
return self::newMarkupEngine(array(
|
||||||
'custom-inline' => PhabricatorEnv::getEnvConfig(
|
'custom-inline' => PhabricatorEnv::getEnvConfig(
|
||||||
'differential.custom-remarkup-rules'),
|
'differential.custom-remarkup-rules'),
|
||||||
'custom-block' => PhabricatorEnv::getEnvConfig(
|
'custom-block' => PhabricatorEnv::getEnvConfig(
|
||||||
'differential.custom-remarkup-block-rules'),
|
'differential.custom-remarkup-block-rules'),
|
||||||
|
'differential.diff' => idx($options, 'differential.diff'),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ class PhabricatorMarkupEngine {
|
||||||
'remarkup.enable-embedded-youtube'),
|
'remarkup.enable-embedded-youtube'),
|
||||||
'custom-inline' => array(),
|
'custom-inline' => array(),
|
||||||
'custom-block' => array(),
|
'custom-block' => array(),
|
||||||
|
'differential.diff' => null,
|
||||||
'macros' => true,
|
'macros' => true,
|
||||||
'uri.allowed-protocols' => PhabricatorEnv::getEnvConfig(
|
'uri.allowed-protocols' => PhabricatorEnv::getEnvConfig(
|
||||||
'uri.allowed-protocols'),
|
'uri.allowed-protocols'),
|
||||||
|
@ -92,9 +94,19 @@ class PhabricatorMarkupEngine {
|
||||||
$engine->setConfig(
|
$engine->setConfig(
|
||||||
'uri.allowed-protocols',
|
'uri.allowed-protocols',
|
||||||
$options['uri.allowed-protocols']);
|
$options['uri.allowed-protocols']);
|
||||||
|
$engine->setConfig('differential.diff', $options['differential.diff']);
|
||||||
|
|
||||||
$rules = array();
|
$rules = array();
|
||||||
$rules[] = new PhutilRemarkupRuleEscapeRemarkup();
|
$rules[] = new PhutilRemarkupRuleEscapeRemarkup();
|
||||||
|
|
||||||
|
$custom_rule_classes = $options['custom-inline'];
|
||||||
|
if ($custom_rule_classes) {
|
||||||
|
foreach ($custom_rule_classes as $custom_rule_class) {
|
||||||
|
PhutilSymbolLoader::loadClass($custom_rule_class);
|
||||||
|
$rules[] = newv($custom_rule_class, array());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($options['fileproxy']) {
|
if ($options['fileproxy']) {
|
||||||
$rules[] = new PhabricatorRemarkupRuleProxyImage();
|
$rules[] = new PhabricatorRemarkupRuleProxyImage();
|
||||||
}
|
}
|
||||||
|
@ -122,14 +134,6 @@ class PhabricatorMarkupEngine {
|
||||||
|
|
||||||
$rules[] = new PhabricatorRemarkupRuleMention();
|
$rules[] = new PhabricatorRemarkupRuleMention();
|
||||||
|
|
||||||
$custom_rule_classes = $options['custom-inline'];
|
|
||||||
if ($custom_rule_classes) {
|
|
||||||
foreach ($custom_rule_classes as $custom_rule_class) {
|
|
||||||
PhutilSymbolLoader::loadClass($custom_rule_class);
|
|
||||||
$rules[] = newv($custom_rule_class, array());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$rules[] = new PhutilRemarkupRuleEscapeHTML();
|
$rules[] = new PhutilRemarkupRuleEscapeHTML();
|
||||||
$rules[] = new PhutilRemarkupRuleMonospace();
|
$rules[] = new PhutilRemarkupRuleMonospace();
|
||||||
$rules[] = new PhutilRemarkupRuleBold();
|
$rules[] = new PhutilRemarkupRuleBold();
|
||||||
|
|
Loading…
Reference in a new issue