Commit Graph
4077 Commits
Author SHA1 Message Date
Stanislas Gueniffey c46ee8f4c0 [IMP] web_editor: create links with (Shift+) Enter
Typing a valid URL and pressing Space creates a clickable link with that
URL. Users expect the same to happen when pressing Enter instead (with
or without holding Shift), but that was not the case previously.

This commit enables link creation with both Enter and Shift+Enter. It
factorises the code that creates the link into a function
`_handleAutomaticLinkInsertion`.

While this feature is part of the `keydown` event for Space and
Shift+Enter, it is part of the later `input` event for Enter (without
Shift). This is due to a required call to historyRollback(), which would
undo the just-created link, forcing its creation to be delayed.

Two tests have been added for these new use cases. For the Space use
case, an existing test has been adapted to account for the change of
handling (from `input` to `keydown` event). That test is also simplified
to avoid modifying the DOM content (which was meant to replicate the
exact behavior of the browser for regular users, deemed not necessary
for tests).

Task-3094666

closes odoo/odoo#122001

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-06-02 14:29:57 +02:00
Martin Trigaux 2afdda2576 [I18N] *: export saas-16.3 source terms
closes odoo/odoo#123046

X-original-commit: 137f5ca0cb703ee953cb01db525362f7a778e6bd
Related: odoo/enterprise#41703
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-06-01 11:43:51 +02:00
Robin Lejeune (role) 3f80451100 [FIX] web_editor: fix flipped SVG shapes on Firefox
On Firefox only: some SVG shapes either disappear when flipped or are
not properly flipped.
This is due to the way Firefox parses SVGs and the way Odoo applies
transformations on them. It happens when the main `<svg>` contains other
nested `<svg>`, and the flip transformation is applied to each of them,
causing unexpected behaviors.
When the parent contains a direct `<svg>` child and both of them are
then applied a transformation, the whole shape disappears. When the
parent contains some `<svg>` inside a `<defs>`, and the children are
then included with `<use>`, each element is flipped individually, which
means the flip is not processed as we would expect.
This commit makes sure the flip is only applied to the main `<svg>`.

Steps to reproduce:
(A) >= 14.0:
- On Firefox, drag & drop the image-text snippet
- Add a background shape and choose "Origins 07"
- Flip it: it isn't flipped

(B) >= 15.2:
- On Firefox, drag & drop any block snippet
- Add a background shape and choose "Float 13"
- Flip it: the shape is hidden

task-3264851

closes odoo/odoo#123175

X-original-commit: 784b4dd1a7c0a75d301466a83a2894418ff8eaa2
Signed-off-by: Bojabza Soukéina (sobo) <sobo@odoo.com>
2023-06-01 10:25:30 +02:00
Louis (loco) 75ecaa48e6 [FIX] web_editor, *: reorder invisible elements panel at snippet move
*website

Steps to reproduce the bug:
- Add a Cover and a Picture snippet on the website.
- Change their visibility to "Conditionally".
- Change the order of the two snippets on the page either with the drag
and drop tool or with the "move up" or "move down" option.
=> Their order on the "Invisible Elements" panel has not been updated.

The problem is fixed by calling `_updateInvisibleDOM()` at the end of
`moveSnippet()` and `_onSnippetDragAndDropStop()`. Note that before this
commit, all the snippets with a conditional visibility were hidden at
the call of `_onSnippetDragAndDropStop()`. This is due to the call of
`cleanForSave()` from `_destroyEditors()`. `_onSnippetDragAndDropStop()`
has been adapted in order to, as for the "move" option, do not change
the visibility of those elements.

task-3203914

closes odoo/odoo#123027

X-original-commit: 3a023cf00812cfbbef7f3b406fbd01b74f07b7c8
Signed-off-by: Dieleman Guillaume (gdi) <gdi@odoo.com>
Signed-off-by: Colin Louis (loco) <loco@odoo.com>
2023-06-01 09:14:05 +02:00
Louis (loco) 0af5ffed31 [FIX] *: display the correct eye icon of the invisible elements
*web_editor, website

Steps to reproduce the bug:
- Add a Text-Image snippet.
- Change its visibility to "Conditionally".
- Save.
- Edit again.
=> The eye icon indicates that the snippet is not visible but the
snippet is displayed.

Note that [1] introduced a mechanism to solve this problem (the
`cleanForSave()` of the `ConditionalVisibility` option) but the code was
not working correctly since [2].

Let's first remember that when calling `toggleTargetVisibility()`, two
main actions are performed:
- The addition or suppression of the `data-invisible` attribute from the
dataset of an invisible element. This attribute is responsible for the
crossed or not of the eye icon in the "Invisible Elements" panel.
- The call to `onTargetHide()` or `onTargetShow()` that performs among
other things the addition or the suppression of the
`o_conditional_hidden` class on an invisible element. This class is
responsible for the visibility of the element on the page in edit mode.

