mirror of
https://github.com/array-in-a-matrix/xinny.git
synced 2024-05-15 19:04:30 -04:00
41f67cabc0
* add slate editor history * reset mark on editor reset
107 lines
2.2 KiB
TypeScript
107 lines
2.2 KiB
TypeScript
import { BaseEditor } from 'slate';
|
|
import { ReactEditor } from 'slate-react';
|
|
import { HistoryEditor } from 'slate-history';
|
|
import { BlockType } from './Elements';
|
|
|
|
export type HeadingLevel = 1 | 2 | 3;
|
|
|
|
export type Editor = BaseEditor & HistoryEditor & ReactEditor;
|
|
|
|
export type Text = {
|
|
text: string;
|
|
};
|
|
|
|
export type FormattedText = Text & {
|
|
bold?: boolean;
|
|
italic?: boolean;
|
|
underline?: boolean;
|
|
strikeThrough?: boolean;
|
|
code?: boolean;
|
|
spoiler?: boolean;
|
|
};
|
|
|
|
export type LinkElement = {
|
|
type: BlockType.Link;
|
|
href: string;
|
|
children: FormattedText[];
|
|
};
|
|
export type SpoilerElement = {
|
|
type: 'spoiler';
|
|
alert?: string;
|
|
children: FormattedText[];
|
|
};
|
|
export type MentionElement = {
|
|
type: BlockType.Mention;
|
|
id: string;
|
|
highlight: boolean;
|
|
name: string;
|
|
children: Text[];
|
|
};
|
|
export type EmoticonElement = {
|
|
type: BlockType.Emoticon;
|
|
key: string;
|
|
shortcode: string;
|
|
children: Text[];
|
|
};
|
|
|
|
export type ParagraphElement = {
|
|
type: BlockType.Paragraph;
|
|
children: FormattedText[];
|
|
};
|
|
export type HeadingElement = {
|
|
type: BlockType.Heading;
|
|
level: HeadingLevel;
|
|
children: FormattedText[];
|
|
};
|
|
export type CodeLineElement = {
|
|
type: BlockType.CodeLine;
|
|
children: Text[];
|
|
};
|
|
export type CodeBlockElement = {
|
|
type: BlockType.CodeBlock;
|
|
children: CodeLineElement[];
|
|
};
|
|
export type QuoteLineElement = {
|
|
type: BlockType.QuoteLine;
|
|
children: FormattedText[];
|
|
};
|
|
export type BlockQuoteElement = {
|
|
type: BlockType.BlockQuote;
|
|
children: QuoteLineElement[];
|
|
};
|
|
export type ListItemElement = {
|
|
type: BlockType.ListItem;
|
|
children: FormattedText[];
|
|
};
|
|
export type OrderedListElement = {
|
|
type: BlockType.OrderedList;
|
|
children: ListItemElement[];
|
|
};
|
|
export type UnorderedListElement = {
|
|
type: BlockType.UnorderedList;
|
|
children: ListItemElement[];
|
|
};
|
|
|
|
export type CustomElement =
|
|
| LinkElement
|
|
// | SpoilerElement
|
|
| MentionElement
|
|
| EmoticonElement
|
|
| ParagraphElement
|
|
| HeadingElement
|
|
| CodeLineElement
|
|
| CodeBlockElement
|
|
| QuoteLineElement
|
|
| BlockQuoteElement
|
|
| ListItemElement
|
|
| OrderedListElement
|
|
| UnorderedListElement;
|
|
|
|
declare module 'slate' {
|
|
interface CustomTypes {
|
|
Editor: Editor;
|
|
Element: CustomElement;
|
|
Text: FormattedText & Text;
|
|
}
|
|
}
|