a tool for shared writing and social publishing
at update/reader 100 lines 2.8 kB view raw
1import { LexiconDoc } from "@atproto/lexicon"; 2const FacetItems: LexiconDoc["defs"] = { 3 link: { 4 type: "object", 5 description: 6 "Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.", 7 required: ["uri"], 8 properties: { 9 uri: { type: "string" }, 10 }, 11 }, 12 didMention: { 13 type: "object", 14 description: "Facet feature for mentioning a did.", 15 required: ["did"], 16 properties: { did: { type: "string", format: "did" } }, 17 }, 18 atMention: { 19 type: "object", 20 description: "Facet feature for mentioning an AT URI.", 21 required: ["atURI"], 22 properties: { atURI: { type: "string", format: "uri" } }, 23 }, 24 code: { 25 type: "object", 26 description: "Facet feature for inline code.", 27 required: [], 28 properties: {}, 29 }, 30 highlight: { 31 type: "object", 32 description: "Facet feature for highlighted text.", 33 required: [], 34 properties: {}, 35 }, 36 underline: { 37 type: "object", 38 description: "Facet feature for underline markup", 39 required: [], 40 properties: {}, 41 }, 42 strikethrough: { 43 type: "object", 44 description: "Facet feature for strikethrough markup", 45 required: [], 46 properties: {}, 47 }, 48 id: { 49 type: "object", 50 description: 51 "Facet feature for an identifier. Used for linking to a segment", 52 required: [], 53 properties: { id: { type: "string" } }, 54 }, 55 bold: { 56 type: "object", 57 description: "Facet feature for bold text", 58 required: [], 59 properties: {}, 60 }, 61 italic: { 62 type: "object", 63 description: "Facet feature for italic text", 64 required: [], 65 properties: {}, 66 }, 67}; 68 69export const PubLeafletRichTextFacet = { 70 lexicon: 1, 71 id: "pub.leaflet.richtext.facet", 72 defs: { 73 main: { 74 type: "object", 75 description: "Annotation of a sub-string within rich text.", 76 required: ["index", "features"], 77 properties: { 78 index: { type: "ref", ref: "#byteSlice" }, 79 features: { 80 type: "array", 81 items: { 82 type: "union", 83 refs: Object.keys(FacetItems).map((k) => `#${k}`), 84 }, 85 }, 86 }, 87 }, 88 byteSlice: { 89 type: "object", 90 description: 91 "Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.", 92 required: ["byteStart", "byteEnd"], 93 properties: { 94 byteStart: { type: "integer", minimum: 0 }, 95 byteEnd: { type: "integer", minimum: 0 }, 96 }, 97 }, 98 ...FacetItems, 99 }, 100};