Skip to content

Commit 5558104

Browse files
committed
feat: Add embed blocks support with EmbedType enum (v0.17.0)
- Add embed_block() helper for embedding external content - Add EmbedType enum (YOUTUBE, FIGMA, VIMEO, CODESANDBOX, GITHUB_GIST, MIRO, IFRAME) - Automatic URL transformation for YouTube, Figma, and GitHub Gist - Add EmbedBlockNode, EmbedBlockAttrs, EmbedBlockData types - Add 18 unit tests and 1 integration test - Add embed_blocks_example.py example - Update documentation (guides, API reference, enums) - Add enum documentation standards to project rules - Compact JSON serialization for embed data - Auto-generate UIDs using _generate_uid() for consistency
1 parent b40ab0d commit 5558104

14 files changed

Lines changed: 1235 additions & 5 deletions

.cursor/rules/project-standards.mdc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,62 @@ Follow this checklist to ensure completeness:
4949
- [ ] Use existing enums instead of primitive types where applicable (e.g., `AvatarMode` instead of `int`)
5050
- [ ] Reuse shared models from `vaiz/models/base.py` (e.g., `ColorInfo` for color configurations)
5151

52+
### Enums Documentation
53+
54+
When adding new enums, follow these documentation standards:
55+
56+
**1. Code Implementation:**
57+
- Export enum from `vaiz/__init__.py` for easy access
58+
- Use `str, Enum` inheritance for string enums
59+
- Use descriptive names matching API values
60+
61+
**2. Documentation Structure:**
62+
63+
In **`docs-site/docs/api-reference/enums.md`**:
64+
```markdown
65+
## EnumName
66+
67+
Brief description of what the enum represents:
68+
69+
```python
70+
from vaiz import EnumName # or from vaiz.models.enums
71+
72+
EnumName.VALUE1 # Description
73+
EnumName.VALUE2 # Description
74+
```
75+
76+
**Usage:**
77+
78+
```python
79+
from vaiz import function_name, EnumName
80+
81+
# Show real-world example
82+
function_name(
83+
param=EnumName.VALUE1
84+
)
85+
```
86+
```
87+
88+
In **Guide Pages** (`docs-site/docs/guides/*.md`):
89+
- Show simple usage WITHOUT explicit enum references in examples
90+
- Add link to enum documentation: `See [EnumName](../api-reference/enums#enumname)`
91+
- Focus on functionality, not enum details
92+
93+
**Example:**
94+
95+
```python
96+
# ✅ Good - Guide page example (simple)
97+
embed_block(url="https://youtube.com/...")
98+
99+
# ❌ Bad - Don't show enum in guides
100+
embed_block(url="...", embed_type=EmbedType.YOUTUBE)
101+
```
102+
103+
**3. References:**
104+
- Always link to enum documentation: `[EnumName](../api-reference/enums#enumname)`
105+
- Mention enum exists but show simple usage first
106+
- Full enum examples only in `enums.md` and examples files
107+
52108
## Changelog
53109

54110
**Keep CHANGELOG.md user-focused and concise:**

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [0.17.0] - 2025-10-24
4+
5+
### Added
6+
7+
- **🎬 Embed Blocks**: Support for embedding external content (YouTube, Figma, CodeSandbox, etc.)
8+
- `embed_block(url, embed_type, size, is_content_hidden)` - Create embed blocks for external content
9+
- `EmbedType` enum - Type-safe embed types (YOUTUBE, FIGMA, VIMEO, CODESANDBOX, GITHUB_GIST, MIRO, IFRAME)
10+
311
## [0.16.0] - 2025-10-24
412

513
### Changed

docs-site/docs/api-reference/document-structure.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,87 @@ client.replace_json_document(document_id, content)
12421242

12431243
---
12441244

