Commit Graph
4278 Commits
Author SHA1 Message Date
David Monjoie 11d1eff8c9 [IMP] web_editor: allow users to select font size 16
The default font size of the frontend is 16 so the `default` option
in the font size dropdown was supposed to be enough for this use case.

However, this is not true in the context of website_blog where the
default font size of blog content is not 16. This is not a problem
because if the user does not like the default blog font size then
they can change it using the font dropdown... except they have no
way to select 16 for a size and `default` doesn't mean 16 in blog.

This commit adds an explicit entry for 16 in the font size dropdown.

opw-3110711

closes odoo/odoo#113011

X-original-commit: a35679d5a30e3931216c65ff4ea896e507ba4cf1
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-18 00:23:51 +01:00
xO-Tx d1e5e4420a [FIX] web_editor: prevent editor rollback of top menu
To reproduce the issue:

- Website > Add menu items to activate the "+" dropdown.
- Edit mode > The top menu disappears.

On `_activateContenteditable()`, The `initAutoMoreMenu` > `_adapt()`
mutations (changes to move the overflowing menu items to a "+" dropdown)
are recorded and rollbacked by the editor, leading to reset the top menu
to the step before removing the `.o_menu_loading` class.

Recording the `initAutoMoreMenu` mutations leads to some other issues:

On edit mode (without overflowing items):

- Website > Edit mode > The editor starts (before any updates) with an
extra "history step".
- Undo > The top menu disappears.

On edit mode (with "Mega Menu" items):

- Website > Edit mode > Edit text in a "Mega Menu" item > The top menu
disappears.

The goal of this commit is to fix this behaviour using the
`renderingClasses` filter (added in [1]) to prevent the `o_menu_loading`
class from being taken into account in the `filterMutationRecords()`.

[1]: The https://github.com/odoo/odoo/commit/1c25ddb42393b136cac2a0ee0b9b7280fd803e7d

opw-3146873

closes odoo/odoo#113016

X-original-commit: 96c9ebd26aabc3f99acf5d586746b05db7cf4953
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-17 22:02:38 +01:00
Benoit Sociasandqsm-odoo 85c0f12c88 [FIX] web_editor: make empty we-select visible
When a `we-select` has no elements, it is drawn as a flat line.

This commit puts a "/" in its toggler content. This character is the
same one as the one that is displayed if the selected value is not one
of the available values.

Steps to reproduce:
- Delete all `website.snippet.filter`
- In debug mode, drop a "Dynamic Snippet" in a website page
- Select it
=> The "Filter" option was displayed as a flat line.

opw-3166634

closes odoo/odoo#112932

X-original-commit: dc6ff20386567abbabcb2d35388a3dc8995cab28
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
2023-02-17 13:06:56 +01:00
Bruno Boi db4ec2ba2f [REM] web, web_editor: remove throttle function
This function is deprecated as its behaviour is closer to "debounce".
Furthermore, it is not covered by any tests.

Only one usage has been found in the code base:
- the VideoSelector component from web_editor

This usage has been replaced by the "debounce" timing utility,
which is appropriate considering what the code tries to do.

Part-of: odoo/odoo#112913
2023-02-17 12:07:25 +01:00
Guillaume (gdi) cf1a8f34b1 [IMP] web_editor: scroll to new element of we-list
This commit improves the ListUserValueWidget to scoll to the new element
when the user adds a new element.

task-2601533

closes odoo/odoo#81241

Signed-off-by: Vray Benjamin (bvr) <bvr@odoo.com>
2023-02-17 12:07:02 +01:00
Guillaume (gdi) 0263ec8cc8 [IMP] website, website_sale, web_editor: set step on numeric inputs
Changing numeric values using the keyboard arrows did not work on some
fields. This commit solves this problem by adding the necessary
attributes to the numeric (we-)inputs.

task-2601533

Part-of: odoo/odoo#81241
2023-02-17 12:07:01 +01:00
Guillaume (gdi) e40a91cd4c [IMP] web_editor: hide arrows for all input
This commit removes the arrows that are in the numeric inputs of the
editor.

task-2601533

