Open joomlapl-bot opened 1 month ago
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/43579 Poniżej zmiany w oryginale:
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/43579 Poniżej zmiany w oryginale:
Click to expand the diff!
```diff diff --git a/administrator/components/com_media/resources/scripts/components/breadcrumb/breadcrumb.vue b/administrator/components/com_media/resources/scripts/components/breadcrumb/breadcrumb.vue index 25cddeca8c4e6..87e7945939b69 100644 --- a/administrator/components/com_media/resources/scripts/components/breadcrumb/breadcrumb.vue +++ b/administrator/components/com_media/resources/scripts/components/breadcrumb/breadcrumb.vue @@ -78,7 +78,10 @@ export default { { bubbles: true, cancelable: false, - detail: {}, + detail: { + type: 'dir', + path: destination.path, + }, }, ), ); diff --git a/administrator/components/com_media/resources/scripts/components/browser/items/directory.vue b/administrator/components/com_media/resources/scripts/components/browser/items/directory.vue index f78a9b6b47ed6..82f02863690ef 100644 --- a/administrator/components/com_media/resources/scripts/components/browser/items/directory.vue +++ b/administrator/components/com_media/resources/scripts/components/browser/items/directory.vue @@ -51,6 +51,17 @@ export default { /* Handle the on preview double click event */ onPreviewDblClick() { this.navigateTo(this.item.path); + + window.parent.document.dispatchEvent( + new CustomEvent('onMediaFileSelected', { + bubbles: true, + cancelable: false, + detail: { + type: this.item.type, + path: this.item.path, + }, + }), + ); }, /* Hide actions dropdown */ hideActions() { diff --git a/administrator/components/com_media/resources/scripts/components/browser/items/item.es6.js b/administrator/components/com_media/resources/scripts/components/browser/items/item.es6.js index 9ca4be5a3b7ad..0c8d1f20c27d5 100644 --- a/administrator/components/com_media/resources/scripts/components/browser/items/item.es6.js +++ b/administrator/components/com_media/resources/scripts/components/browser/items/item.es6.js @@ -126,6 +126,7 @@ export default { bubbles: true, cancelable: false, detail: { + type: this.item.type, path: this.item.path, thumb: this.item.thumb, fileType: this.item.mime_type ? this.item.mime_type : false, @@ -142,7 +143,10 @@ export default { new CustomEvent('onMediaFileSelected', { bubbles: true, cancelable: false, - detail: {}, + detail: { + type: this.item.type, + path: this.item.path, + }, }), ); } diff --git a/administrator/components/com_media/resources/scripts/components/browser/table/row.vue b/administrator/components/com_media/resources/scripts/components/browser/table/row.vue index 32d1c68157f0c..aff5df71ff2b8 100644 --- a/administrator/components/com_media/resources/scripts/components/browser/table/row.vue +++ b/administrator/components/com_media/resources/scripts/components/browser/table/row.vue @@ -136,32 +136,31 @@ export default { * @param event */ onClick(event) { - const path = false; const data = { - path, + path: this.item.path, + type: this.item.type, thumb: false, fileType: this.item.mime_type ? this.item.mime_type : false, extension: this.item.extension ? this.item.extension : false, }; if (this.item.type === 'file') { - data.path = this.item.path; data.thumb = this.item.thumb ? this.item.thumb : false; data.width = this.item.width ? this.item.width : 0; data.height = this.item.height ? this.item.height : 0; - - window.parent.document.dispatchEvent( - new CustomEvent( - 'onMediaFileSelected', - { - bubbles: true, - cancelable: false, - detail: data, - }, - ), - ); } + window.parent.document.dispatchEvent( + new CustomEvent( + 'onMediaFileSelected', + { + bubbles: true, + cancelable: false, + detail: data, + }, + ), + ); + // Handle clicks when the item was not selected if (!this.isSelected()) { // Unselect all other selected items, diff --git a/administrator/components/com_media/resources/scripts/components/tree/drive.vue b/administrator/components/com_media/resources/scripts/components/tree/drive.vue index e330d003acaee..d025e4fdbcc63 100644 --- a/administrator/components/com_media/resources/scripts/components/tree/drive.vue +++ b/administrator/components/com_media/resources/scripts/components/tree/drive.vue @@ -77,6 +77,17 @@ export default { /* Handle the on drive click event */ onDriveClick() { this.navigateTo(this.drive.root); + + window.parent.document.dispatchEvent( + new CustomEvent('onMediaFileSelected', { + bubbles: true, + cancelable: false, + detail: { + type: 'dir', + path: this.drive.root, + }, + }), + ); }, moveFocusToChildElement(nextRoot) { this.$refs[nextRoot].setFocusToFirstChild(); diff --git a/administrator/components/com_media/resources/scripts/components/tree/tree.vue b/administrator/components/com_media/resources/scripts/components/tree/tree.vue index 1f14eddff439c..21ae3df7104b7 100644 --- a/administrator/components/com_media/resources/scripts/components/tree/tree.vue +++ b/administrator/components/com_media/resources/scripts/components/tree/tree.vue @@ -88,7 +88,10 @@ export default { { bubbles: true, cancelable: false, - detail: {}, + detail: { + type: item.type, + path: item.path, + }, }, ), ); diff --git a/administrator/language/en-GB/plg_editors_tinymce.ini b/administrator/language/en-GB/plg_editors_tinymce.ini index 88033c39615ca..b48d32e3326df 100644 --- a/administrator/language/en-GB/plg_editors_tinymce.ini +++ b/administrator/language/en-GB/plg_editors_tinymce.ini @@ -11,6 +11,7 @@ PLG_TINY_CORE_BUTTONS="CMS Content" PLG_TINY_DND_ADDITIONALDATA="Additional Data" PLG_TINY_DND_ALTTEXT="Image Description (Alt Text)" PLG_TINY_DND_EMPTY_ALT="No Description" +PLG_TINY_DND_FILE_EXISTS_ERROR="File \"%s\" already exists." PLG_TINY_DND_LAZYLOADED="Image will be lazyloaded" PLG_TINY_ERR_CUSTOMCSSFILENOTPRESENT="The file name %s was entered in the TinyMCE Custom CSS field. This file could not be found in the default template folder. No styles are available." PLG_TINY_ERR_EDITORCSSFILENOTPRESENT="Could not find the file 'editor.css' in the template or templates/system folder. No styles are available." diff --git a/build/media_source/plg_editors_tinymce/js/plugins/dragdrop/plugin.es6.js b/build/media_source/plg_editors_tinymce/js/plugins/dragdrop/plugin.es6.js index 0c866a890ae66..0929f0ef19dcb 100644 --- a/build/media_source/plg_editors_tinymce/js/plugins/dragdrop/plugin.es6.js +++ b/build/media_source/plg_editors_tinymce/js/plugins/dragdrop/plugin.es6.js @@ -26,9 +26,7 @@ function readFile(file, callback) { window.tinymce.PluginManager.add('jdragndrop', (editor) => { const registerOption = editor.options.register; registerOption('uploadUri', { processor: 'string' }); - registerOption('comMediaAdapter', { processor: 'string' }); registerOption('parentUploadFolder', { processor: 'string' }); - registerOption('csrfToken', { processor: 'string' }); // Reset the drop area border const dragleaveCallback = (e) => { @@ -61,10 +59,9 @@ window.tinymce.PluginManager.add('jdragndrop', (editor) => { const settings = editor.options.get; Joomla.request({ - url: `${settings('uploadUri')}&path=${settings('comMediaAdapter')}${settings('parentUploadFolder')}`, + url: `${settings('uploadUri')}&path=${settings('parentUploadFolder')}`, method: 'POST', data: JSON.stringify({ - [settings('csrfToken')]: 1, name, content, parent: settings('parentUploadFolder'), @@ -72,11 +69,13 @@ window.tinymce.PluginManager.add('jdragndrop', (editor) => { headers: { 'Content-Type': 'application/json', }, - onSuccess: (resp) => { + promise: true, + }) + .then((resp) => { let response; try { - response = JSON.parse(resp); + response = JSON.parse(resp.responseText); } catch (e) { editor.windowManager.alert(`${Joomla.Text._('ERROR')}: {${e}}`); } @@ -145,9 +144,14 @@ window.tinymce.PluginManager.add('jdragndrop', (editor) => { onCancel: (api) => dialogClose(api), }); } - }, - onError: (xhr) => editor.windowManager.alert(`Error: ${xhr.statusText}`), - }); + }) + .catch((xhr) => { + let message = `Error: ${xhr.statusText}`; + if (xhr.status === 409) { + message = Joomla.Text._('PLG_TINY_DND_FILE_EXISTS_ERROR').replace('%s', `${settings('parentUploadFolder')}/${name}`); + } + editor.windowManager.alert(message); + }); } // Logic for the dropped file diff --git a/build/media_source/system/js/fields/joomla-field-media.w-c.es6.js b/build/media_source/system/js/fields/joomla-field-media.w-c.es6.js index ec499cef94a97..e004ec2075db5 100644 --- a/build/media_source/system/js/fields/joomla-field-media.w-c.es6.js +++ b/build/media_source/system/js/fields/joomla-field-media.w-c.es6.js @@ -39,12 +39,12 @@ class JoomlaFieldMedia extends HTMLElement { } static get observedAttributes() { - return ['type', 'base-path', 'root-folder', 'url', 'modal-title', 'modal-width', 'modal-height', 'input', 'button-select', 'button-clear', 'preview', 'preview-width', 'preview-height']; + return ['base-path', 'root-folder', 'url', 'modal-title', 'modal-width', 'modal-height', 'input', 'button-select', 'button-clear', 'preview', 'preview-width', 'preview-height']; } - get type() { return this.getAttribute('type'); } + get types() { return this.getAttribute('types') || ''; } - set type(value) { this.setAttribute('type', value); } + set types(value) { this.setAttribute('types', value); } get basePath() { return this.getAttribute('base-path'); } @@ -175,7 +175,13 @@ class JoomlaFieldMedia extends HTMLElement { async modalClose() { try { - await Joomla.getMedia(Joomla.selectedMediaFile, this.inputElement, this); + const item = Joomla.selectedMediaFile; + if (item && item.type === 'dir') { + // Set directory path as value only when the field is configured to support of directories + this.setValue(this.types.includes('directories') ? item.path : ''); + } else { + await Joomla.getMedia(item, this.inputElement, this); + } } catch (err) { Joomla.renderMessages({ error: [Joomla.Text._('JLIB_APPLICATION_ERROR_SERVER')], diff --git a/build/media_source/system/js/fields/joomla-media-select.w-c.es6.js b/build/media_source/system/js/fields/joomla-media-select.w-c.es6.js index 8e8864d80f811..70facf109fb16 100644 --- a/build/media_source/system/js/fields/joomla-media-select.w-c.es6.js +++ b/build/media_source/system/js/fields/joomla-media-select.w-c.es6.js @@ -48,7 +48,7 @@ document.addEventListener('onMediaFileSelected', async (e) => { images, audios, videos, documents, } = supportedExtensions; - if (Joomla.selectedMediaFile.path) { + if (Joomla.selectedMediaFile.path && Joomla.selectedMediaFile.type === 'file') { let type; if (images.includes(Joomla.selectedMediaFile.extension.toLowerCase())) { type = 'images'; diff --git a/layouts/joomla/form/field/media.php b/layouts/joomla/form/field/media.php index 6e10e2e4dd5ea..c5a5dc4a170d4 100644 --- a/layouts/joomla/form/field/media.php +++ b/layouts/joomla/form/field/media.php @@ -40,7 +40,8 @@ * @var integer $size The size text * @var string $value The value text * @var string $src The path and filename of the image - * @var array $mediaTypes The supported media types for the Media Manager + * @var string $mediaTypes The ids of supported media types for the Media Manager + * @var array $mediaTypeNames The names of supported media types for the Media Manager * @var array $imagesExt The supported extensions for images * @var array $audiosExt The supported extensions for audios * @var array $videosExt The supported extensions for videos @@ -155,7 +156,8 @@ } ?> -