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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
f60d3e68
Commit
f60d3e68
authored
Oct 08, 2019
by
mfluharty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turn URLs in blob editor into clickable links
parent
9096bda9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletion
+32
-1
app/assets/javascripts/blob_edit/edit_blob.js
app/assets/javascripts/blob_edit/edit_blob.js
+18
-1
app/assets/stylesheets/framework/files.scss
app/assets/stylesheets/framework/files.scss
+7
-0
spec/features/projects/blobs/edit_spec.rb
spec/features/projects/blobs/edit_spec.rb
+7
-0
No files found.
app/assets/javascripts/blob_edit/edit_blob.js
View file @
f60d3e68
...
@@ -4,7 +4,8 @@ import $ from 'jquery';
...
@@ -4,7 +4,8 @@ import $ from 'jquery';
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
}
from
'
~/locale
'
;
import
TemplateSelectorMediator
from
'
../blob/file_template_mediator
'
;
import
{
blobLinkRegex
}
from
'
~/blob/blob_utils
'
;
import
TemplateSelectorMediator
from
'
~/blob/file_template_mediator
'
;
import
getModeByFileExtension
from
'
~/lib/utils/ace_utils
'
;
import
getModeByFileExtension
from
'
~/lib/utils/ace_utils
'
;
import
{
addEditorMarkdownListeners
}
from
'
~/lib/utils/text_markdown
'
;
import
{
addEditorMarkdownListeners
}
from
'
~/lib/utils/text_markdown
'
;
...
@@ -17,6 +18,7 @@ export default class EditBlob {
...
@@ -17,6 +18,7 @@ export default class EditBlob {
this
.
initModePanesAndLinks
();
this
.
initModePanesAndLinks
();
this
.
initSoftWrap
();
this
.
initSoftWrap
();
this
.
initFileSelectors
();
this
.
initFileSelectors
();
this
.
initBlobContentLinkClickability
();
}
}
configureAceEditor
()
{
configureAceEditor
()
{
...
@@ -89,6 +91,21 @@ export default class EditBlob {
...
@@ -89,6 +91,21 @@ export default class EditBlob {
return
this
.
editor
.
focus
();
return
this
.
editor
.
focus
();
}
}
initBlobContentLinkClickability
()
{
this
.
editor
.
renderer
.
on
(
'
afterRender
'
,
()
=>
{
document
.
querySelectorAll
(
'
.ace_text-layer .ace_line > *
'
).
forEach
(
token
=>
{
if
(
token
.
getAttribute
(
'
data-linkified
'
)
||
!
token
.
textContent
.
includes
(
'
http
'
))
return
;
// eslint-disable-next-line no-param-reassign
token
.
innerHTML
=
token
.
innerHTML
.
replace
(
blobLinkRegex
,
'
<a target="_blank" href="$&">$&</a>
'
,
);
token
.
setAttribute
(
'
data-linkified
'
,
'
true
'
);
});
});
}
initSoftWrap
()
{
initSoftWrap
()
{
this
.
isSoftWrapped
=
false
;
this
.
isSoftWrapped
=
false
;
this
.
$toggleButton
=
$
(
'
.soft-wrap-toggle
'
);
this
.
$toggleButton
=
$
(
'
.soft-wrap-toggle
'
);
...
...
app/assets/stylesheets/framework/files.scss
View file @
f60d3e68
...
@@ -258,6 +258,13 @@
...
@@ -258,6 +258,13 @@
}
}
}
}
}
}
.file-editor
{
.ace_line
a
{
pointer-events
:
auto
;
color
:
inherit
;
}
}
}
}
span
.idiff
{
span
.idiff
{
...
...
spec/features/projects/blobs/edit_spec.rb
View file @
f60d3e68
...
@@ -60,6 +60,13 @@ describe 'Editing file blob', :js do
...
@@ -60,6 +60,13 @@ describe 'Editing file blob', :js do
expect
(
page
).
to
have_content
'NextFeature'
expect
(
page
).
to
have_content
'NextFeature'
end
end
it
'renders a URL in the content of file as a link'
do
project
.
repository
.
create_file
(
user
,
'file.yml'
,
'# go to https://gitlab.com'
,
message:
'testing'
,
branch_name:
branch
)
visit
project_edit_blob_path
(
project
,
tree_join
(
branch
,
'file.yml'
))
expect
(
page
).
to
have_selector
(
'.ace_content .ace_line a'
)
end
context
'from blob file path'
do
context
'from blob file path'
do
before
do
before
do
visit
project_blob_path
(
project
,
tree_join
(
branch
,
file_path
))
visit
project_blob_path
(
project
,
tree_join
(
branch
,
file_path
))
...
...
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