Commit Graph
2658 Commits
Author SHA1 Message Date
Antoine Guenet bbab68a5c9 [REF] web_editor: initialize the Powerbox in the editor's constructor
The constructor of OdooEditor called a function that initialized the
Powerbox. This moves that function inline into the constructor to avoid
a function called only once, and moves the main commands and categories
directly into the arguments to `new Powerbox()`.

closes odoo/odoo#97725

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-09 07:47:53 +02:00
qsm-odoo 9139bb306c [FIX] web_editor: restore "custom" image filters option for bg images
The widgets related to "custom" image filters in the case of background
images were never shown anymore since [1]. [1] is actually a
forward-ported version of [2] but the bug only appeared since [1] as
the forward-port adaptation created the error: the widgets of this
option were not shown or hidden before... but simply not rendered at
all, kinda by mistake. The adaptation in [1] used the conventional way
of doing things by using the `_computeWidgetVisibility` method to
indicate if widgets should be shown or not. The problem is that an
error was done when writing that visibility condition.

[1]: https://github.com/odoo/odoo/commit/89ce9f9ab5b8db148c273f70be0a06c768892566
[2]: https://github.com/odoo/odoo/commit/7c17d78fbdbb64b1aa5b55f78d3202a64a85ed2f

closes odoo/odoo#97514

X-original-commit: 10a48dc213117c4ac29b1ce56d3f1c02e58111d8
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-08-08 17:43:01 +02:00
Antoine Guenet 51722cf993 [ADD] web_editor: add tests for Powerbox
This adds a series of tests for the editor's Powerbox and its
integration with the editor.

closes odoo/odoo#96287

Related: odoo/enterprise#29649
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-08 14:17:01 +02:00
Antoine Guenet b58606f705 [FIX] web_editor: ensure the Powerbox displays above a modal
The upgrade from Bootstrap 4 to 5 broke the display of the Powerbox when
the editor is in a modal. This adapts the Powerbox's z-index to make
sure it always displays above a modal.

task-2901697

Part-of: odoo/odoo#96287
2022-08-08 14:17:01 +02:00
Antoine Guenet f9cbcccdfe [REF] web_editor: convert editor styles to scss
Odoo Editor's styles were defined in CSS when it was all still part of
a separate repository. They can now be converted to SCSS, which will
allow us to use Odoo's SCSS variables in the future, and allows us now
to refactor the styles in the more readable SCSS format.

Part-of: odoo/odoo#96287
2022-08-08 14:17:01 +02:00
Antoine Guenet 8e1f9fffc8 [IMP] web_editor, mass_mailing, website: reorganize Powerbox items
This reorganizes the Powerbox items under different category names, in a
more preferable order.

task-2901697

Part-of: odoo/odoo#96287
2022-08-08 14:17:00 +02:00
Antoine Guenet 9154e707df [ADD] web_editor, website: new API to organize Powerbox
This introduces a new API for the Powerbox, which allows to order its
commands and categories. The order is based on the priority assigned to
the category or command. If two items have the same priority, they are
ordered alphabetically.
To order categories, pass said categories in the Powerbox's params, each
with its own priority. If a command declares itself as part of a
category that was not itself declared, said category will be added
automatically, with the lowest priority.

task-2901697

Part-of: odoo/odoo#96287
2022-08-08 14:17:00 +02:00
Antoine Guenet ef1fe4a700 [REF] web_editor: refactor the Powerbox
This refactors the Powerbox for maintainability and efficiency, and
removes unused code from it.

task-2901697

Part-of: odoo/odoo#96287
2022-08-08 14:17:00 +02:00
Younn Olivier e2e65790a5 [FIX] web_editor: fix nearest dropzone when moving a snippet
Before this commit, when a snippet was moved, and dropped outside of a
dropzone, the nearest dropzone was not found and the snippet would
return to its initial position.

This commit fixes it by using the editable document instead of the
global one.

Related to https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

task-2687506

closes odoo/odoo#96401

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-08-08 12:32:52 +02:00
Younn Olivier d4bf7c4b46 [FIX] web_editor: fix snippets overlay buttons ui
After [1] was merged, the delete/move buttons of the snippets overlay
reduced in size, because of the font-size difference between the backend
and the frontend.

