import { ViewEventHandlersOptions } from "../extensions/core/view-event-handlers.js"; import { getAllNodesAttributesByType } from "./typist-editor.helper.js"; import * as react from "react"; import { Editor, EditorEvents, Extensions } from "@tiptap/core"; import { Selection } from "@tiptap/pm/state"; //#region src/components/typist-editor.d.ts /** * The forwarded ref that describes the helper methods that the `TypistEditor` parent component * will have access to. */ type TypistEditorRef = { /** * Returns the `Editor` instance associated to the `TypistEditor` component. */ getEditor: () => Editor; /** * Returns the current editor document output as Markdown. */ getMarkdown: () => string; /** * Returns the attributes of a given node type for all the nodes in the editor document. */ getAllNodesAttributesByType: (nodeType: string) => ReturnType; }; /** * The properties that describe the `beforeCreate` editor event. */ type BeforeCreateProps = EditorEvents['beforeCreate']; /** * The properties that describe the `create` editor event. */ type CreateProps = EditorEvents['create']; /** * The properties that describe the `update` editor event. */ type UpdateProps = EditorEvents['update'] & Pick; /** * The properties that describe the `selectionUpdate` editor event. */ type SelectionUpdateProps = EditorEvents['selectionUpdate']; /** * The properties that describe the `transaction` editor event. */ type TransacationProps = EditorEvents['transaction']; /** * The properties that describe the `focus` editor event. */ type FocusProps = EditorEvents['focus']; /** * The properties that describe the `blur` editor event. */ type BlurProps = EditorEvents['blur']; /** * The properties that describe the `destroy` editor event. */ type DestroyProps = EditorEvents['destroy']; /** * The properties available to represent an instance of the `TypistEditor` component, including * the supported WAI-ARIA 1.1 attributes. */ type TypistEditorProps = { /** * Auto focus the editor to the end of the document on initialization. */ autoFocus?: boolean; /** * The CSS class for the container surrounding the editor DOM element. */ className?: string; /** * The initial Markdown content for the editor. */ content?: string; /** * The initial content selection (only applied if `autoFocus` is `true`). */ contentSelection?: Selection; /** * Determines if users can write into the editor. */ editable?: boolean; /** * The list of required extensions to initialize the editor. * * You may consider wrapping this prop with `useMemo` to prevent unnecessary re-renders. */ extensions: Extensions; /** * A short hint that gives users an idea what can be entered in the editor. */ placeholder?: string; /** * The event handler that is fired before the editor view is created. * * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders. */ onBeforeCreate?: (props: BeforeCreateProps) => void; /** * The event handler that is fired when the editor view is ready. * * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders. */ onCreate?: (props: CreateProps) => void; /** * The event handler that is fired when the editor content has changed. * * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders. */ onUpdate?: (props: UpdateProps) => void; /** * The event handler that is fired when the editor selection has changed. * * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders. */ onSelectionUpdate?: (props: SelectionUpdateProps) => void; /** * The event handler that is fired when the editor state has changed. * * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders. */ onTransaction?: (props: TransacationProps) => void; /** * The event handler that is fired when the editor view gains focus. * * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders. */ onFocus?: (props: FocusProps) => void; /** * The event handler that is fired when the editor view loses focus. * * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders. */ onBlur?: (props: BlurProps) => void; /** * The event handler that is fired when the editor view is being destroyed. * * You may consider wrapping this prop with `useCallback` to prevent unnecessary re-renders. */ onDestroy?: (props: DestroyProps) => void; /** * Identifies the element (or elements) that describes the object. * * @see aria-labelledby */ 'aria-describedby'?: React.AriaAttributes['aria-describedby']; /** * Defines a string value that labels the current element. * * @see aria-labelledby. */ 'aria-label'?: React.AriaAttributes['aria-label']; /** * Identifies the element (or elements) that labels the current element. * * @see aria-describedby. */ 'aria-labelledby'?: React.AriaAttributes['aria-labelledby']; /** * The event handler that processes `click` events in the editor. */ onClick?: ViewEventHandlersOptions['onClick']; /** * The event handler that processes `keydown` events in the editor. */ onKeyDown?: ViewEventHandlersOptions['onKeyDown']; }; /** * The `TypistEditor` component represents a plain-text or a rich-text editing control, built on * top of the amazing [Tiptap](https://tiptap.dev/) library. */ declare const TypistEditor: react.ForwardRefExoticComponent>; //#endregion export { type BeforeCreateProps, type BlurProps, type CreateProps, type DestroyProps, type FocusProps, type SelectionUpdateProps, type TransacationProps, TypistEditor, type TypistEditorProps, type TypistEditorRef, type UpdateProps }; //# sourceMappingURL=typist-editor.d.ts.map