Commit Graph
3502 Commits
Author SHA1 Message Date
Antoine Guenet 4acc954bff [FIX] web_editor: restore button and link commands
Commit [1] introduced an option to enable link and button commands.
The goal was to be able to disable it in website_forum when the user
doesn't have the proper privileges. Instead, it disabled it everywhere
except in website_forum (and then indeed only enabled it when the user
had said privileges). The same is true of images and videos.

This enables these commands by default instead, and disables them only
specifically for website_forum under the appropriate circumstances.

[1] e104937118

task-2917285

closes odoo/odoo#98111

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-22 16:48:34 +02:00
shsa-odoo e8c66dc10a [FIX] web_editor: replace button should replace the image then add another
Before this commit:

Replace button was adding another image without replacing the existing one.

After this commit:

Now replace button replaces the existing image with another one.

Task-2895601

closes odoo/odoo#98513

X-original-commit: 3e8db4fa7a2d8eb9eba4b184e33bb3a6f69ce687
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-22 08:57:50 +02:00
Ipsita Borisagar 968c13103f [FIX] web_editor: error while changing background color of button
Before this commit:

When we want to change the background color of a button, clicking on that button
will occur traceback(dropdown is not a function).

After this commit:

Traceback will not occur by initializing the dropdown component as it has
converted into the OWL component.

Task-2916277

closes odoo/odoo#96508

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-18 16:47:24 +02:00
Nicolas Bayet 3dc3b6cc3c [FIX] web_editor: don't observe changes that cancel each others
Before this commit, if the mutation records would contain records that
would cancel each others, those change would be listened and considered.
For instance:
- Mutation 1: Adding ID on element A
- Mutation 2: Removing ID on element A
When processing the mutation records, it is useless to consider those
2 as the Id of the element A is the same before and after the mutation.

This led to multiple issues, especially in case where some elements have
the same branding (and are thus the same field/xpath).
In such cases, the editor is replicating the changes made on one of them
to the others to keep the "same" fields sync'd.
For instance, if you go on an event page and try to modify a date, the
change will be replicated at multiple place in the page which are
actually the same t-field.

When replicating those changes, somehow the jQuery Sizzle ID changes
were listened, leading to infinite loop of mutation observer.

Step to reproduce:
- Install website
- Go to any page and enter edit mode
- Click on the navbar and in the right panel select Vertical header
- Activate the CTA option in that navbar right panel (should already be)
- Click on the CTA button
- Try to edit the URL in the right panel or any link option (style etc)

The changes will be ignored as the button's section is being re-rendered
every 50ms infinitely.
On chrome you can easily see it by watching the DOM in the dev tool. The
section will blink again and again, hinting about DOM change.

opw-2893480

closes odoo/odoo#98331

X-original-commit: 97c712e81692661fc9bc65e0810abc4dc017ed87
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-18 13:46:45 +02:00
Benjamin Vray 6bfca9f714 [IMP] web_editor: adds a remove button next to the shape selector
This commit aims to make it easier to remove a shape over a background
image.

Before this commit, we could only remove a shape by clicking on the
"shape" button in the background options (it was not easy to find
quickly), but with this commit we can now also remove it thanks to a
"remove" button that has been added next to the shape selector.

task-2827802

closes odoo/odoo#96788

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-08-17 19:48:18 +02:00
Antoine Guenet 737479b25b [ADD] web_editor, website: commands to convert text into columns
This adds commands to convert the current text into 2, 3 or 4 columns,
and to remove said columns.

task-2901585

closes odoo/odoo#95359

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-16 17:49:58 +02:00
Romain Estievenart 36628c9b1c [FIX] *: removes .form-inline
this commit removes the usage of .form-inline class which is deprecated
since BS5.

here is the css rules that was used:
https://github.com/twbs/bootstrap/blob/8fa0d3010112dca5dd6dd501173415856001ba8b/dist/css/bootstrap.css#L2303

'''Breaking change: Dropped form-specific layout classes for our grid
system.
Use our grid and utilities instead of .form-group, .form-row, or
.form-inline.'''

https://getbootstrap.com/docs/5.0/migration/#forms

We also took the opportunity to remove some .input-group-append and
.form-group. We are currently working to remove all of them.

