Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
editoria
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yannis Barlas
editoria
Commits
3ba766c9
Commit
3ba766c9
authored
8 years ago
by
john
Browse files
Options
Downloads
Patches
Plain Diff
resolve choosing active comment logic
parent
4f06972a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/components/SimpleEditor/panes/Comments/CommentsProvider.js
+44
-8
44 additions, 8 deletions
...omponents/SimpleEditor/panes/Comments/CommentsProvider.js
with
44 additions
and
8 deletions
app/components/SimpleEditor/panes/Comments/CommentsProvider.js
+
44
−
8
View file @
3ba766c9
...
...
@@ -74,6 +74,7 @@ class CommentsProvider extends TocProvider {
}
const
activeComment
=
this
.
getActiveComment
()
if
(
!
activeComment
)
return
this
.
removeActiveEntry
()
// current selection and previous selection both belong to the same comment
if
(
activeEntry
===
activeComment
.
id
)
return
...
...
@@ -157,16 +158,46 @@ class CommentsProvider extends TocProvider {
}
getActiveComment
()
{
const
commentAnnotations
=
this
.
getSelectionComments
()
const
commentState
=
this
.
getCommentState
()
const
comments
=
this
.
getSelectionComments
()
const
mode
=
this
.
getMode
()
const
selection
=
this
.
getSelection
()
// we have a non-collapsed selection that contains multiple comments
if
(
mode
===
'
fuse
'
)
{
// only keep the comments that contain the whole selection
let
annos
=
_
.
filter
(
comments
,
annotation
=>
{
return
annotation
.
getSelection
().
contains
(
selection
)
})
if
(
annos
.
length
===
0
)
return
null
if
(
annos
.
length
===
1
)
return
annos
[
0
]
// find comments that contain all other comments and remove them
// the focus of the active comment should be inwards
let
remove
=
[]
_
.
forEach
(
annos
,
anno
=>
{
let
removeIt
=
true
// TODO -- there's gotta be a better way to do this than a double loop
_
.
forEach
(
annos
,
innerAnno
=>
{
if
(
anno
===
innerAnno
)
return
switch
(
commentState
.
mode
)
{
case
'
fuse
'
:
const
count
=
commentAnnotations
.
length
-
1
return
commentAnnotations
[
count
]
default
:
return
commentAnnotations
[
0
]
const
outerSelection
=
anno
.
getSelection
()
const
innerSelection
=
innerAnno
.
getSelection
()
if
(
!
outerSelection
.
contains
(
innerSelection
))
removeIt
=
false
})
if
(
removeIt
)
remove
.
push
(
anno
)
})
annos
=
_
.
difference
(
annos
,
remove
)
// once you have all comments that do not contain each other wholly
// just choose the one on the left
return
_
.
minBy
(
annos
,
'
startOffset
'
)
}
return
comments
[
0
]
}
// returns an array of all comments in selection
...
...
@@ -193,6 +224,11 @@ class CommentsProvider extends TocProvider {
return
commandStates
.
comment
}
getMode
()
{
const
commentState
=
this
.
getCommentState
()
return
commentState
.
mode
}
getNode
(
id
)
{
const
doc
=
this
.
getDocument
()
return
doc
.
get
(
id
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment