Procházet zdrojové kódy

tinyMCE integration

AlexiCauvin před 6 roky
rodič
revize
020f1cba33
1 změnil soubory, kde provedl 18 přidání a 21 odebrání
  1. 18 21
      dist/index.html

+ 18 - 21
dist/index.html Zobrazit soubor

33
     <script src="/dev/popper-1.12.3.js"></script>
33
     <script src="/dev/popper-1.12.3.js"></script>
34
     <script src="/dev/bootstrap-4.0.0-beta.2.js"></script>
34
     <script src="/dev/bootstrap-4.0.0-beta.2.js"></script>
35
 
35
 
36
+    <script type="text/javascript" src="/asset/tinymce/jquery.tinymce.min.js"></script>
37
+    <script type="text/javascript" src="/asset/tinymce/tinymce.min.js"></script>
38
+
36
     <script type='text/javascript'>
39
     <script type='text/javascript'>
37
       let prevSelectedApp = {name: ''} // default value
40
       let prevSelectedApp = {name: ''} // default value
38
 
41
 
72
     </script>
75
     </script>
73
 
76
 
74
     <script type='text/javascript'>
77
     <script type='text/javascript'>
75
-      if (window.matchMedia("(min-width:1200px)").matches) {
76
-
77
-        var jsScript = document.createElement("script");
78
-        jsScript.type = "text/javascript";
79
-        jsScript.src = "https://cloud.tinymce.com/stable/tinymce.min.js?apiKey=dfdhxdokxj2wagzkbxfgysgh86d6rr9m3dln0172vo3shipc";
80
-
81
-        jsScript.onload = function() {
78
+      $(document).ready(function () {
79
+        wysiwyg = function () {
82
           function base64EncodeAndTinyMceInsert (files) {
80
           function base64EncodeAndTinyMceInsert (files) {
83
             for (var i = 0; i < files.length; i++) {
81
             for (var i = 0; i < files.length; i++) {
84
               if (files[i].size > 1000000)
82
               if (files[i].size > 1000000)
133
                 icon: 'mce-ico mce-i-image',
131
                 icon: 'mce-ico mce-i-image',
134
                 title: 'Image',
132
                 title: 'Image',
135
                 onclick: function () {
133
                 onclick: function () {
136
-                  var hiddenTinyMceInput = $('#hidden_tinymce_fileinput')
137
-
138
-                  if (hiddenTinyMceInput.length > 0) hiddenTinyMceInput.remove()
134
+                  if ($('#hidden_tinymce_fileinput').length > 0) $('#hidden_tinymce_fileinput').remove()
139
 
135
 
140
                   fileTag = document.createElement('input')
136
                   fileTag = document.createElement('input')
141
                   fileTag.id = 'hidden_tinymce_fileinput'
137
                   fileTag.id = 'hidden_tinymce_fileinput'
142
                   fileTag.type = 'file'
138
                   fileTag.type = 'file'
143
                   $('body').append(fileTag)
139
                   $('body').append(fileTag)
144
 
140
 
145
-                  hiddenTinyMceInput.on('change', function () {
141
+                  $('#hidden_tinymce_fileinput').on('change', function () {
146
                     base64EncodeAndTinyMceInsert($(this)[0].files)
142
                     base64EncodeAndTinyMceInsert($(this)[0].files)
147
                   })
143
                   })
148
 
144
 
149
-                  hiddenTinyMceInput.click()
145
+                  $('#hidden_tinymce_fileinput').click()
150
                 }
146
                 }
151
               })
147
               })
152
 
148
 
153
               //////////////////////////////////////////////
149
               //////////////////////////////////////////////
154
               // Handle drag & drop image into TinyMce by encoding them in base64 (to avoid uploading them somewhere and keep saving comment in string format)
150
               // Handle drag & drop image into TinyMce by encoding them in base64 (to avoid uploading them somewhere and keep saving comment in string format)
155
               $editor
151
               $editor
156
-                .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
157
-                  e.preventDefault()
158
-                  e.stopPropagation()
159
-                })
160
-                .on('drop', function(e) {
161
-                  base64EncodeAndTinyMceInsert(e.dataTransfer.files)
162
-                })
152
+              .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
153
+                e.preventDefault()
154
+                e.stopPropagation()
155
+              })
156
+              .on('drop', function(e) {
157
+                base64EncodeAndTinyMceInsert(e.dataTransfer.files)
158
+              })
163
             }
159
             }
164
           });
160
           });
165
         }
161
         }
166
-        document.getElementsByTagName("body")[0].appendChild(jsScript);
167
-      }
162
+
163
+        wysiwyg()
164
+      })
168
     </script>
165
     </script>
169
   </body>
166
   </body>
170
 </html>
167
 </html>