Welcome Guest Search | Active Topics | Sign In | Register

UploadAndInsertImage function Options
Arnold Bailey
Posted: Saturday, September 20, 2008 3:44:05 PM
Rank: Advanced Member
Groups: Member

Joined: 8/4/2007
Posts: 42
I need to modify the Editor to do an Upload and Insert an Image function instead of the current Url input function. I have the AJAXUploader working properly as per your Attachements Demo. What I need to do now is upon FileUploaded Event somehow insert at the cursor in the Editor the link to the image in the FinalFileLocation directory.

<img src="Upload/image.jpg" />

This is so on a website the user can upload a file to display in the editor and eventually post. When they post we'll add the uploaded file as CID: attachements to the message.

I just don't get how to insert text programatically at the cursor while editing
eo_support
Posted: Saturday, September 20, 2008 4:10:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,193
Hi,

I believe you can call execCommand method on the editor to insert any HTML at the cursor:

http://www.essentialobjects.com/ViewDoc.aspx?t=JSDoc.Public.Editor.execCommand.html

You would use "InsertHTML" command. You will need to use some kind of AJAX solution that captures the Uploader's FileUploaded event (which you probably already have in place) and then pass the Url of the uploaded files to the client side in order to call execCommand though.

Thanks
Arnold Bailey
Posted: Sunday, September 21, 2008 1:48:14 PM
Rank: Advanced Member
Groups: Member

Joined: 8/4/2007
Posts: 42
I've been able to pass the image path information after the Upload using the CallBackPanel.Execute event in the CallbackEventArgs Data property. On the Client side I have a CallbackAfterUpdate event handler that finds the editor and does the insert.

Code: JavaScript
function after_update(sender, data)
    {
      if (data.length > 0)
      {
        oEditor = eo_GetObject('HtmlEditor1');
        oEditor.execCommand('InsertHTML','<img src="' + data + '" />');
      }
    }


This inserts the image, but it _always inserts it in the first position of the editor field instead of at the cursor insertion point. Can't seem to get InsertHTML to do anything else.
eo_support
Posted: Sunday, September 21, 2008 2:12:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,193
That's interesting. We will look into it and see what we can find.
Arnold Bailey
Posted: Monday, September 22, 2008 7:19:23 AM
Rank: Advanced Member
Groups: Member

Joined: 8/4/2007
Posts: 42
More and further. It inserts in the first position with IE7.
With Firefox and Safari it inserts correctly at the cursor position.
Opera won't accept the added toolItems. Opera also will not run your AJAXUploader Toolbar demo.
eo_support
Posted: Monday, September 22, 2008 7:20:37 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,193
Thanks for the additional information!
eo_support
Posted: Wednesday, September 24, 2008 12:19:43 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,193
Both issues have been fixed in build 2008.0.35 (6.0.35).


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.