It already has a link button. The way the editor works though is via the execCommand() method, which can only insert valid HTML tags, not bb code tags like you say you want. But, what really matters I would think is the value that the form submits. For that, the value of the hidden field (configured via the fieldname argument of the writeRichText function) could be altered using regular expressions, or some other string altering method. For example:
Code:
<form name="RTEDemo" action="demo.htm" method="post" onsubmit="return submitForm();">
<script language="JavaScript" type="text/javascript">
<!--
function submitForm() {
//make sure hidden and iframe values are in sync before submitting form
//to sync only 1 rte, use updateRTE(rte)
//to sync all rtes, use updateRTEs
updateRTE('rte1');
//updateRTEs();
document.RTEDemo.rte1.value = document.RTEDemo.rte1.value.replace(/</g, '[').replace(/>/g, ']');
alert("rte1 = " + document.RTEDemo.rte1.value);
//change the following line to true to submit form
return false;
}
//Usage: initRTE(imagesPath, includesPath, cssFile)
initRTE("images/", "", "");
//-->
</script>
<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>
<script language="JavaScript" type="text/javascript">
<!--
//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
writeRichText('rte1', 'here's the "<em>preloaded</em> <b>content</b>"', 400, 200, true, false);
//-->
</script>
<p>Click submit to show the value of the text box.</p>
<p><input type="submit" name="submit" value="Submit"></p>
</form>
If you check the View Source checkbox, you will see HTML code. But if you submit, you will see the value transformed to bb code. If this form were to actually submit (in this example it only alerts, returning false on the submission) it would submit the bb code version.
Bookmarks