|
|
|
@ -82,7 +82,7 @@ const basicSetup: Extension = (() => [
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
export class EditorComponent {
|
|
|
|
|
APP_URL = 'http://localhost:4200/'; // à retirer
|
|
|
|
|
APP_URL = 'http://localhost:4200/'; // à retirer
|
|
|
|
|
|
|
|
|
|
@Input() currentWork!: Work;
|
|
|
|
|
isLoaded: boolean = false; // Pour vérifier si le chargement est terminé
|
|
|
|
@ -148,6 +148,9 @@ export class EditorComponent {
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
if (this.currentWork) {
|
|
|
|
|
this.selectedLanguage = this.languages.find(
|
|
|
|
|
(lang) => lang.name === this.currentWork.language
|
|
|
|
|
)!;
|
|
|
|
|
this.editorContent = this.currentWork.content;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -196,8 +199,12 @@ export class EditorComponent {
|
|
|
|
|
a.click();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addToDatabase() :string {
|
|
|
|
|
return this.workService.postWork(this.editorContent, this.selectedLanguage.name, 1); // replace 1 by current_user's id
|
|
|
|
|
addToDatabase(): string {
|
|
|
|
|
return this.workService.postWork(
|
|
|
|
|
this.editorContent,
|
|
|
|
|
this.selectedLanguage.name,
|
|
|
|
|
1
|
|
|
|
|
); // replace 1 by current_user's id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shareButtonClicked() {
|
|
|
|
@ -206,13 +213,16 @@ export class EditorComponent {
|
|
|
|
|
const ok = TranslateModule;
|
|
|
|
|
// Vérifiez si l'API clipboard est disponible
|
|
|
|
|
if (navigator.clipboard) {
|
|
|
|
|
navigator.clipboard.writeText(url).then(() => {
|
|
|
|
|
// Optionnel : Afficher un message à l'utilisateur
|
|
|
|
|
alert('URL copied to clipboard!');
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
// Optionnel : Afficher un message d'erreur à l'utilisateur
|
|
|
|
|
alert('Failed to copy URL to clipboard.');
|
|
|
|
|
});
|
|
|
|
|
navigator.clipboard
|
|
|
|
|
.writeText(url)
|
|
|
|
|
.then(() => {
|
|
|
|
|
// Optionnel : Afficher un message à l'utilisateur
|
|
|
|
|
alert('URL copied to clipboard!');
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
// Optionnel : Afficher un message d'erreur à l'utilisateur
|
|
|
|
|
alert('Failed to copy URL to clipboard.');
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// Optionnel : Si l'API clipboard n'est pas disponible, afficher un message à l'utilisateur
|
|
|
|
|
alert('Clipboard API not available');
|
|
|
|
@ -222,7 +232,8 @@ export class EditorComponent {
|
|
|
|
|
saveButtonClicked() {
|
|
|
|
|
this.workService.updateWork(
|
|
|
|
|
String(this.currentWork.id_work),
|
|
|
|
|
this.editorContent
|
|
|
|
|
this.editorContent,
|
|
|
|
|
this.selectedLanguage.name
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|