@playkit-js/transcript 3.5.20 → 3.5.21-canary.0-cf3ec21

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.20",
3
+ "version": "3.5.21-canary.0-cf3ec21",
4
4
  "main": "dist/playkit-transcript.js",
5
5
  "license": "AGPL-3.0",
6
6
  "private": false,
@@ -15,7 +15,7 @@
15
15
  "devDependencies": {
16
16
  "@playkit-js/kaltura-player-js": "3.17.9",
17
17
  "@playkit-js/playkit-js-ui": "0.78.0",
18
- "@playkit-js/ui-managers": "1.5.2",
18
+ "@playkit-js/ui-managers": "1.6.0-canary.0-93cb124",
19
19
  "@types/sanitize-html": "^2.9.3",
20
20
  "conventional-github-releaser": "3.1.3",
21
21
  "copyfiles": "^2.4.1",
@@ -77,7 +77,7 @@
77
77
  "html5 player"
78
78
  ],
79
79
  "dependencies": {
80
- "@playkit-js/common": "1.5.9",
80
+ "@playkit-js/common": "1.5.13",
81
81
  "sanitize-html": "^2.11.0",
82
82
  "stream-browserify": "^3.0.0"
83
83
  },
@@ -0,0 +1,21 @@
1
+ @import '~@playkit-js/playkit-js-ui';
2
+
3
+ .attach-placeholder-container {
4
+ position: absolute;
5
+ top: 50%;
6
+ left: 50%;
7
+ transform: translate(-50%, -50%);
8
+ display: flex;
9
+ flex-direction: column;
10
+ justify-content: center;
11
+ align-items: center;
12
+ .attach-text {
13
+ line-height: 20px;
14
+ font-weight: 700;
15
+ letter-spacing: normal;
16
+ color: $tone-1-color;
17
+ }
18
+ .attach-button {
19
+ margin-top: 20px;
20
+ }
21
+ }
@@ -0,0 +1,23 @@
1
+ import {h} from 'preact';
2
+ import {ui} from '@playkit-js/kaltura-player-js';
3
+ import {Button, ButtonType, ButtonSize} from '@playkit-js/common/dist/components/button';
4
+ import * as styles from './attach-placeholder.scss';
5
+
6
+ const {Text} = ui.preacti18n;
7
+
8
+ interface AttachPlaceholderProps {
9
+ onAttach: () => void;
10
+ }
11
+
12
+ export const AttachPlaceholder = ({onAttach}: AttachPlaceholderProps) => {
13
+ return (
14
+ <div className={styles.attachPlaceholderContainer} data-testid="transcriptAttachPlaceholder">
15
+ <div className={styles.attachText}>
16
+ <Text id="transcript.attachTranscriptText">Transcript popped out</Text>
17
+ </div>
18
+ <Button type={ButtonType.primary} size={ButtonSize.medium} className={styles.attachButton} onClick={onAttach} testId="transcriptAttachButton">
19
+ <Text id="transcript.attachTranscriptButton">Bring it back</Text>
20
+ </Button>
21
+ </div>
22
+ );
23
+ };
@@ -0,0 +1 @@
1
+ export * from './attach-placeholder';
@@ -101,7 +101,7 @@ export class Caption extends Component<ExtendedCaptionProps> {
101
101
  render() {
102
102
  const {caption, highlighted, showTime, longerThanHour} = this.props;
103
103
  const {startTime, id} = caption;
104
- const isHighlighted = Object.keys(highlighted)[0] === id;
104
+ const isHighlighted = Object.keys(highlighted).some(c => c === id) ;
105
105
  const time = showTime ? secondsToTime(startTime, longerThanHour) : '';
106
106
 
107
107
  const captionA11yProps: Record<string, any> = {
@@ -46,6 +46,7 @@
46
46
  }
47
47
 
48
48
  .global-container {
49
+ position: relative;
49
50
  height: 100%;
50
51
  display: flex;
51
52
  flex-direction: column;
@@ -26,7 +26,9 @@ const SEARCH_EVENT_DISPATCH_TIMEOUT = 2000;
26
26
  const translates = {
27
27
  skipTranscript: <Text id="transcript.skip_transcript">Skip transcript</Text>,
28
28
  errorTitle: <Text id="transcript.whoops">Whoops!</Text>,
29
- errorDescripton: <Text id="transcript.load_failed">Failed to load transcript</Text>
29
+ errorDescripton: <Text id="transcript.load_failed">Failed to load transcript</Text>,
30
+ attachTranscript: <Text id="transcript.attach_transcript">Bring Transcript back</Text>,
31
+ detachTranscript: <Text id="transcript.detach_transcript">Popout Transcript</Text>
30
32
  };
31
33
 
32
34
  export interface TranscriptProps {
@@ -49,6 +51,8 @@ export interface TranscriptProps {
49
51
  skipTranscript?: string;
50
52
  errorTitle?: string;
51
53
  errorDescripton?: string;
54
+ attachTranscript?: string;
55
+ detachTranscript?: string;
52
56
  downloadDisabled: boolean;
53
57
  onDownload: () => void;
54
58
  printDisabled: boolean;
@@ -57,6 +61,9 @@ export interface TranscriptProps {
57
61
  expandMode?: string;
58
62
  dispatcher: (name: string, payload?: any) => void;
59
63
  activeCaptionLanguage: string;
64
+ onDetach: () => void;
65
+ onAttach: () => void;
66
+ kitchenSinkDetached: boolean;
60
67
  }
61
68
 
62
69
  interface TranscriptState {
@@ -187,7 +194,7 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
187
194
 
188
195
  private _dispatchSearchEvent = (state: TranscriptState) => {
189
196
  this.props.dispatcher(TranscriptEvents.TRANSCRIPT_SEARCH, {search: this.state.search});
190
- }
197
+ };
191
198
 
192
199
  private _setActiveSearchIndex = (index: number) => {
193
200
  this._scrollToSearchMatchEnabled = true;
@@ -210,7 +217,20 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
210
217
  };
211
218
 
212
219
  private _renderHeader = () => {
213
- const {toggledWithEnter, kitchenSinkActive, downloadDisabled, onDownload, printDisabled, onPrint, isLoading} = this.props;
220
+ const {
221
+ toggledWithEnter,
222
+ kitchenSinkActive,
223
+ kitchenSinkDetached,
224
+ downloadDisabled,
225
+ onDownload,
226
+ printDisabled,
227
+ onPrint,
228
+ isLoading,
229
+ onAttach,
230
+ onDetach,
231
+ attachTranscript,
232
+ detachTranscript
233
+ } = this.props;
214
234
  const {search, activeSearchIndex, totalSearchResults} = this.state;
215
235
  return (
216
236
  <div className={[styles.header, this._getHeaderStyles()].join(' ')} data-testid="transcript_header">
@@ -224,16 +244,29 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
224
244
  kitchenSinkActive={kitchenSinkActive}
225
245
  />
226
246
  <TranscriptMenu {...{downloadDisabled, onDownload, printDisabled, onPrint, isLoading}} />
227
- <div data-testid="transcriptCloseButton">
247
+ <div data-testid="transcriptDetachAttachButton">
228
248
  <Button
229
249
  type={ButtonType.borderless}
230
250
  size={ButtonSize.medium}
231
- disabled={false}
232
- onClick={this.props.onClose}
233
- ariaLabel={'Hide Transcript'}
234
- tooltip={{label: 'Hide Transcript'}}
235
- icon={'close'}></Button>
251
+ onClick={kitchenSinkDetached ? onAttach : onDetach}
252
+ icon={kitchenSinkDetached ? 'attach' : 'detach'}
253
+ ariaLabel={kitchenSinkDetached ? attachTranscript : detachTranscript}
254
+ tooltip={{label: kitchenSinkDetached ? attachTranscript! : detachTranscript!}}
255
+ />
236
256
  </div>
257
+ {!kitchenSinkDetached && (
258
+ <div data-testid="transcriptCloseButton">
259
+ <Button
260
+ type={ButtonType.borderless}
261
+ size={ButtonSize.medium}
262
+ disabled={false}
263
+ onClick={this.props.onClose}
264
+ ariaLabel={'Hide Transcript'}
265
+ tooltip={{label: 'Hide Transcript'}}
266
+ icon={'close'}
267
+ />
268
+ </div>
269
+ )}
237
270
  </div>
238
271
  );
239
272
  };
@@ -387,11 +420,11 @@ export class Transcript extends Component<TranscriptProps, TranscriptState> {
387
420
  };
388
421
 
389
422
  render(props: TranscriptProps) {
390
- const {isLoading, kitchenSinkActive, hasError, smallScreen, toggledWithEnter} = props;
423
+ const {isLoading, kitchenSinkActive, kitchenSinkDetached, hasError, smallScreen, toggledWithEnter} = props;
391
424
  const renderTranscriptButtons = !(isLoading || hasError);
392
425
  return (
393
426
  <div
394
- className={`${styles.root} ${kitchenSinkActive ? '' : styles.hidden}`}
427
+ className={`${styles.root} ${kitchenSinkActive || kitchenSinkDetached ? '' : styles.hidden}`}
395
428
  ref={node => {
396
429
  this._widgetRootRef = node;
397
430
  }}
@@ -10,6 +10,7 @@ import {Transcript} from './components/transcript';
10
10
  import {getConfigValue, isBoolean, makePlainText, prepareCuePoint} from './utils';
11
11
  import {TranscriptConfig, PluginStates, HighlightedMap, CuePointData, ItemTypes, CuePoint} from './types';
12
12
  import {TranscriptEvents} from './events/events';
13
+ import {AttachPlaceholder} from './components/attach-placeholder';
13
14
 
14
15
  export const pluginName: string = 'playkit-js-transcript';
15
16
 
@@ -227,6 +228,21 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
227
228
  }));
228
229
  };
229
230
 
231
+ private _handleDetach = () => {
232
+ this.sidePanelsManager?.detachItem(this._transcriptPanel, {
233
+ width: 600,
234
+ height: 600,
235
+ title: 'Transcript',
236
+ attachPlaceholder: () => (<AttachPlaceholder onAttach={this._handleAttach} />) as any
237
+ });
238
+ };
239
+ private _handleAttach = () => {
240
+ this.sidePanelsManager?.attachItem(this._transcriptPanel);
241
+ };
242
+ private _isDetached = (): boolean => {
243
+ return this.sidePanelsManager!.isItemDetached(this._transcriptPanel);
244
+ };
245
+
230
246
  private _addTranscriptItem(): void {
231
247
  if (Math.max(this._transcriptPanel, this._transcriptIcon) > 0) {
232
248
  // transcript panel or icon already exist
@@ -264,6 +280,7 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
264
280
  currentTime={this.player.currentTime}
265
281
  videoDuration={this.player.duration}
266
282
  kitchenSinkActive={this._isPluginActive()}
283
+ kitchenSinkDetached={this._isDetached()}
267
284
  toggledWithEnter={this._triggeredByKeyboard}
268
285
  onClose={this._handleClose}
269
286
  downloadDisabled={getConfigValue(downloadDisabled, isBoolean, false)}
@@ -272,12 +289,14 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
272
289
  onPrint={this._handlePrint}
273
290
  dispatcher={(eventType, payload) => this.dispatchEvent(eventType, payload)}
274
291
  activeCaptionLanguage={this._activeCaptionMapId}
275
- /> as any
276
- );
292
+ onDetach={this._handleDetach}
293
+ onAttach={this._handleAttach}
294
+ />
295
+ ) as any;
277
296
  },
278
297
  presets: [ReservedPresetNames.Playback, ReservedPresetNames.Live, ReservedPresetNames.Ads],
279
298
  position: position,
280
- expandMode: expandMode === SidePanelModes.ALONGSIDE ? SidePanelModes.ALONGSIDE : SidePanelModes.OVER,
299
+ expandMode: expandMode === SidePanelModes.ALONGSIDE ? SidePanelModes.ALONGSIDE : SidePanelModes.OVER
281
300
  }) as number;
282
301
  const translates = {
283
302
  showTranscript: <Text id="transcript.show_plugin">Show Transcript</Text>,
@@ -16,7 +16,11 @@
16
16
  "load_failed": "Failed to load transcript",
17
17
  "skip_transcript": "Skip transcript",
18
18
  "smallScreenText": "To see the transcript, go to full screen",
19
- "smallScreenMobileText": "To see the transcript, rotate the phone"
19
+ "smallScreenMobileText": "To see the transcript, rotate the phone",
20
+ "attachTranscriptText": "Transcript popped out",
21
+ "attachTranscriptButton": "Bring it back",
22
+ "attachTranscript": "Bring Transcript back",
23
+ "detachTranscript": "Popout Transcript"
20
24
  }
21
25
  }
22
26
  }