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
feat(transcript): set the pinned transcript apart from the note's content
Elian Dorane1ed642c84cb
diff --git a/apps/client/src/widgets/layout/PinnedAttachments.css b/apps/client/src/widgets/layout/PinnedAttachments.cssindex 760ec8d541..e442d83c38 100644--- a/apps/client/src/widgets/layout/PinnedAttachments.css+++ b/apps/client/src/widgets/layout/PinnedAttachments.css@@ -1,4 +1,13 @@-.pinned-attachment {+.collapsible.pinned-attachment {+ margin-bottom: 1rem;++ .collapsible-inner-body {+ margin-top: 0.5em;+ padding: 0.25rem 1rem;+ border-radius: var(--card-border-radius, 8px);+ background: var(--card-background-color, var(--accented-background-color));+ }+.transcript {height: auto;max-height: 40vh;diff --git a/apps/client/src/widgets/type_widgets/transcript/TranscriptView.css b/apps/client/src/widgets/type_widgets/transcript/TranscriptView.cssindex 4418f4f7f8..023eb700c4 100644--- a/apps/client/src/widgets/type_widgets/transcript/TranscriptView.css+++ b/apps/client/src/widgets/type_widgets/transcript/TranscriptView.css@@ -5,6 +5,10 @@padding: 0.5rem 1rem 1rem;user-select: text;+ &.more-below {+ mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);+ }+.transcript-options {display: flex;justify-content: flex-end;diff --git a/apps/client/src/widgets/type_widgets/transcript/TranscriptView.spec.tsx b/apps/client/src/widgets/type_widgets/transcript/TranscriptView.spec.tsxindex ae5ed2d74c..74be47084c 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, not for one who scrolled up", async () => {+ it("follows new turns for a reader at the end, and marks when more is 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.@@ -576,13 +576,24 @@ describe("TranscriptView", () => {expect(scroller.querySelectorAll(".transcript-turn")).toHaveLength(count));};+ const scrollTo = (top: number) => act(() => {+ scroller.scrollTop = top;+ scroller.dispatchEvent(new Event("scroll"));+ });+await addTurn();await addTurn();expect(scroller.scrollTop).toBe(150);+ expect(scroller.classList.contains("more-below")).toBe(false);- scroller.scrollTop = 0;+ scrollTo(0);+ expect(scroller.classList.contains("more-below")).toBe(true);await addTurn();expect(scroller.scrollTop).toBe(0);+ expect(scroller.classList.contains("more-below")).toBe(true);++ scrollTo(100);+ expect(scroller.classList.contains("more-below")).toBe(false);});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 5712a3fb02..b26825c70b 100644--- a/apps/client/src/widgets/type_widgets/transcript/TranscriptView.tsx+++ b/apps/client/src/widgets/type_widgets/transcript/TranscriptView.tsx@@ -31,8 +31,8 @@ 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, and keeps a reader who is at the end there as new- * turns arrive. With `transcriptCleanupEnabled`, shows each utterance through+ * 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* `cleanUtteranceText()` and leaves out the ones it empties; the stored transcript stays verbatim.*/export default function TranscriptView({ attachment }: { attachment: FAttachment }) {@@ -41,6 +41,7 @@ export default function TranscriptView({ attachment }: { attachment: FAttachmentconst recording = useTranscriptionState();const pending = recording.noteId === attachment.ownerId ? recording.pendingSources : [];const scrollerRef = useRef<HTMLDivElement>(null);+ const [ hasMoreBelow, setHasMoreBelow ] = useState(false);/** 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. */@@ -71,6 +72,7 @@ export default function TranscriptView({ attachment }: { attachment: FAttachmentscroller.scrollTop = scroller.scrollHeight;}scrollHeightRef.current = scroller.scrollHeight;+ setHasMoreBelow(!wasAtEnd(scroller, scroller.scrollHeight));});useTriliumEvent("entitiesReloaded", ({ loadResults }) => {const { attachmentId } = attachment;@@ -110,7 +112,12 @@ export default function TranscriptView({ attachment }: { attachment: FAttachment</p>);return (- <div ref={scrollerRef} className="transcript">+ <div+ ref={scrollerRef}+ className={clsx("transcript", { "more-below": hasMoreBelow })}+ onScroll={(e) => setHasMoreBelow(+ !wasAtEnd(e.currentTarget, e.currentTarget.scrollHeight))}+ >{transcript.utterances.length > 0 && (<div className="transcript-options"><FormToggle