Add get/set content to code editor plugin

Fixes plain text / snippet editor issue
Fixes #2059
This commit is contained in:
Samuel Georges 2016-05-29 08:54:22 +10:00
parent 55e7e1e545
commit bb5a44ced5
4 changed files with 30 additions and 1 deletions

View File

@ -63,10 +63,20 @@ class CodeEditor extends FormWidgetBase
public $margin = 0;
/**
* @var $theme Ace Editor theme to use.
* @var string Ace Editor theme to use.
*/
public $theme = 'twilight';
/**
* @var bool Show invisible characters.
*/
public $showInvisibles = false;
/**
* @var bool Highlight the active line.
*/
public $highlightActiveLine = true;
/**
* @var boolean If true, the editor is set to read-only mode
*/
@ -119,6 +129,8 @@ class CodeEditor extends FormWidgetBase
'fontSize',
'margin',
'theme',
'showInvisibles',
'highlightActiveLine',
'readOnly',
'autocompletion',
'enableSnippets',

View File

@ -4713,6 +4713,8 @@ renderer.setPrintMarginColumn(80)
break}}
CodeEditor.prototype.setTheme=function(theme){var self=this
assetManager.load({js:[this.options.vendorPath+'/theme-'+theme+'.js']},function(){self.editor.setTheme('ace/theme/'+theme)})}
CodeEditor.prototype.getContent=function(){return this.editor.getSession().getValue()}
CodeEditor.prototype.setContent=function(html){this.editor.getSession().setValue(html)}
CodeEditor.prototype.getEditorObject=function(){return this.editor}
CodeEditor.prototype.getToolbar=function(){return this.$toolbar}
CodeEditor.prototype.toggleFullscreen=function(){this.$el.toggleClass('editor-fullscreen')

View File

@ -340,6 +340,14 @@
})
}
CodeEditor.prototype.getContent = function() {
return this.editor.getSession().getValue()
}
CodeEditor.prototype.setContent = function(html) {
this.editor.getSession().setValue(html)
}
CodeEditor.prototype.getEditorObject = function() {
return this.editor
}

View File

@ -0,0 +1,7 @@
ace.define("ace/snippets/plain_text",["require","exports","module"], function(require, exports, module) {
"use strict";
exports.snippetText =undefined;
exports.scope = "plain_text";
});