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
Show 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,11 +330,27 @@ class CopyAsGFM {
...
@@ -330,11 +330,27 @@ class CopyAsGFM {
}
}
static
transformGFMSelection
(
documentFragment
)
{
static
transformGFMSelection
(
documentFragment
)
{
// If the documentFragment contains more than just Markdown, don't copy as GFM.
const
gfmEls
=
documentFragment
.
querySelectorAll
(
'.md, .wiki'
);
if
(
documentFragment
.
querySelector
(
'.md, .wiki'
))
return
null
;
switch
(
gfmEls
.
length
)
{
case
0
:
{
return
documentFragment
;
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
allGfmEl
;
}
}
}
static
transformCodeSelection
(
documentFragment
)
{
static
transformCodeSelection
(
documentFragment
)
{
const
lineEls
=
documentFragment
.
querySelectorAll
(
'.line'
);
const
lineEls
=
documentFragment
.
querySelectorAll
(
'.line'
);
...
...
app/assets/javascripts/shortcuts_issuable.js
View file @
78e7efae
...
@@ -38,7 +38,7 @@ import './shortcuts_navigation';
...
@@ -38,7 +38,7 @@ import './shortcuts_navigation';
}
}
ShortcutsIssuable
.
prototype
.
replyWithSelectedText
=
function
()
{
ShortcutsIssuable
.
prototype
.
replyWithSelectedText
=
function
()
{
var
quote
,
documentFragment
,
selected
,
separator
;
var
quote
,
documentFragment
,
el
,
selected
,
separator
;
var
replyField
=
$
(
'.js-main-target-form #note_note'
);
var
replyField
=
$
(
'.js-main-target-form #note_note'
);
documentFragment
=
window
.
gl
.
utils
.
getSelectedFragment
();
documentFragment
=
window
.
gl
.
utils
.
getSelectedFragment
();
...
@@ -47,10 +47,8 @@ import './shortcuts_navigation';
...
@@ -47,10 +47,8 @@ import './shortcuts_navigation';
return
;
return
;
}
}
// If the documentFragment contains more than just Markdown, don't copy as GFM.
el
=
window
.
gl
.
CopyAsGFM
.
transformGFMSelection
(
documentFragment
.
cloneNode
(
true
));
if
(
documentFragment
.
querySelector
(
'.md, .wiki'
))
return
;
selected
=
window
.
gl
.
CopyAsGFM
.
nodeToGFM
(
el
);
selected
=
window
.
gl
.
CopyAsGFM
.
nodeToGFM
(
documentFragment
);
if
(
selected
.
trim
()
===
""
)
{
if
(
selected
.
trim
()
===
""
)
{
return
;
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