From 4d3a06f8cd924f5afda467ba68b8a3bc7ca7dcde Mon Sep 17 00:00:00 2001 From: xlxiang <528405129@qq.com> Date: Fri, 29 May 2020 14:58:46 +0800 Subject: [PATCH 1/2] fix --- Pipfile | 1 + .../js/plugins/image-dialog/image-dialog.js | 360 +++++++++--------- 2 files changed, 191 insertions(+), 170 deletions(-) diff --git a/Pipfile b/Pipfile index 54b012e..ce7af24 100644 --- a/Pipfile +++ b/Pipfile @@ -4,6 +4,7 @@ verify_ssl = true name = "pypi" [packages] +pillow="6.0" django = "==2.2.10" django-mdeditor = "*" diff --git a/mdeditor/static/mdeditor/js/plugins/image-dialog/image-dialog.js b/mdeditor/static/mdeditor/js/plugins/image-dialog/image-dialog.js index 2d7b42c..9ae4b73 100755 --- a/mdeditor/static/mdeditor/js/plugins/image-dialog/image-dialog.js +++ b/mdeditor/static/mdeditor/js/plugins/image-dialog/image-dialog.js @@ -9,117 +9,121 @@ * @license MIT */ -(function() { +(function () { var factory = function (exports) { - var pluginName = "image-dialog"; + var pluginName = "image-dialog"; - exports.fn.imageDialog = function() { + exports.fn.imageDialog = function () { - var _this = this; - var cm = this.cm; - var lang = this.lang; - var editor = this.editor; - var settings = this.settings; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - var imageLang = lang.dialog.image; + var _this = this; + var cm = this.cm; + var lang = this.lang; + var editor = this.editor; + var settings = this.settings; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + var imageLang = lang.dialog.image; var classPrefix = this.classPrefix; - var iframeName = classPrefix + "image-iframe"; - var dialogName = classPrefix + pluginName, dialog; - var img_width = "img_width"; - var img_height = "img_height"; - var img_per = "img_per"; - var img_qua = "img_qua"; - - imageLang.width=imageLang.width?imageLang.width:"宽"; - imageLang.height=imageLang.height?imageLang.height:"高"; - imageLang.scaling=imageLang.scaling?imageLang.scaling:"缩放"; - imageLang.quality=imageLang.quality?imageLang.quality:"质量(小于95)"; - - cm.focus(); - - var loading = function(show) { + var iframeName = classPrefix + "image-iframe"; + var dialogName = classPrefix + pluginName, dialog; + var img_width = "img_width"; + var img_height = "img_height"; + var img_scaling = "img_scaling"; + var img_quality = "img_quality"; + //设定默认值 + var width_default = 0; + var height_default = 0; + //默认不缩放 + var scaling_default = 1; + var quality_default = 75; + + imageLang.width = imageLang.width ? imageLang.width : "宽"; + imageLang.height = imageLang.height ? imageLang.height : "高"; + imageLang.scaling = imageLang.scaling ? imageLang.scaling : "缩放"; + imageLang.quality = imageLang.quality ? imageLang.quality : "质量(小于95)"; + + + cm.focus(); + + var loading = function (show) { var _loading = dialog.find("." + classPrefix + "dialog-mask"); _loading[(show) ? "show" : "hide"](); }; - if (editor.find("." + dialogName).length < 1) - { - var guid = (new Date).getTime(); + if (editor.find("." + dialogName).length < 1) { + var guid = (new Date).getTime(); var action = settings.imageUploadURL + (settings.imageUploadURL.indexOf("?") >= 0 ? "&" : "?") + "guid=" + guid; - if (settings.crossDomainUpload) - { + if (settings.crossDomainUpload) { action += "&callback=" + settings.uploadCallbackURL + "&dialog_id=editormd-image-dialog-" + guid; } - - var dialogContent = ( (settings.imageUpload) ? "