Modifications pour le document DocumentTree
Modifié par Florent Charton le 2024/08/08 18:44
Depuis la version 1.1
modifié par superadmin
sur 2022/06/20 08:49
sur 2022/06/20 08:49
Commentaire de modification :
Install extension [org.xwiki.contrib:application-ckeditor-ui/1.63.1]
À la version 3.1
modifié par Florent Charton
sur 2024/08/08 18:44
sur 2024/08/08 18:44
Commentaire de modification :
Install extension [org.xwiki.platform:xwiki-platform-ckeditor-ui/15.10.11]
Résumé
-
Propriétés de la Page (1 modifications, 0 ajouts, 0 suppressions)
-
Objets (2 modifications, 0 ajouts, 0 suppressions)
Détails
- Propriétés de la Page
-
- Auteur du document
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. superadmin1 +xwiki:XWiki.fcharton
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -1,23 +1,40 @@ 1 -require(['jquery', 'imageSelector'], function($, imageSelector) { 2 - function getSelected(instance) { 3 - /* jshint camelcase: false */ 4 - return instance.get_selected(false)[0]; 5 - } 6 - 1 +require(['jquery', 'imageSelector'], function ($, imageSelector) { 2 + function getSelected(instance) { 3 + return instance.get_selected(false)[0]; 4 + } 5 + 7 7 function validateSelection(instance) { 8 8 var selected = getSelected(instance); 9 9 return selected && selected.startsWith("attachment:"); 10 10 } 11 11 12 - $('.attachments-tree').xtree() 13 - .one('ready.jstree', function(event, data) { 14 - data.instance.openTo("document:" + XWiki.Model.serialize(XWiki.currentDocument.getDocumentReference())); 15 - }) 16 - .on('changed.jstree', function(event, data) { 17 - if (validateSelection(data.instance)) { 18 - imageSelector.updateSelectedImageReferences([getSelected(data.instance)]); 19 - } else { 20 - imageSelector.updateSelectedImageReferences([]); 21 - } 22 - }); 11 + function init(element) { 12 + element.find('.attachments-tree').xtree() 13 + .one('ready.jstree', function (event, data) { 14 + const documentReference = element.find('input[name="documentReference"]').val() 15 + data.instance.openTo(documentReference); 16 + }) 17 + .on('changed.jstree', function (event, data) { 18 + if (validateSelection(data.instance)) { 19 + imageSelector.updateSelectedImageReferences([getSelected(data.instance)], $(this)); 20 + } else { 21 + imageSelector.updateSelectedImageReferences([], $(this)); 22 + } 23 + }) 24 + .on('load_node.jstree', function (node, status) { 25 + for (var child of status.node.children) { 26 + var childNode = status.instance.get_node(child); 27 + if (childNode.data.mimetype && !childNode.data.mimetype.startsWith('image/')) { 28 + // Disable the nodes instead of hiding them because they still can be search in the search field. 29 + status.instance.disable_node(childNode); 30 + } 31 + } 32 + }); 33 + } 34 + 35 + init($(document).find('.image-selector')); 36 + 37 + $(document).on('xwiki:dom:updated', (event, data) => { 38 + data.elements.forEach(element => init($(element))); 39 + }); 23 23 });
- XWiki.UIExtensionClass[0]
-
- Executed Content
-
... ... @@ -1,11 +1,11 @@ 1 1 {{velocity}} 2 2 #set ($discard = $xwiki.jsx.use('CKEditor.ImageSelectorServiceUIX.DocumentTree')) 3 -{{html clean="false"}} 3 +{{html clean="false" wiki="false"}} 4 + <input type='hidden' name='documentReference' value='$escapetool.xml("document:$services.model.serialize($request.documentReference, 'default')")' /> 4 4 #template('documentTree_macros.vm') 5 5 #documentTree({ 6 6 'class': 'attachments-tree', 7 7 'finder': true, 8 - 'openTo': "document:$services.model.serialize($doc.documentReference, 'default')", 9 9 'showWikis': true, 10 10 'showTranslations': false 11 11 }) - Extension Parameters
-
... ... @@ -1,3 +1,3 @@ 1 1 priority=200 2 -title=ckeditor.plugin.image.imageSelector. documentTreeTab.title2 +title=ckeditor.plugin.image.imageSelector.treeTab.title 3 3 id=documentTree