mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
* 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>
27 lines
783 B
JavaScript
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>
|
|
);
|
|
};
|