diff static/js/tiny_mce/plugins/legacyoutput/editor_plugin_src.js @ 442:6c182ceb7147

Fixing #217; upgrade TinyMCE to 3.4.2 and enable the paste plugin.
author Brian Neal <bgneal@gmail.com>
date Thu, 26 May 2011 00:43:49 +0000
parents 88b2b9cb8c1f
children
line wrap: on
line diff
--- a/static/js/tiny_mce/plugins/legacyoutput/editor_plugin_src.js	Wed May 25 02:39:08 2011 +0000
+++ b/static/js/tiny_mce/plugins/legacyoutput/editor_plugin_src.js	Thu May 26 00:43:49 2011 +0000
@@ -26,7 +26,7 @@
 			editor.onInit.add(function() {
 				var alignElements = 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img',
 					fontSizes = tinymce.explode(editor.settings.font_size_style_values),
-					serializer = editor.serializer;
+					schema = editor.schema;
 
 				// Override some internal formats to produce legacy elements and attributes
 				editor.formatter.register({
@@ -34,13 +34,27 @@
 					alignleft : {selector : alignElements, attributes : {align : 'left'}},
 					aligncenter : {selector : alignElements, attributes : {align : 'center'}},
 					alignright : {selector : alignElements, attributes : {align : 'right'}},
-					alignfull : {selector : alignElements, attributes : {align : 'full'}},
+					alignfull : {selector : alignElements, attributes : {align : 'justify'}},
 
-					// Change the basic formatting elements to use deprecated element types
-					bold : {inline : 'b'},
-					italic : {inline : 'i'},
-					underline : {inline : 'u'},
-					strikethrough : {inline : 'strike'},
+					// Change the basic formatting elements to use deprecated element types
+					bold : [
+						{inline : 'b', remove : 'all'},
+						{inline : 'strong', remove : 'all'},
+						{inline : 'span', styles : {fontWeight : 'bold'}}
+					],
+					italic : [
+						{inline : 'i', remove : 'all'},
+						{inline : 'em', remove : 'all'},
+						{inline : 'span', styles : {fontStyle : 'italic'}}
+					],
+					underline : [
+						{inline : 'u', remove : 'all'},
+						{inline : 'span', styles : {textDecoration : 'underline'}, exact : true}
+					],
+					strikethrough : [
+						{inline : 'strike', remove : 'all'},
+						{inline : 'span', styles : {textDecoration: 'line-through'}, exact : true}
+					],
 
 					// Change font size and font family to use the deprecated font element
 					fontname : {inline : 'font', attributes : {face : '%value'}},
@@ -58,35 +72,24 @@
 					hilitecolor : {inline : 'font', styles : {backgroundColor : '%value'}}
 				});
 
-				// Force parsing of the serializer rules
-				serializer._setup();
-
 				// Check that deprecated elements are allowed if not add them
 				tinymce.each('b,i,u,strike'.split(','), function(name) {
-					var rule = serializer.rules[name];
-
-					if (!rule)
-						serializer.addRules(name);
+					schema.addValidElements(name + '[*]');
 				});
 
 				// Add font element if it's missing
-				if (!serializer.rules["font"])
-					serializer.addRules("font[face|size|color|style]");
+				if (!schema.getElementRule("font"))
+					schema.addValidElements("font[face|size|color|style]");
 
 				// Add the missing and depreacted align attribute for the serialization engine
 				tinymce.each(alignElements.split(','), function(name) {
-					var rule = serializer.rules[name], found;
+					var rule = schema.getElementRule(name), found;
 
 					if (rule) {
-						tinymce.each(rule.attribs, function(name, attr) {
-							if (attr.name == 'align') {
-								found = true;
-								return false;
-							}
-						});
-
-						if (!found)
-							rule.attribs.push({name : 'align'});
+						if (!rule.attributes.align) {
+							rule.attributes.align = {};
+							rule.attributesOrder.push('align');
+						}
 					}
 				});
 
@@ -133,4 +136,4 @@
 
 	// Register plugin
 	tinymce.PluginManager.add('legacyoutput', tinymce.plugins.LegacyOutput);
-})(tinymce);
\ No newline at end of file
+})(tinymce);