deputycheek
asked on
Wrapping bbcode around selected text in a textarea
I want a text area to have B, I, U and smilies. I do not want to use any premade editors like tiny_mce or ckeditor.
I've been searching forever and haven't found a working example code that will cross between all the browsers. All the premade editors load slow and you can see the textarea for a second or two before it loads the editor.
How do I do this? I suck with javascript which is why I'm asking here.
Also, what editor does EE use?
I've been searching forever and haven't found a working example code that will cross between all the browsers. All the premade editors load slow and you can see the textarea for a second or two before it loads the editor.
How do I do this? I suck with javascript which is why I'm asking here.
Also, what editor does EE use?
ASKER
I have a simple text area. I would like to click a button, and have bbcode wrapped around the text that is selected in my textarea. If there is no text selected, then I would like to insert the bbcode at the cursor point.
OK, , You are now only using the "bbcode" as what shows in the textarea, and you want buttons to place the bbcode (I guess 4 buttons, one for Bold, one for Italic, one for Underline, and one for Smiles).
So, if you have this line in the textarea -
this is a test
and you click the bold button it will show -
this is a test
I may can do something for that, but you have the word "smilies" in your question, which is plural, and might mean more than one smilie, this may be more difficult since if there is more than one, some sort of menu or choice needs to be shown.
So if they click the Smilie button the textarea would show -
this is a test :-)
I will see what I can find, I have done this before, but it is availible in more complete PHP Bulletin Board Classes
So, if you have this line in the textarea -
this is a test
and you click the bold button it will show -
this is a test
I may can do something for that, but you have the word "smilies" in your question, which is plural, and might mean more than one smilie, this may be more difficult since if there is more than one, some sort of menu or choice needs to be shown.
So if they click the Smilie button the textarea would show -
this is a test :-)
I will see what I can find, I have done this before, but it is availible in more complete PHP Bulletin Board Classes
sorry, I did not realize that this messed up EE interface did bbcode, I will try again, maybe It will show in the "code" input
ok I guess not, , so I will have to use alternate way -
So, if you have this line in the textarea -
this is a test
and you click the bold button it will show as -
this is a test(b)(/b)
where the ( would be a [
ok I guess not, , so I will have to use alternate way -
So, if you have this line in the textarea -
this is a test
and you click the bold button it will show as -
this is a test(b)(/b)
where the ( would be a [
ASKER
it would be like this...
textarea:
this is a test
then if you click and highlight "is a" in the text area, and then hit the bold button
textarea:
this (b)is a(/b) test
however, if you just clicked the button without highlighting text then:
textarea:
this is a test(b)(/b)
As far as the smilies, I can open up a small popup and when someone clicks on a certain smiley then it will put the code for that smiley in the box at cursor position.
textarea:
this is a test
then if you click and highlight "is a" in the text area, and then hit the bold button
textarea:
this (b)is a(/b) test
however, if you just clicked the button without highlighting text then:
textarea:
this is a test(b)(/b)
As far as the smilies, I can open up a small popup and when someone clicks on a certain smiley then it will put the code for that smiley in the box at cursor position.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the code but do you mind commenting it a bit so i can learn from it? I'll try it out this evening. Thanks again
ASKER
That code works perfect. Thanks so much
First, I do not really understand what you are asking to do in your question, , I guess it has to do with = "I want a text area to have Bold, Italic, Underline and smilies", but in your question you have = "bbcode around" bulletin board code is much different than visual javascript editors like tiny_mce.
There are many visual javascript textarea editors, and they all took alot of time and effort to get to work correctly, you may be better off if you use a lightweight editor like widgEditor, or you may have to spend time developing your own javascript editor.
Can you give us some more about what the minimum of functioning you might need, although, I probpally do not have the time to do a full editor.