denwa-react-shared
Version:
92 lines (91 loc) • 3.81 kB
TypeScript
import { BaseEditor, Descendant } from 'slate';
import { ReactEditor } from 'slate-react';
import { PictureData } from './types';
/**
* @description Активна ли кнопка блока
* @param editor - slate editor
* @param format - тип параметра
* @param blockType - тип блока
* @returns тип кнопки primary или default
*/
export declare const isBlockActive: (editor: BaseEditor & ReactEditor, format: string, blockType?: "type" | "align") => "default" | "primary";
/**
* @description Активна ли кнопка маркировки
* @param editor - slate editor
* @param format - тип параметра
* @returns тип кнопки primary или default
*/
export declare const isMarkActive: (editor: BaseEditor & ReactEditor, format: string) => "default" | "primary";
/**
* @description Смена маркировки
* @param editor - slate editor
* @param format - тип параметра
*/
export declare const toggleMark: (editor: BaseEditor & ReactEditor, format: string) => void;
/**
* @description Смена блока
* @param editor - slate editor
* @param format - тип параметра
*/
export declare const toggleBlock: (editor: BaseEditor & ReactEditor, format: string) => void;
/**
* @description Активна ли ссылка
* @param editor - slate editor
*/
export declare const isLinkActive: (editor: BaseEditor & ReactEditor) => boolean;
/**
* @description Убрать ссылку
* @param editor - slate editor
*/
export declare const unwrapLink: (editor: BaseEditor & ReactEditor) => void;
/**
* @description Вставить ссылку
* @param editor - slate editor
* @param url - ссылка
*/
export declare const insertLink: (editor: BaseEditor & ReactEditor, url: string) => void;
/**
* @description Добавить ссылку
* @param editor - slate editor
*/
export declare const wrapLink: (editor: BaseEditor & ReactEditor, url: string) => void;
/**
* @description Вставка картинки
* @param editor - slate editor
* @param url - url картинки
* @param pictureData - подготовленные варианты для <picture>
*/
export declare const insertImage: (editor: BaseEditor & ReactEditor, url: string | ArrayBuffer | null, pictureData?: PictureData) => void;
/**
* @description Проверка что url изображения корректный
* @param url - url картинки
*/
export declare const isImageUrl: (url: string | ArrayBuffer | null) => boolean;
/**
* @description Поддержка картинок в редакторе
* @param editor - slate editor
*/
export declare const withImages: (editor: BaseEditor & ReactEditor) => BaseEditor & ReactEditor;
/**
* @description Поддержка ссылок в редакторе
* @param editor - slate editor
*/
export declare const withInlines: (editor: BaseEditor & ReactEditor) => BaseEditor & ReactEditor;
/**
* @description Экранирование специальных символов в заданной строке текста
* @param {string} string - Исходная строка
* @return {string}
*/
export declare const escapeHtml: (string: string) => string;
/**
* @description Конвертация содержимого редактора в html
* @param {Descendant} node - node узел
* @return {string} Возвращает html строку
*/
export declare const serializeToHtml: (node: Descendant) => string;
/**
* @description Функция для безопасной загрузки данных в Slate
* @param data - slate содержимое
* @return Возвращает нормализованные данные
*/
export declare const normalizeSlateData: (data: unknown) => Descendant[];