-
-
Notifications
You must be signed in to change notification settings - Fork 18
BL-15300 Switch TBT highlighting to pseudoelement #7754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,7 @@ import { | |
| } from "../../../react_components/featureStatus"; | ||
| import { animateStyleName } from "../../../utils/shared"; | ||
| import jQuery from "jquery"; | ||
| import { AudioTextHighlightManager } from "./audioTextHighlightManager"; | ||
|
|
||
| enum Status { | ||
| Disabled, // Can't use button now (e.g., Play when there is no recording) | ||
|
|
@@ -207,6 +208,7 @@ export default class AudioRecording implements IAudioRecorder { | |
|
|
||
| private playbackOrderCache: IPlaybackOrderInfo[] = []; | ||
| private disablingOverlay: HTMLDivElement; | ||
| private audioTextHighlightManager = new AudioTextHighlightManager(); | ||
|
|
||
| constructor(maySetHighlight: boolean = true) { | ||
| this.audioSplitButton = <HTMLButtonElement>( | ||
|
|
@@ -898,6 +900,10 @@ export default class AudioRecording implements IAudioRecorder { | |
| if (pageDocBody) { | ||
| this.removeAudioCurrent(pageDocBody); | ||
| } | ||
|
|
||
| this.audioTextHighlightManager.clearManagedHighlights( | ||
| pageDocBody ?? undefined, | ||
| ); | ||
| } | ||
|
|
||
| private removeAudioCurrent(parentElement: Element) { | ||
|
|
@@ -997,6 +1003,7 @@ export default class AudioRecording implements IAudioRecorder { | |
|
|
||
| if (oldElement === newElement && !forceRedisplay) { | ||
| // No need to do much, and better not to so we can avoid any temporary flashes as the highlight is removed and re-applied | ||
| this.refreshAudioTextHighlights(newElement); | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -1069,6 +1076,23 @@ export default class AudioRecording implements IAudioRecorder { | |
| ); | ||
| } | ||
| } | ||
|
|
||
| this.refreshAudioTextHighlights(newElement); | ||
| } | ||
|
|
||
| private refreshAudioTextHighlights(currentHighlight?: Element | null) { | ||
| const activeHighlight = currentHighlight ?? this.getCurrentHighlight(); | ||
| const currentTextBox = activeHighlight | ||
| ? ((this.getTextBoxOfElement( | ||
| activeHighlight, | ||
| ) as HTMLElement | null) ?? null) | ||
| : null; | ||
| // The manager keeps both the yellow current highlight and the blue post-split | ||
| // highlights in sync so callers do not need separate refresh paths. | ||
| this.audioTextHighlightManager.refreshHighlights( | ||
| activeHighlight, | ||
| currentTextBox, | ||
| ); | ||
| } | ||
|
|
||
| // Scrolls an element into view. | ||
|
|
@@ -4375,6 +4399,7 @@ export default class AudioRecording implements IAudioRecorder { | |
| const currentTextBox = this.getCurrentTextBox(); | ||
| if (currentTextBox) { | ||
| currentTextBox.classList.add("bloom-postAudioSplit"); | ||
| this.refreshAudioTextHighlights(currentTextBox); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -4384,6 +4409,10 @@ export default class AudioRecording implements IAudioRecorder { | |
| currentTextBox.classList.remove("bloom-postAudioSplit"); | ||
| currentTextBox.removeAttribute("data-audioRecordingEndTimes"); | ||
| } | ||
|
|
||
| this.audioTextHighlightManager.clearManagedHighlights( | ||
| currentTextBox ?? undefined, | ||
| ); | ||
|
Comment on lines
+4413
to
+4415
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚩 clearAudioSplit silently skips highlight cleanup when currentTextBox is null At Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| } | ||
|
|
||
| private getElementsToUpdateForCursor(): (Element | null)[] { | ||
|
|
@@ -4823,6 +4852,7 @@ export default class AudioRecording implements IAudioRecorder { | |
| } | ||
| }); | ||
| this.nodesToRestoreAfterPlayEnded.clear(); | ||
| this.refreshAudioTextHighlights(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Test uses wrong CSS variable name
--bloom-audio-highlight-colorinstead of--bloom-audio-highlight-text-colorThe test at line 348 asserts that
sentenceRule?.cssTextcontains"--bloom-audio-highlight-color: rgb(1, 2, 3)", but the production code inStyleEditor.ts:688sets the property as"--bloom-audio-highlight-text-color". The substring--bloom-audio-highlight-colordoes not appear in--bloom-audio-highlight-text-color(which has an extratext-segment), so thetoContainassertion will fail.Was this helpful? React with 👍 or 👎 to provide feedback.