Last modified by Clément Desableau on 2023/06/01

<
From version < 83.1 >
edited by Denis Gervalle
on 2013/02/20
To version < 84.1 >
edited by Denis Gervalle
on 2013/02/20
>
Change comment: Update the WYSIWYG special code advice

Summary

Details

Page properties
Content
... ... @@ -99,12 +99,18 @@
99 99  
100 100  1.1.1 Special code for WYSIWYG edit mode
101 101  
102 -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:
102 +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:
103 103  
104 104  {code}
105 -{{velocity output="no"}}
105 +{{velocity}}
106 106  #if("$xcontext.action" != "edit")
107 - #set($ok = $xwiki.jsx.use("My.Extension"))
107 +{{html}}
108 + <script type=${dq}text/javascript${dq}>
109 +//<![CDATA[
110 +... some javascript ...
111 +// ]]>
112 +</script>
113 +{{/html}}
108 108  #end
109 109  ##
110 110  ## Rest of the code.
... ... @@ -111,8 +111,6 @@
111 111  {{velocity}}
112 112  {code}
113 113  
114 -Check for example the [Lightbox Macro code>extensions:Extension.Lightbox Macro].
115 -
116 116  1.1 Scripting Tips
117 117  
118 118  Following are few useful hints if you plan to do advanced scripting inside your wiki macros:
... ... @@ -193,4 +193,3 @@
193 193  #set($greetUser="$!xcontext.macro.params.greetUser")
194 194  {code}
195 195  
196 -

Get Connected