Skip to content

Commit 20317fc

Browse files
committed
trying the video
1 parent c152f83 commit 20317fc

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

blocks/custom/custom.css

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
.custom-block {
2-
padding: 1rem;
3-
background-color: #f0f0f0;
4-
text-align: center;
5-
border: 1px solid #ccc;
1+
/* blocks/custom/custom.css */
2+
3+
.block.custom {
4+
position: relative;
5+
overflow: hidden;
6+
width: 100%;
7+
max-width: 100%;
8+
aspect-ratio: 16 / 9;
9+
}
10+
11+
.block.custom iframe {
12+
width: 100%;
13+
height: 100%;
14+
border: none;
15+
pointer-events: none;
16+
display: block;
617
}

blocks/custom/custom.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// blocks/custom/custom.js
2+
3+
/**
4+
* Custom video block: expects a table with column "ID"
5+
* and values like "dQw4w9WgXcQ" (YouTube video ID)
6+
* It autoplays, loops, mutes and hides controls.
7+
*/
8+
9+
export default function decorate(block) {
10+
const idCell = block.querySelector('div > div');
11+
if (!idCell) return;
12+
13+
const videoId = idCell.textContent.trim();
14+
if (!videoId) return;
15+
16+
const iframe = document.createElement('iframe');
17+
iframe.src = `https://www.youtube.com/embed/${videoId}?autoplay=1&loop=1&playlist=${videoId}&mute=1&controls=0&rel=0&playsinline=1&disablekb=1`;
18+
iframe.title = 'YouTube Video';
19+
iframe.allow = 'autoplay; encrypted-media';
20+
iframe.allowFullscreen = false;
21+
iframe.setAttribute('tabindex', '-1');
22+
iframe.style = 'border: 0; width: 100%; aspect-ratio: 16/9; pointer-events: none;';
23+
24+
block.innerHTML = '';
25+
block.appendChild(iframe);
26+
}

0 commit comments

Comments
 (0)