This commit fixes it by setting a fixed font-size of 16px (this restores
the same size as before, as the button was using 1rem on the frontend,
and most browsers use 16px as a default font size).

[1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

task-2687506

Part-of: odoo/odoo#96401
2022-08-08 12:32:51 +02:00
Antoine Guenet 00b9a0fcbe [FIX] web_editor: properly convert link-wrapped card-images
The e-mail conversion process for Bootstrap cards stripped card-images
from their link when they had one. This corrects the process to preserve
the link.

task-2937123

closes odoo/odoo#97199

X-original-commit: 947ee6756b9e9d9ddf7380ecaf0beb27c271b231
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-05 19:06:53 +02:00
Ipsita Borisagar 19fa3c35a3 [FIX] web_editor: traceback while removing the link
Before this commit:

After inserting the 'calendar' or 'appointment' link in an article through the
'/appointment ' or '/calendar' command, removing the link shows the error.

After this commit:

Removing the link through the link editor will remove the link and only keep the
text.

Task-2894489

closes odoo/odoo#97210

X-original-commit: 8eda489a26a3d138c2e4c601e42b531e6bc719b6
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-05 15:09:16 +02:00
qsm-odoo 29613c6ec4 [FIX] web_editor: fix the look of the indent symbol in the editor panel
As a stable fix, to not touch XML templates and break existing
translations, the ⌙ character was automatically replaced by └ which
makes more sense for the usecase and should work properly in all
browsers. The ⌙ character is actually rendered mirrored on Windows 11
Chrome (and others) as the font used for those unicode characters is
left to the browser. We could force a font of our own but it's probably
not worth it.

A better solution with a SVG or CSS solution has to be done in master.
That would unify the look of the symbol across all browsers and
also prevent special characters to be placed in translations.

With this forward-port commit, we'll start first by using └ via a CSS
rule. Three new classes have been created: o_we_sublevel_1,
o_we_sublevel_2 and o_we_sublevel_3. Adding any of them on a widget
automatically adds the └ character. Then choosing 1, 2 or 3 controls
the indentation, which was previously controlled by placing the &emsp;
HTML entity directly inside strings.

This commit also takes the opportunity to fix some of those level
indentations (sometimes 2 was used instead of 1 or 1 was used instead of
2, etc) and also review some related labels.

closes odoo/odoo#97361

X-original-commit: e5d45643598671077ade7e41f0dbfe2b502665b8
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-08-04 11:45:31 +02:00
Xavier Morel bb543d75a9 [FIX] web_editor: breaking _onBeforeUnload when canceling edition
After updating mass_mailing_snippets_menu_tabs to cancel the
template's edition at the end of the tour, the editor starts blowing
up during cleanup with:

```
Trying to set result to failed (UncaughtTypeError: Cannot read properties of null (reading 'anchorNode')
    at Sanitize._parse (/web/assets/363-d1667a2/web_editor.assets_wysiwyg.min.js:1453:105)
    at Sanitize.parse (/web/assets/363-d1667a2/web_editor.assets_wysiwyg.min.js:1450:6)
    at new Sanitize (/web/assets/363-d1667a2/web_editor.assets_wysiwyg.min.js:1448:6)
    at sanitize (/web/assets/363-d1667a2/web_editor.assets_wysiwyg.min.js:1460:53)
    at OdooEditor.cleanForSave (/web/assets/363-d1667a2/web_editor.assets_wysiwyg.min.js:1372:37)
    at Class.getValue (/web/assets/363-d1667a2/web_editor.assets_wysiwyg.min.js:2547:1121)
    at Class.isDirty (/web/assets/363-d1667a2/web_editor.assets_wysiwyg.min.js:2547:407)
    at
    _onBeforeUnload (/web/assets/363-d1667a2/web_editor.assets_wysiwyg.min.js:2509:560)
```

After consultation with the relevant team, there are edition contexts
where it's perfectly valid to have no "live" selection for one reason
or an other, so this should be fixed.

Ideally the field should also properly be discarded such that the
event listener is removed and the callback is never called at all,
however the legacy client has no such hook at the field level (the
controller seems to be the lowest).

closes odoo/odoo#96517

Related: odoo/documentation#2550
Related: odoo/enterprise#29824
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2022-08-04 09:14:11 +02:00
Benoit Socias 5de6b5048a [FIX] web_editor, *: restore defaults before applying preset
*: website, website_sale

Before this commit when a search bar was within a navigation bar, its
autocompletion popover was using the text color according to the
navbar's background color determined by the theme. For dark themes, this
made the autocompletion appear almost as white on white.

This commit uses the defaults before applying a specific preset color
so that the dropdown menu style within the navbar uses the original
color.
It also resets the `text-muted` style used in "No results" message.

Also removing the `website_sale.productsSearchBar.autocomplete` template
which was not referenced anymore.

Steps to reproduce:
- Select a dark palette (e.g. one that makes the navigation bars black).
- Drop a "Products Search" block.
- Reset its background color.
- Pick a color combination with a dark background.
=> The autocompletion's "No results" message is shown without contrast.

task-2855511

X-original-commit: f9bf40cb53cf487c8736c1f565c2f0d3834acd5e
Part-of: odoo/odoo#97148
2022-08-03 20:48:04 +02:00
Nicolas Bayet 52d8f8a253 [FIX] web_editor: try to paste html before files
Before this commit, when trying to paste into the Odoo editor, if file
and html was in the clipboard, the file got precedence and were added
instead of html.

task-2941679

closes odoo/odoo#97359

X-original-commit: 0af0927f48f213d835a7d4a8396fc6376476e220
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-03 09:24:39 +02:00
Sébastien Geelen (sge) 59f45f7c47 [FIX] web_editor: correct link behaviors
* Broaden the valid URL pool by including some URL without subdomain
 if they have a white listed TLD.

* Change a link 'href' when we change the link label,
 if the new label is a valid URL.

* Ensure the domain extension cannot be only digit.

task-2858621
task-2901795

closes odoo/odoo#97297

X-original-commit: 500bc6dc9958fe8a9ca396f87544e8866efa744b
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-02 13:06:45 +02:00
Sébastien Geelen (sge) bacda923e2 [FIX] web_editor: adapt link unit tests
Change the unit test to reflect new spec:

* Some TLD are white listed to not required a subdomain to be considered a valid URL.
 => .com, .net, .org + all ccTLD

* URL of a link need to be changed to equal the label, is the label is a new valid URL.

* Domain Extention cannot be only digit

task-2858621

X-original-commit: c13ba3ec771334c9cd7708305b40b9bf1a234bcc
Part-of: odoo/odoo#97297
2022-08-02 13:06:45 +02:00
David Monjoie 0a4fcbfb68 [FIX] web_editor: fix insertText test util for multiple characters
task-2858621

X-original-commit: 308a039d96e709bc0ef27ba77af20abfde881ea3
Part-of: odoo/odoo#97297
2022-08-02 13:06:44 +02:00
Tom De Caluwéandqsm-odoo faff8ddb30 [FIX] web_editor, *: fix animations on transformed images
*: website

Setting transformations on images is handled by the jQuery transfo
plugin. This plugin, however, also manipulates animations related css
properties allowing the plugin to work on animated images.

After closing the transformation tools these properties stay in the DOM,
preventing the animation options to work properly. Animations are not
played when previewing or selecting a choice from the dropdown list.
Instead they remain stuck in their initial keyframe.

To avoid complications from the interaction between both options, this
commit hides either option when the other is activated. Additionally,
css properties added by the transform option are cleaned, avoiding
potential interactions after the transform option is reset again.

opw-2765529

closes odoo/odoo#97137

X-original-commit: 3ac59a7f841b528a32c14a2111e7a1a7e11c830a
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
2022-08-01 13:26:38 +02:00
jlzhou a04c2f134e [FIX] project, web_editor: fix user_id missing bug in this.getSession()
auth_totp module added user_id in session_info, but it's not in the depends of project and web_editor module.

To avoid traceback after uninstalling auth_totp module:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '0'),

we should use uid instead of user_id in js code.

closes odoo/odoo#96880

X-original-commit: 81b92a61907028f71b1337b11d0d60ee98bb5775
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-08-01 10:55:37 +02:00
shsa-odoo 528ee16956 [FIX] web_editor: preventing traceback on quote icon click
Before this commit:

Onclicking quote icon of BlockQuote generates traceback

After this commit:

Now on clicking quote icon doesnot generate traceback

Task-2920794

closes odoo/odoo#96944

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-07-28 21:01:44 +02:00
frc-odoo 8821fb0641 [FIX] web_editor: adds missing not null check
closes odoo/odoo#96975

X-original-commit: c2f6be56a09e3dd627922036c6deaa22aa2238dd
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-07-28 13:21:33 +02:00
Nshimiyimana Séna 679fed2c52 [FIX] web_editor: translate editor commands
Steps to reproduce:
- switch to any language other than English
- go to a page where you can use the text editor,
  for instance you can try to edit a project's description.
- type `/` in the editor

You should see that some commands are not translated.

Some files modified in this commit are located in the
web_editor/static/lib/web-editor directory.
However, only the JS code located into /static/src/ is considered for
export of translations. This is done to avoid polluting translations for
code not managed by Odoo.

We have to update the .pot file manually. A good workaround is to copy
the web-editor folder inside to static/src, export the
translations and then delete the copy folder.

