// jshint ignore:start import React from 'react'; import Code from './actions/code'; import Emphasis from './actions/emphasis'; import Hr from './actions/hr'; import Image from './actions/image'; import Link from './actions/link'; import Striketrough from './actions/striketrough'; import Strong from './actions/strong'; import Quote from './actions/quote'; import AttachmentsEditor from './attachments'; import Upload from './attachments/upload-button/'; import MarkupPreview from './markup-preview'; import * as textUtils from './textUtils'; import Button from 'misago/components/button'; import misago from 'misago'; import ajax from 'misago/services/ajax'; import modal from 'misago/services/modal'; import snackbar from 'misago/services/snackbar'; export default class extends React.Component { constructor(props) { super(props); this.state = { isPreviewLoading: false }; } onPreviewClick = () => { if (this.state.isPreviewLoading) { return; } this.setState({ isPreviewLoading: true }); ajax.post(misago.get('PARSE_MARKUP_API'), {post: this.props.value}).then((data) => { modal.show( ); this.setState({ isPreviewLoading: false }); }, (rejection) => { if (rejection.status === 400) { snackbar.error(rejection.detail); } else { snackbar.apiError(rejection); } this.setState({ isPreviewLoading: false }); }); }; replaceSelection = (operation) => { operation(textUtils.getSelectionText(), this._replaceSelection); }; _replaceSelection = (newValue) => { this.props.onChange({ target: { value: textUtils.replace(newValue) } }); }; render() { return (

); } } export function Protect(props) { if (props.canProtect) { return ( ); } else { return null; } }