There might be another way. Take a look at this example. http://tinymce.moxiecode.com/examples/example_23.php
You can use the links at the bottom (Show,Hide,Bold,Get Contents etc) as a menu (may require some styling). Then, get the id of the textarea currently in focus and pass it to the menu (#current) and use it to change that textarea.
To achieve what you are describing:
- First disable all the indivudual TinyMCE menu items.
- Once they are disabled, create your own TinyMCE menu in HTML and style it accordingly.
- Determine which TinyMCE textarea in focus
- Apply the actions from your new menu to the Textarea that is focused
Now for some code (may require some debugging...)
First, Initialize TinyMCE and disable menus.
tinyMCE configs
({
mode : "textareas",
theme : "advanced",
editor_selector : "editable"
theme_advanced_buttons1 : "",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "botton",
theme_advanced_statusbar_location : "bottom" });
I think you can also edit the _addToolbars function in tiny_mce/themes/advanced/editor_template_src.js and then pack it.
Then determine the text area that is currently in focus using jQuery bind:
$().ready(function() {
var current;
$('.editable').focus(
current = this.id;
);
$('.editable').blur(
//maybe hide the menu (?)
);
}
Then create the HTML with our textareas and the menu
<form method="post" action="somepage">
<div id="independent_menu">
<!-- The Menu, Please Style Accordingly -->
<a href="javascript:;" onmousedown="$('#current').tinymce().show();">[Show]</a>
<a href="javascript:;" onmousedown="$('#current').tinymce().hide();">[Hide]</a>
<a href="javascript:;" onmousedown="$('#current').tinymce().execCommand('Bold');">[Bold]</a>
<a href="javascript:;" onmousedown="alert($('#current').html());">[Get contents]</a>
<a href="javascript:;" onmousedown="alert($('#current').tinymce().selection.getContent());">[Get selected HTML]</a>
<a href="javascript:;" onmousedown="alert($('#current').tinymce().selection.getContent({format : 'text'}));">[Get selected text]</a>
<a href="javascript:;" onmousedown="alert($('#current').tinymce().selection.getNode().nodeName);">[Get selected element]</a>
<a href="javascript:;" onmousedown="$('#current').tinymce().execCommand('mceInsertContent',false,'<b>Hello world!!</b>');">[Insert HTML]</a>
<a href="javascript:;" onmousedown="$('#current').tinymce().execCommand('mceReplaceContent',false,'<b>{$selection}</b>');">[Replace selection]</a>
</div>
<!-- The Text Areas -->
<textarea class="editable" id="one">Some Text Here</textarea>
<textarea class="editable" id="two">Yet another text area</textarea>
<textarea class="editable" id="three">Final Text Area</textarea>