[IMP] web_editor: add possibility to not focus LinkTool input
Before this commit, when requesting the link tool in the right panel, it would always focus its input. This commit adds an option to not focus the input when link tool is requested. It will be used by next commit. task-2618494 X-original-commit: ad13055d58b6cd92d56f483bce17ab2e19216809 Part-of: odoo/odoo#76372
This commit is contained in:
committed by
Romain Derie
parent
fb3ac94ce8
commit
5be974283d
@@ -127,12 +127,14 @@ const Link = Widget.extend({
|
||||
this._updateOptionsUI();
|
||||
this._adaptPreview();
|
||||
|
||||
// ensure the focus in the first input of the link modal
|
||||
setTimeout(()=> {
|
||||
const firstInput = this.$('input:visible:first');
|
||||
firstInput.focus();
|
||||
firstInput.select();
|
||||
}, 0);
|
||||
if (!this.options.noFocusUrl) {
|
||||
// ensure the focus in the first input of the link modal
|
||||
setTimeout(()=> {
|
||||
const firstInput = this.$('input:visible:first');
|
||||
firstInput.focus();
|
||||
firstInput.select();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
@@ -168,7 +168,10 @@ const LinkPopoverWidget = Widget.extend({
|
||||
* @param {Event} ev
|
||||
*/
|
||||
_onEditLinkClick(ev) {
|
||||
$('#toolbar #create-link').click();
|
||||
$('#wrapwrap').data('wysiwyg').toggleLinkTools({
|
||||
forceOpen: true,
|
||||
link: this.$target[0],
|
||||
});
|
||||
ev.stopImmediatePropagation();
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -796,6 +796,7 @@ const Wysiwyg = Widget.extend({
|
||||
* @param {boolean} [options.forceOpen] default: false
|
||||
* @param {boolean} [options.forceDialog] force to open the dialog
|
||||
* @param {boolean} [options.link] The anchor element to edit if it is known.
|
||||
* @param {boolean} [options.noFocusUrl=false] Disable the automatic focusing of the URL field.
|
||||
*/
|
||||
toggleLinkTools(options = {}) {
|
||||
if (this.snippetsMenu && !options.forceDialog) {
|
||||
@@ -804,7 +805,7 @@ const Wysiwyg = Widget.extend({
|
||||
}
|
||||
if (options.forceOpen || !this.linkTools) {
|
||||
const $btn = this.toolbar.$el.find('#create-link');
|
||||
this.linkTools = new weWidgets.LinkTools(this, {wysiwyg: this}, this.odooEditor.editable, {}, $btn, options.link || this.lastMediaClicked);
|
||||
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')) {
|
||||
// Destroy the link tools on click anywhere outside the
|
||||
|
||||
Reference in New Issue
Block a user