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