Properly handling pasted lists
authorAlexander Ebert <ebert@woltlab.com>
Fri, 28 Jun 2013 11:24:01 +0000 (13:24 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 28 Jun 2013 11:24:01 +0000 (13:24 +0200)
wcfsetup/install/files/js/3rdParty/ckeditor/plugins/wbbcode/plugin.js

index 56febbf5e23b586d3ea9c44364c380eb9660ae86..d4612dfd475b6286977c8df3577585f4aeacc8e2 100644 (file)
                        if (ev.data.type == 'html') {
                                var $value = ev.data.dataValue;
                                
+                               console.debug("before:\n" + $value);
+                               
                                // Convert <br> to line breaks.
                                $value = $value.replace(/<br><\/p>/gi,"\n\n");
                                $value = $value.replace(/<br>/gi, "\n");
                                $value = $value.replace(/<\/p>/gi,"\n\n");
                                $value = $value.replace(/&nbsp;/gi," ");
+                               
+                               // convert div-separated content into new lines
                                $value = $value.replace(/<div([^>])>/gi, '');
                                $value = $value.replace(/<\/div>/gi, "\n");
                                
+                               // convert lists into new lines
+                               $value = $value.replace(/<\/li>/gi, "\n");
+                               
                                // remove html tags
                                $value = $value.replace(/<[^>]+>/g, '');
                                
@@ -32,6 +39,8 @@
                                
                                ev.data.dataValue = $value;
                                
+                               console.debug("after:\n" + $value);
+                               
                                $pasted = true;
                        }
                }, null, null, 9);