1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-16 11:44:42 +02:00

Update TinyMCE and CKEditor modules to recognize versions in URLs

This commit is contained in:
Ryan Cramer
2023-12-15 13:37:01 -05:00
parent 8c11a9939c
commit b3d84f15e1
4 changed files with 41 additions and 6 deletions

View File

@@ -180,6 +180,14 @@
var modalUri = ProcessWire.config.urls.admin + 'page/image/'; var modalUri = ProcessWire.config.urls.admin + 'page/image/';
var queryString = '?id=' + page_id + '&edit_page_id=' + edit_page_id + '&modal=1'; var queryString = '?id=' + page_id + '&edit_page_id=' + edit_page_id + '&modal=1';
var version = 0;
if(typeof ProcessWire.config.PagesVersions !== 'undefined') {
if(ProcessWire.config.PagesVersions.page == page_id) {
version = ProcessWire.config.PagesVersions.version;
queryString += '&version=' + version;
}
}
if(file.length) queryString += "&file=" + file; if(file.length) queryString += "&file=" + file;
if(imgWidth) queryString += "&width=" + imgWidth; if(imgWidth) queryString += "&width=" + imgWidth;
@@ -320,7 +328,8 @@
'&file=' + file + '&file=' + file +
'&width=' + width + '&width=' + width +
'&height=' + height + '&height=' + height +
'&hidpi=' + hidpi; '&hidpi=' + hidpi +
'&version=' + version;
if(rotate) resizeURL += '&rotate=' + rotate; if(rotate) resizeURL += '&rotate=' + rotate;
if($img.hasClass('flip_horizontal')) resizeURL += '&flip=h'; if($img.hasClass('flip_horizontal')) resizeURL += '&flip=h';
@@ -339,7 +348,7 @@
click: function() { click: function() {
var $i = $iframe.contents(); var $i = $iframe.contents();
var page_id = jQuery("#page_id", $i).val(); var page_id = jQuery("#page_id", $i).val();
$iframe.attr('src', modalUri + '?id=' + page_id + '&modal=1'); $iframe.attr('src', modalUri + '?id=' + page_id + '&modal=1&version=' + version);
$iframe.setButtons({}); $iframe.setButtons({});
} }
}, { }, {

File diff suppressed because one or more lines are too long

View File

@@ -242,6 +242,12 @@ var InputfieldTinyMCE = {
'&width=' + width + '&width=' + width +
'&hidpi=' + hidpi + '&hidpi=' + hidpi +
'&file=' + src; '&file=' + src;
if(typeof ProcessWire.config.PagesVersions !== 'undefined') {
if(ProcessWire.config.PagesVersions.page == $('#Inputfield_id').val()) {
url += '&version=' + ProcessWire.config.PagesVersions.version;
}
}
t.log('Resizing image to width=' + width, url); t.log('Resizing image to width=' + width, url);

View File

@@ -126,6 +126,7 @@ function pwTinyMCE_image(editor) {
var imagePageId = $('#page_id', $i).val(); var imagePageId = $('#page_id', $i).val();
var hidpi = $("#selected_image_hidpi", $i).is(":checked") ? 1 : 0; var hidpi = $("#selected_image_hidpi", $i).is(":checked") ? 1 : 0;
var rotate = parseInt($("#selected_image_rotate", $i).val()); var rotate = parseInt($("#selected_image_rotate", $i).val());
var version = 0;
$iframe.dialog('disable'); $iframe.dialog('disable');
$iframe.setTitle(labels.savingImage); // Saving Image $iframe.setTitle(labels.savingImage); // Saving Image
@@ -136,12 +137,19 @@ function pwTinyMCE_image(editor) {
file = file.substring(file.lastIndexOf('/')+1); file = file.substring(file.lastIndexOf('/')+1);
if(typeof ProcessWire.config.PagesVersions !== 'undefined') {
if(ProcessWire.config.PagesVersions.page == imagePageId) {
version = ProcessWire.config.PagesVersions.version;
}
}
var resizeUrl = modalUrl + 'resize' + var resizeUrl = modalUrl + 'resize' +
'?id=' + imagePageId + '?id=' + imagePageId +
'&file=' + file + '&file=' + file +
'&width=' + width + '&width=' + width +
'&height=' + height + '&height=' + height +
'&hidpi=' + hidpi; '&hidpi=' + hidpi +
'&version=' + version;
if(rotate) resizeUrl += '&rotate=' + rotate; if(rotate) resizeUrl += '&rotate=' + rotate;
@@ -185,7 +193,13 @@ function pwTinyMCE_image(editor) {
click: function() { click: function() {
var $i = $iframe.contents(); var $i = $iframe.contents();
var imagePageId = $('#page_id', $i).val(); var imagePageId = $('#page_id', $i).val();
$iframe.attr('src', modalUrl + '?id=' + imagePageId + '&modal=1'); var version = 0;
if(typeof ProcessWire.config.PagesVersions !== 'undefined') {
if(ProcessWire.config.PagesVersions.page == imagePageId) {
version = ProcessWire.config.PagesVersions.version;
}
}
$iframe.attr('src', modalUrl + '?id=' + imagePageId + '&modal=1&version=' + version);
$iframe.setButtons({}); $iframe.setButtons({});
} }
} ]; } ];
@@ -282,6 +296,12 @@ function pwTinyMCE_image(editor) {
queryString += ('&winwidth=' + ($(window).width() - 30)); queryString += ('&winwidth=' + ($(window).width() - 30));
if(typeof ProcessWire.config.PagesVersions !== 'undefined') {
if(ProcessWire.config.PagesVersions.page == pageId) {
queryString += '&version=' + ProcessWire.config.PagesVersions.version;
}
}
return queryString; return queryString;
} }
@@ -362,4 +382,4 @@ tinymce.PluginManager.add('pwimage', (editor, url) => {
return { return {
getMetadata: () => ({ name: 'Image' }) getMetadata: () => ({ name: 'Image' })
}; };
}); });