vendor/uvdesk/core-framework/Resources/views/Templates/tinyMCE.html.twig line 1

Open in your IDE?
  1. <script src="{{ asset('bundles/uvdeskcoreframework/js/tinymce/tinymce.min.js') }}"></script>
  2. <script type="text/javascript">
  3.     var sfTinyMce = {
  4.         tinymce : tinymce,
  5.         options : {
  6.             browser_spellcheck : true,
  7.             selector: '.uv-view textarea',
  8.             branding: false,
  9.             relative_urls : false,
  10.             remove_script_host : false,
  11.             image_title: true,
  12.             autoresize_max_height: 350,
  13.             theme: 'modern',
  14.             menubar: false,
  15.             height: 150,
  16.             toolbar: 'undo redo | bold italic | forecolor | bullist | numlist | link | spellchecker | code | image | styleselect',
  17.             spellchecker_languages: 'English=en',
  18.             plugins: [
  19.                 'spellchecker advlist autolink lists link charmap print preview hr anchor pagebreak',
  20.                 'searchreplace wordcount visualblocks visualchars code fullscreen',
  21.                 'media nonbreaking table directionality',
  22.                 'emoticons template paste textcolor colorpicker textpattern codesample toc',
  23.                 'autoresize image imagetools',
  24.                 'mention',
  25.             ],
  26.             invalid_elements : 'script,style,iframe,input,textarea,form,onmouseover,onmouseout,onclick',
  27.             paste_data_images: true,
  28.             mentions : {
  29.                 source: function(){
  30.                     return [];
  31.                 },
  32.             },
  33.         },
  34.         init : function (options){
  35.             if(typeof(options.setup) === 'function'){
  36.                 let optionsSetup = options.setup;
  37.                 this.options.setup = function(editor){
  38.                     sfTinyMce.initImageUpload(editor);
  39.                     optionsSetup(editor);
  40.                 }
  41.                 delete options.setup;
  42.             }else{
  43.                 this.options.setup = function(editor){
  44.                     sfTinyMce.initImageUpload(editor);
  45.                 }
  46.                 delete options.setup;
  47.             }
  48.             this.options = $.extend({}, this.options, options)
  49.             window.tinymce.dom.Event.domLoaded = true;
  50.             tinymce.init(this.options);
  51.         },
  52.         html : function(selector, html){
  53.             tinymce.get(selector).setContent(html);
  54.         },
  55.         initImageUpload : function(editor) {
  56.             // create input and insert in the DOM
  57.             var inp = $('<input id="tinymce-uploader" type="file" name="pic" accept="image/*" style="display:none">');
  58.             $(editor.getElement()).parent().append(inp);
  59.             // add the image upload button to the editor toolbar
  60.             editor.addButton('imageupload', {
  61.                 text: '',
  62.                 icon: 'image',
  63.                 onclick: function(e) { // when toolbar button is clicked, open file select modal
  64.                     inp.trigger('click');
  65.                 }
  66.             });
  67.             // when a file is selected, upload it to the server
  68.             inp.on("change", function(e){
  69.                 sfTinyMce.uploadFile($(this), editor);
  70.             });
  71.         },
  72.         uploadFile : function(input, editor) {
  73.             sendFile(input.get(0).files).done(function(json){
  74.                     //remove loading image
  75.                     if(json['error'] != ''){
  76.                         var response = {
  77.                             'alertClass' : 'danger',
  78.                             'alertMessage' : json['error'],
  79.                         };
  80.                         app.appView.hideLoader();
  81.                         app.appView.renderResponseAlert(response);
  82.                     }else if(json['fileNames']){
  83.                         $.each(json['fileNames'], function(key, path){
  84.                             editor.insertContent('<img class="content-img" src="' + path + '"/>');
  85.                         });
  86.                     }
  87.                     if(json.location != undefined)
  88.                         window.location = json.location;
  89.                 })
  90.                 .fail(function(xhr) {
  91.                     if(url = xhr.getResponseHeader('Location'))
  92.                         window.location = url;
  93.                     app.appView.hideLoader();
  94.                     app.appView.renderResponseAlert(warningResponse);
  95.                 })
  96.             ;
  97.         },
  98.     }
  99.     function sendFile(files) {
  100.         
  101.     }
  102.     function sendUrls(url) {
  103.         
  104.     }
  105.     function removeFile(file) {
  106.         
  107.     }
  108.     addTranslateButton = function(editor) {
  109.         
  110.     }
  111. </script>