This being said, here is what happened at the "Save" before this commit:
- `cleanForSave()` of `snippetEditor` is called. If the related element
has the `o_snippet_invisible` class, `toggleTargetVisibility(false)` is
called (meaning that the `o_conditional_hidden` class and the
`data-invisible` attribute are added to the element).

- `cleanForSave()` of the `ConditionalVisibility` option is called and
before [2], the `data-invisible` attribute was removed from the
corresponding element.

- At the `DOMContentLoaded`, the `o_conditional_hidden` class is removed
from all the elements that have a conditional visibility. The visibility
of those elements on the page now depends on the rule set by the user.

The goal of this commit is to restore the mechansim of the remove of the
`data-invisible` attribute from the conditionnal elements at the
`cleanForSave()`.

[1]: https://github.com/odoo/odoo/commit/1c442782f887a8c16bae05a43fae13a310ac05df
[2]: https://github.com/odoo/odoo/commit/de3c29fab2bc5349da8a9418f9d0086d76e6f7de

task-3203914

X-original-commit: b10d6cbf78235acd170716d556578227cccfbc14
Part-of: odoo/odoo#123027
2023-06-01 09:14:04 +02:00
Louis (loco) f45a6ea385 [FIX] web_editor: reorder the elements of the invisible elements panel
Steps to reproduce the bug:
- Add a form snippet on the footer of the website page.
- Change the visibility of the form snippet to "conditionally".
- On the footer settings, deactivate the "Page Visibility".
=> The form snippet is still present on the "Invisible Elements" panel
but clicking on it has no effects. Indeed, it is inside the footer which
is hidden.

The goal of this commit is to reorganize the "Invisible Elements" panel
in order to better visualize the hierarchy between the different
invisible elements. To do so, the list of the invisible snippet elements
(`[...$invisibleSnippets]`) is scanned. Each invisible snippet that is
the descendant of another is discarded of the list (to only keep the
"root" ones) and a map is created with its `keys` set to invisible
snippets that have invisible descendants. The `value` corresponding to
an invisible snippet element is a list filled with all its descendant
invisible snippets except those that have a closer invisible snippet
ancestor. The list of the root snippets is then scanned. Each root
snippet is inserted in the DOM as well as their descendant snippets
found thanks to the newly created map.

Note that thanks to this commit, another problem is solved:
- Add a cookie bar on the website.
- Add a Text-Image snippet and change its visibility to "conditionally".
- Save and edit again. Note that the "Cookies Bar" is above the "Text-
Image" on the "Invisible Elements" panel.
- Click to display the cookie bar.
=> The order of the "Cookies Bar" and the "Text-Image" is switched on
the "Invisible Elements" panel.
Indeed, before this commit, the order of the snippets was influenced by
the order of their snippet editor creation. Because this order was not
always the same from one call to `_updateInvisibleDOM()` to another, a
glitch could happen when toggling a snippet visibility.
This is now fixed as the order of the invisible snippets in the
"Invisible Elements" panel is determined either by their order in the
list `rootInvisibleSnippetEls` or their order in the lists contained as
value in the map `descendantPerSnippet`.

task-3203914

X-original-commit: 548e95b3dc9bf642c5eea3fc43b83f7ce282be0b
Part-of: odoo/odoo#123027
2023-06-01 09:14:04 +02:00
Benjamin Vray 3a2288dc28 [FIX] web_editor: fix image cropping not working
Since this commit [1], the image cropping feature is no longer
functioning properly. The modification of the "activateCropper" function
code to remove the use of underscore has resulted in a change in the
"data" parameter value passed to the cropper compared to before. This
alteration is the cause of the issue.

Steps to reproduce the bugs:

- Open the homepage in Website edit mode.
- Drag and drop a text-image snippet onto the page.
- Click on the image in the text-image snippet.
- Click on the "Crop Image" button in the image options.
- Change the aspect ratio of the image by clicking on the "4:3" button.
- Click on the "Apply" button to apply the changes.
- Bug: The changes are not being applied.

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

task-3339518

closes odoo/odoo#122996

X-original-commit: d42070b6abe5ca65d43ae4f2426619684c7aec4d
Signed-off-by: Colin Louis (loco) <loco@odoo.com>
2023-05-31 14:23:29 +02:00
Antoine Guenet 6861402746 [FIX] web_editor: save on more than just input
Since commit [1], the state of the editor in the html field is only set
to dirty when the user triggers an input event. This means that if the
user uses the mouse to change the content of the field (eg, drag and
dropping snippets), the editor is not marked as dirty so the save button
will not appear and autosave will not work.

