From c0c779d6622f2a9e817bd15838877f13ee0240c7 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Wed, 17 Jul 2019 12:45:16 +0000 Subject: [FIX] web_editor: remove "missing `class` on parent" On a chromium based browser. Install theme_treehouse, add the "Step" widget. Double click on the FA-icon, error in log. The parent element of `self.$media` does not have a `class` attribute, accessing that attribute returns `undefined` and `cannot call match on undefined` error. closes odoo/odoo#34946 Signed-off-by: Nicolas Lempereur (nle) --- addons/web_editor/static/src/js/widgets/widgets.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web_editor/static/src') diff --git a/addons/web_editor/static/src/js/widgets/widgets.js b/addons/web_editor/static/src/js/widgets/widgets.js index f7d5e3f74c9..c1e181eedaa 100644 --- a/addons/web_editor/static/src/js/widgets/widgets.js +++ b/addons/web_editor/static/src/js/widgets/widgets.js @@ -1162,9 +1162,9 @@ var MediaDialog = Dialog.extend({ tabToShow = 'image'; } else if (self.$media.is('a.o_image')) { tabToShow = 'document'; - } else if (self.$media.attr('class').match(/(^|\s)media_iframe_video($|\s)/)) { + } else if (self.$media.hasClass('media_iframe_video')) { tabToShow = 'video'; - } else if (self.$media.parent().attr('class').match(/(^|\s)media_iframe_video($|\s)/)) { + } else if (self.$media.parent().hasClass('media_iframe_video')) { self.$media = self.$media.parent(); self.media = self.$media[0]; tabToShow = 'video'; -- cgit v1.2.3 From 2136ea5646d77869469a463db4ecd32f0f20ae1e Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Fri, 12 Jul 2019 12:54:25 +0000 Subject: [FIX] web_editor, website: consistently apply undo on CTRL-Z MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a bug in Website, that can be reproduced like so: - insert a snippet - insert a char in it - 2x CTRL-Z The second CTRL-Z didn't do anything because Summernote moved the range to the header, which is not editable. This fix moves the range to the first editable element in the editor in these cases, thereby keeping the focus in an editable area, and ensuring that hotkeys still function. The history feature being non-tested as of this version, no test could be added for this fix. closes odoo/odoo#34834 Signed-off-by: Adrien Dieudonné (adr) --- addons/web_editor/static/src/js/wysiwyg/plugin/history.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'addons/web_editor/static/src') diff --git a/addons/web_editor/static/src/js/wysiwyg/plugin/history.js b/addons/web_editor/static/src/js/wysiwyg/plugin/history.js index a60ab41523b..addf6383783 100644 --- a/addons/web_editor/static/src/js/wysiwyg/plugin/history.js +++ b/addons/web_editor/static/src/js/wysiwyg/plugin/history.js @@ -19,6 +19,12 @@ var HistoryPlugin = Plugins.history.extend({ console.error(e); } this.context.invoke('editor.focus'); + var newRange = this.context.invoke('editor.createRange'); + if (!this.options.isEditableNode(newRange.sc)) { + var firstEditableSel = '[contenteditable="true"]:not(":hidden")'; + var sc = this.$editable.find(firstEditableSel)[0]; + this.context.invoke('editor.setRange', sc, 0, sc, 0).select(); + } }, /** * Clear the history. -- cgit v1.2.3 From ac170e8a8238a9b0aa468f83b11aabc4cd9493de Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 19 Jul 2019 14:50:15 +0000 Subject: [FIX] web_editor, website: stop snippet animations before cloning Before this commit, when a snippet was cloned, its animation was not destroyed first. The flow was: 1. Clone the snippet (DOM) - web_editor trigger `snippet_cloned` 2. Start cloned snippet animation - website listen `snippet_cloned` This was causing bugs, eg facebook snippet for which the animation is to create an iframe containing the facebook widget. When cloning this snippet, its iframe would be cloned to, then its animation would be started, creating another iframe. To fix such flows, the snippet cloning flow should be: 1. Strop the snippet animation 2. Clone the snippet (DOM) - web_editor trigger `snippet_cloned` 3. Start cloned snippet animation - website listen `snippet_cloned` 4. Restart the original snippet animation task-1951466 closes odoo/odoo#35029 Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.editor.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/web_editor/static/src') diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 11a96897fa6..803a190256f 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -337,6 +337,9 @@ var SnippetEditor = Widget.extend({ */ _onCloneClick: function (ev) { ev.preventDefault(); + + this.trigger_up('snippet_will_be_cloned', {$target: this.$target}); + var $clone = this.$target.clone(false); this.trigger_up('request_history_undo_record', {$target: this.$target}); @@ -352,7 +355,7 @@ var SnippetEditor = Widget.extend({ } }, }); - this.trigger_up('snippet_cloned', {$target: $clone}); + this.trigger_up('snippet_cloned', {$target: $clone, $origin: this.$target}); }, /** * Called when the overlay dimensions/positions should be recomputed. -- cgit v1.2.3