Skip to content

Commit b6ff866

Browse files
Merge pull request #25 from prezly/feature/dev-11477-support-embednode-layout-in-prezlycontent-format-js
[DEV-11477] Support `layout` in `EmbedNode`
2 parents f0a62f5 + 4b25f8b commit b6ff866

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/content-format/src/nodes/EmbedNode.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import { OEmbedInfo as OEmbed } from '../common';
22
import { Element } from '../Element';
3-
import { isNonEmptyString, isUuid } from '../validation';
3+
import { isEnum, isNonEmptyString, isUuid } from '../validation';
44

55
export interface EmbedNode extends Element<typeof EmbedNode.TYPE> {
66
uuid: string;
77
url: string;
88
oembed: OEmbed;
9+
layout: `${EmbedNode.Layout}`;
910
}
1011

1112
export namespace EmbedNode {
1213
export const TYPE = 'embed';
1314

15+
export enum Layout {
16+
CONTAINED = 'contained',
17+
EXPANDED = 'expanded',
18+
FULL_WIDTH = 'full-width',
19+
}
20+
1421
export import OEmbedInfo = OEmbed;
1522

1623
export function isEmbedNode(value: any): value is EmbedNode {
@@ -21,6 +28,7 @@ export namespace EmbedNode {
2128
const isValid =
2229
isEmbedNode(value) &&
2330
isNonEmptyString(value.url) &&
31+
isEnum(value.layout, Layout) &&
2432
isUuid(value.uuid) &&
2533
OEmbed.isOEmbedInfo(value.oembed);
2634

0 commit comments

Comments
 (0)