Add set_content() method to the editor widget

pull/6115/head
Aleksander Machniak 7 years ago
parent 4255b21ca0
commit 8b0109d81c

@ -464,13 +464,29 @@ function rcube_text_editor(config, id)
} }
}; };
// Fill the editor with specified content
// TODO: support format conversion
this.set_content = function(content)
{
if (this.editor) {
this.editor.setContent(content);
this.editor.getWin().focus();
}
else if (ed = rcube_find_object(this.id)) {
$(ed).val(content).focus();
}
};
// get selected text (if no selection returns all text) from the editor // get selected text (if no selection returns all text) from the editor
this.get_content = function(args) this.get_content = function(args)
{ {
var sigstart, ed = this.editor, text = '', strip = false, var sigstart, ed = this.editor, text = '', strip = false,
defaults = {refresh: true, selection: false, nosig: false, format: 'html'}; defaults = {refresh: true, selection: false, nosig: false, format: 'html'};
args = $.extend(defaults, args); if (!args)
args = defaults;
else
args = $.extend(defaults, args);
// apply spellcheck changes if spell checker is active // apply spellcheck changes if spell checker is active
if (args.refresh) { if (args.refresh) {

Loading…
Cancel
Save