Wiki-Quellcode von ConfigSheet
Zuletzt geändert von Daniel Herrmann am 2025/06/22 18:46
Verstecke letzte Bearbeiter
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | {{include reference="CKEditor.VelocityMacros" /}} |
| 2 | |||
| 3 | {{velocity}} | ||
| 4 | #if ($xcontext.action == 'edit') | ||
| 5 | {{html clean="false"}} | ||
| 6 | <div class="xform half"> | ||
| 7 | #displayCKEditorConfig($doc 'edit') | ||
| 8 | </div> | ||
| 9 | {{/html}} | ||
| 10 | #end | ||
| 11 | {{/velocity}} | ||
| 12 | |||
| 13 | {{velocity wiki="false"}} | ||
| 14 | #if ($xcontext.action != 'edit') | ||
| 15 | #if ($xcontext.action == 'get') | ||
| 16 | #set ($discard = $response.setContentType('application/javascript')) | ||
| 17 | #end | ||
| 18 | #set ($isTemporaryAttachmentSupported = "$!services.temporaryAttachments" != '') | ||
| 19 | #set ($htmlSyntax = ${services.wysiwyg.HTMLSyntax.toIdString()|'annotatedxhtml/1.0'}) | ||
| 20 | #set ($isHTML5 = !$htmlSyntax.equals('annotatedxhtml/1.0')) | ||
| 21 | ## Global default configuration that doesn't depend on the edited content and that needs Velocity code for evaluation. | ||
| 22 | ## Static global configuration (that doesn't need Velocity) should be put in config.js . The default instance level | ||
| 23 | ## configuration is in EditSheet. | ||
| 24 | #set ($customConfig = { | ||
| 25 | 'editorplaceholder': $services.localization.render('ckeditor.content.placeholder'), | ||
| 26 | 'htmlSyntax': $htmlSyntax, | ||
| 27 | 'stylesSet': "#if ($isHTML5)html5#{else}html4#end", | ||
| 28 | 'xwiki-office': { | ||
| 29 | 'enabled': $services.officemanager.isConnected() | ||
| 30 | }, | ||
| 31 | 'xwiki-realtime': { | ||
| 32 | 'stylesheets': [ | ||
| 33 | $services.webjars.url('org.xwiki.platform:xwiki-platform-realtime-wysiwyg-webjar', 'webjar.bundle.min.css') | ||
| 34 | ] | ||
| 35 | }, | ||
| 36 | 'xwiki-upload': { | ||
| 37 | 'isTemporaryAttachmentSupported': $isTemporaryAttachmentSupported | ||
| 38 | } | ||
| 39 | }) | ||
| 40 | ## CKEditor uses '-' (dash) as locale separator (between the language code and the country code). | ||
| 41 | #set ($customConfig.language = $xcontext.locale.toString().toLowerCase().replace('_', '-')) | ||
| 42 | #set ($configObj = $doc.getObject('CKEditor.ConfigClass')) | ||
| 43 | #foreach ($propName in $configObj.propertyNames) | ||
| 44 | #if ($propName != 'advanced') | ||
| 45 | #set ($discard = $customConfig.put($propName, $configObj.getValue($propName))) | ||
| 46 | #end | ||
| 47 | #end | ||
| 48 | CKEDITOR.editorConfig = function(config) { | ||
| 49 | CKEDITOR.tools.extend(config, $jsontool.serialize($customConfig), true); | ||
| 50 | $!doc.getValue('advanced') | ||
| 51 | }; | ||
| 52 | #end | ||
| 53 | {{/velocity}} |