replyType?: boolean;
focus?: boolean;
disabled?: boolean;
+ maxLength?: number;
onSubmit?(msg: { val: string; formId: string }): any;
onContentChange?(val: string): any;
onReplyCancel?(): any;
+ hideNavigationWarnings?: boolean;
}
interface MarkdownTextAreaState {
}
componentDidUpdate() {
- if (this.state.content) {
+ if (!this.props.hideNavigationWarnings && this.state.content) {
window.onbeforeunload = () => true;
} else {
window.onbeforeunload = undefined;
render() {
return (
<form id={this.formId} onSubmit={linkEvent(this, this.handleSubmit)}>
- <Prompt when={this.state.content} message={i18n.t('block_leaving')} />
+ <Prompt
+ when={!this.props.hideNavigationWarnings && this.state.content}
+ message={i18n.t('block_leaving')}
+ />
<div class="form-group row">
<div className={`col-sm-12`}>
<textarea
required
disabled={this.props.disabled}
rows={2}
- maxLength={10000}
+ maxLength={this.props.maxLength || 10000}
/>
{this.state.previewMode && (
<div
- className="card card-body md-div"
+ className="card bg-transparent border-secondary card-body md-div"
dangerouslySetInnerHTML={mdToHtml(this.state.content)}
/>
)}
<use xlinkHref="#icon-code"></use>
</svg>
</button>
+ <button
+ class="btn btn-sm text-muted"
+ data-tippy-content={i18n.t('subscript')}
+ onClick={linkEvent(this, this.handleInsertSubscript)}
+ >
+ <svg class="icon icon-inline">
+ <use xlinkHref="#icon-subscript"></use>
+ </svg>
+ </button>
+ <button
+ class="btn btn-sm text-muted"
+ data-tippy-content={i18n.t('superscript')}
+ onClick={linkEvent(this, this.handleInsertSuperscript)}
+ >
+ <svg class="icon icon-inline">
+ <use xlinkHref="#icon-superscript"></use>
+ </svg>
+ </button>
<button
class="btn btn-sm text-muted"
data-tippy-content={i18n.t('spoiler')}
i.simpleInsert('#');
}
+ handleInsertSubscript(i: MarkdownTextArea, event: any) {
+ event.preventDefault();
+ i.simpleSurround('~');
+ }
+
+ handleInsertSuperscript(i: MarkdownTextArea, event: any) {
+ event.preventDefault();
+ i.simpleSurround('^');
+ }
+
simpleInsert(chars: string) {
if (!this.state.content) {
this.state.content = `${chars} `;