Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: CI

permissions:
contents: read

on:
push:
branches: [main, develop]
Expand Down
19 changes: 4 additions & 15 deletions src/features/properties/views/PropertyDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,10 @@ async function copyAnnonce() {
// Convert HTML to plain text while preserving line breaks
function htmlToPlainText(html: string) {
if (!html) return '';
// remove script/style blocks
const cleaned = html
.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/gi, '')
.replace(/<style[\s\S]*?>[\s\S]*?<\/style>/gi, '');
// replace <br> and closing block tags with newlines
const withBreaks = cleaned
.replace(/<br\s*\/*>/gi, '\n')
.replace(/<\/(p|div|h[1-6]|li|ul|ol|tr|table|section|article)>/gi, '\n')
.replace(/<(\/)?td[^>]*>/gi, '\t');
// strip remaining tags
const stripped = withBreaks.replace(/<[^>]+>/g, '');
// decode HTML entities
const txt = document.createElement('textarea');
txt.innerHTML = stripped;
let decoded = txt.value;
// Use DOM parsing to safely convert HTML to text
const container = document.createElement('div');
container.innerHTML = html;
let decoded = (container.innerText || container.textContent || '');
// Normalize line endings and collapse multiple blank lines
decoded = decoded
.replace(/\r/g, '')
Expand Down
7 changes: 5 additions & 2 deletions src/shared/components/RichTextDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ const sanitizedContent = computed(() => {
});

const isEmpty = computed(() => {
// Vérifier si le contenu est vide après suppression des balises
const textOnly = sanitizedContent.value.replace(/<[^>]*>/g, '').trim();
// Vérifier si le contenu est vide après suppression des balises,
// en extrayant le texte depuis un conteneur DOM temporaire plutôt que via une regex
const container = document.createElement('div');
container.innerHTML = sanitizedContent.value;
const textOnly = (container.textContent || '').trim();
return !textOnly;
});
</script>
Expand Down