Skip to content

Commit d0eeb0b

Browse files
authored
Merge pull request #49 from Biggertablecloth/master
Add support for <video> tag
2 parents f27e690 + ac992bf commit d0eeb0b

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
@@ -74,6 +74,26 @@ function genFragment(
7474
return { chunk: getAtomicBlockChunk(entityId) };
7575
}
7676

77+
if (
78+
nodeName === 'video' &&
79+
node instanceof HTMLVideoElement
80+
) {
81+
const entityConfig = {};
82+
entityConfig.src = node.getAttribute ? node.getAttribute('src') || node.src : node.src;
83+
entityConfig.alt = node.alt;
84+
entityConfig.height = node.style.height;
85+
entityConfig.width = node.style.width;
86+
if (node.style.float) {
87+
entityConfig.alignment = node.style.float;
88+
}
89+
const entityId = Entity.__create(
90+
'VIDEO',
91+
'MUTABLE',
92+
entityConfig,
93+
);
94+
return { chunk: getAtomicBlockChunk(entityId) };
95+
}
96+
7797
if (
7898
nodeName === 'iframe' &&
7999
node instanceof HTMLIFrameElement

0 commit comments

Comments
 (0)