Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CleanWord fix

- Don't strip carriage returns
  • Loading branch information...
commit 72960a6a6dbb2213d9f8a92bc5b9d8ad5e5fd338 1 parent eee5cf8
julmis authored
Showing with 34 additions and 7 deletions.
  1. +34 −7 lib/editor/htmlarea.php
View
41 lib/editor/htmlarea.php
@@ -933,9 +933,9 @@ function (str, l1, l2, l3) {
if (D.indexOf("class=Mso") >= 0 || D.indexOf("mso") >= 0 || D.indexOf("Mso") >= 0) {
// make one line
- D = D.replace(/\r\n/g, ' ').
- replace(/\n/g, ' ').
- replace(/\r/g, ' ').
+ D = D.replace(/\r\n/g, '\[br\]').
+ replace(/\n/g, '').
+ replace(/\r/g, '').
replace(/\&nbsp\;/g,' ');
// keep tags, strip attributes
@@ -976,6 +976,7 @@ function (str, l1, l2, l3) {
//D = D.replace(/<strong><\/strong>/gi,'').
//replace(/<i><\/i>/gi,'').
//replace(/<P[^>]*><\/P>/gi,'');
+ D = D.replace(/<h[1-6]+>\s?<\/h[1-6]+>/gi, ''); // Remove empty headings
// nuke double tags
oldlen = D.length + 1;
@@ -991,6 +992,28 @@ function (str, l1, l2, l3) {
// nuke double spaces
D = D.replace(/ */gi,' ');
+ // Split into lines and remove
+ // empty lines and add carriage returns back
+ var splitter = /\[br\]/g;
+ var emptyLine = /^\s+\s+$/g;
+ var strHTML = '';
+ var toLines = D.split(splitter);
+ for (var i = 0; i < toLines.length; i++) {
+ var line = toLines[i];
+ if (line.length < 1) {
+ continue;
+ }
+
+ if (emptyLine.test(line)) {
+ continue;
+ }
+
+ line = line.replace(/^\s+\s+$/g, '');
+ strHTML += line + '\n';
+ }
+ D = strHTML;
+ strHTML = '';
+
this.setHTML(D);
this.updateToolbar();
}
@@ -1848,9 +1871,11 @@ function getMozSelection(txtarea) {
case "copy":
case "paste":
try {
- if (this.config.killWordOnPaste)
- this._wordClean();
+ // Paste first then clean
this._doc.execCommand(cmdID, UI, param);
+ if (this.config.killWordOnPaste) {
+ this._wordClean();
+ }
} catch (e) {
if (HTMLArea.is_gecko) {
if (confirm("Unprivileged scripts cannot access Cut/Copy/Paste programatically " +
@@ -2288,8 +2313,10 @@ function getMozSelection(txtarea) {
html = "<!--" + root.data + "-->";
break; // skip comments, for now.
}
- //html = html.replace(/^\n+/, '');
- return HTMLArea.formathtml(html);
+
+ //return HTMLArea.formathtml(html);
+ // formathtml doesn't work properly yet!!!
+ return html;
};
HTMLArea.prototype.stripBaseURL = function(string) {
Please sign in to comment.
Something went wrong with that request. Please try again.