diff --git a/addons/web_editor/static/src/js/backend/QWebPlugin.js b/addons/web_editor/static/src/js/backend/QWebPlugin.js index f6b316dc0a6..897c811cb82 100644 --- a/addons/web_editor/static/src/js/backend/QWebPlugin.js +++ b/addons/web_editor/static/src/js/backend/QWebPlugin.js @@ -12,6 +12,7 @@ export class QWebPlugin { this._editable = this._options.editable; this._document = this._options.document || window.document; } + this._getContextFromParentRect = this._options.editor?.options?.getContextFromParentRect || (() => ({ top: 0, left: 0 })); this._editable = this._options.editable || (this._options.editor && this._options.editor.editable); this._document = this._options.document || (this._options.editor && this._options.editor.document) || window.document; this._tGroupCount = 0; @@ -183,9 +184,13 @@ export class QWebPlugin { const box = target.getBoundingClientRect(); const selBox = this._selectElWrapper.getBoundingClientRect(); + const parentBox = this._getContextFromParentRect(); - this._selectElWrapper.style.left = `${window.scrollX + box.left}px`; - this._selectElWrapper.style.top = `${window.scrollY + box.top - selBox.height}px`; + const left = parentBox.left + window.scrollX + box.left; + const top = parentBox.top + window.scrollY + box.top - selBox.height; + + this._selectElWrapper.style.left = `${left}px`; + this._selectElWrapper.style.top = `${top}px`; } _renderBranchingSelection(target) { const selectEl = document.createElement('select'); diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg_iframe.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg_iframe.js index a027abeb13a..e2702691b0f 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg_iframe.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg_iframe.js @@ -48,9 +48,11 @@ patch(Wysiwyg.prototype, 'wysiwyg_iframe.js', { **/ _getEditorOptions() { const options = this._super.apply(this, arguments); - options.getContextFromParentRect = () => { - return this.$iframe && this.$iframe.length ? this.$iframe[0].getBoundingClientRect() : { top: 0, left: 0 }; - }; + if (!("getContextFromParentRect" in options)) { + options.getContextFromParentRect = () => { + return this.$iframe && this.$iframe.length ? this.$iframe[0].getBoundingClientRect() : { top: 0, left: 0 }; + }; + } return options; }, /**