@edtr-io/plugin-text
Version:
## Table of contents
215 lines (193 loc) • 4.84 kB
TypeScript
/// <reference types="react" />
import { DeepPartial } from '@edtr-io/ui';
import { Descendant } from 'slate';
import { EditorPlugin } from '@edtr-io/plugin';
import { EditorPluginProps } from '@edtr-io/plugin';
import { Range as Range_2 } from 'slate';
import { SerializedScalarStateType } from '@edtr-io/plugin';
declare interface ColorsTheme {
colors: string[];
defaultColor: string;
}
/**
* @param config - {@link TextEditorConfig | Plugin configuration}
* @returns The text plugin
* @public
*/
export declare const createTextPlugin: (config: TextEditorConfig) => EditorPlugin<TextEditorState, TextEditorConfig>;
/** @public */
export declare type CustomElement = Paragraph | OrderedList | UnorderedList | ListItem | ListItemText | Heading | Link | MathElement;
/** @public */
export declare interface CustomText {
text: string;
strong?: true;
em?: true;
code?: true;
color?: number;
}
/** @public */
export declare interface Heading {
type: 'h';
level: 1 | 2 | 3;
children: CustomText[];
}
declare interface I18n {
blockquote: {
toggleTitle: string;
};
code: {
toggleTitle: string;
};
colors: {
setColorTitle: string;
resetColorTitle: string;
openMenuTitle: string;
closeMenuTitle: string;
colorNames: string[];
};
headings: {
setHeadingTitle(level: Heading['level']): string;
openMenuTitle: string;
closeMenuTitle: string;
};
link: {
toggleTitle: string;
placeholder: string;
openInNewTabTitle: string;
};
list: {
toggleOrderedList: string;
toggleUnorderedList: string;
openMenuTitle: string;
closeMenuTitle: string;
};
math: {
toggleTitle: string;
displayBlockLabel: string;
placeholder: string;
editors: {
visual: string;
latex: string;
noVisualEditorAvailableMessage: string;
};
helpText(KeySpan: React.ComponentType<{
children: React.ReactNode;
}>): React.ReactNode;
};
richText: {
toggleStrongTitle: string;
toggleEmphasizeTitle: string;
};
suggestions: {
noResultsMessage: string;
};
}
/** @public */
export declare interface Link {
type: 'a';
href: string;
children: CustomText[];
}
/** @public */
export declare interface ListItem {
type: 'list-item';
children: ListItemText[];
}
/** @public */
export declare interface ListItemText {
type: 'list-item-child';
children: CustomText[];
}
/** @public */
export declare interface MathElement {
type: 'math';
src: string;
inline: boolean;
children: CustomText[];
}
/** @public */
export declare interface OrderedList {
type: 'ordered-list';
children: ListItem[];
}
/** @public */
export declare interface Paragraph {
type: 'p';
children: CustomText[];
}
/** @public */
export declare interface TextEditorConfig {
placeholder?: TextEditorPluginConfig['placeholder'];
controls?: TextEditorControl[];
i18n?: DeepPartial<TextEditorPluginConfig['i18n']>;
theme?: DeepPartial<TextEditorPluginConfig['theme']>;
blockquote?: string;
noLinebreaks?: boolean;
}
/** @public */
export declare enum TextEditorControl {
code = "code",
colors = "colors",
headings = "headings",
katex = "katex",
links = "links",
lists = "lists",
math = "math",
paragraphs = "paragraphs",
richText = "richText"
}
/** @public */
export declare interface TextEditorPluginConfig {
placeholder: string;
controls: TextEditorControl[];
i18n: I18n;
theme: Theme;
blockquote?: string;
noLinebreaks?: boolean;
}
/** @public */
export declare type TextEditorProps = EditorPluginProps<TextEditorState, TextEditorConfig>;
/** @public */
export declare type TextEditorState = SerializedScalarStateType<Descendant[], {
value: Descendant[];
selection: Range_2 | null;
}>;
declare interface Theme {
backgroundColor: string;
color: string;
hoverColor: string;
borderColor: string;
borderRadius: string;
active: {
backgroundColor: string;
color: string;
};
dropDown: {
backgroundColor: string;
};
suggestions: {
background: {
default: string;
highlight: string;
};
text: {
default: string;
highlight: string;
};
};
overlay: {
backgroundColor: string;
boxShadow: string;
color: string;
};
controls: {
colors: ColorsTheme;
headings: Heading['level'][];
};
}
/** @public */
export declare interface UnorderedList {
type: 'unordered-list';
children: ListItem[];
}
export { }