@playkit-js/transcript 3.2.1 → 3.2.2-canary.1-792a782

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.2.1",
3
+ "version": "3.2.2-canary.1-792a782",
4
4
  "main": "dist/playkit-transcript.js",
5
5
  "license": "AGPL-3.0",
6
6
  "private": false,
@@ -67,7 +67,7 @@
67
67
  "html5 player"
68
68
  ],
69
69
  "dependencies": {
70
- "@playkit-js/common": "^1.0.18",
70
+ "@playkit-js/common": "^1.1.0",
71
71
  "@playkit-js/playkit-js-ui": "^0.73.0",
72
72
  "@playkit-js/ui-managers": "^1.3.2",
73
73
  "cypress": "^12.3.0",
@@ -21,7 +21,6 @@ export const AutoscrollButton = withText(translates)(
21
21
  return (
22
22
  <A11yWrapper onClick={onClick}>
23
23
  <div
24
- role="button"
25
24
  className={`${styles.autoscrollButton} ${isAutoScrollEnabled ? '' : styles.autoscrollButtonVisible}`}
26
25
  tabIndex={isAutoScrollEnabled ? -1 : 1}
27
26
  aria-label={autoScrollLabel}
@@ -131,7 +131,6 @@ export class Caption extends Component<ExtendedCaptionProps, CaptionState> {
131
131
  const isHighlighted = Object.keys(highlighted)[0] === id;
132
132
 
133
133
  const captionA11yProps: Record<string, any> = {
134
- role: isHighlighted ? 'text' : 'listitem',
135
134
  ariaCurrent: isHighlighted,
136
135
  onFocus: this._handleFocus,
137
136
  onBlur: this._handleBlur,
@@ -140,7 +139,7 @@ export class Caption extends Component<ExtendedCaptionProps, CaptionState> {
140
139
  };
141
140
 
142
141
  return (
143
- <A11yWrapper onClick={this._handleKeyDown}>
142
+ <A11yWrapper onClick={this._handleKeyDown} role={isHighlighted ? 'text' : 'listitem'}>
144
143
  <div
145
144
  className={styles.caption}
146
145
  ref={node => {
@@ -9,17 +9,23 @@ const {Tooltip, Icon} = KalturaPlayer.ui.components;
9
9
  interface PluginButtonProps {
10
10
  isActive: boolean;
11
11
  onClick: OnClick;
12
+ setRef?: (ref: HTMLButtonElement | null) => void;
12
13
  id: string;
13
14
  icon: string;
14
15
  label?: string;
15
16
  dataTestId?: string;
16
17
  }
17
18
 
18
- export const PluginButton = ({isActive, onClick, label, id, icon, dataTestId}: PluginButtonProps) => {
19
+ export const PluginButton = ({isActive, onClick, label, id, icon, dataTestId, setRef}: PluginButtonProps) => {
19
20
  return (
20
21
  <Tooltip label={label} type="bottom">
21
22
  <A11yWrapper onClick={onClick}>
22
23
  <button
24
+ ref={node => {
25
+ if (setRef) {
26
+ setRef(node);
27
+ }
28
+ }}
23
29
  aria-label={label}
24
30
  className={[ui.style.upperBarIcon, styles.pluginButton, isActive ? styles.active : ''].join(' ')}
25
31
  data-testid={dataTestId}>
@@ -1,5 +1,5 @@
1
1
  import {h, Component} from 'preact';
2
- import {OnClickEvent} from '@playkit-js/common';
2
+ import {OnClickEvent, OnClick} from '@playkit-js/common';
3
3
  import {debounce} from '../../utils';
4
4
  import * as styles from './transcript.scss';
5
5
  import {Spinner} from '../spinner';
@@ -21,7 +21,7 @@ const translates = {
21
21
 
22
22
  export interface TranscriptProps {
23
23
  onSeek(time: number): void;
24
- onClose: () => void;
24
+ onClose: OnClick;
25
25
  onRetryLoad: () => void;
26
26
  isLoading: boolean;
27
27
  hasError: boolean;
@@ -342,7 +342,7 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
342
342
 
343
343
  private _handleEsc = (event: KeyboardEvent) => {
344
344
  if (event.keyCode === ESC) {
345
- this.props.onClose();
345
+ this.props.onClose(event, true);
346
346
  }
347
347
  };
348
348
 
@@ -46,6 +46,7 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
46
46
  private _printIcon = -1;
47
47
  private _downloadIcon = -1;
48
48
  private _pluginState: PluginStates | null = null;
49
+ private _pluginButtonRef: HTMLButtonElement | null = null;
49
50
 
50
51
  constructor(name: string, player: KalturaPlayerTypes.Player, config: TranscriptConfig) {
51
52
  super(name, player, config);
@@ -216,8 +217,14 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
216
217
  svgIcon: {path: icons.DOWNLOAD_ICON, viewBox: `0 0 ${icons.BigSize} ${icons.BigSize}`},
217
218
  onClick: this._handleDownload,
218
219
  component: withText(translate)((props: {label: string}) => (
219
- <PluginButton isActive={false} onClick={this._handleDownload} id={'download-transcript'} icon={icons.DOWNLOAD_ICON} label={props.label}
220
- dataTestId="transcript_downloadButton" />
220
+ <PluginButton
221
+ isActive={false}
222
+ onClick={this._handleDownload}
223
+ id={'download-transcript'}
224
+ icon={icons.DOWNLOAD_ICON}
225
+ label={props.label}
226
+ dataTestId="transcript_downloadButton"
227
+ />
221
228
  ))
222
229
  }) as number;
223
230
  }
@@ -235,8 +242,14 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
235
242
  svgIcon: {path: icons.PRINT_ICON, viewBox: `0 0 ${icons.BigSize} ${icons.BigSize}`},
236
243
  onClick: this._handlePrint,
237
244
  component: withText(translate)((props: {label: string}) => (
238
- <PluginButton isActive={false} onClick={this._handlePrint} id={'print-transcript'} icon={icons.PRINT_ICON} label={props.label}
239
- dataTestId="transcript_printButton" />
245
+ <PluginButton
246
+ isActive={false}
247
+ onClick={this._handlePrint}
248
+ id={'print-transcript'}
249
+ icon={icons.PRINT_ICON}
250
+ label={props.label}
251
+ dataTestId="transcript_printButton"
252
+ />
240
253
  ))
241
254
  }) as number;
242
255
  }
@@ -268,7 +281,7 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
268
281
  videoDuration={this.player.duration}
269
282
  kitchenSinkActive={this._isPluginActive()}
270
283
  toggledWithEnter={this._triggeredByKeyboard}
271
- onClose={this._deactivatePlugin}
284
+ onClose={this._handleClose}
272
285
  />
273
286
  );
274
287
  },
@@ -289,8 +302,15 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
289
302
  const isActive = this._isPluginActive();
290
303
  const label = isActive ? props.hideTranscript : props.showTranscript;
291
304
  return (
292
- <PluginButton isActive={isActive} onClick={this._handleClickOnPluginIcon} id="transcript-icon" label={label} icon={icons.PLUGIN_ICON}
293
- dataTestId="transcript_pluginButton" />
305
+ <PluginButton
306
+ isActive={isActive}
307
+ onClick={this._handleClickOnPluginIcon}
308
+ id="transcript-icon"
309
+ label={label}
310
+ icon={icons.PLUGIN_ICON}
311
+ dataTestId="transcript_pluginButton"
312
+ setRef={this._setPluginButtonRef}
313
+ />
294
314
  );
295
315
  })
296
316
  }) as number;
@@ -300,6 +320,10 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
300
320
  }
301
321
  }
302
322
 
323
+ private _setPluginButtonRef = (ref: HTMLButtonElement | null) => {
324
+ this._pluginButtonRef = ref;
325
+ };
326
+
303
327
  private _seekTo = (time: number) => {
304
328
  this.player.currentTime = time;
305
329
  };
@@ -324,6 +348,13 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
324
348
  }
325
349
  };
326
350
 
351
+ private _handleClose = (e: OnClickEvent, byKeyboard: boolean) => {
352
+ if (byKeyboard) {
353
+ this._pluginButtonRef?.focus();
354
+ }
355
+ this._deactivatePlugin();
356
+ };
357
+
327
358
  static isValid(): boolean {
328
359
  return true;
329
360
  }
@@ -335,6 +366,7 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
335
366
  this.upperBarManager!.remove(this._transcriptIcon);
336
367
  this._transcriptPanel = -1;
337
368
  this._transcriptIcon = -1;
369
+ this._pluginButtonRef = null;
338
370
  }
339
371
  if (this._printIcon > 0) {
340
372
  this.upperBarManager!.remove(this._printIcon);