Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e02f8154
Commit
e02f8154
authored
Mar 29, 2017
by
Simon Knox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update textarea height and refocus when attaching files
also fix extra newline when pasting image into textarea
parent
41a3d9a2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
app/assets/javascripts/dropzone_input.js
app/assets/javascripts/dropzone_input.js
+7
-4
changelogs/unreleased/30008-textarea-focus.yml
changelogs/unreleased/30008-textarea-focus.yml
+4
-0
No files found.
app/assets/javascripts/dropzone_input.js
View file @
e02f8154
...
...
@@ -126,13 +126,15 @@ window.DropzoneInput = (function() {
pasteText
=
function
(
text
)
{
var
afterSelection
,
beforeSelection
,
caretEnd
,
caretStart
,
textEnd
;
var
formattedText
=
text
+
"
\n\n
"
;
caretStart
=
$
(
child
)[
0
].
selectionStart
;
caretEnd
=
$
(
child
)[
0
].
selectionEnd
;
const
textarea
=
child
.
get
(
0
);
caretStart
=
textarea
.
selectionStart
;
caretEnd
=
textarea
.
selectionEnd
;
textEnd
=
$
(
child
).
val
().
length
;
beforeSelection
=
$
(
child
).
val
().
substring
(
0
,
caretStart
);
afterSelection
=
$
(
child
).
val
().
substring
(
caretEnd
,
textEnd
);
$
(
child
).
val
(
beforeSelection
+
formattedText
+
afterSelection
);
child
.
get
(
0
).
setSelectionRange
(
caretStart
+
formattedText
.
length
,
caretEnd
+
formattedText
.
length
);
textarea
.
setSelectionRange
(
caretStart
+
formattedText
.
length
,
caretEnd
+
formattedText
.
length
);
textarea
.
style
.
height
=
`
${
textarea
.
scrollHeight
}
px`
;
return
form_textarea
.
trigger
(
"
input
"
);
};
getFilename
=
function
(
e
)
{
...
...
@@ -176,7 +178,7 @@ window.DropzoneInput = (function() {
};
insertToTextArea
=
function
(
filename
,
url
)
{
return
$
(
child
).
val
(
function
(
index
,
val
)
{
return
val
.
replace
(
"
{{
"
+
filename
+
"
}}
"
,
url
+
"
\n
"
);
return
val
.
replace
(
"
{{
"
+
filename
+
"
}}
"
,
url
);
});
};
appendToTextArea
=
function
(
url
)
{
...
...
@@ -211,6 +213,7 @@ window.DropzoneInput = (function() {
form
.
find
(
"
.markdown-selector
"
).
click
(
function
(
e
)
{
e
.
preventDefault
();
$
(
this
).
closest
(
'
.gfm-form
'
).
find
(
'
.div-dropzone
'
).
click
();
form_textarea
.
focus
();
});
}
...
...
changelogs/unreleased/30008-textarea-focus.yml
0 → 100644
View file @
e02f8154
---
title
:
refocus textarea after attaching a file
merge_request
:
author
:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment