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
Boxiang Sun
gitlab-ce
Commits
8b16f107
Commit
8b16f107
authored
Oct 05, 2017
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Highlighting mechanism
parent
8d14a956
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
16 deletions
+18
-16
app/assets/javascripts/line_highlighter.js
app/assets/javascripts/line_highlighter.js
+6
-3
app/assets/javascripts/repo/components/repo_editor.vue
app/assets/javascripts/repo/components/repo_editor.vue
+9
-5
app/assets/javascripts/repo/components/repo_preview.vue
app/assets/javascripts/repo/components/repo_preview.vue
+3
-0
app/assets/javascripts/repo/components/repo_sidebar.vue
app/assets/javascripts/repo/components/repo_sidebar.vue
+0
-8
No files found.
app/assets/javascripts/line_highlighter.js
View file @
8b16f107
...
@@ -54,12 +54,14 @@ LineHighlighter.prototype.bindEvents = function() {
...
@@ -54,12 +54,14 @@ LineHighlighter.prototype.bindEvents = function() {
$fileHolder
.
on
(
'
highlight:line
'
,
this
.
highlightHash
);
$fileHolder
.
on
(
'
highlight:line
'
,
this
.
highlightHash
);
};
};
LineHighlighter
.
prototype
.
highlightHash
=
function
()
{
LineHighlighter
.
prototype
.
highlightHash
=
function
(
newHash
)
{
var
range
;
let
range
;
if
(
newHash
)
this
.
_hash
=
newHash
;
this
.
clearHighlight
();
if
(
this
.
_hash
!==
''
)
{
if
(
this
.
_hash
!==
''
)
{
range
=
this
.
hashToRange
(
this
.
_hash
);
range
=
this
.
hashToRange
(
this
.
_hash
);
if
(
range
[
0
])
{
if
(
range
[
0
])
{
this
.
highlightRange
(
range
);
this
.
highlightRange
(
range
);
const
lineSelector
=
`#L
${
range
[
0
]}
`
;
const
lineSelector
=
`#L
${
range
[
0
]}
`
;
...
@@ -131,6 +133,7 @@ LineHighlighter.prototype.hashToRange = function(hash) {
...
@@ -131,6 +133,7 @@ LineHighlighter.prototype.hashToRange = function(hash) {
//
//
// lineNumber - Line number to highlight
// lineNumber - Line number to highlight
LineHighlighter
.
prototype
.
highlightLine
=
function
(
lineNumber
)
{
LineHighlighter
.
prototype
.
highlightLine
=
function
(
lineNumber
)
{
console
.
log
(
'
LINE :
'
+
lineNumber
);
return
$
(
"
#LC
"
+
lineNumber
).
addClass
(
this
.
highlightLineClass
);
return
$
(
"
#LC
"
+
lineNumber
).
addClass
(
this
.
highlightLineClass
);
};
};
...
...
app/assets/javascripts/repo/components/repo_editor.vue
View file @
8b16f107
...
@@ -64,11 +64,6 @@ const RepoEditor = {
...
@@ -64,11 +64,6 @@ const RepoEditor = {
if
(
e
.
target
.
element
.
classList
.
contains
(
'
line-numbers
'
))
{
if
(
e
.
target
.
element
.
classList
.
contains
(
'
line-numbers
'
))
{
location
.
hash
=
`L
${
lineNumber
}
`
;
location
.
hash
=
`L
${
lineNumber
}
`
;
Store
.
setActiveLine
(
lineNumber
);
Store
.
setActiveLine
(
lineNumber
);
Helper
.
monacoInstance
.
setPosition
({
lineNumber
:
this
.
activeLine
,
column
:
1
,
});
}
}
},
},
},
},
...
@@ -101,6 +96,15 @@ const RepoEditor = {
...
@@ -101,6 +96,15 @@ const RepoEditor = {
this
.
setupEditor
();
this
.
setupEditor
();
}
}
},
},
activeLine
()
{
if
(
Helper
.
monacoInstance
)
{
Helper
.
monacoInstance
.
setPosition
({
lineNumber
:
this
.
activeLine
,
column
:
1
,
});
}
},
},
},
computed
:
{
computed
:
{
shouldHideEditor
()
{
shouldHideEditor
()
{
...
...
app/assets/javascripts/repo/components/repo_preview.vue
View file @
8b16f107
...
@@ -28,6 +28,9 @@ export default {
...
@@ -28,6 +28,9 @@ export default {
this
.
highlightFile
();
this
.
highlightFile
();
});
});
},
},
activeLine
(
e
)
{
this
.
lineHighlighter
.
highlightHash
(
'
#L
'
+
Store
.
activeLine
);
},
},
},
};
};
</
script
>
</
script
>
...
...
app/assets/javascripts/repo/components/repo_sidebar.vue
View file @
8b16f107
...
@@ -42,14 +42,6 @@ export default {
...
@@ -42,14 +42,6 @@ export default {
const
lineNumber
=
Number
(
location
.
hash
.
substr
(
2
));
const
lineNumber
=
Number
(
location
.
hash
.
substr
(
2
));
if
(
!
isNaN
(
lineNumber
))
{
if
(
!
isNaN
(
lineNumber
))
{
Store
.
setActiveLine
(
lineNumber
);
Store
.
setActiveLine
(
lineNumber
);
if
(
Store
.
isPreviewView
()
&&
document
.
getElementById
(
`L
${
lineNumber
}
`
))
{
document
.
getElementById
(
`L
${
lineNumber
}
`
).
scrollIntoView
();
}
else
{
Helper
.
monacoInstance
.
setPosition
({
lineNumber
:
this
.
activeLine
,
column
:
1
,
});
}
}
}
}
}
}
else
{
}
else
{
...
...
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