[FIX] web_editor: correctly init "open in new window" link option
The "Open in new window" checkbox was always initialized as false, even if the link would open in a new window - both in the link tools and dialog. task-2172311 closes odoo/odoo#76880 X-original-commit: 52b034e8844336cc424e3126b843ec084fd7118e Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
@@ -59,6 +59,7 @@ const Link = Widget.extend({
|
||||
range.selectNodeContents(link);
|
||||
this.data.range = range;
|
||||
this.$link = $(link);
|
||||
this.linkEl = link;
|
||||
} else {
|
||||
const selection = editable && editable.ownerDocument.getSelection();
|
||||
this.data.range = selection && selection.rangeCount && selection.getRangeAt(0);
|
||||
@@ -66,6 +67,7 @@ const Link = Widget.extend({
|
||||
|
||||
if (this.data.range) {
|
||||
this.$link = this.$link || $(OdooEditorLib.getInSelection(this.editable.ownerDocument, 'a'));
|
||||
this.linkEl = this.$link[0];
|
||||
this.data.iniClassName = this.$link.attr('class') || '';
|
||||
this.colorCombinationClass = false;
|
||||
let $node = this.$link;
|
||||
@@ -88,6 +90,10 @@ const Link = Widget.extend({
|
||||
this.data.content = this.data.content ? this.data.content.replace(/[ \t\r\n]+/g, ' ') : '';
|
||||
}
|
||||
|
||||
if (this.linkEl) {
|
||||
this.data.isNewWindow = this.data.isNewWindow || this.linkEl.target === '_blank';
|
||||
}
|
||||
|
||||
const allBtnClassSuffixes = /(^|\s+)btn(-[a-z0-9_-]*)?/gi;
|
||||
const allBtnShapes = /\s*(rounded-circle|flat)\s*/gi;
|
||||
this.data.className = this.data.iniClassName
|
||||
|
||||
@@ -641,7 +641,7 @@
|
||||
</we-select>
|
||||
</we-row>
|
||||
<we-row t-if="!widget.isButton && !widget.options.forceNewWindow">
|
||||
<we-button class="o_we_user_value_widget o_we_checkbox_wrapper">
|
||||
<we-button t-attf-class="o_we_user_value_widget o_we_checkbox_wrapper #{widget.data.isNewWindow ? 'active' : ''}">
|
||||
<we-title class="o_long_title">⌙ Open in new window</we-title>
|
||||
<div class="o_switch">
|
||||
<we-checkbox name="is_new_window" t-att-checked="widget.data.isNewWindow ? 'checked' : undefined"/>
|
||||
|
||||
Reference in New Issue
Block a user