@explita/editor
Version:
`@explita/editor` is a versatile, modern rich-text editor built on TipTap for seamless integration into React applications. It provides extensive customization options and advanced features to cater to diverse content creation needs.
169 lines (168 loc) • 6.03 kB
TypeScript
/**
* Sets an image in the editor with the specified source and optional attributes.
*
* @param {string} src - The source URL of the image.
* @param {Object} [opts] - Optional attributes for the image.
* @param {string} [opts.alt] - Alternative text for the image.
* @param {string} [opts.title] - Title for the image.
*/
declare function setImage(src: string, opts?: {
alt?: string;
title?: string;
}): void;
/**
* Undoes the last action in the editor.
*/
declare function undo(): void;
/**
* Redoes the last undone action in the editor.
*/
declare function redo(): void;
/**
* Toggles bold formatting for the selected text in the editor.
*/
declare function toggleBold(): void;
/**
* Toggles italic formatting for the selected text in the editor.
*/
declare function toggleItalic(): void;
/**
* Toggles underline formatting for the selected text in the editor.
*/
declare function toggleUnderline(): void;
/**
* Toggles strikethrough formatting for the selected text in the editor.
*/
declare function toggleStrikethrough(): void;
/**
* Toggles superscript formatting for the selected text in the editor.
*/
declare function toggleSuperscript(): void;
/**
* Toggles subscript formatting for the selected text in the editor.
*/
declare function toggleSubscript(): void;
/**
* Toggles todo list formatting for the selected text in the editor.
*/
declare function toggleTodoList(): void;
/**
* Clears all formatting from the selected text in the editor.
*/
declare function clearFormatting(): void;
/**
* Inserts a horizontal rule at the current cursor position in the editor.
*/
declare function insertHorizontalRule(): void;
/**
* Sets the font family for the selected text in the editor.
*
* @param {string} fontFamily - The font family to apply.
*/
declare function setFontFamily(fontFamily: string): void;
/**
* Sets the font size for the selected text in the editor.
*
* @param {string} newSize - The new font size to apply.
*/
declare function setFontSize(newSize: string): void;
/**
* Sets the line height for the selected text in the editor.
*
* @param {string} lineHeight - The new line height to apply.
*/
declare function setLineHeight(lineHeight: string): void;
/**
* Sets the text color for the selected text in the editor.
*
* @param {string} color - The new text color to apply.
*/
declare function setTextColor(color: string): void;
/**
* Sets the highlight color for the selected text in the editor.
*
* @param {string} color - The new highlight color to apply.
*/
declare function setHighlightColor(color: string): void;
/**
* Sets the text alignment for the selected text in the editor.
*
* @param {string} value - The new text alignment to apply.
*/
declare function setTextAlign(value: "left" | "center" | "justify" | "right"): void;
/**
* Sets a link for the selected text in the editor.
*
* @param {Object} attributes - The attributes for the link.
* @param {string} attributes.href - The URL of the link.
* @param {string} [attributes.target] - The target attribute for the link.
* @param {string} [attributes.rel] - The rel attribute for the link.
* @param {string} [attributes.class] - The class attribute for the link.
*/
declare function setLink(attributes: {
href: string;
target?: string | null;
rel?: string | null;
class?: string | null;
}): void;
/**
* Removes the link from the selected text in the editor.
*/
declare function unsetLink(): void;
/**
* Inserts a list of the specified type at the current cursor position in the editor.
*
* @param {string} type - The type of list to insert. Can be "bullet" or "ordered".
*/
declare function insertList(type: "bullet" | "ordered"): void;
/**
* A collection of commands that can be executed on the editor.
*
* The commands are:
*
* - setImage: Sets the image at the current cursor position.
* - undo: Undoes the last action.
* - redo: Redoes the last undone action.
* - toggleBold: Toggles bold formatting on or off.
* - toggleItalic: Toggles italic formatting on or off.
* - toggleUnderline: Toggles underline formatting on or off.
* - toggleStrikethrough: Toggles strikethrough formatting on or off.
* - toggleSuperscript: Toggles superscript formatting on or off.
* - toggleSubscript: Toggles subscript formatting on or off.
* - toggleTodoList: Toggles todo list formatting on or off.
* - clearFormatting: Clears all formatting from the current selection.
* - insertHorizontalRule: Inserts a horizontal rule at the current cursor position.
* - setFontFamily: Sets the font family for the current selection.
* - setFontSize: Sets the font size for the current selection.
* - setLineHeight: Sets the line height for the current selection.
* - setTextColor: Sets the text color for the current selection.
* - setHighlightColor: Sets the highlight color for the current selection.
* - setTextAlign: Sets the text alignment for the current selection.
* - setLink: Sets a link for the current selection.
* - unsetLink: Removes any existing link from the current selection.
* - insertList: Inserts a list of the specified type at the current cursor position.
*/
export declare const commands: {
setImage: typeof setImage;
undo: typeof undo;
redo: typeof redo;
toggleBold: typeof toggleBold;
toggleItalic: typeof toggleItalic;
toggleUnderline: typeof toggleUnderline;
toggleStrikethrough: typeof toggleStrikethrough;
toggleSuperscript: typeof toggleSuperscript;
toggleSubscript: typeof toggleSubscript;
toggleTodoList: typeof toggleTodoList;
clearFormatting: typeof clearFormatting;
insertHorizontalRule: typeof insertHorizontalRule;
setFontFamily: typeof setFontFamily;
setFontSize: typeof setFontSize;
setLineHeight: typeof setLineHeight;
setTextColor: typeof setTextColor;
setHighlightColor: typeof setHighlightColor;
setTextAlign: typeof setTextAlign;
setLink: typeof setLink;
unsetLink: typeof unsetLink;
insertList: typeof insertList;
};
export {};