Skip to content

Commit bdd062c

Browse files
authoredOct 25, 2023
Merge pull request #36 from FloAppsLtd/redactor-x
2 parents 5966ed2 + 297f545 commit bdd062c

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed
 

‎CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/),
66
and this project adheres to
77
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).
88

9+
## 3.1.0, 2023-10-24
10+
11+
### Changed
12+
13+
* Changed logic how image is inserted to Redactor X content
14+
915
## 3.0.0, 2023-09-15
1016

1117
### Added

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "uploadcare-redactor",
3-
"version": "3.0.0",
3+
"version": "3.1.0",
44
"widgetVersion": "3.x",
55
"description": "File Uploader by Uploadcare. The plugin for Imperavi Redactor to work with Uploadcare Widget.",
66
"main": "./src/uploadcare.js",

‎src/redactorX/insertHtml.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ export default function insertHtml(plugin, fileInfo) {
44
var fileUrl = getFileUrl(fileInfo)
55

66
if (fileInfo.isImage) {
7-
var openTag = plugin.ucOpts.imageTag ? '<' + plugin.ucOpts.imageTag + '>' : ''
8-
var closeTag = plugin.ucOpts.imageTag ? '</' + plugin.ucOpts.imageTag + '>' : ''
7+
var $image = plugin.dom('<img>')
8+
.attr('src', fileUrl)
9+
.attr('alt', fileInfo.name)
10+
.attr('data-image', fileInfo.uuid);
911

10-
plugin.app.insertion.insertHtml(
11-
openTag +
12-
'<img src="' +
13-
fileUrl +
14-
'" alt="' +
15-
fileInfo.name +
16-
'" data-image="' +
17-
fileInfo.uuid +
18-
'" />' +
19-
closeTag
20-
)
21-
}
22-
else {
23-
plugin.app.insertion.insertHtml('<a href="' + fileUrl + '" data-file="' + fileInfo.uuid + '">' + fileInfo.name + '</a>')
12+
if (plugin.ucOpts.imageTag) {
13+
var $source = plugin.dom('<' + plugin.ucOpts.imageTag + '>');
14+
$source.append($image);
15+
} else {
16+
var $source = $image;
17+
}
18+
19+
var instance = plugin.app.create('block.image', $source);
20+
plugin.app.block.add({ instance: instance, type: 'image' });
21+
22+
plugin.app.broadcast('image.upload', { instance: instance, data: {src: fileUrl, id: fileInfo.uuid, name: fileInfo.name, width: fileInfo.crop.width, height: fileInfo.crop.height}});
23+
} else {
24+
plugin.app.insertion.insertHtml('<a href="' + fileUrl + '" data-file="' + fileInfo.uuid + '">' + fileInfo.name + '</a>');
2425
}
2526
}

0 commit comments

Comments
 (0)