a tool for shared writing and social publishing

add iframe block

+69 -1
+12
actions/publishToPublication.ts
··· 19 19 PubLeafletBlocksHorizontalRule, 20 20 PubLeafletBlocksBskyPost, 21 21 PubLeafletBlocksBlockquote, 22 + PubLeafletBlocksIframe, 22 23 } from "lexicons/api"; 23 24 import { Block } from "components/Blocks/Block"; 24 25 import { TID } from "@atproto/common"; ··· 278 279 $type: ids.PubLeafletBlocksText, 279 280 plaintext: stringValue, 280 281 facets, 282 + }; 283 + return block; 284 + } 285 + if (b.type === "embed") { 286 + let [url] = scan.eav(b.value, "embed/url"); 287 + let [height] = scan.eav(b.value, "embed/height"); 288 + if (!url) return; 289 + let block: $Typed<PubLeafletBlocksIframe.Main> = { 290 + $type: "pub.leaflet.blocks.iframe", 291 + url: url.data.value, 292 + height: height?.data.value || 600, 281 293 }; 282 294 return block; 283 295 }
+13
app/lish/[did]/[publication]/[rkey]/PostContent.tsx
··· 11 11 PubLeafletBlocksHorizontalRule, 12 12 PubLeafletBlocksBlockquote, 13 13 PubLeafletBlocksBskyPost, 14 + PubLeafletBlocksIframe, 14 15 } from "lexicons/api"; 15 16 import { blobRefToSrc } from "src/utils/blobRefToSrc"; 16 17 import { TextBlock } from "./TextBlock"; ··· 110 111 let post = bskyPostData.find((p) => p.uri === uri); 111 112 if (!post) return <div>no prefetched post rip</div>; 112 113 return <PubBlueskyPostBlock post={post} />; 114 + } 115 + case PubLeafletBlocksIframe.isMain(b.block): { 116 + return ( 117 + <iframe 118 + className={`flex flex-col relative w-full overflow-hidden group/embedBlock block-border my-2`} 119 + width="100%" 120 + height={b.block.height} 121 + src={b.block.url} 122 + allow="fullscreen" 123 + loading="lazy" 124 + /> 125 + ); 113 126 } 114 127 case PubLeafletBlocksHorizontalRule.isMain(b.block): { 115 128 return <hr className="my-2 w-full border-border-light" />;
-1
components/Blocks/BlockCommands.tsx
··· 281 281 name: "Embed Website", 282 282 icon: <BlockEmbedSmall />, 283 283 type: "block", 284 - hiddenInPublication: true, 285 284 onSelect: async (rep, props) => { 286 285 createBlockWithType(rep, props, "embed"); 287 286 },
+2
lexicons/api/index.ts
··· 13 13 import * as PubLeafletBlocksCode from './types/pub/leaflet/blocks/code' 14 14 import * as PubLeafletBlocksHeader from './types/pub/leaflet/blocks/header' 15 15 import * as PubLeafletBlocksHorizontalRule from './types/pub/leaflet/blocks/horizontalRule' 16 + import * as PubLeafletBlocksIframe from './types/pub/leaflet/blocks/iframe' 16 17 import * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image' 17 18 import * as PubLeafletBlocksMath from './types/pub/leaflet/blocks/math' 18 19 import * as PubLeafletBlocksText from './types/pub/leaflet/blocks/text' ··· 46 47 export * as PubLeafletBlocksCode from './types/pub/leaflet/blocks/code' 47 48 export * as PubLeafletBlocksHeader from './types/pub/leaflet/blocks/header' 48 49 export * as PubLeafletBlocksHorizontalRule from './types/pub/leaflet/blocks/horizontalRule' 50 + export * as PubLeafletBlocksIframe from './types/pub/leaflet/blocks/iframe' 49 51 export * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image' 50 52 export * as PubLeafletBlocksMath from './types/pub/leaflet/blocks/math' 51 53 export * as PubLeafletBlocksText from './types/pub/leaflet/blocks/text'
+23
lexicons/api/lexicons.ts
··· 313 313 }, 314 314 }, 315 315 }, 316 + PubLeafletBlocksIframe: { 317 + lexicon: 1, 318 + id: 'pub.leaflet.blocks.iframe', 319 + defs: { 320 + main: { 321 + type: 'object', 322 + required: ['url'], 323 + properties: { 324 + url: { 325 + type: 'string', 326 + format: 'uri', 327 + }, 328 + height: { 329 + type: 'integer', 330 + minimum: 16, 331 + maximum: 1600, 332 + }, 333 + }, 334 + }, 335 + }, 336 + }, 316 337 PubLeafletBlocksImage: { 317 338 lexicon: 1, 318 339 id: 'pub.leaflet.blocks.image', ··· 499 520 block: { 500 521 type: 'union', 501 522 refs: [ 523 + 'lex:pub.leaflet.blocks.iframe', 502 524 'lex:pub.leaflet.blocks.text', 503 525 'lex:pub.leaflet.blocks.blockquote', 504 526 'lex:pub.leaflet.blocks.header', ··· 1762 1784 PubLeafletBlocksCode: 'pub.leaflet.blocks.code', 1763 1785 PubLeafletBlocksHeader: 'pub.leaflet.blocks.header', 1764 1786 PubLeafletBlocksHorizontalRule: 'pub.leaflet.blocks.horizontalRule', 1787 + PubLeafletBlocksIframe: 'pub.leaflet.blocks.iframe', 1765 1788 PubLeafletBlocksImage: 'pub.leaflet.blocks.image', 1766 1789 PubLeafletBlocksMath: 'pub.leaflet.blocks.math', 1767 1790 PubLeafletBlocksText: 'pub.leaflet.blocks.text',
+2
lexicons/api/types/pub/leaflet/pages/linearDocument.ts
··· 5 5 import { CID } from 'multiformats/cid' 6 6 import { validate as _validate } from '../../../../lexicons' 7 7 import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' 8 + import type * as PubLeafletBlocksIframe from '../blocks/iframe' 8 9 import type * as PubLeafletBlocksText from '../blocks/text' 9 10 import type * as PubLeafletBlocksBlockquote from '../blocks/blockquote' 10 11 import type * as PubLeafletBlocksHeader from '../blocks/header' ··· 38 39 export interface Block { 39 40 $type?: 'pub.leaflet.pages.linearDocument#block' 40 41 block: 42 + | $Typed<PubLeafletBlocksIframe.Main> 41 43 | $Typed<PubLeafletBlocksText.Main> 42 44 | $Typed<PubLeafletBlocksBlockquote.Main> 43 45 | $Typed<PubLeafletBlocksHeader.Main>
+1
lexicons/pub/leaflet/pages/linearDocument.json
··· 23 23 "block": { 24 24 "type": "union", 25 25 "refs": [ 26 + "pub.leaflet.blocks.iframe", 26 27 "pub.leaflet.blocks.text", 27 28 "pub.leaflet.blocks.blockquote", 28 29 "pub.leaflet.blocks.header",
+16
lexicons/src/blocks.ts
··· 205 205 }, 206 206 }, 207 207 }; 208 + 209 + export const PubLeafletBlocksIFrame: LexiconDoc = { 210 + lexicon: 1, 211 + id: "pub.leaflet.blocks.iframe", 212 + defs: { 213 + main: { 214 + type: "object", 215 + required: ["url"], 216 + properties: { 217 + url: { type: "string", format: "uri" }, 218 + height: { type: "integer", minimum: 16, maximum: 1600 }, 219 + }, 220 + }, 221 + }, 222 + }; 208 223 export const BlockLexicons = [ 224 + PubLeafletBlocksIFrame, 209 225 PubLeafletBlocksText, 210 226 PubLeafletBlocksBlockQuote, 211 227 PubLeafletBlocksHeader,