[FIX] web_editor: allow to select a link already selected
Before this commit, selecting a link was not working all the time. This commit allow to properly select a link all the time. Task-2667983 X-original-commit: 8c90772470046d0b932443ac7b2c2a868c443a85 Part-of: odoo/odoo#79641
This commit is contained in:
@@ -68,7 +68,6 @@ const LinkTools = Link.extend({
|
||||
this.$button.removeClass('active');
|
||||
this.options.wysiwyg.odooEditor.observerActive();
|
||||
this.applyLinkToDom(this._getData());
|
||||
setSelection(this.$link[0], 0, this.$link[0], 1);
|
||||
this.options.wysiwyg.odooEditor.historyStep();
|
||||
this._super(...arguments);
|
||||
},
|
||||
|
||||
@@ -886,16 +886,19 @@ const Wysiwyg = Widget.extend({
|
||||
return;
|
||||
}
|
||||
if (this.snippetsMenu && !options.forceDialog) {
|
||||
if (this.linkTools) {
|
||||
this.linkTools.destroy();
|
||||
}
|
||||
if (options.forceOpen || !this.linkTools) {
|
||||
const $btn = this.toolbar.$el.find('#create-link');
|
||||
this.linkTools = new weWidgets.LinkTools(this, {wysiwyg: this, noFocusUrl: options.noFocusUrl}, this.odooEditor.editable, {}, $btn, options.link || this.lastMediaClicked);
|
||||
if (!this.linkTools || ![options.link, ...wysiwygUtils.ancestors(options.link)].includes(this.linkTools.$link[0])) {
|
||||
this.linkTools = new weWidgets.LinkTools(this, {wysiwyg: this, noFocusUrl: options.noFocusUrl}, this.odooEditor.editable, {}, $btn, options.link || this.lastMediaClicked);
|
||||
}
|
||||
const _onMousedown = ev => {
|
||||
if (!ev.target.closest('.oe-toolbar') && !ev.target.closest('.ui-autocomplete')) {
|
||||
if (
|
||||
!ev.target.closest('.oe-toolbar') &&
|
||||
!ev.target.closest('.ui-autocomplete') &&
|
||||
(!this.linkTools || ![ev.target, ...wysiwygUtils.ancestors(ev.target)].includes(this.linkTools.$link[0]))
|
||||
) {
|
||||
// Destroy the link tools on click anywhere outside the
|
||||
// toolbar.
|
||||
// toolbar if the target is the orgiginal target not in the original target.
|
||||
this.linkTools && this.linkTools.destroy();
|
||||
this.linkTools = undefined;
|
||||
this.odooEditor.document.removeEventListener('mousedown', _onMousedown, true);
|
||||
@@ -904,6 +907,7 @@ const Wysiwyg = Widget.extend({
|
||||
this.odooEditor.document.addEventListener('mousedown', _onMousedown, true);
|
||||
this.linkTools.appendTo(this.toolbar.$el);
|
||||
} else {
|
||||
this.linkTools.destroy();
|
||||
this.linkTools = undefined;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -440,6 +440,7 @@ body:not(.editor_has_snippets) {
|
||||
border: dashed 3px #01bad2;
|
||||
position: absolute;
|
||||
inset: -5px;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user