From ee0c9aabb2ce9112a16e930420706bbd5b3fc988 Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Tue, 10 Feb 2026 22:14:23 +0400 Subject: [PATCH] handle pasting bluesky posts --- components/Blocks/TextBlock/useHandlePaste.ts | 21 ++++++++++++++++++- src/utils/getBlocksAsHTML.tsx | 11 +++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/components/Blocks/TextBlock/useHandlePaste.ts b/components/Blocks/TextBlock/useHandlePaste.ts index 1e50bc5d..3e165a67 100644 --- a/components/Blocks/TextBlock/useHandlePaste.ts +++ b/components/Blocks/TextBlock/useHandlePaste.ts @@ -396,6 +396,24 @@ const createBlockFromHTML = ( ]); } + if (child.tagName === "DIV" && child.getAttribute("data-bluesky-post")) { + let postData = child.getAttribute("data-bluesky-post"); + if (postData) { + rep.mutate.assertFact([ + { + entity: entityID, + attribute: "block/type", + data: { type: "block-type-union", value: "bluesky-post" }, + }, + { + entity: entityID, + attribute: "block/bluesky-post", + data: { type: "bluesky-post", value: JSON.parse(postData) }, + }, + ]); + } + } + if (child.tagName === "DIV" && child.getAttribute("data-entityid")) { let oldEntityID = child.getAttribute("data-entityid") as string; let factsData = child.getAttribute("data-facts"); @@ -593,7 +611,8 @@ function flattenHTMLToTextBlocks(element: HTMLElement): HTMLElement[] { "HR", ].includes(elementNode.tagName) || elementNode.getAttribute("data-entityid") || - elementNode.getAttribute("data-tex") + elementNode.getAttribute("data-tex") || + elementNode.getAttribute("data-bluesky-post") ) { htmlBlocks.push(elementNode); } else { diff --git a/src/utils/getBlocksAsHTML.tsx b/src/utils/getBlocksAsHTML.tsx index 98bf380a..d9ac5b73 100644 --- a/src/utils/getBlocksAsHTML.tsx +++ b/src/utils/getBlocksAsHTML.tsx @@ -79,7 +79,16 @@ const BlockTypeToHTML: { mailbox: async () => null, poll: async () => null, embed: async () => null, - "bluesky-post": async () => null, + "bluesky-post": async (b, tx) => { + let [post] = await scanIndex(tx).eav(b.value, "block/bluesky-post"); + if (!post) return null; + return ( +
+ ); + }, math: async (b, tx, a) => { let [math] = await scanIndex(tx).eav(b.value, "block/math"); const html = Katex.renderToString(math?.data.value || "", { -- 2.51.2