mirror of
https://github.com/flarum/core.git
synced 2025-08-08 01:16:52 +02:00
Simplify TextEditor by moving oncreate from the textarea vnode in view to the component itself, and removing the redundant vnode lifecycle hooks (since those can be applied on the component as well)
This commit is contained in:
committed by
Franz Liedke
parent
955c8121d3
commit
a6d4658dff
@@ -34,9 +34,6 @@ export default class TextEditor extends Component {
|
||||
<div className="TextEditor">
|
||||
<textarea
|
||||
className="FormControl Composer-flexible"
|
||||
oncreate={this.textareaOncreate.bind(this)}
|
||||
onupdate={this.textareaOnupdate.bind(this)}
|
||||
onremove={this.textareaOnremove.bind(this)}
|
||||
oninput={(e) => {
|
||||
this.oninput(e.target.value, e);
|
||||
}}
|
||||
@@ -53,28 +50,18 @@ export default class TextEditor extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
textareaOncreate(vnode) {
|
||||
oncreate(vnode) {
|
||||
const handler = () => {
|
||||
this.onsubmit();
|
||||
m.redraw();
|
||||
};
|
||||
|
||||
$(vnode.dom).bind('keydown', 'meta+return', handler);
|
||||
$(vnode.dom).bind('keydown', 'ctrl+return', handler);
|
||||
this.$('textarea').bind('keydown', 'meta+return', handler);
|
||||
this.$('textarea').bind('keydown', 'ctrl+return', handler);
|
||||
|
||||
this.attrs.composer.editor = new SuperTextarea(vnode.dom);
|
||||
this.attrs.composer.editor = new SuperTextarea(this.$('textarea'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Here for extensibility
|
||||
*/
|
||||
textareaOnupdate(vnode) {}
|
||||
|
||||
/**
|
||||
* Here for extensibility
|
||||
*/
|
||||
textareaOnremove(vnode) {}
|
||||
|
||||
/**
|
||||
* Build an item list for the text editor controls.
|
||||
*
|
||||
|
Reference in New Issue
Block a user