|
21 | 21 | </div>
|
22 | 22 | </div>
|
23 | 23 | <div class="row">
|
24 |
| - <div class="col-md-6 col-md-offset-3"> |
| 24 | + <div class="col-md-6"> |
| 25 | + <h2>Summernote</h2> |
| 26 | + <textarea id="summernote-editor" name="content"></textarea> |
| 27 | + </div> |
| 28 | + <div class="col-md-6"> |
25 | 29 | <h2>Standalone Button</h2>
|
26 | 30 | <div class="input-group">
|
27 | 31 | <span class="input-group-btn">
|
|
44 | 48 |
|
45 | 49 | <!-- CKEditor init -->
|
46 | 50 | <script src="//cdnjs.cloudflare.com/ajax/libs/ckeditor/4.5.11/ckeditor.js"></script>
|
47 |
| - <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> |
48 | 51 | <script src="//cdnjs.cloudflare.com/ajax/libs/ckeditor/4.5.11/adapters/jquery.js"></script>
|
49 | 52 | <script>
|
50 | 53 | $('textarea[name=ce]').ckeditor({
|
|
98 | 101 | <script>
|
99 | 102 | $('#lfm').filemanager('image', {prefix: route_prefix});
|
100 | 103 | </script>
|
| 104 | + |
| 105 | + <link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.4/summernote.css" rel="stylesheet"> |
| 106 | + <script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.4/summernote.js"></script> |
| 107 | + <script> |
| 108 | + $(document).ready(function() { |
| 109 | + $('#summernote').summernote(); |
| 110 | + }); |
| 111 | + </script> |
| 112 | + <script> |
| 113 | + $(document).ready(function(){ |
| 114 | +
|
| 115 | + // Define function to open filemanager window |
| 116 | + var lfm = function(options, cb) { |
| 117 | + var route_prefix = (options && options.prefix) ? options.prefix : '/laravel-filemanager'; |
| 118 | + window.open(route_prefix + '?type=' + options.type || 'file', 'FileManager', 'width=900,height=600'); |
| 119 | + window.SetUrl = cb; |
| 120 | + }; |
| 121 | +
|
| 122 | + // Define LFM summernote button |
| 123 | + var LFMButton = function(context) { |
| 124 | + var ui = $.summernote.ui; |
| 125 | + var button = ui.button({ |
| 126 | + contents: '<i class="note-icon-picture"></i> ', |
| 127 | + tooltip: 'Insert image with filemanager', |
| 128 | + click: function() { |
| 129 | +
|
| 130 | + lfm({type: 'image', prefix: '/laravel-filemanager'}, function(url, path) { |
| 131 | + context.invoke('insertImage', url); |
| 132 | + }); |
| 133 | +
|
| 134 | + } |
| 135 | + }); |
| 136 | + return button.render(); |
| 137 | + }; |
| 138 | +
|
| 139 | + // Initialize summernote with LFM button in the popover button group |
| 140 | + // Please note that you can add this button to any other button group you'd like |
| 141 | + $('#summernote-editor').summernote({ |
| 142 | + toolbar: [ |
| 143 | + ['popovers', ['lfm']], |
| 144 | + ], |
| 145 | + buttons: { |
| 146 | + lfm: LFMButton |
| 147 | + } |
| 148 | + }) |
| 149 | + }); |
| 150 | + </script> |
101 | 151 | </body>
|
102 | 152 | </html>
|
0 commit comments