<
From version < 69.2 >
edited by simba
on 2009/11/16
To version < 70.1 >
edited by JeromeVelociter
on 2009/11/16
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.simba
1 +XWiki.JeromeVelociter
Content
... ... @@ -119,19 +119,19 @@
119 119  
120 120  #warning("needs more explanation or a example.")
121 121  
122 -Even in edit mode, the WYSIWYG editor will execute the macro and feed the result back into the document. So for a macro to work correctly in the WYSIWYG editor, a macro may need a special safeguard:
122 +Even in edit mode, the WYSIWYG editor will execute the macro and feed the result back into the document. If your macro includes a JavaScript extension that manipulate the document's DOM (injecting new elements, moving existing elements, removing elements, etc.), you may want to protect the content in WYSIWYG edit mode the performed transformation do not get saved. Here is how you can prevent this behavior
123 123  
124 124  {code}
125 125  {{velocity output="no"}}
126 -#if($context.action == 'edit')
127 - ## Code for WYSIWYG edit mode.
128 -#else
129 - ## Code for normal display.
126 +#if("$context.action" != "edit")
127 + #set($ok = $xwiki.jsx.use("My.Extension"))
130 130  #end
129 +##
130 +## Rest of the code.
131 131  {{velocity}}
132 132  {code}
133 133  
134 -The code for WYSIWYG edit mode is typically a reduced version of the normal code. It shares the appearance but lacks certain interactivity which is not needed and may even cause trouble in the edit mode.
134 +Check for example the [[code:Macros.LightboxMacro>>Lightbox Macro code]].
135 135  
136 136  1.1 Scripting Tips
137 137  

Get Connected