This commit fixes this by checking the editor's dirty state whenever a
history step event is triggered. Since this reverts commit [1], we need
to ensure the bug it fixed does not reappear. This is done by ensuring
we don't check the saved value against the modified editing value when
it's empty (namely, the editor doesn't allow an empty string as a value
and replaces it with `<p><br></p>`, which we need to undo in
`_isDirty`).

task-3263653
task-3288416
opw-3274329

[1]: https://github.com/odoo/odoo/pull/113088/commits/095bbb93d6c3b9b0b099b7ed1a6a15e8ad914e9f

closes odoo/odoo#122628

X-original-commit: db0c092973f480f3336a44e5f6868dc5a79f0e3a
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2023-05-26 16:15:59 +02:00
Stanislas Gueniffey 23922fa2af [IMP] web_editor: re-run tests with mobile version
Some tests use methods that have two different implementations (one for
desktop and one for mobile). So far, the only example is deleteBackward
and its mobile counterpart deleteBackwardMobile.

This commit introduces a mechanism in the web_editor tests to avoid
duplicating such tests. When a test calls a method that has two
implementations, it uses the desktop one by default and a flag is set
that indicates the test should be re-run with its mobile implementation
next.

When errors are raised while the mobile version is in use, we prefix
their message with '[MOBILE VERSION]' to ease debugging.

Note that this mechanism relies on proper flag management by the
aforementioned methods.

Task-3054808

closes odoo/odoo#122096

X-original-commit: 008ab1c9971928411ee797d50d0aef71dde5f5ed
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Stanislas Gueniffey (stgu) <stgu@odoo.com>
2023-05-23 18:01:51 +02:00
Renaud Thiry bb542f8374 [FIX] mail: allow editing of mail mail
As it holds full HTML documents, mail.mail often encounters issues with
the html editor.

We piggy-back off the intoduction of the switching
behavior between code-view and readonly-view behavior introduced in
a5c0085ce91570c6c961e3293dfe50f4faba6043

The 'sandboxed preview' mode can now be enabled with an option
and will ensure all content can only be viewed in a sandboxed iframe
or in the code editor.

This re-introduces editing, which was mistakenly fully disabled in the
usability fix that introduced body_content here:
5055b374c3bac0126f441dad61afd7e0b68b1370

Some tests are added to ensure the key points of this commit remain
the same. Tests are re-ordered alphabetically to match the order
of execution, making debugging easier.

task-3255777

closes odoo/odoo#121976

X-original-commit: 062569ef042f3b01044c5e4cdbd8b71e96bfd39d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-23 16:32:13 +02:00
Renaud Thiry 5ee99c04ce [FIX] web_editor: hide codeview when readonly
In 2389f77c25f3c4dcfd609a8674dc673703cac6a1
containsComplexHTML was added to allow editing of html content
that would otherwise break when inserted as-is in a DOM

For this we added a rule to always display the code view toggle button.
This should not be the case when the field is marked as readonly.

Switching to the code view in readonly mode will cause a traceback.

task-3255777

X-original-commit: 243b7879ecad229aaefed3cdf0c64e7ae434d8ec
Part-of: odoo/odoo#121976
2023-05-23 16:32:12 +02:00
Antoine Guenet 8ca115b3b9 [ADD] web_editor: full screen image preview on dblclick (html field)
When double-clicking on an image in an html field, display it "full
screen" (similar to clicking on an image in the attachments list). This
replaces the current behavior (which is to open the media selector to
replace the current image - the Replace action remains available in the
toolbar).

In the toolbar for images, display an icon that users can click on to
open the full screen preview as well.

task-3109331

closes odoo/odoo#119625

Related: odoo/enterprise#40450
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-23 16:31:21 +02:00
Odoo 47cd29f33c [FIX] web_editor: non-uniform behaviour in
Before this commit:

When a new list is created and any list item is applied a style
like h1, bold ,itallic etc.. and when when toggle that list, the list
style breaks

After this commit:

Toggling through the list does not break the style.

closes odoo/odoo#121955

Task-id: 3269908
X-original-commit: d06e043c4b55e2157992bf4a12b40f1e6bd3b690
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-22 17:52:18 +02:00
Louis Wicket (wil) 04189318cc [I18N] *: update master translations
Currently, only stable releases see their translations updated. This has
resulted in master accumulating outdated stuff for years, which can be
confusing for users testing master on runbot.

This one-shot commit resynchronizes master translations based on the
content from 16.0 and removes empty PO files (i.e. no longer containing
translations).

closes odoo/odoo#121629

Related: odoo/enterprise#41171
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-05-22 17:52:07 +02:00
Deependra Solanki 13c6e34635 [FIX] web_editor: command click goes through fix
Before this commit:

Previously, when opening a command bar below an image such that the command bar
was on the image, clicking on the command bar would select both the command bar
option and the image.

