Skip to content

Commit

Permalink
Merge pull request #3790 from udecode/histor/media-placeholder
Browse files Browse the repository at this point in the history
Histor/media placeholder
  • Loading branch information
zbeyens committed Nov 19, 2024
1 parent 4ae99c0 commit 3ee1699
Show file tree
Hide file tree
Showing 57 changed files with 233 additions and 172 deletions.
4 changes: 2 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const nextConfig = {
async redirects() {
return [
{
source: '/',
destination: '/editor',
permanent: true,
permanent: false,
source: '/',
},
];
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"tailwindcss-animate": "1.0.7"
},
"devDependencies": {
"eslint-plugin-prettier": "^5.2.1",
"@types/node": "^22.9.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
Expand Down
39 changes: 39 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 0 additions & 26 deletions src/app/api/uploadthing/core.ts

This file was deleted.

27 changes: 25 additions & 2 deletions src/app/api/uploadthing/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
import { createRouteHandler } from 'uploadthing/next';
import type { FileRouter } from 'uploadthing/next';

import { ourFileRouter } from './core';
import { createRouteHandler, createUploadthing } from 'uploadthing/next';

const f = createUploadthing();

// FileRouter for your app, can contain multiple FileRoutes
const ourFileRouter = {
// Define as many FileRoutes as you like, each with a unique routeSlug
imageUploader: f(['image', 'text', 'blob', 'pdf', 'video', 'audio'])
// Set permissions and file types for this FileRoute
.middleware(async ({ req }) => {
// This code runs on your server before upload

// Whatever is returned here is accessible in onUploadComplete as `metadata`
return {};
})
.onUploadComplete(({ file, metadata }) => {
// This code RUNS ON YOUR SERVER after upload

// !!! Whatever is returned here is sent to the clientside `onClientUploadComplete` callback
return { file };
}),
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;

// Export routes for Next App Router
export const { GET, POST } = createRouteHandler({
Expand Down
50 changes: 25 additions & 25 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
import Image from "next/image";
import Image from 'next/image';

export default function Home() {
return (
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
<main className="flex flex-col gap-8 row-start-2 items-center sm:items-start">
<div className="grid min-h-screen grid-rows-[20px_1fr_20px] items-center justify-items-center gap-16 p-8 pb-20 font-[family-name:var(--font-geist-sans)] sm:p-20">
<main className="row-start-2 flex flex-col items-center gap-8 sm:items-start">
<Image
className="dark:invert"
src="https://nextjs.org/icons/next.svg"
alt="Next.js logo"
width={180}
height={38}
src="https://nextjs.org/icons/next.svg"
width={180}
priority
/>
<ol className="list-inside list-decimal text-sm text-center sm:text-left font-[family-name:var(--font-geist-mono)]">
<ol className="list-inside list-decimal text-center font-[family-name:var(--font-geist-mono)] text-sm sm:text-left">
<li className="mb-2">
Get started by editing{" "}
<code className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-semibold">
Get started by editing{' '}
<code className="rounded bg-black/[.05] px-1 py-0.5 font-semibold dark:bg-white/[.06]">
app/page.tsx
</code>
.
</li>
<li>Save and see your changes instantly.</li>
</ol>

<div className="flex gap-4 items-center flex-col sm:flex-row">
<div className="flex flex-col items-center gap-4 sm:flex-row">
<a
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5"
className="bg-foreground text-background flex h-10 items-center justify-center gap-2 rounded-full border border-solid border-transparent px-4 text-sm transition-colors hover:bg-[#383838] sm:h-12 sm:px-5 sm:text-base dark:hover:bg-[#ccc]"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
target="_blank"
>
<Image
className="dark:invert"
src="https://nextjs.org/icons/vercel.svg"
alt="Vercel logomark"
width={20}
height={20}
src="https://nextjs.org/icons/vercel.svg"
width={20}
/>
Deploy now
</a>
<a
className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44"
className="flex h-10 items-center justify-center rounded-full border border-solid border-black/[.08] px-4 text-sm transition-colors hover:border-transparent hover:bg-[#f2f2f2] sm:h-12 sm:min-w-44 sm:px-5 sm:text-base dark:border-white/[.145] dark:hover:bg-[#1a1a1a]"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
target="_blank"
>
Read our docs
</a>
</div>
</main>
<footer className="row-start-3 flex gap-6 flex-wrap items-center justify-center">
<footer className="row-start-3 flex flex-wrap items-center justify-center gap-6">
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
target="_blank"
>
<Image
alt="File icon"
aria-hidden
height={16}
src="https://nextjs.org/icons/file.svg"
alt="File icon"
width={16}
height={16}
/>
Learn
</a>
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
target="_blank"
>
<Image
alt="Window icon"
aria-hidden
height={16}
src="https://nextjs.org/icons/window.svg"
alt="Window icon"
width={16}
height={16}
/>
Examples
</a>
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
target="_blank"
>
<Image
alt="Globe icon"
aria-hidden
height={16}
src="https://nextjs.org/icons/globe.svg"
alt="Globe icon"
width={16}
height={16}
/>
Go to nextjs.org →
</a>
Expand Down
5 changes: 1 addition & 4 deletions src/components/editor/plugins/indent-list-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import {
FireLiComponent,
FireMarker,
} from '@/components/plate-ui/indent-fire-marker';
import {
TodoLi,
TodoMarker,
} from '@/components/plate-ui/indent-todo-marker';
import { TodoLi, TodoMarker } from '@/components/plate-ui/indent-todo-marker';

export const indentListPlugins = [
IndentPlugin.extend({
Expand Down
4 changes: 2 additions & 2 deletions src/components/plate-ui/ai-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ export function AIMenu() {
)}

{isLoading ? (
<div className="flex grow select-none items-center gap-2 p-2 text-sm text-muted-foreground">
<div className="text-muted-foreground flex grow select-none items-center gap-2 p-2 text-sm">
<Loader2Icon className="size-4 animate-spin" />
{messages.length > 1 ? 'Editing...' : 'Thinking...'}
</div>
) : (
<InputCommand
variant="ghost"
className="rounded-none border-b border-solid border-border [&_svg]:hidden"
className="border-border rounded-none border-b border-solid [&_svg]:hidden"
value={input}
onKeyDown={(e) => {
if (isHotkey('backspace')(e) && input.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/plate-ui/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export const AvatarImage = withCn(

export const AvatarFallback = withCn(
AvatarPrimitive.Fallback,
'flex size-full items-center justify-center rounded-full bg-muted'
'bg-muted flex size-full items-center justify-center rounded-full'
);
6 changes: 3 additions & 3 deletions src/components/plate-ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cn, withRef } from '@udecode/cn';
import { type VariantProps, cva } from 'class-variance-authority';

export const buttonVariants = cva(
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
'ring-offset-background focus-visible:ring-ring inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
{
defaultVariants: {
size: 'sm',
Expand All @@ -28,10 +28,10 @@ export const buttonVariants = cva(
destructive:
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
ghost: 'hover:bg-accent hover:text-accent-foreground',
inlineLink: 'text-base text-primary underline underline-offset-4',
inlineLink: 'text-primary text-base underline underline-offset-4',
link: 'text-primary underline-offset-4 hover:underline',
outline:
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
'border-input bg-background hover:bg-accent hover:text-accent-foreground border',
secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/plate-ui/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const Checkbox = withRef<typeof CheckboxPrimitive.Root>(
<CheckboxPrimitive.Root
ref={ref}
className={cn(
'peer size-4 shrink-0 rounded-sm border border-primary bg-background ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
'border-primary bg-background ring-offset-background focus-visible:ring-ring data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground peer size-4 shrink-0 rounded-sm border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
className
)}
{...props}
Expand Down
2 changes: 1 addition & 1 deletion src/components/plate-ui/code-block-element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const CodeBlockElement = withRef<typeof PlateElement>(
className={cn('relative py-1', state.className, className)}
{...props}
>
<pre className="overflow-x-auto rounded-md bg-muted px-6 py-8 font-mono text-sm leading-[normal] [tab-size:2]">
<pre className="bg-muted overflow-x-auto rounded-md px-6 py-8 font-mono text-sm leading-[normal] [tab-size:2]">
<code>{children}</code>
</pre>

Expand Down
2 changes: 1 addition & 1 deletion src/components/plate-ui/code-leaf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const CodeLeaf = withRef<typeof PlateLeaf>(
ref={ref}
asChild
className={cn(
'whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm',
'bg-muted whitespace-pre-wrap rounded-md px-[0.3em] py-[0.2em] font-mono text-sm',
className
)}
{...props}
Expand Down
2 changes: 1 addition & 1 deletion src/components/plate-ui/color-dropdown-menu-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function ColorDropdownMenuItem({
size: 'icon',
variant: 'outline',
}),
'my-1 flex size-6 items-center justify-center rounded-full border border-solid border-muted p-0 transition-all hover:scale-125',
'border-muted my-1 flex size-6 items-center justify-center rounded-full border border-solid p-0 transition-all hover:scale-125',
!isBrightColor && 'border-transparent text-white hover:!text-white',
className
)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/plate-ui/column-group-element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function ColumnFloatingToolbar({ children }: React.PropsWithChildren) {
side="top"
sideOffset={10}
>
<div className="box-content flex items-center [&_svg]:size-4 [&_svg]:text-muted-foreground">
<div className="[&_svg]:text-muted-foreground box-content flex items-center [&_svg]:size-4">
<Button size="icon" variant="ghost" onClick={setDoubleColumn}>
<DoubleColumnOutlined />
</Button>
Expand Down
Loading

0 comments on commit 3ee1699

Please sign in to comment.