Details
Description
Steps to reproduce:
1. go to http://127.0.0.1:8080/xwiki/bin/admin/XWiki/XWikiPreferences?editor=globaladmin§ion=WYSIWYG and in the Advanced Configuration add one of the following:
config.stylesSet = false;
or
config.stylesSet = [{name: 'Monospace', element: 'span', attributes: {'class': 'monospace-style'}}];
2. go to any page in edit mode (WYSIWYG or In place) and select image macro
3. go to Upload tab
4. browse and upload a file
5. click Select the file
6. click Insert
Expected result:
The file is inserted in the document content
Actual result:
The file is not inserted in the document content and the following warning appears in the browser console:
14:00:49.839 jQuery.Deferred exception: f.$.parentNode is null insertBefore@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:71:515 replace@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:79:278 d@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:1170:299 stateShifter/<@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:1195:179 data@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:1172:412 overrideImageWidget/a.data@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:1490:275 overrideImageWidget/a.data@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:1490:275 overrideImageWidget/e.data@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:1498:283 l@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:10:246 CKEDITOR.event.prototype.fire@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:12:91 setData@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:1161:137 f/</<@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/xwiki-platform-ckeditor-webjar/14.10.4/ckeditor.js:1495:38 c@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/jquery/3.6.0/jquery.min.js?r=1:2:28327 fireWith@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/jquery/3.6.0/jquery.min.js?r=1:2:29072 e@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/jquery/3.6.0/jquery.min.js?r=1:2:30310 Deferred/then/l/</t<@http://127.0.0.1:8080/xwiki/webjars/wiki%3Axwiki/jquery/3.6.0/jquery.min.js?r=1:2:30340 undefined jquery.min.js:2:31593 14:00:49.916 MouseEvent.mozPressure is deprecated. Use PointerEvent.pressure instead. base.js:2169:347
Indications:
The link between the image plugin and the configured styleset is this https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/resources/xwiki-image/imageEditor.js#L301 . It's a poor / fragile way to check for HTML5. It should have been:
isHTML5: params.editor.config.htmlSyntax === 'annotatedhtml/5.0'
The consequence is that once you configure the stylesheet the image plugin thinks the editor is not using anymore HTML5 so it disables the caption feature, which in turn leads to some image insertion bug that can be fixed by:
- hasCaption: $("#imageCaptionActivation").prop('checked'), + hasCaption: !!$("#imageCaptionActivation").prop('checked'),
also in image editor.