-
Notifications
You must be signed in to change notification settings - Fork 3
/
types.d.ts
188 lines (163 loc) · 5.06 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import { ReactNode } from 'react';
import {
Editor as TiptapEditor,
Extension,
Node,
} from "@tiptap/core/dist/packages/core/src";
import { Range } from "@tiptap/core/dist/packages/core/src/types";
import { Transaction } from "prosemirror-state";
import { CodeOptions } from "@tiptap/extension-code";
import { UnderlineOptions } from "@tiptap/extension-underline";
import { HighlightOptions } from "lowlight/lib/core";
import { CodeBlockLowlightOptions } from "@tiptap/extension-code-block-lowlight";
import { StarterKitOptions } from "@tiptap/starter-kit";
import { PlaceholderOptions } from "@tiptap/extension-placeholder";
import { CharacterCountOptions } from "@tiptap/extension-character-count";
import Variables from "components/Editor/CustomExtensions/Variable/index";
interface Command {
title: string;
Icon: Function;
description?: string;
optionName: string;
active?: ({ editor: TiptapEditor }) => boolean;
command?: (props: { editor: TiptapEditor; range: Range }) => void;
items?: Command[];
}
interface Variable {
label?: string;
key: string;
value?: any;
}
interface VariableCategory {
category_key: string;
category_label?: string;
variables?: Variable[];
}
interface Mention {
key?: string;
name: string;
imageUrl?: string;
}
type KeyboardShortcuts = {
[shortcut: string]: (props: { editor: TiptapEditor }) => boolean | void;
};
type EditorFocus = (props: {
editor: TiptapEditor;
event: FocusEvent;
transaction: Transaction;
}) => void;
interface tooltip {
label: string;
keys: string[];
}
interface tooltips {
[key: string]: tooltip;
}
interface MenuProps {
tooltips?: tooltips;
editor: TiptapEditor | null;
menuType?: "fixed" | "bubble" | "headless" | "none";
defaults?: string[];
addons?: string[];
mentions?: Mention[];
editorSecrets?: Array<{ unsplash?: string }>;
variables?: (VariableCategory | Variable)[];
addonCommands?: Command[];
isIndependant?: boolean;
className?: string;
}
interface attachment {
filename?: string;
signedId?: string;
url?: string;
[otherProps: string]: any;
};
interface attachmentsConfig {
maxFileSize?: number,
maxNumberOfFiles?: number,
allowedFileTypes?: string[],
}
interface EditorProps {
attachmentsConfig?: attachmentsConfig;
isMenuIndependent?: boolean;
isMenuCollapsible?: boolean;
menuClassName?: string;
attachmentsClassName?: string;
errorWrapperClassName?: string;
tooltips?: tooltips;
initialValue?: string;
menuType?: "fixed" | "bubble" | "headless" | "none";
label?: string;
required?: boolean;
autoFocus?: boolean;
hideSlashCommands?: boolean;
defaults?: string[];
addons?: string[];
addonCommands?: Command[];
className?: string;
contentClassName?: string;
contentWrapperClassName?: string;
contentAttributes?: { [key: string]: string };
onChange?: (htmlContent: string) => void;
onFocus?: EditorFocus;
onBlur?: EditorFocus;
onSubmit?: (htmlContent: string) => void;
variables?: (VariableCategory | Variable)[];
mentions?: Mention[];
placeholder?: string;
extensions?: Array<Node | Extension>;
editorSecrets?: Array<{ unsplash?: string }>;
rows?: number;
isCharacterCountActive?: boolean;
keyboardShortcuts?: KeyboardShortcuts;
error?: string;
attachments?: Array<attachment>;
onChangeAttachments?: (attachments: attachment[]) => void;
children?: ReactNode;
openImageInNewTab?: boolean;
openLinkInNewTab?: boolean;
enableReactNodeViewOptimization?: boolean;
size?: "large" | "medium" | "small";
[otherProps: string]: any;
}
interface FormikEditorProps extends EditorProps {
name: string;
shouldUpdate?: (nextProps: EditorProps, prevProps: EditorProps) => boolean;
}
interface AttachmentsProps {
config?: attachmentsConfig;
endpoint?: string;
attachments?: Array<attachment>;
dragDropRef?: React.RefObject<HTMLDivElement>;
onChange?: (attachments: attachment[]) => void;
isIndependent?: boolean;
disabled?: boolean;
className?: string;
showToastr?: boolean;
allowDelete?: boolean;
}
type EditorContentConfigType = {
enableHeaderLinks?: boolean;
}
export function Editor(props: EditorProps): JSX.Element;
export function FormikEditor(props: FormikEditorProps): JSX.Element;
export function Attachments(props: AttachmentsProps): JSX.Element;
export function EditorContent(props: {
content?: string;
className?: string;
variables?: (VariableCategory | Variable)[];
size?: "large" | "medium" | "small";
configuration?: EditorContentConfigType;
[otherProps: string]: any;
}): JSX.Element;
export function Menu(props: MenuProps): JSX.Element;
export function removeEmptyTags(html: string): string;
export function isEditorEmpty(htmlContent: string | null | undefined): boolean;
export function isEditorContentWithinLimit(htmlContent: string | null | undefined, maxLength: number): boolean;
export function isEditorOverlaysActive(): boolean;
export function isEmojiSuggestionsMenuActive(): boolean;
export function transformEditorContent(content: string): string;
export function substituteVariables(
highlightedContent: string,
variables: (VariableCategory | Variable)[]
): string;