,A.wrap.dom.firstChild.nextSibling,true);var ty=Roo.form.HtmlEditor.ToolbarContext.types;this.toolbars={};for(var i in ty){this.toolbars[i]=this.buildToolbar(ty[i],i);}this.tb=this.toolbars.BODY;this.tb.el.show();this.buildFooter();this.footer.show();A.on('hide',function(){this.footer.hide()}
,this);A.on('show',function(){this.footer.show()},this);this.rendered=true;A.on('editorevent',this.updateToolbar,this);},updateToolbar:function(A,ev,B){if(!this.editorcore.activated){this.editor.onFirstFocus();return;}if(ev&&(ev.type=='mouseup'||ev.type=='click')&&ev.target&&ev.target.tagName=='IMG'){B=ev.target;
this.editorcore.selectNode(B);}var C=this.editorcore.getAllAncestors();var ty=Roo.form.HtmlEditor.ToolbarContext.types;if(!B){B=C.length?(C[0]?C[0]:C[1]):this.editorcore.doc.body;B=B?B:this.editorcore.doc.body;B=B.tagName.length?B:this.editorcore.doc.body;
-}var tn=B.tagName.toUpperCase();var D=this.tb.selectedNode;this.tb.selectedNode=B;var E=tn;var db=Roo.get(B).findParent('[data-block]');var F=false;if(db&&!B.hasAttribute('contenteditable')&&B.getAttribute('contenteditable')!='true'){F=Roo.htmleditor.Block.factory(db);
-if(F){tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;this.editorcore.selectNode(db);if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(F.context,tn,F.friendly_name);}E=F.friendly_name;C=this.editorcore.getAllAncestors();
-}}if(this.tb.name==tn&&D==this.tb.selectedNode&&ev!==false){return;}this.tb.el.hide();this.tb=typeof(this.toolbars[tn])!='undefined'?this.toolbars[tn]:this.toolbars['*'];this.tb.el.show();this.tb.items.first().el.innerHTML=E+': ';if(F){this.tb.fields.each(function(e){e.setValue(F[e.attrname]);
+}var tn=B.tagName.toUpperCase();var D=this.tb.selectedNode;this.tb.selectedNode=B;var E=tn;var db=Roo.get(B).findParent('[data-block]');var F=Roo.get(B).findParent('[contenteditable=true]');if(db&&F&&F.tagName!='BODY'){db=false;}var G=false;if(db&&!B.hasAttribute('contenteditable')&&B.getAttribute('contenteditable')!='true'){G=Roo.htmleditor.Block.factory(db);
+if(G){tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;this.editorcore.selectNode(db);if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(G.context,tn,G.friendly_name);}E=G.friendly_name;C=this.editorcore.getAllAncestors();
+}}if(this.tb.name==tn&&D==this.tb.selectedNode&&ev!==false){return;}this.tb.el.hide();this.tb=typeof(this.toolbars[tn])!='undefined'?this.toolbars[tn]:this.toolbars['*'];this.tb.el.show();this.tb.items.first().el.innerHTML=E+': ';if(G){this.tb.fields.each(function(e){e.setValue(G[e.attrname]);
});}else if(this.tb.fields&&this.tb.selectedNode){this.tb.fields.each(function(e){if(e.stylename){e.setValue(this.tb.selectedNode.style[e.stylename]);return;}e.setValue(this.tb.selectedNode.getAttribute(e.attrname));},this);this.updateToolbarStyles(this.tb.selectedNode);
}Roo.menu.MenuMgr.hideAll();this.updateFooter(C);},updateToolbarStyles:function(A){var B=false;for(var i in this.styles){B=true;break;}if(B){var st=this.tb.fields.item(0);st.store.removeAll();var cn=A.className.split(/\s+/);var C=[];if(this.styles['*']){Roo.each(this.styles['*'],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);
});}if(this.styles[tn]){Roo.each(this.styles[tn],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);});}st.store.loadData(C);st.collapse();st.setValue(cn);}},updateFooter:function(A){var B='';if(A===false){this.footDisp.dom.innerHTML='';return;}this.footerEls=A.reverse();
// ok see if we are editing a block?
var db = Roo.get(sel).findParent('[data-block]');
+ var cepar = Roo.get(sel).findParent('[contenteditable=true]');
+ if (db && cepar && cepar.tagName != 'BODY') {
+ db = false; // we are inside an editable block.. = not sure how we are going to handle nested blocks!?
+ }
var block = false;
if (db && !sel.hasAttribute('contenteditable') && sel.getAttribute('contenteditable') != 'true' ) {
block = Roo.htmleditor.Block.factory(db);
// ok see if we are editing a block?
var db = Roo.get(sel).findParent('[data-block]');
+ var cepar = Roo.get(sel).findParent('[contenteditable=true]');
+ if (db && cepar && cepar.tagName != 'BODY') {
+ db = false; // we are inside an editable block.. = not sure how we are going to handle nested blocks!?
+ }
var block = false;
if (db && !sel.hasAttribute('contenteditable') && sel.getAttribute('contenteditable') != 'true' ) {
block = Roo.htmleditor.Block.factory(db);
,A.wrap.dom.firstChild.nextSibling,true);var ty=Roo.form.HtmlEditor.ToolbarContext.types;this.toolbars={};for(var i in ty){this.toolbars[i]=this.buildToolbar(ty[i],i);}this.tb=this.toolbars.BODY;this.tb.el.show();this.buildFooter();this.footer.show();A.on('hide',function(){this.footer.hide()}
,this);A.on('show',function(){this.footer.show()},this);this.rendered=true;A.on('editorevent',this.updateToolbar,this);},updateToolbar:function(A,ev,B){if(!this.editorcore.activated){this.editor.onFirstFocus();return;}if(ev&&(ev.type=='mouseup'||ev.type=='click')&&ev.target&&ev.target.tagName=='IMG'){B=ev.target;
this.editorcore.selectNode(B);}var C=this.editorcore.getAllAncestors();var ty=Roo.form.HtmlEditor.ToolbarContext.types;if(!B){B=C.length?(C[0]?C[0]:C[1]):this.editorcore.doc.body;B=B?B:this.editorcore.doc.body;B=B.tagName.length?B:this.editorcore.doc.body;
-}var tn=B.tagName.toUpperCase();var D=this.tb.selectedNode;this.tb.selectedNode=B;var E=tn;var db=Roo.get(B).findParent('[data-block]');var F=false;if(db&&!B.hasAttribute('contenteditable')&&B.getAttribute('contenteditable')!='true'){F=Roo.htmleditor.Block.factory(db);
-if(F){tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;this.editorcore.selectNode(db);if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(F.context,tn,F.friendly_name);}E=F.friendly_name;C=this.editorcore.getAllAncestors();
-}}if(this.tb.name==tn&&D==this.tb.selectedNode&&ev!==false){return;}this.tb.el.hide();this.tb=typeof(this.toolbars[tn])!='undefined'?this.toolbars[tn]:this.toolbars['*'];this.tb.el.show();this.tb.items.first().el.innerHTML=E+': ';if(F){this.tb.fields.each(function(e){e.setValue(F[e.attrname]);
+}var tn=B.tagName.toUpperCase();var D=this.tb.selectedNode;this.tb.selectedNode=B;var E=tn;var db=Roo.get(B).findParent('[data-block]');var F=Roo.get(B).findParent('[contenteditable=true]');if(db&&F&&F.tagName!='BODY'){db=false;}var G=false;if(db&&!B.hasAttribute('contenteditable')&&B.getAttribute('contenteditable')!='true'){G=Roo.htmleditor.Block.factory(db);
+if(G){tn='BLOCK.'+db.getAttribute('data-block');this.tb.selectedNode=db;this.editorcore.selectNode(db);if(typeof(this.toolbars[tn])=='undefined'){this.toolbars[tn]=this.buildToolbar(G.context,tn,G.friendly_name);}E=G.friendly_name;C=this.editorcore.getAllAncestors();
+}}if(this.tb.name==tn&&D==this.tb.selectedNode&&ev!==false){return;}this.tb.el.hide();this.tb=typeof(this.toolbars[tn])!='undefined'?this.toolbars[tn]:this.toolbars['*'];this.tb.el.show();this.tb.items.first().el.innerHTML=E+': ';if(G){this.tb.fields.each(function(e){e.setValue(G[e.attrname]);
});}else if(this.tb.fields&&this.tb.selectedNode){this.tb.fields.each(function(e){if(e.stylename){e.setValue(this.tb.selectedNode.style[e.stylename]);return;}e.setValue(this.tb.selectedNode.getAttribute(e.attrname));},this);this.updateToolbarStyles(this.tb.selectedNode);
}Roo.menu.MenuMgr.hideAll();this.updateFooter(C);},updateToolbarStyles:function(A){var B=false;for(var i in this.styles){B=true;break;}if(B){var st=this.tb.fields.item(0);st.store.removeAll();var cn=A.className.split(/\s+/);var C=[];if(this.styles['*']){Roo.each(this.styles['*'],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);
});}if(this.styles[tn]){Roo.each(this.styles[tn],function(v){C.push([v,cn.indexOf(v)>-1?1:0]);});}st.store.loadData(C);st.collapse();st.setValue(cn);}},updateFooter:function(A){var B='';if(A===false){this.footDisp.dom.innerHTML='';return;}this.footerEls=A.reverse();