1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 08:17:12 +02:00

Update InputfieldTinyMCE to trigger change events for formatting and image resize actions. This is so that they can be detected by PageAutosave, ProDrafts, UserActivity, or other modules that might track change events.

This commit is contained in:
Ryan Cramer
2023-09-15 08:19:59 -04:00
parent 2ea60ee7d5
commit 36580883d7
2 changed files with 15 additions and 13 deletions

View File

@@ -342,18 +342,16 @@ var InputfieldTinyMCE = {
if(!$inputfield.length) $inputfield = $editor.closest('.Inputfield');
editor.on('Dirty', function() {
$inputfield.trigger('change');
// t.log('event Dirty');
});
editor.on('input', function() {
function changed() {
if(inputTimeout) clearTimeout(inputTimeout);
inputTimeout = setTimeout(function() {
$inputfield.trigger('change');
// t.log('event Input');
}, 500);
});
}, 500);
}
editor.on('Dirty', function() { changed() });
editor.on('SetContent', function() { changed() });
editor.on('input', function() { changed() });
// for image resizes
if(features.indexOf('imgResize') > -1) {
@@ -361,6 +359,7 @@ var InputfieldTinyMCE = {
// @todo account for case where image in figure is resized, and figure needs its width updated with the image
if(e.target.nodeName === 'IMG') {
t.imageResized(editor, e.target, e.width);
changed();
}
});
}
@@ -372,9 +371,12 @@ var InputfieldTinyMCE = {
editor.on('ExecCommand', function(e, f) {
if(e.command === 'mceFocus') return;
t.log('command: ' + e.command, e);
if(e.command === 'mceToggleFormat' && e.value && e.value.indexOf('align') === 0) {
var editor = this;
t.elementAligned(editor);
if(e.command === 'mceToggleFormat') {
if(e.value && e.value.indexOf('align') === 0) {
var editor = this;
t.elementAligned(editor);
}
changed();
}
});

View File

@@ -74,7 +74,7 @@ class InputfieldTinyMCE extends InputfieldTextarea implements ConfigurableModule
return array(
'title' => 'TinyMCE',
'summary' => 'TinyMCE rich text editor version ' . self::mceVersion . '.',
'version' => 615,
'version' => 616,
'icon' => 'keyboard-o',
'requires' => 'ProcessWire>=3.0.200, MarkupHTMLPurifier',
);