comparison 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
comparison
equal deleted inserted replaced
441:33d0c55e57a9 442:6c182ceb7147
24 tinymce.create('tinymce.plugins.LegacyOutput', { 24 tinymce.create('tinymce.plugins.LegacyOutput', {
25 init : function(editor) { 25 init : function(editor) {
26 editor.onInit.add(function() { 26 editor.onInit.add(function() {
27 var alignElements = 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', 27 var alignElements = 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img',
28 fontSizes = tinymce.explode(editor.settings.font_size_style_values), 28 fontSizes = tinymce.explode(editor.settings.font_size_style_values),
29 serializer = editor.serializer; 29 schema = editor.schema;
30 30
31 // Override some internal formats to produce legacy elements and attributes 31 // Override some internal formats to produce legacy elements and attributes
32 editor.formatter.register({ 32 editor.formatter.register({
33 // Change alignment formats to use the deprecated align attribute 33 // Change alignment formats to use the deprecated align attribute
34 alignleft : {selector : alignElements, attributes : {align : 'left'}}, 34 alignleft : {selector : alignElements, attributes : {align : 'left'}},
35 aligncenter : {selector : alignElements, attributes : {align : 'center'}}, 35 aligncenter : {selector : alignElements, attributes : {align : 'center'}},
36 alignright : {selector : alignElements, attributes : {align : 'right'}}, 36 alignright : {selector : alignElements, attributes : {align : 'right'}},
37 alignfull : {selector : alignElements, attributes : {align : 'full'}}, 37 alignfull : {selector : alignElements, attributes : {align : 'justify'}},
38 38
39 // Change the basic formatting elements to use deprecated element types 39 // Change the basic formatting elements to use deprecated element types
40 bold : {inline : 'b'}, 40 bold : [
41 italic : {inline : 'i'}, 41 {inline : 'b', remove : 'all'},
42 underline : {inline : 'u'}, 42 {inline : 'strong', remove : 'all'},
43 strikethrough : {inline : 'strike'}, 43 {inline : 'span', styles : {fontWeight : 'bold'}}
44 ],
45 italic : [
46 {inline : 'i', remove : 'all'},
47 {inline : 'em', remove : 'all'},
48 {inline : 'span', styles : {fontStyle : 'italic'}}
49 ],
50 underline : [
51 {inline : 'u', remove : 'all'},
52 {inline : 'span', styles : {textDecoration : 'underline'}, exact : true}
53 ],
54 strikethrough : [
55 {inline : 'strike', remove : 'all'},
56 {inline : 'span', styles : {textDecoration: 'line-through'}, exact : true}
57 ],
44 58
45 // Change font size and font family to use the deprecated font element 59 // Change font size and font family to use the deprecated font element
46 fontname : {inline : 'font', attributes : {face : '%value'}}, 60 fontname : {inline : 'font', attributes : {face : '%value'}},
47 fontsize : { 61 fontsize : {
48 inline : 'font', 62 inline : 'font',
56 // Setup font elements for colors as well 70 // Setup font elements for colors as well
57 forecolor : {inline : 'font', styles : {color : '%value'}}, 71 forecolor : {inline : 'font', styles : {color : '%value'}},
58 hilitecolor : {inline : 'font', styles : {backgroundColor : '%value'}} 72 hilitecolor : {inline : 'font', styles : {backgroundColor : '%value'}}
59 }); 73 });
60 74
61 // Force parsing of the serializer rules
62 serializer._setup();
63
64 // Check that deprecated elements are allowed if not add them 75 // Check that deprecated elements are allowed if not add them
65 tinymce.each('b,i,u,strike'.split(','), function(name) { 76 tinymce.each('b,i,u,strike'.split(','), function(name) {
66 var rule = serializer.rules[name]; 77 schema.addValidElements(name + '[*]');
67
68 if (!rule)
69 serializer.addRules(name);
70 }); 78 });
71 79
72 // Add font element if it's missing 80 // Add font element if it's missing
73 if (!serializer.rules["font"]) 81 if (!schema.getElementRule("font"))
74 serializer.addRules("font[face|size|color|style]"); 82 schema.addValidElements("font[face|size|color|style]");
75 83
76 // Add the missing and depreacted align attribute for the serialization engine 84 // Add the missing and depreacted align attribute for the serialization engine
77 tinymce.each(alignElements.split(','), function(name) { 85 tinymce.each(alignElements.split(','), function(name) {
78 var rule = serializer.rules[name], found; 86 var rule = schema.getElementRule(name), found;
79 87
80 if (rule) { 88 if (rule) {
81 tinymce.each(rule.attribs, function(name, attr) { 89 if (!rule.attributes.align) {
82 if (attr.name == 'align') { 90 rule.attributes.align = {};
83 found = true; 91 rule.attributesOrder.push('align');
84 return false; 92 }
85 }
86 });
87
88 if (!found)
89 rule.attribs.push({name : 'align'});
90 } 93 }
91 }); 94 });
92 95
93 // Listen for the onNodeChange event so that we can do special logic for the font size and font name drop boxes 96 // Listen for the onNodeChange event so that we can do special logic for the font size and font name drop boxes
94 editor.onNodeChange.add(function(editor, control_manager) { 97 editor.onNodeChange.add(function(editor, control_manager) {