mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 02:46:11 +02:00
Mode codemirror.js under app/javascript/packs
Meld codemirror_fluentd.js into codemirror.js. Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
This commit is contained in:
parent
d5f0eac035
commit
e87982d765
@ -1,29 +0,0 @@
|
||||
function codemirrorify(el) {
|
||||
return CodeMirror.fromTextArea(el, {
|
||||
theme: "neo",
|
||||
lineNumbers: true,
|
||||
viewportMargin: Infinity,
|
||||
mode: "fluentd"
|
||||
});
|
||||
}
|
||||
|
||||
$(function(){
|
||||
$('.js-fluentd-config-editor').each(function(_, el){
|
||||
codemirrorify(el);
|
||||
});
|
||||
});
|
||||
|
||||
Vue.directive('config-editor', {
|
||||
bind: function(){
|
||||
var $parent = this.vm;
|
||||
// NOTE: needed delay for waiting CodeMirror setup
|
||||
_.delay(function(textarea){
|
||||
var cm = codemirrorify(textarea);
|
||||
// textarea.codemirror = cm; // for test, but doesn't work for now (working on Chrome, but Poltergeist not)
|
||||
cm.on('change', function(code_mirror){
|
||||
// bridge Vue - CodeMirror world
|
||||
$parent.editContent = code_mirror.getValue();
|
||||
});
|
||||
}, 0, this.el);
|
||||
}
|
||||
});
|
||||
@ -1,7 +1,8 @@
|
||||
import CodeMirror from 'codemirror/lib/codemirror'
|
||||
|
||||
// See: http://codemirror.net/doc/manual.html#modeapi
|
||||
// and sample mode files: https://github.com/codemirror/CodeMirror/tree/master/mode
|
||||
|
||||
|
||||
CodeMirror.defineMode('fluentd', function(){
|
||||
return {
|
||||
startState: function(aa){
|
||||
@ -57,3 +58,33 @@ CodeMirror.defineMode('fluentd', function(){
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
function codemirrorify(el) {
|
||||
return CodeMirror.fromTextArea(el, {
|
||||
theme: "neo",
|
||||
lineNumbers: true,
|
||||
viewportMargin: Infinity,
|
||||
mode: "fluentd"
|
||||
});
|
||||
}
|
||||
|
||||
$(function(){
|
||||
$('.js-fluentd-config-editor').each(function(_, el){
|
||||
codemirrorify(el);
|
||||
});
|
||||
});
|
||||
|
||||
Vue.directive('config-editor', {
|
||||
bind: function(){
|
||||
var $parent = this.vm;
|
||||
// NOTE: needed delay for waiting CodeMirror setup
|
||||
_.delay(function(textarea){
|
||||
var cm = codemirrorify(textarea);
|
||||
// textarea.codemirror = cm; // for test, but doesn't work for now (working on Chrome, but Poltergeist not)
|
||||
cm.on('change', function(code_mirror){
|
||||
// bridge Vue - CodeMirror world
|
||||
$parent.editContent = code_mirror.getValue();
|
||||
});
|
||||
}, 0, this.el);
|
||||
}
|
||||
});
|
||||
@ -1,4 +1,5 @@
|
||||
- page_title t('.page_title', label: @fluentd.label)
|
||||
- add_javascript_pack_tag("codemirror")
|
||||
|
||||
= form_tag(daemon_setting_path(@fluentd), method: :patch) do
|
||||
.form-group
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user