mirror of
https://github.com/Ategon/Jamjar.git
synced 2025-02-12 06:16:21 +00:00
Compare commits
No commits in common. "6cc5aa04657486d979b639925f3f7633b5afa697" and "87878f270a8ed7edebaf1ac2c53de7e3b3e455df" have entirely different histories.
6cc5aa0465
...
87878f270a
9 changed files with 5 additions and 85 deletions
public/images/tags
src
app
components
helpers
Binary file not shown.
Before ![]() (image error) Size: 45 KiB |
|
@ -180,7 +180,7 @@ export default function CreatePostPage() {
|
|||
};
|
||||
|
||||
return (
|
||||
<div className="static flex items-top mt-10 justify-center top-0 left-0 gap-16">
|
||||
<div className="absolute flex items-top mt-40 justify-center top-0 left-0 w-screen h-screen">
|
||||
<Form
|
||||
className="w-full max-w-2xl flex flex-col gap-4"
|
||||
validationErrors={errors}
|
||||
|
@ -282,7 +282,6 @@ export default function CreatePostPage() {
|
|||
|
||||
<Spacer />
|
||||
|
||||
<p>Tags</p>
|
||||
{mounted && (
|
||||
<Select
|
||||
styles={styles}
|
||||
|
|
|
@ -151,7 +151,7 @@ export default function PostPage() {
|
|||
<Spacer y={4} />
|
||||
|
||||
<div
|
||||
className="prose dark:prose-invert !duration-250 !ease-linear !transition-all max-w-full break-words"
|
||||
className="prose dark:prose-invert !duration-250 !ease-linear !transition-all"
|
||||
dangerouslySetInnerHTML={{ __html: post.content }}
|
||||
/>
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ export default function UserPage() {
|
|||
<div className="p-8 mt-8">
|
||||
<p className="text-3xl">{user.name}</p>
|
||||
<div
|
||||
className="prose dark:prose-invert !duration-250 !ease-linear !transition-all max-w-full break-words"
|
||||
className="prose dark:prose-invert !duration-250 !ease-linear !transition-all"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html:
|
||||
user.bio && user.bio != "<p></p>" ? user.bio : "No user bio",
|
||||
|
|
|
@ -9,7 +9,6 @@ import {
|
|||
Bold,
|
||||
Code,
|
||||
Highlighter,
|
||||
ImageIcon,
|
||||
Italic,
|
||||
LinkIcon,
|
||||
Minus,
|
||||
|
@ -22,8 +21,6 @@ import {
|
|||
Undo,
|
||||
} from "lucide-react";
|
||||
import EditorMenuButton from "./EditorMenuButton";
|
||||
import { toast } from "react-toastify";
|
||||
import { getCookie } from "@/helpers/cookie";
|
||||
|
||||
type EditorMenuProps = {
|
||||
editor: Editor | null;
|
||||
|
@ -44,74 +41,6 @@ export default function EditorMenuBar({ editor }: EditorMenuProps) {
|
|||
}
|
||||
};
|
||||
|
||||
const addImage = () => {
|
||||
const input = document.createElement("input");
|
||||
input.type = "file";
|
||||
input.accept = "image/*";
|
||||
input.style.display = "none";
|
||||
|
||||
input.addEventListener("change", handleImageUpload);
|
||||
|
||||
document.body.appendChild(input);
|
||||
input.click();
|
||||
|
||||
// Clean up after the dialog closes
|
||||
input.addEventListener("blur", () => document.body.removeChild(input));
|
||||
};
|
||||
|
||||
async function handleImageUpload(event: Event) {
|
||||
const target = event.target as HTMLInputElement;
|
||||
if (!target.files || target.files.length === 0) return;
|
||||
|
||||
const file = target.files[0];
|
||||
const filesize = parseInt((file.size / 1024 / 1024).toFixed(4));
|
||||
|
||||
const allowedTypes = [
|
||||
"image/jpeg", // JPEG images
|
||||
"image/png", // PNG images
|
||||
"image/apng", // APNG images
|
||||
"image/gif", // GIF images
|
||||
"image/webp", // WebP images
|
||||
"image/svg+xml", // SVG images
|
||||
];
|
||||
|
||||
if (!allowedTypes.includes(file.type)) {
|
||||
toast.error("Invalid file format");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (filesize > 8) {
|
||||
toast.error("Image is too big");
|
||||
return false;
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("upload", file);
|
||||
|
||||
fetch(
|
||||
process.env.NEXT_PUBLIC_MODE === "PROD"
|
||||
? "https://d2jam.com/api/v1/image"
|
||||
: "http://localhost:3005/api/v1/image",
|
||||
{
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers: {
|
||||
authorization: `Bearer ${getCookie("token")}`,
|
||||
},
|
||||
credentials: "include",
|
||||
}
|
||||
).then((response) => {
|
||||
if (response.ok) {
|
||||
response.json().then((data) => {
|
||||
toast.success(data.message);
|
||||
editor?.commands.setImage({ src: data.data });
|
||||
});
|
||||
} else {
|
||||
toast.error("Failed to upload image");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const buttons = [
|
||||
{
|
||||
icon: <Bold size={20} />,
|
||||
|
@ -161,12 +90,6 @@ export default function EditorMenuBar({ editor }: EditorMenuProps) {
|
|||
disabled: false,
|
||||
isActive: editor.isActive("link"),
|
||||
},
|
||||
{
|
||||
icon: <ImageIcon size={20} />,
|
||||
onClick: addImage,
|
||||
disabled: false,
|
||||
isActive: false,
|
||||
},
|
||||
{
|
||||
icon: <Minus size={20} />,
|
||||
onClick: () => editor.chain().focus().setHorizontalRule().run(),
|
||||
|
|
|
@ -129,7 +129,6 @@ export default function Editor({
|
|||
const allowedTypes = [
|
||||
"image/jpeg", // JPEG images
|
||||
"image/png", // PNG images
|
||||
"image/apng", // APNG images
|
||||
"image/gif", // GIF images
|
||||
"image/webp", // WebP images
|
||||
"image/svg+xml", // SVG images
|
||||
|
|
|
@ -45,7 +45,7 @@ export default function CommentCard({ comment }: { comment: CommentType }) {
|
|||
<Spacer y={4} />
|
||||
|
||||
<div
|
||||
className="prose dark:prose-invert !duration-250 !ease-linear !transition-all max-w-full break-words"
|
||||
className="prose dark:prose-invert !duration-250 !ease-linear !transition-all"
|
||||
dangerouslySetInnerHTML={{ __html: comment.content }}
|
||||
/>
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ export default function PostCard({
|
|||
<Spacer y={4} />
|
||||
|
||||
<div
|
||||
className="prose dark:prose-invert !duration-250 !ease-linear !transition-all max-w-full break-words"
|
||||
className="prose dark:prose-invert !duration-250 !ease-linear !transition-all"
|
||||
dangerouslySetInnerHTML={{ __html: post.content }}
|
||||
/>
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ export function sanitize(content: string) {
|
|||
allowedAttributes: {
|
||||
img: ["src", "style"],
|
||||
p: ["style"],
|
||||
a: ["target", "rel", "href"],
|
||||
},
|
||||
allowedStyles: {
|
||||
img: {
|
||||
|
|
Loading…
Reference in a new issue