From f24a2f7d0176f8ee232d21aaa251ff8ed5aad7d1 Mon Sep 17 00:00:00 2001 From: Karel Vasicek Date: Tue, 24 Oct 2023 15:52:12 +0200 Subject: [PATCH 1/2] Tweaked inserting image to Redactor X content --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/redactorX/insertHtml.js | 33 +++++++++++++++++---------------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be77f54..f8bfb81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 3.0.1, 2023-10-24 + +### Changed + +* Changed logic how image is inserted to Redactor X content + ## 3.0.0, 2023-09-15 ### Added diff --git a/package.json b/package.json index d2ae967..708e281 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uploadcare-redactor", - "version": "3.0.0", + "version": "3.0.1", "widgetVersion": "3.x", "description": "File Uploader by Uploadcare. The plugin for Imperavi Redactor to work with Uploadcare Widget.", "main": "./src/uploadcare.js", diff --git a/src/redactorX/insertHtml.js b/src/redactorX/insertHtml.js index e5f6b93..b5f09b3 100644 --- a/src/redactorX/insertHtml.js +++ b/src/redactorX/insertHtml.js @@ -4,22 +4,23 @@ export default function insertHtml(plugin, fileInfo) { var fileUrl = getFileUrl(fileInfo) if (fileInfo.isImage) { - var openTag = plugin.ucOpts.imageTag ? '<' + plugin.ucOpts.imageTag + '>' : '' - var closeTag = plugin.ucOpts.imageTag ? '' : '' + var $image = plugin.dom('') + .attr('src', fileUrl) + .attr('alt', fileInfo.name) + .attr('data-image', fileInfo.uuid); - plugin.app.insertion.insertHtml( - openTag + - '' +
-      fileInfo.name +
-      '' + - closeTag - ) - } - else { - plugin.app.insertion.insertHtml('' + fileInfo.name + '') + if (plugin.ucOpts.imageTag) { + var $source = plugin.dom('<' + plugin.ucOpts.imageTag + '>'); + $source.append($image); + } else { + var $source = $image; + } + + var instance = plugin.app.create('block.image', $source); + plugin.app.block.add({ instance: instance, type: 'image' }); + + plugin.app.broadcast('image.upload', { instance: instance, data: {src: fileUrl, id: fileInfo.uuid, name: fileInfo.name, width: fileInfo.crop.width, height: fileInfo.crop.height}}); + } else { + plugin.app.insertion.insertHtml('' + fileInfo.name + ''); } } From 297f54582d902ec8f539b36163b21df02b9a03b0 Mon Sep 17 00:00:00 2001 From: Karel Vasicek Date: Wed, 25 Oct 2023 08:01:45 +0200 Subject: [PATCH 2/2] Changed version --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8bfb81..2b381ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## 3.0.1, 2023-10-24 +## 3.1.0, 2023-10-24 ### Changed diff --git a/package.json b/package.json index 708e281..48cc58e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uploadcare-redactor", - "version": "3.0.1", + "version": "3.1.0", "widgetVersion": "3.x", "description": "File Uploader by Uploadcare. The plugin for Imperavi Redactor to work with Uploadcare Widget.", "main": "./src/uploadcare.js",