import type { Post } from "../classes/post"; import { EmbedDataType } from "../enums"; import { MAX_LENGTH } from "../limits"; import type { BaseElementProps } from "../types"; import { isAltEditableType } from "../utils/helpers"; import { PostContent } from "./post"; interface EditedPostProps extends BaseElementProps { post: Post; }; export function PostAltTextEdit(props: EditedPostProps) { const post: Post = props.post; let num = -1; const embedAltTextEdit = post.embedContent?.map((embedData) => { ++num; if (!isAltEditableType(embedData.type)) return; const thumbURL = (embedData.type == EmbedDataType.Video) ? "thumbs/video.png" : `preview/file/${embedData.content}`; return (

{/* Accessible handlers will be added in via the htmx header */} Edit Alt
); }); const altEditBlock = embedAltTextEdit; if (altEditBlock?.at(0) === undefined || altEditBlock.length <= 0) { return null; } return (
Embed Edits

{altEditBlock}

); } export function PostEdit(props: EditedPostProps) { const post: Post = props.post; // If this post is posted, just show the same object again. if (post.posted) { return (); } // yeah these are kind egregious... const editSpinner: string = `editSpinner-${post.uuid}`; const editResponse: string = `editResponse-${post.uuid}`; const editPostField: string = `edit-${post.uuid}`; const editCountId: string = `editCount-${post.uuid}`; const postFormId: string = `editPost-${post.uuid}`; return (
Character Count: 0/{MAX_LENGTH}
Cancel
); };