@playkit-js/transcript 3.5.24 → 3.5.25-canary.0-46c6dcd

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.24",
3
+ "version": "3.5.25-canary.0-46c6dcd",
4
4
  "main": "dist/playkit-transcript.js",
5
5
  "license": "AGPL-3.0",
6
6
  "private": false,
@@ -3,8 +3,12 @@ import {HOUR} from '../../utils';
3
3
  import {Caption} from '../caption';
4
4
  import * as styles from './captionList.scss';
5
5
  import {HighlightedMap, CuePointData} from '../../types';
6
+ import {TranscriptEvents} from "../../events/events";
7
+ import {ui} from "@playkit-js/kaltura-player-js";
6
8
 
7
9
  const {END, HOME} = KalturaPlayer.ui.utils.KeyMap;
10
+ const {withEventManager} = KalturaPlayer.ui.Event;
11
+ const {withPlayer} = ui.Components;
8
12
 
9
13
  export interface CaptionProps {
10
14
  showTime: boolean;
@@ -28,20 +32,35 @@ export interface Props {
28
32
  activeSearchIndex: number;
29
33
  searchMap: Record<string, Record<string, number>>;
30
34
  captionProps: CaptionProps;
35
+ eventManager?: any;
36
+ player?: any;
31
37
  }
38
+
39
+
40
+ @withEventManager
41
+ @withPlayer
32
42
  export class CaptionList extends Component<Props> {
33
43
  private _currentCaptionRef: any = null;
34
44
  private _firstCaptionRef: any = null;
35
45
  private _lastCaptionRef: any = null;
46
+ private _isTranscriptNavigateTriggered: boolean = false;
47
+
48
+ constructor(props: Props | undefined) {
49
+ super(props);
50
+ this._setFocus();
51
+ }
52
+
36
53
  shouldComponentUpdate(nextProps: Readonly<Props>) {
37
- const {highlightedMap, data, searchMap, activeSearchIndex, isAutoScrollEnabled, captionProps} = this.props;
54
+ const {highlightedMap, data, searchMap, activeSearchIndex, isAutoScrollEnabled} = this.props;
55
+ if (searchMap !== nextProps.searchMap){
56
+ this._isTranscriptNavigateTriggered = false;
57
+ }
38
58
  if (
39
59
  highlightedMap !== nextProps.highlightedMap ||
40
60
  data !== nextProps.data ||
41
61
  searchMap !== nextProps.searchMap ||
42
62
  activeSearchIndex !== nextProps.activeSearchIndex ||
43
- isAutoScrollEnabled !== nextProps.isAutoScrollEnabled ||
44
- captionProps.videoDuration !== nextProps.captionProps.videoDuration
63
+ isAutoScrollEnabled !== nextProps.isAutoScrollEnabled
45
64
  ) {
46
65
  return true;
47
66
  }
@@ -103,6 +122,12 @@ export class CaptionList extends Component<Props> {
103
122
  }
104
123
  };
105
124
 
125
+ private _setFocus = () =>{
126
+ this.props.eventManager?.listen(this.props.player, TranscriptEvents.TRANSCRIPT_NAVIGATE_RESULT, () => {
127
+ this._isTranscriptNavigateTriggered = true
128
+ });
129
+ }
130
+
106
131
  render() {
107
132
  const {data} = this.props;
108
133
  let isSearchCaption = false;
@@ -126,6 +151,9 @@ export class CaptionList extends Component<Props> {
126
151
  }
127
152
  });
128
153
  }
154
+ if (this._isTranscriptNavigateTriggered && isSearchCaption){
155
+ this._currentCaptionRef?.base?.focus();
156
+ }
129
157
  if (!isSearchCaption && captionProps.highlighted[captionData.id]) {
130
158
  this._currentCaptionRef = node;
131
159
  }
@@ -45,7 +45,7 @@
45
45
  font-style: normal;
46
46
  }
47
47
 
48
- *:focus-visible:not(input) {
48
+ *:focus:not(input) {
49
49
  outline: 1px solid $tab-focus-color;
50
50
  }
51
51
  }
@@ -27,6 +27,8 @@ interface TimedMetadataEvent {
27
27
  }
28
28
 
29
29
  export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
30
+ public displayName = 'Transcript';
31
+ public svgIcon = {path: icons.PLUGIN_ICON, viewBox: '0 0 32 32'};
30
32
  static defaultConfig: TranscriptConfig = {
31
33
  expandMode: SidePanelModes.ALONGSIDE,
32
34
  expandOnFirstPlay: true,
@@ -48,6 +50,7 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
48
50
 
49
51
  private _transcriptPanel = -1;
50
52
  private _transcriptIcon = -1;
53
+ private _audioPlayerIconId = -1;
51
54
  private _pluginState: PluginStates | null = null;
52
55
  private _pluginButtonRef: HTMLButtonElement | null = null;
53
56
 
@@ -111,6 +114,10 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
111
114
  this._updateTranscriptPanel();
112
115
  };
