*/
equals : function(b)
{
- // https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript
- if (this === b) {
- return true;
- }
- if (b == null) {
- return false;
- }
- if (this.length !== b.length) {
- return false;
- }
-
- // sort?? a.sort().equals(b.sort());
+ // https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript
+ if (this === b) {
+ return true;
+ }
+ if (b == null) {
+ return false;
+ }
+ if (this.length !== b.length) {
+ return false;
+ }
+
+ // sort?? a.sort().equals(b.sort());
+
+ for (var i = 0; i < this.length; ++i) {
+ if (this[i] !== b[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+
+
+});
+
+Roo.applyIf(Array, {
+ /**
+ * from
+ * @static
+ * @param {Array} o Or Array like object (eg. nodelist)
+ * @returns {Array}
+ */
+ from : function(o)
+ {
+ var ret= [];
+
+ for (var i =0; i < o.length; i++) {
+ ret[i] = o[i];
+ }
+ return ret;
- for (var i = 0; i < this.length; ++i) {
- if (this[i] !== b[i]) {
- return false;
- }
- }
- return true;
}
});
-
-
-
// cleans up the whole document..
Roo.log('cleanuppaste');
- this.cleanUpChildren(this.doc.body);
+ this.cleanUpChild(this.doc.body);
var clean = this.cleanWordChars(this.doc.body.innerHTML);
if (clean != this.doc.body.innerHTML) {
this.doc.body.innerHTML = clean;
return output;
},
-
- cleanUpChildren : function (n)
- {
- if (!n.childNodes.length) {
- return;
- }
- for (var i = n.childNodes.length-1; i > -1 ; i--) {
- this.cleanUpChild(n.childNodes[i]);
- }
- },
-
+
cleanUpChild : function (node)
{
- var ed = this;
- //console.log(node);
- if (node.nodeName == "#text") {
- // clean up silly Windows -- stuff?
- return;
- }
- if (node.nodeName == "#comment") {
- if (!this.allowComments) {
- node.parentNode.removeChild(node);
- }
- // clean up silly Windows -- stuff?
- return;
- }
- var lcname = node.tagName.toLowerCase();
- // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
- // whitelist of tags..
-
- if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
- // remove node.
- node.parentNode.removeChild(node);
- return;
-
- }
-
- var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
-
- // spans with no attributes - just remove them..
- if ((!node.attributes || !node.attributes.length) && lcname == 'span') {
- remove_keep_children = true;
- }
-
- // remove <a name=....> as rendering on yahoo mailer is borked with this.
- // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
-
- //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
- // remove_keep_children = true;
- //}
-
- if (remove_keep_children) {
- this.cleanUpChildren(node);
- // inserts everything just before this node...
- while (node.childNodes.length) {
- var cn = node.childNodes[0];
- node.removeChild(cn);
- node.parentNode.insertBefore(cn, node);
- }
- node.parentNode.removeChild(node);
- return;
- }
-
- if (!node.attributes || !node.attributes.length) {
-
-
-
-
- this.cleanUpChildren(node);
- return;
- }
-
- function cleanAttr(n,v)
- {
-
- if (v.match(/^\./) || v.match(/^\//)) {
- return;
- }
- if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
- return;
- }
- if (v.match(/^#/)) {
- return;
- }
- if (v.match(/^\{/)) { // allow template editing.
- return;
- }
-// Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
- node.removeAttribute(n);
-
- }
-
- var cwhite = this.cwhite;
- var cblack = this.cblack;
-
- function cleanStyle(n,v)
- {
- if (v.match(/expression/)) { //XSS?? should we even bother..
- node.removeAttribute(n);
- return;
- }
-
- var parts = v.split(/;/);
- var clean = [];
-
- Roo.each(parts, function(p) {
- p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
- if (!p.length) {
- return true;
- }
- var l = p.split(':').shift().replace(/\s+/g,'');
- l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
-
- if ( cwhite.length && cblack.indexOf(l) > -1) {
-// Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
- //node.removeAttribute(n);
- return true;
- }
- //Roo.log()
- // only allow 'c whitelisted system attributes'
- if ( cwhite.length && cwhite.indexOf(l) < 0 && cwhite.indexOf(l.toLowerCase()) < 0 ) {
-// Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
- //node.removeAttribute(n);
- return true;
- }
-
-
-
-
- clean.push(p);
- return true;
- });
- if (clean.length) {
- node.setAttribute(n, clean.join(';'));
- } else {
- node.removeAttribute(n);
- }
-
- }
-
-
- for (var i = node.attributes.length-1; i > -1 ; i--) {
- var a = node.attributes[i];
- //console.log(a);
-
- if (a.name.toLowerCase().substr(0,2)=='on') {
- node.removeAttribute(a.name);
- continue;
- }
- if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
- node.removeAttribute(a.name);
- continue;
- }
- if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
- cleanAttr(a.name,a.value); // fixme..
- continue;
- }
- if (a.name == 'style') {
- cleanStyle(a.name,a.value);
- continue;
- }
- /// clean up MS crap..
- // tecnically this should be a list of valid class'es..
-
-
- if (a.name == 'class') {
- if (a.value.match(/^Mso/)) {
- node.removeAttribute('class');
- }
-
- if (a.value.match(/^body$/)) {
- node.removeAttribute('class');
- }
- continue;
- }
-
- // style cleanup!?
- // class cleanup?
-
- }
-
-
- this.cleanUpChildren(node);
+ Roo.htmleditor.FilterComment.walk(node);
+ Roo.htmleditor.FilterAttributes.walkWith(node, this.ablack, this.aclean, this.cwhite, this.cblack )
+ Roo.htmleditor.FilterBlack.walkWith(node,this.black);
+ Roo.htmleditor.FilterKeepChildren.walkWith(node,this.remove);
+
},
/**
* Clean up MS wordisms...
+ * @deprecated - use filter directly
*/
cleanWord : function(node)
{
- if (!node) {
- this.cleanWord(this.doc.body);
- return;
- }
+ Roo.htmleditor.FilterWord.walk(node ? node : this.doc.body);
- if(
- node.nodeName == 'SPAN' &&
- !node.hasAttributes() &&
- node.childNodes.length == 1 &&
- node.firstChild.nodeName == "#text"
- ) {
- var textNode = node.firstChild;
- node.removeChild(textNode);
- if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
- node.parentNode.insertBefore(node.ownerDocument.createTextNode(" "), node);
- }
- node.parentNode.insertBefore(textNode, node);
- if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
- node.parentNode.insertBefore(node.ownerDocument.createTextNode(" ") , node);
- }
- node.parentNode.removeChild(node);
- }
-
- if (node.nodeName == "#text") {
- // clean up silly Windows -- stuff?
- return;
- }
- if (node.nodeName == "#comment") {
- node.parentNode.removeChild(node);
- // clean up silly Windows -- stuff?
- return;
- }
-
- if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
- node.parentNode.removeChild(node);
- return;
- }
- //Roo.log(node.tagName);
- // remove - but keep children..
- if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)) {
- //Roo.log('-- removed');
- while (node.childNodes.length) {
- var cn = node.childNodes[0];
- node.removeChild(cn);
- node.parentNode.insertBefore(cn, node);
- // move node to parent - and clean it..
- this.cleanWord(cn);
- }
- node.parentNode.removeChild(node);
- /// no need to iterate chidlren = it's got none..
- //this.iterateChildren(node, this.cleanWord);
- return;
- }
- // clean styles
- if (node.className.length) {
-
- var cn = node.className.split(/\W+/);
- var cna = [];
- Roo.each(cn, function(cls) {
- if (cls.match(/Mso[a-zA-Z]+/)) {
- return;
- }
- cna.push(cls);
- });
- node.className = cna.length ? cna.join(' ') : '';
- if (!cna.length) {
- node.removeAttribute("class");
- }
- }
-
- if (node.hasAttribute("lang")) {
- node.removeAttribute("lang");
- }
-
- if (node.hasAttribute("style")) {
-
- var styles = node.getAttribute("style").split(";");
- var nstyle = [];
- Roo.each(styles, function(s) {
- if (!s.match(/:/)) {
- return;
- }
- var kv = s.split(":");
- if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
- return;
- }
- // what ever is left... we allow.
- nstyle.push(s);
- });
- node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
- if (!nstyle.length) {
- node.removeAttribute('style');
- }
- }
- this.iterateChildren(node, this.cleanWord);
-
-
-
- },
- /**
- * iterateChildren of a Node, calling fn each time, using this as the scole..
- * @param {DomNode} node node to iterate children of.
- * @param {Function} fn method of this class to call on each item.
- */
- iterateChildren : function(node, fn)
- {
- if (!node.childNodes.length) {
- return;
- }
- for (var i = node.childNodes.length-1; i > -1 ; i--) {
- fn.call(this, node.childNodes[i])
- }
},
-
+
/**
- * cleanTableWidths.
- *
- * Quite often pasting from word etc.. results in tables with column and widths.
- * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
- *
+
+ * @deprecated - use filters
*/
cleanTableWidths : function(node)
{
-
-
- if (!node) {
- this.cleanTableWidths(this.doc.body);
- return;
- }
-
- // ignore list...
- if (node.nodeName == "#text" || node.nodeName == "#comment") {
- return;
- }
- Roo.log(node.tagName);
- if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
- this.iterateChildren(node, this.cleanTableWidths);
- return;
- }
- if (node.hasAttribute('width')) {
- node.removeAttribute('width');
- }
-
-
- if (node.hasAttribute("style")) {
- // pretty basic...
-
- var styles = node.getAttribute("style").split(";");
- var nstyle = [];
- Roo.each(styles, function(s) {
- if (!s.match(/:/)) {
- return;
- }
- var kv = s.split(":");
- if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
- return;
- }
- // what ever is left... we allow.
- nstyle.push(s);
- });
- node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
- if (!nstyle.length) {
- node.removeAttribute('style');
- }
- }
-
- this.iterateChildren(node, this.cleanTableWidths);
-
+ Roo.htmleditor.FilterTable.walk(node ? node : this.doc.body);
+
},
-
+ /* ?? why ?? */
domToHTML : function(currentElement, depth, nopadtext) {
depth = depth || 0;
+++ /dev/null
-/**
- * Filter Clean
- *
- * Based on White / Blacklists etc...
- *
- *
- * usually call Roo.apply(Roo.htmleditor.FilterClean)
- *
- */
-
-Roo.htmleditor.FilterBlack = {
-
- black : false, // array
- walkWith : function(node, black)
- {
- this.black = black;
- this.walk(node);
- },
-
-
- walk : function (node)
- {
- Roo.htmleditor.Filter.walk.call(this, node, this.black);
-
- },
-
- replace : function(n)
- {
- n.parentNode.removeChild(n);
- }
-};
-
-/**
- * filter span's with no attributes out..
- */
-
-Roo.htmleditor.FilterSpan = {
-
- walk : function (node)
- {
- Roo.htmleditor.Filter.walk.call(this, 'SPAN', true );
-
- },
- replace : function(node)
- {
- if (node.attributes && node.attributes.length > 0) {
- this.walk(node);
- return true;
- }
- for (var i = 0; i < node.childNodes.length; i++) {
- node.removeChild(node.childNodes[i]);
- // what if we need to walk these???
- node.insertBefore(node.childNodes[i], node);
- this.walk(node.childNodes[i]);
- }
- n.parentNode.removeChild(n);
- return false; // don't walk children
-
- }
-
-};
-/**
- * filter span's with no attributes out..
- */
-Roo.htmleditor.FilterKeepChildren = {
-
- black : false, // array
- walkWith : function (node, black)
- {
- this.black = black;
- this.walk(node);
-
- },
- walk : function (node)
- {
- Roo.htmleditor.Filter.walk.call(this, node, this.black);
-
- },
-
-
- replace : function(n)
- {
- // walk children...
- for (var i = 0; i < node.childNodes.length; i++) {
- node.removeChild(node.childNodes[i]);
- // what if we need to walk these???
- node.insertBefore(node.childNodes[i], node);
- this.walk(node.childNodes[i]);
- }
- n.parentNode.removeChild(n);
- return false; // don't walk children
-
-
- }
-}
-Roo.htmleditor.FilterAttributes = {
- attrib_black : false, // array
- attrib_clean : false,
- style_white : false,
- style_black : false,
- walkWith : function (node, attrib_black, attrib_clean, style_white, style_black )
- {
- this.attrib_black = attrib_black;
- this.attrib_clean = attrib_clean;
- this.style_white = style_white ;
- this.style_black = style_black ;
- this.walk(node);
-
- },
- walk : function (node)
- {
- Roo.htmleditor.Filter.walk.call(this, node, true);
- },
-
-
- replace : function(node)
- {
- if (!node.attributes || !node.attributes.length) {
- return true;
- }
-
- for (var i = node.attributes.length-1; i > -1 ; i--) {
- var a = node.attributes[i];
- //console.log(a);
-
- if (a.name.toLowerCase().substr(0,2)=='on') {
- node.removeAttribute(a.name);
- continue;
- }
-
-
- if (this.attrib_black.indexOf(a.name.toLowerCase()) > -1) {
- node.removeAttribute(a.name);
- continue;
- }
- if (this.attrib_clean.indexOf(a.name.toLowerCase()) > -1) {
- this.cleanAttr(node,a.name,a.value); // fixme..
- continue;
- }
- if (a.name == 'style') {
- this.cleanStyle(node,a.name,a.value);
- continue;
- }
- /// clean up MS crap..
- // tecnically this should be a list of valid class'es..
-
-
- if (a.name == 'class') {
- if (a.value.match(/^Mso/)) {
- node.removeAttribute('class');
- }
-
- if (a.value.match(/^body$/)) {
- node.removeAttribute('class');
- }
- continue;
- }
-
-
- // style cleanup!?
- // class cleanup?
-
- }
- return true; // clean children
- },
-
- cleanAttr: function(node, n,v)
- {
-
- if (v.match(/^\./) || v.match(/^\//)) {
- return;
- }
- if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
- return;
- }
- if (v.match(/^#/)) {
- return;
- }
- if (v.match(/^\{/)) { // allow template editing.
- return;
- }
-// Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
- node.removeAttribute(n);
-
- },
- cleanStyle : function(node, n,v)
- {
- if (v.match(/expression/)) { //XSS?? should we even bother..
- node.removeAttribute(n);
- return;
- }
-
- var parts = v.split(/;/);
- var clean = [];
-
- Roo.each(parts, function(p) {
- p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
- if (!p.length) {
- return true;
- }
- var l = p.split(':').shift().replace(/\s+/g,'');
- l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
-
- if ( this.style_black.length && (this.style_black.indexOf(l) > -1 || this.style_black.indexOf(l.toLowerCase()) > -1)) {
- return true;
- }
- //Roo.log()
- // only allow 'c whitelisted system attributes'
- if ( this.style_white.length && style_white.indexOf(l) < 0 && style_white.indexOf(l.toLowerCase()) < 0 ) {
- return true;
- }
-
-
- clean.push(p);
- return true;
- },this);
- if (clean.length) {
- node.setAttribute(n, clean.join(';'));
- } else {
- node.removeAttribute(n);
- }
-
- }
-
-
-
-
-}
\ No newline at end of file
Roo.bootstrap.form.Radio
Roo.bootstrap.form.SecurePass
+
+Roo.htmleditor.Filter
+Roo.htmleditor.FilterAttributes
+Roo.htmleditor.FilterBlack
+Roo.htmleditor.FilterComment
+Roo.htmleditor.FilterKeepChildren
+Roo.htmleditor.FilterParagraph
+Roo.htmleditor.FilterSpan
+Roo.htmleditor.FilterTableWidth
+Roo.htmleditor.FilterWord
+
Roo.HtmlEditorCore
Roo.bootstrap.form.HtmlEditor
Roo.bootstrap.form.HtmlEditorToolbarStandard
Roo.form.ComboNested
Roo.form.Checkbox
Roo.form.Radio
+
+Roo.htmleditor.Filter
+Roo.htmleditor.FilterAttributes
+Roo.htmleditor.FilterBlack
+Roo.htmleditor.FilterComment
+Roo.htmleditor.FilterKeepChildren
+Roo.htmleditor.FilterParagraph
+Roo.htmleditor.FilterSpan
+Roo.htmleditor.FilterTableWidth
+Roo.htmleditor.FilterWord
+
+
Roo.HtmlEditorCore
Roo.form.HtmlEditor
Roo.form.HtmlEditor.ToolbarStandard
],
"returns" : []
},
+ {
+ "name" : "from",
+ "type" : "function",
+ "desc" : "from",
+ "sig" : "(o)",
+ "static" : true,
+ "memberOf" : "",
+ "isStatic" : true,
+ "isConstructor" : false,
+ "isPrivate" : false,
+ "example" : "",
+ "deprecated" : "",
+ "since" : "",
+ "see" : "",
+ "exceptions" : "",
+ "requires" : "",
+ "params" : [
+ {
+ "name" : "o",
+ "type" : "Array",
+ "desc" : "Or Array like object (eg. nodelist)",
+ "isOptional" : false
+ }
+ ],
+ "returns" : []
+ },
{
"name" : "indexOf",
"type" : "function",
{
"name" : "cleanTableWidths",
"type" : "function",
- "desc" : "cleanTableWidths.\n\nQuite often pasting from word etc.. results in tables with column and widths.\nThis does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..",
+ "desc" : "",
"sig" : "()\n{\n\n}",
"static" : false,
"memberOf" : "",
"isConstructor" : false,
"isPrivate" : false,
"example" : "",
- "deprecated" : "",
+ "deprecated" : "This has been deprecated: - use filters",
"since" : "",
"see" : "",
"exceptions" : "",
"isConstructor" : false,
"isPrivate" : false,
"example" : "",
- "deprecated" : "",
+ "deprecated" : "This has been deprecated: - use filter directly",
"since" : "",
"see" : "",
"exceptions" : "",
"params" : [],
"returns" : []
},
- {
- "name" : "iterateChildren",
- "type" : "function",
- "desc" : "iterateChildren of a Node, calling fn each time, using this as the scole..",
- "sig" : "(node, fn)",
- "static" : false,
- "memberOf" : "",
- "isStatic" : false,
- "isConstructor" : false,
- "isPrivate" : false,
- "example" : "",
- "deprecated" : "",
- "since" : "",
- "see" : "",
- "exceptions" : "",
- "requires" : "",
- "params" : [
- {
- "name" : "node",
- "type" : "DomNode",
- "desc" : "node to iterate children of.",
- "isOptional" : false
- },
- {
- "name" : "fn",
- "type" : "Function",
- "desc" : "method of this class to call on each item.",
- "isOptional" : false
- }
- ],
- "returns" : []
- },
{
"name" : "on",
"type" : "function",
"desc" : "of html tags - in addition to standard blacklist.",
"memberOf" : ""
},
+ {
+ "name" : "bodyCls-",
+ "type" : "string",
+ "desc" : "default '' default classes to add to body of editable area - usually undoreset is a good start..",
+ "memberOf" : ""
+ },
{
"name" : "clearUp",
"type" : "Boolean",
{
"name" : "stylesheets",
"type" : "Array",
- "desc" : "url of stylesheets. set to [] to disable stylesheets.",
+ "desc" : "url of stylesheets. set to [] to disable stylesheets - this is usally a good idea rootURL + '/roojs1/css/undoreset.css', .",
"memberOf" : ""
},
{
*/
</span><span class="jsdoc-var">equals </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">b</span><span class="jsdoc-syntax">)
{
- </span><span class="jsdoc-comment">// https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this </span><span class="jsdoc-syntax">=== </span><span class="jsdoc-var">b</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-keyword">return true</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">b </span><span class="jsdoc-syntax">== </span><span class="jsdoc-keyword">null</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-keyword">return false</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.length </span><span class="jsdoc-syntax">!== </span><span class="jsdoc-var">b.length</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-keyword">return false</span><span class="jsdoc-syntax">;
- }
+ </span><span class="jsdoc-comment">// https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript
+ </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this </span><span class="jsdoc-syntax">=== </span><span class="jsdoc-var">b</span><span class="jsdoc-syntax">) {
+ </span><span class="jsdoc-keyword">return true</span><span class="jsdoc-syntax">;
+ }
+ </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">b </span><span class="jsdoc-syntax">== </span><span class="jsdoc-keyword">null</span><span class="jsdoc-syntax">) {
+ </span><span class="jsdoc-keyword">return false</span><span class="jsdoc-syntax">;
+ }
+ </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.length </span><span class="jsdoc-syntax">!== </span><span class="jsdoc-var">b.length</span><span class="jsdoc-syntax">) {
+ </span><span class="jsdoc-keyword">return false</span><span class="jsdoc-syntax">;
+ }
- </span><span class="jsdoc-comment">// sort?? a.sort().equals(b.sort());
+ </span><span class="jsdoc-comment">// sort?? a.sort().equals(b.sort());
- </span><span class="jsdoc-keyword">for </span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">= 0; </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">< </span><span class="jsdoc-var">this.length</span><span class="jsdoc-syntax">; ++</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">] !== </span><span class="jsdoc-var">b</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">]) {
- </span><span class="jsdoc-keyword">return false</span><span class="jsdoc-syntax">;
- }
- }
- </span><span class="jsdoc-keyword">return true</span><span class="jsdoc-syntax">;
+ </span><span class="jsdoc-keyword">for </span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">= 0; </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">< </span><span class="jsdoc-var">this.length</span><span class="jsdoc-syntax">; ++</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">) {
+ </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">] !== </span><span class="jsdoc-var">b</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">]) {
+ </span><span class="jsdoc-keyword">return false</span><span class="jsdoc-syntax">;
+ }
+ }
+ </span><span class="jsdoc-keyword">return true</span><span class="jsdoc-syntax">;
}
+
+
+
+
});
+</span><span class="jsdoc-var">Roo.applyIf</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">Array</span><span class="jsdoc-syntax">, {
+ </span><span class="jsdoc-comment">/**
+ * from
+ * @static
+ * @param {Array} o Or Array like object (eg. nodelist)
+ * @returns {Array}
+ */
+ </span><span class="jsdoc-var">from </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o</span><span class="jsdoc-syntax">)
+ {
+ </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">ret</span><span class="jsdoc-syntax">= [];
+ </span><span class="jsdoc-keyword">for </span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">=0; </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">< </span><span class="jsdoc-var">o.length</span><span class="jsdoc-syntax">; </span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">++) {
+ </span><span class="jsdoc-var">ret</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">] = </span><span class="jsdoc-var">o</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">];
+ }
+ </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">ret</span><span class="jsdoc-syntax">;
+ }
+});
</span></code></body></html>
\ No newline at end of file
</span><span class="jsdoc-string">'</style>'</span><span class="jsdoc-syntax">;
} </span><span class="jsdoc-keyword">else </span><span class="jsdoc-syntax">{
</span><span class="jsdoc-keyword">for </span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">i </span><span class="jsdoc-keyword">in </span><span class="jsdoc-var">this.stylesheets</span><span class="jsdoc-syntax">) {
+ </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">typeof</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.stylesheets</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">]) != </span><span class="jsdoc-string">'string'</span><span class="jsdoc-syntax">) {
+ </span><span class="jsdoc-keyword">continue</span><span class="jsdoc-syntax">;
+ }
</span><span class="jsdoc-var">st </span><span class="jsdoc-syntax">+= </span><span class="jsdoc-string">'<link rel="stylesheet" href="' </span><span class="jsdoc-syntax">+ </span><span class="jsdoc-var">this.stylesheets</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">] +</span><span class="jsdoc-string">'" type="text/css">'</span><span class="jsdoc-syntax">;
}
</span><span class="jsdoc-comment">/**
* Clean up MS wordisms...
+ * @deprecated - use filter directly
*/
</span><span class="jsdoc-var">cleanWord </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">)
{
</span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-var">this.cleanWord</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.doc.body</span><span class="jsdoc-syntax">);
+ </span><span class="jsdoc-var">Roo.htmleditor.FilterWord.walk</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.doc.body</span><span class="jsdoc-syntax">);
</span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
}
-
- </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(
- </span><span class="jsdoc-var">node.nodeName </span><span class="jsdoc-syntax">== </span><span class="jsdoc-string">'SPAN' </span><span class="jsdoc-syntax">&&
- !</span><span class="jsdoc-var">node.hasAttributes</span><span class="jsdoc-syntax">() &&
- </span><span class="jsdoc-var">node.childNodes.length </span><span class="jsdoc-syntax">== 1 &&
- </span><span class="jsdoc-var">node.firstChild.nodeName </span><span class="jsdoc-syntax">== </span><span class="jsdoc-string">"#text"
- </span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">textNode </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">node.firstChild</span><span class="jsdoc-syntax">;
- </span><span class="jsdoc-var">node.removeChild</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">textNode</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.getAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'lang'</span><span class="jsdoc-syntax">) != </span><span class="jsdoc-string">'zh-CN'</span><span class="jsdoc-syntax">) { </span><span class="jsdoc-comment">// do not space pad on chinese characters..
- </span><span class="jsdoc-var">node.parentNode.insertBefore</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.ownerDocument.createTextNode</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">" "</span><span class="jsdoc-syntax">), </span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">);
- }
- </span><span class="jsdoc-var">node.parentNode.insertBefore</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">textNode</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.getAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'lang'</span><span class="jsdoc-syntax">) != </span><span class="jsdoc-string">'zh-CN'</span><span class="jsdoc-syntax">) { </span><span class="jsdoc-comment">// do not space pad on chinese characters..
- </span><span class="jsdoc-var">node.parentNode.insertBefore</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.ownerDocument.createTextNode</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">" "</span><span class="jsdoc-syntax">) , </span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">);
- }
- </span><span class="jsdoc-var">node.parentNode.removeChild</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">);
- }
-
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.nodeName </span><span class="jsdoc-syntax">== </span><span class="jsdoc-string">"#text"</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-comment">// clean up silly Windows -- stuff?
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.nodeName </span><span class="jsdoc-syntax">== </span><span class="jsdoc-string">"#comment"</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-var">node.parentNode.removeChild</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-comment">// clean up silly Windows -- stuff?
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
-
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.tagName.toLowerCase</span><span class="jsdoc-syntax">()</span><span class="jsdoc-var">.match</span><span class="jsdoc-syntax">(/^(style|script|applet|embed|noframes|noscript)$/)) {
- </span><span class="jsdoc-var">node.parentNode.removeChild</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-comment">//Roo.log(node.tagName);
- // remove - but keep children..
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.tagName.toLowerCase</span><span class="jsdoc-syntax">()</span><span class="jsdoc-var">.match</span><span class="jsdoc-syntax">(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)) {
- </span><span class="jsdoc-comment">//Roo.log('-- removed');
- </span><span class="jsdoc-keyword">while </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.childNodes.length</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">cn </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">node.childNodes</span><span class="jsdoc-syntax">[0];
- </span><span class="jsdoc-var">node.removeChild</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">cn</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-var">node.parentNode.insertBefore</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">cn</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-comment">// move node to parent - and clean it..
- </span><span class="jsdoc-var">this.cleanWord</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">cn</span><span class="jsdoc-syntax">);
- }
- </span><span class="jsdoc-var">node.parentNode.removeChild</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-comment">/// no need to iterate chidlren = it's got none..
- //this.iterateChildren(node, this.cleanWord);
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-comment">// clean styles
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.className.length</span><span class="jsdoc-syntax">) {
-
- </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">cn </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">node.className.split</span><span class="jsdoc-syntax">(/\W+/);
- </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">cna </span><span class="jsdoc-syntax">= [];
- </span><span class="jsdoc-var">Roo.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">cn</span><span class="jsdoc-syntax">, </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">cls</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">cls.match</span><span class="jsdoc-syntax">(/Mso[a-zA-Z]+/)) {
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-var">cna.push</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">cls</span><span class="jsdoc-syntax">);
- });
- </span><span class="jsdoc-var">node.className </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">cna.length </span><span class="jsdoc-syntax">? </span><span class="jsdoc-var">cna.join</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">' '</span><span class="jsdoc-syntax">) : </span><span class="jsdoc-string">''</span><span class="jsdoc-syntax">;
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">cna.length</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-var">node.removeAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">"class"</span><span class="jsdoc-syntax">);
- }
- }
-
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.hasAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">"lang"</span><span class="jsdoc-syntax">)) {
- </span><span class="jsdoc-var">node.removeAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">"lang"</span><span class="jsdoc-syntax">);
- }
-
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.hasAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">"style"</span><span class="jsdoc-syntax">)) {
-
- </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">styles </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">node.getAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">"style"</span><span class="jsdoc-syntax">)</span><span class="jsdoc-var">.split</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">";"</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">nstyle </span><span class="jsdoc-syntax">= [];
- </span><span class="jsdoc-var">Roo.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">styles</span><span class="jsdoc-syntax">, </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">s</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">s.match</span><span class="jsdoc-syntax">(/:/)) {
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">kv </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">s.split</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">":"</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">kv</span><span class="jsdoc-syntax">[0]</span><span class="jsdoc-var">.match</span><span class="jsdoc-syntax">(/^(mso-|line|font|background|margin|padding|color)/)) {
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-comment">// what ever is left... we allow.
- </span><span class="jsdoc-var">nstyle.push</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">s</span><span class="jsdoc-syntax">);
- });
- </span><span class="jsdoc-var">node.setAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">"style"</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">nstyle.length </span><span class="jsdoc-syntax">? </span><span class="jsdoc-var">nstyle.join</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">';'</span><span class="jsdoc-syntax">) : </span><span class="jsdoc-string">''</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">nstyle.length</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-var">node.removeAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'style'</span><span class="jsdoc-syntax">);
- }
- }
- </span><span class="jsdoc-var">this.iterateChildren</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">this.cleanWord</span><span class="jsdoc-syntax">);
+ </span><span class="jsdoc-var">Roo.htmleditor.FilterWord.walk</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">);
+ </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- },
- </span><span class="jsdoc-comment">/**
- * iterateChildren of a Node, calling fn each time, using this as the scole..
- * @param {DomNode} node node to iterate children of.
- * @param {Function} fn method of this class to call on each item.
- */
- </span><span class="jsdoc-var">iterateChildren </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">fn</span><span class="jsdoc-syntax">)
- {
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">node.childNodes.length</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-keyword">for </span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">node.childNodes.length</span><span class="jsdoc-syntax">-1; </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">> -1 ; </span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">--) {
- </span><span class="jsdoc-var">fn.call</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">node.childNodes</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">])
- }
},
</span><span class="jsdoc-comment">/**
- * cleanTableWidths.
- *
- * Quite often pasting from word etc.. results in tables with column and widths.
- * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
- *
+
+ * @deprecated - use filters
*/
</span><span class="jsdoc-var">cleanTableWidths </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">)
{
</span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-var">this.cleanTableWidths</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.doc.body</span><span class="jsdoc-syntax">);
+ </span><span class="jsdoc-var">Roo.htmleditor.FilterTable.walk</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.doc.body</span><span class="jsdoc-syntax">);
</span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
}
-
- </span><span class="jsdoc-comment">// ignore list...
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.nodeName </span><span class="jsdoc-syntax">== </span><span class="jsdoc-string">"#text" </span><span class="jsdoc-syntax">|| </span><span class="jsdoc-var">node.nodeName </span><span class="jsdoc-syntax">== </span><span class="jsdoc-string">"#comment"</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-var">Roo.log</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.tagName</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">node.tagName.toLowerCase</span><span class="jsdoc-syntax">()</span><span class="jsdoc-var">.match</span><span class="jsdoc-syntax">(/^(table|td|tr)$/)) {
- </span><span class="jsdoc-var">this.iterateChildren</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">this.cleanTableWidths</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.hasAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'width'</span><span class="jsdoc-syntax">)) {
- </span><span class="jsdoc-var">node.removeAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'width'</span><span class="jsdoc-syntax">);
- }
-
-
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.hasAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">"style"</span><span class="jsdoc-syntax">)) {
- </span><span class="jsdoc-comment">// pretty basic...
-
- </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">styles </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">node.getAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">"style"</span><span class="jsdoc-syntax">)</span><span class="jsdoc-var">.split</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">";"</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">nstyle </span><span class="jsdoc-syntax">= [];
- </span><span class="jsdoc-var">Roo.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">styles</span><span class="jsdoc-syntax">, </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">s</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">s.match</span><span class="jsdoc-syntax">(/:/)) {
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">kv </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">s.split</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">":"</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">kv</span><span class="jsdoc-syntax">[0]</span><span class="jsdoc-var">.match</span><span class="jsdoc-syntax">(/^\s*(width|min-width)\s*$/)) {
- </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
- }
- </span><span class="jsdoc-comment">// what ever is left... we allow.
- </span><span class="jsdoc-var">nstyle.push</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">s</span><span class="jsdoc-syntax">);
- });
- </span><span class="jsdoc-var">node.setAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">"style"</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">nstyle.length </span><span class="jsdoc-syntax">? </span><span class="jsdoc-var">nstyle.join</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">';'</span><span class="jsdoc-syntax">) : </span><span class="jsdoc-string">''</span><span class="jsdoc-syntax">);
- </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">nstyle.length</span><span class="jsdoc-syntax">) {
- </span><span class="jsdoc-var">node.removeAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'style'</span><span class="jsdoc-syntax">);
- }
- }
-
- </span><span class="jsdoc-var">this.iterateChildren</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">this.cleanTableWidths</span><span class="jsdoc-syntax">);
-
+ </span><span class="jsdoc-var">Roo.htmleditor.FilterTable.walk</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node</span><span class="jsdoc-syntax">);
},
</span><span class="jsdoc-var">width</span><span class="jsdoc-syntax">: 500,
</span><span class="jsdoc-comment">/**
- * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
+ * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets - this is usally a good idea rootURL + '/roojs1/css/undoreset.css', .
*
*/
</span><span class="jsdoc-var">stylesheets</span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">,
* @cfg {boolean} allowComments - default false - allow comments in HTML source - by default they are stripped - if you are editing email you may need this.
*/
</span><span class="jsdoc-var">allowComments</span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">,
+ </span><span class="jsdoc-comment">/**
+ * @cfg {string} bodyCls- default '' default classes to add to body of editable area - usually undoreset is a good start..
+ */
+
+
+ </span><span class="jsdoc-var">bodyCls </span><span class="jsdoc-syntax">: </span><span class="jsdoc-string">''</span><span class="jsdoc-syntax">,
</span><span class="jsdoc-comment">// id of frame..
</span><span class="jsdoc-var">frameId</span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">,
}
]
},
+ {
+ "name" : "from",
+ "type" : "function",
+ "desc" : "from",
+ "sig" : "(o)",
+ "static" : true,
+ "memberOf" : "",
+ "isStatic" : true,
+ "isConstructor" : false,
+ "isPrivate" : false,
+ "example" : "",
+ "deprecated" : "",
+ "since" : "",
+ "see" : "",
+ "exceptions" : "",
+ "requires" : "",
+ "params" : [
+ {
+ "name" : "o",
+ "type" : "Array",
+ "desc" : "Or Array like object (eg. nodelist)",
+ "isOptional" : false
+ }
+ ],
+ "returns" : []
+ },
{
"name" : "map",
"type" : "function",
"isConstructor" : false,
"isPrivate" : false,
"example" : "",
- "deprecated" : "",
+ "deprecated" : "This has been deprecated: - use filter directly",
"since" : "",
"see" : "",
"exceptions" : "",
{
"name" : "cleanTableWidths",
"type" : "function",
- "desc" : "cleanTableWidths.\n\nQuite often pasting from word etc.. results in tables with column and widths.\nThis does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..",
+ "desc" : "",
"sig" : "()\n{\n\n}",
"static" : false,
"memberOf" : "",
"isConstructor" : false,
"isPrivate" : false,
"example" : "",
- "deprecated" : "",
+ "deprecated" : "This has been deprecated: - use filters",
"since" : "",
"see" : "",
"exceptions" : "",
"params" : [],
"returns" : []
},
- {
- "name" : "iterateChildren",
- "type" : "function",
- "desc" : "iterateChildren of a Node, calling fn each time, using this as the scole..",
- "sig" : "(node, fn)",
- "static" : false,
- "memberOf" : "",
- "isStatic" : false,
- "isConstructor" : false,
- "isPrivate" : false,
- "example" : "",
- "deprecated" : "",
- "since" : "",
- "see" : "",
- "exceptions" : "",
- "requires" : "",
- "params" : [
- {
- "name" : "node",
- "type" : "DomNode",
- "desc" : "node to iterate children of.",
- "isOptional" : false
- },
- {
- "name" : "fn",
- "type" : "Function",
- "desc" : "method of this class to call on each item.",
- "isOptional" : false
- }
- ],
- "returns" : []
- },
{
"name" : "pushValue",
"type" : "function",
"desc" : "Array of toolbars. - defaults to just the Standard one",
"memberOf" : ""
},
+ {
+ "name" : "bodyCls-",
+ "type" : "string",
+ "desc" : "default '' default classes to add to body of editable area - usually undoreset is a good start..",
+ "memberOf" : ""
+ },
{
"name" : "width",
"type" : "Number",
"desc" : "Label to use when rendering a form.",
"memberOf" : "Roo.form.Field"
},
- {
- "name" : "disableClass",
- "type" : "String",
- "desc" : "CSS class added to the component when it is disabled (defaults to \"x-item-disabled\").",
- "memberOf" : "Roo.Component"
- },
{
"name" : "validationDelay",
"type" : "Number",
"desc" : "The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)",
"memberOf" : "Roo.form.Field"
},
+ {
+ "name" : "disableClass",
+ "type" : "String",
+ "desc" : "CSS class added to the component when it is disabled (defaults to \"x-item-disabled\").",
+ "memberOf" : "Roo.Component"
+ },
{
"name" : "stylesheets",
"type" : "Array",
- "desc" : "url of stylesheets. set to [] to disable stylesheets.",
+ "desc" : "url of stylesheets. set to [] to disable stylesheets - this is usally a good idea rootURL + '/roojs1/css/undoreset.css', .",
"memberOf" : ""
},
{
Roo.HtmlEditorCore.ablack=['on'];Roo.HtmlEditorCore.aclean=['action','background','codebase','dynsrc','href','lowsrc'];Roo.HtmlEditorCore.pwhite=['http','https','mailto'];Roo.HtmlEditorCore.cwhite=[];Roo.HtmlEditorCore.cblack=[];Roo.HtmlEditorCore.swapCodes=[[8211,"–"],[8212,"—"],[8216,"'"],[8217,"'"],[8220,'"'],[8221,'"'],[8226,"*"],[8230,"..."]];
// Roo/form/HtmlEditor.js
-Roo.form.HtmlEditor=function(A){Roo.form.HtmlEditor.superclass.constructor.call(this,A);if(!this.toolbars){this.toolbars=[];}this.editorcore=new Roo.HtmlEditorCore(Roo.apply({owner:this},A));};Roo.extend(Roo.form.HtmlEditor,Roo.form.Field,{clearUp:true,toolbars:false,resizable:false,height:300,width:500,stylesheets:false,cblack:false,cwhite:false,black:false,white:false,allowComments:false,frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',actionMode:'container',defaultAutoCreate:{tag:"textarea",style:"width:500px;height:300px;",autocomplete:"new-password"}
+Roo.form.HtmlEditor=function(A){Roo.form.HtmlEditor.superclass.constructor.call(this,A);if(!this.toolbars){this.toolbars=[];}this.editorcore=new Roo.HtmlEditorCore(Roo.apply({owner:this},A));};Roo.extend(Roo.form.HtmlEditor,Roo.form.Field,{clearUp:true,toolbars:false,resizable:false,height:300,width:500,stylesheets:false,cblack:false,cwhite:false,black:false,white:false,allowComments:false,bodyCls:'',frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',actionMode:'container',defaultAutoCreate:{tag:"textarea",style:"width:500px;height:300px;",autocomplete:"new-password"}
,initComponent:function(){this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editmodechange:true,editorevent:true,firstfocus:true,autosave:true,savedpreview:true,stylesheetsclick:true});this.defaultAutoCreate={tag:"textarea",style:'width: '+this.width+'px;height: '+this.height+'px;',autocomplete:"new-password"}
;},createToolbar:function(A){Roo.log("create toolbars");if(!A.toolbars||!A.toolbars.length){A.toolbars=[new Roo.form.HtmlEditor.ToolbarStandard()];}for(var i=0;i<A.toolbars.length;i++){A.toolbars[i]=Roo.factory(typeof(A.toolbars[i])=='string'?{xtype:A.toolbars[i]}
:A.toolbars[i],Roo.form.HtmlEditor);A.toolbars[i].init(A);}},onRender:function(ct,A){var _t=this;Roo.form.HtmlEditor.superclass.onRender.call(this,ct,A);this.wrap=this.el.wrap({cls:'x-html-editor-wrap',cn:{cls:'x-html-editor-tb'}});this.editorcore.onRender(ct,A);
'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
'</style>';
} else {
- for (var i in this.stylesheets) {
+ for (var i in this.stylesheets) {
+ if (typeof(this.stylesheets[i]) != 'string') {
+ continue;
+ }
st += '<link rel="stylesheet" href="' + this.stylesheets[i] +'" type="text/css">';
}
// Roo/HtmlEditorCore.js
Roo.HtmlEditorCore=function(A){Roo.HtmlEditorCore.superclass.constructor.call(this,A);this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editorevent:true});this.applyBlacklists();};Roo.extend(Roo.HtmlEditorCore,Roo.Component,{owner:false,resizable:false,height:300,width:500,stylesheets:false,allowComments:false,frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,sourceEditMode:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',clearUp:true,black:false,white:false,bodyCls:'',getDocMarkup:function(){var st='';
if(this.stylesheets===false){Roo.get(document.head).select('style').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);});Roo.get(document.head).select('link').each(function(B){st+=B.dom.outerHTML||new XMLSerializer().serializeToString(B.dom);
-});}else if(!this.stylesheets.length){st='<style type="text/css">'+'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}'+'</style>';}else{for(var i in this.stylesheets){st+='<link rel="stylesheet" href="'+this.stylesheets[i]+'" type="text/css">';}
-}st+='<style type="text/css">'+'IMG { cursor: pointer } '+'</style>';var A='roo-htmleditor-body';if(this.bodyCls.length){A+=' '+this.bodyCls;}return '<html><head>'+st+' </head><body contenteditable="true" data-enable-grammerly="true" class="'+A+'"></body></html>';
+});}else if(!this.stylesheets.length){st='<style type="text/css">'+'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}'+'</style>';}else{for(var i in this.stylesheets){if(typeof(this.stylesheets[i])!='string'){continue;}st+='<link rel="stylesheet" href="'+this.stylesheets[i]+'" type="text/css">';
+}}st+='<style type="text/css">'+'IMG { cursor: pointer } '+'</style>';var A='roo-htmleditor-body';if(this.bodyCls.length){A+=' '+this.bodyCls;}return '<html><head>'+st+' </head><body contenteditable="true" data-enable-grammerly="true" class="'+A+'"></body></html>';
},onRender:function(ct,A){var _t=this;this.el=this.owner.inputEl?this.owner.inputEl():this.owner.el;this.el.dom.style.border='0 none';this.el.dom.setAttribute('tabIndex',-1);this.el.addClass('x-hidden hide');if(Roo.isIE){this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')}
this.frameId=Roo.id();var B=this.owner.wrap.createChild({tag:'iframe',cls:'form-control',id:this.frameId,name:this.frameId,frameBorder:'no','src':Roo.SSL_SECURE_URL?Roo.SSL_SECURE_URL:"javascript:false"},this.el);this.iframe=B.dom;this.assignDocWin();this.doc.designMode='on';
this.doc.open();this.doc.write(this.getDocMarkup());this.doc.close();var C={run:function(){this.assignDocWin();if(this.doc.body||this.doc.readyState=='complete'){try{this.doc.designMode="on";}catch(e){return;}Roo.TaskMgr.stop(C);this.initEditor.defer(10,this);
width: 500,
/**
- * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
+ * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets - this is usally a good idea rootURL + '/roojs1/css/undoreset.css', .
*
*/
stylesheets: false,
* @cfg {boolean} allowComments - default false - allow comments in HTML source - by default they are stripped - if you are editing email you may need this.
*/
allowComments: false,
+ /**
+ * @cfg {string} bodyCls- default '' default classes to add to body of editable area - usually undoreset is a good start..
+ */
+
+
+ bodyCls : '',
// id of frame..
frameId: false,
width: 500,
/**
- * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
+ * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets - this is usally a good idea rootURL + '/roojs1/css/undoreset.css', .
*
*/
stylesheets: false,
* @cfg {boolean} allowComments - default false - allow comments in HTML source - by default they are stripped - if you are editing email you may need this.
*/
allowComments: false,
+ /**
+ * @cfg {string} bodyCls- default '' default classes to add to body of editable area - usually undoreset is a good start..
+ */
+
+
+ bodyCls : '',
// id of frame..
frameId: false,
Roo.HtmlEditorCore.ablack=['on'];Roo.HtmlEditorCore.aclean=['action','background','codebase','dynsrc','href','lowsrc'];Roo.HtmlEditorCore.pwhite=['http','https','mailto'];Roo.HtmlEditorCore.cwhite=[];Roo.HtmlEditorCore.cblack=[];Roo.HtmlEditorCore.swapCodes=[[8211,"–"],[8212,"—"],[8216,"'"],[8217,"'"],[8220,'"'],[8221,'"'],[8226,"*"],[8230,"..."]];
// Roo/form/HtmlEditor.js
-Roo.form.HtmlEditor=function(A){Roo.form.HtmlEditor.superclass.constructor.call(this,A);if(!this.toolbars){this.toolbars=[];}this.editorcore=new Roo.HtmlEditorCore(Roo.apply({owner:this},A));};Roo.extend(Roo.form.HtmlEditor,Roo.form.Field,{clearUp:true,toolbars:false,resizable:false,height:300,width:500,stylesheets:false,cblack:false,cwhite:false,black:false,white:false,allowComments:false,frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',actionMode:'container',defaultAutoCreate:{tag:"textarea",style:"width:500px;height:300px;",autocomplete:"new-password"}
+Roo.form.HtmlEditor=function(A){Roo.form.HtmlEditor.superclass.constructor.call(this,A);if(!this.toolbars){this.toolbars=[];}this.editorcore=new Roo.HtmlEditorCore(Roo.apply({owner:this},A));};Roo.extend(Roo.form.HtmlEditor,Roo.form.Field,{clearUp:true,toolbars:false,resizable:false,height:300,width:500,stylesheets:false,cblack:false,cwhite:false,black:false,white:false,allowComments:false,bodyCls:'',frameId:false,validationEvent:false,deferHeight:true,initialized:false,activated:false,onFocus:Roo.emptyFn,iframePad:3,hideMode:'offsets',actionMode:'container',defaultAutoCreate:{tag:"textarea",style:"width:500px;height:300px;",autocomplete:"new-password"}
,initComponent:function(){this.addEvents({initialize:true,activate:true,beforesync:true,beforepush:true,sync:true,push:true,editmodechange:true,editorevent:true,firstfocus:true,autosave:true,savedpreview:true,stylesheetsclick:true});this.defaultAutoCreate={tag:"textarea",style:'width: '+this.width+'px;height: '+this.height+'px;',autocomplete:"new-password"}
;},createToolbar:function(A){Roo.log("create toolbars");if(!A.toolbars||!A.toolbars.length){A.toolbars=[new Roo.form.HtmlEditor.ToolbarStandard()];}for(var i=0;i<A.toolbars.length;i++){A.toolbars[i]=Roo.factory(typeof(A.toolbars[i])=='string'?{xtype:A.toolbars[i]}
:A.toolbars[i],Roo.form.HtmlEditor);A.toolbars[i].init(A);}},onRender:function(ct,A){var _t=this;Roo.form.HtmlEditor.superclass.onRender.call(this,ct,A);this.wrap=this.el.wrap({cls:'x-html-editor-wrap',cn:{cls:'x-html-editor-tb'}});this.editorcore.onRender(ct,A);