summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/rte.js
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2016-01-13 14:32:16 +0100
committerNicolas Lempereur <nle@odoo.com>2016-01-13 16:28:29 +0100
commit060cff9be31a70b096f7f12fec0c410fd6963758 (patch)
tree2baaa09bb928ac508808c08c8574fef911dbb353 /addons/web_editor/static/src/js/rte.js
parentd26c85dc0a4346f3fbce3400ecb9796a811847b6 (diff)
[FIX] web_editor: get unlink button working
f3f7bd9 improved some link editing behaviour by adding contenteditable attribute on it. But if contenteditable is set on a link, using command "unlink" on the element for `document.execCommand` does not work. Hence this commit adds a code so the first click outside the link remove contenteditable. closes #10436 second-part-of: opw-659772
Diffstat (limited to 'addons/web_editor/static/src/js/rte.js')
-rw-r--r--addons/web_editor/static/src/js/rte.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/addons/web_editor/static/src/js/rte.js b/addons/web_editor/static/src/js/rte.js
index 85721ba0387..becaf978d17 100644
--- a/addons/web_editor/static/src/js/rte.js
+++ b/addons/web_editor/static/src/js/rte.js
@@ -513,13 +513,21 @@ var RTE = Widget.extend({
}
if ($target.is('a')) {
+ // add contenteditable on link to improve its editing behaviour
$target.attr('contenteditable', true);
setTimeout(function () {
$editable.attr('contenteditable', false);
});
- } else if ($editable.attr('contenteditable') === 'false') {
- $target.removeAttr('contenteditable');
- $editable.attr('contenteditable', true);
+ // once clicked outside, remove contenteditable on link
+ var reactive_editable = function(e){
+ if($target.is(e.target)) {
+ return;
+ }
+ $target.removeAttr('contenteditable');
+ $editable.attr('contenteditable', true);
+ $(document).off('mousedown', reactive_editable);
+ }
+ $(document).on('mousedown', reactive_editable);
}
if (this && this.$last && (!$editable.size() || this.$last[0] != $editable[0])) {