Part-of: odoo/odoo#81241
2023-02-17 12:07:01 +01:00
Guillaume (gdi) 9e9031a943 [IMP] web_editor, website: improve the behavior of we-list
This commit improves the handling of events on the editor's lists. The
fields that make up the list can trigger a preview and it is possible to
switch from one field to another using the keyboard. Note that the
social media we-list must render at each blur of one of its inputs, so
this we-list does not allow to switch from one input to another with the
keyboard.

As the we-list events changed, the social media block tests had to be
slightly modified to take these changes into account.

task-2601533

Part-of: odoo/odoo#81241
2023-02-17 12:07:00 +01:00
Nicolas Bayet de4bb25464 [FIX] web_editor: check if no selection in _handleSelectionInTable
Before this commit, if there were no selection in
`_handleSelectionInTable` because the document was removed (in case the
document was in a removed iframe), the method would crash.

task-3052658

closes odoo/odoo#112908

X-original-commit: 8e23a4191730d5512c9de81c23f8e4e88e99ddb1
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-16 17:57:20 +01:00
Nicolas Bayet 196a837c57 [FIX] web_editor: commit changes when using the sidebar
Before this commit, some operation (eg. move node, duplicate or remove a
snippet from the snippetMenu) in the snippetMenu sidebar did not
trigger the mass mailing commit changes and therefore if no selection
was made in the document followed by a blur was made, no changes could
be recorded and saved by the owl form component.

task-3052658

X-original-commit: 8bd8db97ee0d7774e5aa0495b9a5cc7d695fca67
Part-of: odoo/odoo#112908
2023-02-16 17:57:20 +01:00
Nicolas Bayet 1748d38e8a [FIX] web_editor: fix iframe tree structure
When the debug assets option is not activated, the assets are rendered
with a space being trimmed from a string notation using backtick.
This fix, uses the single quote notation to avoid this issue in
`wysiwyg_iframe`. Without that fix, the structure of the dom is wrong
and causes css rules to not be applied.

task-3100202

X-original-commit: c54fcf21aecccac20b2c1d781132ed67df6c20a7
Part-of: odoo/odoo#112908
2023-02-16 17:57:19 +01:00
Nicolas Bayet 172a40709c [FIX] web_editor,mass_mailing: prevent sidebar glitch
Before this commit, the sidebar visibility was toggled with a css
transition, each time a change was made in the html_field.
Additionally, the transition was not working properly when opening
a mailing. Because this transition was made for website and this code
is no longer being used in website and is not usefull for mass mailing
we can remove it.

task-3100202

X-original-commit: 21056444562e530fb811095b4805345709295ca3
Part-of: odoo/odoo#112908
2023-02-16 17:57:19 +01:00
Nicolas Bayet 0c9f5147b3 [FIX] web_editor: make to_inline with html2canvas fast
In mass_mailing, when there is an element with a background image, the
method html2canvas is used.
On a Mac M1, rendering that snippet takes ±700ms per element that goes
into html2canvas.
The reason is that html2canvas clone all the document of the node that
is passed to html2canvas. This is the document of the mass mailing
iframe (for instance including the snippet menu).

As a rendering is called at each input change in the editable
(eg. editor blur, adding a snipet, ...), the main thread will be blocked
more than 700ms each time the input change.

The reason it is slow is because html2canvas is cloning the whole
document, in order to properly get the style of the targeted element.
Because the element style is already inlined by the to_inline, this is
not necessary to clone the whole document.

In order to make html2canvas instantaneous without changing the lib
source code, the solution is to render from another iframe that
contain only the element to render.

task-3100165

X-original-commit: 8ea22ea04e4d7108ba6920fed3e1898df28a53d8
Part-of: odoo/odoo#112908
2023-02-16 17:57:19 +01:00
Michael (mcm) 9f4622492c [REF] *: register field descriptors instead of components
Before this commit, the field's description was stored on the
component and this component was then registered.

Now, an object describing the field is used on registration the same way
as it is done for views since https://github.com/odoo/odoo/commit/b828cfc72c587d0b73fcc5459695705640437671.
This split the component's description (props, template, ...) of
the field's description (displayName, supportedTypes, ...) and makes
it clearer.

