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

rerender comments on change

parent 6eaa5775
No related branches found
No related tags found
No related merge requests found
...@@ -43,16 +43,11 @@ class Editor extends ProseEditor { ...@@ -43,16 +43,11 @@ class Editor extends ProseEditor {
willUpdateState () {} willUpdateState () {}
didMount () { didMount () {
this.editorSession.onRender('document', this.editorContentUpdated, this)
// this.documentSession.on('didUpdate', this.documentSessionUpdated, this) // this.documentSession.on('didUpdate', this.documentSessionUpdated, this)
// this.documentSession.on('fileUploadTrigger', this.handleUpload, this) // this.documentSession.on('fileUploadTrigger', this.handleUpload, this)
this.extendState({ editorReady: true }) this.extendState({ editorReady: true })
} }
editorContentUpdated () {
this.emit('ui:updated')
}
handleUpload (file, callback) { handleUpload (file, callback) {
const { fileUpload } = this.props const { fileUpload } = this.props
......
...@@ -4,6 +4,8 @@ class CommentComponent extends AnnotationComponent { ...@@ -4,6 +4,8 @@ class CommentComponent extends AnnotationComponent {
constructor (parent, props) { constructor (parent, props) {
super(parent, props) super(parent, props)
this.active = props.node.active this.active = props.node.active
// this.context.editorSession.onUpdate('', this.rerender, this)
} }
render ($$) { render ($$) {
...@@ -39,6 +41,7 @@ class CommentComponent extends AnnotationComponent { ...@@ -39,6 +41,7 @@ class CommentComponent extends AnnotationComponent {
// put here all conditions for the node to change // put here all conditions for the node to change
hasNodeChanged () { hasNodeChanged () {
const { node } = this.props const { node } = this.props
console.log(node)
if (this.active !== node.active) return true if (this.active !== node.active) return true
return false return false
} }
......
import _ from 'lodash' import _ from 'lodash'
import { createAnnotation, TOCProvider as TocProvider } from 'substance' import { TOCProvider as TocProvider } from 'substance'
class CommentsProvider extends TocProvider { class CommentsProvider extends TocProvider {
// TODO -- works if I rename to doc // TODO -- works if I rename to doc
...@@ -9,15 +9,13 @@ class CommentsProvider extends TocProvider { ...@@ -9,15 +9,13 @@ class CommentsProvider extends TocProvider {
const editorSession = props.editorSession const editorSession = props.editorSession
editorSession.onUpdate('', this.updateActiveEntry, this) editorSession.onUpdate('', this.updateActiveEntry, this)
editorSession.onRender('document', this.update, this) editorSession.onRender('document', this.update, this)
// TODO is this needed? // TODO is this needed anymore?
// const doc = editorSession.getDocument() // const doc = editorSession.getDocument()
// doc.on('document:changed', this.update, this) // doc.on('document:changed', this.update, this)
// const editor = props.controller
const editor = props.controller // editor.on('ui:updated', this.onUiUpdate, this)
editor.on('ui:updated', this.onUiUpdate, this)
} }
// //
......
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