summaryrefslogtreecommitdiff
path: root/animism-align/frontend/views/align/align.actions.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-07-05 17:02:39 +0200
committerJules Laplace <julescarbon@gmail.com>2020-07-05 17:02:39 +0200
commit3e5bc2f5581890f2d7d9f679ab5171c0637ff460 (patch)
treefc88ac2387974ba0bd8377957732fdf697cef961 /animism-align/frontend/views/align/align.actions.js
parentbc1515b965e02641cab2a984410a3cb5cfae891c (diff)
notion of selected annotation
Diffstat (limited to 'animism-align/frontend/views/align/align.actions.js')
-rw-r--r--animism-align/frontend/views/align/align.actions.js23
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()