UNPKG

react-smart-editor

Version:
70 lines 2.79 kB
import { Editor } from 'slate'; import { LinkElement, ChangeMetadata, User } from '../types'; /** * Plugin to handle inline links * @param editor - The Slate editor * @returns The editor with link support */ export declare const withLinks: (editor: Editor) => Editor; /** * Check if a link is active at the current selection * @param editor - The Slate editor * @returns True if a link is active */ export declare const isLinkActive: (editor: Editor) => boolean; /** * Get the active link element and its path * @param editor - The Slate editor * @returns The link element and path, or null */ export declare const getActiveLink: (editor: Editor) => [LinkElement, number[]] | null; /** * Unwrap link at current selection * @param editor - The Slate editor */ export declare const unwrapLink: (editor: Editor) => void; /** * Wrap selection in a link with track changes support * @param editor - The Slate editor * @param url - The URL for the link * @param text - Optional text for the link * @param user - User making the change (optional, for track changes) * @param createChangeMetadata - Function to create change metadata (optional) * @returns Array of change metadata if tracking changes */ export declare const wrapLink: (editor: Editor, url: string, text?: string, user?: User, createChangeMetadata?: (type: "insert" | "delete", content: string, description: string, user: User) => ChangeMetadata) => ChangeMetadata[]; /** * Insert a link at the current selection with track changes support * @param editor - The Slate editor * @param url - The URL for the link * @param text - The text for the link * @param user - User making the change (optional) * @param createChangeMetadata - Function to create change metadata (optional) * @returns Array of change metadata if tracking changes */ export declare const insertLink: (editor: Editor, url: string, text: string, user?: User, createChangeMetadata?: (type: "insert" | "delete", content: string, description: string, user: User) => ChangeMetadata) => ChangeMetadata[]; /** * Update an existing link * @param editor - The Slate editor * @param url - The new URL * @param text - The new text (optional) */ export declare const updateLink: (editor: Editor, url: string, text?: string) => void; /** * Remove a link * @param editor - The Slate editor */ export declare const removeLink: (editor: Editor) => void; /** * Check if the selection is inside a link * @param editor - The Slate editor * @returns True if inside a link */ export declare const isSelectionInLink: (editor: Editor) => boolean; /** * Get selected text * @param editor - The Slate editor * @returns The selected text */ export declare const getSelectedText: (editor: Editor) => string; //# sourceMappingURL=links.d.ts.map