a tool for shared writing and social publishing

handle pasting bluesky posts

+30 -2
+20 -1
components/Blocks/TextBlock/useHandlePaste.ts
··· 396 396 ]); 397 397 } 398 398 399 + if (child.tagName === "DIV" && child.getAttribute("data-bluesky-post")) { 400 + let postData = child.getAttribute("data-bluesky-post"); 401 + if (postData) { 402 + rep.mutate.assertFact([ 403 + { 404 + entity: entityID, 405 + attribute: "block/type", 406 + data: { type: "block-type-union", value: "bluesky-post" }, 407 + }, 408 + { 409 + entity: entityID, 410 + attribute: "block/bluesky-post", 411 + data: { type: "bluesky-post", value: JSON.parse(postData) }, 412 + }, 413 + ]); 414 + } 415 + } 416 + 399 417 if (child.tagName === "DIV" && child.getAttribute("data-entityid")) { 400 418 let oldEntityID = child.getAttribute("data-entityid") as string; 401 419 let factsData = child.getAttribute("data-facts"); ··· 593 611 "HR", 594 612 ].includes(elementNode.tagName) || 595 613 elementNode.getAttribute("data-entityid") || 596 - elementNode.getAttribute("data-tex") 614 + elementNode.getAttribute("data-tex") || 615 + elementNode.getAttribute("data-bluesky-post") 597 616 ) { 598 617 htmlBlocks.push(elementNode); 599 618 } else {
+10 -1
src/utils/getBlocksAsHTML.tsx
··· 79 79 mailbox: async () => null, 80 80 poll: async () => null, 81 81 embed: async () => null, 82 - "bluesky-post": async () => null, 82 + "bluesky-post": async (b, tx) => { 83 + let [post] = await scanIndex(tx).eav(b.value, "block/bluesky-post"); 84 + if (!post) return null; 85 + return ( 86 + <div 87 + data-type="bluesky-post" 88 + data-bluesky-post={JSON.stringify(post.data.value)} 89 + /> 90 + ); 91 + }, 83 92 math: async (b, tx, a) => { 84 93 let [math] = await scanIndex(tx).eav(b.value, "block/math"); 85 94 const html = Katex.renderToString(math?.data.value || "", {