mui-tiptap
Version:
A Material-UI (MUI) styled WYSIWYG rich text editor, using Tiptap
40 lines (39 loc) • 1.87 kB
TypeScript
import { type Editor } from "@tiptap/core";
import { type ReactNode } from "react";
export type EditLinkMenuContentProps = {
editor: Editor;
onCancel: () => void;
onSave: ({ text, link }: {
text: string;
link: string;
}) => void;
/**
* Function to format the `href` value the user entered for the link, when a
* user has finished typing (`onBlur` or when pressing Enter). Takes in the
* user-entered input value and returns the formatted value.
*
* If not provided, the default behavior:
* - trims leading/trailing whitespace
* - ensures the value has a protocol (http://) if it doesn't already, unless
* it's a relative URL (starting with "/") or anchor (starting with "#")
* - URL-encodes the result
*/
formatHref?: (value: string) => string;
/** Override default text content/labels used within the component. */
labels?: {
/** Menu title shown when adding a new link. */
editLinkAddTitle?: ReactNode;
/** Menu title shown when editing an existing link. */
editLinkEditTitle?: ReactNode;
/** Label for the input text field to edit the text content of a link. */
editLinkTextInputLabel?: ReactNode;
/** Label for the input text field to edit the href (URL) of a link. */
editLinkHrefInputLabel?: ReactNode;
/** Content shown in the button used to cancel editing/adding a link. */
editLinkCancelButtonLabel?: ReactNode;
/** Content shown in the button used to save when editing/adding a link. */
editLinkSaveButtonLabel?: ReactNode;
};
};
/** Shown when a user is adding/editing a Link for Tiptap. */
export default function EditLinkMenuContent({ editor, onCancel, onSave, labels, formatHref, }: EditLinkMenuContentProps): import("react/jsx-runtime").JSX.Element;