mirror of
https://github.com/moodle/moodle.git
synced 2025-03-18 14:40:06 +01:00
MDL-47736 editor_atto: only save/restore draft when necessary
This commit is contained in:
parent
c57681ed49
commit
e924e1b33a
@ -793,7 +793,7 @@ EditorAutosave.prototype = {
|
||||
* @property lastText
|
||||
* @type string
|
||||
*/
|
||||
lastText: null,
|
||||
lastText: "",
|
||||
|
||||
/**
|
||||
* Autosave instance.
|
||||
@ -848,10 +848,16 @@ EditorAutosave.prototype = {
|
||||
success: function(id,o) {
|
||||
if (typeof o.responseText !== "undefined" && o.responseText !== "") {
|
||||
response_json = JSON.parse(o.responseText);
|
||||
|
||||
// Revert untouched editor contents to an empty string.
|
||||
if (response_json.result === '<p></p>' || response_json.result === '<p><br></p>') {
|
||||
response_json.result = '';
|
||||
}
|
||||
|
||||
if (response_json.error || typeof response_json.result === 'undefined') {
|
||||
Y.log('Error occurred recovering draft text: ' + response_json.error, 'debug', LOGNAME_AUTOSAVE);
|
||||
this.showMessage(M.util.get_string('errortextrecovery', 'editor_atto'), NOTIFY_WARNING, RECOVER_MESSAGE_TIMEOUT);
|
||||
} else if (response_json !== this.textarea.get('value')) {
|
||||
} else if (response_json.result !== this.textarea.get('value')) {
|
||||
Y.log('Autosave text found - recover it.', 'debug', LOGNAME_AUTOSAVE);
|
||||
this.recoverText(response_json.result);
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -788,7 +788,7 @@ EditorAutosave.prototype = {
|
||||
* @property lastText
|
||||
* @type string
|
||||
*/
|
||||
lastText: null,
|
||||
lastText: "",
|
||||
|
||||
/**
|
||||
* Autosave instance.
|
||||
@ -843,9 +843,15 @@ EditorAutosave.prototype = {
|
||||
success: function(id,o) {
|
||||
if (typeof o.responseText !== "undefined" && o.responseText !== "") {
|
||||
response_json = JSON.parse(o.responseText);
|
||||
|
||||
// Revert untouched editor contents to an empty string.
|
||||
if (response_json.result === '<p></p>' || response_json.result === '<p><br></p>') {
|
||||
response_json.result = '';
|
||||
}
|
||||
|
||||
if (response_json.error || typeof response_json.result === 'undefined') {
|
||||
this.showMessage(M.util.get_string('errortextrecovery', 'editor_atto'), NOTIFY_WARNING, RECOVER_MESSAGE_TIMEOUT);
|
||||
} else if (response_json !== this.textarea.get('value')) {
|
||||
} else if (response_json.result !== this.textarea.get('value')) {
|
||||
this.recoverText(response_json.result);
|
||||
}
|
||||
this._fireSelectionChanged();
|
||||
|
10
lib/editor/atto/yui/src/editor/js/autosave.js
vendored
10
lib/editor/atto/yui/src/editor/js/autosave.js
vendored
@ -89,7 +89,7 @@ EditorAutosave.prototype = {
|
||||
* @property lastText
|
||||
* @type string
|
||||
*/
|
||||
lastText: null,
|
||||
lastText: "",
|
||||
|
||||
/**
|
||||
* Autosave instance.
|
||||
@ -144,10 +144,16 @@ EditorAutosave.prototype = {
|
||||
success: function(id,o) {
|
||||
if (typeof o.responseText !== "undefined" && o.responseText !== "") {
|
||||
response_json = JSON.parse(o.responseText);
|
||||
|
||||
// Revert untouched editor contents to an empty string.
|
||||
if (response_json.result === '<p></p>' || response_json.result === '<p><br></p>') {
|
||||
response_json.result = '';
|
||||
}
|
||||
|
||||
if (response_json.error || typeof response_json.result === 'undefined') {
|
||||
Y.log('Error occurred recovering draft text: ' + response_json.error, 'debug', LOGNAME_AUTOSAVE);
|
||||
this.showMessage(M.util.get_string('errortextrecovery', 'editor_atto'), NOTIFY_WARNING, RECOVER_MESSAGE_TIMEOUT);
|
||||
} else if (response_json !== this.textarea.get('value')) {
|
||||
} else if (response_json.result !== this.textarea.get('value')) {
|
||||
Y.log('Autosave text found - recover it.', 'debug', LOGNAME_AUTOSAVE);
|
||||
this.recoverText(response_json.result);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user