|
@@ -14,7 +14,6 @@ export const replaceTokens = (content, sourceIds, char, user) => {
|
|
|
const videoIdToken = /{{VIDEO_FILE_ID_([a-f0-9-]+)}}/gi; // Regex to capture the video ID
|
|
|
const htmlIdToken = /{{HTML_FILE_ID_([a-f0-9-]+)}}/gi; // Regex to capture the HTML ID
|
|
|
|
|
|
-
|
|
|
// Replace {{char}} if char is provided
|
|
|
if (char !== undefined && char !== null) {
|
|
|
content = content.replace(charToken, char);
|
|
@@ -37,17 +36,16 @@ export const replaceTokens = (content, sourceIds, char, user) => {
|
|
|
return `<iframe src="${htmlUrl}" width="100%" frameborder="0" onload="this.style.height=(this.contentWindow.document.body.scrollHeight+20)+'px';"></iframe>`;
|
|
|
});
|
|
|
|
|
|
-
|
|
|
// Remove sourceIds from the content and replace them with <source_id>...</source_id>
|
|
|
- if (Array.isArray(sourceIds)) {
|
|
|
- sourceIds.forEach((sourceId) => {
|
|
|
- // Create a token based on the exact `[sourceId]` string
|
|
|
- const sourceToken = `\\[${sourceId}\\]`; // Escape special characters for RegExp
|
|
|
- const sourceRegex = new RegExp(sourceToken, 'g'); // Match all occurrences of [sourceId]
|
|
|
-
|
|
|
- content = content.replace(sourceRegex, `<source_id data="${sourceId}" />`);
|
|
|
- });
|
|
|
- }
|
|
|
+ if (Array.isArray(sourceIds)) {
|
|
|
+ sourceIds.forEach((sourceId) => {
|
|
|
+ // Create a token based on the exact `[sourceId]` string
|
|
|
+ const sourceToken = `\\[${sourceId}\\]`; // Escape special characters for RegExp
|
|
|
+ const sourceRegex = new RegExp(sourceToken, 'g'); // Match all occurrences of [sourceId]
|
|
|
+
|
|
|
+ content = content.replace(sourceRegex, `<source_id data="${sourceId}" />`);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
return content;
|
|
|
};
|