After this commit:

Clicking on the command bar no longer selects the image when it is beneath the
command bar.

Task - 3126311

closes odoo/odoo#121941

X-original-commit: 4a25135dc19337eea70102f33468371e5bf88d27
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-22 16:30:09 +02:00
Stanislas Gueniffey 0cf2437f67 [IMP] web_editor: remove dead '_onInput' code
The 'insertLineBreak' case in `onInput` is dead code because any event
that might cause it (pressing Shift+Enter) first triggers `onKeydown`,
which calls `ev.preventDefault()` and thus prevents it from reaching
`onInput`.

Task-3301232

closes odoo/odoo#121850

X-original-commit: c63cd2f0140959a7ac6e05ef15ac5c2ac552453d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-22 11:43:11 +02:00
dhba-odoo 28b54dfa39 [FIX] web_editor: entering a hax color triggers traceback
Before this commit:

In mass_mailing entering a hax color for text triggers traceback.

After this commit:

Now, the traceback will not be triggered and color will be applied to the text

Task-3271517

closes odoo/odoo#121800

X-original-commit: b526bc1e56fd486cad422bca3a7b0e837376cd17
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-19 15:40:52 +02:00
David Monjoieanddhba-odoo 6dd38640ce [FIX] web_editor: fix select all in empty paragraph
The previous code with `parentsUntil` would not return any result
in an empty paragraph because the only valid element would be the
anchorNode itself but `parentsUntil` would only return parents and
never the base node itself. It makes sense, but is not suitable for
the case at hand.

Before this commit:
CTRL+A does nothing from inside an empty paragraph.

After this commit:
CTRL+A correctly triggers a select all from inside an empty paragraph.

Task-3150956

closes odoo/odoo#121727

X-original-commit: 4bcba1d785afeaa8287adc48076f208d04fc72c3
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Co-authored-by: dhba-odoo <dhba@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
2023-05-19 10:18:57 +02:00
Preksha Chouhan feff1fc79f [FIX] web_editor: convert color opacity to be compatible with PIL Image color
ValueError 'unknown colour specifier' occurs when we access
export_icon_to_png(). This error occurs when we change the colour of an
icon in the mailing template, because the value of alpha (opacity) in 'rgba'
is in the range of 0 to 1, but PIL Image support colour opacity range 0 to 255.

This commit converts the opacity value range (0 to 1) to a range (0 to 255)
compatible with the PIL image library when the colour specifier is 'rgba'.

sentry - 3933353285

closes odoo/odoo#121696

X-original-commit: 7e4be89f6c0b2f8b82a207030e8a8cb20d72664f
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-19 10:18:53 +02:00
Martin Trigaux 077bbd0b0b [I18N] *: export master source terms
closes odoo/odoo#121563

Related: odoo/enterprise#41140
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-05-17 10:34:00 +02:00
Soukéina Bojabza fcd100cf8f [FIX] web_editor: fix grid mode with inner snippet outside a row
Before this commit, there were cases where toggling the grid mode did
not work correctly. These cases are:
- when a snippet has None columns (e.g. Cover) and that an inner snippet
containing a row (e.g. Form) was dropped into it,
- when a snippet has some content outside its row (e.g. Picture) and
that an inner snippet containing a row was dropped in this outer
content,
- when a snippet has some content outside its row (e.g. Picture) and
that an inner content (e.g. Alert) was dropped in this outer content.

The first two cases happen because the row that was taken into account
when toggling the grid mode was the first `.row` element found in
general, instead of only considering the container children. Therefore,
what happened in these problematic cases is that the row found was the
inner snippet one, which should not be the case and caused the toggle to
fail because it was trying to put the element inside itself.

The third case happens because the `div` elements were excluded when
placing the outer content in a column, instead of only excluding the row
element.

This commit fixes these issues by only considering the container
children when looking for the row element when toggling the grid mode,
and by filtering out only the row element instead of every `div` when
creating a column for the outer content.

task-3279191

closes odoo/odoo#121393

X-original-commit: f94fe1d40f05a8dbb42f0f2a95d3fff68a3af0ec
Signed-off-by: Dieleman Guillaume <gdi@odoo.com>
2023-05-16 14:42:09 +02:00
Rodolpho Lima 859b17e3fc [FIX] web_editor: fix typo that led to unexistant property read
closes odoo/odoo#119556

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-15 15:07:19 +02:00
Rodolpho Lima 5994c3a8b3 [FIX] web_editor: add unit tests for selection correction
This commit adds unit tests for cases where the cursor is placed at the
editable root (which is corrected by the Editor).

Part-of: odoo/odoo#119556
2023-05-15 15:07:19 +02:00
Rodolpho Lima 0c9980f1dc [FIX] web_editor: fix selection on editable root
Some of the Editor methods relies on not having inline elements at
the editable root. For this reason, the cursor should never be placed
at the editable root, but always inside a block element.

