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
f1e9d6d8
Commit
f1e9d6d8
authored
8 years ago
by
john
Browse files
Options
Downloads
Patches
Plain Diff
expand add annotation when writing on its left edge
parent
db8493e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/components/SimpleEditor/elements/track_change/TrackChangesProvider.js
+50
-10
50 additions, 10 deletions
...impleEditor/elements/track_change/TrackChangesProvider.js
with
50 additions
and
10 deletions
app/components/SimpleEditor/elements/track_change/TrackChangesProvider.js
+
50
−
10
View file @
f1e9d6d8
...
@@ -27,17 +27,35 @@ class TrackChangesProvider {
...
@@ -27,17 +27,35 @@ class TrackChangesProvider {
if
(
status
!==
'
add
'
)
return
if
(
status
!==
'
add
'
)
return
const
isSelectionCollapsed
=
this
.
isSelectionCollapsed
()
const
isSelectionCollapsed
=
this
.
isSelectionCollapsed
()
const
mode
=
this
.
getMode
()
//
const mode = this.getMode()
let
selection
let
selection
if
(
isSelectionCollapsed
)
{
if
(
isSelectionCollapsed
)
{
this
.
insertText
(
event
)
this
.
insertText
(
event
)
if
(
mode
)
return
selection
=
this
.
setSelectionPlusOne
(
'
left
'
)
const
notOnTrack
=
this
.
isNotOnTrackAnnotation
()
this
.
createAddAnnotation
(
selection
)
this
.
moveCursorTo
(
'
end
'
)
if
(
notOnTrack
)
{
return
selection
=
this
.
setSelectionPlusOne
(
'
left
'
)
this
.
createAddAnnotation
(
selection
)
this
.
moveCursorTo
(
'
end
'
)
return
}
else
{
const
isOnAdd
=
this
.
isOnAnnotation
(
'
add
'
)
if
(
isOnAdd
)
{
const
annotation
=
this
.
getAnnotationByStatus
(
'
add
'
)
const
isOnLeftEdge
=
this
.
isOnLeftEdge
(
annotation
)
if
(
isOnLeftEdge
)
{
selection
=
this
.
setSelectionPlusOne
(
'
left
'
)
this
.
expandTrackAnnotation
(
selection
,
annotation
)
this
.
moveCursorTo
(
'
end
'
)
return
}
}
}
}
else
{
}
else
{
selection
=
this
.
getSelection
()
selection
=
this
.
getSelection
()
this
.
createDeleteAnnotation
(
selection
)
this
.
createDeleteAnnotation
(
selection
)
...
@@ -98,8 +116,9 @@ class TrackChangesProvider {
...
@@ -98,8 +116,9 @@ class TrackChangesProvider {
createTrackAnnotation
(
selection
,
status
)
{
createTrackAnnotation
(
selection
,
status
)
{
const
surface
=
this
.
getSurface
()
const
surface
=
this
.
getSurface
()
const
info
=
this
.
getInfo
()
surface
.
transac
tion
(
(
tx
,
args
)
=>
{
const
transforma
tion
=
(
tx
,
args
)
=>
{
const
newNode
=
{
const
newNode
=
{
selection
:
selection
,
selection
:
selection
,
node
:
{
node
:
{
...
@@ -108,18 +127,23 @@ class TrackChangesProvider {
...
@@ -108,18 +127,23 @@ class TrackChangesProvider {
}
}
}
}
createAnnotation
(
tx
,
newNode
)
createAnnotation
(
tx
,
newNode
)
})
}
surface
.
transaction
(
transformation
,
info
)
}
}
expandTrackAnnotation
(
selection
,
annotation
)
{
expandTrackAnnotation
(
selection
,
annotation
)
{
const
surface
=
this
.
getSurface
()
const
surface
=
this
.
getSurface
()
const
info
=
this
.
getInfo
()
surface
.
transac
tion
(
(
tx
,
args
)
=>
{
const
transforma
tion
=
(
tx
,
args
)
=>
{
args
.
selection
=
selection
args
.
selection
=
selection
args
.
anno
=
annotation
args
.
anno
=
annotation
expandAnnotation
(
tx
,
args
)
expandAnnotation
(
tx
,
args
)
})
}
surface
.
transaction
(
transformation
,
info
)
}
}
separateAnnotations
()
{
separateAnnotations
()
{
...
@@ -177,6 +201,12 @@ class TrackChangesProvider {
...
@@ -177,6 +201,12 @@ class TrackChangesProvider {
return
annotations
return
annotations
}
}
// prevent substance from running getBoundingRectangle,
// as we will unset the selection manually
getInfo
()
{
return
{
skipSelection
:
true
}
}
// returns whether the selection is on an add / delete tracked change
// returns whether the selection is on an add / delete tracked change
isOnAnnotation
(
status
)
{
isOnAnnotation
(
status
)
{
const
annotations
=
this
.
getAllExistingTrackAnnotations
()
const
annotations
=
this
.
getAllExistingTrackAnnotations
()
...
@@ -188,6 +218,16 @@ class TrackChangesProvider {
...
@@ -188,6 +218,16 @@ class TrackChangesProvider {
return
true
return
true
}
}
isOnLeftEdge
(
annotation
)
{
const
selection
=
this
.
getSelection
()
return
(
selection
.
startOffset
===
annotation
.
startOffset
)
}
isNotOnTrackAnnotation
()
{
const
mode
=
this
.
getMode
()
return
(
mode
===
null
)
}
/**
/**
HISTORY HANDLERS
HISTORY HANDLERS
...
...
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