|
@@ -11,148 +11,99 @@
|
11
|
11
|
<link rel="stylesheet" type="text/css" href="./dev/bootstrap-4.0.0-beta.css">
|
12
|
12
|
</head>
|
13
|
13
|
<body>
|
14
|
|
- <script src="./dev/jquery-3.2.1.js"></script>
|
15
|
|
- <script src="./dev/popper-1.12.3.js"></script>
|
16
|
|
- <script src="./dev/bootstrap-4.0.0-beta.2.js"></script>
|
17
|
|
-
|
18
|
|
- <div id='content'></div>
|
19
|
|
-
|
20
|
|
- <script src='./thread.app.dev.js'></script>
|
21
|
|
-
|
22
|
|
- <script type='text/javascript'>
|
23
|
|
- GLOBAL_renderApp = app => {
|
24
|
|
- switch (app.appData.name) {
|
25
|
|
- case 'PageHtml':
|
26
|
|
- appPageHtml.renderApp('appContainer'); break
|
27
|
|
- case 'Thread':
|
28
|
|
- appThread.renderApp('appContainer'); break
|
29
|
|
- }
|
30
|
|
- }
|
31
|
|
-
|
32
|
|
- GLOBAL_dispatchEvent = (data) => {
|
33
|
|
- var event = new CustomEvent('appCustomEvent', {detail: data})
|
34
|
|
- document.dispatchEvent(event)
|
35
|
|
- }
|
36
|
|
-
|
37
|
|
- GLOBAL_unmountApp = () => {
|
38
|
|
- switch (appName) {
|
39
|
|
- case 'PageHtml':
|
40
|
|
- appPageHtml.hideApp('appContainer'); break
|
41
|
|
- case 'Thread':
|
42
|
|
- appThread.hideApp('appContainer'); break
|
43
|
|
- }
|
44
|
|
- }
|
45
|
|
-
|
46
|
|
- // only usefull if app doesn't handle fileContent himself
|
47
|
|
- GLOBAL_handleRequireRedraw = () => {
|
48
|
|
- var rez = appA.destroyApp('app')
|
49
|
|
- if (rez) GLOBAL_drawApp('redraw')
|
50
|
|
- else console.log('Erreur, failed at destroying app')
|
51
|
|
- }
|
52
|
|
- </script>
|
53
|
|
-
|
54
|
|
- <script type='text/javascript'>
|
55
|
|
- // appPageHtml.renderApp('content')
|
56
|
|
- </script>
|
57
|
|
-
|
58
|
|
- <script type="text/javascript" src="/asset/tinymce/jquery.tinymce.min.js"></script>
|
59
|
|
- <script type="text/javascript" src="/asset/tinymce/tinymce.min.js"></script>
|
60
|
|
-
|
61
|
|
- <script type='text/javascript'>
|
62
|
|
- if (window.matchMedia("(min-width:1200px)").matches) {
|
63
|
|
-
|
64
|
|
- var jsScript = document.createElement("script");
|
65
|
|
- jsScript.type = "text/javascript";
|
66
|
|
- jsScript.src = "https://cloud.tinymce.com/stable/tinymce.min.js?apiKey=dfdhxdokxj2wagzkbxfgysgh86d6rr9m3dln0172vo3shipc";
|
67
|
|
-
|
68
|
|
- jsScript.onload = function() {
|
69
|
|
- function base64EncodeAndTinyMceInsert (files) {
|
70
|
|
- for (var i = 0; i < files.length; i++) {
|
71
|
|
- if (files[i].size > 1000000)
|
72
|
|
- files[i].allowed = confirm(files[i].name + " fait plus de 1mo et peut prendre du temps à insérer, voulez-vous continuer ?")
|
73
|
|
- }
|
|
14
|
+<script src="./dev/jquery-3.2.1.js"></script>
|
|
15
|
+<script src="./dev/popper-1.12.3.js"></script>
|
|
16
|
+<script src="./dev/bootstrap-4.0.0-beta.2.js"></script>
|
|
17
|
+
|
|
18
|
+<script type="text/javascript" src="/asset/tinymce/js/tinymce/jquery.tinymce.min.js"></script>
|
|
19
|
+<script type="text/javascript" src="/asset/tinymce/js/tinymce/tinymce.min.js"></script>
|
|
20
|
+
|
|
21
|
+<div id='content'></div>
|
|
22
|
+
|
|
23
|
+<script type='text/javascript'>
|
|
24
|
+ (function () {
|
|
25
|
+ wysiwyg = function (selector, handleOnChange) {
|
|
26
|
+ function base64EncodeAndTinyMceInsert (files) {
|
|
27
|
+ for (var i = 0; i < files.length; i++) {
|
|
28
|
+ if (files[i].size > 1000000)
|
|
29
|
+ files[i].allowed = confirm(files[i].name + " fait plus de 1mo et peut prendre du temps à insérer, voulez-vous continuer ?")
|
|
30
|
+ }
|
74
|
31
|
|
75
|
|
- for (var i = 0; i < files.length; i++) {
|
76
|
|
- if (files[i].allowed !== false && files[i].type.match('image.*')) {
|
77
|
|
- var img = document.createElement('img')
|
|
32
|
+ for (var i = 0; i < files.length; i++) {
|
|
33
|
+ if (files[i].allowed !== false && files[i].type.match('image.*')) {
|
|
34
|
+ var img = document.createElement('img')
|
78
|
35
|
|
79
|
|
- var fr = new FileReader()
|
|
36
|
+ var fr = new FileReader()
|
80
|
37
|
|
81
|
|
- fr.readAsDataURL(files[i])
|
|
38
|
+ fr.readAsDataURL(files[i])
|
82
|
39
|
|
83
|
|
- fr.onloadend = function (e) {
|
84
|
|
- img.src = e.target.result
|
85
|
|
- tinymce.activeEditor.execCommand('mceInsertContent', false, img.outerHTML)
|
86
|
|
- }
|
87
|
|
- }
|
|
40
|
+ fr.onloadend = function (e) {
|
|
41
|
+ img.src = e.target.result
|
|
42
|
+ tinymce.activeEditor.execCommand('mceInsertContent', false, img.outerHTML)
|
88
|
43
|
}
|
89
|
44
|
}
|
|
45
|
+ }
|
|
46
|
+ }
|
90
|
47
|
|
91
|
|
- // HACK: The tiny mce source code modal contain a textarea, but we
|
92
|
|
- // can't edit it (like it's readonly). The following solution
|
93
|
|
- // solve the bug: https://stackoverflow.com/questions/36952148/tinymce-code-editor-is-readonly-in-jtable-grid
|
94
|
|
- $(document).on('focusin', function(e) {
|
95
|
|
- if ($(e.target).closest(".mce-window").length) {
|
96
|
|
- e.stopImmediatePropagation();
|
97
|
|
- }
|
98
|
|
- });
|
99
|
|
-
|
100
|
|
- tinymce.init({
|
101
|
|
- selector: 'textarea',
|
102
|
|
- height: 130,
|
103
|
|
- // width: 530,
|
104
|
|
- menubar: false,
|
105
|
|
- resize: false,
|
106
|
|
- plugins: [
|
107
|
|
- 'advlist autolink lists link image charmap print preview anchor textcolor',
|
108
|
|
- 'searchreplace visualblocks code fullscreen',
|
109
|
|
- 'insertdatetime media table contextmenu paste code help'
|
110
|
|
- ],
|
111
|
|
- toolbar: 'insert | formatselect | bold italic underline strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | table | code ',
|
112
|
|
- content_css: [
|
113
|
|
- '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
114
|
|
- '//www.tinymce.com/css/codepen.min.css'
|
115
|
|
- ],
|
116
|
|
- setup: function ($editor) {
|
117
|
|
- //////////////////////////////////////////////
|
118
|
|
- // add custom btn to handle image by selecting them with system explorer
|
119
|
|
- $editor.addButton('customInsertImage', {
|
120
|
|
- icon: 'mce-ico mce-i-image',
|
121
|
|
- title: 'Image',
|
122
|
|
- onclick: function () {
|
123
|
|
- var hiddenTinyMceInput = $('#hidden_tinymce_fileinput')
|
124
|
|
-
|
125
|
|
- if (hiddenTinyMceInput.length > 0) hiddenTinyMceInput.remove()
|
126
|
|
-
|
127
|
|
- fileTag = document.createElement('input')
|
128
|
|
- fileTag.id = 'hidden_tinymce_fileinput'
|
129
|
|
- fileTag.type = 'file'
|
130
|
|
- $('body').append(fileTag)
|
131
|
|
-
|
132
|
|
- hiddenTinyMceInput.on('change', function () {
|
133
|
|
- base64EncodeAndTinyMceInsert($(this)[0].files)
|
134
|
|
- })
|
135
|
|
-
|
136
|
|
- hiddenTinyMceInput.click()
|
137
|
|
- }
|
|
48
|
+ // HACK: The tiny mce source code modal contain a textarea, but we
|
|
49
|
+ // can't edit it (like it's readonly). The following solution
|
|
50
|
+ // solve the bug: https://stackoverflow.com/questions/36952148/tinymce-code-editor-is-readonly-in-jtable-grid
|
|
51
|
+ $(document).on('focusin', function(e) {
|
|
52
|
+ if ($(e.target).closest(".mce-window").length) {
|
|
53
|
+ e.stopImmediatePropagation();
|
|
54
|
+ }
|
|
55
|
+ });
|
|
56
|
+
|
|
57
|
+ tinymce.init({
|
|
58
|
+ selector: selector,
|
|
59
|
+ menubar: false,
|
|
60
|
+ resize: false,
|
|
61
|
+ skin: "lightgray",
|
|
62
|
+ plugins:'advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table contextmenu paste code help',
|
|
63
|
+ toolbar: 'insert | formatselect | bold italic underline strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | table | code ',
|
|
64
|
+ content_style: "div {height: 100%;}",
|
|
65
|
+ setup: function ($editor) {
|
|
66
|
+ $editor.on('change', function(e) {
|
|
67
|
+ handleOnChange({target: {value: $editor.getContent()}}) // target.value to emulate a js event so the react handler can expect one
|
|
68
|
+ })
|
|
69
|
+
|
|
70
|
+ //////////////////////////////////////////////
|
|
71
|
+ // add custom btn to handle image by selecting them with system explorer
|
|
72
|
+ $editor.addButton('customInsertImage', {
|
|
73
|
+ icon: 'mce-ico mce-i-image',
|
|
74
|
+ title: 'Image',
|
|
75
|
+ onclick: function () {
|
|
76
|
+ if ($('#hidden_tinymce_fileinput').length > 0) $('#hidden_tinymce_fileinput').remove()
|
|
77
|
+
|
|
78
|
+ fileTag = document.createElement('input')
|
|
79
|
+ fileTag.id = 'hidden_tinymce_fileinput'
|
|
80
|
+ fileTag.type = 'file'
|
|
81
|
+ $('body').append(fileTag)
|
|
82
|
+
|
|
83
|
+ $('#hidden_tinymce_fileinput').on('change', function () {
|
|
84
|
+ base64EncodeAndTinyMceInsert($(this)[0].files)
|
138
|
85
|
})
|
139
|
86
|
|
140
|
|
- //////////////////////////////////////////////
|
141
|
|
- // Handle drag & drop image into TinyMce by encoding them in base64 (to avoid uploading them somewhere and keep saving comment in string format)
|
142
|
|
- $editor
|
143
|
|
- .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
|
144
|
|
- e.preventDefault()
|
145
|
|
- e.stopPropagation()
|
146
|
|
- })
|
147
|
|
- .on('drop', function(e) {
|
148
|
|
- base64EncodeAndTinyMceInsert(e.dataTransfer.files)
|
149
|
|
- })
|
|
87
|
+ $('#hidden_tinymce_fileinput').click()
|
150
|
88
|
}
|
151
|
|
- });
|
|
89
|
+ })
|
|
90
|
+
|
|
91
|
+ //////////////////////////////////////////////
|
|
92
|
+ // Handle drag & drop image into TinyMce by encoding them in base64 (to avoid uploading them somewhere and keep saving comment in string format)
|
|
93
|
+ $editor
|
|
94
|
+ .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
|
|
95
|
+ e.preventDefault()
|
|
96
|
+ e.stopPropagation()
|
|
97
|
+ })
|
|
98
|
+ .on('drop', function(e) {
|
|
99
|
+ base64EncodeAndTinyMceInsert(e.dataTransfer.files)
|
|
100
|
+ })
|
152
|
101
|
}
|
153
|
|
- document.getElementsByTagName("body")[0].appendChild(jsScript);
|
154
|
|
- }
|
155
|
|
- </script>
|
|
102
|
+ })
|
|
103
|
+ }
|
|
104
|
+ })()
|
|
105
|
+</script>
|
156
|
106
|
|
|
107
|
+<script src='./thread.app.dev.js'></script>
|
157
|
108
|
</body>
|
158
|
109
|
</html>
|