I tried to copy some text in another page and paste it into my codepress editor. The text happened to be in an <h2> tag. This caused the getCode() to truncate the text in the editor to everything just before the <h2>. I was using Firefox 2.0.0.4.
It seems that when I pasted the text FF preserved the <h2> tags surrounding the text and inserted those into the editor too. For some reason this broke up the <pre> tag into 2 separate <pre> tags. 1 surrounding the text before the insert and another surrounding everything else. So when getCode() was called it just got the innerHTML of the first <pre> tag and nothing else.
This patch fixes the problem on FF. I don't think it causes any others and I haven't tested to see if the same problem exists in IE or not.
I tried to copy some text in another page and paste it into my codepress editor. The text happened to be in an <h2> tag. This caused the getCode() to truncate the text in the editor to everything just before the <h2>. I was using Firefox 2.0.0.4.
It seems that when I pasted the text FF preserved the <h2> tags surrounding the text and inserted those into the editor too. For some reason this broke up the <pre> tag into 2 separate <pre> tags. 1 surrounding the text before the insert and another surrounding everything else. So when getCode() was called it just got the innerHTML of the first <pre> tag and nothing else.
This patch fixes the problem on FF. I don't think it causes any others and I haven't tested to see if the same problem exists in IE or not.
--- engines/gecko.js.orig 2008-06-04 18:24:58.000000000 -0400
+++ engines/gecko.js 2008-06-04 18:35:48.000000000 -0400
@@ -233,7 +233,14 @@
getCode : function() {
if(!document.getElementsByTagName('pre')[0] || editor.innerHTML == '')
editor = CodePress.getEditor();
- var code = editor.innerHTML;
+
+ var code;
+ if(editor.tagName == 'PRE')
+ code = editor.parentNode.innerHTML;
+ else
+ code = editor.innerHTML;
+ code = code.replace(/<pre>/g, '');
+ code = code.replace(/<\/pre>/g, '');
code = code.replace(/<br>/g,'\n');
code = code.replace(/\u2009/g,'');
code = code.replace(/<.*?>/g,'');