File tree 4 files changed +64
-3
lines changed
lib/rails_admin/config/fields/types
4 files changed +64
-3
lines changed Original file line number Diff line number Diff line change @@ -125,11 +125,23 @@ $(document).live 'rails_admin.dom_ready', ->
125
125
# ckeditor
126
126
127
127
$ (' form [data-richtext=ckeditor]' ).not (' .ckeditored' ).each ->
128
- window .CKEDITOR_BASEPATH = ' /assets/ckeditor/'
129
128
options = $ (this ).data (' options' )
129
+ window .CKEDITOR_BASEPATH = options[' base_location' ]
130
130
if not window .CKEDITOR
131
131
$ (window .document ).append (' <script src="' + options[' jspath' ] + ' "><\/ script>' )
132
132
if instance = window .CKEDITOR .instances [this .id ]
133
133
instance .destroy (true )
134
134
window .CKEDITOR .replace (this , options[' options' ])
135
135
$ (this ).addClass (' ckeditored' )
136
+
137
+ # codemirror
138
+
139
+ $ (' form [data-richtext=codemirror]' ).not (' .codemirrored' ).each ->
140
+ options = $ (this ).data (' options' )
141
+ if not window .CodeMirror
142
+ $ (window .document ).append (' <script src="' + options[' jspath' ] + ' " type="text\/ javascript"><\/ script>' )
143
+ $ (' head' ).append (' <script src="' + options[' locations' ][' mode' ] + ' " type="text\/ javascript"><\/ script>' )
144
+ $ (' head' ).append (' <link href="' + options[' csspath' ] + ' " rel="stylesheet" media="all" type="text\/ css">' )
145
+ $ (' head' ).append (' <link href="' + options[' locations' ][' theme' ] + ' " rel="stylesheet" media="all" type="text\/ css">' )
146
+ CodeMirror .fromTextArea (this ,{mode : options[' options' ][' mode' ],theme : options[' options' ][' theme' ]})
147
+ $ (this ).addClass (' codemirrored' )
Original file line number Diff line number Diff line change 34
34
@import "bootstrap/grid";
35
35
@import "bootstrap/layouts";
36
36
@import "bootstrap/type";
37
- @import "bootstrap/code";
38
37
@import "bootstrap/forms";
39
38
@import "bootstrap/tables";
40
39
@import "bootstrap/sprites";
Original file line number Diff line number Diff line change 2
2
if field.ckeditor
3
3
richtext = ' ckeditor'
4
4
js_data = {
5
- :jspath => ' /assets/ckeditor/ckeditor.js' ,
5
+ :jspath => field.ckeditor_location,
6
+ :base_location => field.ckeditor_base_location,
6
7
:options => {
7
8
:customConfig => field.ckeditor_config_js
8
9
}
9
10
}
11
+ elsif field.codemirror
12
+ richtext = ' codemirror'
13
+ js_data = {
14
+ :csspath => field.codemirror_css_location,
15
+ :jspath => field.codemirror_js_location,
16
+ :options => field.codemirror_config,
17
+ :locations => field.codemirror_assets
18
+ }
10
19
else
11
20
richtext = false
12
21
js_data = {}
Original file line number Diff line number Diff line change @@ -19,6 +19,47 @@ class Text < RailsAdmin::Config::Fields::Base
19
19
"/assets/ckeditor/config.js"
20
20
end
21
21
22
+ #Use this if you want to point to a cloud instances of CKeditor
23
+ register_instance_option ( :ckeditor_location ) do
24
+ '/assets/ckeditor/ckeditor.js'
25
+ end
26
+
27
+ #Use this if you want to point to a cloud instances of the base CKeditor
28
+ register_instance_option ( :ckeditor_base_location ) do
29
+ '/assets/ckeditor/'
30
+ end
31
+
32
+ # Codemirror is disabled by default and CKEditor takes precedence
33
+ register_instance_option ( :codemirror ) do
34
+ false
35
+ end
36
+
37
+ #Pass the theme and mode for Codemirror
38
+ register_instance_option ( :codemirror_config ) do
39
+ {
40
+ :mode => 'css' ,
41
+ :theme => 'night'
42
+ }
43
+ end
44
+
45
+ #Pass the location of the theme and mode for Codemirror
46
+ register_instance_option ( :codemirror_assets ) do
47
+ {
48
+ :mode => '/assets/codemirror/modes/css.js' ,
49
+ :theme => '/assets/codemirror/themes/night.css'
50
+ }
51
+ end
52
+
53
+ #Use this if you want to point to a cloud instances of CodeMirror
54
+ register_instance_option ( :codemirror_js_location ) do
55
+ '/assets/codemirror.js'
56
+ end
57
+
58
+ #Use this if you want to point to a cloud instances of CodeMirror
59
+ register_instance_option ( :codemirror_css_location ) do
60
+ '/assets/codemirror.css'
61
+ end
62
+
22
63
register_instance_option ( :html_attributes ) do
23
64
{
24
65
:cols => "48" ,
You can’t perform that action at this time.
0 commit comments