Hi, I have all my users pics saved in the same directory, with a list of each users pics in a DB. So, I want to make my own "insert images" interface. Then when I got the HTML, I would like to insert it into the FCKeditor. I hope you understand what I mean, I'm sort of looking for a simple function like FCK.EditorWindow.insertHTML("<img src='a.gif'>");
Thanks!
Thanks!
RE: Inserting HTML manually
This is how i insert HTML at the cursor within FCKEditor: I didnt separate my own code from what anyone elses needs will be... That said, It works for me..., obviously change ID's or whatever else.

Background Info on what I'm doing:
I have a mailmerge select box with an id="mailMerge" that has stuff like "Full Name", "First Name" "Last Name", respectivly the values of those options are "[[:fullName:]]", "[[:firstName:]]", "[[:lastName:]]" ... The goal is to insert those values into the FCKEditor (or whatever field the user is on) where the cursor is. (hence currentField = id...)
It works in IE cuz of the createRange on the function insertText(){ .. } It doesnt work in FF... there _is_ a way to insert it into firefox. though i'm to lazy to debug my way through it. If the need arises, i'll post that solution... if anyone else figures it out, please post it for the rest of us
Hope it helps!
function insertText(){
var str = document.getElementById('mailMerge').value;
if(str == "blank"){
return false;
}
document.getElementById('mailMerge').value = 'blank';
if(currentField == 'htmlBody'){
if (document.selection) {
var oEditor = FCKeditorAPI.GetInstance('htmlBody') ;
var jasonB = oEditor.EditorDocument.selection;
jasonB.clear(); var sel = jasonB.createRange();
sel.text = str;
} else {
alert('This browser does not support this feature.');
}
return true;
}
function insertAtCursor(myField, myValue) {
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
//MOZILLA/NETSCAPE support
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
} else {
myField.value += myValue;
}
}
insertAtCursor(document.getElementById(currentField), str);
alert(currentField);
}
function updateCurrentField(id){
currentField = id;
}
function DoSomething( instance ) {
currentField = instance.Name;
//alert('currentField just changed to '+currentField);
}
function FCKeditor_OnComplete( editorInstance )
{
editorInstance.Events.AttachEvent( 'OnSelectionChange', DoSomething ) ;
}
RE: Inserting HTML manually
You can find it out in the documentation: http://wiki.fckeditor.net/Developer%27s ... script_API
FCK.InsertHTML