index.html 6.5KB

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