@playkit-js/transcript 3.5.29 → 3.5.30-canary.0-bdae263

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playkit-js/transcript",
3
- "version": "3.5.29",
3
+ "version": "3.5.30-canary.0-bdae263",
4
4
  "main": "dist/playkit-transcript.js",
5
5
  "license": "AGPL-3.0",
6
6
  "private": false,
@@ -20,6 +20,7 @@ export interface CaptionProps {
20
20
  player?: any;
21
21
  captionLabel?: string;
22
22
  moveToSearch?: string;
23
+ navigationInstruction?: string
23
24
  setTextToRead: (textToRead: string, delay?: number) => void;
24
25
  }
25
26
 
@@ -37,7 +38,8 @@ interface ExtendedCaptionProps extends CaptionProps {
37
38
 
38
39
  const translates = {
39
40
  captionLabel: <Text id="transcript.caption_label">Jump to this point in video</Text>,
40
- moveToSearch: <Text id="transcript.move_to_search">Click to jump to search result</Text>
41
+ moveToSearch: <Text id="transcript.move_to_search">Click to jump to search result</Text>,
42
+ navigationInstruction: <Text id="transcript.navigation_instruction">Press Home to navigate to the beginning of the transcript. Press End to jump to the end of the transcript.</Text>
41
43
  };
42
44
 
43
45
  @withText(translates)
@@ -143,7 +145,7 @@ export class Caption extends Component<ExtendedCaptionProps> {
143
145
  };
144
146
 
145
147
  render() {
146
- const {caption, highlighted, showTime, longerThanHour, indexMap, captionLabel, moveToSearch} = this.props;
148
+ const {caption, highlighted, showTime, longerThanHour, indexMap, captionLabel, moveToSearch, navigationInstruction} = this.props;
147
149
  const {startTime, id} = caption;
148
150
  const isHighlighted = Object.keys(highlighted).some(c => c === id);
149
151
  const time = showTime ? secondsToTime(startTime, longerThanHour) : '';
@@ -151,7 +153,7 @@ export class Caption extends Component<ExtendedCaptionProps> {
151
153
  const captionA11yProps: Record<string, any> = {
152
154
  ariaCurrent: isHighlighted,
153
155
  tabIndex: 0,
154
- ariaLabel: `${time}${showTime ? ' ' : ''}${caption.text} ${indexMap ? moveToSearch : captionLabel}`,
156
+ ariaLabel: `${time}${showTime ? ' ' : ''}${caption.text} ${indexMap ? moveToSearch : captionLabel}. ${navigationInstruction}`,
155
157
  role: 'button'
156
158
  };
157
159
 
@@ -98,9 +98,9 @@ export class CaptionList extends Component<Props> {
98
98
 
99
99
  private _handleKeyUp = (event: KeyboardEvent) => {
100
100
  if (event.keyCode === END) {
101
- this._lastCaptionRef?._hotspotRef?.focus();
101
+ this._lastCaptionRef?.base.focus();
102
102
  } else if (event.keyCode === HOME) {
103
- this._firstCaptionRef?._hotspotRef?.focus();
103
+ this._firstCaptionRef?.base.focus();
104
104
  }
105
105
  };
106
106
 
@@ -24,6 +24,7 @@ export const PluginButton = ({isActive, label, id, icon, dataTestId, setRef}: Pl
24
24
  setRef(node);
25
25
  }
26
26
  }}
27
+ tabIndex={0}
27
28
  type="button"
28
29
  aria-label={label}
29
30
  className={[ui.style.upperBarIcon, styles.pluginButton, isActive ? styles.active : ''].join(' ')}
@@ -1,7 +1,12 @@
1
1
  import {h, Component} from 'preact';
2
2
  import {InputField} from '@playkit-js/common/dist/components/input-field';
3
+ import {core} from '@playkit-js/kaltura-player-js';
3
4
 
5
+ const {Utils} = core;
6
+ const {withEventManager} = KalturaPlayer.ui.Event;
7
+ const {TAB} = KalturaPlayer.ui.utils.KeyMap;
4
8
  const {withText, Text} = KalturaPlayer.ui.preacti18n;
9
+
5
10
  const translates = ({activeSearchIndex, totalSearchResults}: SearchProps) => ({
6
11
  searchLabel: <Text id="transcript.search">Search in Transcript</Text>,
7
12
  clearSearchLabel: <Text id="transcript.clear_search">Clear search</Text>,
@@ -34,11 +39,26 @@ export interface SearchProps {
34
39
  nextMatchLabel?: string;
35
40
  prevMatchLabel?: string;
36
41
  searchResultsLabel?: string;
42
+ eventManager?: any
43
+ focusPluginButton: () => void;
37
44
  }
38
45
 
46
+ @withEventManager
39
47
  class SearchComponent extends Component<SearchProps> {
40
48
  private _inputField: InputField | null = null;
41
49
 
50
+ constructor(props: SearchProps) {
51
+ super(props);
52
+ this.props.eventManager?.listen(document, 'keydown', this.handleKeydownEvent);
53
+ }
54
+
55
+ private handleKeydownEvent = (event: KeyboardEvent) => {
56
+ if (event.keyCode === TAB && event.shiftKey && this._inputField?.base?.contains(document.activeElement)){
57
+ event.preventDefault();
58
+ this.props.focusPluginButton();
59
+ }
60
+ };
61
+
42
62
  shouldComponentUpdate(nextProps: Readonly<SearchProps>) {
43
63
  const {value, activeSearchIndex, totalSearchResults, kitchenSinkActive} = this.props;
44
64
  if (
@@ -70,6 +70,7 @@ export interface TranscriptProps {
70
70
  isMobile?: boolean;
71
71
  playerWidth?: number;
72
72
  onJumpToSearchMatch: () => void;
73
+ focusPluginButton: () => void;
73
74
  }
74
75
 
75
76
  interface TranscriptState {
@@ -325,6 +326,7 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
325
326
  totalSearchResults={totalSearchResults}
326
327
  toggledWithEnter={toggledWithEnter}
327
328
  kitchenSinkActive={kitchenSinkActive}
329
+ focusPluginButton={this.props.focusPluginButton}
328
330
  />
329
331
  {this._renderJumpToSearchButton()}
330
332
  <TranscriptMenu {...{downloadDisabled, onDownload, printDisabled, onPrint, isLoading, detachMenuItem, kitchenSinkDetached}} />
@@ -335,6 +335,8 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
335
335
  this._handleAttach(CloseDetachTypes.arrow);
336
336
  }}
337
337
  onJumpToSearchMatch={this._toSearchMatch}
338
+ //@ts-ignore
339
+ focusPluginButton={() => this.upperBarManager!.focusPluginButton(this._transcriptIcon)}
338
340
  />
339
341
  ) as any;
340
342
  },
@@ -25,7 +25,8 @@
25
25
  "caption_label": "Jump to this point in video",
26
26
  "move_to_search": "Click to jump to search result",
27
27
  "to_search_result": "Go to result",
28
- "to_search_result_label": "Click to jump to this point in the video"
28
+ "to_search_result_label": "Click to jump to this point in the video",
29
+ "navigation_instruction": "Press Home to navigate to the beginning of the transcript. Press End to jump to the end of the transcript."
29
30
  }
30
31
  }
31
32
  }