-
-
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
a422876
commit c974e6b
Showing
6 changed files
with
355 additions
and
12 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
25 changes: 25 additions & 0 deletions
25
apps/www/src/registry/default/plate-ui/comment-leaf-static.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,25 @@ | ||
import React from 'react'; | ||
|
||
import type { TCommentText } from '@udecode/plate-comments'; | ||
import type { StaticLeafProps } from '@udecode/plate-common'; | ||
|
||
import { cn } from '@udecode/cn'; | ||
import { PlateStaticLeaf } from '@udecode/plate-common'; | ||
|
||
export function CommentLeafStatic({ | ||
children, | ||
className, | ||
...props | ||
}: StaticLeafProps<TCommentText>) { | ||
return ( | ||
<PlateStaticLeaf | ||
className={cn( | ||
'border-b-2 border-b-highlight/35 bg-highlight/15', | ||
className | ||
)} | ||
{...props} | ||
> | ||
<>{children}</> | ||
</PlateStaticLeaf> | ||
); | ||
} |
56 changes: 56 additions & 0 deletions
56
apps/www/src/registry/default/plate-ui/date-element-static.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,56 @@ | ||
import React from 'react'; | ||
|
||
import type { StaticElementProps } from '@udecode/plate-common'; | ||
|
||
import { cn } from '@udecode/cn'; | ||
import { PlateStaticElement } from '@udecode/plate-common'; | ||
|
||
export function DateElementStatic({ | ||
children, | ||
className, | ||
element, | ||
...props | ||
}: StaticElementProps) { | ||
return ( | ||
<PlateStaticElement | ||
className={cn('inline-block', className)} | ||
element={element} | ||
{...props} | ||
> | ||
<span | ||
className={cn('w-fit rounded-sm bg-muted px-1 text-muted-foreground')} | ||
> | ||
{element.date ? ( | ||
(() => { | ||
const today = new Date(); | ||
const elementDate = new Date(element.date as string); | ||
const isToday = | ||
elementDate.getDate() === today.getDate() && | ||
elementDate.getMonth() === today.getMonth() && | ||
elementDate.getFullYear() === today.getFullYear(); | ||
|
||
const isYesterday = | ||
new Date(today.setDate(today.getDate() - 1)).toDateString() === | ||
elementDate.toDateString(); | ||
const isTomorrow = | ||
new Date(today.setDate(today.getDate() + 2)).toDateString() === | ||
elementDate.toDateString(); | ||
|
||
if (isToday) return 'Today'; | ||
if (isYesterday) return 'Yesterday'; | ||
if (isTomorrow) return 'Tomorrow'; | ||
|
||
return elementDate.toLocaleDateString(undefined, { | ||
day: 'numeric', | ||
month: 'long', | ||
year: 'numeric', | ||
}); | ||
})() | ||
) : ( | ||
<span>Pick a date</span> | ||
)} | ||
</span> | ||
{children} | ||
</PlateStaticElement> | ||
); | ||
} |
54 changes: 54 additions & 0 deletions
54
apps/www/src/registry/default/plate-ui/mention-element-static.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,54 @@ | ||
import React from 'react'; | ||
|
||
import type { StaticElementProps } from '@udecode/plate-common'; | ||
import type { TMentionElement } from '@udecode/plate-mention'; | ||
|
||
import { cn } from '@udecode/cn'; | ||
import { IS_APPLE, PlateStaticElement } from '@udecode/plate-common'; | ||
|
||
export function MentionElementStatic({ | ||
children, | ||
className, | ||
element, | ||
prefix, | ||
renderLabel, | ||
...props | ||
}: StaticElementProps & { | ||
prefix?: string; | ||
renderLabel?: (mentionable: TMentionElement) => string; | ||
}) { | ||
return ( | ||
<PlateStaticElement | ||
className={cn( | ||
'inline-block cursor-pointer rounded-md bg-muted px-1.5 py-0.5 align-baseline text-sm font-medium', | ||
element.children[0].bold === true && 'font-bold', | ||
element.children[0].italic === true && 'italic', | ||
element.children[0].underline === true && 'underline', | ||
className | ||
)} | ||
data-slate-value={element.value} | ||
element={element} | ||
{...props} | ||
> | ||
{IS_APPLE ? ( | ||
// Mac OS IME https://github.com/ianstormtaylor/slate/issues/3490 | ||
<React.Fragment> | ||
{children} | ||
{prefix} | ||
{renderLabel | ||
? renderLabel(element as TMentionElement) | ||
: element.value} | ||
</React.Fragment> | ||
) : ( | ||
// Others like Android https://github.com/ianstormtaylor/slate/pull/5360 | ||
<React.Fragment> | ||
{prefix} | ||
{renderLabel | ||
? renderLabel(element as TMentionElement) | ||
: element.value} | ||
{children} | ||
</React.Fragment> | ||
)} | ||
</PlateStaticElement> | ||
); | ||
} |
Oops, something went wrong.