[IMP] web_editor: Add rel="ugc" to some user generated links

See odoo task : https://www.odoo.com/web#action=333&active_id=1695&cids=1&id=2319575&menu_id=4720&model=project.task&view_type=form

closes odoo/odoo#70614

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Sébastien Geelen (sge)
2021-05-17 08:58:50 +00:00
committed by Antoine Guenet
parent c910976162
commit fa2e0a6349
4 changed files with 13 additions and 1 deletions
@@ -150,8 +150,14 @@ const Link = Widget.extend({
const attrs = Object.assign({}, this.data.oldAttributes, {
href: data.url,
target: data.isNewWindow ? '_blank' : '',
class: `${data.classes}`,
});
if (data.classes) {
attrs.class = `${data.classes}`;
}
if (data.rel) {
attrs.rel = `${data.rel}`;
}
this.$link.attr(attrs);
if (!this.$link.attr('target')) {
this.$link[0].removeAttribute('target');
@@ -79,6 +79,7 @@ const Wysiwyg = Widget.extend({
isRootEditable: this.options.isRootEditable,
controlHistoryFromDocument: this.options.controlHistoryFromDocument,
getContentEditableAreas: this.options.getContentEditableAreas,
defaultLinkAttributes: this.options.userGeneratedContent ? {rel: 'ugc' } : {},
getContextFromParentRect: options.getContextFromParentRect,
noScrollSelector: 'body, .note-editable, .o_content, #wrapwrap',
commands: commands,
@@ -586,6 +587,9 @@ const Wysiwyg = Widget.extend({
if (!linkWidget.$link.length) {
linkWidget.$link = $(linkWidget.getOrCreateLink(this.$editable[0]));
}
if (this.options.userGeneratedContent) {
data.rel = 'ugc';
}
linkWidget.applyLinkToDom(data);
getDeepRange(this.odooEditor.editable, {range: data.range, select: true});
@@ -131,6 +131,7 @@ publicWidget.registry.websiteForum = publicWidget.Widget.extend({
res_id: +window.location.pathname.split('-').pop(),
},
resizable: true,
userGeneratedContent: true,
};
if (!hasFullEdit) {
options.plugins = {
@@ -68,6 +68,7 @@ publicWidget.registry.websiteProfileEditor = publicWidget.Widget.extend({
res_id: parseInt(this.$('input[name=user_id]').val()),
},
resizable: true,
userGeneratedContent: true,
});
return Promise.all([def]);