Skip to content
Snippets Groups Projects
Commit b59c9ce1 authored by chris's avatar chris
Browse files

accept reject track changes working for deletions and addtions

parent 6f19501d
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,7 @@ class Editor extends ProseEditor { ...@@ -35,6 +35,7 @@ class Editor extends ProseEditor {
this.props.updateTrackChangesStatus(!this.props.trackChanges) this.props.updateTrackChangesStatus(!this.props.trackChanges)
this.extendState({ trackChanges: !this.props.trackChanges }) this.extendState({ trackChanges: !this.props.trackChanges })
console.log(this.el)
} }
updateTrackChangeView () { updateTrackChangeView () {
...@@ -107,7 +108,7 @@ class Editor extends ProseEditor { ...@@ -107,7 +108,7 @@ class Editor extends ProseEditor {
contentPanelWithSplitPane contentPanelWithSplitPane
) )
) )
if (this.props.trackChanges || this.state.trackChangesView) el.addClass('track-changes-mode')
return el return el
} }
......
...@@ -38,6 +38,12 @@ $white: #fff; ...@@ -38,6 +38,12 @@ $white: #fff;
top: 10px; top: 10px;
} }
} }
.track-changes-mode {
.se-content {
line-height: 38px;
}
}
} }
.sc-prose-editor { .sc-prose-editor {
...@@ -183,7 +189,6 @@ $white: #fff; ...@@ -183,7 +189,6 @@ $white: #fff;
.se-content { .se-content {
color: $transparent-black; color: $transparent-black;
font-family: 'Fira Sans'; font-family: 'Fira Sans';
line-height: 38px;
word-wrap: break-word; word-wrap: break-word;
::selection { ::selection {
......
...@@ -7,7 +7,7 @@ class TrackChangeComponent extends AnnotationComponent { ...@@ -7,7 +7,7 @@ class TrackChangeComponent extends AnnotationComponent {
const trackChangesView = this.toggleTrackChangeView() const trackChangesView = this.toggleTrackChangeView()
let hideDeletes = '' let hideDeletes = ''
let ShowAdditions = '' let ShowAdditions = ''
// console.log('trackChangesView', trackChangesView)
if (trackChangesView === false && status === 'delete') { if (trackChangesView === false && status === 'delete') {
hideDeletes = 'sc-track-delete-hide' hideDeletes = 'sc-track-delete-hide'
} }
...@@ -45,6 +45,7 @@ class TrackChangeComponent extends AnnotationComponent { ...@@ -45,6 +45,7 @@ class TrackChangeComponent extends AnnotationComponent {
return el return el
} }
// TODO Move most of the funcs into provider
getSurface () { getSurface () {
const surfaceManager = this.context.surfaceManager const surfaceManager = this.context.surfaceManager
const containerId = this.context.controller.props.containerId const containerId = this.context.controller.props.containerId
...@@ -62,9 +63,38 @@ class TrackChangeComponent extends AnnotationComponent { ...@@ -62,9 +63,38 @@ class TrackChangeComponent extends AnnotationComponent {
acceptTrackChange () { acceptTrackChange () {
const nodeId = this.props.node.id const nodeId = this.props.node.id
const status = this.props.node.status const status = this.props.node.status
console.log('accept track change', status) const ds = this.getDocumentSession()
const doc = ds.getDocument()
const nodeData = this.buildNodeData()
const ds = this.context.documentSession var self = this
ds.transaction(function (tx, args) {
if (status === 'add') createAnnotation(doc, nodeData)
deleteNode(tx, { nodeId: nodeId })
if (status === 'delete') self.context.surface.delete(tx, nodeData)
})
}
rejectTrackChange () {
const nodeId = this.props.node.id
const status = this.props.node.status
const ds = this.getDocumentSession()
const doc = ds.getDocument()
const nodeData = this.buildNodeData()
var self = this
ds.transaction(function (tx, args) {
if (status === 'delete') createAnnotation(doc, nodeData)
deleteNode(tx, { nodeId: nodeId })
if (status === 'add') self.context.surface.delete(tx, nodeData)
})
}
buildNodeData () {
const nodeId = this.props.node.id
const ds = this.getDocumentSession()
const doc = ds.getDocument() const doc = ds.getDocument()
const trackChangeNode = doc.get(nodeId) const trackChangeNode = doc.get(nodeId)
...@@ -74,19 +104,14 @@ class TrackChangeComponent extends AnnotationComponent { ...@@ -74,19 +104,14 @@ class TrackChangeComponent extends AnnotationComponent {
const sel = ds.createSelection(path, startOffset, endOffset) const sel = ds.createSelection(path, startOffset, endOffset)
const nodeData = { return {
selection: sel, selection: sel,
node: { type: 'paragraph' } node: { type: 'paragraph' }
} }
ds.transaction(function (tx, args) {
createAnnotation(doc, nodeData)
deleteNode(tx, { nodeId: nodeId })
})
} }
rejectTrackChange () { getDocumentSession () {
console.log('reject track change') return this.context.documentSession
} }
} }
......
...@@ -13,7 +13,8 @@ class TrackChangeControlViewCommand extends Command { ...@@ -13,7 +13,8 @@ class TrackChangeControlViewCommand extends Command {
execute (params, context) { execute (params, context) {
const surface = context.surfaceManager.getSurface('body') const surface = context.surfaceManager.getSurface('body')
surface.send('trackChangesViewUpdate') surface.send('trackChangesViewUpdate')
return true surface.selectAll()
surface.selectFirst()
} }
} }
......
.sc-track-change { $blue: blue;
// background-color: #f7f70c;
}
.sc-track-change-add { .sc-track-change-add {
color: blue; color: $blue;
text-decoration: none; text-decoration: none;
} }
...@@ -16,7 +14,11 @@ ...@@ -16,7 +14,11 @@
} }
.sc-track-add-show { .sc-track-add-show {
background: transparent !important; color: inherit !important;
.sc-accept-reject-container {
display: none;
}
} }
.sc-accept-reject-container { .sc-accept-reject-container {
...@@ -27,11 +29,12 @@ ...@@ -27,11 +29,12 @@
position: absolute; position: absolute;
.sc-track-item { .sc-track-item {
color: $blue;
cursor: pointer; cursor: pointer;
color: blue;
} }
.sc-track-separator { .sc-track-separator {
color: blue; color: $blue;
} }
} }
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