113
116
 
117
+ public open(): void {
118
+ this._handleDetach();
119
+ }
120
+
114
121
  private _handleLanguageChange = () => {
115
122
  this._activeCaptionMapId = this._getCaptionMapId();
116
123
  this._initLoading();
@@ -271,11 +278,10 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
271
278
  };
272
279
 
273
280
  private _addTranscriptItem(): void {
274
- if (Math.max(this._transcriptPanel, this._transcriptIcon) > 0) {
281
+ if (Math.max(this._transcriptPanel, this._transcriptIcon, this._audioPlayerIconId) > 0) {
275
282
  // transcript panel or icon already exist
276
283
  return;
277
284
  }
278
-
279
285
  const {
280
286
  expandMode,
281
287
  position,
@@ -331,29 +337,36 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
331
337
  showTranscript: <Text id="transcript.show_plugin">Show Transcript</Text>,
332
338
  hideTranscript: <Text id="transcript.hide_plugin">Hide Transcript</Text>
333
339
  };
334
- this._transcriptIcon = this.upperBarManager!.add({
335
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
340
+ // @ts-ignore
341
+ if (ui.redux.useStore().getState().shell['activePresetName'] !== ReservedPresetNames.MiniAudioUI) {
342
+ this._transcriptIcon = this.upperBarManager!.add({
343
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
344
+ // @ts-ignore
345
+ displayName: 'Transcript',
346
+ ariaLabel: 'Transcript',
347
+ order: 30,
348
+ svgIcon: {path: icons.PLUGIN_ICON, viewBox: `0 0 ${icons.BigSize} ${icons.BigSize}`},
349
+ onClick: this._handleClickOnPluginIcon as () => void,
350
+ component: withText(translates)((props: {showTranscript: string; hideTranscript: string}) => {
351
+ const isActive = this._isPluginActive();
352
+ const label = isActive ? props.hideTranscript : props.showTranscript;
353
+ return (
354
+ <PluginButton
355
+ isActive={isActive}
356
+ id={pluginName}
357
+ label={label}
358
+ icon={icons.PLUGIN_ICON}
359
+ dataTestId="transcript_pluginButton"
360
+ setRef={this._setPluginButtonRef}
361
+ />
362
+ );
363
+ })
364
+ }) as number;
365
+ } else {
366
+ const {displayName, svgIcon} = this;
336
367
  // @ts-ignore
337
- displayName: 'Transcript',
338
- ariaLabel: 'Transcript',
339
- order: 30,
340
- svgIcon: {path: icons.PLUGIN_ICON, viewBox: `0 0 ${icons.BigSize} ${icons.BigSize}`},
341
- onClick: this._handleClickOnPluginIcon as () => void,
342
- component: withText(translates)((props: {showTranscript: string; hideTranscript: string}) => {
343
- const isActive = this._isPluginActive();
344
- const label = isActive ? props.hideTranscript : props.showTranscript;
345
- return (
346
- <PluginButton
347
- isActive={isActive}
348
- id={pluginName}
349
- label={label}
350
- icon={icons.PLUGIN_ICON}
351
- dataTestId="transcript_pluginButton"
352
- setRef={this._setPluginButtonRef}
353
- />
354
- );
355
- })
356
- }) as number;
368
+ this._audioPlayerIconId = this.player.getService('AudioPluginsManager').add({displayName, svgIcon, onClick: (e) => this.open(e)});
369
+ }
357
370
 
358
371
  if ((expandOnFirstPlay && !this._pluginState) || this._pluginState === PluginStates.OPENED) {
359
372
  this._activatePlugin(true);
@@ -397,10 +410,6 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
397
410
  this._pluginState = PluginStates.CLOSED;
398
411
  };
399
412
 
400
- public isPluginAvailable = () => {
401
- return this._captionMap.size > 0;
402
- };
403
-
404
413
  static isValid(): boolean {
405
414
  return true;
406
415
  }
@@ -410,8 +419,11 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
410
419
  if (Math.max(this._transcriptPanel, this._transcriptIcon) > 0) {
411
420
  this.sidePanelsManager?.remove(this._transcriptPanel);
412
421
  this.upperBarManager!.remove(this._transcriptIcon);
422
+ // @ts-ignore
423
+ this.player.getService('AudioPluginsManager').remove(this._audioPlayerIconId);
413
424
  this._transcriptPanel = -1;
414
425
  this._transcriptIcon = -1;
426
+ this._audioPlayerIconId = -1;
415
427
  this._pluginButtonRef = null;
416
428
  }
417
429
  this._captionMap = new Map();