mise a jour pour mtweb.0.9.0
[mw_pages] / app / out / default / tiny_mce / plugins / legacyoutput / editor_plugin_src.js
diff --git a/app/out/default/tiny_mce/plugins/legacyoutput/editor_plugin_src.js b/app/out/default/tiny_mce/plugins/legacyoutput/editor_plugin_src.js
new file mode 100644 (file)
index 0000000..e852da1
--- /dev/null
@@ -0,0 +1,136 @@
+/**\r
+ * editor_plugin_src.js\r
+ *\r
+ * Copyright 2009, Moxiecode Systems AB\r
+ * Released under LGPL License.\r
+ *\r
+ * License: http://tinymce.moxiecode.com/license\r
+ * Contributing: http://tinymce.moxiecode.com/contributing\r
+ *\r
+ * This plugin will force TinyMCE to produce deprecated legacy output such as font elements, u elements, align\r
+ * attributes and so forth. There are a few cases where these old items might be needed for example in email applications or with Flash\r
+ *\r
+ * However you should NOT use this plugin if you are building some system that produces web contents such as a CMS. All these elements are\r
+ * not apart of the newer specifications for HTML and XHTML.\r
+ */\r
+\r
+(function(tinymce) {\r
+       // Override inline_styles setting to force TinyMCE to produce deprecated contents\r
+       tinymce.onAddEditor.addToTop(function(tinymce, editor) {\r
+               editor.settings.inline_styles = false;\r
+       });\r
+\r
+       // Create the legacy ouput plugin\r
+       tinymce.create('tinymce.plugins.LegacyOutput', {\r
+               init : function(editor) {\r
+                       editor.onInit.add(function() {\r
+                               var alignElements = 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img',\r
+                                       fontSizes = tinymce.explode(editor.settings.font_size_style_values),\r
+                                       serializer = editor.serializer;\r
+\r
+                               // Override some internal formats to produce legacy elements and attributes\r
+                               editor.formatter.register({\r
+                                       // Change alignment formats to use the deprecated align attribute\r
+                                       alignleft : {selector : alignElements, attributes : {align : 'left'}},\r
+                                       aligncenter : {selector : alignElements, attributes : {align : 'center'}},\r
+                                       alignright : {selector : alignElements, attributes : {align : 'right'}},\r
+                                       alignfull : {selector : alignElements, attributes : {align : 'full'}},\r
+\r
+                                       // Change the basic formatting elements to use deprecated element types\r
+                                       bold : {inline : 'b'},\r
+                                       italic : {inline : 'i'},\r
+                                       underline : {inline : 'u'},\r
+                                       strikethrough : {inline : 'strike'},\r
+\r
+                                       // Change font size and font family to use the deprecated font element\r
+                                       fontname : {inline : 'font', attributes : {face : '%value'}},\r
+                                       fontsize : {\r
+                                               inline : 'font',\r
+                                               attributes : {\r
+                                                       size : function(vars) {\r
+                                                               return tinymce.inArray(fontSizes, vars.value) + 1;\r
+                                                       }\r
+                                               }\r
+                                       },\r
+\r
+                                       // Setup font elements for colors as well\r
+                                       forecolor : {inline : 'font', styles : {color : '%value'}},\r
+                                       hilitecolor : {inline : 'font', styles : {backgroundColor : '%value'}}\r
+                               });\r
+\r
+                               // Force parsing of the serializer rules\r
+                               serializer._setup();\r
+\r
+                               // Check that deprecated elements are allowed if not add them\r
+                               tinymce.each('b,i,u,strike'.split(','), function(name) {\r
+                                       var rule = serializer.rules[name];\r
+\r
+                                       if (!rule)\r
+                                               serializer.addRules(name);\r
+                               });\r
+\r
+                               // Add font element if it's missing\r
+                               if (!serializer.rules["font"])\r
+                                       serializer.addRules("font[face|size|color|style]");\r
+\r
+                               // Add the missing and depreacted align attribute for the serialization engine\r
+                               tinymce.each(alignElements.split(','), function(name) {\r
+                                       var rule = serializer.rules[name], found;\r
+\r
+                                       if (rule) {\r
+                                               tinymce.each(rule.attribs, function(name, attr) {\r
+                                                       if (attr.name == 'align') {\r
+                                                               found = true;\r
+                                                               return false;\r
+                                                       }\r
+                                               });\r
+\r
+                                               if (!found)\r
+                                                       rule.attribs.push({name : 'align'});\r
+                                       }\r
+                               });\r
+\r
+                               // Listen for the onNodeChange event so that we can do special logic for the font size and font name drop boxes\r
+                               editor.onNodeChange.add(function(editor, control_manager) {\r
+                                       var control, fontElm, fontName, fontSize;\r
+\r
+                                       // Find font element get it's name and size\r
+                                       fontElm = editor.dom.getParent(editor.selection.getNode(), 'font');\r
+                                       if (fontElm) {\r
+                                               fontName = fontElm.face;\r
+                                               fontSize = fontElm.size;\r
+                                       }\r
+\r
+                                       // Select/unselect the font name in droplist\r
+                                       if (control = control_manager.get('fontselect')) {\r
+                                               control.select(function(value) {\r
+                                                       return value == fontName;\r
+                                               });\r
+                                       }\r
+\r
+                                       // Select/unselect the font size in droplist\r
+                                       if (control = control_manager.get('fontsizeselect')) {\r
+                                               control.select(function(value) {\r
+                                                       var index = tinymce.inArray(fontSizes, value.fontSize);\r
+\r
+                                                       return index + 1 == fontSize;\r
+                                               });\r
+                                       }\r
+                               });\r
+                       });\r
+               },\r
+\r
+               getInfo : function() {\r
+                       return {\r
+                               longname : 'LegacyOutput',\r
+                               author : 'Moxiecode Systems AB',\r
+                               authorurl : 'http://tinymce.moxiecode.com',\r
+                               infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/legacyoutput',\r
+                               version : tinymce.majorVersion + "." + tinymce.minorVersion\r
+                       };\r
+               }\r
+       });\r
+\r
+       // Register plugin\r
+       tinymce.PluginManager.add('legacyoutput', tinymce.plugins.LegacyOutput);\r
+})(tinymce);
\ No newline at end of file