// no need to apply config.
this.replaceDocBullets(cfg.node);
+ this.replaceAname(cfg.node);
// this is disabled as the removal is done by other filters;
// this.walk(cfg.node);
});
return ret;
},
-
+
+
+ replaceAname : function (doc)
+ {
+ // replace all the a/name without..
+ var aa = Array.from(doc.getElementsByTagName('a'));
+ for (var i = 0; i < aa.length; i++) {
+ var a = aa[i];
+ if (a.hasAttribute("name")) {
+ a.removeAttribute("name");
+ }
+ if (a.hasAttribute("href")) {
+ continue;
+ }
+ // reparent children.
+ this.removeNodeKeepChildren(a);
+
+ }
+
+
+
+ },
+
+
+
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');
+ var listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpFirst'));
+ for( var i = 0; i < listpara.length; i ++) {
+ listpara[i].className = "MsoListParagraph";
+ }
+
+ listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpMiddle'));
+ for( var i = 0; i < listpara.length; i ++) {
+ listpara[i].className = "MsoListParagraph";
+ }
+ listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpLast'));
for( var i = 0; i < listpara.length; i ++) {
- listpara.item(i).className = "MsoListParagraph";
+ listpara[i].className = "MsoListParagraph";
}
+ listpara = Array.from(doc.getElementsByClassName('ql-indent-1'));
+ for( var i = 0; i < listpara.length; i ++) {
+ listpara[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');
+ var htwo = Array.from(doc.getElementsByTagName('h2'));
for( var i = 0; i < htwo.length; i ++) {
- if (htwo.item(i).hasAttribute('style') && htwo.item(i).getAttribute('style').match(/mso-list:/)) {
- htwo.item(i).className = "MsoListParagraph";
+ if (htwo[i].hasAttribute('style') && htwo[i].getAttribute('style').match(/mso-list:/)) {
+ htwo[i].className = "MsoListParagraph";
}
}
- listpara = doc.getElementsByClassName('MsoNormal');
- while(listpara.length) {
- if (listpara.item(0).hasAttribute('style') && listpara.item(0).getAttribute('style').match(/mso-list:/)) {
- listpara.item(0).className = "MsoListParagraph";
+ listpara = Array.from(doc.getElementsByClassName('MsoNormal'));
+ for( var i = 0; i < listpara.length; i ++) {
+ if (listpara[i].hasAttribute('style') && listpara[i].getAttribute('style').match(/mso-list:/)) {
+ listpara[i].className = "MsoListParagraph";
} else {
- listpara.item(0).className = "MsoNormalx";
+ listpara[i].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));
doc = parent.ownerDocument,
items = [];
-
+ var listtype = 'ul';
while (ns) {
if (ns.nodeType != 1) {
ns = ns.nextSibling;
if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) {
break;
}
- if (ns.getAttribute('style').match(/mso-list/)) {
+ 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');
}
var has_list = false;
for(var i = 0; i < spans.length; i++) {
- if (spans[i].getAttribute('style').match(/mso-list/)) {
+ if (spans[i].hasAttribute('style') && spans[i].getAttribute('style').match(/mso-list/)) {
has_list = true;
break;
}
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 ];
}
-
+ var num = 1;
var style = {};
for(var i = 0; i < spans.length; i++) {
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;
}
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);
}
lvl = nlvl;
+ // not starting at 1..
+ if (!stack[nlvl].hasAttribute("start") && listtype == "ol") {
+ stack[nlvl].setAttribute("start", num);
+ }
+
var nli = stack[nlvl].appendChild(doc.createElement('li'));
last_li = nli;
nli.innerHTML = n.innerHTML;