summaryrefslogtreecommitdiff
path: root/animism-align/frontend/views/align/align.actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'animism-align/frontend/views/align/align.actions.js')
-rw-r--r--animism-align/frontend/views/align/align.actions.js44
1 files changed, 14 insertions, 30 deletions
diff --git a/animism-align/frontend/views/align/align.actions.js b/animism-align/frontend/views/align/align.actions.js
index b819584..351b826 100644
--- a/animism-align/frontend/views/align/align.actions.js
+++ b/animism-align/frontend/views/align/align.actions.js
@@ -6,6 +6,7 @@ import { session } from '../../session'
import throttle from 'lodash.throttle'
import { ZOOM_STEPS } from './constants'
+import { getFirstPunctuationMarkIndex, cutFirstSentence } from './align.util'
export const setScrollPosition = start_ts => dispatch => (
dispatch({ type: types.align.set_display_setting, key: 'start_ts', value: start_ts })
@@ -16,22 +17,27 @@ export const setZoom = zoom => dispatch => {
dispatch({ type: types.align.set_display_setting, key: 'zoom', value: zoom })
}
}
+export const throttledSetZoom = throttle(zoom => dispatch => {
+ setZoom(zoom)(dispatch)
+}, 250, { leading: true })
+
+export const setCursor = cursor_ts => dispatch => (
+ dispatch({ type: types.align.set_display_setting, key: 'cursor_ts', value: cursor_ts })
+)
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 })
-
-export const setCursor = cursor_ts => dispatch => (
- dispatch({ type: types.align.set_display_setting, key: 'cursor_ts', value: cursor_ts })
-)
+export const setSelectedParagraph = paragraph_id => dispatch => {
+ dispatch({ type: types.align.set_display_setting, key: 'selected_paragraph_id', value: paragraph_id })
+}
+export const clearSelectedParagraph = paragraph_id => dispatch => {
+ dispatch({ type: types.align.set_display_setting, key: 'selected_paragraph_id', value: -1 })
+}
export const showNewAnnotationForm = (start_ts, text) => dispatch => {
let croppedText;
@@ -67,28 +73,6 @@ 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 = getFirstPunctuationMarkIndex(textToCrop)
- if (!cropIndex) cropIndex = textToCrop.length
- const croppedText = textToCrop.substr(0, cropIndex).trim()
- const updatedText = text.trim().replace(croppedText, '').trim()
- actions.site.updateText(updatedText)
- return croppedText
-}
export const hideAnnotationForm = () => dispatch => {
dispatch({