Make autofocus works in text editor
This commit is contained in:
@@ -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'])) {
|
||||||
|
|||||||
4
assets/js/app.min.js
vendored
4
assets/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -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];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user