From 6e279e64f6026bb611a6460ef70e90a410c8b314 Mon Sep 17 00:00:00 2001 From: Henning Leutz <leutz@pcsg.de> Date: Wed, 2 Jun 2021 10:27:08 +0200 Subject: [PATCH] fix: added media button for image2 plugin --- bin/Editor.js | 99 +++++++++++++++++++++++++++++++++++++- plugins/activePlugins.json | 2 +- 2 files changed, 99 insertions(+), 2 deletions(-) diff --git a/bin/Editor.js b/bin/Editor.js index 41199d4..c5c48e2 100644 --- a/bin/Editor.js +++ b/bin/Editor.js @@ -97,6 +97,7 @@ define('package/quiqqer/ckeditor4/bin/Editor', [ var Editor = QUI.Controls.getById(ev.editor.name); Editor.$imageDialog(ev); + Editor.$image2Dialog(ev); Editor.$linkDialog(ev); Editor.$html5AudioDialog(ev); Editor.$html5VideoDialog(ev); @@ -787,6 +788,102 @@ define('package/quiqqer/ckeditor4/bin/Editor', [ return ev; }, + $image2Dialog: function (ev) { + // Take the dialog name and its definition from the event data. + var self = this, + dialogName = ev.data.name, + dialogDefinition = ev.data.definition; + + /** + * Image dialog + */ + if (dialogName !== 'image2') { + return ev; + } + + var oldOnShow = dialogDefinition.onShow; + + // Get a reference to the "Link Info" tab. + dialogDefinition.onShow = function () { + var Button; + + oldOnShow.bind(this)(); + console.log(this); + // image button + var UrlGroup = this.getContentElement('info', 'src') + .getElement().$; + + var HeightInput = this.getContentElement('info', 'height') + .getElement().$ + .getElement('input[type="text"]'); + + var WidthInput = this.getContentElement('info', 'width') + .getElement().$ + .getElement('input[type="text"]'); + + + console.log('#############'); + console.log(UrlGroup); + var UrlInput = UrlGroup.getElement('input[type="text"]'); + + if (!UrlGroup.getElement('.qui-button')) { + new Element('button', { + 'class': 'qui-button', + html : '<span class="fa fa-picture-o"></span>', + styles : { + margin: 0 + }, + events : { + click: function () { + self.openMedia({ + events: { + onSubmit: function (Win, data) { + UrlInput.value = data.url; + + Ajax.get('ajax_media_details', function (fileData) { + if (fileData.image_height > 500 || + fileData.image_width > 500) { + var result = QUIMath.resizeVar( + fileData.image_height, + fileData.image_width, + 500 + ); + // es darf keine image height gesetzt + // da das Bild sonst im mobile view sich verzieht + // HeightInput.value = result.var1; + WidthInput.value = result.var2; + } else { + // HeightInput.value = fileData.image_height; + WidthInput.value = fileData.image_width; + } + + // if (!fileData.image_height) { + // HeightInput.value = ''; + // } + + if (!fileData.image_width) { + WidthInput.value = ''; + } + }, { + project: data.project, + fileid : data.id + }); + } + } + }); + } + } + }).inject(UrlGroup); + + UrlInput.setStyle('float', 'left'); + UrlInput.setStyle('width', 'calc(100% - 35px)'); + UrlInput.setStyle('lineHeight', 20); + } + + console.log(UrlInput); + }; + }, + /** * edit the link dialog * @@ -800,7 +897,7 @@ define('package/quiqqer/ckeditor4/bin/Editor', [ /** * Link dialog */ - if (dialogName != 'link') { + if (dialogName !== 'link') { return ev; } diff --git a/plugins/activePlugins.json b/plugins/activePlugins.json index d9cf99b..65fb6e4 100644 --- a/plugins/activePlugins.json +++ b/plugins/activePlugins.json @@ -18,7 +18,7 @@ "html5video", "iframe", "iframedialog", - "image", + "image2", "indentblock", "justify", "language", -- GitLab