BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
fecebc79
Commit
fecebc79
authored
Dec 14, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed new line being included in bold/italic in GFM form
Closes #25456
parent
09b622f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
text_utility.js
app/assets/javascripts/lib/utils/text_utility.js
+22
-3
No files found.
app/assets/javascripts/lib/utils/text_utility.js
View file @
fecebc79
...
...
@@ -44,9 +44,18 @@
}
};
gl
.
text
.
insertText
=
function
(
textArea
,
text
,
tag
,
blockTag
,
selected
,
wrap
)
{
var
insertText
,
inserted
,
selectedSplit
,
startChar
;
var
insertText
,
inserted
,
selectedSplit
,
startChar
,
removedLastNewLine
;
removedLastNewLine
=
false
;
// Remove the last newline
if
(
textArea
.
selectionEnd
-
textArea
.
selectionStart
>
selected
.
replace
(
/
\n
$/
,
''
).
length
)
{
removedLastNewLine
=
true
;
selected
=
selected
.
replace
(
/
\n
$/
,
''
);
}
selectedSplit
=
selected
.
split
(
'
\
n'
);
startChar
=
!
wrap
&&
textArea
.
selectionStart
>
0
?
'
\
n'
:
''
;
if
(
selectedSplit
.
length
>
1
&&
(
!
wrap
||
(
blockTag
!=
null
)))
{
if
(
blockTag
!=
null
)
{
insertText
=
this
.
blockTagText
(
text
,
textArea
,
blockTag
,
selected
);
...
...
@@ -62,6 +71,11 @@
}
else
{
insertText
=
""
+
startChar
+
tag
+
selected
+
(
wrap
?
tag
:
' '
);
}
if
(
removedLastNewLine
)
{
insertText
+=
'
\
n'
;
}
if
(
document
.
queryCommandSupported
(
'insertText'
))
{
inserted
=
document
.
execCommand
(
'insertText'
,
false
,
insertText
);
}
...
...
@@ -74,9 +88,9 @@
document
.
execCommand
(
"ms-endUndoUnit"
);
}
catch
(
error
)
{}
}
return
this
.
moveCursor
(
textArea
,
tag
,
wrap
);
return
this
.
moveCursor
(
textArea
,
tag
,
wrap
,
removedLastNewLine
);
};
gl
.
text
.
moveCursor
=
function
(
textArea
,
tag
,
wrapped
)
{
gl
.
text
.
moveCursor
=
function
(
textArea
,
tag
,
wrapped
,
removedLastNewLine
)
{
var
pos
;
if
(
!
textArea
.
setSelectionRange
)
{
return
;
...
...
@@ -87,6 +101,11 @@
}
else
{
pos
=
textArea
.
selectionStart
;
}
if
(
removedLastNewLine
)
{
pos
-=
1
;
}
return
textArea
.
setSelectionRange
(
pos
,
pos
);
}
};
...
...
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