UNPKG

@grafana/ui

Version:
59 lines (52 loc) 1.82 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var jsxRuntime = require('react/jsx-runtime'); var css = require('@emotion/css'); var memoize = require('micro-memoize'); var data = require('@grafana/data'); var MaybeWrapWithLink = require('../components/MaybeWrapWithLink.cjs'); var styles = require('../styles.cjs'); function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } var memoize__default = /*#__PURE__*/_interopDefaultCompat(memoize); "use strict"; function MarkdownCell({ field, rowIdx, disableSanitizeHtml }) { const rawValue = field.values[rowIdx]; if (rawValue == null) { return null; } const renderValue = field.display(rawValue); return /* @__PURE__ */ jsxRuntime.jsx(MaybeWrapWithLink.MaybeWrapWithLink, { field, rowIdx, children: /* @__PURE__ */ jsxRuntime.jsx( "div", { className: "markdown-container", dangerouslySetInnerHTML: { __html: data.renderMarkdown(renderValue.text, { noSanitize: disableSanitizeHtml }).trim() } } ) }); } const getStyles = memoize__default.default( (theme, { maxHeight }) => css.css({ [`&, ${styles.getActiveCellSelector(Boolean(maxHeight))}`]: { whiteSpace: "normal" }, ".markdown-container": { width: "100%", // for elements like `p`, `h*`, etc. which have an inherent margin, // we want to remove the bottom margin for the last one in the container. "> *:last-child": { marginBottom: 0 } }, "ol, ul": { paddingLeft: theme.spacing(2.5) }, p: { whiteSpace: "pre-line" } }), { isMatchingKey: styles.isTableCellStylesKeyEqual } ); exports.MarkdownCell = MarkdownCell; exports.getStyles = getStyles; //# sourceMappingURL=MarkdownCell.cjs.map