This commit is contained in:
caishi 2020-04-29 15:27:55 +08:00
parent 59edb107ee
commit 9427a3500f
3 changed files with 7 additions and 10 deletions

View File

@ -6,22 +6,18 @@ const map = {
'colorBlue': 'colorBlue', // 蓝字白底
}
class ActionBtn extends Component {
constructor(props) {
super(props);
}
render() {
let { to, children, style, className, ...others } = this.props
return (
<React.Fragment>
{
to == undefined ?
to === undefined ?
<a onClick={this.props.onClick}
{...others}
className={"Actionbtn " + `${map[style || 'blue']} ${this.props.className}`}
className={`Actionbtn ${map[style || 'blue']} ${this.props.className}`}
>{children}</a>
:
<Link to={to} className={"btn " + `${map[this.props.style]} ${this.props.className}`} {...others}>{this.props.children}</Link>
<Link to={to} className={`btn ${map[this.props.style]} ${this.props.className}`} {...others}>{this.props.children}</Link>
}
</React.Fragment>
)

View File

@ -5,12 +5,13 @@ import { exportMdtoHtml } from 'educoder'
let preRegex = /<pre[^>]*>/g
export default ({ value = '', is_md = true, className, style = {} }) => {
let html = is_md ? exportMdtoHtml(value) : value
html = html.replace(/▁/g, "▁▁▁").replace('<p>[TOC]</p>', '')
console.log(html, '----========')
html = html.replace(/▁/g, "▁▁▁")
const el = useRef()
useEffect(() => {
if (el.current && html) {
if (preRegex.test(html)) {
if (html.match(preRegex)) {
window.PR.prettyPrint()
}
}

View File

@ -112,7 +112,7 @@ class CaseDetail extends Component {
}
{
operation && operation.can_editable ? <ActionBtn style="colorBlue" to={`/moop_cases/${this.props.match.params.caseID}/edit`} className="fr mr20">编辑</ActionBtn> : ""
operation && operation.can_editable ? <ActionBtn style=" colorBlue" to={`/moop_cases/${this.props.match.params.caseID}/edit`} className="fr mr20">编辑</ActionBtn> : ""
}
</li>
<li className="clearfix lineh-20">