Intégration d'iframe pour les vidéos youtube (REGEX DE LA MORT QUI TUE)
This commit is contained in:
parent
6c52142c2e
commit
4990bd9db7
@ -1,9 +1,9 @@
|
|||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<p class="footer-creator">Site web réalisé par <strong>Guams</strong>.</p>
|
<p class="footer-creator">Site web réalisé par <strong>Guams</strong>.</p>
|
||||||
<p class="footer-banner">Bannière réalisée par <a href="https://twitter.com/Orabiss" target="_blank" class="footer-link">@Orabiss</a> sur Twitter.</p>
|
<p class="footer-banner">Bannière réalisée par <a href="https://x.com/Orabisss" target="_blank" class="footer-link">@Orabisss</a> sur Twitter.</p>
|
||||||
<p class="footer-follow">Suivez-moi sur :</p>
|
<p class="footer-follow">Suivez-moi sur :</p>
|
||||||
<p class="footer-links">
|
<p class="footer-links">
|
||||||
<a href="https://x.com/Orabisss" target="_blank" class="footer-link">Twitter</a>
|
<a href="https://x.com/Guams8" target="_blank" class="footer-link">Twitter</a>
|
||||||
<a href="https://github.com/Guamss" target="_blank" class="footer-link">GitHub</a>
|
<a href="https://github.com/Guamss" target="_blank" class="footer-link">GitHub</a>
|
||||||
</p>
|
</p>
|
||||||
<p class="footer-copyright">© 2024 Guams. Tous droits réservés.</p>
|
<p class="footer-copyright">© 2024 Guams. Tous droits réservés.</p>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {Component, Input, OnDestroy} from '@angular/core';
|
import {AfterViewInit, Component, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||||
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
|
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||||
import {InputTextModule} from 'primeng/inputtext';
|
import {InputTextModule} from 'primeng/inputtext';
|
||||||
import {InputTextareaModule} from 'primeng/inputtextarea';
|
import {InputTextareaModule} from 'primeng/inputtextarea';
|
||||||
@ -65,6 +65,7 @@ export class PostFormComponent implements OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
loadPostData(): void {
|
loadPostData(): void {
|
||||||
if (this.postId) {
|
if (this.postId) {
|
||||||
this.subs.push(
|
this.subs.push(
|
||||||
@ -94,7 +95,7 @@ export class PostFormComponent implements OnDestroy {
|
|||||||
onSubmit(): void {
|
onSubmit(): void {
|
||||||
if (this.form.valid && this.uploadedFile) {
|
if (this.form.valid && this.uploadedFile) {
|
||||||
const formData = this.form.value;
|
const formData = this.form.value;
|
||||||
// this.transformParagraphs()
|
formData.body = this.transformYouTubeLinksToIframes(formData.body);
|
||||||
const postData: any = {
|
const postData: any = {
|
||||||
title: formData.title,
|
title: formData.title,
|
||||||
description: formData.description,
|
description: formData.description,
|
||||||
@ -109,7 +110,10 @@ export class PostFormComponent implements OnDestroy {
|
|||||||
return this.postService.changeIllustration(this.postId, this.uploadedFile, this.cookieService.get('token'));
|
return this.postService.changeIllustration(this.postId, this.uploadedFile, this.cookieService.get('token'));
|
||||||
})
|
})
|
||||||
).subscribe({
|
).subscribe({
|
||||||
next: (_) => this.successMessage('Succès', 'Post créé avec succès'),
|
next: (_) => {
|
||||||
|
this.successMessage('Succès', 'Post mis à jour avec succès')
|
||||||
|
console.log(this.body);
|
||||||
|
},
|
||||||
error: (err) => this.failureMessage('Erreur', err.message)
|
error: (err) => this.failureMessage('Erreur', err.message)
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -126,6 +130,7 @@ export class PostFormComponent implements OnDestroy {
|
|||||||
).subscribe({
|
).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.router.navigate(['/']).then(() => {
|
this.router.navigate(['/']).then(() => {
|
||||||
|
console.log(this.body);
|
||||||
this.successMessage('Succès', 'Post créé avec succès')
|
this.successMessage('Succès', 'Post créé avec succès')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -136,6 +141,13 @@ export class PostFormComponent implements OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private transformYouTubeLinksToIframes(html: string): string {
|
||||||
|
return html.replace(/<a[^>]*href="(https?:\/\/(?:www\.)?(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]+)[^"]*)".*?<\/a>/g,
|
||||||
|
(_, url, _prefix, videoId) => {
|
||||||
|
return `<iframe width="560" height="315" src="https://www.youtube.com/embed/${videoId}" frameborder="0" allowfullscreen></iframe>`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
choose(callback: Function) {
|
choose(callback: Function) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user