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.item(i).className = "MsoListParagraph";
+ 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[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;
}
+ 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');
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;
this.colspan = Math.max(1,1*node.getAttribute('colspan'));
this.rowspan = Math.max(1,1*node.getAttribute('rowspan'));
this.html = node.innerHTML;
+ if (node.style.textAlign != '') {
+ this.textAlign = node.style.textAlign;
+ }
},
if (this.enableBlocks) {
new Roo.htmleditor.FilterBlock({ node : div });
}
+
+ var html = div.innerHTML;
+
//?? tidy?
- var tidy = new Roo.htmleditor.TidySerializer({
- inner: true
- });
- var html = tidy.serialize(div);
+ if (this.autoClean) {
+
+ new Roo.htmleditor.FilterAttributes({
+ node : div,
+ attrib_white : [
+ 'href',
+ 'src',
+ 'name',
+ 'align',
+ 'colspan',
+ 'rowspan',
+ 'data-display',
+ 'data-width',
+ 'start' ,
+ 'style',
+ // youtube embed.
+ 'class',
+ 'allowfullscreen',
+ 'frameborder',
+ 'width',
+ 'height',
+ 'alt'
+ ],
+ attrib_clean : ['href', 'src' ]
+ });
+
+ var tidy = new Roo.htmleditor.TidySerializer({
+ inner: true
+ });
+ html = tidy.serialize(div);
+
+ }
if(Roo.isSafari){
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});