nice-ui
Version:
React design system, components, and utilities
43 lines (42 loc) • 1.54 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.BlockText = void 0;
const React = require("react");
const nano_theme_1 = require("nano-theme");
const HighlightCode_1 = require("../../../1-inline/HighlightCode");
const css = {
block: (0, nano_theme_1.rule)({
...nano_theme_1.theme.font.mono.mid,
fz: '12px',
pad: '0 8px',
mar: 0,
pre: {
mar: 0,
pad: 0,
},
}),
};
const BlockText = ({ src, compact, select, lang }) => {
const style = {
padding: compact ? '0' : undefined,
fontSize: compact ? '11px' : undefined,
};
return (React.createElement("pre", { className: css.block, style: style, onMouseDown: select
? (event) => {
const el = event.nativeEvent.target;
if (!el)
return;
if (window.getSelection && document.createRange) {
const selection = window.getSelection();
if (!selection)
return;
event.preventDefault();
const range = document.createRange();
range.selectNodeContents(el);
selection.removeAllRanges();
selection.addRange(range);
}
}
: void 0 }, lang ? React.createElement(HighlightCode_1.default, { code: src, lang: lang }) : React.createElement("code", null, src)));
};
exports.BlockText = BlockText;
;