Changes for page Writing XWiki Rendering Macros in wiki pages
Last modified by Clément Desableau on 2023/06/01
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. simba1 +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. Sofor amacro to workcorrectlyinthe WYSIWYG editor,amacro mayneedaspecialsafeguard: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 - TheodeforWYSIWYGeditmode is typically a reducedversion ofthenormalcode. It sharesthe appearance butlacks certain interactivity which is notneededand may evencause troublein the edit mode.134 +Check for example the [[code:Macros.LightboxMacro>>Lightbox Macro code]]. 135 135 136 136 1.1 Scripting Tips 137 137