Changeset View
Changeset View
Standalone View
Standalone View
src/view/form/control/PhabricatorRemarkupControl.php
Show All 16 Lines | final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl { | ||||
protected function renderInput() { | protected function renderInput() { | ||||
$id = $this->getID(); | $id = $this->getID(); | ||||
if (!$id) { | if (!$id) { | ||||
$id = celerity_generate_unique_node_id(); | $id = celerity_generate_unique_node_id(); | ||||
$this->setID($id); | $this->setID($id); | ||||
} | } | ||||
$viewer = $this->getUser(); | |||||
if (!$viewer) { | |||||
throw new Exception( | |||||
pht('Call setUser() before rendering a PhabricatorRemarkupControl!')); | |||||
} | |||||
// We need to have this if previews render images, since Ajax can not | // We need to have this if previews render images, since Ajax can not | ||||
// currently ship JS or CSS. | // currently ship JS or CSS. | ||||
require_celerity_resource('lightbox-attachment-css'); | require_celerity_resource('lightbox-attachment-css'); | ||||
Javelin::initBehavior( | Javelin::initBehavior( | ||||
'aphront-drag-and-drop-textarea', | 'aphront-drag-and-drop-textarea', | ||||
array( | array( | ||||
'target' => $id, | 'target' => $id, | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | $actions = array( | ||||
'fa-table' => array( | 'fa-table' => array( | ||||
'tip' => pht('Table'), | 'tip' => pht('Table'), | ||||
), | ), | ||||
'fa-cloud-upload' => array( | 'fa-cloud-upload' => array( | ||||
'tip' => pht('Upload File'), | 'tip' => pht('Upload File'), | ||||
), | ), | ||||
); | ); | ||||
if (!$this->disableMacro and function_exists('imagettftext')) { | $can_use_macros = | ||||
(!$this->disableMacro) && | |||||
(function_exists('imagettftext')); | |||||
if ($can_use_macros) { | |||||
$can_use_macros = PhabricatorApplication::isClassInstalledForViewer( | |||||
'PhabricatorMacroApplication', | |||||
$viewer); | |||||
} | |||||
if ($can_use_macros) { | |||||
$actions[] = array( | $actions[] = array( | ||||
'spacer' => true, | 'spacer' => true, | ||||
); | ); | ||||
$actions['fa-meh-o'] = array( | $actions['fa-meh-o'] = array( | ||||
'tip' => pht('Meme'), | 'tip' => pht('Meme'), | ||||
); | ); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | $buttons = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'remarkup-assist-bar', | 'class' => 'remarkup-assist-bar', | ||||
), | ), | ||||
$buttons); | $buttons); | ||||
$monospaced_textareas = null; | $monospaced_textareas = null; | ||||
$monospaced_textareas_class = null; | $monospaced_textareas_class = null; | ||||
$user = $this->getUser(); | |||||
if ($user) { | $monospaced_textareas = $viewer | ||||
$monospaced_textareas = $user | |||||
->loadPreferences() | ->loadPreferences() | ||||
->getPreference( | ->getPreference( | ||||
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS); | PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS); | ||||
if ($monospaced_textareas == 'enabled') { | if ($monospaced_textareas == 'enabled') { | ||||
$monospaced_textareas_class = 'PhabricatorMonospaced'; | $monospaced_textareas_class = 'PhabricatorMonospaced'; | ||||
} | } | ||||
} | |||||
$this->setCustomClass( | $this->setCustomClass( | ||||
'remarkup-assist-textarea '.$monospaced_textareas_class); | 'remarkup-assist-textarea '.$monospaced_textareas_class); | ||||
return javelin_tag( | return javelin_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'sigil' => 'remarkup-assist-control', | 'sigil' => 'remarkup-assist-control', | ||||
), | ), | ||||
array( | array( | ||||
$buttons, | $buttons, | ||||
parent::renderInput(), | parent::renderInput(), | ||||
)); | )); | ||||
} | } | ||||
} | } |