Part-of: odoo/odoo#97967
2022-08-16 09:19:08 +02:00
Antoine Guenet 22a413f868 [FIX] web_editor: preserve card alignment on mailing conversion
Card dimensions were not properly preserved on mailing conversion.

opw-2850967

X-original-commit: 1be80cc83bec6a08abf6a3e8493d22f44350d038
Part-of: odoo/odoo#98107
2022-08-12 23:37:58 +02:00
Antoine Guenet b7f223eeab [FIX] web_editor: properly convert css calc and var values
convert_inline relies on getComputedStyle to crystalize var and calc
values. This however was conflicting with the fact that it also combines
positional styles (eg., margin-top, padding-left) together. This seems
to make getComputedStyle give out the wrong value with var and calc.

closes odoo/odoo#98003

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-12 20:16:47 +02:00
David Monjoie 300d3d1b74 [FIX] web_editor: fix code textarea size in Firefox
On Chrome, the textarea is automatically resized to use all the
available space. On Firefox, this is not the case. Since the css rules
only set the position of the textarea and not its size, the textarea in
Firefox was ridiculously small and unusable.

task-id 2950108

closes odoo/odoo#98060

X-original-commit: ca1d70cb36be99a171a46eb1455b9f5ef5ac388b
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-12 19:05:29 +02:00
David MonjoieandNicolas Bayet 0755d72433 [FIX] web_editor: fix colorpicker reverting history
The colorpickers forcefully reset the current history step to revert the
color change while previewing colors. This works when the only change in
the current step is in fact the colorpicker. If other changes already
existed in the current step however, they will be reverted as well. This
commit fixes the issue by introducing the concept of stashing mutations to
avoid that these be reverted. They can be unstashed later on when the
system is done abusing the revert mechanism.

task-2921844

closes odoo/odoo#97973

X-original-commit: cc280522d590c3ed257e7c6c495008e8986b2bf3
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Co-authored-by: Nicolas Bayet <nby@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
2022-08-11 17:57:34 +02:00
David MonjoieandNicolas Bayet 0c22f04354 [FIX] web_editor: fix link tools losing selection
When clicking the link tools button, the focus is set inside the URL
input, changing the selection temporarily to that input. This means that
if the user clicks any other button from the toolbar right after using
that input, a command would try (and refuse) to execute outside the
editable area.

The link tool is now destroyed when clicking other buttons of the
toolbar, thus either validating the link or reverting it, and the
selection is reset accordingly.

The toolbar buttons are now correctly bound on click rather than some
being bound on mousedown and some on clicks, like colorpickers, which
would result in weird behavior such as a mousedown handler modifying the
dom which changes the layout so the mouseup event is on another node and
the click is not fired anymore. This commit streamlines the behavior to
use click so that this issue does not occur anymore.

task-2921844

X-original-commit: 798e3d0eb0017e05261ca0a0c5e29706629f0350
Part-of: odoo/odoo#97973
Co-authored-by: Nicolas Bayet <nby@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
2022-08-11 17:57:34 +02:00
Antoine Guenet 85b1592b80 [FIX] web_editor: prevent toolbar disappear on click link tools button
When clicking the link tools button, the listener on `body` clicks is
triggered and we check if the toolbar should appear or be hidden. This
check should be skipped whenever we click in the toolbar but this was
checked via the selection on the global document rather that on the
editable's owner document, resulting in an oft-empty selection object.
As consequence, the checks were done and the toolbar was hidden, whereas
it should remain shown.

task-2921844

X-original-commit: f74184b4f98772949040eeea94e389b425fc3265
Part-of: odoo/odoo#97973
2022-08-11 17:57:34 +02:00
Antoine Guenet 457095b393 [FIX] web_editor: ensure link preview placeholder on empty label
When opening the link tools with a collapsed selection, we have an empty
link, which is ugly with its dashed border around an element of width 0.
This inserts a placeholder space composed of two nbsps so that the
dashed border is correctly rendered.

task-2921844

X-original-commit: a1a3fc850fe50284441f74afb43ac06b0ae2d6c4
Part-of: odoo/odoo#97973
2022-08-11 17:57:34 +02:00
Antoine GuenetandNicolas Bayet 720d46db4c [FIX] web_editor: adapt link on input url in link tools
The link tools were made so that one needed to validate the URL they
input before it was applied to the DOM. But this was awkward, especially
when the selection was collapsed and we counted on the URL input to fill
the link's label.

