Merge pull request #13966 from hasnain2808/maxlines-argument-to-ace-editor
feat: max_lines option in ace editor
This commit is contained in:
commit
0a7720c013
1 changed files with 16 additions and 6 deletions
|
|
@ -9,12 +9,7 @@ frappe.ui.form.ControlCode = class ControlCode extends frappe.ui.form.ControlTex
|
|||
this.ace_editor_target = $('<div class="ace-editor-target"></div>')
|
||||
.appendTo(this.input_area);
|
||||
|
||||
this.expanded = false;
|
||||
this.$expand_button = $(`<button class="btn btn-xs btn-default">${this.get_button_label()}</button>`).click(() => {
|
||||
this.expanded = !this.expanded;
|
||||
this.refresh_height();
|
||||
this.toggle_label();
|
||||
}).appendTo(this.$input_wrapper);
|
||||
|
||||
// styling
|
||||
this.ace_editor_target.addClass('border rounded');
|
||||
this.ace_editor_target.css('height', 300);
|
||||
|
|
@ -22,6 +17,21 @@ frappe.ui.form.ControlCode = class ControlCode extends frappe.ui.form.ControlTex
|
|||
// initialize
|
||||
const ace = window.ace;
|
||||
this.editor = ace.edit(this.ace_editor_target.get(0));
|
||||
|
||||
if (this.df.max_lines || this.df.min_lines) {
|
||||
if (this.df.max_lines)
|
||||
this.editor.setOption("maxLines", this.df.max_lines);
|
||||
if (this.df.min_lines)
|
||||
this.editor.setOption("minLines", this.df.min_lines);
|
||||
} else {
|
||||
this.expanded = false;
|
||||
this.$expand_button = $(`<button class="btn btn-xs btn-default">${this.get_button_label()}</button>`).click(() => {
|
||||
this.expanded = !this.expanded;
|
||||
this.refresh_height();
|
||||
this.toggle_label();
|
||||
}).appendTo(this.$input_wrapper);
|
||||
}
|
||||
|
||||
this.editor.setTheme('ace/theme/tomorrow');
|
||||
this.editor.setOption("showPrintMargin", false);
|
||||
this.editor.setOption("wrap", this.df.wrap);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue