|
@@ -92,8 +92,8 @@
|
92
|
92
|
</script>
|
93
|
93
|
|
94
|
94
|
<script type='text/javascript'>
|
95
|
|
- $(document).ready(function () {
|
96
|
|
- wysiwyg = function () {
|
|
95
|
+ (function () {
|
|
96
|
+ wysiwyg = function (selector, handleOnChange) {
|
97
|
97
|
function base64EncodeAndTinyMceInsert (files) {
|
98
|
98
|
for (var i = 0; i < files.length; i++) {
|
99
|
99
|
if (files[i].size > 1000000)
|
|
@@ -126,9 +126,7 @@
|
126
|
126
|
});
|
127
|
127
|
|
128
|
128
|
tinymce.init({
|
129
|
|
- /*editor_deselector : "notawysiwygtext", // class="notawysiwygtext" will not have tinyMCE
|
130
|
|
- editor_selector : "wysiwygtext", // class="wysiwygtext" will.*/
|
131
|
|
- selector: 'textarea',
|
|
129
|
+ selector: selector,
|
132
|
130
|
// height: 130,
|
133
|
131
|
// width: 530,
|
134
|
132
|
menubar: false,
|
|
@@ -144,6 +142,10 @@
|
144
|
142
|
'//www.tinymce.com/css/codepen.min.css'
|
145
|
143
|
],
|
146
|
144
|
setup: function ($editor) {
|
|
145
|
+ $editor.on('change', function(e) {
|
|
146
|
+ handleOnChange({target: {value: $editor.getContent()}}) // target.value to emulate a js event so the react handler can expect one
|
|
147
|
+ })
|
|
148
|
+
|
147
|
149
|
//////////////////////////////////////////////
|
148
|
150
|
// add custom btn to handle image by selecting them with system explorer
|
149
|
151
|
$editor.addButton('customInsertImage', {
|
|
@@ -168,19 +170,17 @@
|
168
|
170
|
//////////////////////////////////////////////
|
169
|
171
|
// Handle drag & drop image into TinyMce by encoding them in base64 (to avoid uploading them somewhere and keep saving comment in string format)
|
170
|
172
|
$editor
|
171
|
|
- .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
|
172
|
|
- e.preventDefault()
|
173
|
|
- e.stopPropagation()
|
174
|
|
- })
|
175
|
|
- .on('drop', function(e) {
|
176
|
|
- base64EncodeAndTinyMceInsert(e.dataTransfer.files)
|
177
|
|
- })
|
|
173
|
+ .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
|
|
174
|
+ e.preventDefault()
|
|
175
|
+ e.stopPropagation()
|
|
176
|
+ })
|
|
177
|
+ .on('drop', function(e) {
|
|
178
|
+ base64EncodeAndTinyMceInsert(e.dataTransfer.files)
|
|
179
|
+ })
|
178
|
180
|
}
|
179
|
|
- });
|
|
181
|
+ })
|
180
|
182
|
}
|
181
|
|
-
|
182
|
|
- wysiwyg()
|
183
|
|
- })
|
|
183
|
+ })()
|
184
|
184
|
</script>
|
185
|
185
|
</body>
|
186
|
186
|
</html>
|