UNPKG

@douyinfe/semi-ui

Version:

A modern, comprehensive, flexible design system and UI library. Connect DesignOps & DevOps. Quickly build beautiful React apps. Maintained by Douyin-fe team.

60 lines (59 loc) 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = require("react"); var _classnames = _interopRequireDefault(require("classnames")); var _propTypes = _interopRequireDefault(require("prop-types")); var _constants = require("@douyinfe/semi-foundation/lib/cjs/highlight/constants"); var _index = require("../_utils/index"); require("@douyinfe/semi-foundation/lib/cjs/highlight/highlight.css"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } const prefixCls = _constants.cssClasses.PREFIX; class Highlight extends _react.PureComponent { render() { const { searchWords, sourceString, component, highlightClassName, highlightStyle, caseSensitive, autoEscape } = this.props; const tagCls = (0, _classnames.default)({ [`${prefixCls}-tag`]: true }, highlightClassName); const option = { highlightTag: component, highlightClassName: tagCls, highlightStyle, caseSensitive, autoEscape }; return (0, _index.getHighLightTextHTML)({ sourceString, searchWords, option }); } } Highlight.propTypes = { style: _propTypes.default.object, className: _propTypes.default.string, autoEscape: _propTypes.default.bool, caseSensitive: _propTypes.default.bool, sourceString: _propTypes.default.string, searchWords: _propTypes.default.arrayOf(_propTypes.default.string), highlightStyle: _propTypes.default.object, highlightClassName: _propTypes.default.string, component: _propTypes.default.string }; Highlight.defaultProps = { component: 'mark', autoEscape: true, caseSensitive: false, sourceString: '' }; var _default = exports.default = Highlight;