diff options
Diffstat (limited to 'animism-align/frontend/views/align/align.actions.js')
| -rw-r--r-- | animism-align/frontend/views/align/align.actions.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/animism-align/frontend/views/align/align.actions.js b/animism-align/frontend/views/align/align.actions.js index b10f257..b819584 100644 --- a/animism-align/frontend/views/align/align.actions.js +++ b/animism-align/frontend/views/align/align.actions.js @@ -17,6 +17,14 @@ export const setZoom = zoom => dispatch => { } } +export const setSelectedAnnotation = annotation_id => dispatch => { + dispatch({ type: types.align.set_display_setting, key: 'selected_annotation_id', value: annotation_id }) +} + +export const clearSelectedAnnotation = annotation_id => dispatch => { + dispatch({ type: types.align.set_display_setting, key: 'selected_annotation_id', value: -1 }) +} + export const throttledSetZoom = throttle(zoom => dispatch => { setZoom(zoom)(dispatch) }, 250, { leading: true }) @@ -59,9 +67,22 @@ export const updateAnnotationSettings = (key, value) => dispatch => { dispatch({ type: types.align.update_temporary_annotation_settings, key, value }) } +const getFirstPunctuationMarkIndex = text => { + return Math.min( + text.indexOf('. '), + text.indexOf('? '), + text.indexOf('! '), + text.indexOf('." '), + text.indexOf('?" '), + text.indexOf('!" '), + text.indexOf('.” '), + text.indexOf('?” '), + text.indexOf('!” '), + ) + 1 +} const cutFirstSentence = text => { const textToCrop = text.trim().replace("\n", " ").split("\n")[0] - let cropIndex = textToCrop.indexOf('. ') + 1 + let cropIndex = getFirstPunctuationMarkIndex(textToCrop) if (!cropIndex) cropIndex = textToCrop.length const croppedText = textToCrop.substr(0, cropIndex).trim() const updatedText = text.trim().replace(croppedText, '').trim() |
