denwa-react-shared
Version:
74 lines (73 loc) • 2.18 kB
TypeScript
import { RefObject } from 'react';
import { RenderElementProps, RenderLeafProps } from 'slate-react';
import { Range } from 'slate';
export interface BaseTextEditorRefMethods {
resetData: () => void;
setValue: (value: string) => void;
}
export interface BaseTextEditorProps {
ref: RefObject<BaseTextEditorRefMethods | null>;
boldText: string;
italicText: string;
underlineText: string;
numberedListText: string;
bulletedListText: string;
leftText: string;
centerText: string;
rightText: string;
justifyText: string;
linkErrorText: string;
linkButtonTooltipText: string;
removeLinkTooltipText: string;
imageButtonTooltipText?: string;
language: string;
readOnly?: boolean;
onSetContent: (contentJSON: string, lang: string) => void;
onSetHtml: (html: string, lang: string) => void;
onErrorMessage: (error: string) => void;
onUploadImage?: (file: File) => Promise<{
url: string;
pictureData?: PictureData;
} | null>;
}
export interface ElementProps extends RenderElementProps {
element: any;
}
export interface LeafProps extends RenderLeafProps {
leaf: any;
}
export type ElementTypes = 'title' | 'subtitle' | 'paragraph' | 'note' | 'info' | 'list-item' | 'numbered-list' | 'bulleted-list' | 'image' | 'link';
export interface PictureData {
image1x: string;
image2x?: string;
image1xWebp?: string;
image2xWebp?: string;
image1xAvif?: string;
image2xAvif?: string;
mobileImage1x?: string;
mobileImage2x?: string;
mobileImage1xWebp?: string;
mobileImage2xWebp?: string;
mobileImage1xAvif?: string;
mobileImage2xAvif?: string;
}
export type CustomElement = {
type: ElementTypes;
url?: string | ArrayBuffer | null;
href?: string;
align?: 'left' | 'center' | 'right' | 'justify';
pictureData?: PictureData;
alt?: string;
children: CustomText[];
selection?: Range | null;
};
export type CustomText = {
text: string;
bold?: boolean;
italic?: boolean;
underline?: boolean;
};
export interface ITranslateContentNode {
text: string;
children: ITranslateContentNode[];
}