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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
ee65f5ee
Commit
ee65f5ee
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
2b934a7f
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 @
ee65f5ee
...
@@ -130,13 +130,15 @@ window.DropzoneInput = (function() {
...
@@ -130,13 +130,15 @@ window.DropzoneInput = (function() {
var
afterSelection
,
beforeSelection
,
caretEnd
,
caretStart
,
textEnd
;
var
afterSelection
,
beforeSelection
,
caretEnd
,
caretStart
,
textEnd
;
var
formattedText
=
text
;
var
formattedText
=
text
;
if
(
shouldPad
)
formattedText
+=
"
\n\n
"
;
if
(
shouldPad
)
formattedText
+=
"
\n\n
"
;
caretStart
=
$
(
child
)[
0
].
selectionStart
;
const
textarea
=
child
.
get
(
0
);
caretEnd
=
$
(
child
)[
0
].
selectionEnd
;
caretStart
=
textarea
.
selectionStart
;
caretEnd
=
textarea
.
selectionEnd
;
textEnd
=
$
(
child
).
val
().
length
;
textEnd
=
$
(
child
).
val
().
length
;
beforeSelection
=
$
(
child
).
val
().
substring
(
0
,
caretStart
);
beforeSelection
=
$
(
child
).
val
().
substring
(
0
,
caretStart
);
afterSelection
=
$
(
child
).
val
().
substring
(
caretEnd
,
textEnd
);
afterSelection
=
$
(
child
).
val
().
substring
(
caretEnd
,
textEnd
);
$
(
child
).
val
(
beforeSelection
+
formattedText
+
afterSelection
);
$
(
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
"
);
return
form_textarea
.
trigger
(
"
input
"
);
};
};
getFilename
=
function
(
e
)
{
getFilename
=
function
(
e
)
{
...
@@ -180,7 +182,7 @@ window.DropzoneInput = (function() {
...
@@ -180,7 +182,7 @@ window.DropzoneInput = (function() {
};
};
insertToTextArea
=
function
(
filename
,
url
)
{
insertToTextArea
=
function
(
filename
,
url
)
{
return
$
(
child
).
val
(
function
(
index
,
val
)
{
return
$
(
child
).
val
(
function
(
index
,
val
)
{
return
val
.
replace
(
"
{{
"
+
filename
+
"
}}
"
,
url
+
"
\n
"
);
return
val
.
replace
(
"
{{
"
+
filename
+
"
}}
"
,
url
);
});
});
};
};
appendToTextArea
=
function
(
url
)
{
appendToTextArea
=
function
(
url
)
{
...
@@ -215,6 +217,7 @@ window.DropzoneInput = (function() {
...
@@ -215,6 +217,7 @@ window.DropzoneInput = (function() {
form
.
find
(
"
.markdown-selector
"
).
click
(
function
(
e
)
{
form
.
find
(
"
.markdown-selector
"
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
$
(
this
).
closest
(
'
.gfm-form
'
).
find
(
'
.div-dropzone
'
).
click
();
$
(
this
).
closest
(
'
.gfm-form
'
).
find
(
'
.div-dropzone
'
).
click
();
form_textarea
.
focus
();
});
});
}
}
...
...
changelogs/unreleased/30008-textarea-focus.yml
0 → 100644
View file @
ee65f5ee
---
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