a tool for shared writing and social publishing
0
fork

Configure Feed

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

restrict block types available in pub draft

celine 0fedfb90 6f9b4fa7

+48 -21
+14 -3
components/Blocks/BlockCommandBar.tsx
··· 5 5 import { useEntitySetContext } from "components/EntitySetProvider"; 6 6 import { NestedCardThemeProvider } from "components/ThemeManager/ThemeProvider"; 7 7 import { UndoManager } from "src/undoManager"; 8 + import { useLeafletPublicationData } from "components/PageSWRDataProvider"; 8 9 9 10 type Props = { 10 11 parent: string; ··· 29 30 30 31 let { rep, undoManager } = useReplicache(); 31 32 let entity_set = useEntitySetContext(); 33 + let { data: publicationData } = useLeafletPublicationData(); 34 + let pub = publicationData?.[0]; 32 35 33 - let commandResults = blockCommands.filter((command) => 34 - command.name.toLocaleLowerCase().includes(searchValue.toLocaleLowerCase()), 35 - ); 36 + let commandResults = blockCommands.filter((command) => { 37 + const matchesSearch = command.name 38 + .toLocaleLowerCase() 39 + .includes(searchValue.toLocaleLowerCase()); 40 + const isVisible = !pub || !command.hiddenInPublication; 41 + return matchesSearch && isVisible; 42 + }); 43 + 36 44 useEffect(() => { 37 45 if ( 38 46 !highlighted || ··· 186 194 </button> 187 195 ); 188 196 }; 197 + function usePublicationContext() { 198 + throw new Error("Function not implemented."); 199 + }
+10
components/Blocks/BlockCommands.tsx
··· 98 98 name: string; 99 99 icon: React.ReactNode; 100 100 type: string; 101 + hiddenInPublication?: boolean; 101 102 onSelect: ( 102 103 rep: Replicache<ReplicacheMutators>, 103 104 props: Props & { entity_set: string }, ··· 175 176 name: "Button", 176 177 icon: <BlockButtonSmall />, 177 178 type: "block", 179 + hiddenInPublication: true, 178 180 onSelect: async (rep, props, um) => { 179 181 props.entityID && clearCommandSearchText(props.entityID); 180 182 await createBlockWithType(rep, props, "button"); ··· 190 192 name: "Mailbox", 191 193 icon: <BlockMailboxSmall />, 192 194 type: "block", 195 + hiddenInPublication: true, 193 196 onSelect: async (rep, props, um) => { 194 197 props.entityID && clearCommandSearchText(props.entityID); 195 198 await createBlockWithType(rep, props, "mailbox"); ··· 205 208 name: "Poll", 206 209 icon: <BlockPollSmall />, 207 210 type: "block", 211 + hiddenInPublication: true, 208 212 onSelect: async (rep, props, um) => { 209 213 let entity = await createBlockWithType(rep, props, "poll"); 210 214 let pollOptionEntity = v7(); ··· 250 254 name: "Embed Website", 251 255 icon: <BlockEmbedSmall />, 252 256 type: "block", 257 + hiddenInPublication: true, 253 258 onSelect: async (rep, props) => { 254 259 createBlockWithType(rep, props, "embed"); 255 260 }, ··· 258 263 name: "Bluesky Post", 259 264 icon: <BlockBlueskySmall />, 260 265 type: "block", 266 + hiddenInPublication: true, 261 267 onSelect: async (rep, props) => { 262 268 createBlockWithType(rep, props, "bluesky-post"); 263 269 }, ··· 269 275 name: "RSVP", 270 276 icon: <BlockRSVPSmall />, 271 277 type: "event", 278 + hiddenInPublication: true, 272 279 onSelect: (rep, props) => { 273 280 props.entityID && clearCommandSearchText(props.entityID); 274 281 return createBlockWithType(rep, props, "rsvp"); ··· 278 285 name: "Date and Time", 279 286 icon: <BlockCalendarSmall />, 280 287 type: "event", 288 + hiddenInPublication: true, 281 289 onSelect: (rep, props) => { 282 290 props.entityID && clearCommandSearchText(props.entityID); 283 291 return createBlockWithType(rep, props, "datetime"); ··· 290 298 name: "New Page", 291 299 icon: <BlockDocPageSmall />, 292 300 type: "page", 301 + hiddenInPublication: true, 293 302 onSelect: async (rep, props, um) => { 294 303 props.entityID && clearCommandSearchText(props.entityID); 295 304 let entity = await createBlockWithType(rep, props, "card"); ··· 329 338 name: "New Canvas", 330 339 icon: <BlockCanvasPageSmall />, 331 340 type: "page", 341 + hiddenInPublication: true, 332 342 onSelect: async (rep, props, um) => { 333 343 props.entityID && clearCommandSearchText(props.entityID); 334 344 let entity = await createBlockWithType(rep, props, "card");
+24 -18
components/Blocks/TextBlock/index.tsx
··· 35 35 import { BlockDocPageSmall } from "components/Icons/BlockDocPageSmall"; 36 36 import { BlockImageSmall } from "components/Icons/BlockImageSmall"; 37 37 import { isIOS } from "src/utils/isDevice"; 38 + import { useLeafletPublicationData } from "components/PageSWRDataProvider"; 38 39 39 40 const HeadingStyle = { 40 41 1: "text-xl font-bold", ··· 471 472 const CommandOptions = (props: BlockProps & { className?: string }) => { 472 473 let rep = useReplicache(); 473 474 let entity_set = useEntitySetContext(); 475 + let { data: publicationData } = useLeafletPublicationData(); 476 + let pub = publicationData?.[0]; 477 + 474 478 return ( 475 479 <div 476 480 className={`absolute top-0 right-0 w-fit flex gap-[6px] items-center font-bold rounded-md text-sm text-border ${props.pageType === "canvas" && "mr-[6px]"}`} ··· 494 498 <BlockImageSmall className="hover:text-accent-contrast text-border" /> 495 499 </TooltipButton> 496 500 497 - <TooltipButton 498 - className={props.className} 499 - onMouseDown={async () => { 500 - let command = blockCommands.find((f) => f.name === "New Page"); 501 - if (!rep.rep) return; 502 - await command?.onSelect( 503 - rep.rep, 504 - { ...props, entity_set: entity_set.set }, 505 - rep.undoManager, 506 - ); 507 - }} 508 - side="bottom" 509 - tooltipContent={ 510 - <div className="flex gap-1 font-bold">Add a Subpage</div> 511 - } 512 - > 513 - <BlockDocPageSmall className="hover:text-accent-contrast text-border" /> 514 - </TooltipButton> 501 + {!pub && ( 502 + <TooltipButton 503 + className={props.className} 504 + onMouseDown={async () => { 505 + let command = blockCommands.find((f) => f.name === "New Page"); 506 + if (!rep.rep) return; 507 + await command?.onSelect( 508 + rep.rep, 509 + { ...props, entity_set: entity_set.set }, 510 + rep.undoManager, 511 + ); 512 + }} 513 + side="bottom" 514 + tooltipContent={ 515 + <div className="flex gap-1 font-bold">Add a Subpage</div> 516 + } 517 + > 518 + <BlockDocPageSmall className="hover:text-accent-contrast text-border" /> 519 + </TooltipButton> 520 + )} 515 521 516 522 <TooltipButton 517 523 className={props.className}