Skip to content

Commit 759dc78

Browse files
committed
add support for <video> tag
1 parent 176c780 commit 759dc78

File tree

3 files changed

+1008
-653
lines changed

3 files changed

+1008
-653
lines changed

dist/html-to-draftjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/library/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ function genFragment(
5959
return { chunk: getAtomicBlockChunk(entityId) };
6060
}
6161

62+
if (
63+
nodeName === 'video' &&
64+
node instanceof HTMLVideoElement
65+
) {
66+
const entityConfig = {};
67+
entityConfig.src = node.getAttribute ? node.getAttribute('src') || node.src : node.src;
68+
entityConfig.alt = node.alt;
69+
entityConfig.height = node.style.height;
70+
entityConfig.width = node.style.width;
71+
if (node.style.float) {
72+
entityConfig.alignment = node.style.float;
73+
}
74+
const entityId = Entity.__create(
75+
'VIDEO',
76+
'MUTABLE',
77+
entityConfig,
78+
);
79+
return { chunk: getAtomicBlockChunk(entityId) };
80+
}
81+
6282
if (
6383
nodeName === 'iframe' &&
6484
node instanceof HTMLIFrameElement

0 commit comments

Comments
 (0)