@playkit-js/transcript 2.1.5-canary.18-708d21c → 2.1.5-canary.21-e28422e
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/CHANGELOG.md +4 -1
- package/dist/playkit-transcript.js +1 -1
- package/dist/playkit-transcript.js.map +1 -1
- package/package.json +1 -1
- package/src/components/download-print-menu/download-print-menu.tsx +0 -5
- package/src/components/spinner/spinner.scss +1 -1
- package/src/components/spinner/spinner.tsx +1 -1
- package/src/components/transcript/transcript.tsx +3 -3
- package/src/transcript-plugin.tsx +56 -45
package/package.json
CHANGED
|
@@ -65,11 +65,6 @@ interface DownloadPrintMenuState {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export class DownloadPrintMenu extends Component<DownloadPrintMenuProps, DownloadPrintMenuState> {
|
|
68
|
-
static defaultProps = {
|
|
69
|
-
dropdownAriaLabel: 'Download or print current transcript',
|
|
70
|
-
printButtonAriaLabel: 'Print current transcript',
|
|
71
|
-
downloadButtonAriaLabel: 'Download current transcript'
|
|
72
|
-
};
|
|
73
68
|
state: DownloadPrintMenuState = {
|
|
74
69
|
popoverOpen: false
|
|
75
70
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {h, Component} from 'preact';
|
|
2
|
-
import {A11yWrapper} from '@playkit-js/common';
|
|
2
|
+
import {A11yWrapper, OnClickEvent} from '@playkit-js/common';
|
|
3
3
|
import {debounce} from '../../utils';
|
|
4
4
|
import * as styles from './transcript.scss';
|
|
5
5
|
import {Spinner} from '../spinner';
|
|
@@ -84,7 +84,7 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
|
|
|
84
84
|
this._setWidgetSize();
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
private _enableAutoScroll = (event:
|
|
87
|
+
private _enableAutoScroll = (event: OnClickEvent, byKeyboard?: boolean) => {
|
|
88
88
|
event.preventDefault();
|
|
89
89
|
if (this.state.isAutoScrollEnabled) {
|
|
90
90
|
return;
|
|
@@ -93,7 +93,7 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
|
|
|
93
93
|
this.setState({
|
|
94
94
|
isAutoScrollEnabled: true
|
|
95
95
|
});
|
|
96
|
-
if (
|
|
96
|
+
if (byKeyboard) {
|
|
97
97
|
this._skipTranscriptButtonRef?.focus();
|
|
98
98
|
}
|
|
99
99
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {h} from 'preact';
|
|
2
|
-
import {
|
|
2
|
+
import {OnClickEvent} from '@playkit-js/common';
|
|
3
3
|
import {ui} from 'kaltura-player-js';
|
|
4
|
+
import {ObjectUtils} from './utils';
|
|
4
5
|
import {PluginButton} from './components/plugin-button/plugin-button';
|
|
5
6
|
import {Transcript} from './components/transcript';
|
|
6
7
|
import {getConfigValue, isBoolean, makePlainText, prepareCuePoint} from './utils';
|
|
@@ -10,6 +11,13 @@ import {DownloadPrintMenu, downloadContent, printContent} from './components/dow
|
|
|
10
11
|
const {SidePanelModes, SidePanelPositions, ReservedPresetNames, ReservedPresetAreas} = ui;
|
|
11
12
|
const {get} = ObjectUtils;
|
|
12
13
|
const {Tooltip} = KalturaPlayer.ui.components;
|
|
14
|
+
const {withText, Text} = KalturaPlayer.ui.preacti18n;
|
|
15
|
+
|
|
16
|
+
const translates = () => ({
|
|
17
|
+
printDownloadAreaLabel: <Text id="transcript.print_download_area_label">Download or print current transcript</Text>,
|
|
18
|
+
printTranscript: <Text id="transcript.print_transcript">Print current transcript</Text>,
|
|
19
|
+
downloadTranscript: <Text id="transcript.download_transcript">Download current transcript</Text>
|
|
20
|
+
});
|
|
13
21
|
|
|
14
22
|
interface TimedMetadataEvent {
|
|
15
23
|
payload: {
|
|
@@ -62,27 +70,34 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
|
|
|
62
70
|
this.logger.warn("kalturaCuepoints or sidePanelsManager haven't registered");
|
|
63
71
|
return;
|
|
64
72
|
}
|
|
65
|
-
this.
|
|
73
|
+
this._initListeners();
|
|
66
74
|
this.cuePointManager.registerTypes([this.cuePointManager.CuepointType.CAPTION]);
|
|
67
75
|
}
|
|
68
76
|
|
|
69
|
-
|
|
77
|
+
private _initListeners(): void {
|
|
78
|
+
this.eventManager.listen(this.player, this.player.Event.FIRST_PLAYING, () => {
|
|
79
|
+
if ((this.player.getTracks(this.player.Track.TEXT) || []).length) {
|
|
80
|
+
// check if captions already added in TextTrack
|
|
81
|
+
if (!this._captionMap.size) {
|
|
82
|
+
// turn on loading animation till captions added to TextTrack
|
|
83
|
+
this._isLoading = true;
|
|
84
|
+
}
|
|
85
|
+
this._addPopoverIcon();
|
|
86
|
+
this._addTranscriptItem();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
70
89
|
this.eventManager.listen(this.player, this.player.Event.TIMED_METADATA_CHANGE, this._onTimedMetadataChange);
|
|
71
90
|
this.eventManager.listen(this.player, this.player.Event.TIMED_METADATA_ADDED, this._onTimedMetadataAdded);
|
|
72
91
|
this.eventManager.listen(this.player, this.player.Event.TEXT_TRACK_CHANGED, this._handleLanguageChange);
|
|
73
92
|
}
|
|
74
93
|
|
|
75
|
-
onRegisterUI(): void {}
|
|
76
|
-
|
|
77
94
|
private _handleLanguageChange = () => {
|
|
78
95
|
this._activeCaptionMapId = this._getCaptionMapId();
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
96
|
+
this._isLoading = !this._captionMap.has(this._activeCaptionMapId);
|
|
97
|
+
this._updateTranscriptPanel();
|
|
82
98
|
};
|
|
83
99
|
|
|
84
100
|
private _updateTranscriptPanel() {
|
|
85
|
-
this._isLoading = false;
|
|
86
101
|
if (this._transcriptPanel) {
|
|
87
102
|
this.sidePanelsManager.update(this._transcriptPanel);
|
|
88
103
|
}
|
|
@@ -114,7 +129,8 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
|
|
|
114
129
|
private _addCaptionData = (newData: CuePointData[]) => {
|
|
115
130
|
this._activeCaptionMapId = this._getCaptionMapId();
|
|
116
131
|
this._captionMap.set(this._activeCaptionMapId, newData);
|
|
117
|
-
this.
|
|
132
|
+
this._isLoading = false;
|
|
133
|
+
this._updateTranscriptPanel();
|
|
118
134
|
};
|
|
119
135
|
|
|
120
136
|
private _getCaptionMapId = (): string => {
|
|
@@ -127,13 +143,9 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
|
|
|
127
143
|
return '';
|
|
128
144
|
};
|
|
129
145
|
|
|
130
|
-
private
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
this.sidePanelsManager.deactivateItem(this._transcriptPanel);
|
|
134
|
-
} else {
|
|
135
|
-
this.sidePanelsManager.activateItem(this._transcriptPanel);
|
|
136
|
-
}
|
|
146
|
+
private _handleCloseClick = () => {
|
|
147
|
+
this.sidePanelsManager.deactivateItem(this._transcriptPanel);
|
|
148
|
+
this._pluginState = PluginStates.CLOSED;
|
|
137
149
|
};
|
|
138
150
|
|
|
139
151
|
private _addPopoverIcon(): void {
|
|
@@ -142,33 +154,23 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
|
|
|
142
154
|
return;
|
|
143
155
|
}
|
|
144
156
|
this._removePopoverIcon = this.player.ui.addComponent({
|
|
145
|
-
label: 'Download transcript',
|
|
157
|
+
label: 'Download or print transcript',
|
|
146
158
|
area: ReservedPresetAreas.TopBarRightControls,
|
|
147
159
|
presets: [ReservedPresetNames.Playback, ReservedPresetNames.Live],
|
|
148
|
-
get: () => (
|
|
160
|
+
get: withText(translates)(({printDownloadAreaLabel, printTranscript, downloadTranscript}: Record<string, string>) => (
|
|
149
161
|
<DownloadPrintMenu
|
|
150
162
|
onDownload={this._handleDownload}
|
|
151
163
|
onPrint={this._handlePrint}
|
|
152
164
|
downloadDisabled={getConfigValue(downloadDisabled, isBoolean, false)}
|
|
153
165
|
printDisabled={getConfigValue(printDisabled, isBoolean, false)}
|
|
154
|
-
dropdownAriaLabel={
|
|
155
|
-
printButtonAriaLabel={
|
|
156
|
-
downloadButtonAriaLabel={
|
|
166
|
+
dropdownAriaLabel={printDownloadAreaLabel}
|
|
167
|
+
printButtonAriaLabel={printTranscript}
|
|
168
|
+
downloadButtonAriaLabel={downloadTranscript}
|
|
157
169
|
/>
|
|
158
|
-
)
|
|
170
|
+
))
|
|
159
171
|
});
|
|
160
172
|
}
|
|
161
173
|
|
|
162
|
-
private _createOrUpdatePlugin = () => {
|
|
163
|
-
if (this._transcriptPanel) {
|
|
164
|
-
this._updateTranscriptPanel();
|
|
165
|
-
} else {
|
|
166
|
-
this._initLoading();
|
|
167
|
-
this._addPopoverIcon();
|
|
168
|
-
this._addTranscriptItem();
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
|
|
172
174
|
private _addTranscriptItem(): void {
|
|
173
175
|
const buttonLabel = 'Transcript';
|
|
174
176
|
const {expandMode, position, expandOnFirstPlay} = this.config;
|
|
@@ -192,19 +194,31 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
|
|
|
192
194
|
captions={this._data}
|
|
193
195
|
isLoading={this._isLoading}
|
|
194
196
|
hasError={this._hasError}
|
|
195
|
-
onRetryLoad={this.
|
|
197
|
+
onRetryLoad={this._updateTranscriptPanel}
|
|
196
198
|
currentTime={this.player.currentTime}
|
|
197
199
|
videoDuration={this.player.duration}
|
|
198
200
|
kitchenSinkActive={!!this.sidePanelsManager.isItemActive(this._transcriptPanel)}
|
|
199
201
|
toggledWithEnter={this._triggeredByKeyboard}
|
|
200
|
-
onClose={this.
|
|
202
|
+
onClose={this._handleCloseClick}
|
|
201
203
|
/>
|
|
202
204
|
);
|
|
203
205
|
},
|
|
204
206
|
iconComponent: ({isActive}: {isActive: boolean}) => {
|
|
205
207
|
return (
|
|
206
208
|
<Tooltip label={buttonLabel} type="bottom">
|
|
207
|
-
<PluginButton
|
|
209
|
+
<PluginButton
|
|
210
|
+
isActive={isActive}
|
|
211
|
+
label={buttonLabel}
|
|
212
|
+
onClick={(e: OnClickEvent, byKeyboard?: boolean) => {
|
|
213
|
+
if (this.sidePanelsManager.isItemActive(this._transcriptPanel)) {
|
|
214
|
+
this._triggeredByKeyboard = false;
|
|
215
|
+
this._handleCloseClick();
|
|
216
|
+
} else {
|
|
217
|
+
this._triggeredByKeyboard = Boolean(byKeyboard);
|
|
218
|
+
this.sidePanelsManager.activateItem(this._transcriptPanel);
|
|
219
|
+
}
|
|
220
|
+
}}
|
|
221
|
+
/>
|
|
208
222
|
</Tooltip>
|
|
209
223
|
);
|
|
210
224
|
},
|
|
@@ -223,14 +237,6 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
|
|
|
223
237
|
}
|
|
224
238
|
}
|
|
225
239
|
|
|
226
|
-
private _initLoading() {
|
|
227
|
-
if (!this._isLoading || this._hasError) {
|
|
228
|
-
this._isLoading = true;
|
|
229
|
-
this._hasError = false;
|
|
230
|
-
this._updateTranscriptPanel();
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
240
|
private _seekTo = (time: number) => {
|
|
235
241
|
this.player.currentTime = time;
|
|
236
242
|
};
|
|
@@ -260,15 +266,20 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
|
|
|
260
266
|
}
|
|
261
267
|
|
|
262
268
|
reset(): void {
|
|
269
|
+
this.eventManager.removeAll();
|
|
263
270
|
if (this._removePopoverIcon) {
|
|
264
271
|
this._removePopoverIcon();
|
|
265
272
|
this._removePopoverIcon = null;
|
|
266
273
|
}
|
|
267
|
-
|
|
274
|
+
if (this._transcriptPanel) {
|
|
275
|
+
this.sidePanelsManager.removeItem(this._transcriptPanel);
|
|
276
|
+
this._transcriptPanel = null;
|
|
277
|
+
}
|
|
268
278
|
this._captionMap = new Map();
|
|
269
279
|
this._activeCaptionMapId = '';
|
|
270
280
|
this._isLoading = false;
|
|
271
281
|
this._hasError = false;
|
|
282
|
+
this._triggeredByKeyboard = false;
|
|
272
283
|
}
|
|
273
284
|
|
|
274
285
|
destroy(): void {
|