Skip to content

Commit

Permalink
disable preview formaters
Browse files Browse the repository at this point in the history
  • Loading branch information
blurymind committed Mar 25, 2024
1 parent 7976456 commit 7aefa23
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions src/js/classes/richTextFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,38 @@ export const RichTextFormatter = function(app) {
const ytRegex = /(?:http(?:s?):\/\/|)(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?(?:\?t=[0-9]+)?/gi;
const otherUrlPattern = `^(?!${twRegex.source}|${ytRegex.source}|${instaRegex.source})https?:.*$`;
const combinedRegex = new RegExp(otherUrlPattern, 'gm');
// result = result.replace(combinedRegex, function(id) {
// return `
// <div style="position: relative">
// <iframe src="${id}" style="position:relative;left:-70px !important;width:90%;height:500px"></iframe>
// </div>
// `;
// });
result = result.replace(combinedRegex, function(id) {
return `
<div style="position: relative">
<iframe src="${id}" style="position:relative;left:-70px !important;width:90%;height:500px"></iframe>
</div>
<a class="link" href="${id}">${id}</a>
`;
});
// add tweet embeds :3
const tweets = [];
result = result.replace(twRegex, function(id) {
const extractedtweetId = id.match(
/https:\/\/twitter.com\/.*\/status\/([0-9]+)/i
);
if (extractedtweetId.length > 1) {
tweets.push(extractedtweetId[1]);
return `<a class="tweet" id="${extractedtweetId[1]}"></a>`;
}
});
setTimeout(() => {
const tweetItems = document.querySelectorAll('.tweet');
tweets.forEach((tweetPost, index) => {
twttr.widgets.createTweet(tweetPost, tweetItems[index], {
align: 'center',
follow: false,
});
});
}, 500);
// const tweets = [];
// result = result.replace(twRegex, function(id) {
// const extractedtweetId = id.match(
// /https:\/\/twitter.com\/.*\/status\/([0-9]+)/i
// );
// if (extractedtweetId.length > 1) {
// tweets.push(extractedtweetId[1]);
// return `<a class="tweet" id="${extractedtweetId[1]}"></a>`;
// }
// });
// setTimeout(() => {
// const tweetItems = document.querySelectorAll('.tweet');
// tweets.forEach((tweetPost, index) => {
// twttr.widgets.createTweet(tweetPost, tweetItems[index], {
// align: 'center',
// follow: false,
// });
// });
// }, 500);
// create Youtube previews :)
result = result.replace(ytRegex, function(id) {
const extractedId = id.match(
Expand Down

0 comments on commit 7aefa23

Please sign in to comment.