mirror of
https://github.com/flarum/core.git
synced 2025-08-09 18:07:02 +02:00
update: forum/components/ComposerBody
This commit is contained in:
committed by
Franz Liedke
parent
2a784009fb
commit
84c5248872
@@ -24,8 +24,10 @@ import ItemList from '../../common/utils/ItemList';
|
|||||||
* @abstract
|
* @abstract
|
||||||
*/
|
*/
|
||||||
export default class ComposerBody extends Component {
|
export default class ComposerBody extends Component {
|
||||||
init() {
|
oninit(vnode) {
|
||||||
this.composer = this.props.composer;
|
super.oninit(vnode);
|
||||||
|
|
||||||
|
this.composer = this.attrs.composer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the component is loading.
|
* Whether or not the component is loading.
|
||||||
@@ -37,11 +39,11 @@ export default class ComposerBody extends Component {
|
|||||||
// Let the composer state know to ask for confirmation under certain
|
// Let the composer state know to ask for confirmation under certain
|
||||||
// circumstances, if the body supports / requires it and has a corresponding
|
// circumstances, if the body supports / requires it and has a corresponding
|
||||||
// confirmation question to ask.
|
// confirmation question to ask.
|
||||||
if (this.props.confirmExit) {
|
if (this.attrs.confirmExit) {
|
||||||
this.composer.preventClosingWhen(() => this.hasChanges(), this.props.confirmExit);
|
this.composer.preventClosingWhen(() => this.hasChanges(), this.attrs.confirmExit);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.composer.fields.content(this.props.originalContent || '');
|
this.composer.fields.content(this.attrs.originalContent || '');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated BC layer, remove in Beta 15.
|
* @deprecated BC layer, remove in Beta 15.
|
||||||
@@ -53,15 +55,15 @@ export default class ComposerBody extends Component {
|
|||||||
view() {
|
view() {
|
||||||
return (
|
return (
|
||||||
<ConfirmDocumentUnload when={this.hasChanges.bind(this)}>
|
<ConfirmDocumentUnload when={this.hasChanges.bind(this)}>
|
||||||
<div className={'ComposerBody ' + (this.props.className || '')}>
|
<div className={'ComposerBody ' + (this.attrs.className || '')}>
|
||||||
{avatar(this.props.user, { className: 'ComposerBody-avatar' })}
|
{avatar(this.attrs.user, { className: 'ComposerBody-avatar' })}
|
||||||
<div className="ComposerBody-content">
|
<div className="ComposerBody-content">
|
||||||
<ul className="ComposerBody-header">{listItems(this.headerItems().toArray())}</ul>
|
<ul className="ComposerBody-header">{listItems(this.headerItems().toArray())}</ul>
|
||||||
<div className="ComposerBody-editor">
|
<div className="ComposerBody-editor">
|
||||||
{TextEditor.component({
|
{TextEditor.component({
|
||||||
submitLabel: this.props.submitLabel,
|
submitLabel: this.attrs.submitLabel,
|
||||||
placeholder: this.props.placeholder,
|
placeholder: this.attrs.placeholder,
|
||||||
disabled: this.loading || this.props.disabled,
|
disabled: this.loading || this.attrs.disabled,
|
||||||
composer: this.composer,
|
composer: this.composer,
|
||||||
preview: this.jumpToPreview && this.jumpToPreview.bind(this),
|
preview: this.jumpToPreview && this.jumpToPreview.bind(this),
|
||||||
onchange: this.composer.fields.content,
|
onchange: this.composer.fields.content,
|
||||||
@@ -84,7 +86,7 @@ export default class ComposerBody extends Component {
|
|||||||
hasChanges() {
|
hasChanges() {
|
||||||
const content = this.composer.fields.content();
|
const content = this.composer.fields.content();
|
||||||
|
|
||||||
return content && content !== this.props.originalContent;
|
return content && content !== this.attrs.originalContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user