UNPKG

@edtr-io/plugin-text

Version:
171 lines 5.26 kB
import { EditorPlugin, EditorPluginProps, SerializedScalarStateType } from '@edtr-io/plugin'; import { DeepPartial } from '@edtr-io/ui'; import * as React from 'react'; import { BlockJSON, InlineJSON, MarkJSON, ValueJSON } from 'slate'; import { Rule } from 'slate-html-serializer'; import { Editor, EditorProps, Plugin, RenderBlockProps, RenderInlineProps, RenderMarkProps } from 'slate-react'; import { isValueEmpty } from './factory'; import type { SlatePluginClosure } from './factory/types'; import { NewNode } from './state-migration-serializer'; /** @public */ export declare type MarkEditorProps = RenderMarkProps; /** @public */ export interface MarkRendererProps { mark: MarkJSON; } /** @public */ export declare type BlockEditorProps = RenderBlockProps; /** @public */ export declare type InlineEditorProps = RenderInlineProps; /** @public */ export declare type NodeEditorProps = BlockEditorProps | InlineEditorProps; /** @public */ export declare type NodeControlsProps = EditorProps & { editor: Editor; }; /** @public */ export interface InlineRendererProps { node: InlineJSON; } /** @public */ export interface BlockRendererProps { node: BlockJSON; } /** @public */ export declare type NodeRendererProps = BlockRendererProps | InlineRendererProps; /** @public */ export declare type TextPlugin = Plugin & Rule & { commands?: { [key: string]: (editor: Editor, ...args: any[]) => Editor; }; }; /** * @param config - {@link TextConfig | Plugin configuration} * @returns The text plugin * @public */ export declare function createTextPlugin(config: TextConfig): EditorPlugin<TextPluginState, TextConfig>; /** @public */ export interface TextConfig { placeholder?: TextPluginConfig['placeholder']; plugins?: TextConfigPlugins; /** @deprecated */ registry: TextPluginConfig['registry']; i18n?: DeepPartial<TextPluginConfig['i18n']>; theme?: DeepPartial<TextPluginConfig['theme']>; blockquote?: string; noLinebreaks?: boolean; } /** @public */ export interface TextConfigPlugins { code?: boolean; colors?: boolean; headings?: boolean; katex?: boolean; links?: boolean; lists?: boolean; math?: boolean; paragraphs?: boolean; richText?: boolean; suggestions?: boolean; } /** @public */ export declare type TextPluginState = SerializedScalarStateType<NewNode[], ValueJSON>; /** @public */ export interface TextPluginConfig { placeholder: string; enabledPlugins: TextConfigPlugins; plugins: ((pluginClosure: SlatePluginClosure) => TextPlugin)[]; registry: { name: string; title?: string; description?: string; }[]; i18n: { blockquote: { toggleTitle: string; }; code: { toggleTitle: string; }; colors: { setColorTitle: string; resetColorTitle: string; openMenuTitle: string; closeMenuTitle: string; }; headings: { setHeadingTitle(level: number): 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; }; }; theme: { backgroundColor: string; color: string; hoverColor: string; active: { backgroundColor: string; color: string; }; dropDown: { backgroundColor: string; }; suggestions: { background: { default: string; highlight: string; }; text: { default: string; highlight: string; }; }; plugins: { colors: { colors: string[]; defaultColor: string; }; }; }; blockquote?: string; noLinebreaks?: boolean; } /** @public */ export declare type TextProps = EditorPluginProps<TextPluginState, TextConfig>; export { isValueEmpty, SlatePluginClosure }; export type { SlateClosure } from './factory/types'; export * from './state-migration-serializer'; export { slateValueToHtml, htmlToSlateValue } from './model'; //# sourceMappingURL=index.d.ts.map