Before this commit, in some situations (notably around tables and
horizontal separators), the cursor could be placed having its anchorNode
at the editable root, allowing the user to insert inlined text at it.

This commit fixes the selection range in such cases, and an empty paragraph
is inserted in cases where there would be no other way to insert text before
or after an existing block.

task-3128747
opw-3106752

Part-of: odoo/odoo#119556
2023-05-15 15:07:19 +02:00
Rodolpho Lima ab0b2440fc [FIX] web_editor: split isVoidElement utility function
The `isVoidElement` utility function has a misleading name, and the need
for an actual list of void elements arose.

This commit replaces the `isVoidElement` utility by two functions:
- `isArtificialVoidElement`: returns true for elements that we decided to
treat as if they were void elements. This method is used to decide whether
they should have their "isContentEditable" attribute set to false.
- `isNotAllowedContent`: actual void elements + the ones above.

Part-of: odoo/odoo#119556
2023-05-15 15:07:18 +02:00
Soukéina Bojabza fa0cd18f9d [IMP] web_editor: align numeric inputs text without units to the right
Before this commit, the input widgets that do not have units have their
text aligned to the left. However, when the content is numeric, it would
be better if the number was on the right, just as when there is a unit.

This commit also considers as numeric an input widget that has the
`data-step` attribute (and not only the `data-unit` attribute) and
forces the text alignment to the right in this case.

task-2798576

closes odoo/odoo#89055

Signed-off-by: Dieleman Guillaume <gdi@odoo.com>
2023-05-15 12:55:58 +02:00
Benoit Socias 225cea8b74 [FIX] web_editor: restore avoiding updates of link content
[1] mistakenly removed the variable used by the mechanism that was
introduced in [2] to avoid updating link content.

This commit uses the link's `needLabel` instead to achieve the same
goal.

Steps to reproduce:
- Add a mega menu.
- Set the mega menu template to Cards.
- Click on the text of a card.
- DO NOT click on the edit link icon in the popover.
- Click on the href field in the options panel.
- Change the value.

=> Links content was broken (image was removed and texts were grouped).

[1]: https://github.com/odoo/odoo/commit/75166dbcd4962f30624fe19829757acbf8e76022
[2]: https://github.com/odoo/odoo/commit/7a0e58f8d7237514d23d815cdf3d81fc79edb1ec

task-3300977

X-original-commit: 1dbcf2825b2d495c206e110a39efe620e646e7c4
Part-of: odoo/odoo#121362
2023-05-15 11:41:54 +02:00
Pulinckx Pierre (PIPU) f4f0f78318 [REF] *: Replace underscore.js function by native JS
Before this commit : The library underscore.js and
underscore.string.js were used in the ODOO solution.
After this commit : Every usages of a function from
underscore.js lib has been replaced with native javascript.
The goal is to remove all usages of underscore.js and to
not use anymore this library in ODOO.
---
TaskId : 3246238

closes odoo/odoo#120437

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-05-15 09:37:48 +02:00
Brieuc-brd 418413e499 [IMP] web, *: directional icons
This commit adapts the directional icons to improve the usability and
maintain consistency with the ui icons library.

task-2818586

Part-of: odoo/odoo#116641
2023-05-12 22:59:22 +02:00
stefanorigano (SRI) 46b762a1f1 [REF] web, *: milk colors
*: google_calendar, hr_holidays, hr_skills_slides, mail,
microsoft_calendar, point_of_sale, web_editor, website_livechat,
website_sale

task-2818586

Part-of: odoo/odoo#116641
2023-05-12 22:59:12 +02:00
Benoit Socias 4978d2d107 [IMP] *: allow empty frontend m2o and deselection in the editor
*: base, web_editor

The Many2oneUserValueWidget does not allow the user to reset it
to blank if it already contains a selection. This commit makes it
possible to select an empty value by specifying a `null_text` option.

task-2406626

Part-of: odoo/odoo#67913
2023-05-12 19:54:08 +02:00
Mathieu (mano) b7b05a2d1c [IMP] web_editor: new shapes full height menu
This commit replaces the `we-select-pager` for a full-height version
allowing better sorting and visibility of the shapes and background
shapes.

The new UI now has a navbar inside the pager which allows to scroll to
anchors inside the menu. To do so a new attribute `data-scroll-to` is
added on the button element allowing to scroll to the class contained
in the attribute with the new function `_onClickScrollPage`. Thanks to
ard the Selection widget now activates the corresponding menu section
of the new pager whenever the data-scroll matches a section that has
passed the middle of the container.

The menu being full width, the angle with the class `.o_pager_nav_angle`
triggers the `_onClickCloseMenu` to close the menu.

