a tool for shared writing and social publishing
1import { LexiconDoc, LexRefUnion } from "@atproto/lexicon";
2import { PubLeafletRichTextFacet } from "./facet";
3
4export const PubLeafletBlocksText: LexiconDoc = {
5 lexicon: 1,
6 id: "pub.leaflet.blocks.text",
7 defs: {
8 main: {
9 type: "object",
10 required: ["plaintext"],
11 properties: {
12 plaintext: { type: "string" },
13 textSize: { type: "string", enum: ["default", "small", "large"] },
14 facets: {
15 type: "array",
16 items: { type: "ref", ref: PubLeafletRichTextFacet.id },
17 },
18 },
19 },
20 },
21};
22
23export const PubLeafletBlocksPage: LexiconDoc = {
24 lexicon: 1,
25 id: "pub.leaflet.blocks.page",
26 defs: {
27 main: {
28 type: "object",
29 required: ["id"],
30 properties: {
31 id: { type: "string" },
32 },
33 },
34 },
35};
36
37export const PubLeafletBlocksBskyPost: LexiconDoc = {
38 lexicon: 1,
39 id: "pub.leaflet.blocks.bskyPost",
40 defs: {
41 main: {
42 type: "object",
43 required: ["postRef"],
44 properties: {
45 postRef: { type: "ref", ref: "com.atproto.repo.strongRef" },
46 },
47 },
48 },
49};
50
51export const PubLeafletBlocksBlockQuote: LexiconDoc = {
52 lexicon: 1,
53 id: "pub.leaflet.blocks.blockquote",
54 defs: {
55 main: {
56 type: "object",
57 required: ["plaintext"],
58 properties: {
59 plaintext: { type: "string" },
60 facets: {
61 type: "array",
62 items: { type: "ref", ref: PubLeafletRichTextFacet.id },
63 },
64 },
65 },
66 },
67};
68
69export const PubLeafletBlocksHorizontalRule: LexiconDoc = {
70 lexicon: 1,
71 id: "pub.leaflet.blocks.horizontalRule",
72 defs: {
73 main: {
74 type: "object",
75 required: [],
76 properties: {},
77 },
78 },
79};
80
81export const PubLeafletBlocksCode: LexiconDoc = {
82 lexicon: 1,
83 id: "pub.leaflet.blocks.code",
84 defs: {
85 main: {
86 type: "object",
87 required: ["plaintext"],
88 properties: {
89 plaintext: { type: "string" },
90 language: { type: "string" },
91 syntaxHighlightingTheme: { type: "string" },
92 },
93 },
94 },
95};
96
97export const PubLeafletBlocksMath: LexiconDoc = {
98 lexicon: 1,
99 id: "pub.leaflet.blocks.math",
100 defs: {
101 main: {
102 type: "object",
103 required: ["tex"],
104 properties: {
105 tex: { type: "string" },
106 },
107 },
108 },
109};
110
111export const PubLeafletBlocksLeafletQuote: LexiconDoc = {
112 lexicon: 1,
113 id: "pub.leaflet.blocks.leafletQuote",
114 defs: {
115 main: {
116 type: "object",
117 required: ["src"],
118 properties: {
119 record: { type: "ref", ref: "com.atproto.repo.strongRef" },
120 position: {
121 type: "union",
122 refs: ["pub.leaflet.pages.linearDocument#quote"],
123 },
124 },
125 },
126 },
127};
128
129export const PubLeafletBlocksWebsite: LexiconDoc = {
130 lexicon: 1,
131 id: "pub.leaflet.blocks.website",
132 defs: {
133 main: {
134 type: "object",
135 required: ["src"],
136 properties: {
137 previewImage: { type: "blob", accept: ["image/*"], maxSize: 1000000 },
138 title: { type: "string" },
139 description: { type: "string" },
140 src: { type: "string", format: "uri" },
141 },
142 },
143 },
144};
145
146export const PubLeafletBlocksHeader: LexiconDoc = {
147 lexicon: 1,
148 id: "pub.leaflet.blocks.header",
149 defs: {
150 main: {
151 type: "object",
152 required: ["plaintext"],
153 properties: {
154 level: { type: "integer", minimum: 1, maximum: 6 },
155 plaintext: { type: "string" },
156 facets: {
157 type: "array",
158 items: { type: "ref", ref: PubLeafletRichTextFacet.id },
159 },
160 },
161 },
162 },
163};
164
165export const PubLeafletBlocksImage: LexiconDoc = {
166 lexicon: 1,
167 id: "pub.leaflet.blocks.image",
168 defs: {
169 main: {
170 type: "object",
171 required: ["image", "aspectRatio"],
172 properties: {
173 image: { type: "blob", accept: ["image/*"], maxSize: 1000000 },
174 alt: {
175 type: "string",
176 description: "Alt text description of the image, for accessibility.",
177 },
178 aspectRatio: {
179 type: "ref",
180 ref: "#aspectRatio",
181 },
182 },
183 },
184 aspectRatio: {
185 type: "object",
186 required: ["width", "height"],
187 properties: {
188 width: { type: "integer" },
189 height: { type: "integer" },
190 },
191 },
192 },
193};
194
195export const PubLeafletBlocksOrderedList: LexiconDoc = {
196 lexicon: 1,
197 id: "pub.leaflet.blocks.orderedList",
198 defs: {
199 main: {
200 type: "object",
201 required: ["children"],
202 properties: {
203 startIndex: { type: "integer" },
204 children: { type: "array", items: { type: "ref", ref: "#listItem" } },
205 },
206 },
207 listItem: {
208 type: "object",
209 required: ["content"],
210 properties: {
211 content: {
212 type: "union",
213 refs: [
214 PubLeafletBlocksText,
215 PubLeafletBlocksHeader,
216 PubLeafletBlocksImage,
217 ].map((l) => l.id),
218 },
219 children: { type: "array", items: { type: "ref", ref: "#listItem" } },
220 },
221 },
222 },
223};
224
225export const PubLeafletBlocksUnorderedList: LexiconDoc = {
226 lexicon: 1,
227 id: "pub.leaflet.blocks.unorderedList",
228 defs: {
229 main: {
230 type: "object",
231 required: ["children"],
232 properties: {
233 children: { type: "array", items: { type: "ref", ref: "#listItem" } },
234 },
235 },
236 listItem: {
237 type: "object",
238 required: ["content"],
239 properties: {
240 content: {
241 type: "union",
242 refs: [
243 PubLeafletBlocksText,
244 PubLeafletBlocksHeader,
245 PubLeafletBlocksImage,
246 ].map((l) => l.id),
247 },
248 children: { type: "array", items: { type: "ref", ref: "#listItem" } },
249 },
250 },
251 },
252};
253
254export const PubLeafletBlocksIFrame: LexiconDoc = {
255 lexicon: 1,
256 id: "pub.leaflet.blocks.iframe",
257 defs: {
258 main: {
259 type: "object",
260 required: ["url"],
261 properties: {
262 url: { type: "string", format: "uri" },
263 height: { type: "integer", minimum: 16, maximum: 1600 },
264 },
265 },
266 },
267};
268
269export const PubLeafletBlocksPoll: LexiconDoc = {
270 lexicon: 1,
271 id: "pub.leaflet.blocks.poll",
272 defs: {
273 main: {
274 type: "object",
275 required: ["pollRef"],
276 properties: {
277 pollRef: { type: "ref", ref: "com.atproto.repo.strongRef" },
278 },
279 },
280 },
281};
282
283export const PubLeafletBlocksButton: LexiconDoc = {
284 lexicon: 1,
285 id: "pub.leaflet.blocks.button",
286 defs: {
287 main: {
288 type: "object",
289 required: ["text", "url"],
290 properties: {
291 text: { type: "string" },
292 url: { type: "string", format: "uri" },
293 },
294 },
295 },
296};
297
298export const BlockLexicons = [
299 PubLeafletBlocksIFrame,
300 PubLeafletBlocksText,
301 PubLeafletBlocksBlockQuote,
302 PubLeafletBlocksHeader,
303 PubLeafletBlocksImage,
304 PubLeafletBlocksUnorderedList,
305 PubLeafletBlocksWebsite,
306 PubLeafletBlocksMath,
307 PubLeafletBlocksCode,
308 PubLeafletBlocksHorizontalRule,
309 PubLeafletBlocksBskyPost,
310 PubLeafletBlocksPage,
311 PubLeafletBlocksPoll,
312 PubLeafletBlocksButton,
313];
314export const BlockUnion: LexRefUnion = {
315 type: "union",
316 refs: [...BlockLexicons.map((lexicon) => lexicon.id)],
317};