Dear Wiki user, You have subscribed to a wiki page or wiki category on "Lenya Wiki" for change notification.
The following page has been changed by JörnNettingsmeier: http://wiki.apache.org/lenya/GenericEditorAPI ------------------------------------------------------------------------------ === Contract between generic editor usecases (editors.insertImage, editors.insertLink) and editor-specific modules === - Each editor module can access and use the generic insertImage and insertLink implementations in the editors module: + Each editor module can access and use the generic insertImage and insertLink implementations in the editors module. The most common way to do that is to use a javascript window.open call to create a separate window for the usecase: {{{ + <img src="linkbutton.gif" onclick="window.open('?lenya.usecase=editors.insertLink&lenya.editorModule=$YOUREDITOR')" /><br /> + <img src="imagebutton.gif" onclick="window.open('?lenya.usecase=editors.insertImage&lenya.editorModule=$YOUREDITOR')" /><br /> - <!-- This is an editor button --> - <a href="?lenya.usecase=editors.insertImage&lenya.editorModule=youreditor">Insert Image</a><br /> - <a href="?lenya.usecase=editors.insertLink&lenya.editorModule=youreditor">Insert Link</a><br /> }}} + The "lenya.editorModule" request parameter is necessary so that the correct javascript callback functions can be included by the generic usecase view: {{{ <script type="text/javascript" src="/modules/{$editorModule}/javascript/editorCallbacks.js"> </script> }}} - each editor module that wishes to use the generic usecase implementations '''must''' provide the following callbacks in a file named {{{resources/javascript/editorCallbacks.js}}}: + Each editor module that wishes to use the generic usecase implementations '''must''' provide the following callbacks in a file named {{{resources/javascript/editorCallbacks.js}}}: {{{ function LenyaInsertImage(imageData) {}; where @@ -42, +42 @@ }; }}} - These functions need to take care of passing the data back to the editor. + These functions need to take care of passing the data back to your editor. + The passing of objects instead of parameter lists allows for easy extension if necessary. - In the generic javascript, each global object or function bears the "Lenya" prefix to avoid naming clashes with editor-specific code. + Note that in the generic javascript, each global object or function bears the "Lenya" prefix to avoid naming clashes with editor-specific code. - The passing of objects instead of parameter lists allows for easy extension if necessary. + Your actual callback might look like this: + + {{{ + function LenyaInsertLink(linkData) { + // transform the linkData into something your editor understands + var address = linkData['href']; + var title = linkData['title']; + var text = linkData['text']; + // call into the parent window: + window.opener.YourEditor.setSelectedText(text); + window.opener.YourEditor.createLinkAtSelected(href,title,'',''); + window.opener.YourEditor.selectNone(); + } + }}} === Contract between validation on the server and editor modules === --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
