ToolJet/frontend/src/Editor/Components/Html.jsx
Manish Kushare 22f9e1f97c
added HTML-CSS widget (#2938)
* added HTML widget

* removed console

* removed injecting css to the html page

* Shorten the div of default code for HTML widget

* Updated widget icon from tabler icons

Co-authored-by: Sherfin Shamsudeen <sherfin94@gmail.com>
2022-06-16 17:58:11 +05:30

27 lines
783 B
JavaScript

import React, { useState, useEffect } from 'react';
import DOMPurify from 'dompurify';
export const Html = function ({ height, properties, styles, darkMode }) {
const { rawHtml: stringifyHTML } = properties;
const baseStyle = {
backgroundColor: darkMode ? '#47505D' : '#ffffff',
color: darkMode ? 'white' : 'black',
};
const { visibility } = styles;
const [rawHtml, setRawHtml] = useState('');
useEffect(() => {
setRawHtml(stringifyHTML);
}, [stringifyHTML]);
return (
<div style={{ display: visibility ? '' : 'none', width: '100%', height, overflowY: 'auto' }}>
{
<div
style={baseStyle}
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(rawHtml, { FORCE_BODY: true }) }}
/>
}
</div>
);
};