Changeset 170
- Timestamp:
- 05/18/05 18:16:29 (8 years ago)
- Files:
-
- 1 modified
-
trunk/htmlarea.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/htmlarea.js
r169 r170 4504 4504 } 4505 4505 4506 HTMLArea.getHTMLWrapper = function(root, outputRoot, editor ) {4506 HTMLArea.getHTMLWrapper = function(root, outputRoot, editor, indent) { 4507 4507 var html = ""; 4508 if(!indent) indent = ''; 4509 4508 4510 switch (root.nodeType) { 4509 4511 case 10:// Node.DOCUMENT_TYPE_NODE … … 4524 4526 // Mozilla seems to convert CDATA into a comment when going into wysiwyg mode, 4525 4527 // don't know about IE 4526 html += '<![CDATA[' + root.data + ']]>';4528 html += (HTMLArea.is_ie ? ('\n' + indent) : '') + '<![CDATA[' + root.data + ']]>' ; 4527 4529 break; 4528 4530 … … 4534 4536 // PI's don't seem to survive going into the wysiwyg mode, (at least in moz) 4535 4537 // so this is purely academic 4536 html += '<?' + root.target + ' ' + root.data + ' ?>';4538 html += (HTMLArea.is_ie ? ('\n' + indent) : '') + '<?' + root.target + ' ' + root.data + ' ?>'; 4537 4539 break; 4538 4540 … … 4551 4553 if (HTMLArea.is_ie && root_tag == "head") { 4552 4554 if (outputRoot) 4553 html += "<head>";4555 html += (HTMLArea.is_ie ? ('\n' + indent) : '') + "<head>"; 4554 4556 // lowercasize 4555 4557 var save_multiline = RegExp.multiline; … … 4559 4561 }); 4560 4562 RegExp.multiline = save_multiline; 4561 html += txt ;4563 html += txt + '\n'; 4562 4564 if (outputRoot) 4563 html += "</head>";4565 html += (HTMLArea.is_ie ? ('\n' + indent) : '') + "</head>"; 4564 4566 break; 4565 4567 } else if (outputRoot) { 4566 4568 closed = (!(root.hasChildNodes() || HTMLArea.needsClosingTag(root))); 4567 html ="<" + root.tagName.toLowerCase();4569 html += (HTMLArea.is_ie && HTMLArea.isBlockElement(root) ? ('\n' + indent) : '') + "<" + root.tagName.toLowerCase(); 4568 4570 var attrs = root.attributes; 4569 4571 for (i = 0; i < attrs.length; ++i) { … … 4619 4621 } 4620 4622 } 4623 var containsBlock = false; 4621 4624 for (i = root.firstChild; i; i = i.nextSibling) { 4622 html += HTMLArea.getHTMLWrapper(i, true, editor); 4625 if(!containsBlock && i.nodeType == 1 && HTMLArea.isBlockElement(i)) containsBlock = true; 4626 html += HTMLArea.getHTMLWrapper(i, true, editor, indent + ' '); 4623 4627 } 4624 4628 if (outputRoot && !closed) { 4625 html += "</" + root.tagName.toLowerCase() + ">";4629 html += (HTMLArea.is_ie && HTMLArea.isBlockElement(root) && containsBlock ? ('\n' + indent) : '') + "</" + root.tagName.toLowerCase() + ">"; 4626 4630 } 4627 4631 break; 4628 4632 } 4629 4633 case 3: // Node.TEXT_NODE 4630 4631 // If a text node is alone in an element and all spaces, replace it with an non breaking one4632 // This partially undoes the damage done by moz, which translates ' 's into spaces in the data element4633 4634 4634 html = /^script|style$/i.test(root.parentNode.tagName) ? root.data : HTMLArea.htmlEncode(root.data); 4635 4635 break; … … 4637 4637 case 8: // Node.COMMENT_NODE 4638 4638 html = "<!--" + root.data + "-->"; 4639 break; // skip comments, for now.4639 break; 4640 4640 } 4641 4641 return html;
