Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfeng33 committed Mar 4, 2025
1 parent 26164cb commit d1c3774
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/www/content/docs/en/components/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Use the [CLI](https://platejs.org/docs/components/cli) to install the latest ver
### March 2 #20.2

- `block-suggestion`: fix styles
- `suggestion-leaf-static`: add static versions

### March 1 #20.1

Expand Down
46 changes: 46 additions & 0 deletions apps/www/src/registry/default/plate-ui/suggestion-leaf-static.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';

import { cn } from '@udecode/cn';
import { type SlateLeafProps, SlateLeaf } from '@udecode/plate';
import {
type TSuggestionText,
BaseSuggestionPlugin,
} from '@udecode/plate-suggestion';
import { useEditorPlugin } from '@udecode/plate/react';

export function SuggestionLeafStatic(props: SlateLeafProps) {
const { children, className, leaf } = props;

const { api } = useEditorPlugin(BaseSuggestionPlugin);

const dataList = api.suggestion.dataList(leaf as TSuggestionText);

const hasRemove = dataList.some((data) => data.type === 'remove');

const diffOperation = {
type: hasRemove ? 'delete' : 'insert',
} as const;

const Component = (
{
delete: 'del',
insert: 'ins',
update: 'span',
} as const
)[diffOperation.type];

return (
<SlateLeaf
{...props}
as={Component}
className={cn(
'border-b-2 border-b-brand/[.24] bg-brand/[.08] text-brand/80 no-underline transition-colors duration-200',
hasRemove &&
'border-b-gray-300 bg-gray-300/25 text-gray-400 line-through',
className
)}
>
{children}
</SlateLeaf>
);
}
5 changes: 4 additions & 1 deletion apps/www/src/registry/registry-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,10 @@ export const uiNodes: Registry['items'] = [
docs: [{ route: '/docs/suggestion' }],
examples: ['comments-demo', 'comments-pro'],
},
files: [{ path: 'plate-ui/suggestion-leaf.tsx', type: 'registry:ui' }],
files: [
{ path: 'plate-ui/suggestion-leaf.tsx', type: 'registry:ui' },
{ path: 'plate-ui/suggestion-leaf-static.tsx', type: 'registry:ui' },
],
name: 'suggestion-leaf',
registryDependencies: ['suggestion-plugin'],
type: 'registry:ui',
Expand Down

0 comments on commit d1c3774

Please sign in to comment.