diff --git a/api/app/outbound/spacy/spacy_client.py b/api/app/outbound/spacy/spacy_client.py index 3283b65..b500008 100644 --- a/api/app/outbound/spacy/spacy_client.py +++ b/api/app/outbound/spacy/spacy_client.py @@ -32,6 +32,11 @@ class SpacyClient: """Use SpaCy to get parts of speech for the given text and language, broken down by sentences and then by tokens.""" nlp = self._get_nlp(language) + + # Recognise line-breaks as always being sentence boundaries, even if the model doesn't. + # This is important for the frontend to be able to show line-breaks in the source text. + nlp.add_pipe("sentencizer", before="parser") + doc = nlp(text) sentences = [ diff --git a/frontend/src/routes/app/articles/[article_id]/+page.svelte b/frontend/src/routes/app/articles/[article_id]/+page.svelte index d78a404..74754cd 100644 --- a/frontend/src/routes/app/articles/[article_id]/+page.svelte +++ b/frontend/src/routes/app/articles/[article_id]/+page.svelte @@ -1,11 +1,10 @@ -
+ +
{#each paragraphs as para (para.index)}

{#each para.sentences as sentence (sentence.idx)} @@ -22,8 +162,13 @@ {#if !token.is_punct} @@ -43,6 +188,9 @@ flex-direction: column; gap: var(--space-4); font-family: var(--font-body); + /* Allow vertical scroll gestures to pass through; horizontal drags are + intercepted by our pointer handlers for word selection. */ + touch-action: pan-y; } .paragraph { @@ -76,6 +224,9 @@ transition: background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard); + /* Prevent text selection highlight during drag */ + user-select: none; + -webkit-user-select: none; } .word:hover { diff --git a/frontend/src/routes/app/articles/[article_id]/TranslationPanel.svelte b/frontend/src/routes/app/articles/[article_id]/TranslationPanel.svelte index 50f6fb5..331838d 100644 --- a/frontend/src/routes/app/articles/[article_id]/TranslationPanel.svelte +++ b/frontend/src/routes/app/articles/[article_id]/TranslationPanel.svelte @@ -1,58 +1,101 @@ -