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
Jérome Perrin
gitlab-ce
Commits
a713a29a
Commit
a713a29a
authored
Dec 19, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed first newline not working
parent
fecebc79
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
app/assets/javascripts/lib/utils/text_utility.js
app/assets/javascripts/lib/utils/text_utility.js
+12
-1
spec/features/issues/markdown_toolbar_spec.rb
spec/features/issues/markdown_toolbar_spec.rb
+37
-0
No files found.
app/assets/javascripts/lib/utils/text_utility.js
View file @
a713a29a
...
...
@@ -44,8 +44,15 @@
}
};
gl
.
text
.
insertText
=
function
(
textArea
,
text
,
tag
,
blockTag
,
selected
,
wrap
)
{
var
insertText
,
inserted
,
selectedSplit
,
startChar
,
removedLastNewLine
;
var
insertText
,
inserted
,
selectedSplit
,
startChar
,
removedLastNewLine
,
removedFirstNewLine
;
removedLastNewLine
=
false
;
removedFirstNewLine
=
false
;
// Remove the first newline
if
(
selected
.
indexOf
(
'
\n
'
)
===
0
)
{
removedFirstNewLine
=
true
;
selected
=
selected
.
replace
(
/
\n
+/
,
''
);
}
// Remove the last newline
if
(
textArea
.
selectionEnd
-
textArea
.
selectionStart
>
selected
.
replace
(
/
\n
$/
,
''
).
length
)
{
...
...
@@ -72,6 +79,10 @@
insertText
=
""
+
startChar
+
tag
+
selected
+
(
wrap
?
tag
:
'
'
);
}
if
(
removedFirstNewLine
)
{
insertText
=
'
\n
'
+
insertText
;
}
if
(
removedLastNewLine
)
{
insertText
+=
'
\n
'
;
}
...
...
spec/features/issues/markdown_toolbar_spec.rb
0 → 100644
View file @
a713a29a
require
'rails_helper'
feature
'Issue markdown toolbar'
,
feature:
true
,
js:
true
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
login_as
(
user
)
visit
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
end
it
"doesn't include first new line when adding bold"
do
find
(
'#note_note'
).
native
.
send_keys
(
'test'
)
find
(
'#note_note'
).
native
.
send_key
(
:enter
)
find
(
'#note_note'
).
native
.
send_keys
(
'bold'
)
page
.
evaluate_script
(
'document.getElementById("note_note").setSelectionRange(4, 9)'
)
first
(
'.toolbar-btn'
).
click
expect
(
find
(
'#note_note'
)[
:value
]).
to
eq
(
"test
\n
**bold**
\n
"
)
end
it
"doesn't include first new line when adding underline"
do
find
(
'#note_note'
).
native
.
send_keys
(
'test'
)
find
(
'#note_note'
).
native
.
send_key
(
:enter
)
find
(
'#note_note'
).
native
.
send_keys
(
'underline'
)
page
.
evaluate_script
(
'document.getElementById("note_note").setSelectionRange(4, 50)'
)
find
(
'.toolbar-btn:nth-child(2)'
).
click
expect
(
find
(
'#note_note'
)[
:value
]).
to
eq
(
"test
\n
*underline*
\n
"
)
end
end
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