-
-
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
5b8072d
commit ff2db0c
Showing
23 changed files
with
336 additions
and
452 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
12 changes: 12 additions & 0 deletions
12
apps/www/src/registry/default/plate-static-ui/blockquote-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,12 @@ | ||
import type { StaticElementProps } from '@udecode/plate-core'; | ||
|
||
export const BlockquoteStaticElement = ({ | ||
attributes, | ||
children, | ||
}: StaticElementProps) => { | ||
return ( | ||
<blockquote className="my-1 border-l-2 pl-6 italic" {...attributes}> | ||
{children} | ||
</blockquote> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
apps/www/src/registry/default/plate-static-ui/code-block-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,22 @@ | ||
import type { TCodeBlockElement } from '@udecode/plate-code-block'; | ||
import type { StaticElementProps } from '@udecode/plate-core'; | ||
|
||
import { cn } from '../lib/utils'; | ||
|
||
export const CodeBlockElementStatic = ( | ||
props: StaticElementProps<TCodeBlockElement> | ||
) => { | ||
const { attributes, children, element } = props; | ||
|
||
const codeClassName = element?.lang | ||
? `${element.lang} language-${element.lang}` | ||
: ''; | ||
|
||
return ( | ||
<div className={cn('relative py-1', codeClassName)} {...attributes}> | ||
<pre className="overflow-x-auto rounded-md bg-muted px-6 py-8 font-mono text-sm leading-[normal] [tab-size:2]"> | ||
<code>{children}</code> | ||
</pre> | ||
</div> | ||
); | ||
}; |
11 changes: 11 additions & 0 deletions
11
apps/www/src/registry/default/plate-static-ui/code-leaf.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,11 @@ | ||
import type { StaticLeafProps } from '@udecode/plate-core'; | ||
|
||
export const CodeStaticLeaf = ({ attributes, children }: StaticLeafProps) => { | ||
return ( | ||
<span {...attributes}> | ||
<code className="whitespace-pre-wrap rounded-md bg-muted px-[0.3em] py-[0.2em] font-mono text-sm"> | ||
{children} | ||
</code> | ||
</span> | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
apps/www/src/registry/default/plate-static-ui/code-line-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,7 @@ | ||
import type { StaticElementProps } from '@udecode/plate-core'; | ||
|
||
export const CodeLineStaticElement = (props: StaticElementProps) => { | ||
const { children } = props; | ||
|
||
return <div>{children}</div>; | ||
}; |
5 changes: 5 additions & 0 deletions
5
apps/www/src/registry/default/plate-static-ui/code-syntax-leaf.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,5 @@ | ||
import type { StaticLeafProps } from '@udecode/plate-core'; | ||
|
||
export function CodeSyntaxStaticLeaf({ children, ...props }: StaticLeafProps) { | ||
return <div {...props}>{children}</div>; | ||
} |
21 changes: 21 additions & 0 deletions
21
apps/www/src/registry/default/plate-static-ui/heading-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,21 @@ | ||
import type { StaticElementProps } from '@udecode/plate-core'; | ||
|
||
import { headingVariants } from '../plate-ui/heading-element'; | ||
|
||
interface HeadingElementViewProps extends StaticElementProps { | ||
variant?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; | ||
} | ||
|
||
export const HeadingStaticElement = ({ | ||
attributes, | ||
children, | ||
variant = 'h1', | ||
}: HeadingElementViewProps) => { | ||
const Component = variant as any; | ||
|
||
return ( | ||
<Component className={headingVariants({ variant })} {...attributes}> | ||
{children} | ||
</Component> | ||
); | ||
}; |
18 changes: 18 additions & 0 deletions
18
apps/www/src/registry/default/plate-static-ui/paragraph-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,18 @@ | ||
import type { StaticElementProps, StaticLeafProps } from '@udecode/plate-core'; | ||
|
||
export const ParagraphStaticElement = ({ | ||
attributes, | ||
children, | ||
}: StaticElementProps) => { | ||
return ( | ||
<div className="m-0 px-0 py-1" {...attributes}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export function PlateStaticLeaf({ as, attributes, children }: StaticLeafProps) { | ||
const Leaf = (as ?? 'span') as any; | ||
|
||
return <Leaf {...attributes}>{children}</Leaf>; | ||
} |
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
82 changes: 32 additions & 50 deletions
82
apps/www/src/registry/default/plate-ui/code-block-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 |
---|---|---|
@@ -1,57 +1,39 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
|
||
import type { TCodeBlockElement } from '@udecode/plate-code-block'; | ||
import type { StaticElementProps } from '@udecode/plate-common'; | ||
import { cn, withRef } from '@udecode/cn'; | ||
import { useCodeBlockElementState } from '@udecode/plate-code-block/react'; | ||
|
||
import { cn } from '@udecode/cn'; | ||
import { CodeBlockCombobox } from './code-block-combobox'; | ||
import { PlateElement } from './plate-element'; | ||
|
||
import './code-block-element.css'; | ||
|
||
// export const CodeBlockElement = withRef<typeof PlateElement>( | ||
// ({ children, className, ...props }, ref) => { | ||
// const { element } = props; | ||
|
||
// const state = useCodeBlockElementState({ element }); | ||
|
||
// return ( | ||
// <PlateElement | ||
// ref={ref} | ||
// className={cn('relative py-1', className)} | ||
// {...props} | ||
// > | ||
// <pre className="overflow-x-auto rounded-md bg-muted px-6 py-8 font-mono text-sm leading-[normal] [tab-size:2]"> | ||
// <code>{children}</code> | ||
// </pre> | ||
|
||
// {state.syntax && ( | ||
// <div | ||
// className="absolute right-2 top-2 z-10 select-none" | ||
// contentEditable={false} | ||
// > | ||
// <CodeBlockCombobox /> | ||
// </div> | ||
// )} | ||
// </PlateElement> | ||
// ); | ||
// } | ||
// ); | ||
|
||
export const CodeBlockElementStatic = ( | ||
props: StaticElementProps<TCodeBlockElement> | ||
) => { | ||
const { attributes, children, element } = props; | ||
|
||
const codeClassName = element?.lang | ||
? `${element.lang} language-${element.lang}` | ||
: ''; | ||
|
||
return ( | ||
<div className={cn('relative py-1', codeClassName)} {...attributes}> | ||
<pre className="overflow-x-auto rounded-md bg-muted px-6 py-8 font-mono text-sm leading-[normal] [tab-size:2]"> | ||
<code>{children}</code> | ||
</pre> | ||
</div> | ||
); | ||
}; | ||
export const CodeBlockElement = withRef<typeof PlateElement>( | ||
({ children, className, ...props }, ref) => { | ||
const { element } = props; | ||
|
||
const state = useCodeBlockElementState({ element }); | ||
|
||
return ( | ||
<PlateElement | ||
ref={ref} | ||
className={cn('relative py-1', className)} | ||
{...props} | ||
> | ||
<pre className="overflow-x-auto rounded-md bg-muted px-6 py-8 font-mono text-sm leading-[normal] [tab-size:2]"> | ||
<code>{children}</code> | ||
</pre> | ||
|
||
{state.syntax && ( | ||
<div | ||
className="absolute right-2 top-2 z-10 select-none" | ||
contentEditable={false} | ||
> | ||
<CodeBlockCombobox /> | ||
</div> | ||
)} | ||
</PlateElement> | ||
); | ||
} | ||
); |
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
11 changes: 1 addition & 10 deletions
11
apps/www/src/registry/default/plate-ui/code-line-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 |
---|---|---|
@@ -1,19 +1,10 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
|
||
import type { StaticElementProps } from '@udecode/plate-common'; | ||
|
||
import { withRef } from '@udecode/cn'; | ||
import { withRef } from '@udecode/plate-common/react'; | ||
|
||
import { PlateElement } from './plate-element'; | ||
|
||
export const CodeLineElement = withRef<typeof PlateElement>((props, ref) => ( | ||
<PlateElement ref={ref} {...props} /> | ||
)); | ||
|
||
export const CodeLineStaticElement = (props: StaticElementProps) => { | ||
const { children } = props; | ||
|
||
return <div>{children}</div>; | ||
}; |
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
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
Oops, something went wrong.