View Full Version : TinyMCE y TabPanel
anotine
4 Dec 2006, 6:29 AM
Does anybody try to load via updateManater in a tab a textarea that should be seen with a TinyMCE editor?
Thank you for any help
Rickard
5 Dec 2006, 12:53 AM
You can add it anywhere if you initializes tinyMCE with code below.
tinyMCE.init({
theme : "advanced",
mode : "none",
language : "en", ..........
bTextareaWasTinyfied = false; //Cookie
function setTextareaToTinyMCE(sEditorID) {
var oEditor = document.getElementById(sEditorID);
if(oEditor && !bTextareaWasTinyfied) {
tinyMCE.execCommand('mceAddControl', false, sEditorID);
bTextareaWasTinyfied = true;
}
return;
}
When you load it , use setTextareaToTinyMCE(sEditorID) , then it takes over the textarea to be a tinyMCE editor.
But there is a small z-index problem when colorboxes appear on tinyMCE, it displays below the dialog when using it in a modaldialog window.
Hopes this will help you.
anotine
8 Dec 2006, 8:05 AM
Thank you ! :P
I have added a tinymce instance to a textarea that is display inside a BasicDialog popup window. I keep getting a this.getDoc() error when the tinymce textarea gets focus or when i call certain custom javascript functions that tinymce supports.
Anybody met this problem?
I'm guessing this problem happens because the texatrea which initially belongs in a certain area of the DOM, is extracted out and moved around dynamically by the BasicDialog constructor?
I have added a tinymce instance to a textarea that is display inside a BasicDialog popup window. I keep getting a this.getDoc() error when the tinymce textarea gets focus or when i call certain custom javascript functions that tinymce supports.
That's what I found to prevent this error:
tinyMCE.idCounter=0; // prevent this.geDoc() error with ajax
tinyMCE.execCommand("mceAddControl" , true, "myField");
manugoel2003
10 Mar 2007, 10:07 AM
I get a similar error
this.getDoc() has no properties
on the following line
return this.contentBody ? this.contentBody : this.getDoc().body;
tof, please explain how to use the solution you have proposed..... I have the following init.... what modifications do I need??
tinyMCE.init({
mode : "exact",
elements : "elm-1,elm-2,elm-3",
theme : "advanced",
plugins : "advimage,advlink,insertdatetime",
theme_advanced_buttons1 : "bold, italic, underline, separator, justifyleft, justifycenter, justifyright, separator, fontsizeselect, separator, bullist, numlist, separator, outdent, indent, separator, link, unlink, image, separator, insertdate, inserttime, separator, forecolor, backcolor",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_path : false,
plugin_insertdate_dateFormat : "%Y-%m-%d",
plugin_insertdate_timeFormat : "%H:%M:%S",
theme_advanced_resize_horizontal : false,
theme_advanced_resizing : true
});
Moreover, I have a requirement in which I want to give an option to switch between Plain and HTML editing.... so when the user clicks on Plain, I want the original textarea there..... and when he clicks on HTML, I want the tinyMCE instance..... but I want the data to be synchronized between the Plain and HTML instances..... has anybody done anything like this????
And as far as I know, tinyMCE gives random unique id to each textarea it is attached to.... so if I have a variable number of textareas, what is the best way to access their content??
Thanx in advance
Actually, each new instance of a tiny_mce text zone corresponds to one mce_editor_n, with n incrementing each time.
When you :
- trigger save
- close the page (unload)
- ... and others
tiny_mce get all mce_editor_n registered, and execute the action.
If you have destroyed the container of mce_editor_0 and created another mce_editor_1, it will look for mce_editor_0 and scream (getDoc).
- The "Good" solution : unregister tinymce before deleting the text zone, for exemple before removing an element with textareas :
tas = myElement.getChildrenByClassName("tinyMceTextArea");
for (i = 0; i < tas.length; i++)
{ tinyMCE.execCommand("mceRemoveControl", false, tas[i].id); }
- The "Bad" solution, work only if you have ONE simultaneous instance of tinymce; when you create the edit zone with
tinyMCE.execCommand("mceAddControl" , true, "myField");
you have to reset the counter beforer, with
tinyMCE.idCounter=0;
ozilix
14 Mar 2007, 1:32 AM
can anybody send me an example about how to use tinyMCE with ext-1.0-alpha3 r4 ???
alindsay55661
23 Mar 2007, 12:55 PM
Yeah, that would be great. I am having trouble loading tinymce into a dialog using updatemanager.
JohnF
24 Mar 2007, 12:20 PM
Try doing the following which should work if you need TinyMCE inside a BorderLayout:
1) Load the TinyMCE JS-file
2) Initialize the TinyMCE like:
tinyMCE.init({
...
oninit : "appTinyMCE_onInit",
...
});
function appTinyMCE_onInit() {
// Do some after-Ext-loading stuff here...
}
3) Load Ext files
ozilix
26 Mar 2007, 3:39 AM
firstly sorry of my english.
If you keep getting a this.getDoc() error when the tinymce textarea gets focus or when you call certain custom javascript functions that tinymce supports, you can solve it that way;
1-index.html includes all scripts
<script type="text/javascript" src="yui-utilities.js"></script>
<script type="text/javascript" src="ext-yui-adapter.js"></script>
<script type="text/javascript" src="ext-all.js"></script>
<script type="text/javascript" src="global.js"></script>
<script language="javascript" type="text/javascript" src="tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "specific_textareas",
theme : "advanced",
height : "325",
width : "560",
relative_urls : false,
remove_script_host : false,
cleanup : true,
cleanup_on_startup : true,
...
});
2-global.js
Ext.TabPanelItem.prototype.closeClick = function(e){
var o = {};
e.stopEvent();
this.fireEvent("beforeclose", this, o);
if(this.bodyEl.onClose){
this.bodyEl.onClose(o);
}
if(o.cancel !== true){
this.tabPanel.removeTab(this.id);
}
};
Ext.ContentPanel.prototype.convertToNested = function(layout){
this.layout = layout;
this.layout.monitorWindowResize = false; // turn off autosizing
this.layout.getEl().addClass("x-layout-nested-layout");
this.setSize = function(width, height){
if(!this.ignoreResize(width, height)){
var size = this.adjustForComponents(width, height);
this.layout.getEl().setSize(size.width, size.height);
this.layout.layout();
}
};
this.getLayout().layout();
layout.layout();
};
Ext.ContentPanel.prototype.getLayout = function(){
return this.layout;
};
mceFunctions = function(event,tMces,inputs){
var mceCounter = tinyMCE.idCounter;
var setMceContent;
if(mceCounter > 0){
for(var mce in tinyMCE.instances){
if(mce != 'remove'){
for(mces in tMces){
if(mces != 'remove'){
var inst = tinyMCE.instances[mce];
if (!tinyMCE.isInstance(inst))
continue;
if(eval('tinyMCE.instances[\''+mce+'\'].formTargetElementId') == mces){
switch(event){
case 'load' :
tinyMCE.removeInstance(eval('tinyMCE.instances[\''+mce+'\']'));
break;
case 'showForUpdate' :
setMceContent = eval('inputs["'+mces+'"].getValue()');
tinyMCE.execInstanceCommand(mce,'mceSetContent',mces,setMceContent);
break;
case 'showForNew' :
tinyMCE.execInstanceCommand(mce,'mceSetContent',mces,'');
break;
case 'saveData' :
setMceContent = eval('tinyMCE.getContent(\''+mce+'\')');
eval('inputs["'+mces+'"].setValue(setMceContent)');
break;
case 'selectedInstance' :
while(tinyMCE.selectedInstance.editorId != eval('tinyMCE.instances[\''+mce+'\'].editorId')){
tinyMCE.selectedInstance = eval('tinyMCE.instances[\''+mce+'\']');
}
break;
case 'unLoad' :
tinyMCE.removeInstance(eval('tinyMCE.instances[\''+mce+'\']'));
break;
}
}
}
}
}
}
}
}
3-sections.html includes tinyMCE element(s)
<div id="sectionsAdmin" class="ylayout-inactive-content">
<div id="sectionsToolbar" class="ylayout-inactive-content"></div>
<div id="sectionsContent" class="ylayout-inactive-content">
<div id="sectionsGrid" style="overflow: hidden; width: 100%; height: 100%; "></div>
</div>
</div>
<div id="hiddenElements">
</div>
<div id="sectionsDialog" style="visibility:hidden;">
<div class="x-dlg-hd">Section</div>
<div class="x-dlg-bd">
<div id="sectionsLayout" class="ylayout-inactive-content">
<div id="sectionsDialogInfo" class="ylayout-inactive-content" style="padding:2px;background:#EEEEEE">
<table cellspacing="2" cellpadding="1">
<tr>
<td class="kk-header">Section Name</td>
<td><div id="edt_name"/></td>
<td class="kk-header">Publish Status</td>
<td>
<select id="edt_published">
<option selected value="0">No</option>
<option value="1">Yes</option>
</select>
</td>
</tr>
<tr>
<td class="kk-header">Description</td>
<td colspan="3"><div id="description"/></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="sectionsLayout.js"></script>
4-sectionsLayout.js
var sectionsDialog = function(){
return {
dialog: true,
inputs: true,
mces:true,
init : function(){
...
this.inputs = new Array();
this.mces = new Array();
this.inputs['description'] = new textEditor('description',{minLength:1});
this.mces['description'] = 'description';
...
var dialogLayout = this.dialog.getLayout();
dialogLayout.beginUpdate();
...
dialogLayout.endUpdate();
mceFunctions('load',this.mces,this.inputs);
tinyMCE.execCommand('mceAddControl', true, 'description');
},
show : function(sourceEl, edit){
if (edit){
...
mceFunctions('showForUpdate',this.mces,this.inputs);
this.dialog.recordMode = 'Update';
}else{
...
mceFunctions('showForNew',this.mces,this.inputs);
this.dialog.recordMode = 'Insert';
}
this.dialog.show(sourceEl.el?sourceEl.el.dom:sourceEl.container.dom);
},
saveData: function(del){
var formCB = function(oElement, bSuccess, oResponse){
this.uploadIndicator.remove();
this.dialog.hide();
sections.gridSource.load();
sections.grid.getSelectionModel().clearSelections();
}
var forms = new Array(
{
table : 'sections',
inputs : this.inputs,
primaryKey : 'ID'
}
);
mceFunctions('saveData',this.mces,this.inputs);
this.uploadIndicator = Ext.DomHelper.append(this.dialog.footer.dom, {tag:'div',style:'display:none',html:'<form id="formData"></form>'}, true);
this.uploadIndicator.getUpdateManager().update({url:"bla.php",params:{data: /*private function for prepare data*/buildPostData(forms,del)},callback:formCB.createDelegate(this)});
sectionsDialog.deletedRecords = null;
}
}
}();
var sections = function(){
return{
layout: true,
grid:true,
gridSource:true,
init : function(){
if(newtab){
newtab.el.onClose = function(){
mceFunctions('unLoad',sectionsDialog.mces,sectionsDialog.inputs);
}
}
var parentElement = newtab ? newtab.el : 'sectionsAdmin';
...
this.layout.beginUpdate();
var buttonClicked = function(btn,e){
mceFunctions('selectedInstance',sectionsDialog.mces,sectionsDialog.inputs);
switch(btn.id){
case 'sectionAdd' :
sectionsDialog.show(btn);
break;
case 'sectionEdit' :
if(this.grid.getSelectionModel().getSelected()){
sectionsDialog.show.createDelegate(sectionsDialog)(btn,'edit');
}
break;
}
};
sectionsToolbar.add(
{
id: 'sectionAdd',
icon: 'table_add.png',
cls: 'x-btn-icon',
handler:buttonClicked.createDelegate(this),
tooltip:'Section Add'
},
'-',
{
id: 'sectionEdit',
icon: 'table_edit.png',
cls: 'x-btn-icon',
handler:buttonClicked.createDelegate(this),
tooltip:'Section Edit'
}
);
this.layout.add('north', new Ext.ContentPanel('sectionsToolbar',{closable:false}));
var Records = Ext.data.Record.create([
...
]);
var reader = new Ext.data.XmlReader({
root: 'DataSet',
record: 'Row',
totalRecords: 'TotalCount',
id: 'sid'
}, Records);
this.gridSource = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'bla.php'
}),
reader: reader,
remoteSort: true
});
var query = escape("s.ID sid,s.title,s.name,s.description,published from sections s ");
this.gridSource.setDefaultSort('s.ID', 'asc');
var cm = new Ext.grid.ColumnModel([
{
id:'sid',
header: "ID",
width: 50,
dataIndex: 'sid',
sortable: true,
align: 'right'
},{
header: "Name",
width: 100,
dataIndex: 'name',
sortable: true,
align: 'left'
},
header: "Publish State",
width: 100,
dataIndex: 'published',
sortable: true
}
]);
cm.defaultSortable = true;
this.grid = new Ext.grid.Grid('sectionsGrid', {
ds: this.gridSource,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
enableColLock:true,
monitorWindowResize: true,
autoWidth:true,
trackMouseOver: true
});
var gridDblClick = function(){
sectionsDialog.show(this,'edit');
}
this.grid.on('rowdblclick',gridDblClick);
this.grid.render();
var gridFoot = this.grid.getView().getFooterPanel(true);
var pagbar = new Ext.PagingToolbar(gridFoot, this.gridSource);
this.gridSource.load();
this.layout.add('center', new Ext.GridPanel(this.grid, {fitToFrame:true, closable:false}));
this.layout.endUpdate();
}
}
}();
sectionsDialog.init();
sections.init();
newtab.convertToNested(sections.layout);
I hope this will solve your problems about TinyMCE in Ext.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.