includes/clientside/tinymce/plugins/xhtmlxtras/js/element_common.js
changeset 778 57ce13805b6f
parent 588 20484deb89cd
child 1193 e3b94bd055dc
--- a/includes/clientside/tinymce/plugins/xhtmlxtras/js/element_common.js	Sun Dec 21 15:35:46 2008 -0500
+++ b/includes/clientside/tinymce/plugins/xhtmlxtras/js/element_common.js	Sun Dec 21 16:28:00 2008 -0500
@@ -160,19 +160,19 @@
 			if (tinymce.isIE && element_name.indexOf('html:') == 0)
 				element_name = element_name.substring(5).toLowerCase();
 
-			h = '<' + tagName + ' id="#sxe_temp_' + element_name + '#">' + s + '</' + tagName + '>';
-
-			tinyMCEPopup.execCommand('mceInsertContent', false, h);
-
-			var elementArray = tinymce.grep(SXE.inst.dom.select(element_name), function(n) {return n.id == '#sxe_temp_' + element_name + '#';});
+			insertInlineElement(element_name);
+			var elementArray = tinymce.grep(SXE.inst.dom.select(element_name));
 			for (var i=0; i<elementArray.length; i++) {
 				var elm = elementArray[i];
 
-				elm.id = '';
-				elm.setAttribute('id', '');
-				elm.removeAttribute('id');
+				if (SXE.inst.dom.getAttrib(elm, '_mce_new')) {
+					elm.id = '';
+					elm.setAttribute('id', '');
+					elm.removeAttribute('id');
+					elm.removeAttribute('_mce_new');
 
-				setAllCommonAttribs(elm);
+					setAllCommonAttribs(elm);
+				}
 			}
 		}
 	} else {
@@ -218,4 +218,14 @@
 SXE.addClass = function(elm,cl) {
 	if(!SXE.containsClass(elm,cl)) elm.className ? elm.className += " " + cl : elm.className = cl;
 	return true;
-}
\ No newline at end of file
+}
+
+function insertInlineElement(en) {
+	var ed = tinyMCEPopup.editor, dom = ed.dom;
+
+	ed.getDoc().execCommand('FontName', false, 'mceinline');
+	tinymce.each(dom.select(tinymce.isWebKit ? 'span' : 'font'), function(n) {
+		if (n.style.fontFamily == 'mceinline' || n.face == 'mceinline')
+			dom.replace(dom.create(en, {_mce_new : 1}), n, 1);
+	});
+}