feat: update captions content (#36732)
This commit is contained in:
@@ -67,6 +67,8 @@ var workerConfig = function() {
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.JS_ENV_EXTRA_CONFIG': JSON.parse(process.env.JS_ENV_EXTRA_CONFIG),
|
||||
'CAPTIONS_CONTENT_TO_REPLACE': JSON.stringify(process.env.CAPTIONS_CONTENT_TO_REPLACE || ''),
|
||||
'CAPTIONS_CONTENT_REPLACEMENT': JSON.stringify(process.env.CAPTIONS_CONTENT_REPLACEMENT || '')
|
||||
})
|
||||
],
|
||||
module: {
|
||||
|
||||
@@ -21,7 +21,9 @@ module.exports = _.values(Merge.smart(commonConfig, {
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': JSON.stringify('development'),
|
||||
'process.env.JS_ENV_EXTRA_CONFIG': process.env.JS_ENV_EXTRA_CONFIG || '{}'
|
||||
'process.env.JS_ENV_EXTRA_CONFIG': process.env.JS_ENV_EXTRA_CONFIG || '{}',
|
||||
'CAPTIONS_CONTENT_TO_REPLACE': JSON.stringify(process.env.CAPTIONS_CONTENT_TO_REPLACE || ''),
|
||||
'CAPTIONS_CONTENT_REPLACEMENT': JSON.stringify(process.env.CAPTIONS_CONTENT_REPLACEMENT || '')
|
||||
})
|
||||
],
|
||||
module: {
|
||||
|
||||
@@ -19,7 +19,9 @@ var optimizedConfig = Merge.smart(commonConfig, {
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
'process.env.JS_ENV_EXTRA_CONFIG': process.env.JS_ENV_EXTRA_CONFIG || '{}'
|
||||
'process.env.JS_ENV_EXTRA_CONFIG': process.env.JS_ENV_EXTRA_CONFIG || '{}',
|
||||
'CAPTIONS_CONTENT_TO_REPLACE': JSON.stringify(process.env.CAPTIONS_CONTENT_TO_REPLACE || ''),
|
||||
'CAPTIONS_CONTENT_REPLACEMENT': JSON.stringify(process.env.CAPTIONS_CONTENT_REPLACEMENT || '')
|
||||
}),
|
||||
new webpack.LoaderOptionsPlugin({ // This may not be needed; legacy option for loaders written for webpack 1
|
||||
minimize: true
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
'showClosedCaptions', 'hideClosedCaptions', 'toggleClosedCaptions',
|
||||
'updateCaptioningCookie', 'handleCaptioningCookie', 'handleTranscriptToggle',
|
||||
'listenForDragDrop', 'setTranscriptVisibility', 'updateTranscriptCookie',
|
||||
'updateGoogleDisclaimer', 'toggleGoogleDisclaimer'
|
||||
'updateGoogleDisclaimer', 'toggleGoogleDisclaimer', 'updateProblematicCaptionsContent'
|
||||
);
|
||||
|
||||
this.state = state;
|
||||
@@ -540,6 +540,21 @@
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @desc Replaces content in a caption
|
||||
*
|
||||
* @param {array} captions List of captions for the video.
|
||||
* @param {string} content content to be replaced
|
||||
* @param {string} replacementContent the replace string
|
||||
*
|
||||
* @returns {array} captions List of captions for the video.
|
||||
*/
|
||||
updateProblematicCaptionsContent: function(captions, content = '', replacementContent = '') {
|
||||
var updatedCaptions = captions.map(caption => caption.replace(content, replacementContent));
|
||||
|
||||
return updatedCaptions;
|
||||
},
|
||||
|
||||
/**
|
||||
* @desc Fetch the caption file specified by the user. Upon successful
|
||||
* receipt of the file, the captions will be rendered.
|
||||
@@ -594,6 +609,10 @@
|
||||
results = self.getBoundedCaptions();
|
||||
start = results.start;
|
||||
captions = results.captions;
|
||||
var contentToReplace = CAPTIONS_CONTENT_TO_REPLACE,
|
||||
replacementContent = CAPTIONS_CONTENT_REPLACEMENT;
|
||||
|
||||
captions = self.updateProblematicCaptionsContent(captions, contentToReplace, replacementContent);
|
||||
|
||||
self.renderGoogleDisclaimer(captions);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user