Skip to content

Commit 4b6d3e1

Browse files
author
epriestley
committed
Unconditionally enable drag-and-drop uploads for Remarkup text areas
Summary: Make these always work. Notably, this makes them work in Maniphest. Previously this was at odds with stuff fixed in D3651. Test Plan: Dragged and dropped files into Remarkup in Maniphest. Reviewers: btrahan, vrana Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D3652
1 parent 8573a1e commit 4b6d3e1

File tree

7 files changed

+17
-28
lines changed

7 files changed

+17
-28
lines changed

src/applications/differential/view/DifferentialAddCommentView.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ public function render() {
133133
->setName('comment')
134134
->setID('comment-content')
135135
->setLabel('Comment')
136-
->setEnableDragAndDropFileUploads(true)
137136
->setValue($this->draft ? $this->draft->getDraft() : null))
138137
->appendChild(
139138
id(new AphrontFormSubmitControl())

src/applications/phame/controller/post/PhamePostEditController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ public function processRequest() {
259259
->setName('body')
260260
->setValue($post->getBody())
261261
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
262-
->setEnableDragAndDropFileUploads(true)
263262
->setID('post-body')
264263
)
265264
->appendChild(

src/applications/phriction/controller/PhrictionEditController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ public function processRequest() {
223223
->setValue($content_text)
224224
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
225225
->setName('content')
226-
->setID('document-textarea')
227-
->setEnableDragAndDropFileUploads(true))
226+
->setID('document-textarea'))
228227
->appendChild(
229228
id(new AphrontFormTextControl())
230229
->setLabel('Edit Notes')

src/applications/ponder/view/PonderAddAnswerView.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ public function render() {
6060
->setName('answer')
6161
->setLabel('Answer')
6262
->setError(true)
63-
->setID('answer-content')
64-
->setEnableDragAndDropFileUploads(true))
63+
->setID('answer-content'))
6564
->appendChild(
6665
id(new AphrontFormSubmitControl())
6766
->setValue($is_serious ? 'Submit' : 'Make it so.'));

src/applications/ponder/view/PonderAddCommentView.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ public function render() {
6060
->addHiddenInput('question_id', $questionID)
6161
->appendChild(
6262
id(new AphrontFormTextAreaControl())
63-
->setName('content')
64-
->setEnableDragAndDropFileUploads(false))
63+
->setName('content'))
6564
->appendChild(
6665
id(new AphrontFormSubmitControl())
6766
->setValue($is_serious ? 'Submit' : 'Editorialize'));

src/view/form/control/AphrontFormTextAreaControl.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ protected function getCustomControlClass() {
4848
return 'aphront-form-control-textarea';
4949
}
5050

51-
public function setEnableDragAndDropFileUploads($enable) {
52-
$this->enableDragAndDropFileUploads = $enable;
53-
return $this;
54-
}
55-
5651
public function setCustomClass($custom_class) {
5752
$this->customClass = $custom_class;
5853
return $this;
@@ -74,20 +69,6 @@ protected function renderInput() {
7469
$classes[] = $this->customClass;
7570
$classes = trim(implode(' ', $classes));
7671

77-
$id = $this->getID();
78-
if ($this->enableDragAndDropFileUploads) {
79-
if (!$id) {
80-
$id = celerity_generate_unique_node_id();
81-
}
82-
Javelin::initBehavior(
83-
'aphront-drag-and-drop-textarea',
84-
array(
85-
'target' => $id,
86-
'activatedClass' => 'aphront-textarea-drag-and-drop',
87-
'uri' => '/file/dropupload/',
88-
));
89-
}
90-
9172
return phutil_render_tag(
9273
'textarea',
9374
array(
@@ -96,7 +77,7 @@ protected function renderInput() {
9677
'readonly' => $this->getReadonly() ? 'readonly' : null,
9778
'class' => $classes,
9879
'style' => $this->getControlStyle(),
99-
'id' => $id,
80+
'id' => $this->getID(),
10081
),
10182
phutil_escape_html($this->getValue()));
10283
}

src/view/form/control/PhabricatorRemarkupControl.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@
1919
final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
2020

2121
protected function renderInput() {
22+
$id = $this->getID();
23+
if (!$id) {
24+
$id = celerity_generate_unique_node_id();
25+
$this->setID($id);
26+
}
27+
28+
Javelin::initBehavior(
29+
'aphront-drag-and-drop-textarea',
30+
array(
31+
'target' => $id,
32+
'activatedClass' => 'aphront-textarea-drag-and-drop',
33+
'uri' => '/file/dropupload/',
34+
));
2235

2336
Javelin::initBehavior('phabricator-remarkup-assist', array());
2437
Javelin::initBehavior('phabricator-tooltips', array());

0 commit comments

Comments
 (0)