-
Notifications
You must be signed in to change notification settings - Fork 917
/
Copy pathsummernote.blade.php
76 lines (65 loc) · 2.81 KB
/
summernote.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{{-- summernote editor --}}
@php
// make sure that the options array is defined
// and at the very least, dialogsInBody is true;
// that's needed for modals to show above the overlay in Bootstrap 4
$field['options'] = array_merge(['dialogsInBody' => true, 'tooltip' => false], $field['options'] ?? []);
@endphp
@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
@include('crud::fields.inc.translatable_icon')
<textarea
name="{{ $field['name'] }}"
data-init-function="bpFieldInitSummernoteElement"
data-options="{{ json_encode($field['options']) }}"
bp-field-main-input
@include('crud::fields.inc.attributes', ['default_class' => 'form-control summernote'])
>{{ old_empty_or_null($field['name'], '') ?? $field['value'] ?? $field['default'] ?? '' }}</textarea>
{{-- HINT --}}
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
@include('crud::fields.inc.wrapper_end')
{{-- ########################################## --}}
{{-- 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 --}}
{{-- FIELD CSS - will be loaded in the after_styles section --}}
@push('crud_fields_styles')
{{-- include summernote css --}}
@basset('https://unpkg.com/[email protected]/dist/summernote-bs4.min.css')
@basset('https://unpkg.com/[email protected]/dist/font/summernote.woff2', false)
@loadOnce('summernoteCss')
<style type="text/css">
.note-editor.note-frame .note-status-output, .note-editor.note-airframe .note-status-output {
height: auto;
}
</style>
@endLoadOnce
@endpush
{{-- FIELD JS - will be loaded in the after_scripts section --}}
@push('crud_fields_scripts')
{{-- include summernote js --}}
@basset('https://unpkg.com/[email protected]/dist/summernote.min.js')
@loadOnce('bpFieldInitSummernoteElement')
<script>
function bpFieldInitSummernoteElement(element) {
var summernoteOptions = element.data('options');
let summernotCallbacks = {
onChange: function(contents, $editable) {
element.val(contents).trigger('change');
}
}
element.on('CrudField:disable', function(e) {
element.summernote('disable');
});
element.on('CrudField:enable', function(e) {
element.summernote('enable');
});
summernoteOptions['callbacks'] = summernotCallbacks;
element.summernote(summernoteOptions);
}
</script>
@endLoadOnce
@endpush
{{-- End of Extra CSS and JS --}}
{{-- ########################################## --}}