closes odoo/odoo#112498

Task: 3171520
Related: odoo/enterprise#37105
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-02-16 14:13:32 +01:00
Benoit Socias fb9efde4f3 [FIX] *: replace werkzeug's Response by odoo's Response
*: base, http_routing, mass_mailing, web, web_editor, website_slides

In some situations `werkzeug.wrappers.Response` are used instead of
`odoo.http.Reponse` that extends it.
This is a problem because since [1] the calls to `set_cookie` expect it
to accept the `cookie_type` parameter, which is not the case in the base
werkzeug implementation.

This commit replaces the `werkzeug.wrappers.Response` by
`odoo.http.Response`.

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

closes odoo/odoo#112827

X-original-commit: 28da08292b7028575e628c5ad846fc05d30498f2
Signed-off-by: Julien Castiaux (juc) <juc@odoo.com>
2023-02-16 09:01:07 +01:00
Nicolas Bayet 34c5de8e72 [REF] web_editor: prevent concurrency issue in resetEditor
The PR #105579 introduce the call of `setupCollaboration` in
`resetEditor` but did not remove the instructions in `resetEditor`
that will be called in `setupCollaboration`.

`this._getNewPtp` should be called by `setupCollaboration` as it is
called after an asynchronous call.

Additionally, `this._peerToPeerLoading` has to be awaited to prevent
concurrency issues.

closes odoo/odoo#112253

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-15 12:33:40 +01:00
Guillaume (gdi) 3897dfcf0f [FIX] web_editor: fix inputs usable with the arrows and without preview
The user can use arrows up/down to change the value of an input in the
editor (inputs that handle numerical values). Unfortunately if this
input does not trigger a preview (data-no-preview="true"), the
modifications made by the user with arrow up/down are not saved. This
commit solves this problem by notifying that the value has changed at
the input blur (or on ENTER key press) if arrow up/down has been used.

Details:
Since we use text inputs in the editor, (even to manage numerical value)
the management of arrow up/down is done manually, so Javascript does not
consider the value of the input has changed and therefore does not
trigger the change event. Another solution would have been to say that
when we know that the input is going to manage a numeric value, we put
the type="number" on it but in this case, the change event is triggered
at each arrow up/down which breaks the fact that some inputs do not want
to have a preview.

Steps to reproduce the problem:
- Drop the Products block in a page
- Use arrow up/down to change the value of the Slider Speed input
- Save and Edit again
=> The change made with arrow up/down has not been saved.

task-2765868

closes odoo/odoo#112145

X-original-commit: 2e668f9c33e80ad9a78d5c0648d595a698936c81
Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
2023-02-15 09:11:24 +01:00
Antoine Guenet b64e862f40 [FIX] web_editor: include selected td's descendants in getTraversedNodes
When a td has the `o_selected_td` class, it should be included in the
traversed/selected nodes, along with all its descendants. A syntax error
made it so that the descendants weren't in fact included.

closes odoo/odoo#112669

X-original-commit: 9f9279babbd98c343f51028fc719d7d9f1b2f887
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-14 17:09:56 +01:00
Antoine Guenet b03bb44048 [FIX] web_editor: properly change tag of blocks in table cells
When selecting across table cells and changing block style, we applied
the block style to the traversed blocks which included the ones we want
to change but also their parent cell (`<td>`). This resulted in invalid
nested blocks like `<td><p><h1>...</h1></p></td>`.

task-3177014

X-original-commit: a6aff77af82066630f9d3b887beed288d2bdafaa
Part-of: odoo/odoo#112669
2023-02-14 17:09:56 +01:00
Romain Derie 2461cbddb5 [IMP] web_editor: show drag & drop tooltip helper faster
Before this commit, if the user mousedown a snippet, it would start a
timer of 1500 ms and a the end of the timer, it would show a tooltip to
help the user indicating him that he should drag & drop and not click.
The drag & drop code would (sort of) stop that timer if a drag was
detected, to not show the tooltip if the user is correctly drag &
dropping.

But it feels weird, as when you fail to realize you should drag & drop
but click instead, you only have the hint 1.5s later.
Some internal people would actually use triple click on snippet when
trying to show this tooltip, because it's probably not easy to figure
exactly what the trigger is.

