diff -r e165aa89ac82 -r b0e36664f1f2 client/src/components/SlateEditor.js --- a/client/src/components/SlateEditor.js Wed Jun 28 12:54:48 2017 +0200 +++ b/client/src/components/SlateEditor.js Wed Jun 28 13:29:07 2017 +0200 @@ -69,8 +69,12 @@ super(props); const annotationPlugin = AnnotationPlugin({ - onChange: (text) => { - this.setState({ currentSelectionText: text }); + onChange: (text, start, end) => { + this.setState({ + currentSelectionText: text, + currentSelectionStart: start, + currentSelectionEnd: end + }); } }); @@ -81,6 +85,8 @@ startedAt: null, finishedAt: null, currentSelectionText: '', + currentSelectionStart: 0, + currentSelectionEnd: 0, hoveringMenu: null, isPortalOpen: false, categories: Immutable.List([]), @@ -349,7 +355,7 @@ onCategoryClick = (category) => { - const { state, currentSelectionText } = this.state; + const { state, currentSelectionText, currentSelectionStart, currentSelectionEnd } = this.state; let { categories } = this.state; const transform = state.transform(); @@ -360,6 +366,10 @@ type: 'category', data: { text: currentSelectionText, + selection: { + start: currentSelectionStart, + end: currentSelectionEnd, + }, color: category.color, key: category.key }