Completed
Pull Request — master (#2225)
by
unknown
03:18
created

Code::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Form\Field;
4
use Encore\Admin\Form\Field;
5
6
class Code extends Field
7
{
8
9
    protected $view = 'admin::form.code';
10
11
    protected static $css = [
12
        // main css file
13
        '/vendor/laravel-admin/codemirror/lib/codemirror.css',
14
        // darcula theme
15
        '/vendor/laravel-admin/codemirror/theme/darcula.css',
16
        // full screen
17
        '/vendor/laravel-admin/codemirror/addon/display/fullscreen.css',
18
    ];
19
20
    protected static $js = [
21
        // main js file
22
        '/vendor/laravel-admin/codemirror/lib/codemirror.js',
23
        // matchbrackets
24
        '/vendor/laravel-admin/codemirror/addon/edit/matchbrackets.js',
25
        // active line
26
        '/vendor/laravel-admin/codemirror/addon/selection/active-line.js',
27
        // full screen
28
        '/vendor/laravel-admin/codemirror/addon/display/fullscreen.js',
29
        // x-httpd-php mode
30
        '/vendor/laravel-admin/codemirror/mode/htmlmixed/htmlmixed.js',
31
        '/vendor/laravel-admin/codemirror/mode/xml/xml.js',
32
        '/vendor/laravel-admin/codemirror/mode/javascript/javascript.js',
33
        '/vendor/laravel-admin/codemirror/mode/css/css.js',
34
        '/vendor/laravel-admin/codemirror/mode/clike/clike.js',
35
        '/vendor/laravel-admin/codemirror/mode/php/php.js',
36
    ];
37
38
    public function render()
39
    {
40
        $this->script = <<<EOT
41
var editor = CodeMirror.fromTextArea($this->id, {
42
    lineNumbers: true, // show lineNumbers
43
    indentUnit: 4, // indentUnit 4
44
    styleActiveLine: true, // styleActiveLine
45
    matchBrackets: true, // matchBrackets
46
    mode: 'application/x-httpd-php', // php mode
47
    lineWrapping: true, // lineWrapping
48
    theme: 'darcula', // darcula theme
49
}); 
50
editor.setOption("extraKeys", {
51
    // Esc fullScreen
52
    "Esc": function(cm) {
53
        cm.setOption("fullScreen", !cm.getOption("fullScreen"));
54
    }
55
});
56
EOT;
57
        return parent::render();
0 ignored issues
show
Bug Compatibility introduced by
The expression parent::render(); of type string|Illuminate\View\V...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 57 which is incompatible with the return type declared by the interface Illuminate\Contracts\Support\Renderable::render of type string.
Loading history...
58
    }
59
}
60