Browse Source

tinyMCE integration

AlexiCauvin 6 years ago
parent
commit
020f1cba33
1 changed files with 18 additions and 21 deletions
  1. 18 21
      dist/index.html

+ 18 - 21
dist/index.html View File

@@ -33,6 +33,9 @@
33 33
     <script src="/dev/popper-1.12.3.js"></script>
34 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 39
     <script type='text/javascript'>
37 40
       let prevSelectedApp = {name: ''} // default value
38 41
 
@@ -72,13 +75,8 @@
72 75
     </script>
73 76
 
74 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 80
           function base64EncodeAndTinyMceInsert (files) {
83 81
             for (var i = 0; i < files.length; i++) {
84 82
               if (files[i].size > 1000000)
@@ -133,38 +131,37 @@
133 131
                 icon: 'mce-ico mce-i-image',
134 132
                 title: 'Image',
135 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 136
                   fileTag = document.createElement('input')
141 137
                   fileTag.id = 'hidden_tinymce_fileinput'
142 138
                   fileTag.type = 'file'
143 139
                   $('body').append(fileTag)
144 140
 
145
-                  hiddenTinyMceInput.on('change', function () {
141
+                  $('#hidden_tinymce_fileinput').on('change', function () {
146 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 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 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 165
     </script>
169 166
   </body>
170 167
 </html>