[IMP] web_editor: allow onRemove to be async
Now, a snippet option can do async operations in its onRemove implementation. task-2636545 X-original-commit: ef2e55d7f407dedfbf724f2cae32a0fcaede6890 Part-of: odoo/odoo#77256
This commit is contained in:
@@ -451,9 +451,9 @@ var SnippetEditor = Widget.extend({
|
||||
await new Promise(resolve => {
|
||||
this.trigger_up('call_for_each_child_snippet', {
|
||||
$snippet: this.$target,
|
||||
callback: function (editor, $snippet) {
|
||||
callback: async function (editor, $snippet) {
|
||||
for (var i in editor.styles) {
|
||||
editor.styles[i].onRemove();
|
||||
await editor.styles[i].onRemove();
|
||||
}
|
||||
},
|
||||
onSuccess: resolve,
|
||||
|
||||
@@ -2950,8 +2950,9 @@ const SnippetOptionWidget = Widget.extend({
|
||||
* Called when the associated snippet is about to be removed from the DOM.
|
||||
*
|
||||
* @abstract
|
||||
* @returns {Promise|undefined}
|
||||
*/
|
||||
onRemove: function () {},
|
||||
onRemove: async function () {},
|
||||
/**
|
||||
* Called when the target is shown, only meaningful if the target was hidden
|
||||
* at some point (typically used for 'invisible' snippets).
|
||||
|
||||
Reference in New Issue
Block a user