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 (
|
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
|
<Form
|
||||||
className="w-full max-w-2xl flex flex-col gap-4"
|
className="w-full max-w-2xl flex flex-col gap-4"
|
||||||
validationErrors={errors}
|
validationErrors={errors}
|
||||||
|
@ -282,7 +282,6 @@ export default function CreatePostPage() {
|
||||||
|
|
||||||
<Spacer />
|
<Spacer />
|
||||||
|
|
||||||
<p>Tags</p>
|
|
||||||
{mounted && (
|
{mounted && (
|
||||||
<Select
|
<Select
|
||||||
styles={styles}
|
styles={styles}
|
||||||
|
|
|
@ -151,7 +151,7 @@ export default function PostPage() {
|
||||||
<Spacer y={4} />
|
<Spacer y={4} />
|
||||||
|
|
||||||
<div
|
<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 }}
|
dangerouslySetInnerHTML={{ __html: post.content }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ export default function UserPage() {
|
||||||
<div className="p-8 mt-8">
|
<div className="p-8 mt-8">
|
||||||
<p className="text-3xl">{user.name}</p>
|
<p className="text-3xl">{user.name}</p>
|
||||||
<div
|
<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={{
|
dangerouslySetInnerHTML={{
|
||||||
__html:
|
__html:
|
||||||
user.bio && user.bio != "<p></p>" ? user.bio : "No user bio",
|
user.bio && user.bio != "<p></p>" ? user.bio : "No user bio",
|
||||||
|
|
|
@ -9,7 +9,6 @@ import {
|
||||||
Bold,
|
Bold,
|
||||||
Code,
|
Code,
|
||||||
Highlighter,
|
Highlighter,
|
||||||
ImageIcon,
|
|
||||||
Italic,
|
Italic,
|
||||||
LinkIcon,
|
LinkIcon,
|
||||||
Minus,
|
Minus,
|
||||||
|
@ -22,8 +21,6 @@ import {
|
||||||
Undo,
|
Undo,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import EditorMenuButton from "./EditorMenuButton";
|
import EditorMenuButton from "./EditorMenuButton";
|
||||||
import { toast } from "react-toastify";
|
|
||||||
import { getCookie } from "@/helpers/cookie";
|
|
||||||
|
|
||||||
type EditorMenuProps = {
|
type EditorMenuProps = {
|
||||||
editor: Editor | null;
|
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 = [
|
const buttons = [
|
||||||
{
|
{
|
||||||
icon: <Bold size={20} />,
|
icon: <Bold size={20} />,
|
||||||
|
@ -161,12 +90,6 @@ export default function EditorMenuBar({ editor }: EditorMenuProps) {
|
||||||
disabled: false,
|
disabled: false,
|
||||||
isActive: editor.isActive("link"),
|
isActive: editor.isActive("link"),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
icon: <ImageIcon size={20} />,
|
|
||||||
onClick: addImage,
|
|
||||||
disabled: false,
|
|
||||||
isActive: false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
icon: <Minus size={20} />,
|
icon: <Minus size={20} />,
|
||||||
onClick: () => editor.chain().focus().setHorizontalRule().run(),
|
onClick: () => editor.chain().focus().setHorizontalRule().run(),
|
||||||
|
|
|
@ -129,7 +129,6 @@ export default function Editor({
|
||||||
const allowedTypes = [
|
const allowedTypes = [
|
||||||
"image/jpeg", // JPEG images
|
"image/jpeg", // JPEG images
|
||||||
"image/png", // PNG images
|
"image/png", // PNG images
|
||||||
"image/apng", // APNG images
|
|
||||||
"image/gif", // GIF images
|
"image/gif", // GIF images
|
||||||
"image/webp", // WebP images
|
"image/webp", // WebP images
|
||||||
"image/svg+xml", // SVG images
|
"image/svg+xml", // SVG images
|
||||||
|
|
|
@ -45,7 +45,7 @@ export default function CommentCard({ comment }: { comment: CommentType }) {
|
||||||
<Spacer y={4} />
|
<Spacer y={4} />
|
||||||
|
|
||||||
<div
|
<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 }}
|
dangerouslySetInnerHTML={{ __html: comment.content }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ export default function PostCard({
|
||||||
<Spacer y={4} />
|
<Spacer y={4} />
|
||||||
|
|
||||||
<div
|
<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 }}
|
dangerouslySetInnerHTML={{ __html: post.content }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ export function sanitize(content: string) {
|
||||||
allowedAttributes: {
|
allowedAttributes: {
|
||||||
img: ["src", "style"],
|
img: ["src", "style"],
|
||||||
p: ["style"],
|
p: ["style"],
|
||||||
a: ["target", "rel", "href"],
|
|
||||||
},
|
},
|
||||||
allowedStyles: {
|
allowedStyles: {
|
||||||
img: {
|
img: {
|
||||||
|
|
Loading…
Reference in a new issue