a tool for shared writing and social publishing

properly handle text-align-justify in publications

+22 -2
+12 -2
actions/publishToPublication.ts
··· 195 195 let alignmentValue = 196 196 scan.eav(blockOrList.block.value, "block/text-alignment")[0]?.data 197 197 .value || "left"; 198 - let alignment = 198 + let alignment: ExcludeString< 199 + PubLeafletPagesLinearDocument.Block["alignment"] 200 + > = 199 201 alignmentValue === "center" 200 202 ? "lex:pub.leaflet.pages.linearDocument#textAlignCenter" 201 203 : alignmentValue === "right" 202 204 ? "lex:pub.leaflet.pages.linearDocument#textAlignRight" 203 - : undefined; 205 + : alignmentValue === "justify" 206 + ? "lex:pub.leaflet.pages.linearDocument#textAlignJustify" 207 + : undefined; 204 208 let b = await blockToRecord(blockOrList.block, did); 205 209 if (!b) return []; 206 210 let block: PubLeafletPagesLinearDocument.Block = { ··· 547 551 } 548 552 return []; 549 553 } 554 + 555 + type ExcludeString<T> = T extends string 556 + ? string extends T 557 + ? never 558 + : T /* maybe literal, not the whole `string` */ 559 + : T; /* not a string */
+2
lexicons/api/index.ts
··· 96 96 'pub.leaflet.pages.linearDocument#textAlignCenter', 97 97 LinearDocumentTextAlignRight: 98 98 'pub.leaflet.pages.linearDocument#textAlignRight', 99 + LinearDocumentTextAlignJustify: 100 + 'pub.leaflet.pages.linearDocument#textAlignJustify', 99 101 } 100 102 101 103 export class AtpBaseClient extends XrpcClient {
+3
lexicons/api/lexicons.ts
··· 1615 1615 textAlignRight: { 1616 1616 type: 'token', 1617 1617 }, 1618 + textAlignJustify: { 1619 + type: 'token', 1620 + }, 1618 1621 quote: { 1619 1622 type: 'object', 1620 1623 required: ['start', 'end'],
+1
lexicons/api/types/pub/leaflet/pages/linearDocument.ts
··· 81 81 export const TEXTALIGNLEFT = `${id}#textAlignLeft` 82 82 export const TEXTALIGNCENTER = `${id}#textAlignCenter` 83 83 export const TEXTALIGNRIGHT = `${id}#textAlignRight` 84 + export const TEXTALIGNJUSTIFY = `${id}#textAlignJustify` 84 85 85 86 export interface Quote { 86 87 $type?: 'pub.leaflet.pages.linearDocument#quote'
+3
lexicons/pub/leaflet/pages/linearDocument.json
··· 64 64 "textAlignRight": { 65 65 "type": "token" 66 66 }, 67 + "textAlignJustify": { 68 + "type": "token" 69 + }, 67 70 "quote": { 68 71 "type": "object", 69 72 "required": [
+1
lexicons/src/pages/LinearDocument.ts
··· 32 32 textAlignLeft: { type: "token" }, 33 33 textAlignCenter: { type: "token" }, 34 34 textAlignRight: { type: "token" }, 35 + textAlignJustify: { type: "token" }, 35 36 quote: { 36 37 type: "object", 37 38 required: ["start", "end"],