Changes for page EditSheet

Last modified by superadmin on 2025/02/27 10:46

From version 4.1
edited by Thomas Coelho
on 2022/10/17 13:54
Change comment: Install extension [org.xwiki.platform:xwiki-platform-ckeditor-ui/14.8]
To version 5.1
edited by Thomas Coelho (local)
on 2023/01/17 20:36
Change comment: Install extension [org.xwiki.platform:xwiki-platform-ckeditor-ui/14.10.3]

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.thw
1 +XWiki.coelho
XWiki.JavaScriptExtension[0]
Code
... ... @@ -81,12 +81,16 @@
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');
84 84   var sourceDocument = XWiki.currentDocument;
85 - var sourceDocumentReference = $(element).attr('data-sourceDocumentReference');
86 - if (sourceDocumentReference) {
87 - sourceDocument = new XWiki.Document(XWiki.Model.resolve(sourceDocumentReference, XWiki.EntityType.DOCUMENT));
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;
88 88   }
89 - sourceDocument.syntax = $(element).attr('data-sourceDocumentSyntax');
90 90  
91 91   var config = {
92 92   filebrowserUploadUrl: getUploadURL(sourceDocument, 'filebrowser'),
... ... @@ -114,13 +114,18 @@
114 114   '</div>',
115 115   '<div class="ckeditor-autocomplete-item-hint">{hint}</div>',
116 116   '</li>'].join(''),
117 - outputTemplate: '<a href="{url}" data-reference="{typed}|-|{type}|-|{reference}">{label}</a><span>&nbsp;</span>',
121 + outputTemplate: '<a href="{url}" data-reference="{typed}|-|{type}|-|{reference}">{label}</a>',
122 + followingSpace: true,
118 118   marker: '[',
119 119   minChars: 0,
120 120   itemsLimit: 6
121 121   }
122 122   ],
128 + // Used to resolve and serialize relative references. Also used to make HTTP requests with the right context.
123 123   sourceDocument: sourceDocument,
130 + // The syntax of the edited content is not always the same as the syntax of the source document (which applies to
131 + // the source document content, but we might be editing something else, like an object property).
132 + sourceSyntax: sourceSyntax,
124 124   uploadUrl: getUploadURL(sourceDocument, 'filetools'),
125 125   'xwiki-link': {
126 126   // We use the source document to compute the link label generator URL because we want the link references to be