Skip to content
Snippets Groups Projects
Commit a2779ab8 authored by chris's avatar chris Committed by Yannis Barlas
Browse files

fixes: you can add comment and update active entry

parent 29460531
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ class Editor extends ProseEditor {
didMount () {
console.log(this.editorSession)
this.editorSession.onUpdate('document', this.rerender, this, {})
// this.editorSession.onUpdate('document', this.rerender, this, {})
// this.documentSession.on('didUpdate', this.documentSessionUpdated, this)
// this.documentSession.on('fileUploadTrigger', this.handleUpload, this)
this.extendState({ editorReady: true })
......
......@@ -8,16 +8,14 @@ import {
import CommentList from './CommentList'
class CommentBox extends Component {
constructor (props) {
super(props)
constructor (props, args) {
super(props, args)
this.inputHeight = 0
}
// TODO -- fix class names
render ($$) {
console.log('in comment box')
const active = this.props.active
const entry = this.props.entry
const {active, entry} = this.props
let comments = this.props.comments.data
......@@ -85,7 +83,7 @@ class CommentBox extends Component {
textAreaAdjust (event) {
const value = this.refs.commentReply.getValue()
let replyBtn = this.refs.commentReplyButton
console.log('replyBn', replyBtn)
if (value.trim().length > 0) {
replyBtn.removeAttr('disabled')
} else {
......
......@@ -28,15 +28,16 @@ class CommentBoxList extends Component {
// const entries = provider.getEntries()
const entries = provider.computeEntries()
const activeEntry = provider.activeEntry
const { comments, user } = self.props
const listItems = entries.map(function (entry, i) {
const active = (entry.id === activeEntry)
return $$(CommentBox, {
active: active,
comments: self.props.comments[entry.id] || { data: [] },
comments: comments[entry.id] || { data: [] },
entry: entry,
parent: self,
user: self.props.user
user: user
})
})
......@@ -115,6 +116,7 @@ class CommentBoxList extends Component {
// if active, move as many boxes above as needed to bring it to the annotation's height
if (isActive) {
console.log('isActive', isActive)
entry.endHeight = annotationTop + boxHeight + 2
result[pos] = annotationTop
......
......@@ -7,7 +7,7 @@ class CommentsProvider extends TocProvider {
super(document, props)
this.activeEntry = null
const editorSession = props.editorSession
editorSession.onUpdate('document', this.updateActiveEntry, this)
editorSession.onUpdate('', this.updateActiveEntry, this)
const doc = editorSession.getDocument()
doc.on('document:changed', this.update, this)
......@@ -252,11 +252,11 @@ class CommentsProvider extends TocProvider {
const comments = this.getSelectionComments()
if (comments.length === 0) return
const minComment = _.minBy(comments, 'startOffset')
const maxComment = _.maxBy(comments, 'endOffset')
const minComment = _.minBy(comments, 'start.offset')
const maxComment = _.maxBy(comments, 'end.offset')
const min = minComment.startOffset
const max = maxComment.endOffset
const min = minComment.start.offset
const max = maxComment.end.offset
return {
start: min,
......@@ -281,8 +281,8 @@ class CommentsProvider extends TocProvider {
const selection = this.getSelection()
if (
selection.startOffset < commentBorders.start ||
selection.endOffset > commentBorders.end
selection.start.offset < commentBorders.start ||
selection.end.offset > commentBorders.end
) return true
return false
......@@ -376,7 +376,7 @@ class CommentsProvider extends TocProvider {
comments = _.map(comments, function (comment) {
const blockId = comment.path[0]
const blockPosition = container.getPosition(blockId)
const nodePosition = comment.startOffset
const nodePosition = comment.start.offset
return {
id: comment.id,
......
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