I'm converting a Sheer UI module to SPEAK, and it's generally been pretty painless except for one problem. It's a dialog that opens from a button click in the rich text editor. I can't work out how to close it and return a value.
I've tried looking at the way Sitecore's existing SPEAK dialogs do it. For example SelectMediaDialog
:
- It has a rule component called
insertButtonRule
. - The target control is set to
SelectMediaButton
and the trigger is set toclick
. - The condition / action for the associated rule is
"when
always
, set the dialog return value to componentMediaResultsListControl
selectedItemId
".
This seems fairly straight forward, but I couldn't duplicate it for my application - it just does nothing. I realise that none of the current Sitecore SPEAK dialogs are launched from the rich text editor, so this isn't really a like-for-like comparison. Perhaps it's the way I'm opening the dialog?
Here's the js command that I use to open my dialog (it's basically the same as my old Sheer UI app but with a different URL):
RadEditorCommandList["OpenMyApp"] = function(commandName, editor, tool)
{
scEditor = editor;
var range = scEditor.getSelection().getRange()
range.expand("word");
scEditor.getSelection().selectRange(range)
var html = scEditor.getSelection().getText().trim();
scEditor.showExternalDialog(
"/sitecore/client/MySpeakApp?term=" + escape(html),
null, //argument
300, //width
500, //height
scMyCallback,
null,
"My Speak App",
true, //modal
Telerik.Web.UI.WindowBehaviors.Close, // behaviors
false, //showStatusBar
false //showTitleBar
);
};
function scMyCallback(sender, returnValue)
{
if (returnValue)
scEditor.pasteHtml(returnValue.text);
}
Has anyone else written a SPEAK app for the Rich text editor? Any suggestions welcome.
So I had to go looking on the Telerik site, and this code is adapted from what I found:
It feels a little messy mixing this in with shiny new SPEAK code, but right now I'm just glad it works.