@plait/text-plugins
Version:
- `@plait/core`
86 lines (72 loc) • 3.27 kB
TypeScript
import { Alignment, CustomElement, CustomText } from '@plait/common';
import * as slate from 'slate';
import { Editor, Element, Location, BaseEditor, BaseRange } from 'slate';
import { PlaitElement, PlaitBoard } from '@plait/core';
declare const AlignEditor: {
isActive(editor: Editor, alignment: Alignment): boolean;
setAlign(editor: Editor, alignment: Alignment): void;
};
declare enum MarkTypes {
bold = "bold",
italic = "italic",
underline = "underlined",
strike = "strike",
color = "color",
fontSize = "font-size"
}
declare const MarkProps: MarkTypes[];
declare enum FontSizes {
'fontSize12' = "12",
'fontSize13' = "13",
'fontSize14' = "14",
'fontSize15' = "15",
'fontSize16' = "16",
'fontSize18' = "18",
'fontSize20' = "20",
'fontSize24' = "24",
'fontSize28' = "28",
'fontSize32' = "32",
'fontSize40' = "40",
'fontSize48' = "48"
}
declare const HOTKEYS: {
'mod+b': MarkTypes;
'mod+i': MarkTypes;
'mod+u': MarkTypes;
'mod+shift+x': MarkTypes;
};
declare const DEFAULT_FONT_SIZE = 14;
interface MarkEditor extends Editor {
removeMark: (key: string, shouldChange?: boolean) => void;
}
declare const PlaitMarkEditor: {
getMarks(editor: Editor): any;
getMarksByElement(element: Element): any;
isMarkActive(editor: Editor, format: MarkTypes): boolean | undefined;
toggleMark(editor: Editor, format: MarkTypes): void;
setFontSizeMark(editor: Editor, size: FontSizes, defaultSize?: number): void;
setColorMark(editor: Editor, color: string | null, defaultTextColor?: string): void;
};
declare function setSelection(editor: Editor): void;
declare const withMark: <T extends Editor & MarkEditor>(editor: T) => T;
declare const markShortcuts: (editor: Editor, event: KeyboardEvent) => void;
declare const LinkEditor: {
wrapLink(editor: Editor, text: string, url: string): void;
unwrapLink(editor: Editor, at?: Location): void;
isLinkActive(editor: Editor): boolean;
getLinkElement(editor: Editor): slate.NodeEntry<CustomElement>;
};
declare const withLink: <T extends Editor>(editor: T) => T;
declare const getTextFromClipboard: (data: DataTransfer | null) => string | slate.BaseElement;
declare function isUrl(string: string): boolean;
declare const getTextMarksByElement: (element: PlaitElement) => Omit<CustomText, "text">;
declare const TEXT_DEFAULT_HEIGHT = 20;
declare const CLIPBOARD_FORMAT_KEY = "x-plait-text-fragment";
declare const TextTransforms: {
setTextAlign: (board: PlaitBoard, align: Alignment, editors?: BaseEditor[]) => void;
setTextColor: (board: PlaitBoard, color: string | null, textSelection?: BaseRange, editors?: BaseEditor[]) => void;
setFontSize: (board: PlaitBoard, size: FontSizes, defaultFontSize: number | ((element: PlaitElement) => number | undefined), editors?: BaseEditor[]) => void;
setTextMarks: (board: PlaitBoard, mark: MarkTypes, editors?: BaseEditor[]) => void;
};
export { AlignEditor, CLIPBOARD_FORMAT_KEY, DEFAULT_FONT_SIZE, FontSizes, HOTKEYS, LinkEditor, MarkProps, MarkTypes, PlaitMarkEditor, TEXT_DEFAULT_HEIGHT, TextTransforms, getTextFromClipboard, getTextMarksByElement, isUrl, markShortcuts, setSelection, withLink, withMark };
export type { MarkEditor };