Skip to content
Snippets Groups Projects
Commit d3dd110d authored by chris's avatar chris Committed by john
Browse files

click on a note callout on editor scrolls to the corresponding in mini editor

parent f60b2bee
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,7 @@ class Editor extends ProseEditor {
didMount () {
this.extendState({ editorReady: true })
this.on('noteSelected', this.scrollTo, this)
}
render ($$) {
......@@ -260,7 +261,8 @@ class Editor extends ProseEditor {
// notes provider
const notesProvider = new NotesProvider(doc, {
miniEditorSession: ''
miniEditorSession: '',
miniEditorContext: ''
})
// comments provider
......
......@@ -20,6 +20,7 @@ class EditNoteTool extends Tool {
render ($$) {
const miniEditorSession = this._initMiniEditor()
const selected = this.getSelection()
const provider = this.getProvider()
let el = $$('div').addClass('sc-edit-note-tool')
......@@ -28,7 +29,7 @@ class EditNoteTool extends Tool {
el.append($$(MiniEditor, {
editorSession: miniEditorSession
}))
provider.config.miniEditorContext.editor.emit('noteSelected', 'paragraph-71bf75436a5f9b56700064c6ee2116ab')
return el
}
......@@ -125,6 +126,10 @@ class EditNoteTool extends Tool {
}
}
getProvider () {
return this.context.notesProvider
}
getSurface () {
const surfaceManager = this.context.surfaceManager
return surfaceManager.getFocusedSurface()
......
......@@ -10,11 +10,14 @@ import CommentsProvider from '../panes/Comments/CommentsProvider'
class MiniEditor extends ProseEditor {
didMount () {
this.context.notesProvider.config.miniEditorContext = this.getChildContext()
this.editorSession.onUpdate('document', this.setEditorSession, this)
this.context.notesProvider.config.miniEditorSession = this.editorSession
this.on('noteSelected', this.scrollTo, this)
}
setEditorSession () {
this.context.notesProvider.config.miniEditorContext = this.getChildContext()
this.context.notesProvider.config.miniEditorSession = this.editorSession
this.context.notesProvider.computeEntries()
}
......@@ -78,6 +81,10 @@ class MiniEditor extends ProseEditor {
}).ref('mini_body')
}
scrollTo (nodeId) {
this.refs.miniEditorContentPanel.scrollTo(nodeId)
}
getChildContext () {
const oldContext = super.getChildContext()
const doc = this.doc
......
......@@ -80,7 +80,7 @@ class Notes extends Component {
onNotesUpdated (change) {
const notesProvider = this.getProvider()
notesProvider.handleDocumentChange(change)
this.el.el.style.height = '95px'
// this.el.el.style.height = '95px'
}
dispose () {
......
......@@ -10,13 +10,13 @@ class NotesProvider extends TOCProvider {
const docMini = this.config.miniEditorSession.document
let nodesMini = ''
if (docMini) nodesMini = docMini.getNodes()
if(docMini)console.log('paragraphs', nodesMini)
// get all notes from the document
const notesMain = _.pickBy(nodesMain, function (value, key) {
return value.type === 'note'
})
const notesMini = _.pickBy(nodesMini, function (value, key) {
return value.type === 'strong'
return value.type === 'paragraph'
})
const entries = this.sortNodes(notesMain)
......@@ -58,21 +58,22 @@ class NotesProvider extends TOCProvider {
const doc = this.config.miniEditorSession.document
const container = doc.get('body')
console.log(notes)
notes = _.map(notes, function (note) {
const blockId = note.path[0]
const blockPosition = container.getPosition(blockId)
const nodePosition = note.start.offset
// const blockId = note.path[0]
// const blockPosition = container.getPosition(blockId)
// const nodePosition = note.start.offset
return {
id: note.id,
content: note['note-content'],
blockPosition: blockPosition,
nodePosition: nodePosition,
node: note
content: note.content
// blockPosition: blockPosition,
// nodePosition: nodePosition,
// node: note
}
})
return _.sortBy(notes, ['blockPosition', 'nodePosition'])
return notes
// return _.sortBy(notes, ['blockPosition', 'nodePosition'])
}
}
......
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