We need to pause history steps however, otherwise each change will be
its own step in the history and the user will have to undo as many times
as the number of characters that were entered.

task-2921844

X-original-commit: 226c4c4032c26d3d8f622b29fb151fa8e78ba70a
Part-of: odoo/odoo#97973
Co-authored-by: Nicolas Bayet <nby@odoo.com>
Co-authored-by: Antoine Guenet <age@odoo.com>
2022-08-11 17:57:33 +02:00
Antoine Guenet a98d10a75d [FIX] web_editor: only correct triple click when triple click
The triple click correction algorithm in `getDeepRange` is supposed to
do be triggered only when a selection spans multiple nodes and ends at
position 0 of a node. But it only checked the end of the selection and
failed to check if the selection actually did span multiple nodes.

task-2921844

X-original-commit: 22fdcc0d09e232c481f05eefdb2e60ba1cea4f10
Part-of: odoo/odoo#97973
2022-08-11 17:57:33 +02:00
Antoine Guenet b0d068a83c [FIX] web_editor: create a td for Bootstrap grid col offsets on convert
When converting Bootstrap grids to tables for e-mail compatibility, we
need to take into account Bootstrap offsets on columns. We were doing
this by adding that offset to the column but we actually need to create
an extra column instead.

task-2936705

closes odoo/odoo#97962

X-original-commit: 8beb7ac47c4cc86822bbc42b67ce5f6a44d41626
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2022-08-11 17:57:17 +02:00
Antoine Guenet f53e0da42d [FIX] web_editor: properly convert heights of masonry cells
Masonry's top inner container needs to have a 100% height to properly
size its contents.

task-2925779

X-original-commit: 717672d56958915084d98d69246c9e7e986fabab
Part-of: odoo/odoo#97962
2022-08-11 17:57:16 +02:00
Antoine Guenet 40324a03a6 [FIX] web_editor: properly switch background types in mass_mailing
The option to switch background types depends on CSS which was in the
website builder but absent from mass_mailing.

task-2925779

X-original-commit: 63595109516ec3f40be74115ce6cf8894977a727
Part-of: odoo/odoo#97962
2022-08-11 17:57:16 +02:00
Antoine Guenet 4897f23296 [FIX] web_editor: properly convert incomplete Bootstrap rows
When we convert Bootstrap grids to tables for e-mail compatibility, we
need to complete rows whose column sizes don't add up to 12. The way it
was, the last column was stretched to fill up the row, which is wrong as
it can affect the width of its contents.
With this commit, a new, empty column is appended to the row to fill it
up without affecting the existing rows. This is a more accurate way to
emulate the behavior of Flexbox.

task-2936705

X-original-commit: 462b698732dbc0e71972ddbe86c687f4bb3f9492
Part-of: odoo/odoo#97962
2022-08-11 17:57:16 +02:00
Arthur Detroux (ard) c6524ee9d6 [FIX] website: adapt carousel options to BS5
Commit [1] migrated to Bootstrap 5 using automation. This mistakenly
changed attributes related to Snippet Options.
Commit [2] moved the website edition in the backend which created a
conflict with the tooltip system of the editor ([data-tooltip="true"])
and the tooltip system of the backend ([data-tooltip="content"]).

This commit fixes both these issues by changing the XML and removing the
related js code.

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

task-2687506

closes odoo/odoo#94564

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-08-10 20:28:49 +02:00
Younn Olivier 6673a9c965 [FIX] web_editor, website: update toolbar visibility in translate mode
Before this commit, in translate mode, the toolbar and the
table-container were shown when initializing the SnippetsMenu (and
removed for a click on an element that was not a translation).

To reproduce:
-> Install another language on website 1,
-> Click on translate
-> Click on a button of the informative dialog
-> The toolbar was there, then was removed on the click on the dialog,
and won't reappear.

(If the informative dialog is not shown, because it was permanently
dismissed, click on an image, the toolbar is still there and won't be
removed).

