Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a531df8bd |
@@ -155,7 +155,7 @@ export default function PostsScreen() {
|
|||||||
router.push({
|
router.push({
|
||||||
pathname: "/(tabs)/compose",
|
pathname: "/(tabs)/compose",
|
||||||
params: {
|
params: {
|
||||||
prefillContent: post.content,
|
prefillContent: stripHtml(post.content),
|
||||||
prefillIntegrationIds: integrations.map((i) => i.id).join(","),
|
prefillIntegrationIds: integrations.map((i) => i.id).join(","),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
export function stripHtml(html: string): string {
|
export function stripHtml(html: string): string {
|
||||||
return html
|
// Decode entities first so encoded tags like <p> are also stripped
|
||||||
.replace(/<br\s*\/?>/gi, "\n")
|
let s = html
|
||||||
.replace(/<\/p>/gi, "\n")
|
|
||||||
.replace(/<[^>]+>/g, "")
|
|
||||||
.replace(/&/g, "&")
|
.replace(/&/g, "&")
|
||||||
.replace(/</g, "<")
|
.replace(/</g, "<")
|
||||||
.replace(/>/g, ">")
|
.replace(/>/g, ">")
|
||||||
.replace(/"/g, '"')
|
.replace(/"/g, '"')
|
||||||
.replace(/'/g, "'")
|
.replace(/'/g, "'")
|
||||||
.replace(/ /g, " ")
|
.replace(/ /g, " ");
|
||||||
.replace(/\n{3,}/g, "\n\n")
|
// Block-level tags → newlines
|
||||||
.trim();
|
s = s
|
||||||
|
.replace(/<br\s*\/?>/gi, "\n")
|
||||||
|
.replace(/<\/p>/gi, "\n")
|
||||||
|
.replace(/<\/div>/gi, "\n")
|
||||||
|
.replace(/<\/li>/gi, "\n");
|
||||||
|
// Strip all remaining tags
|
||||||
|
s = s.replace(/<[^>]+>/g, "");
|
||||||
|
return s.replace(/\n{3,}/g, "\n\n").trim();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user