Modifications pour le document DocumentTree
Modifié par Florent Charton le 2024/08/08 18:44
Depuis la version 2.1
modifié par Florent Charton
sur 2022/06/28 18:01
sur 2022/06/28 18:01
Commentaire de modification :
Install extension [org.xwiki.contrib:application-ckeditor-ui/1.64.2]
À 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é
-
Objets (2 modifications, 0 ajouts, 0 suppressions)
Détails
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -8,24 +8,33 @@ 8 8 return selected && selected.startsWith("attachment:"); 9 9 } 10 10 11 - $('.attachments-tree').xtree() 12 - .one('ready.jstree', function (event, data) { 13 - data.instance.openTo("document:" + XWiki.Model.serialize(XWiki.currentDocument.getDocumentReference())); 14 - }) 15 - .on('changed.jstree', function (event, data) { 16 - if (validateSelection(data.instance)) { 17 - imageSelector.updateSelectedImageReferences([getSelected(data.instance)]); 18 - } else { 19 - imageSelector.updateSelectedImageReferences([]); 20 - } 21 - }) 22 - .on('load_node.jstree', function (node, status) { 23 - for (var child of status.node.children) { 24 - var childNode = status.instance.get_node(child); 25 - if (childNode.data.mimetype && !childNode.data.mimetype.startsWith('image/')) { 26 - // Disable the nodes instead of hiding them because they still can be search in the search field. 27 - status.instance.disable_node(childNode); 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)); 28 28 } 29 - } 30 - }); 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 + }); 31 31 });
- 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