diff --git a/voyages/apps/blog/admin.py b/voyages/apps/blog/admin.py index 2f77ae8fa..760fe13c0 100644 --- a/voyages/apps/blog/admin.py +++ b/voyages/apps/blog/admin.py @@ -27,7 +27,7 @@ class AdvancedEditorManager(forms.Textarea): class Media: js = ( '//cdn.tiny.cloud/1/s12zokrfdqicajy5cxdauxuczwq653y00bx98ae9qhwklhh3/tinymce/7/tinymce.min.js', - 'scripts/tiny_mce/textareas.js') + 'scripts/tiny_mce/textareas.js',) def __init__(self, language=None, attrs=None): self.language = language or settings.LANGUAGE_CODE[:2] diff --git a/voyages/sitemedia/scripts/tiny_mce/textareas.js b/voyages/sitemedia/scripts/tiny_mce/textareas.js index a72a3e95c..6f30494ba 100644 --- a/voyages/sitemedia/scripts/tiny_mce/textareas.js +++ b/voyages/sitemedia/scripts/tiny_mce/textareas.js @@ -1,16 +1,25 @@ +function FileBrowserPopup(callback, value, type) { + var fbURL = '/admin/filebrowser/browse/?pop=5'; + fbURL = fbURL + "&type=" + type.filetype; + if(value) + fbURL += '&input='; + const instanceApi = tinyMCE.activeEditor.windowManager.openUrl({ + title: 'Filebrowser image/media/file picker', + url: fbURL, + width: 1280, + height: 800, + onMessage: function(dialogApi, details) { + callback(details.content); + instanceApi.close(); + } + }); + return false; +} + tinymce.init({ selector: "textarea", - plugins: [ - "advlist autolink lists link image charmap print preview hr anchor pagebreak", - "searchreplace wordcount visualblocks visualchars code fullscreen", - "insertdatetime media nonbreaking save table contextmenu directionality", - "emoticons template paste textcolor" - ], - toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image", - toolbar2: "print preview media | forecolor backcolor emoticons", + plugins: "link image media", +// images_upload_url: '/documents/blog/images/', image_advtab: true, - templates: [ - {title: 'Test template 1', content: 'Test 1'}, - {title: 'Test template 2', content: 'Test 2'} - ], + file_picker_callback: FileBrowserPopup, });