[FIX] web_editor: fetch undraw images in website and note

task-2794153

closes odoo/odoo#91970

X-original-commit: 536b2ff35f28836ef14cbb353b4749adee21aaad
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Nicolas Bayet
2022-05-20 20:14:23 +02:00
committed by David Monjoie
parent 585ce0e380
commit 36e80e02a8
4 changed files with 31 additions and 1 deletions
@@ -204,6 +204,9 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
allowCommandVideo: Boolean(this.nodeOptions.allowCommandVideo) && (!this.field.sanitize || !this.field.sanitize_tags),
mediaModalParams: {
noVideos: 'noVideos' in this.nodeOptions ? this.nodeOptions.noVideos : true,
res_model: this.model,
res_id: this.res_id,
useMediaLibrary: true,
},
linkForceNewWindow: true,
tabsize: 0,
@@ -1175,6 +1175,7 @@ const Wysiwyg = Widget.extend({
if (!sel.rangeCount) {
return;
}
const range = sel.getRangeAt(0);
// We lose the current selection inside the content editable when we
// click the media dialog button so we need to be able to restore the
// selection when the modal is closed.
@@ -1183,7 +1184,7 @@ const Wysiwyg = Widget.extend({
const $node = $(params.node);
// We need to keep track of FA icon because media.js will _clear those classes
const wasFontAwesome = $node.hasClass('fa');
const $editable = $(this.odooEditor.editable);
const $editable = $(OdooEditorLib.closestElement(range.startContainer, '.o_editable'));
const model = $editable.data('oe-model');
const field = $editable.data('oe-field');
const type = $editable.data('oe-type');
@@ -0,0 +1,24 @@
/** @odoo-module */
import tour from 'web_tour.tour';
import wTourUtils from 'website.tour_utils';
tour.register('website_media_dialog_undraw', {
test: true,
url: '/',
}, [
{
trigger: 'a[data-action=edit]',
},
wTourUtils.dragNDrop({
id: 's_text_image',
name: 'Text - Image',
}),
{
trigger: '.s_text_image img',
run: "dblclick",
},
{
trigger: '.o_select_media_dialog:has(.o_we_search_select option[value="media-library"])',
},
]);
+2
View File
@@ -106,6 +106,8 @@ class TestUiHtmlEditor(odoo.tests.HttpCase):
})
self.start_tour("/", 'test_html_editor_scss', login='admin', timeout=120)
def media_dialog_undraw(self):
self.start_tour("/", 'website_media_dialog_undraw', login='admin')
@odoo.tests.tagged('-at_install', 'post_install')
class TestUiTranslate(odoo.tests.HttpCase):