blob: 30012c1123f96d71ddd455016b08342f58241a14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import { buildUneditableHtmlAsTextTokens } from './build_uneditable_token';
import { ALLOWED_VIDEO_ORIGINS } from '../../constants';
import { getURLOrigin } from '~/lib/utils/url_utility';
const isVideoFrame = (html) => {
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const {
children: { length },
} = doc;
const iframe = doc.querySelector('iframe');
const origin = iframe && getURLOrigin(iframe.getAttribute('src'));
return length === 1 && ALLOWED_VIDEO_ORIGINS.includes(origin);
};
const canRender = ({ type, literal }) => {
return type === 'htmlBlock' && !isVideoFrame(literal);
};
const render = (node) => buildUneditableHtmlAsTextTokens(node);
export default { canRender, render };
|