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

comments--> not disaplying comments pane

parent 6933ff6b
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,13 @@ class ContainerEditor extends SubstanceContainerEditor { ...@@ -44,6 +44,13 @@ class ContainerEditor extends SubstanceContainerEditor {
if (this.isEmpty()) this.createText() if (this.isEmpty()) this.createText()
this.el.focus() // TODO notworking this.el.focus() // TODO notworking
let editorSession = this.getEditorSession()
editorSession.onUpdate('document', this._onContainerChanged, this, {
path: [this.getContainerId(), 'nodes']
})
editorSession.onUpdate('document', this.rerender, this, {})
// if (this.isReadOnlyMode()) { // if (this.isReadOnlyMode()) {
// const documentSession = this.getDocumentSession() // const documentSession = this.getDocumentSession()
// documentSession.on('didUpdate', this.disableToolbar, this) // documentSession.on('didUpdate', this.disableToolbar, this)
...@@ -173,7 +180,6 @@ class ContainerEditor extends SubstanceContainerEditor { ...@@ -173,7 +180,6 @@ class ContainerEditor extends SubstanceContainerEditor {
endOffset: 0 endOffset: 0
}) })
}.bind(this)) }.bind(this))
console.log(newSel)
this.rerender() this.rerender()
this.editorSession.setSelection(newSel) this.editorSession.setSelection(newSel)
} }
......
...@@ -27,7 +27,7 @@ class Editor extends ProseEditor { ...@@ -27,7 +27,7 @@ class Editor extends ProseEditor {
domSelectionRendered () { domSelectionRendered () {
// TODO what to handle here???? // TODO what to handle here????
console.log('rendered') // console.log('rendered')
} }
updateTrackChange () { updateTrackChange () {
...@@ -43,6 +43,8 @@ class Editor extends ProseEditor { ...@@ -43,6 +43,8 @@ class Editor extends ProseEditor {
willUpdateState () {} willUpdateState () {}
didMount () { didMount () {
console.log(this.editorSession)
this.editorSession.onUpdate('document', this.rerender, 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 })
...@@ -84,16 +86,16 @@ class Editor extends ProseEditor { ...@@ -84,16 +86,16 @@ class Editor extends ProseEditor {
footerNotes footerNotes
) )
// var commentsPane = this.state.editorReady var commentsPane = this.state.editorReady
// ? $$(Comments, { ? $$(Comments, {
// // TODO -- should probably remove the || {} // TODO -- should probably remove the || {}
// comments: this.props.fragment.comments || {}, comments: this.props.fragment.comments || {},
// fragment: this.props.fragment, fragment: this.props.fragment,
// update: this.props.update, update: this.props.update,
// user: this.props.user user: this.props.user
// }).addClass('sc-comments-pane') }).addClass('sc-comments-pane')
// : $$('div') : $$('div')
const commentsPane = $$('div')
var editorWithComments = $$(SplitPane, { sizeA: '100%', splitType: 'vertical' }) var editorWithComments = $$(SplitPane, { sizeA: '100%', splitType: 'vertical' })
.append( .append(
editorWithFooter, editorWithFooter,
...@@ -103,7 +105,7 @@ class Editor extends ProseEditor { ...@@ -103,7 +105,7 @@ class Editor extends ProseEditor {
var contentPanel = $$(ScrollPane, { var contentPanel = $$(ScrollPane, {
name: 'contentPanel', name: 'contentPanel',
// contextMenu: 'custom', // contextMenu: 'custom',
scrollbarPosition: 'right', scrollbarPosition: 'right'
}) })
.append(editorWithComments, .append(editorWithComments,
$$(Overlay), $$(Overlay),
...@@ -206,18 +208,18 @@ class Editor extends ProseEditor { ...@@ -206,18 +208,18 @@ class Editor extends ProseEditor {
// notes provider // notes provider
const notesProvider = new NotesProvider(doc) const notesProvider = new NotesProvider(doc)
// // comments provider // comments provider
// const commentsProvider = new CommentsProvider(doc, { const commentsProvider = new CommentsProvider(doc, {
// commandManager: this.commandManager, commandManager: this.commandManager,
// comments: this.props.fragment.comments, comments: this.props.fragment.comments,
// containerId: this.props.containerId, containerId: this.props.containerId,
// controller: this, controller: this,
// documentSession: this.documentSession, editorSession: this.editorSession,
// fragment: this.props.fragment, fragment: this.props.fragment,
// surfaceManager: this.surfaceManager, surfaceManager: this.surfaceManager,
// toggleCommentsArea: this.toggleCommentsArea, toggleCommentsArea: this.toggleCommentsArea,
// update: this.props.update update: this.props.update
// }) })
// TODO -- do I need all of these? // TODO -- do I need all of these?
// track changes provider // track changes provider
...@@ -234,9 +236,9 @@ class Editor extends ProseEditor { ...@@ -234,9 +236,9 @@ class Editor extends ProseEditor {
return { return {
...oldContext, ...oldContext,
tocProvider, tocProvider,
notesProvider notesProvider,
// commentsProvider, commentsProvider,
// trackChangesProvider trackChangesProvider
} }
} }
} }
......
...@@ -13,12 +13,13 @@ import { ...@@ -13,12 +13,13 @@ import {
SubscriptPackage, SubscriptPackage,
SuperscriptPackage, SuperscriptPackage,
SwitchTextTypePackage, SwitchTextTypePackage,
SpellCheckPackage SpellCheckPackage,
ListPackage
} from 'substance' } from 'substance'
// My Elements // My Elements
// import CodeblockPackage from './elements/codeblock/CodeblockPackage' // import CodeblockPackage from './elements/codeblock/CodeblockPackage'
// import CommentPackage from './elements/comment/CommentPackage' import CommentPackage from './elements/comment/CommentPackage'
// import ExtractPackage from './elements/extract/ExtractPackage' // import ExtractPackage from './elements/extract/ExtractPackage'
import NotePackage from './elements/note/NotePackage' import NotePackage from './elements/note/NotePackage'
// import SourceNotePackage from './elements/source_note/SourceNotePackage' // import SourceNotePackage from './elements/source_note/SourceNotePackage'
...@@ -56,12 +57,13 @@ let config = { ...@@ -56,12 +57,13 @@ let config = {
config.import(LinkPackage) config.import(LinkPackage)
config.import(SpellCheckPackage) config.import(SpellCheckPackage)
config.import(ListPackage)
// config.import(CodeblockPackage) // config.import(CodeblockPackage)
// // config.import(DialoguePackage) // // config.import(DialoguePackage)
// config.import(ExtractPackage) // config.import(ExtractPackage)
config.import(NotePackage) config.import(NotePackage)
// config.import(SourceNotePackage) // config.import(SourceNotePackage)
// config.import(CommentPackage) config.import(CommentPackage)
// config.import(ImagePackage) // config.import(ImagePackage)
// //
// config.import(TrackChangePackage) // config.import(TrackChangePackage)
......
import { import {
createAnnotation,
DefaultDOMElement, DefaultDOMElement,
FontAwesomeIcon as Icon, FontAwesomeIcon as Icon,
Tool Tool
...@@ -52,25 +51,27 @@ class CommentBubble extends Tool { ...@@ -52,25 +51,27 @@ class CommentBubble extends Tool {
if (!surface) return if (!surface) return
const documentElement = document.querySelector('.se-content') const documentElement = document.querySelector('.se-content')
const overlayContainer = document.querySelector('.sc-overlay-container') const overlayContainer = document.querySelector('.sc-overlay')
setTimeout(() => { // read comment below setTimeout(() => { // read comment below
const documentElementWidth = documentElement.offsetWidth const documentElementWidth = documentElement.offsetWidth
const overlayContainerLeft = overlayContainer.offsetLeft const overlayContainerLeft = overlayContainer.offsetLeft
const left = documentElementWidth - overlayContainerLeft - 15 const left = documentElementWidth - overlayContainerLeft - 15
const selection = this.getSelection()
const container = surface.getContainer()
const position = container.getPosition(selection.end.path[0])
// unhide it first, as the bubble has no height otherwise // unhide it first, as the bubble has no height otherwise
this.el.removeClass('sc-overlay-bubble-hidden') this.el.removeClass('sc-overlay-bubble-hidden')
console.log('positionposition', position)
const hints = surface.getBoundingRectangleForSelection() // const hints = surface.getBoundingRectangleForSelection()
const selectionHeight = hints.height // const selectionHeight = hints.height
const bubbleHeight = this.el.getHeight() // const bubbleHeight = this.el.getHeight()
const cheat = 3 // const cheat = 3
const moveUp = (selectionHeight / 2) + (bubbleHeight / 2) + cheat // const moveUp = (selectionHeight / 2) + (bubbleHeight / 2) + cheat
const top = '-' + moveUp + 'px' // const top = '-' + moveUp + 'px'
this.el.css('left', left) this.el.css('left', left)
this.el.css('top', top) // this.el.css('top', top)
}) })
/* /*
...@@ -89,8 +90,8 @@ class CommentBubble extends Tool { ...@@ -89,8 +90,8 @@ class CommentBubble extends Tool {
return commandStates.comment return commandStates.comment
} }
getDocumentSession () { getEditorSession () {
return this.context.documentSession return this.context.editorSession
} }
getMode () { getMode () {
...@@ -103,8 +104,8 @@ class CommentBubble extends Tool { ...@@ -103,8 +104,8 @@ class CommentBubble extends Tool {
} }
getSelection () { getSelection () {
const documentSession = this.getDocumentSession() const editorSession = this.getEditorSession()
return documentSession.getSelection() return editorSession.getSelection()
} }
// TODO -- get from provider // TODO -- get from provider
...@@ -137,12 +138,15 @@ class CommentBubble extends Tool { ...@@ -137,12 +138,15 @@ class CommentBubble extends Tool {
const newNode = { const newNode = {
selection: selection, selection: selection,
node: { type: 'comment' } type: 'comment',
path: selection.path,
start: selection.start,
end: selection.end
} }
surface.transaction((tx, args) => { surface.editorSession.transaction((tx, args) => {
const annotation = createAnnotation(tx, newNode) const annotation = tx.create(newNode)
provider.focusTextArea(annotation.node.id) provider.focusTextArea(annotation.id)
}) })
} }
} }
......
...@@ -17,7 +17,7 @@ $white: #fff; ...@@ -17,7 +17,7 @@ $white: #fff;
background-color: $light-green; background-color: $light-green;
} }
.sc-prose-editor-overlay-tools { .sc-overlay {
.se-active-tools { .se-active-tools {
.sc-overlay-bubble { .sc-overlay-bubble {
background: $white; background: $white;
......
...@@ -15,6 +15,7 @@ class CommentBox extends Component { ...@@ -15,6 +15,7 @@ class CommentBox extends Component {
// TODO -- fix class names // TODO -- fix class names
render ($$) { render ($$) {
console.log('in comment box')
const active = this.props.active const active = this.props.active
const entry = this.props.entry const entry = this.props.entry
......
...@@ -24,14 +24,14 @@ class CommentBoxList extends Component { ...@@ -24,14 +24,14 @@ class CommentBoxList extends Component {
render ($$) { render ($$) {
const self = this const self = this
console.log('in render')
const provider = self.getProvider() const provider = self.getProvider()
const entries = provider.getEntries() const entries = provider.getEntries()
const activeEntry = provider.activeEntry const activeEntry = provider.activeEntry
console.log('entries', entries)
const listItems = entries.map(function (entry, i) { const listItems = entries.map(function (entry, i) {
const active = (entry.id === activeEntry) const active = (entry.id === activeEntry)
return $$(CommentBox, { return $$(CommentBox, {
active: active, active: active,
comments: self.props.comments[entry.id] || { data: [] }, comments: self.props.comments[entry.id] || { data: [] },
...@@ -66,6 +66,7 @@ class CommentBoxList extends Component { ...@@ -66,6 +66,7 @@ class CommentBoxList extends Component {
setTops () { setTops () {
const provider = this.getProvider() const provider = this.getProvider()
const entries = provider.getEntries() const entries = provider.getEntries()
const activeEntry = provider.activeEntry const activeEntry = provider.activeEntry
this.calculateTops(entries, activeEntry) this.calculateTops(entries, activeEntry)
......
...@@ -6,11 +6,10 @@ class CommentsProvider extends TocProvider { ...@@ -6,11 +6,10 @@ class CommentsProvider extends TocProvider {
constructor (document, props) { constructor (document, props) {
super(document, props) super(document, props)
this.activeEntry = null this.activeEntry = null
const editorSession = props.editorSession
editorSession.onUpdate('document', this.updateActiveEntry, this)
const documentSession = props.documentSession const doc = editorSession.getDocument()
documentSession.on('didUpdate', this.updateActiveEntry, this)
const doc = documentSession.getDocument()
doc.on('document:changed', this.update, this) doc.on('document:changed', this.update, this)
const editor = props.controller const editor = props.controller
...@@ -65,6 +64,7 @@ class CommentsProvider extends TocProvider { ...@@ -65,6 +64,7 @@ class CommentsProvider extends TocProvider {
// runs when document session is updated // runs when document session is updated
updateActiveEntry () { updateActiveEntry () {
console.log('updateActiveEntry')
const activeEntry = this.getActiveEntry() const activeEntry = this.getActiveEntry()
const selectionContainsComments = this.selectionContainsComments() const selectionContainsComments = this.selectionContainsComments()
...@@ -214,7 +214,7 @@ class CommentsProvider extends TocProvider { ...@@ -214,7 +214,7 @@ class CommentsProvider extends TocProvider {
// returns an array of all comments in selection // returns an array of all comments in selection
getSelectionComments () { getSelectionComments () {
const selectionState = this.config.documentSession.getSelectionState() const selectionState = this.config.editorSession.getSelectionState()
return selectionState.getAnnotationsForType('comment') return selectionState.getAnnotationsForType('comment')
} }
...@@ -246,8 +246,8 @@ class CommentsProvider extends TocProvider { ...@@ -246,8 +246,8 @@ class CommentsProvider extends TocProvider {
return doc.get(id) return doc.get(id)
} }
getDocumentSession () { getEditorSession () {
return this.config.documentSession return this.config.editorSession
} }
// returns the combined borders of all comment annotations in selection // returns the combined borders of all comment annotations in selection
...@@ -268,8 +268,8 @@ class CommentsProvider extends TocProvider { ...@@ -268,8 +268,8 @@ class CommentsProvider extends TocProvider {
} }
getSelection () { getSelection () {
const documentSession = this.getDocumentSession() const editorSession = this.getEditorSession()
return documentSession.getSelection() return editorSession.getSelection()
} }
getSurface () { getSurface () {
......
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