Loading core/modules/ckeditor5/js/ckeditor5.es6.js +3 −30 Original line number Diff line number Diff line Loading @@ -497,38 +497,11 @@ editor.updateSourceElement(); } else { element.removeAttribute('contentEditable'); // Prepare variables that will be used when discarding Quickedit changes. let textElement = null; let originalValue = null; const usingQuickEdit = (((Drupal || {}).quickedit || {}).editors || {}) .editor; if (usingQuickEdit) { // The revert() function in QuickEdit's text editor does not work with // CKEditor 5, as it is triggered before CKEditor 5 is fully // destroyed. This function is overridden so the functionality it // provides can happen after the CKEditor destroy() promise is // fulfilled. // This pulls the necessary values from the QuickEdit Backbone Model // before it is destroyed, so they can be used by // `editor.destroy().then()` to perform the expected revert. Drupal.quickedit.editors.editor.prototype.revert = function revertQuickeditChanges() { textElement = this.$textElement[0]; originalValue = this.model.get('originalValue'); }; } editor // Return the promise to allow external code to queue code to // execute after the destroy is complete. return editor .destroy() .then(() => { // If textElement and originalValue are not null, a QuickEdit // revert has been requested. Perform the revert here as it // can't happen until the CKEditor instance is destroyed. if (textElement && originalValue) { textElement.innerHTML = originalValue; } // Clean up stored references. Drupal.CKEditor5Instances.delete(id); callbacks.delete(id); Loading core/modules/ckeditor5/js/ckeditor5.js +1 −16 Original line number Diff line number Diff line Loading @@ -237,22 +237,7 @@ editor.updateSourceElement(); } else { element.removeAttribute('contentEditable'); let textElement = null; let originalValue = null; const usingQuickEdit = (((Drupal || {}).quickedit || {}).editors || {}).editor; if (usingQuickEdit) { Drupal.quickedit.editors.editor.prototype.revert = function revertQuickeditChanges() { textElement = this.$textElement[0]; originalValue = this.model.get('originalValue'); }; } editor.destroy().then(() => { if (textElement && originalValue) { textElement.innerHTML = originalValue; } return editor.destroy().then(() => { Drupal.CKEditor5Instances.delete(id); callbacks.delete(id); Loading core/modules/quickedit/js/editors/formattedTextEditor.es6.js +49 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,55 @@ this.$textElement = this.$el; } this.model.set('originalValue', this.$textElement.html()); if ( Drupal.editors && Drupal.editors.ckeditor5 && once('quickedit-ckeditor5-destroy', 'body').length ) { /** * CKEditor 5 destroy lifecycle is different because is uses Promises. */ const ckeditor5Detach = Drupal.editors.ckeditor5.detach; Drupal.editors.ckeditor5.detach = function quickeditDetach( element, format, trigger, ) { const destroyPromise = ckeditor5Detach.call( this, element, format, trigger, ); if (destroyPromise && destroyPromise.then) { let textElement = null; let originalValue = null; // The revert() function in QuickEdit's text editor does not work with // CKEditor 5, as it is triggered before CKEditor 5 is fully // destroyed. This function is overridden so the functionality it // provides can happen after the CKEditor destroy() promise is // fulfilled. // This pulls the necessary values from the QuickEdit Backbone Model // before it is destroyed, so they can be used by // `editor.destroy().then()` to perform the expected revert. Drupal.quickedit.editors.editor.prototype.revert = function revertQuickeditChanges() { textElement = this.$textElement[0]; originalValue = this.model.get('originalValue'); }; destroyPromise.then(() => { // If textElement and originalValue are not null, a QuickEdit // revert has been requested. Perform the revert here as it // can't happen until the CKEditor instance is destroyed. if (textElement && originalValue) { textElement.innerHTML = originalValue; } }); } }; } }, /** Loading core/modules/quickedit/js/editors/formattedTextEditor.js +24 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,30 @@ } this.model.set('originalValue', this.$textElement.html()); if (Drupal.editors && Drupal.editors.ckeditor5 && once('quickedit-ckeditor5-destroy', 'body').length) { const ckeditor5Detach = Drupal.editors.ckeditor5.detach; Drupal.editors.ckeditor5.detach = function quickeditDetach(element, format, trigger) { const destroyPromise = ckeditor5Detach.call(this, element, format, trigger); if (destroyPromise && destroyPromise.then) { let textElement = null; let originalValue = null; Drupal.quickedit.editors.editor.prototype.revert = function revertQuickeditChanges() { textElement = this.$textElement[0]; originalValue = this.model.get('originalValue'); }; destroyPromise.then(() => { if (textElement && originalValue) { textElement.innerHTML = originalValue; } }); } }; } }, getEditedElement() { Loading Loading
core/modules/ckeditor5/js/ckeditor5.es6.js +3 −30 Original line number Diff line number Diff line Loading @@ -497,38 +497,11 @@ editor.updateSourceElement(); } else { element.removeAttribute('contentEditable'); // Prepare variables that will be used when discarding Quickedit changes. let textElement = null; let originalValue = null; const usingQuickEdit = (((Drupal || {}).quickedit || {}).editors || {}) .editor; if (usingQuickEdit) { // The revert() function in QuickEdit's text editor does not work with // CKEditor 5, as it is triggered before CKEditor 5 is fully // destroyed. This function is overridden so the functionality it // provides can happen after the CKEditor destroy() promise is // fulfilled. // This pulls the necessary values from the QuickEdit Backbone Model // before it is destroyed, so they can be used by // `editor.destroy().then()` to perform the expected revert. Drupal.quickedit.editors.editor.prototype.revert = function revertQuickeditChanges() { textElement = this.$textElement[0]; originalValue = this.model.get('originalValue'); }; } editor // Return the promise to allow external code to queue code to // execute after the destroy is complete. return editor .destroy() .then(() => { // If textElement and originalValue are not null, a QuickEdit // revert has been requested. Perform the revert here as it // can't happen until the CKEditor instance is destroyed. if (textElement && originalValue) { textElement.innerHTML = originalValue; } // Clean up stored references. Drupal.CKEditor5Instances.delete(id); callbacks.delete(id); Loading
core/modules/ckeditor5/js/ckeditor5.js +1 −16 Original line number Diff line number Diff line Loading @@ -237,22 +237,7 @@ editor.updateSourceElement(); } else { element.removeAttribute('contentEditable'); let textElement = null; let originalValue = null; const usingQuickEdit = (((Drupal || {}).quickedit || {}).editors || {}).editor; if (usingQuickEdit) { Drupal.quickedit.editors.editor.prototype.revert = function revertQuickeditChanges() { textElement = this.$textElement[0]; originalValue = this.model.get('originalValue'); }; } editor.destroy().then(() => { if (textElement && originalValue) { textElement.innerHTML = originalValue; } return editor.destroy().then(() => { Drupal.CKEditor5Instances.delete(id); callbacks.delete(id); Loading
core/modules/quickedit/js/editors/formattedTextEditor.es6.js +49 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,55 @@ this.$textElement = this.$el; } this.model.set('originalValue', this.$textElement.html()); if ( Drupal.editors && Drupal.editors.ckeditor5 && once('quickedit-ckeditor5-destroy', 'body').length ) { /** * CKEditor 5 destroy lifecycle is different because is uses Promises. */ const ckeditor5Detach = Drupal.editors.ckeditor5.detach; Drupal.editors.ckeditor5.detach = function quickeditDetach( element, format, trigger, ) { const destroyPromise = ckeditor5Detach.call( this, element, format, trigger, ); if (destroyPromise && destroyPromise.then) { let textElement = null; let originalValue = null; // The revert() function in QuickEdit's text editor does not work with // CKEditor 5, as it is triggered before CKEditor 5 is fully // destroyed. This function is overridden so the functionality it // provides can happen after the CKEditor destroy() promise is // fulfilled. // This pulls the necessary values from the QuickEdit Backbone Model // before it is destroyed, so they can be used by // `editor.destroy().then()` to perform the expected revert. Drupal.quickedit.editors.editor.prototype.revert = function revertQuickeditChanges() { textElement = this.$textElement[0]; originalValue = this.model.get('originalValue'); }; destroyPromise.then(() => { // If textElement and originalValue are not null, a QuickEdit // revert has been requested. Perform the revert here as it // can't happen until the CKEditor instance is destroyed. if (textElement && originalValue) { textElement.innerHTML = originalValue; } }); } }; } }, /** Loading
core/modules/quickedit/js/editors/formattedTextEditor.js +24 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,30 @@ } this.model.set('originalValue', this.$textElement.html()); if (Drupal.editors && Drupal.editors.ckeditor5 && once('quickedit-ckeditor5-destroy', 'body').length) { const ckeditor5Detach = Drupal.editors.ckeditor5.detach; Drupal.editors.ckeditor5.detach = function quickeditDetach(element, format, trigger) { const destroyPromise = ckeditor5Detach.call(this, element, format, trigger); if (destroyPromise && destroyPromise.then) { let textElement = null; let originalValue = null; Drupal.quickedit.editors.editor.prototype.revert = function revertQuickeditChanges() { textElement = this.$textElement[0]; originalValue = this.model.get('originalValue'); }; destroyPromise.then(() => { if (textElement && originalValue) { textElement.innerHTML = originalValue; } }); } }; } }, getEditedElement() { Loading