Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(transcript): fade the top edge, and stop clipping text inside the card
Elian Doran5bd40a7701e4
diff --git a/apps/client/src/widgets/layout/PinnedAttachments.css b/apps/client/src/widgets/layout/PinnedAttachments.cssindex e442d83c38..51401304ac 100644--- a/apps/client/src/widgets/layout/PinnedAttachments.css+++ b/apps/client/src/widgets/layout/PinnedAttachments.css@@ -3,7 +3,8 @@.collapsible-inner-body {margin-top: 0.5em;- padding: 0.25rem 1rem;+ padding: 0;+ overflow: hidden;border-radius: var(--card-border-radius, 8px);background: var(--card-background-color, var(--accented-background-color));}@@ -11,6 +12,5 @@.transcript {height: auto;max-height: 40vh;- padding-inline: 0;}}diff --git a/apps/client/src/widgets/type_widgets/transcript/TranscriptView.css b/apps/client/src/widgets/type_widgets/transcript/TranscriptView.cssindex 023eb700c4..7c6720238e 100644--- a/apps/client/src/widgets/type_widgets/transcript/TranscriptView.css+++ b/apps/client/src/widgets/type_widgets/transcript/TranscriptView.css@@ -5,8 +5,26 @@padding: 0.5rem 1rem 1rem;user-select: text;+ --transcript-fade-top: 0px;+ --transcript-fade-bottom: 0px;++ &.more-above {+ --transcript-fade-top: 2.5rem;+ }++ &.more-below {+ --transcript-fade-bottom: 2.5rem;+ }++ &.more-above,&.more-below {- mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);+ mask-image: linear-gradient(+ to bottom,+ transparent,+ #000 var(--transcript-fade-top),+ #000 calc(100% - var(--transcript-fade-bottom)),+ transparent+ );}.transcript-options {diff --git a/apps/client/src/widgets/type_widgets/transcript/TranscriptView.spec.tsx b/apps/client/src/widgets/type_widgets/transcript/TranscriptView.spec.tsxindex 74be47084c..47b4fce68f 100644--- a/apps/client/src/widgets/type_widgets/transcript/TranscriptView.spec.tsx+++ b/apps/client/src/widgets/type_widgets/transcript/TranscriptView.spec.tsx@@ -536,7 +536,7 @@ describe("TranscriptView", () => {window.electronApi = undefined;});- it("follows new turns for a reader at the end, and marks when more is below", async () => {+ it("follows new turns for a reader at the end, and marks when more is above or below", async () => {const utterance = (index: number): TranscriptUtterance =>({ source: "microphone", offsetMs: index * 60_000, text: `Line ${index}` });// Each reload adds a turn, alternating sources so that none merge.@@ -583,17 +583,21 @@ describe("TranscriptView", () => {await addTurn();await addTurn();+ const edges = () => [ "more-above", "more-below" ]+ .filter((name) => scroller.classList.contains(name));expect(scroller.scrollTop).toBe(150);- expect(scroller.classList.contains("more-below")).toBe(false);+ expect(edges()).toEqual([ "more-above" ]);scrollTo(0);- expect(scroller.classList.contains("more-below")).toBe(true);+ expect(edges()).toEqual([ "more-below" ]);await addTurn();expect(scroller.scrollTop).toBe(0);- expect(scroller.classList.contains("more-below")).toBe(true);+ expect(edges()).toEqual([ "more-below" ]);+ scrollTo(50);+ expect(edges()).toEqual([ "more-above", "more-below" ]);scrollTo(100);- expect(scroller.classList.contains("more-below")).toBe(false);+ expect(edges()).toEqual([ "more-above" ]);});it("hides filler words and stutters while the option is on, and saves the switch", async () => {diff --git a/apps/client/src/widgets/type_widgets/transcript/TranscriptView.tsx b/apps/client/src/widgets/type_widgets/transcript/TranscriptView.tsxindex b26825c70b..d5bbfbd141 100644--- a/apps/client/src/widgets/type_widgets/transcript/TranscriptView.tsx+++ b/apps/client/src/widgets/type_widgets/transcript/TranscriptView.tsx@@ -32,7 +32,7 @@ const PARAGRAPH_PAUSE_MS = 2000;* Shows a `transcript` attachment as the conversation it records, one paragraph per speaker turn.* Follows the attachment as a running recording rewrites it, shows which speakers the recording* hears before their words are transcribed, keeps a reader who is at the end there as new- * turns arrive, and fades its bottom edge while more turns are below. With `transcriptCleanupEnabled`, shows each utterance through+ * turns arrive, and fades its top and bottom edges while more turns are above or below. With `transcriptCleanupEnabled`, shows each utterance through* `cleanUtteranceText()` and leaves out the ones it empties; the stored transcript stays verbatim.*/export default function TranscriptView({ attachment }: { attachment: FAttachment }) {@@ -41,7 +41,12 @@ export default function TranscriptView({ attachment }: { attachment: FAttachmentconst recording = useTranscriptionState();const pending = recording.noteId === attachment.ownerId ? recording.pendingSources : [];const scrollerRef = useRef<HTMLDivElement>(null);+ const [ hasMoreAbove, setHasMoreAbove ] = useState(false);const [ hasMoreBelow, setHasMoreBelow ] = useState(false);+ const updateEdges = (scroller: HTMLElement) => {+ setHasMoreAbove(scroller.scrollTop > 0);+ setHasMoreBelow(!wasAtEnd(scroller, scroller.scrollHeight));+ };/** The scroll height at the previous render, or `null` before the transcript first shows. */const scrollHeightRef = useRef<number | null>(null);/** How many utterances the first transcript read held; only later ones fade in. */@@ -72,7 +77,7 @@ export default function TranscriptView({ attachment }: { attachment: FAttachmentscroller.scrollTop = scroller.scrollHeight;}scrollHeightRef.current = scroller.scrollHeight;- setHasMoreBelow(!wasAtEnd(scroller, scroller.scrollHeight));+ updateEdges(scroller);});useTriliumEvent("entitiesReloaded", ({ loadResults }) => {const { attachmentId } = attachment;@@ -114,9 +119,11 @@ export default function TranscriptView({ attachment }: { attachment: FAttachmentreturn (<divref={scrollerRef}- className={clsx("transcript", { "more-below": hasMoreBelow })}- onScroll={(e) => setHasMoreBelow(- !wasAtEnd(e.currentTarget, e.currentTarget.scrollHeight))}+ className={clsx("transcript", {+ "more-above": hasMoreAbove,+ "more-below": hasMoreBelow+ })}+ onScroll={(e) => updateEdges(e.currentTarget)}>{transcript.utterances.length > 0 && (<div className="transcript-options">