The change is then made to show the tooltip directly on mouseup.
If the drag & drop code did not indicate that a drag happened, we can
safely assume it was a simple click and not a drag.

closes odoo/odoo#112666

X-original-commit: 00becd38ac5f43e2586b258d01c7af2825f75ddc
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-02-14 17:09:50 +01:00
Antoine Guenet a8581ddca6 [FIX] web_editor: fix triple click on block followed by empty block
Triple click correction failed whenever the triple-click-selected block
was followed by an empty block. The reason is that `getDeepestPosition`
prevents the selection from being placed within a line break (`<br>`)
and therefore returns the block itself (`<p>[]<br></p>` will be
expressed as `(p, 0)`), so the heuristic to determine if triple click
correction in needed in `getDeepRange` would fail as it assumed the
`end` node was a leaf where it wasn't. This fixes the issue by applying
the heurstic to the first leaf of the `end` node instead, and making the
correction for there as well.

task-3180922

closes odoo/odoo#112637

X-original-commit: 81653c320a1e431e4b9ae831bf0b8522588368e6
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-14 13:14:04 +01:00
Rodopho Cammarosano de Lima (rcdl) 0a77f3279f [FIX] web_editor: fix unbreakable rollback upon column number change
When wrapping the contents of a paragraph into a newly created div, the
nodes' ouid (unbreakable id) must be reset in order to prevent a
"unbreakable" rollback.

This commit makes such property reset and fixes errors related to changing
the number of columns of a text snippet.

task-3165895
opw-3137951

closes odoo/odoo#112521

X-original-commit: e33b802b05b41df20e13ebc44bc5b78edae50bb8
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-14 12:13:49 +01:00
Rodopho Cammarosano de Lima (rcdl) f60e8faaca [FIX] web_editor: fix issues caused by textContent
Issue #1: reading textContent

When reading the textContent property of an element, its does not take into
account line breaks introduced by <br> and block elements, whilst innerHtml
does.

This commit solves the issue of updating a link's href to a non-sense url
upon label change. Before this commit, "www.abc.com <br> www.xyz.com" was
being incorrectely parsed as "www.abc.comwww.xyz.com".

Issue #2: setting textContent

When setting the textContent property of an element, all of its child nodes are
removed and replaced by a single text node. While this is fine when the
element contains a single text node, it might not be the desired result when
the element contains other children.

This commit solves the issue obtained when pasting html such as
"link.com<br>link.be" inside an empty inline element such as STRONG or A,
in which cleanForSave was changing its content (removing the line-break) due
to misuse of textContent, when the intended effected was simply removing
ZeroWidthSpace characters. A safer alternative for removing ZeroWidthSpace is
thus provided.

task-3081254

closes odoo/odoo#112579

X-original-commit: 9ff7c2ccff5f959f2a1cd7334c42b7bf0134f5d2
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-14 10:02:24 +01:00
Antoine Guenet 056af045be [FIX] web_editor: properly copy tables
A syntax error sometimes caused a traceback when copying a table.

opw-3166159

closes odoo/odoo#112562

X-original-commit: 7fdeced319902e26ce33b5ffd0dd08957c484eb4
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-13 17:26:16 +01:00
Florian Charlier be9f264011 [IMP] web_editor: add filter-in to m2o/m2m snippet widget
Adds basic support to filter possible m2x values based on another
record. This is necessary for the website_appointment snippet
introduced within this bundle (see related ENT PR).

An important need implemented here is to not store a list of valid IDs
in the DOM but fetch them based on data stored by a different widget.

Use case covered:
Model A has a Many2Many relationship with Model B via a `model_b_ids`
field.

A first widget (Wa) on a snippet's options allows to select a record of
Model A. A second widget (Wb) allows to select records of Model B.

```xml
<!--Widget A-->
<we-many2many data-model="model.a" data-m2o-field="name"
 data-fakem2m="true".../>

<!--Widget B-->
<we-many2many data-model="model.a" data-m2o-field="model_b_ids"
 data-filter-in="true" .../>
```

