From 3f00891650ec76f491d3317696fd08c7ce16bd15 Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 21 Jul 2022 17:34:24 +0800 Subject: [PATCH] remove debug code from word filter --- docs/src/Roo_HtmlEditorCore.js.html | 2 +- docs/src/Roo_htmleditor_FilterWord.js.html | 50 +++++++++++++++++----- roojs-bootstrap-debug.js | 2 +- roojs-bootstrap.js | 2 +- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/docs/src/Roo_HtmlEditorCore.js.html b/docs/src/Roo_HtmlEditorCore.js.html index e0526b4274..d1a2b45347 100644 --- a/docs/src/Roo_HtmlEditorCore.js.html +++ b/docs/src/Roo_HtmlEditorCore.js.html @@ -634,7 +634,7 @@ new Roo.htmleditor.FilterStyleToTag({ node : d }); new Roo.htmleditor.FilterAttributes({ node : d, - attrib_white : ['href', 'src', 'name', 'align', 'colspan', 'rowspan', 'data-display', 'data-width'], + attrib_white : ['href', 'src', 'name', 'align', 'colspan', 'rowspan', 'data-display', 'data-width', 'start'], attrib_clean : ['href', 'src' ] }); new Roo.htmleditor.FilterBlack({ node : d, tag : this.black}); diff --git a/docs/src/Roo_htmleditor_FilterWord.js.html b/docs/src/Roo_htmleditor_FilterWord.js.html index 72e1211cdd..dfc5e5dfa4 100644 --- a/docs/src/Roo_htmleditor_FilterWord.js.html +++ b/docs/src/Roo_htmleditor_FilterWord.js.html @@ -168,12 +168,26 @@ replaceDocBullets : function(doc) { // this is a bit odd - but it appears some indents use ql-indent-1 - //Roo.log(doc.innerHTML); + //Roo.log(doc.innerHTML); var listpara = doc.getElementsByClassName('MsoListParagraphCxSpFirst'); for( var i = 0; i < listpara.length; i ++) { listpara.item(i).className = "MsoListParagraph"; } + + listpara = doc.getElementsByClassName('MsoListParagraphCxSpMiddle'); + for( var i = 0; i < listpara.length; i ++) { + listpara.item(i).className = "MsoListParagraph"; + } + listpara = doc.getElementsByClassName('MsoListParagraphCxSpLast'); + for( var i = 0; i < listpara.length; i ++) { + listpara.item(i).className = "MsoListParagraph"; + } + listpara = doc.getElementsByClassName('ql-indent-1'); + for( var i = 0; i < listpara.length; i ++) { + listpara.item(i).className = "MsoListParagraph"; + } + // this is a bit hacky - we had one word document where h2 had a miso-list attribute. var htwo = doc.getElementsByTagName('h2'); for( var i = 0; i < htwo.length; i ++) { @@ -189,11 +203,12 @@ listpara.item(0).className = "MsoNormalx"; } } - listpara = doc.getElementsByClassName('ql-indent-1'); - while(listpara.length) { - this.replaceDocBullet(listpara.item(0)); - } + listpara = doc.getElementsByClassName('MsoListParagraph'); + + + //Roo.log(doc.innerHTML); + while(listpara.length) { this.replaceDocBullet(listpara.item(0)); @@ -211,7 +226,7 @@ doc = parent.ownerDocument, items = []; - + var listtype = 'ul'; while (ns) { if (ns.nodeType != 1) { ns = ns.nextSibling; @@ -220,10 +235,18 @@ if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) { break; } + var spans = ns.getElementsByTagName('span'); if (ns.hasAttribute('style') && ns.getAttribute('style').match(/mso-list/)) { items.push(ns); ns = ns.nextSibling; has_list = true; + if (spans.length && spans[0].hasAttribute('style')) { + var style = this.styleToObject(spans[0]); + if (typeof(style['font-family']) != 'undefined' && !style['font-family'].match(/Symbol/)) { + listtype = 'ol'; + } + } + continue; } var spans = ns.getElementsByTagName('span'); @@ -250,7 +273,7 @@ return; } - var ul = parent.ownerDocument.createElement('ul'); // what about number lists... + var ul = parent.ownerDocument.createElement(listtype); // what about number lists... parent.insertBefore(ul, p); var lvl = 0; var stack = [ ul ]; @@ -273,7 +296,7 @@ } - + var num = 1; var style = {}; for(var i = 0; i < spans.length; i++) { @@ -281,7 +304,9 @@ if (typeof(style['mso-list']) == 'undefined') { continue; } - + if (listtype == 'ol') { + num = spans[i].innerText.replace(/[^0-9]+]/g,'') * 1; + } spans[i].parentNode.removeChild(spans[i]); // remove the fake bullet. break; } @@ -304,7 +329,7 @@ if (nlvl > lvl) { //new indent - var nul = doc.createElement('ul'); // what about number lists... + var nul = doc.createElement(listtype); // what about number lists... if (!last_li) { last_li = doc.createElement('li'); stack[lvl].appendChild(last_li); @@ -315,6 +340,11 @@ } lvl = nlvl; + // not starting at 1.. + if (!stack[nlvl].hasAttribute("start") && num > 1) { + stack[nlvl].setAttribute("start", num); + } + var nli = stack[nlvl].appendChild(doc.createElement('li')); last_li = nli; nli.innerHTML = n.innerHTML; diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 4c3502b749..f480357f1f 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -26685,9 +26685,9 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, } listpara = doc.getElementsByClassName('MsoListParagraph'); - Roo.log(doc.innerHTML); + //Roo.log(doc.innerHTML); while(listpara.length) { diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index eeb5e4dc04..b6f4ed257c 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1154,7 +1154,7 @@ var C={};Roo.each(B,function(s){if(!s.match(/:/)){return;}var kv=s.split(":");C[ }if(a.hasAttribute("href")){continue;}this.removeNodeKeepChildren(a);}},replaceDocBullets:function(A){var B=A.getElementsByClassName('MsoListParagraphCxSpFirst');for(var i=0;i