+5
.changeset/orange-ads-enjoy.md
+5
.changeset/orange-ads-enjoy.md
+21
lexicons/pub/leaflet/blocks/iframe.json
+21
lexicons/pub/leaflet/blocks/iframe.json
···
1
+
{
2
+
"lexicon": 1,
3
+
"id": "pub.leaflet.blocks.iframe",
4
+
"defs": {
5
+
"main": {
6
+
"type": "object",
7
+
"required": ["url"],
8
+
"properties": {
9
+
"url": {
10
+
"type": "string",
11
+
"format": "uri"
12
+
},
13
+
"height": {
14
+
"type": "integer",
15
+
"minimum": 16,
16
+
"maximum": 1600
17
+
}
18
+
}
19
+
}
20
+
}
21
+
}
+1
lib/lexicons/index.ts
+1
lib/lexicons/index.ts
···
3
3
export * as PubLeafletBlocksCode from "./types/pub/leaflet/blocks/code.js";
4
4
export * as PubLeafletBlocksHeader from "./types/pub/leaflet/blocks/header.js";
5
5
export * as PubLeafletBlocksHorizontalRule from "./types/pub/leaflet/blocks/horizontalRule.js";
6
+
export * as PubLeafletBlocksIframe from "./types/pub/leaflet/blocks/iframe.js";
6
7
export * as PubLeafletBlocksImage from "./types/pub/leaflet/blocks/image.js";
7
8
export * as PubLeafletBlocksMath from "./types/pub/leaflet/blocks/math.js";
8
9
export * as PubLeafletBlocksText from "./types/pub/leaflet/blocks/text.js";
+22
lib/lexicons/types/pub/leaflet/blocks/iframe.ts
+22
lib/lexicons/types/pub/leaflet/blocks/iframe.ts
···
1
+
import type {} from "@atcute/lexicons";
2
+
import * as v from "@atcute/lexicons/validations";
3
+
4
+
const _mainSchema = /*#__PURE__*/ v.object({
5
+
$type: /*#__PURE__*/ v.optional(
6
+
/*#__PURE__*/ v.literal("pub.leaflet.blocks.iframe"),
7
+
),
8
+
height: /*#__PURE__*/ v.optional(
9
+
/*#__PURE__*/ v.constrain(/*#__PURE__*/ v.integer(), [
10
+
/*#__PURE__*/ v.integerRange(16, 1600),
11
+
]),
12
+
),
13
+
url: /*#__PURE__*/ v.genericUriString(),
14
+
});
15
+
16
+
type main$schematype = typeof _mainSchema;
17
+
18
+
export interface mainSchema extends main$schematype {}
19
+
20
+
export const mainSchema = _mainSchema as mainSchema;
21
+
22
+
export interface Main extends v.InferInput<typeof mainSchema> {}
+8
lib/utils.ts
+8
lib/utils.ts
···
8
8
PubLeafletBlocksCode,
9
9
PubLeafletBlocksHeader,
10
10
PubLeafletBlocksHorizontalRule,
11
+
PubLeafletBlocksIframe,
11
12
PubLeafletBlocksImage,
12
13
PubLeafletBlocksMath,
13
14
PubLeafletBlocksText,
···
162
163
"*": ["class", "style"],
163
164
img: ["src", "height", "width", "alt"],
164
165
a: ["href", "target", "rel"],
166
+
iframe: ["height", "allow", "loading", "src"],
165
167
},
166
168
allowedTags: [
167
169
"img",
···
184
186
"div",
185
187
"span",
186
188
"blockquote",
189
+
"iframe",
187
190
],
188
191
selfClosing: ["img"],
189
192
});
···
353
356
354
357
if (is(PubLeafletBlocksBlockquote.mainSchema, block.block)) {
355
358
html += `<blockquote>${parseTextBlock(block.block)}</blockquote>`;
359
+
}
360
+
361
+
if (is(PubLeafletBlocksIframe.mainSchema, block.block)) {
362
+
// @ts-ignore
363
+
html += `<iframe height="${block.block.height}" allow="fullscreen" loading="lazy" src="${block.block.url}"></iframe>`;
356
364
}
357
365
358
366
return html.trim();