To avoid duplication, the label for the devices now uses the same Js
logic as the Animated label for the shapes. This frees the :before and
:after which allows to use the alpha-background extended class on the
we-button for both types of shapes. The devices label information now
shows an aspect ratio rather than full dimensions.

For the new pager to appear full-height and the content being scrollable
inside the proper section of the menu, two new containers are added
one for the pager's navigation (`o_pager_nav`) and one for the shapes
pages (`o_pager_container`). This allows to have the parent div in fixed
positioning and keeping a scrollable section on the `o_pager_container`
under its inner navigation.

The previous shapes are back to their original ratio of 800x600
since switching them in square makes them less recognizable.

Finally, in the `we-toggler` when no elements are selected or when it is
empty, we now display `None` instead of `/`.

task-3266751

closes odoo/odoo#118253

Related: odoo/design-themes#653
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-05-12 11:17:41 +02:00
Odoo c6af10ff34 [FIX] web_editor: deleteing content from a link throws traceback
Before this commit:

When a new link a created on a new sentence, and clicked on it opens a popover,
when your start hitting backspace then as your reach the extreme left it throws
a trace-back error.

After this commit:

Trace-back error is not thrown while deleting backward it does not throw
back.

closes odoo/odoo#120578

Task-id: 3252709
X-original-commit: 843d1be63140b8cdb00e3f18c67ad7803d998a21
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-11 18:25:17 +02:00
qsm-odoo ad63194af3 [FIX] web, *: use proper http-equiv="X-UA-Compatible" value
*: mail, point_of_sale, pos_self_order, web_editor

The `,chrome=1` part is no longer a supported value as the Google Chrome
Frame plugin was discontinued on February 25, 2014. See [1].

Indeed the W3C validator returns an error about this.

[1]: https://rocketvalidator.com/html-validation/a-meta-element-with-an-http-equiv-attribute-whose-value-is-x-ua-compatible-must-have-a-content-attribute-with-the-value-ie-edge

Part-of: odoo/odoo#120311
2023-05-11 18:25:07 +02:00
Benoit Socias 38e2aef445 [IMP] web_editor, web_unsplash: alternate unsplash and illustrations
Before this commit, all search result illustrations were displayed
before the Unsplash images.

This commit makes the search result images from Unsplash and the
illustrations alternate, beginning with the first Unsplash image.
The existing attachment results remain in front.

task-3060679

closes odoo/odoo#111481

Signed-off-by: Bojabza Soukéina (sobo) <sobo@odoo.com>
2023-05-09 19:26:45 +02:00
Xavier-Do ab1e4f670a [REF] web_editor: change custom url
Before this commit an ir_assets generated automaticaly by the web editor
will generate an url ending with ...custom.addon.bundle_name.ext

After this commit the url will start with /_custom/addon.bundle_name/...

This will make it easier to spot at immediately if it is a custom asset
and thus it is useless to apply the glob. Actually, it will fail on the
/_custom when trying to glob, making it faster.

This is mainly useful to clarify and debug but in a case with mainly
customised ir_asset for one bundle, it may have an impact on speed.

An upgrade script was created for this change.

closes odoo/odoo#120699

Related: odoo/upgrade#4636
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2023-05-09 18:27:01 +02:00
Robin Lejeune (role) 5f197e76f4 [FIX] web_editor: fix HTML/CSS editor resizing bug
Starting on version 16.0, the HTML/CSS editor is very hard to resize.
This is due to 16.0 introducing an iframe for the website: as soon as
your mouse enters the iframe, the editor loses focus and cannot be
resized anymore.
This commit fixes that.

task-3006138

closes odoo/odoo#120729

X-original-commit: e489abeffc72293544acb18eba23b52ed2224d60
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-05-09 11:57:19 +02:00
Julien Mougenot c6637e537e [REF] *: Remove date picker libs from main bundles
This commit removes both DateRangePicker and TempusDominus libraries
from the common asset bundle. The legacy widgets still depending on
these libraries will now load them lazily when instanciated.

Part of task 3121497

Part-of: odoo/odoo#112171
2023-05-05 13:52:22 +02:00
Deependra Solanki 36b5757dcd [FIX] web_editor: fix line merge on color change
Before this commit:

When using shift+enter to move to a new line, now applying bold, italics,
underline, etc and then trying to add a color to both lines would result in
lines merging.

After this commit:

Now when the both lines are bold and then applying a color to both the lines
would no longer merge.

closes odoo/odoo#119701

Task: 3269922
X-original-commit: 0473dbd0090dd7b2fb1ff59a83a38df941303681
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-03 12:39:35 +02:00
Michael (mcm) 517d3258f2 [REF] web,*: add dependencies param to odoo.define
This commit makes the `dependencies` param of
`odoo.define` mandatory. It was optional and when
omitted, a regexp read the function to find the
dependencies. We can simplify it now almost all js
modules have been converted to esm.
The transpiler already adds the param for the es
modules except if the module has an alias.

