Zohall wrote:Thank u very much Roger for your package
1- in your package there is 2 file
functions_content.php and
functions.php i cant find this sign
- Code: Select all
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
or something like that to understand your edition.
and for subsilver 2 * Apply bbcodes in editor.js this code not working
- Code: Select all
bbopen = bbopen.toLowerCase(); /* keep tags lowercase for looks */
bbclose = bbclose.toLowerCase();
{
but i dont know why not working yet. can u help me? it is very important for me.
thank u
(1) The comments with all the "at" signs are so I can easily find where I edited. These lines do nothing. I simply search for "@@@@" when I want to quickly get to a part that I edited.
It does not signify a revision code, nor IS it code. It's just a marker for me to find. You can delete those lines if they bother you.
(2) The Javascript (in editor.js) that you show is what I'm working on right now. I am trying to achieve the following:
* If nothing is selected, the cursor ends up between BBCode tags. For example, submitting the BBCode "[XYZ]" should result in "[XYZ]
|[/XYZ]" (the pipe symbol represents the cursor).
* If text is selected, then the text will be surrounded by the BBCode tags, and the selected text will REMAIN highlighted in case further BBCodes are desired on the text.
Unfortunately, either I don't know what I'm doing, or there's a bug in TinyMCE, because the "get selection", "get range", "get and restore bookmark" and other functions are not acting like they are documented, and the TinyMCE forum is absolutely no help. Nor is the TinyMCE documentation, which is sparse, terse and in some cases incorrect.
As I mentioned before, you are completely welcomed to experiment and download any code you wish from my board, but please be aware that it is NOT FINISHED YET and code you download may either not work at all, or it may be flakey (i.e. work fine in Firefox and fail in MSIE) and it may change 5 minutes after you download it.
If you want, here's part of "editor.js" (the part that does the BBCodes and smiley insertions). This is NOT all of editor.js, so look at where it starts and ends.
This is current as of right now, and it (seems) to be working here in Firefox and MSIE 8. Give it a try, but remember it is NOT finished.
- Code: Select all
/**
* Apply bbcodes
*/
function bbfontstyle(bbopen, bbclose)
{
bbopen = bbopen.toLowerCase(); /* keep tags lowercase for looks */
bbclose = bbclose.toLowerCase();
if(tinyMCE)
{
sel = tinyMCE.activeEditor.selection.getContent( {format : 'text'} );
insert_text(bbopen);
tinyMCE.activeEditor.focus();
bm = tinyMCE.activeEditor.selection.getBookmark();
if (sel != '')
{
bm = tinyMCE.activeEditor.selection.getBookmark();
insert_text(sel);
}
insert_text(bbclose);
tinyMCE.activeEditor.focus();
tinyMCE.activeEditor.selection.moveToBookmark(bm);
return;
}
else
{
theSelection = false;
var textarea = document.forms[form_name].elements[text_name];
textarea.focus();
if ((clientVer >= 4) && is_ie && is_win)
{
// Get text selection
theSelection = document.selection.createRange().text;
if (theSelection)
{
// Add tags around selection
document.selection.createRange().text = bbopen + theSelection + bbclose;
document.forms[form_name].elements[text_name].focus();
theSelection = '';
return;
}
}
else if (document.forms[form_name].elements[text_name].selectionEnd && (document.forms[form_name].elements[text_name].selectionEnd - document.forms[form_name].elements[text_name].selectionStart > 0))
{
mozWrap(document.forms[form_name].elements[text_name], bbopen, bbclose);
document.forms[form_name].elements[text_name].focus();
theSelection = '';
return;
}
//The new position for the cursor after adding the bbcode
var caret_pos = getCaretPosition(textarea).start;
var new_pos = caret_pos + bbopen.length;
// Open tag
insert_text(bbopen + bbclose);
// Center the cursor when we don't have a selection
// Gecko and proper browsers
if (!isNaN(textarea.selectionStart))
{
textarea.selectionStart = new_pos;
textarea.selectionEnd = new_pos;
}
// IE
else if (document.selection)
{
var range = textarea.createTextRange();
range.move("character", new_pos);
range.select();
storeCaret(textarea);
}
textarea.focus();
return;
}
}
/**
* Insert text at position
*/
function insert_text(text, spaces, popup)
{
if (spaces)
{
text = ' ' + text + ' ';
}
if(tinyMCE)
{
/* first, handle internet explorer */
if(is_ie && is_win)
{
if (document.forms[form_name])
{ /* parent */
tinyMCE.activeEditor.execCommand('mceInsertContent', false, text);
}
else
{ /* opener */
opener.tinyMCE.activeEditor.execCommand('mceInsertContent', false, text);
}
}
/* then service real browsers */
else
{
if (document.forms[form_name])
{ /* parent */
tinyMCE.activeEditor.selection.setContent(text);
}
else
{ /* opener */
opener.tinyMCE.activeEditor.selection.setContent(text);
}
}
}
else
{
var textarea;
if (!popup)
{
textarea = document.forms[form_name].elements[text_name];
}
else
{
textarea = opener.document.forms[form_name].elements[text_name];
}
if (!isNaN(textarea.selectionStart))
{
var sel_start = textarea.selectionStart;
var sel_end = textarea.selectionEnd;
mozWrap(textarea, text, '')
textarea.selectionStart = sel_start + text.length;
textarea.selectionEnd = sel_end + text.length;
}
else if (textarea.createTextRange && textarea.caretPos)
{
if (baseHeight != textarea.caretPos.boundingHeight)
{
textarea.focus();
storeCaret(textarea);
}
var caret_pos = textarea.caretPos;
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
}
else
{
textarea.value = textarea.value + text;
}
if (!popup)
{
textarea.focus();
}
}
}
Don't worry. One day soon, it will be perfected and finished. I can see why the PHPBB team didn't work on it... pounding one's head against the wall for weeks on end is not much fun!
-- Roger