Before this commit, the second widget would only be able to show
all records of Model B linked to any Model A record and matching a
static domain provided as attribute, which is still supported.

This commit allows, after having selected `record_a` in the first
widget, to only populate the second widget with the records of
Model B that are in `record_a.model_b_ids`.

Implementing this is done by
 * Adding `data-filter-in` to Wb's xml attributes (as above)
 * Calling `Wb.setFilterInDomainIds()` when another record is selected
   in Wa.

Task-2574175
odoo/odoo#90748
See odoo/enterprise#23750

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-02-10 10:13:00 +01:00
Guillaume (gdi) e745a7168a [FIX] web_editor: prevent having wrong connectors when an icon change
Steps to reproduce the bug:
- Drop a block steps on a page
- Change one of the icons
- Change the color of the icon

=> The connectors are not correct anymore.

This is due to [this commit] changing the tag `<i class="fa...` to a
`<span class="fa...` when the user replaces an icon. The steps options
assume that `<i/>` tags will remain `<i/>` tags (as it was before
[this commit]). We should not change the tagName when changing the icon
of an `<i/>` tag. This is likely to break (s)css, options, public
widgets, ... This commit fixes this bug by ensuring that `<i/>` tags do
not become `<span>` tags when replacing the icon. Moreover it allows not
to recreate an editor when you change the icon.

[this commit]: https://github.com/odoo/odoo/commit/7fd0698cf765a79959566b51e33cb76bff83d344

task-3068834
opw-3123850

closes odoo/odoo#112252

X-original-commit: 93eeaf538c24e7b7ee304c4323cc27bf786f261b
Signed-off-by: Outagant Mehdi (mou) <mou@odoo.com>
2023-02-09 18:07:21 +01:00
Nicolas Bayet 9731e9be6d [FIX] web_editor,project,note: ensure same history
This commit add a mechanism to ensure that someone could never save
changes from an history that diverge (in case there is a partition in
the RTC network or a person A was disconnected while another person B
saved changes that were not transmitted to person A).

task-3002163

closes odoo/odoo#112099

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-09 10:49:00 +01:00
Nicolas Bayet 3573fcf3f1 [REM] web_editor: remove useless _shouldDelayBlur fix
The fix that introduced `this._shouldDelayBlur = true` in
`openMediaDialog` was wrong as it was fixing a symptom rather than
the source of the problem. Later fix probably fixed the source of the
problem as the problem is not reproducible at the time of this commit.
If the symptom comes back, it ought to be fixed at it's source.

closes odoo/odoo#112245

X-original-commit: 0dd9da029d58652123ea71085dbb3a1a1e93e77d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-09 09:47:14 +01:00
Nicolas Bayet 6e82d8ee08 [FIX] web_editor: set recovery connection to 3s
When trying to recover peer to peer connection, the timeout of 500ms or
1000ms might be too short and 15000ms in unnecessary too long.

If the timeout is too short, it could remove the connection before the
peer to peer had the time to reconnect to it. When we call
`_recoverConnection` on `disconnect` in `oniceconnectionstatechange`
or `onconnectionstatechange`, the signal `disconnect` does not
necessarily mean that it will remain disconnected. Doing nothing could
be enough to reconnect.
(see: https://w3c.github.io/webrtc-pc/#dom-rtcicetransportstate-disconnected)

closes odoo/odoo#112182

X-original-commit: 3647374c63fcd4bccf501e49a2af6a707fedd737
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-08 13:28:13 +01:00
Nicolas Bayet fb7f8732a4 [FIX] web_editor: properly add iceCandidateBuffer
Before this commit, the iceCandidateBuffer was emptied before finishing
the loop. This is wrong as we must add all candidates from the buffer.

X-original-commit: 520a880574d908a8e28fa258a1e006d1b8504221
Part-of: odoo/odoo#112182
2023-02-08 13:28:13 +01:00
Antoine Guenet dd064ab9aa [FIX] web_editor: force custom style in ui on non-custom link with style
This reverts commit [1] so as to avoid updating the DOM in two separate
places of the code for link edition. Said commit intended to prevent the
removal of custom styles on a button on which styles were applied
(erroneously) without applying a custom button class. This fixes that
issue by adapting the UI to show the button is custom if there are
custom styles applied. This way, if any change is applied, when
modifying the DOM, the custom class will be applied as well. This is the
order in which such corrections are usually applied with the snippets
bar.

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

closes odoo/odoo#112152

X-original-commit: 1b65244a1ae7ed37d7bc1faef2225ed982c94320
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-02-08 13:28:05 +01:00
Aaron Bohy 49297bc7bb [REM] *: remove legacy basic views + some fields/widgets
This commit removes the legacy implementation of the form, kanban
and list views. It also removes the legacy view widget registry,
and all legacy widgets it contained. The legacy field registry
couldn't be removed yet as some fields are still used (e.g. in
client actions: FieldMany2One, FieldMany2ManyTags...), and
sometimes accessed from that registry (e.g. uom service). More
clean up will come later. Note that all tests using legacy views
have thus been removed, even though the tested feature might still
remain (e.g. FieldMany2One tests have been removed, but that field
is still there). However, those features are deprecated and
unlikely to evolve. They should be removed in the next saas, or the
one after.

Finally, this commit also removes the legacy view dialogs.

Task 3168640

Part-of: odoo/odoo#111809
2023-02-08 13:27:58 +01:00
Nicolas Bayet 82d9e8bf9f [FIX] web_editor: write with string in update_checklist
Before this commit, when the user tried to update a checklist, there
was a traceback in `handle_history_divergence` because the `value` is a
byte sequence instead of a string.

opw-3158660
task-3165844

closes odoo/odoo#112112

X-original-commit: e3900dfe51cb294ad139395cb402c9f13dd067c5
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-07 16:38:42 +01:00
Guillaume (gdi) 09b720eff1 [IMP] web_editor, website: initialize the editor's tooltips
The editor offers bootstrap tooltips, but these were not all initialized
and therefore appeared as standard HTML tooltips. This commit fixes that
by initializing all the tooltips so that they all have the same style.

Details:
- The bootstrap tooltips are now available in translate mode.
- With bootstrap 5, only one bootstrap component can be initialized on a
  HTML element. This is why the tooltips are now initialized on the
  first child when there is another bootstrap component.
- Some tests have been adapted.

task-2777738

closes odoo/odoo#85666

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-02-07 16:38:23 +01:00
David Monjoie d2d1c01971 [FIX] web_editor: remove double click popup from links
It is wrong in 15.0 since double clicking on the link does nothing
anymore, as edition of the link is done via the popover. Having both
tooltips at the same time created a race condition that ended up
inserting the second tooltip in the DOM, where it obviously couldn't
function properly anymore.

opw-3147108

closes odoo/odoo#112035

X-original-commit: 35cc6049a8bcc3c80cb4eb2468f85d09734814b8
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-07 08:40:57 +01:00
Antoine Guenet 4ce0664f6a [FIX] web_editor: prevent merging table with other element on paste
When we paste content in the editor, we merge the first and/or the last
element(s) from the clipboard with the element(s) before/after the
selection (eg, pasting `<p>b</p>` at `<p>a[]c</p>` (where `[]` is the
selection) should result in `<p>ab[]c</p>` rather than
`<p>a</p><p>b</p><p>c</p>`). If the element we try to merge is a table
though, we may end up pasting a `<tbody>` without its parent table,
which leads to unexpected results. In any case we don't ever want to
merge a table with another element, so we prevent that.

Steps to reproduce the issue (in the `note` module):
* Type "a" then hit the ENTER key.
* Add a table (using the /table command) and write in each of its cells.
* Make a selection that starts before "a", and ends after the last
  character of the last cell of the table.
* Copy the selection.
* Paste the selection in the paragraph after the table.
What you see before this commit is the text you copied, without the
table.

Everything above is also true of lists (just replace the table with a
list in the text above) and these cases are fixed here in the same way.

task-3165836

closes odoo/odoo#112042

X-original-commit: 07604f2505d9cc32ebb3cf3f09192472f0bf30c4
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2023-02-07 07:43:50 +01:00
Géry Debongnie fd5b2e6a20 [IMP] web_editor: only load ice server configuration once
Before this commit, the web editor loaded the configuration for ice
servers each time it was created.  It is useless to do it more than
once, so this commit simply keep the initial value around.

Part-of: odoo/odoo#111571
2023-02-06 12:09:51 +01:00
Rodopho Cammarosano de Lima (rcdl) 4e4ed9b098 [FIX] web_editor: save a historyStep upon cut
Before this commit, _onClipboardCut removed the selected text but did not
register it as a history step. Other than not storing history properly,
this caused unexpected behavior when followed by an action that leads to a
historyRollback on the current step, such as those in _onInput.

task-3142995

closes odoo/odoo#111927

X-original-commit: 451f1a2641b5b85ea75d9f1e8a8d1b528de031b6
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-06 10:18:56 +01:00
Rodopho Cammarosano de Lima (rcdl) 841d9eaf40 [REM] web_editor: remove unused method _isSelectionOnlyZws
The forementioned method is not called anywhere in the code.

closes odoo/odoo#111131

Related: odoo/enterprise#36356
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-03 18:43:45 +01:00
Rodopho Cammarosano de Lima (rcdl) 82dfb82b21 [REM] web_editor: remove table-related code from toolbar
The UI elements related to table creation and edition are no longer
present in the toolbar, as the Wysiwyg and SnippetEditor instances
remove the `#table` div section from toolbar.
Furthermore, the OdooEditor instantiates a TablePicker instance to be
appended to the tablepicker dropdown menu under the (inexistant) #table div
in the toolbar.

This commit removes dead code related to table creation/edition via the
toolbar.

task-3074598

Part-of: odoo/odoo#111131
2023-02-03 18:43:44 +01:00
shsa-odoo 7a4a836088 [FIX] web_editor: updating mobile view layout
Before this commit:

On mobile view the toolbar icon gets hidden, which it should not.

After this commit:

Now the toolbar items are flexed and wrapped.

Task-2752096

closes odoo/odoo#111876

X-original-commit: d3e6797ff1bd82618601d233f757b616cb10b87e
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-03 16:32:43 +01:00
Antoine Guenet 08645e8e2e [FIX] web_editor: ensure proper live adjacent nested lists merging
Sometimes, two similar adjacent elements must be merged together (eg,
two `<span>` elements with the same style, or two lists of the same
type).  This is done by the sanitizer, which is called on the common
ancestor of the mutated nodes after each change, and on the whole
editable when the document is saved. In the case of nested lists, this
can cause a visible discrepancy between what is saved and what is
edited:

1. In a list, say the first item contains a nested bullet list, and the
   second item contains a nested numbered list:
   `<li><ul>...</ul><li><ol>...</ol></li>`
2. Now we transform the numbered list into a bullet list:
   `<li><ul>...</ul><li><ul>...</ul></li>`
3. The mutation happened on the second `<li>` element so we call the
   sanitizer on it, and it doesn't have enough context information to
   merge the two `<li>` elements, so it leaves them as is.
4. The user saves the document, and the sanitizer is called on the
    whole editable, which has enough context information to merge the
    two `<li>` elements, so it does so, and the saved document is
    different from what the user sees. It is now `<li><ul>...</ul></li>`
    as it should have been immediately after the mutation.

We solve this in a straight-forward, ad-hoc way since we currently know
of no other case where this is needed, by calling the sanitizer on the
parent of the first ancestor nested list of the mutated nodes, if any.

closes odoo/odoo#111871

X-original-commit: 50b7b41a4573fdce8891fac5d6aa1d08c557d455
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-03 16:32:40 +01:00
Antoine Guenet 4a57f9c54f [FIX] web_editor: prevent infinite loop on using checkboxes
In order to be able to check checklist items and color stars even when
in readonly mode, we need to add unique ids to the checkboxes and stars.
Since these ids were random and in order to ensure uniqueness after DOM
manipulations, we updated all these ids every time the document was
sanitized. Since the `sanitize` function is called every time the
`cleanForSave` method is called, and since `wysiwyg`'s `getValue` method
calls `cleanForSave`, this meant that the ids were modified every time
we were getting the value of the wysiwyg. This meant that every call to
`getValue` returned a different value, so the editable was always marked
as dirty, sometimes causing an infinite loop (see steps below).