However, this means that those updates to the .pot file will be lost in
the next translation export.

opw-2918128

closes odoo/odoo#96939

X-original-commit: 0cc5505b27f29d44c25af83653b09b1b49cfec79
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Nshimiyimana Serge Séna (sesn) <sesn@odoo.com>
2022-07-28 10:28:06 +02:00
vishal padhiyar b68890dc5f [FIX] web_editor: add p in each td
Before this commit:

When we put the text direct in td  and try to color it with design toolbar with
text color then text in normal should change the color.

After this commit:

When we enter the text direct and try to change the color  with design toolbar
then it will change the text with defined color.

Task-2843065

closes odoo/odoo#96830

X-original-commit: 76fd633ab78d5cb47c990063040d6d1e9708df2d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-07-28 03:51:26 +02:00
Benoit Socias 11572f0f20 [FIX] web_editor, *: prevent dropping unsafe snippets in model fields
*: website, website_mass_mailing, website_payment

When an unsafe snippet is dropped into a sanitized HTML model field, its
unsafe content gets removed on save.
We need a way to mark snippets as being (in)compatible with
sanitization. It cannot be automatic, as, for example, the snippet
introduced at [1] contains an iframe but is compatible with
sanitization.
In 13.0, we will temporarily set up an automatic mechanism that marks
existing snippets containing forms as being incompatible with
sanitization.
In 14.0 a distinction between full sanitization and form-tolerant
sanitization introduced at [2] is added with this forward-ported commit.

This commit prevents unsafe snippets from being dropped into sanitized
HTML model fields.
The "Form Builder", "Product Search" and "Product Search Input" blocks
are now prevented from being dropped or moved into form-sanitized HTML
fields.

To do this, this commit introduces a new `t-forbid-sanitize` attribute
on the `t-snippet` tag. It can have the value `true` to prevent it from
being dropped into any sanitize fields, or `form` to specifically limit
to form-sanitized fields.

Steps to reproduce (in 13.0):
- Go to a product page
- Drop a "Product Search" snippet into the product-specific section of
the
product
- Save
=> The form was removed.

[1]: https://github.com/odoo/odoo/commit/c2e9bd0e60014b6a42931cf300e0f89f8cf7c225
[2]: https://github.com/odoo/odoo/commit/388c222c6c4bb7e2fe3e67009b248359ae0fd3db

task-2829961

closes odoo/odoo#96812

X-original-commit: 9eaba23781766730b06e936dbd9c5d0c28c909c6
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-07-28 03:51:04 +02:00
Romain Derie 80fa805867 [IMP] web_editor: add "hide controls" option to vimeo video
Only youtube and dailymotion were able to add this property to their
video. Maybe it was not supported by vimeo back then, but it seems to be
supported now.

It improves the vimeo youtube in two ways:
1. For background video, the controls are now hidden. There were visible
   for a few seconds before this PR which is not ideal
2. For non background video, there were no way to hide the controls
   which might be problematic to some users as in mobile there is the
   controls display but also an ugly "Tap to unmute" in the middle of
   the video.

Step to reproduce (background video):
- Drag & drop a "Text - Image" snippet and add it the biggest possible
  padding, also add padding to the image (so you see the full video and
  not just part of it)
- Double click on the image, then on the video tab insert a vimeo url
- Save, you will see the controls for a few seconds (progress bar, video
  title, link to vimeo, etc)

