@include('crud::fields.inc.translatable_icon')
<textarea
class="code"
+ data-language="{{$field['language']}}"
name="{{ $field['name'] }}"
@include('crud::fields.inc.attributes')
{{-- Extra CSS and JS for this particular field --}}
{{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}}
@if ($crud->checkIfFieldIsFirstOfItsType($field))
-textarea.code{
- font-family: Courier, monospace;
-}
+
+ @push('crud_fields_styles')
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/codemirror.min.css"
+ integrity="sha512-xIf9AdJauwKIVtrVRZ0i4nHP61Ogx9fSRAkCLecmE2dL/U8ioWpDvFCAy4dcfecN72HHB9+7FfQj3aiO68aaaw=="
+ crossorigin="anonymous"/>
+ @endpush
+ @push('crud_fields_scripts')
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/codemirror.min.js"
+ integrity="sha512-WWC1A/JchDFZ2ZGaNyMC7CmPFXGLI/6Ih7WN6YG0DX1NGMkW5lqCVFxCmEx3e56Z7iqdQGpO0f+m2t9CJhdb2Q=="
+ crossorigin="anonymous"></script>
+ <script>
+ jQuery(document).ready(function ($) {
+ function initMirrorCode() {
+ $('textarea.code').each(function () {
+ if ($(this).data('mirrorcodeok') === true) {
+ return;
+ }
+ $(this).data('mirrorcodeok', true);
+ CodeMirror.fromTextArea($(this).get(0), {
+ lineNumbers: true,
+ mode: $(this).data('language'),
+ });
+ });
+ }
+
+ initMirrorCode();
+ $(document).on('cubist.bunchmultiple.added', function () {
+ initMirrorCode();
+ });
+ })
+
+
+ </script>
+ @endpush
@endif