@playkit-js/transcript 3.6.3 → 3.6.4-canary.0-ab5dad4
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,13 +1,17 @@
|
|
|
1
1
|
import {h, Component} from 'preact';
|
|
2
2
|
import {InputField} from '@playkit-js/common/dist/components/input-field';
|
|
3
|
-
import {
|
|
3
|
+
import {ui} from '@playkit-js/kaltura-player-js';
|
|
4
4
|
|
|
5
|
-
const {
|
|
5
|
+
const {connect} = ui.redux;
|
|
6
6
|
const {withEventManager} = KalturaPlayer.ui.Event;
|
|
7
7
|
const {TAB} = KalturaPlayer.ui.utils.KeyMap;
|
|
8
8
|
const {withText, Text} = KalturaPlayer.ui.preacti18n;
|
|
9
9
|
const {withPlayer} = ui.Components;
|
|
10
10
|
|
|
11
|
+
const mapStateToProps = (state: any) => ({
|
|
12
|
+
isOverlayOpen: state.shell.playerClasses?.includes('playkit-overlay-active')
|
|
13
|
+
});
|
|
14
|
+
|
|
11
15
|
const translates = ({activeSearchIndex, totalSearchResults}: SearchProps) => ({
|
|
12
16
|
searchLabel: <Text id="transcript.search">Search in Transcript</Text>,
|
|
13
17
|
clearSearchLabel: <Text id="transcript.clear_search">Clear search</Text>,
|
|
@@ -40,30 +44,32 @@ export interface SearchProps {
|
|
|
40
44
|
nextMatchLabel?: string;
|
|
41
45
|
prevMatchLabel?: string;
|
|
42
46
|
searchResultsLabel?: string;
|
|
43
|
-
eventManager?: any
|
|
47
|
+
eventManager?: any;
|
|
44
48
|
focusPluginButton: (event: KeyboardEvent) => void;
|
|
45
49
|
player?: any;
|
|
50
|
+
|
|
51
|
+
isOverlayOpen?: boolean;
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
@withPlayer
|
|
49
55
|
@withEventManager
|
|
56
|
+
@connect(mapStateToProps)
|
|
50
57
|
class SearchComponent extends Component<SearchProps> {
|
|
51
58
|
private _inputField: InputField | null = null;
|
|
52
59
|
|
|
53
60
|
constructor(props: SearchProps) {
|
|
54
61
|
super(props);
|
|
55
|
-
if (this.props.player._firstPlay){
|
|
62
|
+
if (this.props.player._firstPlay) {
|
|
56
63
|
this.props.eventManager?.listen(this.props.player, this.props.player.Event.FIRST_PLAY, () => {
|
|
57
64
|
this.props.eventManager?.listen(document, 'keydown', this.handleKeydownEvent);
|
|
58
|
-
})
|
|
65
|
+
});
|
|
59
66
|
} else {
|
|
60
67
|
this.props.eventManager?.listen(document, 'keydown', this.handleKeydownEvent);
|
|
61
68
|
}
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
private handleKeydownEvent = (event: KeyboardEvent) => {
|
|
65
|
-
if (event.keyCode === TAB && event.shiftKey && document.activeElement === this._inputField?.base?.childNodes[0]){
|
|
66
|
-
//@ts-ignore
|
|
72
|
+
if (event.keyCode === TAB && event.shiftKey && document.activeElement === this._inputField?.base?.childNodes[0] && !this.props.isOverlayOpen) {
|
|
67
73
|
this.props.focusPluginButton(event);
|
|
68
74
|
}
|
|
69
75
|
};
|
|
@@ -117,6 +117,7 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
|
|
|
117
117
|
private _scrollToSearchMatchEnabled: boolean = false;
|
|
118
118
|
private _widgetRootRef: HTMLElement | null = null;
|
|
119
119
|
private _transcriptMenuRef: HTMLElement | null = null;
|
|
120
|
+
private _jumpToSearchButtonComponentRef = ui.preact.createRef<Button>();
|
|
120
121
|
|
|
121
122
|
private _widgetHeight: number = 0;
|
|
122
123
|
private _topAutoscrollEdge: number = 0;
|
|
@@ -142,6 +143,7 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
|
|
|
142
143
|
// use player size to define transcript root element size
|
|
143
144
|
this._debounced.setWidgetSize();
|
|
144
145
|
}
|
|
146
|
+
document.addEventListener('keydown', this._handleKeyboardShortcuts);
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
componentDidUpdate(previousProps: Readonly<TranscriptProps>, previousState: Readonly<TranscriptState>): void {
|
|
@@ -168,8 +170,18 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
|
|
|
168
170
|
this._resizeObserver?.disconnect();
|
|
169
171
|
this._resizeObserver = null;
|
|
170
172
|
}
|
|
173
|
+
document.removeEventListener('keydown', this._handleKeyboardShortcuts);
|
|
171
174
|
}
|
|
172
175
|
|
|
176
|
+
private _handleKeyboardShortcuts = (event: KeyboardEvent) => {
|
|
177
|
+
if ((event.ctrlKey || event.metaKey) && event.code === 'KeyJ') {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
if (this._jumpToSearchButtonComponentRef.current && this._jumpToSearchButtonComponentRef.current.buttonRef.current) {
|
|
180
|
+
this._jumpToSearchButtonComponentRef.current.buttonRef.current.focus();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
173
185
|
private _handleClose = (event: KeyboardEvent) => {
|
|
174
186
|
if (event.keyCode === ESC) {
|
|
175
187
|
this.props.onClose(event, true);
|
|
@@ -288,6 +300,7 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
|
|
|
288
300
|
private _renderJumpToSearchButton = () => {
|
|
289
301
|
const {toSearchResult, onJumpToSearchMatch} = this.props;
|
|
290
302
|
const {search, activeSearchIndex, totalSearchResults} = this.state;
|
|
303
|
+
|
|
291
304
|
if (!search || totalSearchResults === 0 || activeSearchIndex === 0) {
|
|
292
305
|
return null;
|
|
293
306
|
}
|
|
@@ -297,6 +310,7 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
|
|
|
297
310
|
className={styles.toSearchButton}
|
|
298
311
|
onClick={onJumpToSearchMatch}
|
|
299
312
|
ariaLabel={toSearchResult}
|
|
313
|
+
ref={this._jumpToSearchButtonComponentRef}
|
|
300
314
|
testId="transcript_jumpToSearchMatch">
|
|
301
315
|
{toSearchResult}
|
|
302
316
|
</Button>
|