~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/common/codepress/engines/gecko.js

  • Committer: wagrant
  • Date: 2008-12-22 02:41:06 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1061
Make CodePress' Gecko engine merge any <pre>s in the editor widget if there is
more than one. They sometimes appear when pasting in Firefox's designmode.

Fixes [ 2110334 ] Editor doesn't save the whole file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
                        if(body.innerHTML=="<br>") body.innerHTML = "<pre> </pre>";
118
118
                        else body.innerHTML = "<pre>"+body.innerHTML+"</pre>";
119
119
                }
120
 
                return document.getElementsByTagName('pre')[0];
 
120
                /* For some reason we'll sometimes get multiple <pre>s when
 
121
                 * something is pasted from within Firefox (particularly when
 
122
                 * there are blank lines). Here we check if multiple <p>s exist
 
123
                 * and merge any that do. */
 
124
                var pres = document.getElementsByTagName('pre');
 
125
                if(pres.length > 1) {
 
126
                        tomerge = pres.length - 1; // As we kill them, this will change, so we store it here.
 
127
                        for(i = 1; i <= tomerge; i++) {
 
128
                                pres[0].innerHTML += "<br />" + pres[1].innerHTML;
 
129
                                pres[1].parentNode.removeChild(pres[1]);
 
130
                        }
 
131
                }
 
132
                return pres[0];
121
133
        },
122
134
        
123
135
        // syntax highlighting parser