Step to reproduce (non background video):
- Drag & drop a "Text - Image" snippet and double click on the image
- On the video tab, insert a vimeo url
- Select "Auto Play"
- Save and go to mobile, you will see the controls and an ugly "Tap to
  mute" in the middle of the video.

The "Tap to mute" is a browser feature, not a vimeo feature. Browsers
are muting video by default when auto play.

Still, some people want to have a nice auto play video shown to users
without sounds and don't want that overlay/controls.

opw-2901256

closes odoo/odoo#96804

X-original-commit: 7128e4080511b5f224da3dce6d88ba8bcf9a0d47
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-07-28 03:50:47 +02:00
shsa-odoo 2d3f21207a [FIX] web_editor: On pasting image to editor, it must have 100% default width
Before this commit:

On pasting image to editor, the default width was set to auto.

After this commit:

Now on pasting image to editor, the default width is set to 100%.

Task-2862892

closes odoo/odoo#96779

X-original-commit: 2e4811b751960548dc66f6e4ff00495e5226fdbc
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-07-28 02:40:12 +02:00
David Monjoie 467415f631 [IMP] web_editor: rename Auto width to Default
This nomenclature was taken straight from the old Summernote options
when the new editor was merged in 15.0.

While perfectly correct from a technical point of view, the use of the
word "Auto" in this context is confusing because the user might think
that the system is going to choose an optimal size for them while this
is not what this option does at all. What it does is simply removing any
width style property that might be set on the image, thus letting the
image be sized appropriately by the browser in accordance with active
CSS rules at that position in the page, hence its "Default" width.

closes odoo/odoo#96679

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-07-28 01:30:23 +02:00
tsm-odoo 71d5af4ce0 [FIX] bus, *: fix onNotification/offNotification
*: im_livechat, snailmail_account, survey, web_editor.

The callback registered by the bus service method onNotification was
not the same unregistered by offNotification. Since those method were
superfluous, they have been removed in favor of (add/remove)EventListener.

closes odoo/odoo#96684

Related: odoo/enterprise#29819
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-07-27 16:34:10 +02:00
Benoit Socias 0099b8ee36 [FIX] web_editor: filter inline styles when changing media type
Since [1] and even after [2] when replacing a media by a media of a
different type only classes were cleaned - but all inline styles were
copied.

This commit filters the inline styles when replacing a media by a media
of another type.

Steps to reproduce:
- Drop a "Text - Image".
- Replace the image by an icon.
- Apply solid colors for the foreground and the background.
- Replace the icon by an image.
=> The applied colors were kept in the inline style of the image.

[1]: https://github.com/odoo/odoo/commit/7fd0698cf765a79959566b51e33cb76bff83d344
[2]: https://github.com/odoo/odoo/commit/9ca349bbdb75505e8dbd31898f05ba8d694e7953

task-2687506

closes odoo/odoo#95853

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-07-27 02:18:13 +02:00
Benoit Socias cc6e888362 [FIX] web_editor: keep classes that exist in both source & target media
Since [1] when replacing a media by a media of the same type or that has
some extra classes in common, those classes were removed instead of
being kept.

This commit makes sure only the classes that do not exist in the newly
selected media type are removed.

Steps to reproduce:
- Drop a "Text - Image".
- Replace the image by an icon.
- Apply a circle effect and colors on the icon.
- Replace the icon by another icon.
=> The applied effect and colors were lost.

[1]: https://github.com/odoo/odoo/commit/9ca349bbdb75505e8dbd31898f05ba8d694e7953

task-2687506

Part-of: odoo/odoo#95853
2022-07-27 02:18:12 +02:00
Arthur Detroux (ard) a396f791da [FIX] website, web_editor: fix header and footer page options
Commit [1] moved the editor in the backend introducing changes to the
way some options interact with the website. This unfortunately broke
the header position option, the header background option and the footer
visibility option.

The header position option would loop indefinitely, the header
background color option would not display the correct preview colors and
the footer position would trigger a traceback.

This commit fix those bugs:

- The header position option had a callback that was never called, it is
  now called.
- The copy of styles introduced by [2] is now less implicit. Only styles
  that are defined in web_editor/common/utils:
  [EDITOR_COLOR_CSS_VARIABLES] are copied on the snippet menu, and only
  those variables will be used as background colors for the preview
  elements. (Allowing for every other colors like black and white to be
  used with classes).
