-
-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a00478
commit 298a0ad
Showing
13 changed files
with
722 additions
and
142 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
49 changes: 49 additions & 0 deletions
49
apps/www/src/registry/default/plate-static-ui/image-element.tsx
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
|
||
import type { StaticElementProps } from '@udecode/plate-common'; | ||
import type { TImageElement } from '@udecode/plate-media'; | ||
|
||
import { cn } from '@udecode/cn'; | ||
import { PlateStaticElement } from '@udecode/plate-common'; | ||
|
||
export function ImageStaticElement({ | ||
children, | ||
className, | ||
element, | ||
nodeProps, | ||
...props | ||
}: StaticElementProps) { | ||
const { | ||
align = 'center', | ||
url, | ||
width, | ||
} = element as TImageElement & { | ||
width: number; | ||
}; | ||
|
||
return ( | ||
<PlateStaticElement | ||
className={cn('py-2.5', className)} | ||
element={element} | ||
{...props} | ||
> | ||
<figure | ||
className="group relative m-0" | ||
style={{ textAlign: align, width: width }} | ||
> | ||
<div style={{ width: width }}> | ||
<img | ||
className={cn( | ||
'inline-block w-full max-w-full object-cover px-0', | ||
'rounded-sm' | ||
)} | ||
alt="" | ||
src={url} | ||
{...nodeProps} | ||
/> | ||
</div> | ||
</figure> | ||
{children} | ||
</PlateStaticElement> | ||
); | ||
} |
31 changes: 31 additions & 0 deletions
31
apps/www/src/registry/default/plate-static-ui/media-audio-element.tsx
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
|
||
import type { StaticElementProps } from '@udecode/plate-common'; | ||
import type { TAudioElement } from '@udecode/plate-media'; | ||
|
||
import { cn } from '@udecode/cn'; | ||
import { PlateStaticElement } from '@udecode/plate-common'; | ||
|
||
export function MediaAudioStaticElement({ | ||
children, | ||
className, | ||
element, | ||
...props | ||
}: StaticElementProps) { | ||
const { url } = element as TAudioElement; | ||
|
||
return ( | ||
<PlateStaticElement | ||
className={cn('relative mb-1', className)} | ||
element={element} | ||
{...props} | ||
> | ||
<figure className="group relative"> | ||
<div className="h-16"> | ||
<audio className="size-full" src={url} controls /> | ||
</div> | ||
</figure> | ||
{children} | ||
</PlateStaticElement> | ||
); | ||
} |
36 changes: 36 additions & 0 deletions
36
apps/www/src/registry/default/plate-static-ui/media-file-element.tsx
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
|
||
import type { StaticElementProps } from '@udecode/plate-common'; | ||
import type { TFileElement } from '@udecode/plate-media'; | ||
|
||
import { cn } from '@udecode/cn'; | ||
import { PlateStaticElement } from '@udecode/plate-common'; | ||
import { FileUp } from 'lucide-react'; | ||
|
||
export const MediaFileStaticElement = ({ | ||
children, | ||
className, | ||
element, | ||
...props | ||
}: StaticElementProps) => { | ||
const { name } = element as TFileElement; | ||
|
||
return ( | ||
<PlateStaticElement | ||
className={cn('relative my-px rounded-sm', className)} | ||
element={element} | ||
{...props} | ||
> | ||
<div | ||
className="hover:bg-muted group relative m-0 flex cursor-pointer items-center rounded px-0.5 py-[3px]" | ||
role="button" | ||
> | ||
<div className="flex items-center gap-1 p-1"> | ||
<FileUp className="size-5" /> | ||
<div>{name}</div> | ||
</div> | ||
</div> | ||
{children} | ||
</PlateStaticElement> | ||
); | ||
}; |
38 changes: 38 additions & 0 deletions
38
apps/www/src/registry/default/plate-static-ui/media-video-element.tsx
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
|
||
import type { StaticElementProps } from '@udecode/plate-common'; | ||
import type { TVideoElement } from '@udecode/plate-media'; | ||
|
||
import { cn } from '@udecode/cn'; | ||
import { PlateStaticElement } from '@udecode/plate-common'; | ||
|
||
export function MediaVideoStaticElement({ | ||
children, | ||
className, | ||
element, | ||
...props | ||
}: StaticElementProps) { | ||
const { align, url, width } = element as TVideoElement & { | ||
width: number; | ||
}; | ||
|
||
console.log('🚀 ~ align:', align); | ||
|
||
return ( | ||
<PlateStaticElement | ||
className={cn('relative my-px rounded-sm', className)} | ||
element={element} | ||
{...props} | ||
> | ||
<div style={{ textAlign: align }}> | ||
<video | ||
className="inline-block" | ||
src={url} | ||
width={width} | ||
controls | ||
></video> | ||
</div> | ||
{children} | ||
</PlateStaticElement> | ||
); | ||
} |
Oops, something went wrong.