task id: 3271352

closes odoo/odoo#119145

Related: odoo/enterprise#40040
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2023-05-03 12:39:30 +02:00
can-odoo 044a3cfdb3 [IMP] web_editor: set default values for repeat-pattern background size
Description of the issue/feature this PR addresses:
---

When a user chooses "Repeat Pattern" as the background image position,
nothing happens.

Current behavior before PR:
---

As the background size is set to auto, for background-position
`repeat-pattern` no effect[1] can be seen in the
background size.

[1]: https://bit.ly/3MM31Ac

Desired behavior after PR is merged:
---
Not a bug but can be considered an improvement in features by setting
some default[2] width or height for a repeat-pattern option for all
relevant snippets.

[2]: https://bit.ly/3GbGIBo

task- 2862510

closes odoo/odoo#102995

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-05-02 20:01:39 +02:00
Pulinckx Pierre (PIPU) 126da95642 [FIX] *: replace %d by %s when using sprintf
*: web, web_editor, payment
Before this commit, templates with %d was given to sprintf but it was not interpreted by the function
After the commit, %d are replaced by %s in templates for sprintf
Also this commit converts a last _.str.sprintf into sprintf

PR#120143

closes odoo/odoo#120143

Signed-off-by: Michaël Mattiello <mcm@odoo.com>
2023-05-02 15:59:04 +02:00
David MonjoieandJinjiu Liu d0e14f6064 [FIX] web_editor: fix ClipboardJS traceback in Firefox 109
Starting with Firefox 109, a widget element prototype that is put
inside an iframe will not be instanceof its original constructor.
See: https://github.com/webcompat/web-bugs/issues/118350

This is because a node that is adopted by an iframe will have its
prototype changed to match the constructor from within the iframe
instead of its original one. This has been the case for a long time.
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1470017

It largely went unnoticed because of another quirk of Firefox related
to the use of instanceof which was fixed in version 109.
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1360715

Since this bug was fixed it became apparent, in the form of a
traceback, that the wrong instance of ClipboardJS was being used
in the case of Firefox, due to the forced prototype change.

This commit could be reverted once Firefox is fixed.

Steps to reproduce the issue in Firefox > 109:
- Create a new mass mailing.
- Choose the third template with "Thank you for joining us!".
- Click on the "LOGIN" button link inside the email.
- Get a traceback about a paremeter not being the right type.

Task-3186513
OPW-3172914

closes odoo/odoo#120171

X-original-commit: c0da01c716716f9d35abe9d90dad27cce1452ebb
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Co-authored-by: Jinjiu Liu <jili@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
2023-05-02 14:47:28 +02:00
Mathieu (mano) 3e683cc716 [IMP] web_editor, website: add minor design improvements to the editor
This commit gives a small refresh to the web_editor UI. To do so we
remove the borders from the buttons and inputs. We also increase the
border radius to 4px instead of 2px. The nested menus such as in Themes
tab now have the same  background color than the rest of the UI.

The box shadows on the `we-title`, `we-customize-block-options` and the
checkbox switch have been removed.

All the buttons and select components are now taking the full available
width. The inputs fields remain unchanged except their font which is now
set to sans-serif.

Finally a `<div>` have been added to the replace media snippet to make
it consistent with the other buttons having an icon. Maybe in the future
we'll need a better way to define those.

task-3265187

closes odoo/odoo#119697

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-04-28 16:04:35 +02:00
Benjamin Vray 33b86b26e3 [FIX] web_editor: fix resizing and padding options of snippets
Since this commit [1], the resizing and padding options of snippets are
not functioning properly in the website's edit mode.

For example, if a user wants to increase the width of a column to the
right, nothing happens. The user must first reduce the column by moving
to the left with the mouse before being able to increase it to the
right. The same problem occurs when attempting to adjust the padding
using the handle buttons.

This issue was caused by a numeric value ('key') being changed to a
string.

[1]: https://github.com/odoo/odoo/commit/800223ae7c5891bf700d45eb6d5f541093dc273c

task-3289164

closes odoo/odoo#119681

Signed-off-by: loco-odoo <loco@odoo.com>
2023-04-28 16:04:33 +02:00
Guillaume (gdi) b4ba82dc20 [FIX] web_editor: correct the custom block HTML
Since [this other commit], custom blocks are not displayed correctly in
the editor. The DIV tag is not supposed to be self-closing. However,
older versions of JQuery supported it anyway (they turned `<div/>` into
`<div></div>`) Since the update of JQuery to version 3.6.3, self-closing
DIVs are no longer correctly supported by JQuery.