To fix that, the clicks on translations elements are not stopped from
the TranslatePageMenu and are taken into account in
_checkEditorToolbarVisibility to show/hide the toolbar.

Related to task-2687506

closes odoo/odoo#97855

X-original-commit: fbe35ed2f4c0727d097227fa6decf544f5db27fe
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-08-10 14:44:02 +02:00
Benoit Socias 19e4f1a856 [REV] web_editor: not add a zero-width space on top of color palettes
Since [1] a zero-width space is added inside all `we-selection-items`.
This breaks the layout of color palettes because zero-width spaces
still have a height, and are not considered as empty text.

This reverts commit e59ad49cb9f32240d8ca3c89fc20ab200e291adc.

based on:

https://github.com/odoo/odoo/pull/97382#issuecomment-1208015098

[1]: https://github.com/odoo/odoo/commit/e59ad49cb9f32240d8ca3c89fc20ab200e291adc

task-2919573

closes odoo/odoo#97829

X-original-commit: 2091bce403368003add4b01eaafaea051c758e27
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-10 09:21:19 +02:00
Antoine Guenet 696f4dc753 [IMP] web_editor: prevent crash with wrongly defined commands
The Powerbox crashed whenever a command was wrongly defined. That's a
bit too brutal so this sets defaults instead.

closes odoo/odoo#97794

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-08-10 09:21:16 +02:00
Antoine Guenet 9263db52a1 [FIX] web_editor: properly define the signature command
The signature command was using the wrong property names, leading to the
Powerbox crashing.

Part-of: odoo/odoo#97794
2022-08-10 09:21:15 +02:00
Elisabeth Dickinson 24a4c7f897 [IMP] mass_mailing, web_editor: add basic img shapes, remove img Style
The `Styles` option contains styles which are unsupported in
emails. The few that are supported can be replaced by other options.
- Shadows: unsupported;
- Rounded rectangle: (unsupported in Outlook)
is replaced by the `Border` options which allows to customize the
border's radius more than the current option.
- Thumbnail: can be done with a combination of `Border` and `Padding`
- Circle: can be done with a shape
(which has been added along with other new shapes)

This option could be found on images and icons and has now been removed.
CSS styles in the `theme_default` file have also been removed since
they are no longer needed.

Three basic shapes (circle, triangle, "slanted" rectangle) have been
added to the `web_editor`'s `Basics` shapes page.
A condition was previously set on the page to avoid showing an empty
page. The condition is moved to each of its buttons instead, so that
new shapes added via xpath from `mass_mailing` to this page are now
visible.

task-2836942

Part-of: odoo/odoo#95974
2022-08-09 11:32:07 +02:00
Younn Olivier 5504c3f983 [FIX] test_website, web_editor: fix test_image_upload_progress tour
Before this commit, the tour test_image_upload_progress was failing
inconsistently at the step "check that the file was correctly uploaded"
during the upload of a single image.

[1] adapted the upload progress toast to owl, but it used a state
variable isVisible, updated with a useEffect hook called on change of
the file props. This was not optimal: the visibility could be updated
directly through a reactive variable from the upload service. Instead of
automanaging its visibility, the component is completely driven by the
upload service.

This small optimization is useful in regards of the implementation of
the TourService.
As it is implemented now, the TourService works this way:
When it completed a step, it will check for the tooltip of the next
step, in the next javascript call stack.
If it does not find it in the DOM at that time, it will listen to the
mutations and wait for 750ms after the last one to check again.

Here, as the progress toast was rendered visible not directly when
uploading a file, but after another render, after the useEffect was
executed, the progress toast was sometimes not found directly after
playing the step sending the 'change' event. Then, the TourService was
waiting for all the mutations to execute (the progress toast appears,
the media dialog closes itself, the toast hides itself) and check again
after a delay. But by then the toast was already hidden.

With that, the tour steps are rewritten to follow the flow:
- Open the media dialog in single upload mode
- Upload an image
- The toast is shown
- The media dialog is closed
- The toast with "The file has been uploaded" is still there
- The toast autohides

Also, the file input value is reset after uploading files, otherwise it
was not possible to upload the same file twice (the 'change' event was
not triggered).

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

runbot-4117

closes odoo/odoo#95890

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-08-09 11:31:59 +02:00
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