Make autofocus works in text editor

This commit is contained in:
Frederic Guillot
2016-11-27 18:57:05 -05:00
parent 453513da29
commit 0c426c6d99
4 changed files with 7 additions and 4 deletions

View File

@@ -220,6 +220,7 @@ class FormHelper extends Base
'labelPreview' => t('Preview'), 'labelPreview' => t('Preview'),
'labelWrite' => t('Write'), 'labelWrite' => t('Write'),
'placeholder' => t('Write your text in Markdown'), 'placeholder' => t('Write your text in Markdown'),
'autofocus' => isset($attributes['autofocus']) && $attributes['autofocus']
); );
if (isset($values['project_id'])) { if (isset($values['project_id'])) {

File diff suppressed because one or more lines are too long

View File

@@ -55,7 +55,6 @@ KB.component('suggest-menu', function(containerElement, options) {
var lines = element.value.substring(0, element.selectionEnd).split("\n"); var lines = element.value.substring(0, element.selectionEnd).split("\n");
var lastLine = lines[lines.length - 1]; var lastLine = lines[lines.length - 1];
var words = lastLine.split(' '); var words = lastLine.split(' ');
console.log(words);
return words[words.length - 1]; return words[words.length - 1];
} }

View File

@@ -10,6 +10,10 @@ KB.component('text-editor', function (containerElement, options) {
.add(viewModeElement) .add(viewModeElement)
.add(writeModeElement) .add(writeModeElement)
.build()); .build());
if (options.autofocus) {
textarea.focus();
}
}; };
function buildViewMode() { function buildViewMode() {
@@ -50,7 +54,6 @@ KB.component('text-editor', function (containerElement, options) {
.attr('name', options.name) .attr('name', options.name)
.attr('tabindex', options.tabindex || '-1') .attr('tabindex', options.tabindex || '-1')
.attr('required', options.required || false) .attr('required', options.required || false)
.attr('autofocus', options.autofocus || null)
.text(options.text) // Order is important for IE11 .text(options.text) // Order is important for IE11
.attr('placeholder', options.placeholder || null) .attr('placeholder', options.placeholder || null)
.build(); .build();