Changes for page ConfigSheet

From version 1.1
edited by superadmin
on 2025/02/21 15:01
Change comment: Install extension [org.xwiki.platform:xwiki-platform-ckeditor-ui/15.10.11]
To version 2.1
edited by Monika Leung
on 2025/04/05 16:45
Change comment: Install extension [org.xwiki.platform:xwiki-platform-ckeditor-ui/17.2.0]

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.superadmin
1 +xwiki:XWiki.leung
Content
... ... @@ -18,26 +18,6 @@
18 18   #set ($isTemporaryAttachmentSupported = "$!services.temporaryAttachments" != '')
19 19   #set ($htmlSyntax = ${services.wysiwyg.HTMLSyntax.toIdString()|'annotatedxhtml/1.0'})
20 20   #set ($isHTML5 = !$htmlSyntax.equals('annotatedxhtml/1.0'))
21 - ## Verify if the office import feature is supported.
22 - ##
23 - ## It's not enough to check if the Office server is connected because the 'importOfficeAttachment' API is available
24 - ## only since XWiki 9.8 (see XWIKI-14739) while the CKEditor Integration extension can be installed on older versions
25 - ## of XWiki where the users won't be able to import office documents from the CKEditor even if the Office server is
26 - ## connected. On these older versions the users will have to use the Create Page dialog with the Page from Office
27 - ## option.
28 - ##
29 - ## We check if the 'importOfficeAttachment' API is available by trying to import an attachment that doesn't exist
30 - ## using the Office Viewer macro, which should output an error message saying that the attachment doesn't exist. This
31 - ## way the Office server is not actually called so there's no risk of slowing down or blocking the CKEditor load (see
32 - ## CKEDITOR-294).
33 - #set ($missingAttachmentReference = $services.model.resolveAttachment('CKEditor.OfficeImporter@doesNotExist.txt'))
34 - #set ($officeServerConnected = $services.officemanager.isConnected())
35 - #if ("$!officeServerConnected" == '')
36 - ## Before XWiki 12.3 and 11.10.5
37 - #set ($officeServerConnected = $services.officemanager.serverState == 'Connected')
38 - #end
39 - #set ($officeImportSupported = $officeServerConnected &&
40 - "$!services.wysiwyg.importOfficeAttachment($missingAttachmentReference, {'useOfficeViewer': true})" != '')
41 41   ## Global default configuration that doesn't depend on the edited content and that needs Velocity code for evaluation.
42 42   ## Static global configuration (that doesn't need Velocity) should be put in config.js . The default instance level
43 43   ## configuration is in EditSheet.
... ... @@ -46,7 +46,7 @@
46 46   'htmlSyntax': $htmlSyntax,
47 47   'stylesSet': "#if ($isHTML5)html5#{else}html4#end",
48 48   'xwiki-office': {
49 - 'enabled': $officeImportSupported
29 + 'enabled': $services.officemanager.isConnected()
50 50   },
51 51   'xwiki-realtime': {
52 52   'stylesheets': [
XWiki.JavaScriptExtension[0]
Code
... ... @@ -24,15 +24,19 @@
24 24   var commaSeparator = /\s*,\s*/;
25 25   var enhanceConfig = function(editor) {
26 26   var availablePlugins = editor.config.plugins.split(commaSeparator);
27 - enhanceList($('#CKEditor\\.ConfigClass_0_removePlugins'), availablePlugins);
27 + enhanceList($('#CKEditor\\.ConfigClass_0_removePlugins'), availablePlugins, 'available-plugins-select');
28 28  
29 29   var availableButtons = Object.keys(editor.ui.items);
30 - enhanceList($('#CKEditor\\.ConfigClass_0_removeButtons'), availableButtons);
30 + enhanceList($('#CKEditor\\.ConfigClass_0_removeButtons'), availableButtons, 'available-buttons-select');
31 +
32 + enhanceTextArea($('#CKEditor\\.ConfigClass_0_advanced'), 'advanced-text-area');
31 31   };
32 32  
33 - var enhanceList = function(input, allowedValues) {
35 + var enhanceList = function(input, allowedValues, selectId) {
34 34   var values = input.hide().val().split(commaSeparator);
35 35   var select = $('<select class="form-control" multiple></select>').insertAfter(input);
38 + input.parent().prev().find('label').attr('for', selectId);
39 + select.attr('id', selectId);
36 36   allowedValues.sort().forEach(function(value) {
37 37   select.append($('<option></option>').text(value));
38 38   });
... ... @@ -48,6 +48,11 @@
48 48   input.val(values.join(','));
49 49   });
50 50   };
55 +
56 + var enhanceTextArea = function(textarea, textareaId) {
57 + textarea.parent().prev().find('label').attr('for', textareaId);
58 + textarea.attr('id', textareaId);
59 + };
51 51  
52 52   ckeditorPromise.done(function(ckeditor) {
53 53   ckeditor.once('instanceLoaded', function(event) {