import { ComponentPropsWithoutRef, ReactNode } from 'react';
import { Extensions, JSONContent } from '@tiptap/core';
import { HelperProps } from '../../../internal/components';
import { FieldLabelProps } from '../../../components/FieldLabel';
import { LayoutUtilProps } from '../../../types';
import { DataTrackingId } from '../../../types/DataTrackingId';
/**
 * A single option displayed in the @mention typeahead dropdown.
 * @property {string} id - Unique identifier for the mention option, stored in the mention node's attributes.
 * @property {string} label - Display name shown in the dropdown and rendered inside the inserted mention node.
 */
export type RichTextEditorMentionOption = {
    id: string;
    label: string;
};
type RichTextEditorBaseProps = {
    id?: string;
    value?: string;
    defaultValue?: string;
    onChange?: (html: string) => void;
    onJsonChange?: (json: JSONContent) => void;
    /**
     * How `value`/`defaultValue` are parsed. Defaults to HTML. Set once — the
     * editor instance is created on mount, so changing this afterwards
     * re-parses the current string under the new assumption instead of
     * converting existing content.
     */
    contentType?: "html" | "markdown";
    /**
     * Fires with the TipTap-markdown-serialized content on every update,
     * alongside `onChange`/`onJsonChange`, regardless of `contentType`. Uses
     * TipTap's official `@tiptap/markdown` extension, which is BETA upstream:
     * known limitations are single-child-per-cell tables and possible loss of
     * HTML comments on round-trip. In markdown mode, a controlled `value`
     * should be the exact string previously emitted here — serialization
     * normalizes formatting and isn't guaranteed to round-trip arbitrary
     * hand-written markdown. Markdown syntax for a feature disabled via an
     * `allow*` flag (e.g. `- item` when `allowLists` is false) is parsed into
     * whatever the configured schema supports; unsupported nodes are dropped
     * or flattened rather than causing an error.
     */
    onMarkdownChange?: (markdown: string) => void;
    /**
     * Extra TipTap extensions appended after the built-in ones (e.g. a custom
     * node type). An extension sharing a built-in's name overrides it. Toolbar
     * controls don't automatically wire up to custom nodes — build any needed
     * UI yourself.
     */
    extensions?: Extensions;
    placeholder?: string;
    disabled?: boolean;
    error?: boolean | string | string[];
    hint?: HelperProps["hint"];
    description?: HelperProps["description"];
    label?: FieldLabelProps["children"];
    labelProps?: FieldLabelProps;
    required?: boolean;
    moreInfo?: ReactNode;
    allowTextFormat?: boolean;
    allowTextAlignment?: boolean;
    allowLists?: boolean;
    allowChecklist?: boolean;
    allowCode?: boolean;
    allowBlockquote?: boolean;
    allowLink?: boolean;
    allowMention?: boolean;
    allowDragDrop?: boolean;
    mentionOptions?: RichTextEditorMentionOption[];
    onMentionInputChange?: (query: string) => void;
    renderMentionOption?: (option: RichTextEditorMentionOption) => ReactNode;
    renderMentionHoverContent?: (option: RichTextEditorMentionOption) => ReactNode;
};
type RichTextEditorWithMedia = {
    /**
     * Enables the Insert dropdown with Image and YouTube options. Requires `onImageUpload`.
     */
    allowMedia: true;
    /**
     * Called when the user selects, pastes, or drops image files into the editor.
     * Receive the files and a callback — invoke it with the resulting URLs once upload is complete.
     */
    onImageUpload: (files: File[], onComplete: (srcs: string[]) => void) => void;
    /**
     * MIME types accepted by the file picker and paste/drop handler.
     * e.g. `["image/jpeg", "image/png"]`. When omitted, defaults to common image types.
     */
    allowedMimeTypes?: `image/${string}`[];
    /**
     * Validates an image's `src` before it's kept in the document (and thus
     * before it can render or be emitted via `onJsonChange`/`onMarkdownChange`),
     * for any input path (typed, pasted, dropped/uploaded, markdown, or set via
     * `value`/`defaultValue`). Defaults to allowing `http:`/`https:` only.
     * Pass a custom validator to loosen or further restrict.
     */
    isAllowedImageSrc?: (src: string) => boolean;
};
type RichTextEditorWithoutMedia = {
    allowMedia?: false;
    onImageUpload?: never;
    allowedMimeTypes?: never;
    isAllowedImageSrc?: never;
};
/**
 * Props for the RichTextEditor component.
 * @property {string} [id] - HTML id applied to the editor's contenteditable element.
 * @property {string} [value] - Controlled HTML string value. When provided, the editor operates in controlled mode.
 * @property {string} [defaultValue] - Default HTML string value for uncontrolled mode.
 * @property {(html: string) => void} [onChange] - Callback fired with the HTML string on each content change.
 * @property {(json: JSONContent) => void} [onJsonChange] - Callback fired with the TipTap JSON representation on each content change.
 * @property {"html" | "markdown"} [contentType] - How `value`/`defaultValue` are parsed. Default: "html". Set once at mount.
 * @property {(markdown: string) => void} [onMarkdownChange] - Callback fired with the markdown representation on each content change, regardless of `contentType`.
 * @property {Extensions} [extensions] - Extra TipTap extensions appended after the built-in ones; same-named extensions override a built-in.
 * @property {string} [placeholder] - Placeholder text shown when the editor is empty.
 * @property {boolean} [disabled] - Disables the editor and toolbar when true.
 * @property {boolean | string | string[]} [error] - Error state. Pass `true` for error styling only, or a string/string[] for error messages.
 * @property {HelperProps["hint"]} [hint] - Hint text displayed below the editor.
 * @property {HelperProps["description"]} [description] - Description text displayed below the editor.
 * @property {FieldLabelProps["children"]} [label] - Label for the editor field.
 * @property {FieldLabelProps} [labelProps] - Additional props passed to the label element.
 * @property {boolean} [required] - Marks the field as required.
 * @property {ReactNode} [moreInfo] - Additional info rendered alongside the label.
 * @property {boolean} [allowTextFormat] - Enables text formatting toolbar section: text type dropdown, font size, bold, italic, underline, strikethrough. Default: true.
 * @property {boolean} [allowTextAlignment] - Enables text alignment toolbar section: left, center, right, justify. Default: true.
 * @property {boolean} [allowLists] - Enables list toolbar section: ordered list, unordered list, indent controls. Default: false.
 * @property {boolean} [allowChecklist] - Enables checklist toolbar section. Default: false.
 * @property {boolean} [allowCode] - Enables inline code toolbar button. Default: false.
 * @property {boolean} [allowBlockquote] - Enables blockquote toolbar button. Default: false.
 * @property {boolean} [allowLink] - Enables link insert/remove toolbar button. Default: false.
 * @property {boolean} [allowMedia] - Enables the Insert dropdown (Image + YouTube). Requires `onImageUpload`. Default: false.
 * @property {boolean} [allowMention] - Enables @mention toolbar button. Requires `mentionOptions`. Default: false.
 * @property {boolean} [allowDragDrop] - Enables drag handle for reordering blocks. Default: false.
 * @property {RichTextEditorMentionOption[]} [mentionOptions] - List of mention options to display in the dropdown.
 * @property {(query: string) => void} [onMentionInputChange] - Fired when the user types after `@`. Use to filter or async-load `mentionOptions`.
 * @property {(option: RichTextEditorMentionOption) => ReactNode} [renderMentionOption] - Custom render function for each option in the mention dropdown.
 * @property {(option: RichTextEditorMentionOption) => ReactNode} [renderMentionHoverContent] - Render function for the hover card shown when hovering over an inserted mention.
 * @property {(files: File[], onComplete: (srcs: string[]) => void) => void} [onImageUpload] - Required when `allowMedia` is true. Called when the user selects, pastes, or drops image files. Invoke the callback with the resulting URLs once upload is complete.
 * @property {`image/${string}`[]} [allowedMimeTypes] - MIME types accepted by the file picker and paste/drop handler when `allowMedia` is true. Defaults to common image types when omitted.
 * @property {(src: string) => boolean} [isAllowedImageSrc] - Validates an image's `src` before it's allowed to render when `allowMedia` is true. Defaults to allowing `http:`/`https:` only.
 * @extends Omit<ComponentPropsWithoutRef<"div">, "onChange">
 * @extends LayoutUtilProps
 * @extends DataTrackingId
 */
export type RichTextEditorProps = Omit<ComponentPropsWithoutRef<"div">, "onChange"> & RichTextEditorBaseProps & (RichTextEditorWithMedia | RichTextEditorWithoutMedia) & LayoutUtilProps & DataTrackingId;
export {};