1245+
## Embed Block
1246+
1247+
Embed external content from various platforms (YouTube, Figma, Vimeo, CodeSandbox, GitHub Gist, Miro, Iframe).
1248+
1249+
**Structure:**
1250+
```json
1251+
{
1252+
"type": "embed",
1253+
"attrs": {
1254+
"uid": "uniqueIdXYZ",
1255+
"custom": 1,
1256+
"contenteditable": "false",
1257+
"size": "medium",
1258+
"isContentHidden": false
1259+
},
1260+
"content": [
1261+
{
1262+
"type": "text",
1263+
"text": "{\"type\":\"YouTube\",\"url\":\"https://www.youtube.com/watch?v=dQw4w9WgXcQ\",\"extractedUrl\":\"https://www.youtube.com/watch?v=dQw4w9WgXcQ\"}"
1264+
}
1265+
]
1266+
}
1267+
```
1268+
1269+
**Embed Data Fields:**
1270+
- `type` - Embed type: `"YouTube"`, `"Figma"`, `"Vimeo"`, `"CodeSandbox"`, `"GitHub Gist"`, `"Miro"`, `"Iframe"`
1271+
- `url` - URL of content to embed
1272+
- `extractedUrl` - Extracted/processed URL (usually same as url)
1273+
- `isContentHidden` - Optional, for Figma/Miro to hide content by default
1274+
1275+
**Attributes:**
1276+
- `uid` - Unique block identifier
1277+
- `custom` - Always 1 for custom blocks
1278+
- `contenteditable` - Should be "false"
1279+
- `size` - Display size: `"small"`, `"medium"`, or `"large"`
1280+
- `isContentHidden` - Whether content is hidden by default
1281+
1282+
**Using Helper (Recommended):**
1283+
```python
1284+
from vaiz import embed_block, heading, paragraph, horizontal_rule
1285+
1286+
content = [
1287+
heading(1, "Project Resources"),
1288+
1289+
# YouTube video
1290+
heading(2, "Demo Video"),
1291+
embed_block(
1292+
url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
1293+
size="large"
1294+
),
1295+
1296+
horizontal_rule(),
1297+
1298+
# Figma design
1299+
heading(2, "Design Files"),
1300+
embed_block(
1301+
url="https://www.figma.com/file/example",
1302+
size="large",
1303+
is_content_hidden=True
1304+
),
1305+
1306+
horizontal_rule(),
1307+
1308+
# Live code sandbox
1309+
heading(2, "Code Example"),
1310+
embed_block(url="https://codesandbox.io/s/example")
1311+
]
1312+
1313+
client.replace_json_document(document_id, content)
1314+
```
1315+
1316+
See [EmbedType enum](./enums#embedtype) for type-safe values.
1317+
1318+
**Parameters:**
1319+
- `url` - URL of content to embed
1320+
- `embed_type` - Type of embed (optional, see [EmbedType](./enums#embedtype))
1321+
- `size` - Display size: `"small"`, `"medium"`, `"large"` (default: `"medium"`)
1322+
- `is_content_hidden` - Hide content by default (default: `False`)
1323+
1324+
---
1325+
12451326
## Image Block
12461327

12471328
Embedded images in documents and task descriptions.

docs-site/docs/api-reference/enums.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,46 @@ CommentReactionType.PARTY # 🎉
8282

8383
---
8484

85+
## EmbedType
86+
87+
Embed content types for document embed blocks:
88+
89+
```python
90+
from vaiz import EmbedType
91+
92+
EmbedType.YOUTUBE # YouTube videos
93+
EmbedType.FIGMA # Figma design files
94+
EmbedType.VIMEO # Vimeo videos
95+
EmbedType.CODESANDBOX # CodeSandbox code sandboxes
96+
EmbedType.GITHUB_GIST # GitHub Gists
97+
EmbedType.MIRO # Miro whiteboards
98+
EmbedType.IFRAME # Generic iframe (default)
99+
```
100+
101+
**Usage:**
102+
103+
```python
104+
from vaiz import embed_block, EmbedType
105+
106+
# YouTube video
107+
embed_block(
108+
url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
109+
embed_type=EmbedType.YOUTUBE
110+
)
111+
112+
# Figma design
113+
embed_block(
114+
url="https://www.figma.com/file/example",
115+
embed_type=EmbedType.FIGMA,
116+
is_content_hidden=True
117+
)
118+
119+
# Default to Iframe when embed_type not specified
120+
embed_block(url="https://example.com/embed")
121+
```
122+
123+
---
124+
85125
## Kind
86126

87127
Entity types for history and documents:

docs-site/docs/guides/document-structure-helpers.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,76 @@ client.replace_json_document(document_id, content)
11161116
- Optional language specification
11171117
- Automatic formatting
11181118

1119+
### Embed Block - External Content
1120+
1121+
Embed external content from various platforms:
1122+
1123+
```python
1124+
from vaiz import embed_block, heading, paragraph, horizontal_rule
1125+
1126+
content = [
1127+
heading(1, "Project Resources"),
1128+
1129+
# YouTube video
1130+
heading(2, "Demo Video"),
1131+
paragraph("Watch our product demo:"),
1132+
embed_block(
1133+
url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
1134+
size="large"
1135+
),
1136+
1137+
horizontal_rule(),
1138+
1139+
# Figma design
1140+
heading(2, "Design Mockups"),
1141+
paragraph("View the design files:"),
1142+
embed_block(
1143+
url="https://www.figma.com/file/example",
1144+
size="large",
1145+
is_content_hidden=True
1146+
),
1147+
1148+
horizontal_rule(),
1149+
1150+
# CodeSandbox
1151+
heading(2, "Live Code Example"),
1152+
paragraph("Try the code live:"),
1153+
embed_block(url="https://codesandbox.io/s/example"),
1154+
1155+
horizontal_rule(),
1156+
1157+
# Generic iframe (default)
1158+
heading(2, "External Tool"),
1159+
embed_block(url="https://example.com/embed")
1160+
]
1161+
1162+
client.replace_json_document(document_id, content)
1163+
```
1164+
1165+
**Supported Embed Types:**
1166+
- YouTube - YouTube videos
1167+
- Figma - Figma design files
1168+
- Vimeo - Vimeo videos
1169+
- CodeSandbox - Interactive code sandboxes
1170+
- GitHub Gist - GitHub code snippets
1171+
- Miro - Miro whiteboards
1172+
- Iframe - Generic iframe embeds (default)
1173+
1174+
See [EmbedType enum](../api-reference/enums#embedtype) for type-safe values.
1175+
1176+
**Parameters:**
1177+
- `url` - URL of content to embed
1178+
- `embed_type` - Type of embed (optional, see [EmbedType](../api-reference/enums#embedtype))
1179+
- `size` - Display size: `"small"`, `"medium"`, `"large"` (default: `"medium"`)
1180+
- `is_content_hidden` - Hide content by default for Figma/Miro (default: `False`)
1181+
1182+
**Use Cases:**
1183+
- Video tutorials and demos
1184+
- Design system documentation
1185+
- Live code examples
1186+
- Interactive prototypes
1187+
- External tool integrations
1188+
11191189
### Complete Navigation Example
11201190

11211191
Combine all navigation blocks for optimal user experience:
@@ -1190,6 +1260,7 @@ All helper functions create nodes compatible with the document editor:
11901260
-`image_block()` - Embed images
11911261
-`files_block()` - Attach files
11921262
-`code_block()` - Code with syntax highlighting
1263+
-`embed_block()` - Embed external content (YouTube, Figma, etc.)
11931264

11941265
### Navigation Blocks
11951266
-`toc_block()` - Automatic table of contents

docs-site/docs/patterns/ready-to-run.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The SDK includes a collection of ready-to-run examples in the [`/examples`](http
4747
- **`advanced_mention_usage.py`** - Advanced usage of mentions in tables, lists, and complex documents
4848
- **`document_navigation_blocks.py`** - TOC, Anchors, and Siblings navigation blocks
4949
- **`document_with_code_blocks.py`** - Code blocks with syntax highlighting
50+
- **`embed_blocks_example.py`** - Embed external content (YouTube, Figma, CodeSandbox, etc.)
5051

5152
## Custom Fields
5253

docs-site/docusaurus.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ const config: Config = {
206206
},
207207
items: [
208208
{
209-
label: "v0.16.0",
210-
href: "https://pypi.org/project/vaiz-sdk/0.16.0/",
209+
label: "v0.17.0",
210+
href: "https://pypi.org/project/vaiz-sdk/0.17.0/",
211211
position: "left",
212212
},
213213
{

0 commit comments

Comments
 (0)