X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=roojs-ui-debug.js;h=d0a33a946043f7796b3367a418712af405e5e506;hb=3818ab34627387a252c8450f8b34bbe7e153cafd;hp=f5ff08a7df62eb6e572f7f662e05dfdfe0729174;hpb=d6ccff3ee7b1385621a7fb364b8f0b7a3aa65cce;p=roojs1 diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index f5ff08a7df..d0a33a9460 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -20900,7 +20900,7 @@ Roo.rtf.Parser.prototype = { this.hexStore.push(cmd); }, cmderror : function(cmd) { - throw new Exception (cmd.value); + throw cmd.value; }, /* @@ -21030,7 +21030,8 @@ Roo.rtf.Parser.prototype = { { this.emitText(); if (this.controlWord === '') { - this.emitError('empty control word'); + // do we want to track this - it seems just to cause problems. + //this.emitError('empty control word'); } else { this.push({ type: 'controlword', @@ -21579,7 +21580,11 @@ Roo.extend(Roo.htmleditor.FilterTableWidth, Roo.htmleditor.Filter, Roo.htmleditor.FilterWord = function(cfg) { // no need to apply config. + this.replaceDocBullets(cfg.node); + this.walk(cfg.node); + + } Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, @@ -21629,7 +21634,10 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, node.removeChild(cn); node.parentNode.insertBefore(cn, node); // move node to parent - and clean it.. - this.replaceTag(cn); + if (cn.nodeType == 1) { + this.replaceTag(cn); + } + } node.parentNode.removeChild(node); /// no need to iterate chidlren = it's got none.. @@ -21681,7 +21689,98 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, + }, + + styleToObject: function(node) + { + var styles = node.getAttribute("style").split(";"); + var ret = {}; + Roo.each(styles, function(s) { + if (!s.match(/:/)) { + return; + } + var kv = s.split(":"); + + // what ever is left... we allow. + ret[kv[0]] = kv[1]; + }); + return ret; + }, + + + replaceDocBullets : function(doc) + { + var listpara = doc.getElementsByClassName('MsoListParagraph'); + while(listpara.length) { + this.replaceDocBullet(listpara.item(0)); + //code + } + }, + + replaceDocBullet : function(p) + { + // gather all the siblings. + var ns = p, + parent = p.parentNode, + doc = parent.ownerDocument, + items = []; + while (ns) { + if (ns.nodeType != 1) { + ns = ns.nextSibling; + continue; + } + if (!ns.className.match(/MsoListParagraph/i)) { + break; + } + items.push(ns); + ns = ns.nextSibling; + + } + var ul = parent.ownerDocument.createElement('ul'); // what about number lists... + parent.insertBefore(ul, p); + var lvl = 0; + var stack = [ ul ]; + var last_li = false; + items.forEach(function(n) { + parent.removeChild(n); + var spans = n.getElementsByTagName('span'); + if (!spans.length || !n.isEqualNode(spans.item(0).parentNode)) { + return; // skip it... + } + + var style = this.styleToObject(n); + if (typeof(style['mso-list']) == 'undefined') { + return; // skip it. + } + n.removeChild(spans.item(0)); // remove the fake bullet. + var nlvl = (style['mso-list'].split(' ')[1].replace(/level/,'') *1) - 1; + if (nlvl > lvl) { + //new indent + var nul = doc.createElement('ul'); // what about number lists... + last_li.appendChild(nul); + stack[nlvl] = nul; + } + lvl = nlvl; + + var nli = stack[nlvl].appendChild(doc.createElement('li')); + last_li = nli; + // copy children of p into nli + while(n.firstChild) { + var fc = n.firstChild; + n.removeChild(fc); + nli.appendChild(fc); + } + + + },this); + + + + } + + + }); /** * @class Roo.htmleditor.FilterStyleToTag @@ -23536,7 +23635,6 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { store : { xtype : 'SimpleStore', data : [ - ['auto'], ['50%'], ['80%'], ['100%'] @@ -23680,7 +23778,7 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { var ret = { tag: 'figure', 'data-block' : 'Figure', - + 'data-width' : this.width, contenteditable : 'false', style : { @@ -23707,9 +23805,9 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { fontSize : '16px', lineHeight : '24px', display : this.caption_display, - maxWidth : this.width + ' !important', + maxWidth : (this.align == 'center' ? this.width : '100%' ) + ' !important', margin: m, - width: this.width + width: this.align == 'center' ? this.width : '100%' }, @@ -23761,7 +23859,7 @@ Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, { this.caption_display = this.getVal(node, 'figcaption', 'data-display'); //this.text_align = this.getVal(node, 'figcaption', 'style','text-align'); - this.width = this.getVal(node, 'figcaption', 'style', 'width'); + this.width = this.getVal(node, true, 'data-width'); //this.margin = this.getVal(node, 'figure', 'style', 'margin'); }, @@ -25607,7 +25705,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { var parser = new Roo.rtf.Parser(cd.getData('text/rtf')); images = parser.doc ? parser.doc.getElementsByType('pict') : []; } - Roo.log(images); + //Roo.log(images); //Roo.log(imgs); // fixme.. images = images.filter(function(g) { return !g.path.match(/^rtf\/(head|pgdsctbl|listtable|footerf)/); }) // ignore headers/footers etc. @@ -25638,10 +25736,12 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { }); } if (this.autoClean) { + new Roo.htmleditor.FilterWord({ node : d }); + new Roo.htmleditor.FilterStyleToTag({ node : d }); new Roo.htmleditor.FilterAttributes({ node : d, - attrib_white : ['href', 'src', 'name', 'align', 'colspan', 'rowspan', 'data-display'], + attrib_white : ['href', 'src', 'name', 'align', 'colspan', 'rowspan', 'data-display', 'data-width'], attrib_clean : ['href', 'src' ] }); new Roo.htmleditor.FilterBlack({ node : d, tag : this.black}); @@ -25651,6 +25751,8 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { new Roo.htmleditor.FilterSpan({ node : d }); new Roo.htmleditor.FilterLongBr({ node : d }); new Roo.htmleditor.FilterComment({ node : d }); + + } if (this.enableBlocks) { @@ -25671,7 +25773,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { if (this.enableBlocks) { Roo.htmleditor.Block.initAll(this.doc.body); } - + e.preventDefault(); return false;