Package: wims / 2:4.29a+dfsg1-3

cheat_tinymce.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
The package tinymce is no longer maintained in Debian

Here is a patch which cheats, by replacing most of tinymce's
features by ckeditor. To make this patch work, there must be a
symlink from /var/lib/wims/public_html/scripts/js/external/ckeditor
to /usr/share/javascript/ckeditor

Index: wims-4.27a~dfsg1/public_html/scripts/js/external/tinymce.phtml
===================================================================
--- wims-4.27a~dfsg1.orig/public_html/scripts/js/external/tinymce.phtml
+++ wims-4.27a~dfsg1/public_html/scripts/js/external/tinymce.phtml
@@ -120,10 +120,32 @@
   !endif
 
 
-  !set wims_html_header= !append line <script src="scripts/js/external/tinymce/tinymce.min.js"></script>\
+  !set wims_html_header= !append line <script src="scripts/js/external/ckeditor/ckeditor.js"></script>\
   <style>.hidden_btn{display:none}.wysiwyg_btns{text-align:right;font-size:.6em}</style>\
   <script>\
-  document.addEventListener("DOMContentLoaded", function() {\
+    var editor_style = {\
+      language: 'fr',\
+      uiColor: '#9AB8F3',\
+      toolbarGroups: [{\
+         "name": "basicstyles",\
+         "groups": ["basicstyles"]\
+        },{\
+          "name": "links",\
+          "groups": ["links"]\
+        },{\
+          "name": "paragraph",\
+          "groups": ["list", "blocks"]\
+        },{\
+          "name": "styles",\
+          "groups": ["styles"]\
+        },{\
+          "name": "about",\
+          "groups": ["about"]\
+      }],\
+      // Remove the redundant buttons from toolbar groups defined above.\
+      removeButtons: 'Underline,Subscript,Superscript,Anchor,Styles'\
+    }; \
+    document.addEventListener("DOMContentLoaded", function() {\
     /* Insert "enable/disable editor" buttons */\
     var ed_instances = document.querySelectorAll("$wims_read_parm");\
     ed_instances.forEach(function(ed) {\
@@ -133,12 +155,12 @@
         var a1 = document.createElement('a');\
         var linkText = document.createTextNode("$name_WYSIWYG_disable");\
         a1.appendChild(linkText);\
-        a1.setAttribute("onclick","javascript:tinymce.execCommand('mceRemoveEditor',true,'"+ed.id+"');this.classList.add('hidden_btn');this.nextElementSibling.classList.remove('hidden_btn');");\
+        a1.setAttribute("onclick","javascript:CKEDITOR.instances['"+ed.id+"'].destroy();this.classList.add('hidden_btn');this.nextElementSibling.classList.remove('hidden_btn');");\
         div.appendChild(a1);\
         var a2 = document.createElement('a');\
         var linkText = document.createTextNode("$name_WYSIWYG_activate");\
         a2.appendChild(linkText);\
-        a2.setAttribute("onclick","javascript:tinymce.execCommand('mceAddEditor',true,'"+ed.id+"');this.classList.add('hidden_btn');this.previousElementSibling.classList.remove('hidden_btn');");\
+        a2.setAttribute("onclick","javascript:CKEDITOR.replace('"+ed.id+"', editor_style);this.classList.add('hidden_btn');this.previousElementSibling.classList.remove('hidden_btn');");\
         a2.classList.add("hidden_btn");\
         div.appendChild(a2);\
         /* insert just after editor */\
@@ -157,31 +179,9 @@
     var find2 = find2.replace(/\./g, '\\.');\
     var find2 = find2.replace(/\?/g, '\\?');\
     var re2 = new RegExp(find2, 'g');\
-    tinymce.init({\
-      selector:'$wims_read_parm',\
-      plugins: '$iEdit_plugins',\
-      block_formats : tinymce.translate('Paragraph')+'=p;' +tinymce.translate('Heading 1')+'=h2;'+tinymce.translate('Heading 2')+'=h3;' +tinymce.translate('Heading 3')+'=h4;' +tinymce.translate('Heading 4')+'=h5;' +tinymce.translate('Heading 5')+'=h6;' +tinymce.translate('Preformatted')+'=pre;' +tinymce.translate('Blockquote')+'=blockquote;',\
-      menubar: false,\
-      branding: false,\
-      toolbar: '$iEdit_toolbar',\
-      $tiny_lang\
-      $iEdit_formats\
-      convert_urls : false,\
-      entities : '160,nbsp,162,cent,8364,euro,163,pound',\
-      content_css : 'html/themes/$wims_theme/css.css',\
-      body_class: 'main_body',\
-      content_style : ':root{--wims_bgcolor: $wims_bgcolor;--wims_link_color: $wims_link_color;--wims_vlink_color: $wims_vlink_color;--wims_hlink_color: $wims_hlink_color;--wims_ref_menucolor: $wims_ref_menucolor;--wims_ref_bgcolor: $wims_ref_bgcolor;--wims_ref_button_color: $wims_ref_button_color;--wims_ref_button_bgcolor: $wims_ref_button_bgcolor;}a, .ui-widget-content a{color:$wims_link_color}a:hover, a:focus {color:$wims_hlink_color}table.wimstable th{background-color: $wims_ref_bgcolor;color: $wims_ref_menucolor}table.wimstable th a{color: $wims_ref_menucolor}.wimstable caption a{color: $wims_ref_menucolor}.wims_emph {color:$wims_ref_bgcolor}input[type="submit"],input[type="button"],.main_body .wims_button{background-color:$wims_ref_button_bgcolor;color:$wims_ref_button_color}.main_body .wims_button_help{background-color:$wims_ref_button_help_bgcolor;color:$wims_ref_button_help_color}.property_fields{border-color:$wims_ref_bgcolor}.property_fields legend{background-color: $wims_ref_bgcolor}.property_fields legend,.property_fields legend>a{color:$wims_ref_menucolor}.wims_color1 {background-color: $wims_ref_bgcolor;color:$wims_ref_menucolor}.wims_color2 {background-color:$wims_ref_button_bgcolor;color:$wims_ref_button_color}.wims_color3 {background-color:$wims_ref_button_help_bgcolor;color:$wims_ref_button_help_color}',\
-      init_instance_callback: function(editor) {\
-        editor.on('PostProcess', function (e) {\
-          // Avant d'afficher le code source\
-          e.content = e.content.replace(re2, replace1);\
-        });\
-        editor.on('BeforeSetContent', function (e) {\
-          // Lors de l'enregistrement du code source\
-          e.content = e.content.replace(re1, replace2);\
-        });\
-        // refresh content, searching for 'imagedir'\
-        editor.setContent(editor.getContent());\
+    ed_instances.forEach(function(ed) {\
+      if(ed.id){\
+        CKEDITOR.replace( ed.id, editor_style);\
       }\
     });\
   });</script>\