-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from KennethWussmann/task/fix-previews
- Loading branch information
Showing
10 changed files
with
111 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,22 @@ | ||
import { Card } from "@/components/ui"; | ||
import { useCaptionEditor } from "@/hooks/provider/caption-editor-provider"; | ||
import { settings } from "@/lib/settings"; | ||
import { useAtom } from "jotai/react"; | ||
|
||
export const CaptionPreview = () => { | ||
const { parts } = useCaptionEditor(); | ||
const [separator] = useAtom(settings.caption.separator); | ||
const [endWithSeparator] = useAtom(settings.caption.endWithSeparator); | ||
|
||
let finalText = parts | ||
.map((part) => part.text.trim()) | ||
.join(separator) | ||
.trim(); | ||
|
||
if (endWithSeparator && !finalText.endsWith(separator.trim())) { | ||
finalText += separator; | ||
} | ||
|
||
const isEmpty = parts.length === 0; | ||
|
||
// TODO: Dont write caption to file, but to the database and then export from there to file | ||
// useEffect(() => { | ||
// if (!imageFile || finalText.length < 3) { | ||
// return; | ||
// } | ||
// writeCaption(finalText, imageFile); | ||
// // eslint-disable-next-line react-hooks/exhaustive-deps | ||
// }, [finalText, writeCaption]); | ||
const { preview } = useCaptionEditor(); | ||
|
||
return ( | ||
<div className="my-2 py-2"> | ||
<div className="flex flex-row gap-2 mb-2 font-semibold items-center"> | ||
Preview | ||
</div> | ||
|
||
{isEmpty && ( | ||
{!preview && ( | ||
<Card className="p-1 px-2 italic text-muted-foreground text-center"> | ||
No caption | ||
</Card> | ||
)} | ||
|
||
{!isEmpty && <Card className="p-1 px-2">{finalText}</Card>} | ||
{preview && <Card className="p-1 px-2">{preview}</Card>} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.