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

------------------------------------------------------------------------------
  It might eventually contain all the information you need to make an editor of 
your choice work with Lenya. Currently, it is incomplete. Use the source, Luke.
  
  
- === Contract between generic editor usecases (editors.insertImage, 
editors.insertLink) and editor-specific modules ===
+ == Contract between generic editor usecases (editors.insertImage, 
editors.insertLink) and editor-specific modules ==
  
- Requirements:
+ === Requirements: ===
  
   * the implementation must be completely editor-agnostic
   * some editors have very good link/image editing facilities (to set title, 
class, target, size etc.), others are very rustic. the generic usecases should 
be able to provide all those features, but they must be switchable in case an 
editor wants to use its own facilities.
   * the API must be really slick :)
  
+ === Design: ===
- Idea: provide the new usecase window with a linkData/imageData object 
containing default settings (see below), and only display form fields for those 
attributes that are (!undefined) in linkData/imageData.
+ Idea: provide the new usecase window with a linkData/imageData object 
containing default settings (see below), and only display form fields for 
attributes with value !== undefined in linkData/imageData.
+ The linkData/imageData object lives in the original editor window and is 
accessed via a callback. 
  
+ === API ===
- Problem: passing data by creating an attribute in the new window object does 
not work reliably in Firefox if the window already exists:
- {{{
-   var foo = window.open("someurl","WindowName", "someoption=no...");
-   foo.lenyaLinkData = {....};
- }}}
- 
- It seems like the window nukes the field again after it has been set :( 
resetting at a later time works, though. not nice.
- 
- Solution: provide a callback that the child window can call.... let's see how 
it works out.
-  
  
  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:
  {{{
@@ -33, +26 @@

    <img src="imagebutton.gif" 
onclick="window.open('?lenya.usecase=editors.insertImage&lenya.editorModule=$YOUREDITOR')"
 /><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">&#160;</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 the context of the opening window:
- 
- FIXME: that is awkward. the callback could more easily be provided by the 
opening window and then called via window.opener.LenyaInsertFOO...
  
  {{{
-  function LenyaInsertImage(imageData) {};
-  where 
-    imageData = { 
-      'src': "/some/path/to/an/image.jpeg", 
-      'alt': "This is a proper alt description.",
-      'title': "The title of the image",
-      'width': "150", /* in pixels */
-      'height': "233" /* in pixels */
+  /**
+    * this function is used to read default settings for the usecase view form.
+    * note: undefined values cause the respective form field to be disabled.
+    * if you don't want to provide a default, but you still want the user to
+    * change the field, pass the empty string ("") rather than undefined.
+    */
+  function LenyaGetLinkData() {
+     return {
+      'href': "/some/path/to/a/document.html",
+      'text': undefined,
+      'title': "This is what pops up if you hover over the <a/>."
     };
  }}}
  
  {{{
-  function LenyaInsertLink(linkData) {};
+  function LenyaSetLinkData(linkData) {};
-  where
+ where
     linkData = {
       'href': "/some/path/to/a/document.html",
       'text': "Click here to see the wonders of the world!",
       'title': "This is what pops up if you hover over the <a/>.",
-      'name': "someFragmentIdentifier",
-      'lang': "en"
     };
  }}}
  
- 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.
- Note that in the generic javascript, each global object or function bears the 
"Lenya" prefix to avoid naming clashes with editor-specific code.
  
- Your actual callback might look like this:
+ == Contract between validation on the server and editor modules ==
  
+ === Requirements: ===
- {{{
-  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 ===
  
  Each editor should be able to handle validation errors from the server 
gracefully. It must receive the appropriate error messages from the server, 
display them to the user, and keep the file checked out!
  
@@ -94, +64 @@

  thus it's a task for well after 2.0 is out.
  
  
- === Writing a usecase handler for your editor ===
+ == Writing a usecase handler for your editor ==
  
+ writeme!
+ 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to