For example, if you type this in the Chrome console:
```
$(`<div id="divRoot">
    <div id="selfClosing"/>
    <div id="notSelfClosing"></div>
</div>`)[0]
```
JQuery will create the following structure:
```
<div id="divRoot">
    <div id="selfClosing">
        <div id="notSelfClosing"></div>
    </div>
</div>
```
JQuery doesn't parse the HTML correctly and returns a wrong structure
(the `#notSelfClosing` is moved inside the `#selfClosing`).

Note that doing `$('<div/>')[0]` will return a correctly parsed DIV.

This commit corrects the layout structure of custom blocks so that they
are not composed of self-closing DIV.

Steps to reproduce the issue:
- Edit a website page
- Drop a block
- Click on the save icon
- Click on "Save and reload"

=> The custom block is not displayed correctly.

[this other commit]: https://github.com/odoo/odoo/commit/ae1cd3d5bb99b9835501144522b71f152aaf8e34

task-3290172

closes odoo/odoo#120027

X-original-commit: fd76d59bcd08e824c4e46814d0754a225f7a1b72
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
Signed-off-by: Guillaume-gdi <gdi@odoo.com>
2023-04-28 09:53:06 +02:00
abd-msyukyu-odoo 1baeea454f [FIX] web_editor: fontawesome subnodes should make a node non-empty
For each node that the `insert` command inserts, the previous node is evaluated
and tested to be a `shrunk` block. If it is, it is considered "invisible" and
removed.

Prior to this commit, an element containing sub-elements with a fontawesome icon
was considered to be `isEmptyBlock==='true'` even though it is supposedly
visible as it contains that icon.

Therefore in cases where multiple nodes are inserted at once, if one of them has
only fa-icon nodes as children, that node would not have been inserted.

Task-3284580

closes odoo/odoo#119931

X-original-commit: 373c3da609582bd170e1c5924a5c2351eb4706ca
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-04-27 18:25:15 +02:00
luvi 894090914e [IMP] web, *: add supportedOptions documentation as field metadata
*: mail, mass_mailing, sms, web_editor

This commit adds a new supportedOptions attribute that can be added to any
field widget metadata object. This documentation can be used from other places
(Studio for example) by getting the field from the registry and then read
this key. This attribute can contain an array, detailing the list of available
options for the field widget.

By using an array, it can be ordered easily without having an object with keys
unalphabetically. Ordering the options can make sense, especially when two
options are tied to each other, it is easier to group them one after the other.
(eg: 'start_date' first, then 'end_date')

Each option documented is an object and has the following attributes:
- help: contains more details on the current option and its use
- name: name used in the options object from the node
- label: a label with a more explicit name than the option name
- type: the type of value that must be used as a value (string, boolean, selection, field, domain)
- choices: for options with a 'selection': can be used to know available values
  where multiple values can be chosen as the value. This must be
  an array containing the options.
- availableTypes: for options with a 'field' selection: can be used to filter the
  available fieldNames to choose as a value.
- default: the value that is used by default, when the option is not set
  in the options

task-3259617

closes odoo/odoo#118713

Related: odoo/enterprise#39847
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-04-27 11:21:09 +02:00
Stanislas Gueniffey 7c0d82a3d9 [IMP] web_editor: allow pasting HTML tables
Previously, when a clipboardData contained both files and html content,
we prioritised files. This is correct when the original content is an
image (in which case the clipboard html may contain an image tag or be
empty, depending on the source). This is however incorrect in at least
one known case: copying a table from a spreadsheet app, as those usually
generate an image of the table alongside the actual html table. In that
case, we would rather keep the table.

This commit differentiates the specific case where the HTML represents a
table from other cases. In the former, priority is now given to the HTML
content. In the latter, we keep the files as we did before.

task-3165757

closes odoo/odoo#119862

X-original-commit: 021f2f028b382fe15ca75928d1b30a4eb48322df
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-27 07:06:08 +02:00
Jinjiu Liu 25be2d15c2 [FIX] web_editor: don’t delete table cell when its left cell has content
Reproduction:
1. Create a 1 by 3 table, input something in the first cell
2. Go to the second cell, hit backspace
3. The second cell is deleted and the third cell is moved to the second
cell

Note: in 15, we don’t have the table selector to remove a row of the
table but that is another issue

Fix: when we try to delete the table cell and the offset is 0, nothing
should be done. Also added a test to make sure the cell is unchanged
when we try to delete in an empty cell which has a cell with content
at the left. Also we skip the rejoin block step if there's a table cell
element is invoivled because the cells are not deleted and rejoining
them is not needed

Task-3171904

closes odoo/odoo#119765

X-original-commit: f62275ddb3967ff769cddcde070b4688d36dc4dd
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-26 23:01:12 +02:00