Showing results for 
Show  only  | Search instead for 
Did you mean: 
Community Member

LTI to replace all content in RCE


Currently, any LTI launched from the RCE that returns content back to Canvas inserts at the current position of the mouse cursor. I don’t see any obvious way to be able to replace all HTML/content in the RCE with content returned from the LTI.

I was wondering if this is possible? Eg) a user performs some action in the LTI and submits it back to replace all the current content in the RCE.

I had a look here: but also couldn’t see anything obvious.

Has anyone come across this issue/solution before?

Labels (2)
0 Kudos
5 Replies
Community Participant

If the user has selected some text before launching the LTI tool then the selected text will be replaced by the returned content, but I haven't seen a way of replacing all of the content.

Community Champion


I have not verified this, but I was looking around today to see if it was possible to send all of the contents to an editor button to see if I could build a button to replace a Windows AutoHotKey script I have. When I found the following, it reminded me that I had read a similar question this week, so I thought I would share what I found.

Under Editor Button Placement, there was this note

Pro-tip: Use the com.instructure.Editor.contents and/or com.instructure.Editor.selection variable substitutions to include the full RCE contents and/or highlighted selection, respectively, in the launch request.

When you look at the variable substitutions page, for com.instructure.Editor.contents, it looks like it sends the entire contents. Whether it does that in HTML (what I would need) or just plain text is not stated.

That doesn't necessarily replace everything, but if you had it all selected when the button was clicked, as Matthew suggested, it might.

Community Member

Hi James and Matthew,

Thanks for your responses. Yes I did notice the variable substitution values, which can pass in the full or highlighted contents to the LTI. I utilise this currently to display the contents of the RCE in my LTI. For context the LTI I'm working on is a templating tool. 
However, when I send the request back, it inserts the content (rather than replacing all). I will need to test Matthew's suggestion about selecting all of the content first. 

Would it be possible to automatically select all of the content when the button for my LTI is clicked?

Community Champion


This may be possible with custom JavaScript, but certainly not trivial. You would need to find a way to determine when the LTI button was pressed and intercept Canvas' processing of it. Then you would select all and then fire Canvas' event handler.

Can I ask more about the process? Is it possible to invoke it in a different way than as an RCE button and have your LTI write the content to the server through the API?

Community Member

We're written a small tool for easily inserting content into the RCE and it uses this functionality. You can see it getting the current selection through the LTI variables and it allows the current selection to be wrapped by the snippet: