Commit Graph
4188 Commits
Author SHA1 Message Date
Antoine Guenet 9d644624dd [FIX] web_editor: only clean ZWS in text nodes actually containing ZWS
When cleaning zero-width spaces (ZWS) in the editor, we were replacing
the node values of all text nodes descending from the node we were
cleaning, regardless of whether they contained a ZWS or not. This could
lead to wrong selections in the tests when arbitrarily changing the
value of a text node in the selection.

Part-of: odoo/odoo#111119
2023-06-08 13:10:02 +02:00
Antoine Guenet c270ba9e85 [REF] web_editor: refactor the sanitizer
This refactors the editor's sanitizer for clarity and efficiency.

task-3081457

Part-of: odoo/odoo#111119
2023-06-08 13:10:02 +02:00
Antoine Guenet 60b37a6fcf [REF] web_editor: turn Sanitize class into a function
The sanitizer was declared as class but was only used as a function.

task-3081457

Part-of: odoo/odoo#111119
2023-06-08 13:10:01 +02:00
Adnan Saiyed 8b90e6be45 [FIX] web_editor: in list heading does not indent by tab
Current behaviour before commit:

In list, heading element doesn't indent when pressing tab.

Desired behaviour after commit:

Now heading element gets indented using tab.

Task id- 3239958

closes odoo/odoo#123569

X-original-commit: e9b33cdb835d36329effa01e2d1045980ec288e9
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-06-08 10:26:36 +02:00
Sébastien Geelen (sge) dd7a50db06 [FIX] web_editor: ensure dynamic placeholder focus
When inserting a dynamic placeholder in the editable document
we need to ensure the said document currently hold the focus and
have an active selection range.

This was previously handle by the `onDynamicPlaceholderClose()` method
which used to be called before `onDynamicPlaceholderValidate()`.

This seems to have changed from 16.1 to 16.2.

In order to fix the problem and ensure the focus in any situation,
we add a `wysiwyg.focus()` call at the beginning of the validate method.

task-3222474

closes odoo/odoo#124149

X-original-commit: 51b992dec0bcdf09fde5e0811699235b590723ee
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-06-07 18:01:13 +02:00
Sébastien Geelen (sge) 335dd9a1e4 [FIX] web_editor: delete comment nodes on sanitize
During `to_inline` process, the document will be transformed to be email friendly.
This can add some `<!-- mso -->` comment into the document.

These comments nodes will create issues during future edition,
if we keep them in the editable.

So we add a sanitize step to remove all comments nodes.

task-3222474

closes odoo/odoo#124020

X-original-commit: b85a29d9ba36aaaa90e514ba45d1054b693a26e2
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
2023-06-07 08:59:10 +02:00
Sébastien Geelen (sge) 74dc80e796 [FIX] web_editor: better urgent save for to inline html field
Reorganize the urgent save steps to call `_toInline` before the urgent `updateValue`.
This will give a chance to the _toInline to finish before the `updateValue`
if no asynchronous process is triggered during the inlining process.

In case we have some async stuff that delay the `_toInline` completion,
we keep the second `updateValue` which will wait for the asynchronous completion, as before.

task-3222474

X-original-commit: 85540a58a58b5f60b587697490fe837b3e4a69ec
Part-of: odoo/odoo#124020
2023-06-07 08:59:09 +02:00
Sébastien Geelen (sge) 722d5fb225 [FIX] web_editor: remove column in inline html field
Column (from bootstrap css) are broken during toInline conversion,
so we remove them from the commands in inlineStyle context.

During inlining of the document,
the css of bootstrap columns ( width, margin, padding, ...) is embeded
and hadcoded in the `style=""` property of the column div element.

After such a process, the edition system cannot work with these column anymore :
It cannot, for example, affect the number of column or remove a column via the powerBox.

If we leave those commands available,
after inlining, the column commands will always work as if there is no column present
at the current location in the document.

For example : Instead of changing the number of column, the user will
create a new set of columns inside a previously inlined column.

task-3222474

X-original-commit: caf4bbe153557249679e0eab2cdb90f9e04708f3
Part-of: odoo/odoo#124020
2023-06-07 08:59:09 +02:00
Sébastien Geelen (sge) 57aaca7555 [FIX] web_editor: prevent inline content on blur
Avoid inlining the content of html_field during blur
to ensure we don't break edition.

Blur occurred when opening dynamic placeholder popup or media modal.

If, during those process, we inline the document content,
the Editor will lose the reference to the current caret position inside the document.
Because Elements where overridden or changed by the `toInline` function.

If the editor cannot put the caret back in the previous correct position,
it will put it back at the end of the document.
And thus inserting the dynamicPlaceholder or new media element
at the wrong place inside the document.

task-3222474

X-original-commit: 28efe94a08d2747936ac4aa78f1d9e53545ee8b2
Part-of: odoo/odoo#124020
2023-06-07 08:59:09 +02:00
Sébastien Geelen (sge) 044f1b2db0 [FIX] web_editor: ensure t-out are inline
Force the sanitization after a dynamic placeholder is inserted.
By default the `<t>` tags are styled as block element,
except if they have the `data-oe-t-inline` attribute set.
The sanitization process ensure the `<t>` tags have this attribute.

With this change the new `<t t-out >` tags added as dynamic placeholder visual
are properly styled as inline elements.

task-3222474

X-original-commit: 08558502ea0726a97c80aae7d1e2084b2bf3952a
Part-of: odoo/odoo#124020
2023-06-07 08:59:09 +02:00
Sébastien Geelen (sge) 623729832f [FIX] web_editor: fix inline html_field
Revert changes made in #101768.

Wrong assumption were made in #101768
regarding inline conversion of html field.
I though Inline HTML field always had two Field,
one for the raw content and one for the inlined content.

This is not correct.

Some only have one (i.e. email templates).
They override the raw version and save the inline version directly.
In those case the inlining was not saved and was always reverted before saving.
This error is corrected here.

task-3222474

X-original-commit: 578600c506fab1461863decdaecaa414f6530eab
Part-of: odoo/odoo#124020
2023-06-07 08:59:08 +02:00
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