Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfeng33 committed Mar 27, 2024
1 parent c4f4688 commit 62b5fb5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import { cn } from '@udecode/cn';
import { TIndentElement } from '@udecode/plate-indent';
import {
LiComponentProps,
MarkerComponentProps,
} from '@udecode/plate-indent-list';

export const FireMarker = (props: any) => {
export const FireMarker = (props: MarkerComponentProps) => {
const { element } = props;

return (
<div contentEditable={false}>
<span style={{ left: -26, top: -1, position: 'absolute' }}>
{element.indent % 2 === 0 ? '🔥' : '🚀'}
{(element as TIndentElement).indent % 2 === 0 ? '🔥' : '🚀'}
</span>
</div>
);
};

export const FireLiComponent = (props: any) => {
const { element, children } = props;
return (
<span
className={cn(element.checked && 'text-muted-foreground line-through')}
>
{children}
</span>
);
export const FireLiComponent = (props: LiComponentProps) => {
const { children } = props;
return <span>{children}</span>;
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { cn } from '@udecode/cn';
import {
LiComponentProps,
MarkerComponentProps,
} from '@udecode/plate-indent-list';
import { setNodes } from '@udecode/slate';
import { findNodePath } from '@udecode/slate-react';

import { Checkbox } from './checkbox';

export const TodoMarker = (props: any) => {
export const TodoMarker = (props: MarkerComponentProps) => {
const { editor, element } = props;

const onChange = (v: boolean) => {
Expand All @@ -16,18 +20,20 @@ export const TodoMarker = (props: any) => {
<div contentEditable={false}>
<Checkbox
style={{ left: -24, top: 4, position: 'absolute' }}
checked={element.checked}
checked={element.checked as boolean}
onCheckedChange={onChange}
/>
</div>
);
};

export const IndentTodoLiComponent = (props: any) => {
export const IndentTodoLiComponent = (props: LiComponentProps) => {
const { element, children } = props;
return (
<span
className={cn(element.checked && 'text-muted-foreground line-through')}
className={cn(
(element.checked as boolean) && 'text-muted-foreground line-through'
)}
>
{children}
</span>
Expand Down
10 changes: 3 additions & 7 deletions packages/indent-list/src/createIndentListPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import {
import { injectIndentListComponent } from './injectIndentListComponent';
import { onKeyDownIndentList } from './onKeyDownIndentList';
import { GetSiblingIndentListOptions } from './queries/getSiblingIndentList';
import {
ILiComponentProps,
IMarkerComponentProps,
ListStyleType,
} from './types';
import { LiComponentProps, ListStyleType, MarkerComponentProps } from './types';
import { withIndentList } from './withIndentList';

export const KEY_LIST_STYLE_TYPE = 'listStyleType';
Expand All @@ -37,8 +33,8 @@ export interface IndentListPlugin {
string,
{
type: string;
markerComponent?: React.FC<IMarkerComponentProps>;
liComponent?: React.FC<ILiComponentProps>;
markerComponent?: React.FC<MarkerComponentProps>;
liComponent?: React.FC<LiComponentProps>;
isNumbered?: boolean;
}
>;
Expand Down
4 changes: 2 additions & 2 deletions packages/indent-list/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ export enum ListStyleType {
Inherit = 'inherit',
}

export interface ILiComponentProps {
export interface LiComponentProps {
element: TElement;
children: any;
}

export interface IMarkerComponentProps {
export interface MarkerComponentProps {
onChange?: (checked: boolean) => void;
element: TElement;
editor: PlateEditor<Value>;
Expand Down

0 comments on commit 62b5fb5

Please sign in to comment.