Full document, spreadsheet, slideshow, and diagram tooling
1/**
2 * Type definitions for the docs module.
3 */
4
5import type { Editor } from '@tiptap/core';
6
7export interface SearchState {
8 query: string;
9 caseSensitive: boolean;
10 regex: boolean;
11 results: SearchResult[];
12 currentIndex: number;
13}
14
15export interface SearchResult {
16 from: number;
17 to: number;
18}
19
20export interface OutlineItem {
21 level: number;
22 text: string;
23 id: string;
24}
25
26export interface OutlineTreeNode extends OutlineItem {
27 children: OutlineTreeNode[];
28}
29
30export interface SlashCommandItem {
31 id: string;
32 name: string;
33 description: string;
34 category: string;
35 icon: string;
36 shortcut: string | null;
37}
38
39export interface SlashCommandCategory {
40 id: string;
41 label: string;
42}
43
44export interface SlashCommandGroup {
45 id: string;
46 label: string;
47 items: SlashCommandItem[];
48}
49
50export interface MarkdownOptions {
51 gfm?: boolean;
52 tables?: boolean;
53 taskLists?: boolean;
54}
55
56export interface BlockHandlePosition {
57 top: number;
58 left: number;
59}
60
61export interface BlockHandleAction {
62 id: string;
63 label: string;
64 icon: string;
65}
66
67export interface TurnIntoItem {
68 id: string;
69 name: string;
70 icon: string;
71}
72
73export interface TooltipPosition {
74 top: number;
75 left: number;
76}
77
78export interface LinkPreviewData {
79 href: string;
80 position: TooltipPosition;
81}
82
83export interface TableCommand {
84 label: string;
85 icon: string;
86 command: string;
87}
88
89export interface TableCommandMap {
90 [key: string]: TableCommand;
91}
92
93export interface CellAttrs {
94 background?: string;
95 backgroundColor?: string;
96}
97
98export interface PdfExportOptions {
99 editorHtml: string;
100 title: string;
101}
102
103export interface DocxConvertResult {
104 html: string;
105 messages: DocxMessage[];
106}
107
108export interface DocxMessage {
109 type: string;
110 message: string;
111}
112
113export type TabAction = 'indent' | 'outdent' | 'insertTab' | 'noop';
114
115export interface TabContext {
116 isInList: boolean;
117 isInCodeBlock: boolean;
118 shiftKey: boolean;
119}
120
121export interface AutoformatRule {
122 id: string;
123 description: string;
124 trigger: string;
125 regex: RegExp;
126 source: string;
127 custom: boolean;
128}
129
130export interface AutoformatMatch {
131 id: string;
132 match: RegExpMatchArray;
133}
134
135export interface ParsedLink {
136 text: string;
137 href: string;
138}
139
140export interface MarkdownToggleOptions {
141 getEditorHtml: () => string;
142 setEditorHtml: (html: string) => void;
143 htmlToMarkdown: (html: string) => string;
144 markdownToHtml: (md: string) => string;
145 onModeChange?: (mode: string) => void;
146}
147
148export interface MarkdownToggleApi {
149 toggle: () => void;
150 getMode: () => string;
151 isMarkdownMode: () => boolean;
152 getMarkdownContent: () => string;
153 setMarkdownContent: (content: string) => void;
154}
155
156export interface ShortcutEntry {
157 keys: string[];
158 label: string;
159}
160
161export interface ShortcutCategory {
162 category: string;
163 shortcuts: ShortcutEntry[];
164}
165
166export type CommandExecutor = (editor: Editor) => void;
167
168export interface SlashCommandsConfig {
169 onStart?: (props: SuggestionCallbackProps) => void;
170 onUpdate?: (props: SuggestionCallbackProps) => void;
171 onExit?: () => void;
172 onKeyDown?: (props: { event: KeyboardEvent }) => boolean;
173 items: (query: string) => SlashCommandExecutableItem[];
174}
175
176export interface SlashCommandExecutableItem extends SlashCommandItem {
177 execute: CommandExecutor;
178}
179
180export interface SuggestionCallbackProps {
181 query: string;
182 command: (item: SlashCommandExecutableItem) => void;
183 clientRect?: (() => DOMRect | null) | null;
184}
185
186export interface SearchReplaceStorage {
187 searchTerm: string;
188 replaceTerm: string;
189 caseSensitive: boolean;
190 matches: SearchResult[];
191 activeIndex: number;
192 isOpen: boolean;
193 showReplace: boolean;
194}
195
196export type BlockHandleMode = 'normal' | 'zen' | 'print';
197
198export interface LinkAttrs {
199 href?: string;
200}
201
202export interface CommentAttrs {
203 commentId: string;
204 author: string;
205 timestamp: string;
206 text: string;
207}
208
209export interface SuggestionMarkAttrs {
210 suggestionId: string | null;
211 author: string | null;
212 timestamp: string | null;
213}
214
215export interface ActiveComment {
216 id: string;
217 element: Element;
218}
219
220export interface ActiveSuggestion {
221 id: string;
222 element: Element;
223 type: 'insert' | 'delete';
224}