Modifications pour le document VelocityMacros
Modifié par Florent Charton le 2026/03/13 11:04
Depuis la version 2.1
modifié par Florent Charton
sur 2024/08/08 18:44
sur 2024/08/08 18:44
Commentaire de modification :
Install extension [org.xwiki.platform:xwiki-platform-ckeditor-ui/15.10.11]
À la version 1.1
modifié par superadmin
sur 2022/06/20 08:49
sur 2022/06/20 08:49
Commentaire de modification :
Install extension [org.xwiki.contrib:application-ckeditor-ui/1.63.1]
Résumé
-
Propriétés de la Page (2 modifications, 0 ajouts, 0 suppressions)
Détails
- Propriétés de la Page
-
- Auteur du document
-
... ... @@ -1,1 +1,1 @@ 1 - xwiki:XWiki.fcharton1 +XWiki.superadmin - Contenu
-
... ... @@ -10,8 +10,7 @@ 10 10 #if ($toHTML) 11 11 #set ($source = { 12 12 'documentReference': $doc.documentReference, 13 - 'syntax': $sourceSyntax, 14 - 'restricted' : $request.wysiwygRestricted 13 + 'syntax': $sourceSyntax 15 15 }) 16 16 #if ($fromHTML) 17 17 #set ($source.html = $text) ... ... @@ -78,15 +78,14 @@ 78 78 ## editor is used. 79 79 #set ($macro.previousDisplayMode = 'edit') 80 80 #end 81 - #set ($restricted = "$!source.restricted" == 'true') 82 82 #if ($source.html) 83 - #set ($html = $services.wysiwyg.parseAndRender($source.html, $source.syntax, $source.documentReference , $restricted))81 + #set ($html = $services.wysiwyg.parseAndRender($source.html, $source.syntax, $source.documentReference)) 84 84 #if ("$!html" == '' && $html != '') 85 85 ## Before XWiki 11.9RC1 (see XWIKI-16737) 86 86 #set ($html = $services.wysiwyg.parseAndRender($source.html, $source.syntax.toIdString())) 87 87 #end 88 88 #else 89 - #set ($html = $services.wysiwyg.toAnnotatedXHTML($source.content, $source.syntax, $source.documentReference , $restricted))87 + #set ($html = $services.wysiwyg.toAnnotatedXHTML($source.content, $source.syntax, $source.documentReference)) 90 90 #if ("$!html" == '' && $html != '') 91 91 ## Before XWiki 11.9RC1 (see XWIKI-16737) 92 92 #set ($html = $services.wysiwyg.toAnnotatedXHTML($source.content, $source.syntax.toIdString())) ... ... @@ -106,6 +106,10 @@ 106 106 #set ($discard = $xwiki.linkx.use($url, {'type': 'text/css', 'rel': 'stylesheet'})) 107 107 #end 108 108 107 +#macro (importCKEditorCSS $path $evaluate) 108 + #ckeditor_importCSS('org.xwiki.contrib' 'application-ckeditor-webjar' $path $evaluate) 109 +#end 110 + 109 109 #macro (importCKEditorResources) 110 110 #set ($discard = $xwiki.ssx.use('CKEditor.EditSheet')) 111 111 ## Add the version of each JavaScript dependency of CKEditor Integration to the URL used to load the CKEditor in order ... ... @@ -112,7 +112,7 @@ 112 112 ## to make sure the browser cache is invalidated when one of these versions changes (e.g. when we upgrade XWiki or one 113 113 ## of these dependencies but the CKEditor version remains the same). 114 114 #set ($discard = $xwiki.jsx.use('CKEditor.EditSheet', { 115 - 'v': $services.extension.installed.getInstalledExtension('org.xwiki. platform:xwiki-platform-ckeditor-ui',117 + 'v': $services.extension.installed.getInstalledExtension('org.xwiki.contrib:application-ckeditor-ui', 116 116 "wiki:$xcontext.database").version.value, 117 117 'xwiki-version': $services.extension.core.getCoreExtension( 118 118 'org.xwiki.platform:xwiki-platform-tree-webjar').version.value, ... ... @@ -121,7 +121,8 @@ 121 121 'bs3typeahead-version': $services.extension.installed.getInstalledExtension('org.webjars.npm:bootstrap-3-typeahead', 122 122 "wiki:$xcontext.database").version.value 123 123 })) 124 - #ckeditor_importCSS('org.xwiki.platform' 'xwiki-platform-ckeditor-plugins' 'webjar.bundle.min.css' true) 126 + #importCKEditorCSS('plugins/xwiki-resource/resourcePicker.min.css' true) 127 + #importCKEditorCSS('plugins/xwiki-macro/macroWizard.min.css' true) 125 125 ## Tree styles needed for the document/attachment tree picker. 126 126 #set ($discard = $xwiki.linkx.use($services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar', 'tree.min.css', 127 127 {'evaluate': true}), {'type': 'text/css', 'rel': 'stylesheet'})) ... ... @@ -131,49 +131,40 @@ 131 131 132 132 #macro (ckeditor $parameters) 133 133 #importCKEditorResources 134 - ## 137 + #set ($sourceDocumentReference = $parameters.attributes.get('data-sourceDocumentReference')) 138 + ## Use the current document as source document, if possible, because it may contain unsaved changes (e.g. changes 139 + ## coming from a template specified in the URL or from other URL parameters). This is important for instance in order 140 + ## to ensure that for new (unsaved) documents we use the syntax that has been copied from the template and not the 141 + ## default wiki syntax. 142 + #if (!$sourceDocumentReference || $sourceDocumentReference.equals($tdoc.documentReference)) 143 + #set ($sourceDocument = $tdoc) 144 + #set ($sourceDocumentReference = $tdoc.documentReference) 145 + #else 146 + #set ($sourceDocument = $xwiki.getDocument($sourceDocumentReference)) 147 + #end 135 135 #set ($escapedName = $escapetool.xml($parameters.attributes.name)) 136 136 <input value="$!escapedName" name="RequiresHTMLConversion" type="hidden"/> 137 - ## 138 - #set ($syntaxId = $parameters.attributes.get('data-syntax')) 139 - <input value="$!escapetool.xml($syntaxId)" name="$!{escapedName}_syntax" type="hidden"/> 140 - ## 150 + <input value="$!escapetool.xml($sourceDocument.syntax.toIdString())" name="$!{escapedName}_syntax" type="hidden"/> 141 141 ## Chrome doesn't cache the enabled/disabled state of the form fields so we must store this state in the value of 142 142 ## another form field. For instance, the enabled/disabled state of the RequiresHTMLConversion hidden input 143 143 ## determines which editor mode (WYSIWYG vs. Source) is loaded initially. 144 144 ## See CKEDITOR-34: Wiki syntax gets escaped when you click "Back" in the browser 145 145 <input value="" name="$!{escapedName}_cache" type="hidden" class="cache"/> 146 - ## 147 147 #set ($discard = $parameters.attributes.putAll({ 148 148 'class': "$!parameters.attributes.get('class') ckeditor-textarea loading", 149 - 'spellcheck': false 158 + 'spellcheck': false, 159 + 'data-sourceDocumentSyntax': $sourceDocument.syntax.toIdString() 150 150 })) 151 - ## 152 - #set ($sourceDocumentReference = $parameters.attributes.get('data-sourceDocumentReference')) 153 - #if (!$sourceDocumentReference) 154 - #set ($sourceDocumentReference = $tdoc.documentReference) 155 - #end 156 - #set ($source = { 157 - 'documentReference': $sourceDocumentReference, 158 - 'syntax': $syntaxId, 159 - 'content': $parameters.content, 160 - 'restricted': $parameters.attributes.data-restricted 161 - }) 162 - ## 163 - ## Disable the file upload and drag & drop when the current user doesn't have edit right on the source document, if 164 - ## the source is restricted. This is the case for instance when an user with comment right adds a comment to a page 165 - ## they don't have edit right on. They are allowed to add the comment but they can't upload files because that 166 - ## requires edit right. We check if the source is in restricted mode because in some cases (such as for Change Request 167 - ## Application) we want to allow file upload even if the current user doesn't have edit right on the source document. 168 - #if ($source.restricted == 'true' && !$services.security.authorization.hasAccess('edit', $source.documentReference)) 169 - #set ($parameters.attributes.data-upload-disabled = 'true') 170 - #end 171 - ## 172 172 <textarea 173 173 #foreach ($entry in $parameters.attributes.entrySet()) 174 174 $entry.key="$!escapetool.xml($entry.value)" 175 175 #end 176 176 ## We render the content sheet at the end because the edited content can overwrite the variables used by this macro. 166 + #set ($source = { 167 + 'documentReference': $sourceDocumentReference, 168 + 'syntax': $sourceDocument.syntax, 169 + 'content': $parameters.content 170 + }) 177 177 #set ($content = "#ckeditor_renderContentSheet($source)") 178 178 >$!escapetool.xml($content)</textarea> 179 179 #end ... ... @@ -198,7 +198,10 @@ 198 198 #end 199 199 200 200 #macro (displayCKEditorConfigPropertyValue $configDoc $propName $action) 201 - #unwrapXPropertyDisplay($configDoc.display($propName, $action)) 195 + #set ($output = $configDoc.display($propName, $action)) 196 + #set ($output = $stringtool.removeStart($output, '{{html clean="false" wiki="false"}}')) 197 + #set ($output = $stringtool.removeEnd($output, '{{/html}}')) 198 + $output 202 202 #end 203 203 204 204 #macro (displayCKEditorConfig $configDoc $action)