From bda40f62ce15e20ce92a8a4a64c083055b63f95b Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Thu, 7 Aug 2025 11:57:30 -0400 Subject: [PATCH] add horizontal rules --- actions/publishToPublication.ts | 11 +++++++- .../[publication]/[rkey]/PostContent.tsx | 4 +++ .../[rkey]/StaticPostContent.tsx | 4 +++ components/Blocks/Block.tsx | 2 ++ components/Blocks/HorizontalRule.tsx | 3 +++ components/Blocks/TextBlock/index.tsx | 11 ++++++++ components/Blocks/TextBlock/useHandlePaste.ts | 5 ++++ lexicons/api/index.ts | 2 ++ lexicons/api/lexicons.ts | 13 ++++++++++ .../pub/leaflet/blocks/horizontalRule.ts | 25 +++++++++++++++++++ .../types/pub/leaflet/pages/linearDocument.ts | 2 ++ .../pub/leaflet/blocks/horizontalRule.json | 11 ++++++++ .../pub/leaflet/pages/linearDocument.json | 3 ++- lexicons/src/blocks.ts | 14 +++++++++++ src/replicache/attributes.ts | 3 ++- src/utils/getBlocksAsHTML.tsx | 3 +++ 16 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 components/Blocks/HorizontalRule.tsx create mode 100644 lexicons/api/types/pub/leaflet/blocks/horizontalRule.ts create mode 100644 lexicons/pub/leaflet/blocks/horizontalRule.json diff --git a/actions/publishToPublication.ts b/actions/publishToPublication.ts index 3f586921..be6bbc1d 100644 --- a/actions/publishToPublication.ts +++ b/actions/publishToPublication.ts @@ -16,6 +16,7 @@ import { PubLeafletBlocksWebsite, PubLeafletBlocksCode, PubLeafletBlocksMath, + PubLeafletBlocksHorizontalRule, } from "lexicons/api"; import { Block } from "components/Blocks/Block"; import { TID } from "@atproto/common"; @@ -232,10 +233,18 @@ function blockToRecord( b.type !== "image" && b.type !== "link" && b.type !== "code" && - b.type !== "math" + b.type !== "math" && + b.type !== "horizontal-rule" ) return; + if (b.type === "horizontal-rule") { + let block: $Typed = { + $type: ids.PubLeafletBlocksHorizontalRule, + }; + return block; + } + if (b.type === "heading") { let [headingLevel] = scan.eav(b.value, "block/heading-level"); diff --git a/app/lish/[did]/[publication]/[rkey]/PostContent.tsx b/app/lish/[did]/[publication]/[rkey]/PostContent.tsx index 849d9a65..632386bd 100644 --- a/app/lish/[did]/[publication]/[rkey]/PostContent.tsx +++ b/app/lish/[did]/[publication]/[rkey]/PostContent.tsx @@ -8,6 +8,7 @@ import { PubLeafletBlocksWebsite, PubLeafletDocument, PubLeafletPagesLinearDocument, + PubLeafletBlocksHorizontalRule, } from "lexicons/api"; import { blobRefToSrc } from "src/utils/blobRefToSrc"; import { TextBlock } from "./TextBlock"; @@ -92,6 +93,9 @@ let Block = ({ `; switch (true) { + case PubLeafletBlocksHorizontalRule.isMain(b.block): { + return
; + } case PubLeafletBlocksUnorderedList.isMain(b.block): { return (