index.html 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8' />
  5. <meta name="viewport" content="width=device-width, user-scalable=no">
  6. <title>Tracim</title>
  7. <link rel='shortcut icon' href='favicon.ico'>
  8. <link rel="stylesheet" type="text/css" href="/font/font-awesome-4.7.0/css/font-awesome.css">
  9. <link href="https://fonts.googleapis.com/css?family=Quicksand:300,400,500,700" rel="stylesheet">
  10. <!--
  11. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
  12. -->
  13. <link rel="stylesheet" type="text/css" href="/asset/hamburger/hamburgers.min.css">
  14. <link rel="stylesheet" type="text/css" href="/dev/bootstrap-4.0.0-beta.css">
  15. </head>
  16. <body>
  17. <div id='content'></div>
  18. <script src='/tracim.vendor.bundle.js'></script>
  19. <script src='/tracim.app.entry.js'></script>
  20. <script src='/app/html-documents.app.js'></script>
  21. <!-- <script src='/app/thread.app.js'></script>
  22. <script src='/app/file.app.js'></script> -->
  23. <script src="/dev/jquery-3.2.1.js"></script>
  24. <script src="/dev/popper-1.12.3.js"></script>
  25. <script src="/dev/bootstrap-4.0.0-beta.2.js"></script>
  26. <script type="text/javascript" src="/asset/tinymce/js/tinymce/jquery.tinymce.min.js"></script>
  27. <script type="text/javascript" src="/asset/tinymce/js/tinymce/tinymce.min.js"></script>
  28. <script type='text/javascript'>
  29. let prevSelectedApp = {name: ''} // default value
  30. getSelectedApp = name => {
  31. switch (name) {
  32. case 'html-documents':
  33. return appHtmlDocument
  34. case 'thread':
  35. return appThread
  36. case 'file':
  37. return appFile
  38. }
  39. }
  40. GLOBAL_renderApp = app => {
  41. console.log('GLOBAL_renderApp', app)
  42. const selectedApp = getSelectedApp(app.config.slug)
  43. if (selectedApp.isRendered) {
  44. GLOBAL_dispatchEvent({type: `${app.config.slug}_showApp`, data: app})
  45. } else {
  46. selectedApp.renderApp(app)
  47. selectedApp.isRendered = true
  48. prevSelectedApp.isRendered = false
  49. prevSelectedApp = selectedApp
  50. }
  51. }
  52. GLOBAL_renderCreateContentApp = app => {
  53. console.log('GLOBAL_renderCreateContentApp', app)
  54. getSelectedApp(app.config.slug).renderPopupCreation(app)
  55. }
  56. GLOBAL_dispatchEvent = ({ type, data }) => {
  57. console.log('GLOBAL_dispatchEvent', type, data)
  58. const event = new CustomEvent('appCustomEvent', { detail: { type, data } })
  59. document.dispatchEvent(event)
  60. }
  61. GLOBAL_eventReducer = ({ detail: { type, data } }) => {
  62. console.log('GLOBAL_eventReducer', type, data)
  63. switch (type) {
  64. case 'hide_popupCreateContent':
  65. getSelectedApp(data.name).unmountApp('popupCreateContentContainer')
  66. break
  67. case 'unmount_app':
  68. prevSelectedApp.unmountApp('appContainer')
  69. prevSelectedApp.unmountApp('popupCreateContentContainer')
  70. prevSelectedApp.isRendered = false
  71. break
  72. }
  73. }
  74. document.addEventListener('appCustomEvent', GLOBAL_eventReducer)
  75. </script>
  76. <script type='text/javascript'>
  77. (function () {
  78. wysiwyg = function (selector, handleOnChange) {
  79. function base64EncodeAndTinyMceInsert (files) {
  80. for (var i = 0; i < files.length; i++) {
  81. if (files[i].size > 1000000)
  82. files[i].allowed = confirm(files[i].name + " fait plus de 1mo et peut prendre du temps à insérer, voulez-vous continuer ?")
  83. }
  84. for (var i = 0; i < files.length; i++) {
  85. if (files[i].allowed !== false && files[i].type.match('image.*')) {
  86. var img = document.createElement('img')
  87. var fr = new FileReader()
  88. fr.readAsDataURL(files[i])
  89. fr.onloadend = function (e) {
  90. img.src = e.target.result
  91. tinymce.activeEditor.execCommand('mceInsertContent', false, img.outerHTML)
  92. }
  93. }
  94. }
  95. }
  96. // HACK: The tiny mce source code modal contain a textarea, but we
  97. // can't edit it (like it's readonly). The following solution
  98. // solve the bug: https://stackoverflow.com/questions/36952148/tinymce-code-editor-is-readonly-in-jtable-grid
  99. $(document).on('focusin', function(e) {
  100. if ($(e.target).closest(".mce-window").length) {
  101. e.stopImmediatePropagation();
  102. }
  103. });
  104. tinymce.init({
  105. selector: selector,
  106. menubar: false,
  107. resize: false,
  108. skin: "lightgray",
  109. plugins:'advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table contextmenu paste code help',
  110. toolbar: 'insert | formatselect | bold italic underline strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | table | code ',
  111. content_style: "div {height: 100%;}",
  112. setup: function ($editor) {
  113. $editor.on('change', function(e) {
  114. handleOnChange({target: {value: $editor.getContent()}}) // target.value to emulate a js event so the react handler can expect one
  115. })
  116. //////////////////////////////////////////////
  117. // add custom btn to handle image by selecting them with system explorer
  118. $editor.addButton('customInsertImage', {
  119. icon: 'mce-ico mce-i-image',
  120. title: 'Image',
  121. onclick: function () {
  122. if ($('#hidden_tinymce_fileinput').length > 0) $('#hidden_tinymce_fileinput').remove()
  123. fileTag = document.createElement('input')
  124. fileTag.id = 'hidden_tinymce_fileinput'
  125. fileTag.type = 'file'
  126. $('body').append(fileTag)
  127. $('#hidden_tinymce_fileinput').on('change', function () {
  128. base64EncodeAndTinyMceInsert($(this)[0].files)
  129. })
  130. $('#hidden_tinymce_fileinput').click()
  131. }
  132. })
  133. //////////////////////////////////////////////
  134. // Handle drag & drop image into TinyMce by encoding them in base64 (to avoid uploading them somewhere and keep saving comment in string format)
  135. $editor
  136. .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
  137. e.preventDefault()
  138. e.stopPropagation()
  139. })
  140. .on('drop', function(e) {
  141. base64EncodeAndTinyMceInsert(e.dataTransfer.files)
  142. })
  143. }
  144. })
  145. }
  146. })()
  147. </script>
  148. </body>
  149. </html>