+++ /dev/null
-/**\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
- schema = editor.schema;\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 : 'justify'}},\r
-\r
- // Change the basic formatting elements to use deprecated element types
- bold : [\r
- {inline : 'b', remove : 'all'},\r
- {inline : 'strong', remove : 'all'},\r
- {inline : 'span', styles : {fontWeight : 'bold'}}\r
- ],\r
- italic : [\r
- {inline : 'i', remove : 'all'},\r
- {inline : 'em', remove : 'all'},\r
- {inline : 'span', styles : {fontStyle : 'italic'}}\r
- ],\r
- underline : [\r
- {inline : 'u', remove : 'all'},\r
- {inline : 'span', styles : {textDecoration : 'underline'}, exact : true}\r
- ],\r
- strikethrough : [\r
- {inline : 'strike', remove : 'all'},\r
- {inline : 'span', styles : {textDecoration: 'line-through'}, exact : true}\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', attributes : {color : '%value'}},\r
- hilitecolor : {inline : 'font', styles : {backgroundColor : '%value'}}\r
- });\r
-\r
- // Check that deprecated elements are allowed if not add them\r
- tinymce.each('b,i,u,strike'.split(','), function(name) {\r
- schema.addValidElements(name + '[*]');\r
- });\r
-\r
- // Add font element if it's missing\r
- if (!schema.getElementRule("font"))\r
- schema.addValidElements("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 = schema.getElementRule(name), found;\r
-\r
- if (rule) {\r
- if (!rule.attributes.align) {\r
- rule.attributes.align = {};\r
- rule.attributesOrder.push('align');\r
- }\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);\r