a tool for shared writing and social publishing
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 code: {
13 type: "object",
14 description: "Facet feature for inline code.",
15 required: [],
16 properties: {},
17 },
18 highlight: {
19 type: "object",
20 description: "Facet feature for highlighted text.",
21 required: [],
22 properties: {},
23 },
24 underline: {
25 type: "object",
26 description: "Facet feature for underline markup",
27 required: [],
28 properties: {},
29 },
30 strikethrough: {
31 type: "object",
32 description: "Facet feature for strikethrough markup",
33 required: [],
34 properties: {},
35 },
36 id: {
37 type: "object",
38 description:
39 "Facet feature for an identifier. Used for linking to a segment",
40 required: [],
41 properties: { id: { type: "string" } },
42 },
43 bold: {
44 type: "object",
45 description: "Facet feature for bold text",
46 required: [],
47 properties: {},
48 },
49 italic: {
50 type: "object",
51 description: "Facet feature for italic text",
52 required: [],
53 properties: {},
54 },
55};
56
57export const PubLeafletRichTextFacet = {
58 lexicon: 1,
59 id: "pub.leaflet.richtext.facet",
60 defs: {
61 main: {
62 type: "object",
63 description: "Annotation of a sub-string within rich text.",
64 required: ["index", "features"],
65 properties: {
66 index: { type: "ref", ref: "#byteSlice" },
67 features: {
68 type: "array",
69 items: {
70 type: "union",
71 refs: Object.keys(FacetItems).map((k) => `#${k}`),
72 },
73 },
74 },
75 },
76 byteSlice: {
77 type: "object",
78 description:
79 "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.",
80 required: ["byteStart", "byteEnd"],
81 properties: {
82 byteStart: { type: "integer", minimum: 0 },
83 byteEnd: { type: "integer", minimum: 0 },
84 },
85 },
86 ...FacetItems,
87 },
88};