a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #57 from hyperlink-academy/Virtual-branch

Added Card, Link, and Mailbox Blocks into the getAsHTML parser

authored by

celine and committed by
GitHub
0358f9f8 446add1a

+20 -1
-1
components/SelectionManager.tsx
··· 3 3 import { create } from "zustand"; 4 4 import { useReplicache } from "src/replicache"; 5 5 import { useUIState } from "src/useUIState"; 6 - import { getBlocksAsHTML } from "src/utils/getBlocksAsHTML"; 7 6 import { scanIndex } from "src/replicache/utils"; 8 7 import { Block, focusBlock } from "./Blocks"; 9 8 import { useEditorStates } from "src/state/useEditorState";
+20
src/utils/getBlocksAsHTML.tsx
··· 59 59 let headingLevel = await scanIndex(tx).eav(b.value, "block/heading-level"); 60 60 wrapper = "h" + headingLevel[0].data.value; 61 61 } 62 + if (b.type === "link") { 63 + let [url] = await scanIndex(tx).eav(b.value, "link/url"); 64 + let [title] = await scanIndex(tx).eav(b.value, "link/title"); 65 + if (!url) return ""; 66 + return renderToStaticMarkup( 67 + <a href={url.data.value} target="_blank"> 68 + {title.data.value} 69 + </a>, 70 + ); 71 + } 72 + if (b.type === "card" || b.type === "mailbox") { 73 + return renderToStaticMarkup( 74 + <div> 75 + <a href={window.location.href} target="_blank"> 76 + View {b.type} 77 + </a>{" "} 78 + in Leaflet! 79 + </div>, 80 + ); 81 + } 62 82 let value = (await scanIndex(tx).eav(b.value, "block/text"))[0]; 63 83 if (!value) 64 84 return ignoreWrapper ? "" : `<${wrapper || "p"}></${wrapper || "p"}>`;