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