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
6131a657
Commit
6131a657
authored
8 years ago
by
john
Browse files
Options
Downloads
Patches
Plain Diff
select and write strikes through selection and creates add annotation after it
parent
ca318e7e
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
+37
-133
37 additions, 133 deletions
...impleEditor/elements/track_change/TrackChangesProvider.js
with
37 additions
and
133 deletions
app/components/SimpleEditor/elements/track_change/TrackChangesProvider.js
+
37
−
133
View file @
6131a657
...
...
@@ -18,11 +18,8 @@ class TrackChangesProvider {
}
handleTransaction
(
options
)
{
// const status = options.status
this
.
handleAdd
(
options
)
this
.
handleDelete
(
options
)
// if (this.shouldDelete(status)) this.delete()
}
handleAdd
(
options
)
{
...
...
@@ -41,6 +38,17 @@ class TrackChangesProvider {
this
.
createAddAnnotation
(
selection
)
this
.
moveCursorTo
(
'
end
'
)
return
}
else
{
selection
=
this
.
getSelection
()
this
.
createDeleteAnnotation
(
selection
)
this
.
moveCursorTo
(
'
end
'
)
this
.
insertText
(
event
)
selection
=
this
.
setSelectionPlusOne
(
'
left
'
)
this
.
createAddAnnotation
(
selection
)
this
.
separateAnnotations
()
this
.
moveCursorTo
(
'
end
'
)
return
}
}
...
...
@@ -49,37 +57,37 @@ class TrackChangesProvider {
if
(
status
!==
'
delete
'
)
return
const
mode
=
this
.
getMode
()
const
isSelectionCollapsed
=
this
.
isSelectionCollapsed
()
let
selection
console
.
log
(
'
move
'
,
move
)
const
direction
=
{
cursorTo
:
(
move
===
'
left
'
)
?
'
start
'
:
'
end
'
,
move
:
move
}
if
(
!
mode
)
{
// selection = this.setSelectionPlusOne('left')
selection
=
this
.
setSelectionPlusOne
(
direction
.
move
)
if
(
isSelectionCollapsed
)
{
if
(
!
mode
)
{
selection
=
this
.
setSelectionPlusOne
(
direction
.
move
)
this
.
createDeleteAnnotation
(
selection
)
this
.
moveCursorTo
(
direction
.
cursorTo
)
return
}
if
(
mode
===
'
delete
'
)
{
selection
=
this
.
setSelectionPlusOne
(
direction
.
move
)
const
annotation
=
this
.
getAnnotationByStatus
(
'
delete
'
)
this
.
expandTrackAnnotation
(
selection
,
annotation
)
this
.
moveCursorTo
(
direction
.
cursorTo
)
return
}
}
else
{
selection
=
this
.
getSelection
()
this
.
createDeleteAnnotation
(
selection
)
this
.
moveCursorTo
(
direction
.
cursorTo
)
return
}
if
(
mode
===
'
delete
'
)
{
selection
=
this
.
setSelectionPlusOne
(
direction
.
move
)
const
annotation
=
this
.
getAnnotationByStatus
(
'
delete
'
)
this
.
expandTrackAnnotation
(
selection
,
annotation
)
this
.
moveCursorTo
(
direction
.
cursorTo
)
}
// const isSelectionCollapsed = this.isSelectionCollapsed()
// if (!this.isSelectionCollapsed()) options.deleteCollapsed = true
// this.createDeletionAnnotation(options)
}
// expand annotation
// truncate annotation
createAddAnnotation
(
selection
)
{
this
.
createTrackAnnotation
(
selection
,
'
add
'
)
}
...
...
@@ -114,60 +122,11 @@ class TrackChangesProvider {
})
}
insertText
(
event
)
{
const
surface
=
this
.
getSurface
()
surface
.
transaction
(
function
(
tx
,
args
)
{
if
(
surface
.
domSelection
)
surface
.
domSelection
.
clear
()
args
.
text
=
event
.
data
return
surface
.
insertText
(
tx
,
args
)
},
{
action
:
'
type
'
})
}
createAdditionAnnotation
()
{
const
mode
=
this
.
getMode
()
const
onDelete
=
this
.
isOnAnnotation
(
'
delete
'
)
// const onAdd = this.isOnAnnotation('add')
// console.log('mode', mode)
// console.log('on delete', onDelete)
// console.log('on add', onAdd)
if
(
mode
&&
!
onDelete
)
return
const
surface
=
this
.
getSurface
()
const
transformation
=
(
tx
,
args
)
=>
{
const
selection
=
this
.
createSelection
(
args
)
const
newNode
=
{
selection
:
selection
,
node
:
{
'
status
'
:
'
add
'
,
'
type
'
:
'
track-change
'
}
}
createAnnotation
(
tx
,
newNode
)
this
.
clearSelection
(
args
,
'
add
'
)
}
const
info
=
{}
surface
.
transaction
(
transformation
,
info
)
if
(
onDelete
)
{
this
.
separateAnnotations
()
}
// if (onAdd) {
//
// }
}
separateAnnotations
()
{
console
.
log
(
'
separate
'
)
const
surface
=
this
.
getSurface
()
const
deleteAnnotation
=
this
.
getAnnotationByStatus
(
'
delete
'
)
const
addAnnotation
=
this
.
getAnnotationByStatus
(
'
add
'
)
console
.
log
(
'
delete anno
'
,
deleteAnnotation
)
console
.
log
(
'
add anno
'
,
addAnnotation
)
const
deleteAnnotation
=
this
.
getAnnotationByStatus
(
'
delete
'
)
surface
.
transaction
((
tx
,
args
)
=>
{
args
.
anno
=
deleteAnnotation
...
...
@@ -176,70 +135,15 @@ class TrackChangesProvider {
})
}
createDeletionAnnotation
(
options
)
{
const
deleteCollapsed
=
options
.
deleteCollapsed
const
mode
=
this
.
getMode
()
insertText
(
event
)
{
const
surface
=
this
.
getSurface
()
const
transformation
=
(
tx
,
args
)
=>
{
let
selection
=
args
.
selection
if
(
!
deleteCollapsed
)
selection
=
this
.
createSelection
(
args
)
if
(
mode
===
'
delete
'
)
{
args
.
anno
=
this
.
getExistingAnnotation
()
expandAnnotation
(
tx
,
args
)
}
else
{
const
newNode
=
{
selection
:
selection
,
node
:
{
'
status
'
:
'
delete
'
,
'
type
'
:
'
track-change
'
}
}
createAnnotation
(
tx
,
newNode
)
}
args
.
deleteCollapsed
=
deleteCollapsed
this
.
clearSelection
(
args
,
'
delete
'
)
}
const
info
=
{}
surface
.
transaction
(
transformation
,
info
)
}
/*
DECISION MAKERS
*/
// shouldAdd (status) {
// if (status !== 'add') return false
//
// const mode = this.getMode()
// if (mode) return false
//
// return true
// }
shouldDelete
(
status
)
{
if
(
status
===
'
delete
'
)
return
true
console
.
log
(
status
)
console
.
log
(
this
.
isSelectionCollapsed
())
if
(
status
===
'
create
'
&&
!
this
.
isSelectionCollapsed
())
return
true
return
false
surface
.
transaction
(
function
(
tx
,
args
)
{
if
(
surface
.
domSelection
)
surface
.
domSelection
.
clear
()
args
.
text
=
event
.
data
return
surface
.
insertText
(
tx
,
args
)
},
{
action
:
'
type
'
})
}
// shouldExpand () {
//
// }
// shouldTruncate () {
//
// }
/*
ANNOTATION HELPERS
...
...
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