This commit makes the IDs iterative rather than random, so they are
predictable (practical for testing), and ensures that the ids are only
updated when necessary, so that upon two consecutive calls to the
`sanitize` function, only the first call may change the HTML.

STEPS:
* create a sale order
* add checkboxes to Terms & Conditions fields
* edit a sale order line
* click outside the edited sale order line

opw-3116430

X-original-commit: 86ff07d9c201668e372377f9ac41d3801aa223e9
Part-of: odoo/odoo#111871
2023-02-03 16:32:40 +01:00
Chong Wang (cwg) 43b00d6b1a [FIX] web: reload data when translation changes
before this commit:
model translation:
when the user changes the translation for the current language in the
translation dialog, the value in the form view is also updated and marked
modified.
But if the user wants to invalidate the translation and set the translation to
`false`, the form view value is also updated to `false`, if the user saves by
accident, all translations are lost.

model_terms translation:
when translations are modified in the translation dialog, the field value will
not be changed

after this commit:
form view data will be reloaded after translations changed in the translation
dialog

closes odoo/odoo#111869

X-original-commit: 9aab8347a1a4cc74050dd2e5035cba838b93863c
Signed-off-by: Wang Chong (cwg) <cwg@odoo.com>
2023-02-03 16:32:34 +01:00
Antoine Guenet ef7d547c3c [FIX] web_editor: properly convert nested lists
Nested lists should not have a bullet point in front of them, but the
current conversion of HTML for emails made them reappear.

opw-3136324
task-3166100

closes odoo/odoo#111822

X-original-commit: 11f44de490d7e9c59b76aaade1d31b3041c9fb3b
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-03 12:55:48 +01:00
Jorge Pinna Puissant 1aa9b41800 [FIX] web_editor: show status indicator buttons on editing html field
Before this commit, when editing a form view, when editing a html field,
the status indicator buttons (the save and discard buttons) didn't show
up until a click outside the html field was done (change event).

Now, the status indicator buttons shown as soon as the input field is
edited (input event).

This is was already done for the other fields in [1].

[1] : 0b2d82282d7f656a9177158fd6117cc2e7a1b4d4

task-id 3147130

closes odoo/odoo#111663

X-original-commit: f56e3bca2456f04616982a9a0e77b8d4c5a0abff
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-02-03 11:45:35 +01:00
Nicolas Bayet 071ca078b5 [FIX] web_editor: retry peer to peer connection with exponential backoff
When there is a problem in the peer to peer network where we try to
recover a connection, retry with exponential backoff instead of
potentially spamming the server indefinitely.

task-3164011

closes odoo/odoo#111802

X-original-commit: fd97295c9cf8b1b0c800f407bb5f538f78cc2665
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-03 10:36:01 +01:00
Antoine Guenet 5cb4175e9c [FIX] web_editor: properly convert image dimensions
Before this commit, the image dimensions were not properly converted
when converting HTML for e-mails.

opw-3144322

closes odoo/odoo#111793

X-original-commit: 1d5c8c9adf18aded19d945cd9b0f72eb9b8bbc72
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-03 10:35:58 +01:00
Antoine Guenet ded7bb0895 [FIX] web_editor: limit custom table selection to editable area bounds
The custom table selection was not limited to the editable area bounds,
which means we could end up styling a table as selected, which did not
belong to the editor's scope. This sometimes happened when Firefox
triggered a selectionchange event during the instantiation of the editor
and the selection happened to be in a table outside the editor.

opw-3150654
task-3166078

closes odoo/odoo#111779

X-original-commit: d51aab54775ed541d7955cee032aceed143d3a08
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-03 10:35:56 +01:00
Antoine Guenet 8a6337f15b [FIX] web_editor: move rules cache from document to wysiwyg instance
The CSS rules cache for convert_inline was stored on the edited
document, which is problematic since OWL destroys the document where we
used to just hide it (eg, when switching tabs in the form view).

X-original-commit: d432ebbddae7192eca7215a8489abb3ad91a45f2
Part-of: odoo/odoo#111778
2023-02-03 10:35:53 +01:00