File tree Expand file tree Collapse file tree 3 files changed +465
-0
lines changed Expand file tree Collapse file tree 3 files changed +465
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * *** MIT LICENSE ***
3
+ * -------------------------------------------------------------------------
4
+ * This code may be modified and distributed under the MIT license.
5
+ * See the LICENSE file for details.
6
+ * -------------------------------------------------------------------------
7
+ *
8
+ * @summary Collection of formatting related types
9
+ *
10
+ * @author Alvis HT Tang <alvis@hilbert.space>
11
+ * @license MIT
12
+ * @copyright Copyright (c) 2021 - All Rights Reserved.
13
+ * -------------------------------------------------------------------------
14
+ */
15
+
16
+ import type { DateValue } from './property' ;
17
+ import type { User } from './user' ;
18
+
19
+ /*
20
+ * Colour
21
+ */
22
+
23
+ export type Color =
24
+ | 'default'
25
+ | 'gray'
26
+ | 'brown'
27
+ | 'orange'
28
+ | 'yellow'
29
+ | 'green'
30
+ | 'blue'
31
+ | 'purple'
32
+ | 'pink'
33
+ | 'red' ;
34
+
35
+ export type BackgroundColor =
36
+ | 'gray_background'
37
+ | 'brown_background'
38
+ | 'orange_background'
39
+ | 'yellow_background'
40
+ | 'green_background'
41
+ | 'blue_background'
42
+ | 'purple_background'
43
+ | 'pink_background'
44
+ | 'red_background' ;
45
+
46
+ /*
47
+ * Flags
48
+ */
49
+
50
+ export interface Annotation {
51
+ bold : boolean ;
52
+ italic : boolean ;
53
+ strikethrough : boolean ;
54
+ underline : boolean ;
55
+ code : boolean ;
56
+ color : Color | BackgroundColor ;
57
+ }
58
+
59
+ /*
60
+ * Base
61
+ */
62
+
63
+ interface RichTextBase < T extends string > {
64
+ plain_text : string ;
65
+ href : string | null ;
66
+ annotations : Annotation ;
67
+ type : T ;
68
+ }
69
+
70
+ /*
71
+ * Text
72
+ */
73
+
74
+ interface RichTextText extends RichTextBase < 'text' > {
75
+ text : {
76
+ content : string ;
77
+ link : { url : string } | null ;
78
+ } ;
79
+ }
80
+
81
+ /*
82
+ * Mention
83
+ */
84
+
85
+ interface UserMention {
86
+ type : 'user' ;
87
+ user : User ;
88
+ }
89
+
90
+ interface PageMention {
91
+ type : 'page' ;
92
+ page : { id : string } ;
93
+ }
94
+
95
+ interface DatabaseMention {
96
+ type : 'database' ;
97
+ database : { id : string } ;
98
+ }
99
+
100
+ interface DateMention {
101
+ type : 'date' ;
102
+ date : DateValue ;
103
+ }
104
+
105
+ interface RichTextMention extends RichTextBase < 'mention' > {
106
+ mention : UserMention | PageMention | DatabaseMention | DateMention ;
107
+ }
108
+
109
+ /*
110
+ * Equation
111
+ */
112
+
113
+ interface RichTextEquation extends RichTextBase < 'equation' > {
114
+ equation : {
115
+ expression : string ;
116
+ } ;
117
+ }
118
+
119
+ /*
120
+ * Main
121
+ */
122
+
123
+ export type RichText = RichTextText | RichTextMention | RichTextEquation ;
Original file line number Diff line number Diff line change 15
15
16
16
/* istanbul ignore file */
17
17
18
+ export * from './format' ;
18
19
export * from './user' ;
20
+ export * from './property' ;
You can’t perform that action at this time.
0 commit comments