Last modified by Simon Urli on 2023/10/10

<
From version < 82.1 >
edited by Manuel Smeria
on 2013/02/20
To version < 85.1 >
edited by Manuel Smeria
on 2013/02/20
>
Change comment: Document converted from syntax xwiki/1.0 to syntax xwiki/2.1

Summary

Details

Page properties
Content
... ... @@ -91,12 +91,18 @@
91 91  
92 92  === Special code for WYSIWYG edit mode ===
93 93  
94 -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 in order to prevent the performed transformation to get saved. Here is how you can prevent this behavior:
94 +Even in edit mode, the WYSIWYG editor will execute the macro and feed the result back into the document. If your macro use some JSX, these will not be loaded. But, if your macro produce some Javascript that use those JSX or 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 in order to prevent the performed transformation to get saved. Here is how you can prevent this behavior:
95 95  
96 96  {{code}}
97 -{{velocity output="no"}}
97 +{{velocity}}
98 98  #if("$xcontext.action" != "edit")
99 - #set($ok = $xwiki.jsx.use("My.Extension"))
99 +{{html}}
100 + <script type=${dq}text/javascript${dq}>
101 +//<![CDATA[
102 +... some javascript ...
103 +// ]]>
104 +</script>
105 +{{/html}}
100 100  #end
101 101  ##
102 102  ## Rest of the code.
... ... @@ -103,8 +103,6 @@
103 103  {{velocity}}
104 104  {{/code}}
105 105  
106 -Check for example the [[Lightbox Macro code>>extensions:Extension.Lightbox Macro]].
107 -
108 108  == Scripting Tips ==
109 109  
110 110  Following are few useful hints if you plan to do advanced scripting inside your wiki macros:

Get Connected