X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=Roo%2Fhtmleditor%2FFilterWord.js;h=a2eeebd43a8a550d476c4b83427a09888584f344;hp=6fefb3e23c2ad6ceb8327c4b56a63a986585df34;hb=89b03a0009ad29be68bd417551948042c2b146b3;hpb=3a2d263256e7a309ae5c514a0123a153ac934780 diff --git a/Roo/htmleditor/FilterWord.js b/Roo/htmleditor/FilterWord.js index 6fefb3e23c..a2eeebd43a 100644 --- a/Roo/htmleditor/FilterWord.js +++ b/Roo/htmleditor/FilterWord.js @@ -168,12 +168,26 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, 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 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, 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 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, doc = parent.ownerDocument, items = []; - + var listtype = 'ul'; while (ns) { if (ns.nodeType != 1) { ns = ns.nextSibling; @@ -220,10 +235,18 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, 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 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, 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 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, } - + var num = 1; var style = {}; for(var i = 0; i < spans.length; i++) { @@ -281,7 +304,9 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, 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 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, 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 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, } 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;