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 clientHost: { type: "string" },
47 },
48 },
49 },
50};
51
52export const PubLeafletBlocksBlockQuote: LexiconDoc = {
53 lexicon: 1,
54 id: "pub.leaflet.blocks.blockquote",
55 defs: {
56 main: {
57 type: "object",
58 required: ["plaintext"],
59 properties: {
60 plaintext: { type: "string" },
61 facets: {
62 type: "array",
63 items: { type: "ref", ref: PubLeafletRichTextFacet.id },
64 },
65 },
66 },
67 },
68};
69
70export const PubLeafletBlocksHorizontalRule: LexiconDoc = {
71 lexicon: 1,
72 id: "pub.leaflet.blocks.horizontalRule",
73 defs: {
74 main: {
75 type: "object",
76 required: [],
77 properties: {},
78 },
79 },
80};
81
82export const PubLeafletBlocksCode: LexiconDoc = {
83 lexicon: 1,
84 id: "pub.leaflet.blocks.code",
85 defs: {
86 main: {
87 type: "object",
88 required: ["plaintext"],
89 properties: {
90 plaintext: { type: "string" },
91 language: { type: "string" },
92 syntaxHighlightingTheme: { type: "string" },
93 },
94 },
95 },
96};
97
98export const PubLeafletBlocksMath: LexiconDoc = {
99 lexicon: 1,
100 id: "pub.leaflet.blocks.math",
101 defs: {
102 main: {
103 type: "object",
104 required: ["tex"],
105 properties: {
106 tex: { type: "string" },
107 },
108 },
109 },
110};
111
112export const PubLeafletBlocksLeafletQuote: LexiconDoc = {
113 lexicon: 1,
114 id: "pub.leaflet.blocks.leafletQuote",
115 defs: {
116 main: {
117 type: "object",
118 required: ["src"],
119 properties: {
120 record: { type: "ref", ref: "com.atproto.repo.strongRef" },
121 position: {
122 type: "union",
123 refs: ["pub.leaflet.pages.linearDocument#quote"],
124 },
125 },
126 },
127 },
128};
129
130export const PubLeafletBlocksWebsite: LexiconDoc = {
131 lexicon: 1,
132 id: "pub.leaflet.blocks.website",
133 defs: {
134 main: {
135 type: "object",
136 required: ["src"],
137 properties: {
138 previewImage: { type: "blob", accept: ["image/*"], maxSize: 1000000 },
139 title: { type: "string" },
140 description: { type: "string" },
141 src: { type: "string", format: "uri" },
142 },
143 },
144 },
145};
146
147export const PubLeafletBlocksHeader: LexiconDoc = {
148 lexicon: 1,
149 id: "pub.leaflet.blocks.header",
150 defs: {
151 main: {
152 type: "object",
153 required: ["plaintext"],
154 properties: {
155 level: { type: "integer", minimum: 1, maximum: 6 },
156 plaintext: { type: "string" },
157 facets: {
158 type: "array",
159 items: { type: "ref", ref: PubLeafletRichTextFacet.id },
160 },
161 },
162 },
163 },
164};
165
166export const PubLeafletBlocksImage: LexiconDoc = {
167 lexicon: 1,
168 id: "pub.leaflet.blocks.image",
169 defs: {
170 main: {
171 type: "object",
172 required: ["image", "aspectRatio"],
173 properties: {
174 image: { type: "blob", accept: ["image/*"], maxSize: 1000000 },
175 alt: {
176 type: "string",
177 description: "Alt text description of the image, for accessibility.",
178 },
179 aspectRatio: {
180 type: "ref",
181 ref: "#aspectRatio",
182 },
183 },
184 },
185 aspectRatio: {
186 type: "object",
187 required: ["width", "height"],
188 properties: {
189 width: { type: "integer" },
190 height: { type: "integer" },
191 },
192 },
193 },
194};
195
196export const PubLeafletBlocksOrderedList: LexiconDoc = {
197 lexicon: 1,
198 id: "pub.leaflet.blocks.orderedList",
199 defs: {
200 main: {
201 type: "object",
202 required: ["children"],
203 properties: {
204 startIndex: {
205 type: "integer",
206 description: "The starting number for this ordered list. Defaults to 1 if not specified.",
207 },
208 children: { type: "array", items: { type: "ref", ref: "#listItem" } },
209 },
210 },
211 listItem: {
212 type: "object",
213 required: ["content"],
214 properties: {
215 content: {
216 type: "union",
217 refs: [
218 PubLeafletBlocksText,
219 PubLeafletBlocksHeader,
220 PubLeafletBlocksImage,
221 ].map((l) => l.id),
222 },
223 children: {
224 type: "array",
225 description: "Nested ordered list items. Mutually exclusive with unorderedListChildren; if both are present, children takes precedence.",
226 items: { type: "ref", ref: "#listItem" },
227 },
228 unorderedListChildren: {
229 type: "ref",
230 description: "A nested unordered list. Mutually exclusive with children; if both are present, children takes precedence.",
231 ref: "pub.leaflet.blocks.unorderedList",
232 },
233 },
234 },
235 },
236};
237
238export const PubLeafletBlocksUnorderedList: LexiconDoc = {
239 lexicon: 1,
240 id: "pub.leaflet.blocks.unorderedList",
241 defs: {
242 main: {
243 type: "object",
244 required: ["children"],
245 properties: {
246 children: { type: "array", items: { type: "ref", ref: "#listItem" } },
247 },
248 },
249 listItem: {
250 type: "object",
251 required: ["content"],
252 properties: {
253 content: {
254 type: "union",
255 refs: [
256 PubLeafletBlocksText,
257 PubLeafletBlocksHeader,
258 PubLeafletBlocksImage,
259 ].map((l) => l.id),
260 },
261 children: {
262 type: "array",
263 description: "Nested unordered list items. Mutually exclusive with orderedListChildren; if both are present, children takes precedence.",
264 items: { type: "ref", ref: "#listItem" },
265 },
266 orderedListChildren: {
267 type: "ref",
268 description: "Nested ordered list items. Mutually exclusive with children; if both are present, children takes precedence.",
269 ref: "pub.leaflet.blocks.orderedList",
270 },
271 },
272 },
273 },
274};
275
276export const PubLeafletBlocksIFrame: LexiconDoc = {
277 lexicon: 1,
278 id: "pub.leaflet.blocks.iframe",
279 defs: {
280 main: {
281 type: "object",
282 required: ["url"],
283 properties: {
284 url: { type: "string", format: "uri" },
285 height: { type: "integer", minimum: 16, maximum: 1600 },
286 },
287 },
288 },
289};
290
291export const PubLeafletBlocksPoll: LexiconDoc = {
292 lexicon: 1,
293 id: "pub.leaflet.blocks.poll",
294 defs: {
295 main: {
296 type: "object",
297 required: ["pollRef"],
298 properties: {
299 pollRef: { type: "ref", ref: "com.atproto.repo.strongRef" },
300 },
301 },
302 },
303};
304
305export const PubLeafletBlocksButton: LexiconDoc = {
306 lexicon: 1,
307 id: "pub.leaflet.blocks.button",
308 defs: {
309 main: {
310 type: "object",
311 required: ["text", "url"],
312 properties: {
313 text: { type: "string" },
314 url: { type: "string", format: "uri" },
315 },
316 },
317 },
318};
319
320export const BlockLexicons = [
321 PubLeafletBlocksIFrame,
322 PubLeafletBlocksText,
323 PubLeafletBlocksBlockQuote,
324 PubLeafletBlocksHeader,
325 PubLeafletBlocksImage,
326 PubLeafletBlocksUnorderedList,
327 PubLeafletBlocksOrderedList,
328 PubLeafletBlocksWebsite,
329 PubLeafletBlocksMath,
330 PubLeafletBlocksCode,
331 PubLeafletBlocksHorizontalRule,
332 PubLeafletBlocksBskyPost,
333 PubLeafletBlocksPage,
334 PubLeafletBlocksPoll,
335 PubLeafletBlocksButton,
336];
337export const BlockUnion: LexRefUnion = {
338 type: "union",
339 refs: [...BlockLexicons.map((lexicon) => lexicon.id)],
340};