Wiki source code of HTMLConverter
Version 1.1 by Ricardo Julio Rodríguez Fernández on 2023/10/05 12:17
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{include reference="CKEditor.VelocityMacros"/}} | ||
2 | |||
3 | {{velocity wiki="false"}} | ||
4 | #set ($toHTML = $request.toHTML == 'true') | ||
5 | #set ($fromHTML = $request.fromHTML == 'true') | ||
6 | #if (($toHTML || $fromHTML) && $services.csrf.isTokenValid($request.formToken)) | ||
7 | #set ($text = "$!request.text") | ||
8 | #set ($stripHTMLEnvelope = $request.stripHTMLEnvelope == 'true') | ||
9 | #set ($output = "#ckeditor_convert($text $toHTML $fromHTML $stripHTMLEnvelope)") | ||
10 | #set ($characterEncoding = 'utf-8') | ||
11 | ## Make sure the Character Encoding response header matches the character encoding used to write the response and | ||
12 | ## compute its length. See CKEDITOR-162: Cannot convert to source code | ||
13 | #set ($discard = $response.setCharacterEncoding($characterEncoding)) | ||
14 | ## We write the output directly to the response to avoid the execution of the Rendering Transformations. Another | ||
15 | ## option would be to specify which Rendering Transformations to execute in the query string (XWIKI-13167). | ||
16 | ## See CKEDITOR-51: Icon transformations are saved by CKEditor | ||
17 | #set ($discard = $response.writer.print($output)) | ||
18 | ## The content length is measured in bytes and one character can use more than one byte. | ||
19 | #set ($discard = $response.setContentLength($output.getBytes($characterEncoding).size())) | ||
20 | ## Make sure the entire content is send back to the client. | ||
21 | #set ($discard = $response.flushBuffer()) | ||
22 | ## Make sure XWiki doesn't write any more content to the response. | ||
23 | #set ($discard = $xcontext.setFinished(true)) | ||
24 | #else | ||
25 | The service used by the CKEditor source plugin to convert between HTML and wiki syntax. | ||
26 | #end | ||
27 | {{/velocity}} |