Skip to content
Snippets Groups Projects
Commit ca318e7e authored by john's avatar john
Browse files

delete and backspace tracking goes in opposite directions

parent ab5dec66
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ import {
ContainerEditor as SubstanceContainerEditor,
// deleteCharacter,
// deleteSelection,
keys as keyboardKeys,
Surface,
uuid
} from 'substance'
......@@ -96,11 +97,11 @@ class ContainerEditor extends SubstanceContainerEditor {
event.stopPropagation()
// TODO -- needed?
const direction = (event.keyCode === keys.BACKSPACE) ? 'left' : 'right'
const direction = (event.keyCode === keyboardKeys.BACKSPACE) ? 'left' : 'right'
const trackChangesProvider = this.context.trackChangesProvider
const options = {
direction: direction,
move: direction,
status: 'delete'
}
trackChangesProvider.handleTransaction(options)
......
......@@ -45,23 +45,30 @@ class TrackChangesProvider {
}
handleDelete (options) {
const { status } = options
const { move, status } = options
if (status !== 'delete') return
const mode = this.getMode()
let selection
console.log('move', move)
const direction = {
cursorTo: (move === 'left') ? 'start' : 'end',
move: move
}
if (!mode) {
selection = this.setSelectionPlusOne('left')
// selection = this.setSelectionPlusOne('left')
selection = this.setSelectionPlusOne(direction.move)
this.createDeleteAnnotation(selection)
this.moveCursorTo('start')
this.moveCursorTo(direction.cursorTo)
return
}
if (mode === 'delete') {
selection = this.setSelectionPlusOne('left')
selection = this.setSelectionPlusOne(direction.move)
const annotation = this.getAnnotationByStatus('delete')
this.expandTrackAnnotation(selection, annotation)
this.moveCursorTo('start')
this.moveCursorTo(direction.cursorTo)
}
// const isSelectionCollapsed = this.isSelectionCollapsed()
......@@ -207,14 +214,14 @@ class TrackChangesProvider {
*/
shouldAdd (status) {
if (status !== 'add') return false
const mode = this.getMode()
if (mode) return false
return true
}
// shouldAdd (status) {
// if (status !== 'add') return false
//
// const mode = this.getMode()
// if (mode) return false
//
// return true
// }
shouldDelete (status) {
if (status === 'delete') return true
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment