Changes for page EditSheet
Last modified by superadmin on 2025/02/27 10:46
From version 6.1
edited by Thomas Coelho
on 2023/02/27 12:06
on 2023/02/27 12:06
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-ckeditor-ui/15.1]
To version 1.1
edited by Thomas Coelho (local)
on 2022/04/20 16:09
on 2022/04/20 16:09
Change comment:
Install extension [org.xwiki.contrib:application-ckeditor-ui/1.61]
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. thw1 +XWiki.coelho
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -1,14 +1,8 @@ 1 1 /* 2 -#if ($services.debug.minify) 3 - #set ($jsExtension = '.min') 4 -#else 5 - #set ($jsExtension = '') 6 -#end 7 -#set ($ckeditorPath = $services.webjars.url('org.xwiki.platform:xwiki-platform-ckeditor-webjar', 'ckeditor')) 2 +#set ($ckeditorPath = $services.webjars.url('org.xwiki.contrib:application-ckeditor-webjar', 'ckeditor')) 8 8 #set ($ckeditorBasePath = $stringtool.removeEnd($stringtool.removeEnd($ckeditorPath, '.js'), 'ckeditor')) 9 -#set ($resourcePickerBundlePath = "${ckeditorBasePath}plugins/xwiki-resource/resourcePicker.bundle$jsExtension") 10 -#set ($macroWizardBundlePath = "${ckeditorBasePath}plugins/xwiki-macro/macroWizard.bundle$jsExtension") 11 -#set ($imageWizardBundlePath = "${ckeditorBasePath}plugins/xwiki-image/imageWizard.bundle$jsExtension") 4 +#set ($resourcePickerBundlePath = "${ckeditorBasePath}plugins/xwiki-resource/resourcePicker.bundle.min") 5 +#set ($macroWizardBundlePath = "${ckeditorBasePath}plugins/xwiki-macro/macroWizard.bundle.min") 12 12 #set ($modalPath = "${ckeditorBasePath}plugins/xwiki-dialog/modal.min") 13 13 #set ($l10nPath = "${ckeditorBasePath}plugins/xwiki-localization/l10n.min") 14 14 */ ... ... @@ -19,7 +19,6 @@ 19 19 modal: '$!modalPath', 20 20 l10n: '$!l10nPath', 21 21 macroWizard: '$!macroWizardBundlePath', 22 - imageWizard: '$!imageWizardBundlePath', 23 23 // This is used by the resource suggest picker on the link modal. 24 24 'bootstrap3-typeahead': $jsontool.serialize($services.webjars.url('org.webjars.npm:bootstrap-3-typeahead', 25 25 'bootstrap3-typeahead.min')), ... ... @@ -34,7 +34,7 @@ 34 34 ckeditor: { 35 35 exports: 'CKEDITOR', 36 36 // This includes dependencies of the plugins bundled with the CKEditor code. 37 - deps: ['jquery', 'resource', 'resourcePicker', 'macroWizard' , 'imageWizard']30 + deps: ['jquery', 'resource', 'resourcePicker', 'macroWizard'] 38 38 } 39 39 }, 40 40 config: { ... ... @@ -63,6 +63,56 @@ 63 63 "$!services.webjars.url('org.xwiki.platform:xwiki-platform-tree-webjar', 'require-config.min.js', {'evaluate': true})" 64 64 ], function($, ckeditor, xwikiMeta) { 65 65 var deferred = $.Deferred(); 59 + 60 + var loadJavaScriptSkinExtensions = $jsontool.serialize($xwiki.getDocument('CKEditor.Config' 61 + ).getValue('loadJavaScriptSkinExtensions')) === 1; 62 + 63 + // See http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules 64 + var allowedContentBySyntax = { 65 + 'xwiki/2.1': { 66 + '$1': { 67 + elements: { 68 + // Elements required because the editor input is a full HTML page. 69 + html: true, head: true, link: true, script: loadJavaScriptSkinExtensions, body: true, 70 + // Headings 71 + h1: true, h2: true, h3: true, h4: true, h5: true, h6: true, 72 + // Lists 73 + dl: true, ol: true, ul: true, 74 + // Tables 75 + table: true, tr: true, th: true, td: true, 76 + // Formatting 77 + span: true, strong: true, em: true, ins: true, del: true, sub: true, sup: true, tt: true, pre: true, 78 + // Others 79 + div: true, hr: true, p: true, a: true, img: true, blockquote: true, figure: true 80 + }, 81 + // The elements above can have any attribute, through the parameter (%%) syntax. 82 + attributes: '*', 83 + styles: '*', 84 + classes: '*' 85 + }, 86 + '$2': { 87 + // The XWiki syntax doesn't support parameters for the following elements. 88 + elements: {br: true, dd: true, dt: true, li: true, tbody: true, figcaption: true} 89 + }, 90 + '$3': { 91 + // Wiki syntax macros can output any HTML. 92 + match: CKEDITOR.plugins.xwikiMacro.isMacroOutput, 93 + attributes: '*', 94 + styles: '*', 95 + classes: '*' 96 + } 97 + }, 98 + 'plain/1.0': ';' 99 + }; 100 + allowedContentBySyntax['xwiki/2.0'] = allowedContentBySyntax['xwiki/2.1']; 101 + // This is a hack, increasing the technical debt since the CKEditor module should not know about the Markdown 102 + // syntax. Actually it should not know either about the xwiki/2.0 and xwiki/2.1 syntaxes ;) 103 + // This should be fixed by implementing https://jira.xwiki.org/browse/CKEDITOR-319 104 + allowedContentBySyntax['markdown/1.2'] = $.extend(true, {}, allowedContentBySyntax['xwiki/2.1']); 105 + // Markdown doesn't allow figures at the moment. 106 + delete allowedContentBySyntax['markdown/1.2']['$1'].elements.figure; 107 + delete allowedContentBySyntax['markdown/1.2']['$2'].elements.figcaption; 108 + 66 66 var currentLocale = $('html').attr('lang') || ''; 67 67 68 68 // We have to pass the plugin that makes the request (the initiator) because the expected response can be different ... ... @@ -71,7 +71,6 @@ 71 71 return document.getURL('get', $.param({ 72 72 sheet: 'CKEditor.FileUploader', 73 73 outputSyntax: 'plain', 74 - // The syntax and language are important especially when the upload request creates a new document. 75 75 syntax: document.syntax, 76 76 language: currentLocale, 77 77 form_token: xwikiMeta.form_token, ... ... @@ -81,26 +81,66 @@ 81 81 82 82 // Extend the default CKEditor configuration with settings that depend on the source document. 83 83 var getConfig = function(element) { 84 - var sourceSyntax = $(element).attr('data-syntax'); 85 85 var sourceDocument = XWiki.currentDocument; 86 - sourceDocument.syntax = XWiki.docsyntax; 87 - var sourceDocumentReference = XWiki.Model.resolve($(element).attr('data-sourceDocumentReference'), 88 - XWiki.EntityType.DOCUMENT, XWiki.currentDocument.documentReference); 89 - if (!XWiki.currentDocument.documentReference.equals(sourceDocumentReference)) { 90 - sourceDocument = new XWiki.Document(sourceDocumentReference); 91 - // We assume the syntax of the source document is the same as the syntax of the edited content. 92 - sourceDocument.syntax = sourceSyntax; 127 + var sourceDocumentReference = $(element).attr('data-sourceDocumentReference'); 128 + if (sourceDocumentReference) { 129 + sourceDocument = new XWiki.Document(XWiki.Model.resolve(sourceDocumentReference, XWiki.EntityType.DOCUMENT)); 93 93 } 131 + sourceDocument.syntax = $(element).attr('data-sourceDocumentSyntax'); 132 + var isHTML5 = $(element).data('syntax') !== 'annotatedxhtml/1.0'; 94 94 95 - var uploadDisabled = element.hasAttribute('data-upload-disabled'); 134 + var allowedContent; 135 + var allowedContentWithoutFigure; 136 + if (sourceDocument.syntax in allowedContentBySyntax) { 137 + allowedContent = allowedContentBySyntax[sourceDocument.syntax]; 138 + // Try removing the figure/figcaption tags for caption content to forbid nested figures. 139 + allowedContentWithoutFigure = $.extend(true, {}, allowedContent); 140 + delete allowedContentWithoutFigure['$1']?.elements?.figure; 141 + delete allowedContentWithoutFigure['$2']?.elements?.figcaption; 96 96 143 + // Disable figure support if the syntax isn't HTML 5. 144 + if (!isHTML5) { 145 + allowedContent = allowedContentWithoutFigure; 146 + } 147 + } 148 + 97 97 var config = { 98 - filebrowserUploadUrl: uploadDisabled ? '' : getUploadURL(sourceDocument, 'filebrowser'), 150 + allowedContent: allowedContent, 151 + editorplaceholder: $jsontool.serialize($services.localization.render('ckeditor.content.placeholder')), 152 + filebrowserUploadUrl: getUploadURL(sourceDocument, 'filebrowser'), 153 + // This is used in CKEditor.FileUploader so we must keep them in sync. 154 + fileTools_defaultFileName: '__fileCreatedFromDataURI__', 99 99 height: $(element).height(), 156 + // CKEditor uses '-' (dash) as locale separator (between the language code and the country code). 157 + language: currentLocale.toLowerCase().replace('_', '-'), 158 + uploadUrl: getUploadURL(sourceDocument, 'filetools'), 159 + stylesSet: isHTML5 ? 'html5' : 'html4', 160 + 'xwiki-image' : { 161 + captionAllowedContent: allowedContentWithoutFigure 162 + }, 163 + 'xwiki-link': { 164 + labelGenerator: sourceDocument.getURL('get', $.param({ 165 + sheet: 'CKEditor.LinkLabelGenerator', 166 + outputSyntax: 'plain', 167 + language: currentLocale 168 + })) 169 + }, 170 + 'xwiki-resource': { 171 + dispatcher: sourceDocument.getURL('get', $.param({ 172 + sheet: 'CKEditor.ResourceDispatcher', 173 + outputSyntax: 'plain', 174 + language: currentLocale 175 + })) 176 + }, 177 + 'xwiki-source': { 178 + htmlConverter: sourceDocument.getURL('get', $.param({ 179 + sheet: 'CKEditor.HTMLConverter', 180 + outputSyntax: 'plain', 181 + language: currentLocale 182 + })) 183 + }, 100 100 mentions: [ 101 101 { 102 - // We use the source document to compute the feed URL because we want the suggested link references to be 103 - // relative to the edited document (we want the editor to output relative references as much as possible). 104 104 feed: sourceDocument.getURL('get', $.param({ 105 105 sheet: 'CKEditor.LinkSuggestions', 106 106 outputSyntax: 'plain', ... ... @@ -120,29 +120,21 @@ 120 120 '</div>', 121 121 '<div class="ckeditor-autocomplete-item-hint">{hint}</div>', 122 122 '</li>'].join(''), 123 - outputTemplate: '<a href="{url}" data-reference="{typed}|-|{type}|-|{reference}">{label}</a>', 124 - followingSpace: true, 205 + outputTemplate: '<a href="{url}" data-reference="{typed}|-|{type}|-|{reference}">{label}</a><span> </span>', 125 125 marker: '[', 126 126 minChars: 0, 127 127 itemsLimit: 6 128 128 } 129 - ], 130 - // Used to resolve and serialize relative references. Also used to make HTTP requests with the right context. 131 - sourceDocument: sourceDocument, 132 - // The syntax of the edited content is not always the same as the syntax of the source document (which applies to 133 - // the source document content, but we might be editing something else, like an object property). 134 - sourceSyntax: sourceSyntax, 135 - uploadUrl: uploadDisabled ? '' : getUploadURL(sourceDocument, 'filetools'), 136 - 'xwiki-link': { 137 - // We use the source document to compute the link label generator URL because we want the link references to be 138 - // resolved relative to the edited document (as they were inserted). 139 - labelGenerator: sourceDocument.getURL('get', $.param({ 140 - sheet: 'CKEditor.LinkLabelGenerator', 141 - outputSyntax: 'plain', 210 + ] 211 + }; 212 + if ($(element).attr('data-officeImporterSupported') === 'true') { 213 + config['xwiki-office'] = { 214 + importer: sourceDocument.getURL('get', $.param({ 215 + sheet: 'CKEditor.OfficeImporter', 142 142 language: currentLocale 143 143 })) 144 - } 145 - } ;218 + }; 219 + } 146 146 return config; 147 147 }; 148 148
- XWiki.StyleSheetExtension[0]
-
- Code
-
... ... @@ -1,7 +1,7 @@ 1 1 #template('colorThemeInit.vm') 2 2 3 3 /* 4 -#set ($ckeditorSkinPath = $services.webjars.url('org.xwiki. platform:xwiki-platform-ckeditor-webjar', 'skins/moono-lisa'))4 +#set ($ckeditorSkinPath = $services.webjars.url('org.xwiki.contrib:application-ckeditor-webjar', 'skins/moono-lisa')) 5 5 #if ($ckeditorSkinPath.indexOf('?') >= 0) 6 6 ## The WebJar resource path was specified in the query string before 7.1M1 which prevented the browser from resolving 7 7 ## relative paths. See XWIKI-10880 (A CSS file inside a webjar cannot use a resource from that webjar).
- XWiki.UIExtensionClass[0]
-
- Extension Parameters
-
... ... @@ -1,2 +1,2 @@ 1 1 id=xwiki-ckeditor 2 -path=$xwiki.getURL('CKEditor.EditSheet', 'jsx', $escapetool.url({'v': $services.extension.installed.getInstalledExtension('org.xwiki. platform:xwiki-platform-ckeditor-ui', "wiki:$xcontext.database").version.value, 'xwiki-version': $services.extension.core.getCoreExtension('org.xwiki.platform:xwiki-platform-tree-webjar').version.value, 'fast-diff-version': $services.extension.installed.getInstalledExtension('org.webjars.npm:fast-diff', "wiki:$xcontext.database").version.value, 'bs3typeahead-version': $services.extension.installed.getInstalledExtension('org.webjars.npm:bootstrap-3-typeahead', "wiki:$xcontext.database").version.value}))2 +path=$xwiki.getURL('CKEditor.EditSheet', 'jsx', $escapetool.url({'v': $services.extension.installed.getInstalledExtension('org.xwiki.contrib:application-ckeditor-ui', "wiki:$xcontext.database").version.value, 'xwiki-version': $services.extension.core.getCoreExtension('org.xwiki.platform:xwiki-platform-tree-webjar').version.value, 'fast-diff-version': $services.extension.installed.getInstalledExtension('org.webjars.npm:fast-diff', "wiki:$xcontext.database").version.value, 'bs3typeahead-version': $services.extension.installed.getInstalledExtension('org.webjars.npm:bootstrap-3-typeahead', "wiki:$xcontext.database").version.value}))