Commit 3555797b authored by chris's avatar chris

select next on on image caption insert

parent 845bc4b9
import { findIndex } from 'lodash'
import { Component } from 'substance'
class ImageCaption extends Component {
......@@ -36,11 +37,34 @@ class ImageCaption extends Component {
editorSession.setSelection(null)
}
moveSelectionToNextBlock() {
//TODO
// console.log(selection)
// console.log(
// this.context.editorSession.document.data.nodes[selection.containerId],
// )
const editorSession = this.context.editorSession
const selection = editorSession.getSelection()
const containerId = selection.containerId
const nodes = editorSession.document.data.nodes[containerId].nodes
const index = findIndex(nodes, node => node === selection.nodeId)
const nextnode = nodes[index + 1] ? nodes[index + 1] : undefined
if (!nextnode) {
editorSession.transaction(tx => {
tx.break()
})
}
setTimeout(() => {
editorSession.transaction(tx => {
tx.setSelection({
type: 'property',
containerId,
surfaceId: containerId,
path: [
editorSession.document.data.nodes[containerId].nodes[index + 1],
'content',
],
startOffset: 0,
endOffset: 0,
})
})
})
}
}
......
Markdown is supported
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