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
78e7efae
Commit
78e7efae
authored
May 18, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy as GFM even when parts of other elements are selected
parent
c013d23d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
8 deletions
+26
-8
copy_as_gfm.js
app/assets/javascripts/copy_as_gfm.js
+19
-3
shortcuts_issuable.js
app/assets/javascripts/shortcuts_issuable.js
+3
-5
dm-copy-gfm-when-parts-of-other-elements-are-selected.yml
...dm-copy-gfm-when-parts-of-other-elements-are-selected.yml
+4
-0
No files found.
app/assets/javascripts/copy_as_gfm.js
View file @
78e7efae
...
...
@@ -330,10 +330,26 @@ class CopyAsGFM {
}
static
transformGFMSelection
(
documentFragment
)
{
// If the documentFragment contains more than just Markdown, don't copy as GFM.
if
(
documentFragment
.
querySelector
(
'.md, .wiki'
))
return
null
;
const
gfmEls
=
documentFragment
.
querySelectorAll
(
'.md, .wiki'
);
switch
(
gfmEls
.
length
)
{
case
0
:
{
return
documentFragment
;
}
case
1
:
{
return
gfmEls
[
0
];
}
default
:
{
const
allGfmEl
=
document
.
createElement
(
'div'
);
for
(
let
i
=
0
;
i
<
gfmEls
.
length
;
i
+=
1
)
{
const
lineEl
=
gfmEls
[
i
];
allGfmEl
.
appendChild
(
lineEl
);
allGfmEl
.
appendChild
(
document
.
createTextNode
(
'
\
n
\
n'
));
}
return
documentFragment
;
return
allGfmEl
;
}
}
}
static
transformCodeSelection
(
documentFragment
)
{
...
...
app/assets/javascripts/shortcuts_issuable.js
View file @
78e7efae
...
...
@@ -38,7 +38,7 @@ import './shortcuts_navigation';
}
ShortcutsIssuable
.
prototype
.
replyWithSelectedText
=
function
()
{
var
quote
,
documentFragment
,
selected
,
separator
;
var
quote
,
documentFragment
,
el
,
selected
,
separator
;
var
replyField
=
$
(
'.js-main-target-form #note_note'
);
documentFragment
=
window
.
gl
.
utils
.
getSelectedFragment
();
...
...
@@ -47,10 +47,8 @@ import './shortcuts_navigation';
return
;
}
// If the documentFragment contains more than just Markdown, don't copy as GFM.
if
(
documentFragment
.
querySelector
(
'.md, .wiki'
))
return
;
selected
=
window
.
gl
.
CopyAsGFM
.
nodeToGFM
(
documentFragment
);
el
=
window
.
gl
.
CopyAsGFM
.
transformGFMSelection
(
documentFragment
.
cloneNode
(
true
));
selected
=
window
.
gl
.
CopyAsGFM
.
nodeToGFM
(
el
);
if
(
selected
.
trim
()
===
""
)
{
return
;
...
...
changelogs/unreleased/dm-copy-gfm-when-parts-of-other-elements-are-selected.yml
0 → 100644
View file @
78e7efae
---
title
:
Copy as GFM even when parts of other elements are selected
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