mirror of
https://github.com/processwire/processwire.git
synced 2025-08-10 08:44:46 +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:
@@ -342,18 +342,16 @@ var InputfieldTinyMCE = {
|
|||||||
|
|
||||||
if(!$inputfield.length) $inputfield = $editor.closest('.Inputfield');
|
if(!$inputfield.length) $inputfield = $editor.closest('.Inputfield');
|
||||||
|
|
||||||
editor.on('Dirty', function() {
|
function changed() {
|
||||||
$inputfield.trigger('change');
|
|
||||||
// t.log('event Dirty');
|
|
||||||
});
|
|
||||||
|
|
||||||
editor.on('input', function() {
|
|
||||||
if(inputTimeout) clearTimeout(inputTimeout);
|
if(inputTimeout) clearTimeout(inputTimeout);
|
||||||
inputTimeout = setTimeout(function() {
|
inputTimeout = setTimeout(function() {
|
||||||
$inputfield.trigger('change');
|
$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
|
// for image resizes
|
||||||
if(features.indexOf('imgResize') > -1) {
|
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
|
// @todo account for case where image in figure is resized, and figure needs its width updated with the image
|
||||||
if(e.target.nodeName === 'IMG') {
|
if(e.target.nodeName === 'IMG') {
|
||||||
t.imageResized(editor, e.target, e.width);
|
t.imageResized(editor, e.target, e.width);
|
||||||
|
changed();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -372,9 +371,12 @@ var InputfieldTinyMCE = {
|
|||||||
editor.on('ExecCommand', function(e, f) {
|
editor.on('ExecCommand', function(e, f) {
|
||||||
if(e.command === 'mceFocus') return;
|
if(e.command === 'mceFocus') return;
|
||||||
t.log('command: ' + e.command, e);
|
t.log('command: ' + e.command, e);
|
||||||
if(e.command === 'mceToggleFormat' && e.value && e.value.indexOf('align') === 0) {
|
if(e.command === 'mceToggleFormat') {
|
||||||
var editor = this;
|
if(e.value && e.value.indexOf('align') === 0) {
|
||||||
t.elementAligned(editor);
|
var editor = this;
|
||||||
|
t.elementAligned(editor);
|
||||||
|
}
|
||||||
|
changed();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -74,7 +74,7 @@ class InputfieldTinyMCE extends InputfieldTextarea implements ConfigurableModule
|
|||||||
return array(
|
return array(
|
||||||
'title' => 'TinyMCE',
|
'title' => 'TinyMCE',
|
||||||
'summary' => 'TinyMCE rich text editor version ' . self::mceVersion . '.',
|
'summary' => 'TinyMCE rich text editor version ' . self::mceVersion . '.',
|
||||||
'version' => 615,
|
'version' => 616,
|
||||||
'icon' => 'keyboard-o',
|
'icon' => 'keyboard-o',
|
||||||
'requires' => 'ProcessWire>=3.0.200, MarkupHTMLPurifier',
|
'requires' => 'ProcessWire>=3.0.200, MarkupHTMLPurifier',
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user