- The footer visibility option had a broken line of code that was copied
  from past code. It is now fixed and working.

[1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b
[2]: https://github.com/odoo/odoo/commit/212a8bfdd21269b18054200b9e2585e1c95540d6

task-2687506

closes odoo/odoo#94949

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-07-27 02:18:06 +02:00
Antoine Guenet b45ac038fe [ADD] web_editor, web: add signature command to PowerBox
This adds a command to the PowerBox to insert the user's e-mail
signature into the editable document.

task-2715295

Part-of: odoo/odoo#94434
2022-07-25 17:45:07 +02:00
David Monjoie a5046ab1da [FIX] web_editor: properly paste newlines on Windows
Windows uses /r/n as newlines and the split parameter was not taking
that into account, thus inserting the /r character.

task-2742071

closes odoo/odoo#96422

X-original-commit: 90e565f811523968c297f0254f4aa7046c4e710e
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-07-25 16:33:53 +02:00
+2 bc0a0cead6 [IMP] web,*: enable owl list & form views
The new list and form views were merged recently [1], but they
weren't activated because they weren't 100% ready yet. This is now
the case. This commit adds those views to the view registry. As a
consequence, a lot of qunit tests and tours needed to be adapted,
mostly for selector changes.

We also add legacy list and form views to the view registry, with
keys 'legacy_list' and 'legacy_form'. This allows to force those
legacy views when necessary. For instance, we did it in views
using complex custom legacy x2many field widgets that haven't been
converted yet (we have a compatibility layer but it isn't complete
and doesn't support every advanced usecases).

[1] odoo/odoo#92475

Part-of: odoo/odoo#78221
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Bruno Boi <boi@odoo.com>
Co-authored-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Samuel Degueldre <sad@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Simon Genin (ges) <ges@odoo.com>
Co-authored-by: Francois (fge) <fge@odoo.com>
Co-authored-by: Michael Mattiello (mcm) <mcm@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Lucas Perais (lpe) <lpe@odoo.com>
Co-authored-by: Jorge Pinna Puissant <jpp@odoo.com>
Co-authored-by: luvi <luvi@odoo.com>
2022-07-22 16:21:45 +02:00
Nicolas Bayet 3cc0fb8339 [FIX] web_editor: style qweb element in odoo editor
Before this commit, the styles for the qweb elements
(t, t-if, t-out, ...) were not applied.
This commit apply them except when converting html to inline
styling.

task-2892193

closes odoo/odoo#96433

X-original-commit: 4cc40661ed3287e15ea21cedf8e2a582e32be5c8
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-07-21 00:50:45 +02:00
Antoine Guenet 79530cb088 [FIX] web_editor, mass_mailing: properly size the codeview
The codeview of mass_mailing had the wrong height in non full-width
contexts.

task-2894177

closes odoo/odoo#96342

X-original-commit: ee001e843a0a02f04030f0959c7db58beaaa3a3b
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-07-19 21:22:12 +02:00
Romeo Fragomeli f3f66d33db [FIX] web_editor: restore margin on we-selection-items
Margin top of `we-selection-items` was removed during the migration of
BS5 to avoid warning on runbot, but we have to restore it for non BS
`dropdown-menu`.

Ref:
odoo/odoo@e1ea58c941

closes odoo/odoo#96186

Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2022-07-19 21:21:58 +02:00
Benjamin Vray aca20be33f [FIX] web_editor: fix destroy editors in modal
After the following steps, snippets overlays are not properly removed
from the DOM:

- In edit mode, drop 2-3 snippets in the page.
- Click on these snippets to activate their overlays.
- Drag and drop a popup in the page.
- Drag and drop a snippet in the popup.
- Move this snippet inside the popup thanks to the move handle button.
- Click on the "eye" button to hide the popup.
- Click on snippets of the page, the overlays are no longer removed when
they should.

It was because since commit [1], it is allowed to define an element
in which '_destroyEditors' destroys the editors but we forgot not to
completely empty the array that contains them.

But anyway, the editors list does not need to be updated in
'_destroyEditors' since commit [2] as it is already done in the
'destroy' method of 'SnippetEditor'.

[1]: https://github.com/odoo/odoo/commit/b7d522e9e7e31ac6bf926aae65e58d9f6cfa8903
[2]: https://github.com/odoo/odoo/commit/2a19a83762c1bc74dd7336378d254ab6da8e3a22

task-2799602

closes odoo/odoo#96267

X-original-commit: 0e97847cf42db935522f5f834f6fcb86de02eae3
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-07-18 22:21:01 +02:00
tsm-odoo 3b9a90e14f [IMP] bus: replace on/off by (add/remove)EventListener
on/off are deprecated in favor of  addEventListener/removeEventListener.
Calls to the bus service have been updated to reflect those changes.

task-2053917

closes odoo/odoo#96017

Related: odoo/enterprise#29501
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-07-18 18:41:33 +02:00
Younn Olivier 204d26e76a [FIX] web_editor: fix multi upload from the media dialog
Before this commit, uploading multiple files could lead to inconsistent
results: the files array was sorted from the lower to the higher size,
but this sorted array was not used after (the unsorted one was).

This commit fixes this issue by clearly defining a sorted array, and
uploading the files sequentially, as it was done before [1].

[1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

task-2687506

Part-of: odoo/odoo#95955
2022-07-18 18:41:29 +02:00
Younn Olivier f2111cb37a [FIX] web_editor: fix media dialog's svg upload
Before this commit, the media dialog was not handling properly the
upload of svg files from the media library: a whole part of the original
ImageWidget was missing in the converted media dialog from [1], which
was converting the svg with the appropriate color codes from the color
palette, to allow for color customization.
See original file from 15.4: web_editor/static/src/js/widgets/media.js.

Also, it was not displaying those svg correctly with the appropriate
background.

This commit fixes those issues by adding back the code handling the
dynamic colors detection and the background css rule.

[1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

task-2687506

Part-of: odoo/odoo#95955
2022-07-18 18:41:29 +02:00
Younn Olivier 2e6b59a8e4 [FIX] web_editor: fix upload progress toast visibility
Before this commit, when uploading multiple files and clicking on the
cross button, the toast was reappearing every time a new file was
succesfully uploaded.

This commit changes its state so that it is only visible when one or
multiple files are added to the uploading queue. The user can still hide
it with the cross.

task-2687506

Part-of: odoo/odoo#95955
2022-07-18 18:41:28 +02:00
Benoit Socias cbbe2029ba [FIX] web_editor: prevent sanitize from grouping font image wrappers
The HTML sanitization regroups similar elements into a single one.
For 'style-inline' HTML fields, the font awesome icons are converted
to images within spans.
Because of this, when sanitizing a "5 Stars" block in a 'style-inline'
HTML field, the spans are grouped and all the images end up inside a
single span, with:
- each image being `display: block;` and
- the global span having a fixed width equal to a single image's width.
This turns the horizontal succession of stars into a vertical one.

This commit adds the `oe_unbreakable` class to the image wrapping spans
to prevent sanitize from grouping them into a single one.

Note that this commit does not address the issue that upon a further
edit of the field, the Stars block is not recognized anymore. This
would require a `convert_from_inline` reverting operation which would
change many other behaviors.

Steps to reproduce:
- Go to user profile.
- Edit signature.
- Insert a "5 Stars" block (i.e. use the "/5" command).
- Save.
=> Stars became vertical.

task-2845963

X-original-commit: 9bf0b9872056e5f69a9c912825b863e0a353d5f5
Part-of: odoo/odoo#96071
2022-07-15 19:16:07 +02:00
Benoit Socias 0e26e59943 [FIX] web_editor: keep unchanged stars blocks saved in views
Since [1] when the Stars blocks were introduced, they were corrupted
during the save operation of views because the views do re-render their
content with `pretty_print=True`.

This commit prevents this from happening by adding a zero-width space
to the Stars blocks.

Steps to reproduce:
- Drop a Text block in a page.
- Insert a "5 Stars" block after the text (type "/5" to find it in the
Power box).
- Save the page.
=> Spaces appear between the stars, and the block does not respond
anymore when clicking on stars if the page is edited again.

[1]: https://github.com/odoo/odoo/commit/8266b978e1bfa5bedfaf1c4fcceadd26400fc85c

task-2845963

X-original-commit: 832995cafcf6181ab3bd1b2d432fd34f6aeed7fe
Part-of: odoo/odoo#96071
2022-07-15 19:16:07 +02:00
Benoit Socias 135aacd33c [FIX] web_editor: not fail when clicking on a technical SVG
Since [1] when the stars were made available in the power box, an
exception is raised when clicking on a technical SVG of the "Steps"
block.
This happens because SVGs have their `nodeType === Node.ELEMENT_NODE`,
they have `className` and `classList` properties, but their `className`
is not a string: it is an `SVGAnimatedString`. Because of this, the
`includes` method is not available on `className`.

This commit prevents the non-existing `includes` from being called.

Steps to reproduce:
- Drop a "Steps" block into the page.
- Click on the column before the first step, at the same height as the
steps icons. (There is an hidden SVG there containing the definition of
the arrows head.)
=> Did raise an exception.

[1]: https://github.com/odoo/odoo/commit/8266b978e1bfa5bedfaf1c4fcceadd26400fc85c

task-2845963

X-original-commit: dbfbf264750a0760d4f2d96a1b7a13ea27472316
Part-of: odoo/odoo#96071
2022-07-15 19:16:07 +02:00
Benoit Socias 990edd0c0d [FIX] web_editor, test_website: replace video by pictogram correctly
Since [1] when the media dialog was re-written in owl, the problem is
solved, this forward-port only keeps the added test scenarios.

See the description of the initial problem below:

Similarly to the comment introduced in [2], classes identifying a video
are only available before media.js begins to save.
This led to wronly inserting the pictogram in an incorrect location when
replacing a video by a pictogram.

This commit keeps track of the fact that a media node was a video before
being replaced instead of trying to find out after the classes have been
removed.

Steps to reproduce:
- Drop a "Text - Image" snippet.
- Replace the image by a video.
- Replace the video by a pictogram.
=> Was adding the pictogram in the first column's button instead.

[1]: https://github.com/odoo/odoo/commit/7fd0698cf765a79959566b51e33cb76bff83d344
[2]: https://github.com/odoo/odoo/commit/d4d25c8b497e465753cef030292faa4824145cb1

task-2729177

closes odoo/odoo#95963

X-original-commit: b50a8015da7bba3b156fa8941b6c2b17533159c7
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-07-15 14:21:57 +02:00
Benoit Sociasandqsm-odoo fe569d4692 [FIX] web_editor, *: not crash when selecting icon after replacing image
*: test_website

Since [1] when the media dialog was re-written in owl, the problem is
solved, this forward-port only keeps the added test scenarios and some
of the code cleanup & comments.

See the description of the initial problem below:

Since [2] replacing an image by an icon then selecting the icon opens an
error popup.

After this commit there is no error when selecting the icon that
replaces an image because the editor of the replaced media is destroyed.

Steps to reproduce:
- drop a Text-Image snippet
- select the image
- replace the image by a pictogram
- click on a different snippet
- click on the pictogram
=> an error popup is displayed

[1]: https://github.com/odoo/odoo/commit/7fd0698cf765a79959566b51e33cb76bff83d344
[2]: https://github.com/odoo/odoo/commit/d934b81aaae8d68b5579d1489b1fbe8ea347b4ed

task-2729177

X-original-commit: e1c4b62601e5a76a36406d790c9ad2da91c54951
Part-of: odoo/odoo#95963
Co-authored-by: qsm-odoo <qsm@odoo.com>
2022-07-15 14:21:57 +02:00
Benoit Socias d7707a4a88 [FIX] web_editor, test_website: hide previously computed image size
Since [1] the file size is displayed only for images that support
processing (filter effect, crop, resize...) but when switching to an
image that does not support it, the old size remains displayed.

After this commit when an image for which the file size is not computed
is selected, the previous file size is hidden.

Steps to reproduce:
- drop a Text-Image snippet
- select the image => the size is displayed in the options block title
- replace the image with an animated gif
=> previous size did remain displayed (now size is not shown anymore)

[1]: https://github.com/odoo/odoo/commit/089ae3d28b5d2d7bdbaad133174ae54240113181

task-2729177

X-original-commit: 378f67749a51d8c0b9fb65767faceaa0844916e5
Part-of: odoo/odoo#95963
2022-07-15 14:21:57 +02:00