import { Editor, Descendant, BaseEditor, BaseElement, Node } from 'slate'; export { BaseElement, BaseSelection, Descendant, Editor, Node, NodeEntry, Path, Range, Transforms } from 'slate'; import { ReactEditor, RenderElementProps } from 'slate-react'; export { ReactEditor, RenderElementProps, Slate, useFocused, useSelected, useSlate } from 'slate-react'; import { HistoryEditor } from 'slate-history'; import React$1, { CSSProperties } from 'react'; type FieldType = "checkbox" | "input" | "label" | "select"; type SelectValue = { value: string; label: string; }; type SelectOptions = SelectValue[]; interface IField { name: string; type: FieldType; label?: string; charSize?: number; options?: SelectOptions; } type IRow = IField | IField[]; type IFieldValues = Record; interface DisplayDialogSettings { title: string; rows: IRow[]; values: IFieldValues; onChange?: (editor: Editor, name: string, value: string, values: IFieldValues) => boolean | undefined; onValidate?: (values: IFieldValues) => IFieldValues | string; onAccept?: (editor: Editor, values: IFieldValues) => void; onClose?: (editor: Editor) => void; } interface IDialogController { display: (settings: DisplayDialogSettings) => void; update: (values: IFieldValues) => void; } declare enum EFormat { bold = "bold", italic = "italic", underlined = "underlined", inserted = "inserted", deleted = "deleted", code = "code", marked = "marked", superscript = "superscript", subscript = "subscript", color = "color", block = "block",// generic block (
) blockQuote = "block-quote", heading1 = "heading1", heading2 = "heading2", heading3 = "heading3", heading4 = "heading4", heading5 = "heading5", heading6 = "heading6", horizontalRule = "horizontal-rule", paragraph = "paragraph", preformatted = "preformatted", listItem = "list-item", numberedList = "ordered-list", bulletedList = "bulleted-list", lineDEPRECATED = "line", inline = "inline",// generic inline () image = "image", link = "link" } declare const kSlateVoidClass = "cc-slate-void"; declare enum EMetaFormat { fontIncrease = "fontIncrease", fontDecrease = "fontDecrease" } type EditorValue = Descendant[]; type HotkeyMap = Record void>; declare function textToSlate(text: string): EditorValue; declare function slateToText(value?: EditorValue): string; interface BlockQuoteElement extends BaseElement { type: 'block-quote'; align?: string; } interface BulletedListElement extends BaseElement { type: 'bulleted-list'; align?: string; } interface EditableVoidElement extends BaseElement { type: 'editable-void'; children: EmptyText[]; } interface HeadingElement extends BaseElement { type: 'heading-one'; align?: string; } interface HeadingTwoElement extends BaseElement { type: 'heading-two'; align?: string; } interface ImageElement extends BaseElement { type: 'image'; src: string; alt?: string; width?: number; height?: number; constrain?: boolean; float?: 'left' | 'right'; children: EmptyText[]; } interface LegacyBlockElement extends BaseElement { type: EFormat.block; tag: string; attrs: Record; } interface LegacyInlineElement extends BaseElement { type: EFormat.inline; tag: string; attrs: Record; } interface LinkElement extends BaseElement { type: 'link'; href: string; } interface ButtonElement extends BaseElement { type: 'button'; } interface ListItemElement extends BaseElement { type: 'list-item'; } interface NumberedListElement extends BaseElement { type: 'ordered-list'; align?: string; } interface ParagraphElement extends BaseElement { type: 'paragraph'; align?: string; } interface UnknownElement extends BaseElement { type: string; } type CustomElement = BlockQuoteElement | BulletedListElement | EditableVoidElement | HeadingElement | HeadingTwoElement | ImageElement | LegacyBlockElement | LegacyInlineElement | LinkElement | ButtonElement | ListItemElement | NumberedListElement | ParagraphElement | UnknownElement; declare function isCustomElement(elt: Node): elt is CustomElement; type CustomText = { bold?: boolean; code?: boolean; color?: string; deleted?: boolean; inserted?: boolean; italic?: boolean; marked?: boolean; subscript?: boolean; superscript?: boolean; underlined?: boolean; text: string; }; type CustomMarks = Omit; type EmptyText = { text: ""; }; interface CCBaseEditor extends BaseEditor { data?: Record; plugins: Record>; globalStyle: (style: React.CSSProperties) => React.CSSProperties; isMarkActive: (format: string) => boolean; toggleMark: (format: string, value?: any) => void; toggleSuperSubscript: (format: EFormat.subscript | EFormat.superscript) => void; isElementActive: (format: string) => boolean; toggleElement: (format: string) => void; selectedElements: () => CustomElement[]; isElementEnabled: (format: string) => boolean; configureElement: (format: string, controller?: IDialogController, elt?: CustomElement) => void; } type CustomEditor = CCBaseEditor & ReactEditor & HistoryEditor; declare module 'slate' { interface CustomTypes { Editor: CustomEditor; Element: CustomElement; Text: CustomText | EmptyText; } } declare const defaultHotkeyMap: HotkeyMap; declare const toggleBlock: (editor: Editor, format: string) => void; declare const isBlockActive: (editor: Editor, format: string, blockType?: string) => boolean; declare const isMarkActive: (editor: Editor, format: string) => boolean; declare const toggleMark: (editor: Editor, format: string, value?: any) => void; declare function toggleSuperSubscript(editor: Editor, format: EFormat.subscript | EFormat.superscript): void; declare function unwrapElement(editor: Editor, format: string): void; declare function wrapElement(editor: Editor, format: string, addProps?: Record, defaultText?: string): void; declare function selectedNodesOfType(editor: Editor, type: EFormat): Node[]; declare function normalizeSelection(editor?: Editor): void; interface IconProps { width: number; height: number; className?: string; title?: string; fill?: string; } type OnClickFn = (format: string) => void; type OnChangeColorFn = (color: string) => void; type OnChangeFn = OnChangeColorFn; type OnDidInvokeToolFn = (format: string) => void; interface IButtonColors { fill?: string; background?: string; } interface IButtonBaseProps { format: EFormat | EMetaFormat | string | null; SvgIcon?: (props: IconProps) => JSX.Element; colors?: IButtonColors; selectedColors?: IButtonColors; tooltip?: string; isActive?: () => boolean; isEnabled?: () => boolean; onClick?: OnClickFn; onChange?: OnChangeFn; onDidInvokeTool?: OnDidInvokeToolFn; } interface IToolbarButtonProps extends IButtonBaseProps { iconSize: number; buttonSize: number; } declare const ToolbarButton: React$1.FC; declare function getPlatformTooltip(str: string): string; type ButtonSpecColorFn = (colors: IButtonColors) => IButtonColors; interface IButtonSpec extends Omit { iconSize?: number; colors?: ButtonSpecColorFn; selectedColors?: ButtonSpecColorFn; } type ButtonSpecKey = NonNullable; type EFormatOrButtonSpec = NonNullable; declare function getToolbarButton(editor: Editor, format: ButtonSpecKey): IButtonSpec | undefined; declare function getDialogController(editor: Editor): IDialogController | undefined; interface IOptions$1 { onClick?: (editor: Editor, element: ImageElement) => void; onDoubleClick?: (editor: Editor, element: ImageElement) => void; } interface IOptions { onClick?: (editor: Editor, element: LinkElement) => void; onDoubleClick?: (editor: Editor, element: LinkElement) => void; } interface ICreateEditorOptions { history?: boolean; imageOptions?: IOptions$1; linkOptions?: IOptions; onInitEditor?: (editor: Editor) => Editor; } declare function createEditor(options?: ICreateEditorOptions): CustomEditor; declare const useSerializing: () => boolean; interface IProps$9 { rows: IRow[]; fieldValues: IFieldValues; onDOMChange: (name: string, value: string, type: FieldType) => void; onValueChange: (name: string, value: string, type: FieldType) => void; onSetMenuIsOpen: (isOpen: boolean) => void; } declare const DialogContent: ({ rows, fieldValues, onDOMChange, onValueChange, onSetMenuIsOpen }: IProps$9) => React$1.JSX.Element; interface IProps$8 { themeStyle?: React$1.CSSProperties; okRef: React$1.RefObject; onCancelClick: () => void; onOkClick: () => void; } declare const DialogFooter: ({ themeStyle, okRef, onCancelClick, onOkClick }: IProps$8) => React$1.JSX.Element; interface IProps$7 { themeStyle?: React$1.CSSProperties; titleStyle?: React$1.CSSProperties; title: string; } declare const DialogHeader: ({ themeStyle, titleStyle, title }: IProps$7) => React$1.JSX.Element; interface IProps$6 { className?: string; allowOutsideClick?: boolean; } declare const ModalCover: ({ className, allowOutsideClick }: IProps$6) => React$1.JSX.Element; interface IProps$5 { coverClassName?: string; dialogClassName?: string; themeColor?: string; fontColor?: string; title: string; rows: IRow[]; fieldValues: IFieldValues; onSetValue: (name: string, value: string, type: FieldType) => void; onChange?: (name: string, value: string, type: FieldType) => void; onValidate?: (values: IFieldValues) => IFieldValues | string; onClose: (values?: IFieldValues) => void; } declare const ModalDialog: React$1.FC; declare function convertDocument(document: any): any; interface MarkDeserializer { test: (el: HTMLElement) => boolean; deserialize: (el: HTMLElement, marks: CustomMarks) => void; } interface ElementDeserializer { test?: (el: HTMLElement) => boolean; deserialize: (el: HTMLElement, children: Descendant[]) => Descendant; } declare function registerMarkDeserializer(tag: string, deserializer: MarkDeserializer): void; declare function registerElementDeserializer(tag: string, deserializer: ElementDeserializer): void; declare function htmlToSlate(html: string): Descendant[]; declare function slateToHtml(value: Descendant[]): string; type RenderAttributes = Record; declare function getDataFromElement(el: Element, _data?: Record): { data: Record | undefined; }; declare function getRenderAttributesFromNode(obj: Descendant, omitProps?: string[]): RenderAttributes; declare function classArray(classes?: string): string[] | undefined; declare function deserializeValueFromLegacy(text: string): any; declare function serializeValueToLegacy(value: EditorValue): string; declare function validateNodeData(node: any): void; type DocumentMetadata = Record; interface SlateExchangeValue { object: "value"; data?: DocumentMetadata; document?: BaseElement; } declare function serializeDocument(document: Descendant[]): { children: Descendant[]; }; declare function serializeValue(document: Descendant[], metadata?: DocumentMetadata): SlateExchangeValue; interface IProps$4 { className?: string; placeholder?: string; readOnly?: boolean; hotkeyMap?: HotkeyMap; historyKeys?: HotkeyMap; onBlur?: React$1.FocusEventHandler; onChange?: (children: Descendant[]) => void; onFocus?: React$1.FocusEventHandler; } declare const SlateEditor: ({ className, placeholder, readOnly, hotkeyMap, historyKeys, onBlur, onChange, onFocus }: IProps$4) => React$1.JSX.Element; interface IToolbarColors { buttonColors?: IButtonColors; selectedColors?: IButtonColors; themeColor?: string; } interface IProps$3 { className?: string; orientation?: "horizontal" | "vertical"; padding?: number; colors?: IToolbarColors; buttonsPerRow?: number; iconSize?: number; buttonSize?: number; buttons: IButtonSpec[]; show?: boolean; onDidInvokeTool?: (format: string) => void; } declare const EditorToolbar: React$1.FC; type ToolbarTransform = (buttons: IButtonSpec[], editor?: Editor, dialogController?: IDialogController) => IButtonSpec[]; interface IProps$2 extends Omit { buttons?: EFormatOrButtonSpec[]; transform?: ToolbarTransform; modalPortalRoot?: HTMLDivElement; modalCoverClassName?: string; modalDialogClassName?: string; } declare const SlateToolbar: React$1.FC; interface IProps$1 extends IProps$2 { portalRoot?: HTMLDivElement; } interface IProps extends IProps$4 { className?: string; editorClassName?: string; value: EditorValue | (() => EditorValue); toolbar?: IProps$1; onBlur?: React$1.FocusEventHandler; onChange?: (children: Descendant[]) => void; onFocus?: React$1.FocusEventHandler; onInitEditor?: (editor: Editor) => Editor; } declare const SlateContainer: React$1.FC; type ElementComponent = (props: RenderElementProps) => JSX.Element; declare function registerElementComponent(format: string, Component: ElementComponent): void; declare function registerMarkRenderer(renderFn: (children: any, leaf: CustomText) => JSX.Element): void; export { DialogContent, DialogFooter, DialogHeader, EFormat, EditorToolbar, ModalCover, ModalDialog, SlateContainer, SlateEditor, SlateToolbar, ToolbarButton, classArray, convertDocument, createEditor, defaultHotkeyMap, deserializeValueFromLegacy, getDataFromElement, getDialogController, getPlatformTooltip, getRenderAttributesFromNode, getToolbarButton, htmlToSlate, isBlockActive, isCustomElement, isMarkActive, kSlateVoidClass, normalizeSelection, registerElementComponent, registerElementDeserializer, registerMarkDeserializer, registerMarkRenderer, selectedNodesOfType, serializeDocument, serializeValue, serializeValueToLegacy, slateToHtml, slateToText, textToSlate, toggleBlock, toggleMark, toggleSuperSubscript, unwrapElement, useSerializing, validateNodeData, wrapElement }; export type { ButtonSpecColorFn, CustomEditor, CustomElement, CustomMarks, CustomText, DisplayDialogSettings, EditorValue, FieldType, IButtonSpec, IDialogController, IField, IFieldValues, IProps$5 as IModalDialogProps, IRow, IToolbarColors, ImageElement, LinkElement, OnChangeColorFn, OnChangeFn, OnClickFn, OnDidInvokeToolFn, SelectOptions, SelectValue, SlateExchangeValue, ToolbarTransform };