| 1 | "use client"; |
| 2 | |
| 3 | import { |
| 4 | type EmptyText, |
| 5 | type KEYS, |
| 6 | type PlainText, |
| 7 | type TBasicMarks, |
| 8 | type TCaptionProps, |
| 9 | type TComboboxInputElement, |
| 10 | type TCommentText, |
| 11 | type TElement, |
| 12 | type TFontMarks, |
| 13 | type TImageElement, |
| 14 | type TLineHeightProps, |
| 15 | type TLinkElement, |
| 16 | type TListProps, |
| 17 | type TMediaEmbedElement, |
| 18 | type TMentionElement, |
| 19 | type TResizableProps, |
| 20 | type TTableElement, |
| 21 | type TText, |
| 22 | type TTextAlignProps, |
| 23 | } from "platejs"; |
| 24 | |
| 25 | export interface MyBlockElement extends TElement, TListProps { |
| 26 | id?: string; |
| 27 | } |
| 28 | |
| 29 | export interface MyTextBlockElement |
| 30 | extends TElement, TLineHeightProps, TTextAlignProps { |
| 31 | children: ( |
| 32 | | MyLinkElement |
| 33 | | MyMentionElement |
| 34 | | MyMentionInputElement |
| 35 | | RichText |
| 36 | )[]; |
| 37 | } |
| 38 | |
| 39 | export interface MyBlockquoteElement extends MyTextBlockElement { |
| 40 | type: typeof KEYS.blockquote; |
| 41 | } |
| 42 | |
| 43 | export interface MyCodeBlockElement extends MyBlockElement { |
| 44 | children: MyCodeLineElement[]; |
| 45 | type: typeof KEYS.codeBlock; |
| 46 | } |
| 47 | |
| 48 | export interface MyCodeLineElement extends TElement { |
| 49 | children: PlainText[]; |
| 50 | type: typeof KEYS.codeLine; |
| 51 | } |
| 52 | |
| 53 | export interface MyH1Element extends MyTextBlockElement { |
| 54 | type: typeof KEYS.h1; |
| 55 | } |
| 56 | |
| 57 | export interface MyH2Element extends MyTextBlockElement { |
| 58 | type: typeof KEYS.h2; |
| 59 | } |
| 60 | |
| 61 | /** Block props */ |
| 62 | |
| 63 | export interface MyH3Element extends MyTextBlockElement { |
| 64 | type: typeof KEYS.h3; |
| 65 | } |
| 66 | |
| 67 | export interface MyH4Element extends MyTextBlockElement { |
| 68 | type: typeof KEYS.h4; |
| 69 | } |
| 70 | |
| 71 | export interface MyH5Element extends MyTextBlockElement { |
| 72 | type: typeof KEYS.h5; |
| 73 | } |
| 74 | |
| 75 | export interface MyH6Element extends MyTextBlockElement { |
| 76 | type: typeof KEYS.h6; |
| 77 | } |
| 78 | |
| 79 | export interface MyHrElement extends MyBlockElement { |
| 80 | children: [EmptyText]; |
| 81 | type: typeof KEYS.hr; |
| 82 | } |
| 83 | |
| 84 | export interface MyImageElement |
| 85 | extends MyBlockElement, TCaptionProps, TImageElement, TResizableProps { |
| 86 | children: [EmptyText]; |
| 87 | type: typeof KEYS.img; |
| 88 | } |
| 89 | |
| 90 | export interface MyLinkElement extends TLinkElement { |
| 91 | children: RichText[]; |
| 92 | type: typeof KEYS.link; |
| 93 | } |
| 94 | |
| 95 | export interface MyMediaEmbedElement |
| 96 | extends MyBlockElement, TCaptionProps, TMediaEmbedElement, TResizableProps { |
| 97 | children: [EmptyText]; |
| 98 | type: typeof KEYS.mediaEmbed; |
| 99 | } |
| 100 | |
| 101 | export interface MyMentionElement extends TMentionElement { |
| 102 | children: [EmptyText]; |
| 103 | type: typeof KEYS.mention; |
| 104 | } |
| 105 | |
| 106 | export interface MyMentionInputElement extends TComboboxInputElement { |
| 107 | children: [PlainText]; |
| 108 | type: typeof KEYS.mentionInput; |
| 109 | } |
| 110 | |
| 111 | export type MyNestableBlock = MyParagraphElement; |
| 112 | |
| 113 | export interface MyParagraphElement extends MyTextBlockElement { |
| 114 | type: typeof KEYS.p; |
| 115 | } |
| 116 | |
| 117 | export interface MyTableCellElement extends TElement { |
| 118 | children: MyNestableBlock[]; |
| 119 | type: typeof KEYS.td; |
| 120 | } |
| 121 | |
| 122 | export interface MyTableElement extends MyBlockElement, TTableElement { |
| 123 | children: MyTableRowElement[]; |
| 124 | type: typeof KEYS.table; |
| 125 | } |
| 126 | |
| 127 | export interface MyTableRowElement extends TElement { |
| 128 | children: MyTableCellElement[]; |
| 129 | type: typeof KEYS.tr; |
| 130 | } |
| 131 | |
| 132 | export interface MyToggleElement extends MyTextBlockElement { |
| 133 | type: typeof KEYS.toggle; |
| 134 | } |
| 135 | |
| 136 | export interface RichText extends TBasicMarks, TCommentText, TFontMarks, TText { |
| 137 | kbd?: boolean; |
| 138 | } |
| 139 | |
| 140 | export type MyValue = ( |
| 141 | | MyBlockquoteElement |
| 142 | | MyCodeBlockElement |
| 143 | | MyH1Element |
| 144 | | MyH2Element |
| 145 | | MyH3Element |
| 146 | | MyH4Element |
| 147 | | MyH5Element |
| 148 | | MyH6Element |
| 149 | | MyHrElement |
| 150 | | MyImageElement |
| 151 | | MyMediaEmbedElement |
| 152 | | MyParagraphElement |
| 153 | | MyTableElement |
| 154 | | MyToggleElement |
| 155 | )[]; |
| 156 |