black: false,
white: false,
-
+ bodyCls : '',
/**
* Protected method that will not generally be called directly. It
'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
'</style>';
} else {
-
+ st = '<style type="text/css">' +
+ this.stylesheets +
+ '</style>';
}
st += '<style type="text/css">' +
'IMG { cursor: pointer } ' +
'</style>';
+ var cls = 'roo-htmleditor-body';
+
+ if(this.bodyCls.length){
+ cls += ' ' + this.bodyCls;
+ }
return '<html><head>' + st +
//<style type="text/css">' +
//'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
//'</style>' +
- ' </head><body class="roo-htmleditor-body"></body></html>';
+ ' </head><body class="' + cls + '"></body></html>';
},
// private
insertAtCursor : function(text)
{
-
-
if(!this.activated){
return;
}
var nodeIsBefore = ss == 1;
var nodeIsAfter = ee == -1;
- if (nodeIsBefore && nodeIsAfter)
+ if (nodeIsBefore && nodeIsAfter) {
return 0; // outer
- if (!nodeIsBefore && nodeIsAfter)
+ }
+ if (!nodeIsBefore && nodeIsAfter) {
return 1; //right trailed.
+ }
- if (nodeIsBefore && !nodeIsAfter)
+ if (nodeIsBefore && !nodeIsAfter) {
return 2; // left trailed.
+ }
// fully contined.
return 3;
},
if (v.match(/^\./) || v.match(/^\//)) {
return;
}
- if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/)) {
+ if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
return;
}
if (v.match(/^#/)) {
node.className = '';
}
- if (a.value.match(/body/)) {
+ if (a.value.match(/^body$/)) {
node.className = '';
}
continue;
},
/**
* 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)
{
*/
cleanTableWidths : function(node)
{
-
- var _t = this;
- var cleanTableWidthsChildren = function()
- {
- if (!node.childNodes.length) {
- return;
- }
- for (var i = node.childNodes.length-1; i > -1 ; i--) {
- _t.cleanTableWidths(node.childNodes[i]);
- }
- }
-
-
-
-
+
+
if (!node) {
- this.cleanWord(this.doc.body);
+ this.cleanTableWidths(this.doc.body);
return;
}
- 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;
+ // ignore list...
+ if (node.nodeName == "#text" || node.nodeName == "#comment") {
+ return;
}
-
- // remove - but keep children..
- if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
- while (node.childNodes.length) {
- var cn = node.childNodes[0];
- node.removeChild(cn);
- node.parentNode.insertBefore(cn, node);
- }
- node.parentNode.removeChild(node);
- cleanWordChildren();
+ Roo.log(node.tagName);
+ if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
+ this.iterateChildren(node, this.cleanTableWidths);
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('width')) {
+ node.removeAttribute('width');
}
+
if (node.hasAttribute("style")) {
+ // pretty basic...
var styles = node.getAttribute("style").split(";");
var nstyle = [];
return;
}
var kv = s.split(":");
- if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
+ if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
return;
}
// what ever is left... we allow.
}
}
- cleanWordChildren();
+ this.iterateChildren(node, this.cleanTableWidths);
},
Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
s.remove();
});
+ },
+
+ setStyle : function(style)
+ {
+ Roo.get(this.iframe.contentDocument.head).createChild({
+ tag : 'style',
+ type : 'text/css',
+ html : style
+ });
+
+ return;
}
// hide stuff that is not compatible