mirror of
https://github.com/flarum/core.git
synced 2025-08-09 18:07:02 +02:00
update: forum/components/TextEditor
This commit is contained in:
committed by
Franz Liedke
parent
7d9db2f4ae
commit
2fb885175a
@@ -30,11 +30,23 @@ export default class TextEditor extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
view() {
|
view() {
|
||||||
|
const configTextArea = () => {
|
||||||
|
const handler = () => {
|
||||||
|
this.onsubmit();
|
||||||
|
m.redraw();
|
||||||
|
};
|
||||||
|
|
||||||
|
$(element).bind('keydown', 'meta+return', handler);
|
||||||
|
$(element).bind('keydown', 'ctrl+return', handler);
|
||||||
|
|
||||||
|
this.attrs.composer.editor = new SuperTextarea(element);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="TextEditor">
|
<div className="TextEditor">
|
||||||
<textarea
|
<textarea
|
||||||
className="FormControl Composer-flexible"
|
className="FormControl Composer-flexible"
|
||||||
config={this.configTextarea.bind(this)}
|
oncreate={configTextArea.bind(this)}
|
||||||
oninput={(e) => {
|
oninput={(e) => {
|
||||||
this.oninput(e.target.value, e);
|
this.oninput(e.target.value, e);
|
||||||
}}
|
}}
|
||||||
@@ -51,26 +63,6 @@ export default class TextEditor extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure the textarea element.
|
|
||||||
*
|
|
||||||
* @param {HTMLTextAreaElement} element
|
|
||||||
* @param {Boolean} isInitialized
|
|
||||||
*/
|
|
||||||
configTextarea(element, isInitialized) {
|
|
||||||
if (isInitialized) return;
|
|
||||||
|
|
||||||
const handler = () => {
|
|
||||||
this.onsubmit();
|
|
||||||
m.redraw();
|
|
||||||
};
|
|
||||||
|
|
||||||
$(element).bind('keydown', 'meta+return', handler);
|
|
||||||
$(element).bind('keydown', 'ctrl+return', handler);
|
|
||||||
|
|
||||||
this.attrs.composer.editor = new SuperTextarea(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build an item list for the text editor controls.
|
* Build an item list for the text editor controls.
|
||||||
*
|
*
|
||||||
@@ -100,7 +92,7 @@ export default class TextEditor extends Component {
|
|||||||
className: 'Button Button--icon',
|
className: 'Button Button--icon',
|
||||||
onclick: this.attrs.preview,
|
onclick: this.attrs.preview,
|
||||||
title: app.translator.trans('core.forum.composer.preview_tooltip'),
|
title: app.translator.trans('core.forum.composer.preview_tooltip'),
|
||||||
config: (elm) => $(elm).tooltip(),
|
oncreate: (vnode) => $(vnode.dom).tooltip(),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user