Commit Graph
4687 Commits
Author SHA1 Message Date
Lucas Perais e474bd5f4b [FIX] web_editor: factorize open Cropper from toolbar
Before this commit, the cropper tool was opened by a closure that spawned the Cropper
tool aside from the editable document.

This was anoying as the editable document can be in an iframe, hence the Cropper would have
been virtually unusable.

This commit factorizes the code in a method to allow overrides. Which is done in
web_studio:ReportEditorWysiwyg.

opw-3484065

closes odoo/odoo#150904

Related: odoo/enterprise#55049
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2024-01-24 23:07:07 +00:00
Lucas Perais 645216248c [FIX] web_editor: loading an image in an srcdoc iframe
To load images in an iframe, the web_editor code expected the iframe to have an src
attribute and built an URL for the image on the basis of that url.

With the srcdoc attribute, there is no need for an src, making the code crash.

After this commit, if an iframe only has srcdoc, we build images' url on the basis of
the main window.

opw-3484065

Part-of: odoo/odoo#150904
2024-01-24 23:07:07 +00:00
Lucas Perais dd16bacc97 [FIX] web_editor: image processing allows already loaded images.
Before this commit, the image processing code always added a listener on the load event
of an image before opening the Cropper tool.
If the image was already loaded, the promise did not resolve at all.

After this commit, an image can be already loaded without any Promise not to be resolved.

Part-of: odoo/odoo#150904
2024-01-24 23:07:07 +00:00
visp-odoo 0818a8497f [FIX] web_editor: sometimes bullet list is not working properly
Before this commit:

Sometimes applying bulletlist does not produce the expected bullet list
formatting .This issue arises when the selection is on an emptyTextNode(""), and
the traversal of nodes using getTraverseNodes results in the same
emptyTextNode(""). In the toggleList function, we typically remove the
emptyTextNode(""), leaving no appropriate node for creating a bullet list.

After this commit:

Now it will create bullet list because we move the selection to its parent when
it is on an emptyTextNode(""), similar to what we have done with the "BR" element.

task-3547574

closes odoo/odoo#150854

X-original-commit: d5380742b05c64ced7eee92fcf520f208e33819e
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
2024-01-24 14:02:19 +00:00
Julien (jula) 25fe8cfbae [FIX] web_editor: fix crash if non-element node in card children
__Current behavior before commit:__
If `child` is not an `Element` (like a Text or a Comment node), the call
to `querySelectorAll` at the following line will crash.

__Description of the fix:__
End the current loop iteration if `child` is not an `Element` to avoid
calling `querySelectorAll` on it.

__Steps to reproduce the issue on runbot:__
In 15.0:
- Open Email Marketing > Mailings > Create > Second template
- Drag and drop a `Comparisons` block
- Display source code
- Write some text under the `<div class="card ...">`
- Save --> Traceback

In 16.0+:
- Open Email Marketing > Mailings > New > `Start From Scratch`
- Drag and drop an `Event` block
- Replace one of the image (a comment node will be added [here][1])
- Save --> Traceback

opw-3682469
opw-3689181

[1]: https://github.com/odoo/odoo/blob/df1b43a6de5ad15a8fee3713de7d8ec926c61f12/addons/web_editor/static/src/js/backend/convert_inline.js#L715

closes odoo/odoo#150752

X-original-commit: 3d1c95d9d143df35320e97abf898f673f4bb1a68
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
Signed-off-by: Julien Launois (jula) <jula@odoo.com>
2024-01-24 12:30:08 +00:00
Benoit Socias 9bd063cd23 [FIX] web_editor: apply spacing after palette only when on same row
Since [1] a margin is applied when another `o_we_user_value_widget`
follows a color palette. Unfortunately this is also applied when the two
elements are not on the same row. Because of this the "Slideout Effect"
option below the "Colors" option of "Footer" looks like it is indented
while it is unrelated to the color selection.

This commit restricts that margin to elements that belong to the a
`we-row`.

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

task-3696870

closes odoo/odoo#150701

X-original-commit: 50c0a5479a11fef0b03bf319283817a94a32cea4
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2024-01-24 09:12:44 +00:00
Jinjiu LiuandGoaman bc440ff045 [FIX] web_editor: blinky colorpicker when applyColor on removed fonts
Reproduction:

1. in Note, type ` abcd ` in an empty note
2. color the background of all the text, bold `abcd`
3. select from the end till the letter `b`, try to change the color,
traceback pops up

Fix: The main reason is we remove element in `splitElement`/
`splitAroundUntil`. In this special case, there are two selected nodes
which returns the same font element. The first font element will be
removed and replaced first. Because the first font element doesn’t exist
anymore, when recovering selection, the second element considered as
collapsed and the recovered selection is a caret. Thus the color picker
is gone after applying the color (preview)

The fix is then, we always make sure that the font we have is still
connected to the page (exist in the page), otherwise it’s problematic to
apply color to a non-existing element and recover cursor from it. If
there is font element(s) that is not connected, we simply get the fonts
again, because new font element is created for the second node, it won’t
split (remove) the first node’s font element again

Task-3476494

closes odoo/odoo#150500

X-original-commit: 06a8b930176093e2c5a853b78431316af90f3550
Signed-off-by: Nicolas Bayet (nby) <nby@odoo.com>
Signed-off-by: Jinjiu Liu (jili) <jili@odoo.com>
Co-authored-by: Goaman <nby@odoo.com>
2024-01-23 22:51:57 +00:00
visp-odoo 47ce4a3623 [FIX] web_editor: wrong time in history of changes
Before this commit:

When a user edits an article and selects the restore button to revert to a
previous version, the displayed time is incorrect because it shows universal
time instead of the user's timezone.

After this commit:

When a user edits an article and utilizes the restore button to revert to a
previous version, the timestamp will now reflect the time in the user's current
timezone.

task-3641579

closes odoo/odoo#149177

Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
2024-01-23 19:49:34 +00:00
Louis (loco) be782ddde5 [FIX] web_editor, *: correctly display the hierarchy between elements
*website

Steps to reproduce:
- Drop a "Text-Image" snippet on the website.
- Click on a column and hide it on desktop.
- Click on the parent snippet and hide it on desktop.

-> The column is not a child of the parent in the invisible entry.

Since [1], invisible snippets are shown hierarchically in order to
better visualize the "parent-children" relation that could exist between
them. To do so, [1] based its logic on the `.o_snippet_invisible` to
find the invisible elements. However, since [2], a distinction has been
made between elements that are hidden only on desktop, only on mobile or
on both depending on some conditions. The goal of this commit is to take
the new `o_snippet_mobile_invisible` and `o_snippet_desktop_invisible`
classes into account at the creation of the invisible entry.

[1]: https://github.com/odoo/odoo/commit/922d3e63b597b1ef7fbbb5ebb4641a3ad8bdf4ed
[2]: https://github.com/odoo/odoo/commit/3103e0553011b5c1f4078972d7a88fa3fd4068b2

task-3679823

closes odoo/odoo#150512

X-original-commit: c8f247ee5fa178f012b2852cba3d0e9322a2c3a6
Signed-off-by: Robin Lejeune (role) <role@odoo.com>
2024-01-23 16:01:50 +00:00
shsa-odoo 59e252c715 [FIX] web_editor: font styles shows active while selecting cells
Before this commit:

-Font styles shows active while selecting cells.

After this commit:

-Font styles should not be active by default.

task-3547652

closes odoo/odoo#150443

X-original-commit: d026f4d7160ec00b6cb27b4cf5b34afc9dbfda13
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-23 16:01:42 +00:00
visp-odoo 2bb2349e49 [FIX] web_editor: can't get out of inline code block
Before this commit:

If we entered text within a inline-code block and pressed the backspace key,the
zero-width space (zws) at the end of the inline-code block would be deleted.
Consequently, there was no way to exit the inline-code block.

After this commit:

Users can now navigate out of the inline-code block by using the right or left
arrow keys when inside an inline-code block.

task-3613340

closes odoo/odoo#150453

X-original-commit: 31c73e9dd53fa0f7379d87e9c9970b2788e454cd
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-23 09:47:22 +00:00
Nicolas Bayet 119fa9f974 [FIX] web_editor: fix isDirty check on html fields
The method `getValue` of the wysiwyg could have some cleaning on the
value that will always make it different from the original value.
The _isDirty method of the html field will now make the original value
be processed by the wysiwyg `getValue` to be able to compare it
with the current value.

The sanizite call in `OdooEditor.cleanForSave` had the wrong root. As
we are calling `cleanForSave` for an element that is not inside the
editable, the root cannot be `this.editable`.

task-3679122

closes odoo/odoo#148996

Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-22 19:01:00 +00:00
Mehdi Outagant (MOU) 3eb5b3410c [FIX] web_editor: fix invisible background position actions in grid mode
Steps to reproduce:

- Go to website (“Edit” mode) > Add a “Big Boxes” block.
- Switch to “Grid” mode > Select the last column n (while n > 1) and set
a background image on it.
- Try to change the background position > You cannot save or cancel the
changes since the option buttons (“Apply” & “Discard”) are invisible.

This is simply because the grid element was cloned on the background
container (`.o_overlay_background`) with its grid `z-index` style
(with `z-index` === n) which automatically hides the buttons.

The goal of this commit is to fix this behaviour by simply forcing the
`z-index` of the background element to 0.

task-3648466

closes odoo/odoo#150351

X-original-commit: 7dbb25dfeae25f27e10d4052db98c5f9d93699ff
Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
2024-01-22 15:56:57 +00:00
Adnan Saiyed 33a3fa1b0f [FIX] web_editor: tablepicker size not visible
Current behaviour before commit:

In tablepicker, number of the selected cells (rows X cols)
is not visible at the bottom.

Desired behaviour after commit:

Now, number of the selected cells is visible at the bottom of
tablepicker.

task-3662728

closes odoo/odoo#150243

X-original-commit: 72aae3599c8cd81fc00b2d46a432ee20f7c44b13
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-22 07:57:07 +00:00
Benoit Socias a28054b05c [FIX] web_editor: do not paste a link if target does not support HTML
When pasting text inside the editor, if the text looks like a URL, a
link is implicitly created.
Unfortunately, this also happens when the edited element does not
support HTML.
Because of this, when translating a page, links are created inside the
translated text which does not support HTML.

This commit solves this by pasting the plain text if the target of the
paste does not support HTML (which is the case for translations).
This commit also prevent link creation when typing a space after text
that looks like an URL in targets that do not support HTML.

In saas-16.4, `_handleAutomaticLinkInsertion` is also adapted to prevent
unwanted link creation.

Steps to reproduce for first scenario:
- Add French to your website.
- Edit your master English Home page.
- Drop a Text snippet in the Home page.
- Save the Home page.
- Switch to French.
- Translate the page.
- From an external text input, copy `http://odoo.com` in your clipboard.
- Put the cursor inside the Text snippet's text.
- Paste.

=> A link was created.

Steps to reproduce for second scenario:
- Add French to your website.
- Edit your master English Home page.
- Drop a Text snippet in the Home page.
- Save the Home page.
- Switch to French.
- Translate the page.
- Put the cursor inside the Text snippet's text.
- Type `http://odoo.com` followed by a space.

=> A link was created.

opw-3546308

closes odoo/odoo#150189

X-original-commit: de351e500559166963fd2e748229d5c1d901aa44
Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
2024-01-22 07:57:07 +00:00
visp-odoo 68d3db616c [FIX] web_editor: unable to delete table row in firefox
Before this commit:

Attempting to delete a selected table row does not result in the removal of the
row in Firefox.

After this commit:

Now deleting a selected table row results in removal of the row in FIrefox.

task-3610789

closes odoo/odoo#150167

X-original-commit: 5dd99a02fc3cce99969e696b5cf428afaa27ba78
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-22 07:57:06 +00:00
Odoo Translation Bot 95a4b6dfdc [I18N] Update translation terms from Transifex 2024-01-21 00:17:03 +01:00
Mahdi Cheikh Rouhou (macr) 2b65959cdc [FIX] web_editor: sign documents with safari 15.4+ with ios
Issue:
=====
Users with IOS can't sign with safari.

Steps to reproduce the issue:
=============================
- Install sign
- Make sure you have a template which has at least one signature sign
  item.
- Share the document and open the link with ios on safari in v 15.4+
  (browserstack) for example.
- Go to the signature sign item and use auto and click sign or sign all
- Nothing will happen.

Origin of the issue:
====================
https://github.com/niklasvh/html2canvas/issues/2864

Solution:
=========
https://github.com/niklasvh/html2canvas/issues/2864#issuecomment-1111044861

opw-3660682

closes odoo/odoo#149903

X-original-commit: f11723f406f2af95090bdd13e9acb30c89014638
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2024-01-18 15:11:59 +00:00
shsa-odoo fc27a3d452 [FIX] web_editor, website: text selection issue in font size dropdown
This commit addresses an issue where the text selection would disappear from
editor when clicking on the font size option from the toolbar.

Modifications:

- The issue of text selection disappearing when interacting with the font size
dropdown has been fixed.
- A new toolbar option, `customFontSize`, has been added. This option is
exclusively enabled for editor that have a toolbar in the same document.
The `readonly` attribute has been added to the input field to make it read-only
in our scenario, providing dropdown functionality for font size in the editor.
However, the functionality remains unchanged for the website.

task-3500827

closes odoo/odoo#142808

Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-18 12:01:00 +00:00
Rodolpho Lima 4a7b2a5051 [FIX] web_editor: URL transformation when followed by '.'
Typing a valid http URL + SPACE transforms the URL into a link (anchor
element).

[1] broke such URL transformation if the URL is followed by punctuation
characters, e.g. "somelink.com...".

After this commit, typing "somelink.com..." + SPACE transforms
"somelink.com" into a link, restoring the behavior prior to [1].

task-3602890

[1]: https://github.com/odoo/odoo/commit/4da0608f7c7cd7a6550ec40535b9562fb35c5417

closes odoo/odoo#147845

Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
2024-01-17 15:36:28 +00:00
Soukéina Bojabza 30ec9ffa2d [FIX] web_editor, website: improve grid image code
Commit [1] added the support for images with a link set on them in grid
mode.

As a follow up, this commit does the following:
- Removes the `!important` from the grid image anchor CSS rules, as they
were not really needed.
- Checks if the image has a closest `o_grid_item_image` column instead
of checking the parent in the `GridImage` options. Indeed, this class
already guarantees that the image is well a grid image; we can therefore
simplify the code.

It also removes a comment that was forgotten in commit [2].

[1]: https://github.com/odoo/odoo/commit/085d70cea571ea80c141ac6005e8bd8333bd269f
[2]: https://github.com/odoo/odoo/commit/d8c374e3e6b31bf88aa42952aadf3379936f7600

related to opw-3580128

closes odoo/odoo#149681

X-original-commit: 9244e85ebb9e1605292698fe31ad94da7709ab86
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2024-01-17 13:04:01 +00:00
Thomas Josse (thjo) 85a5d76728 [IMP] web_editor: adding dirtyness check when in collab mode
This commit adds a new event listener on the odooEditor which listens for
external history steps (if collab mode is enabled), and changes the state of
the record's dirtyness when a user receives external steps.

This way a user will see that the record has been modified when he is editing
a collaborative html field.

task-3609594

closes odoo/odoo#145928

Related: odoo/enterprise#51579
Signed-off-by: Nicolas Bayet (nby) <nby@odoo.com>
2024-01-16 09:55:20 +00:00
bve-odoo 72c1a4f96a [IMP] *: replace type where possible
do not compare types, for exact checks use `is` / `is not`,
for instance checks use `isinstance()`Flake8(E721)

Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
2023-11-07 17:09:34 +00:00
Odoo Translation Bot b81790505b [I18N] Update translation terms from Transifex 2024-01-14 00:16:26 +01:00
Louis (loco) a5df9781be [FIX] web_editor: make the system robust when old mimetype is missing
Steps to reproduce:
- Add an image on the website.
- Save.
- With the HTML editor, change the src of the image (to
"https://odoo.com/logo.png" for example) and remove the
`mimetypeBeforeConversion` data attribute of the image. Note that it is
important to change the src of the image to ensure that the system does
not add the `mimetypeBeforeConversion` data attribute back on the image.
- Enter in edit mode and click on the image.

-> Traceback of type "Cannot read properties of undefined (reading
'split')".

This traceback appears because the `_renderCustomXML()` method of
`ImageHandlerOption` relies on the presence of formats on the list
returned by the `_computeAvailableFormats()` method. Since [1], if there
is no `mimetypeBeforeConversion` data attribute on the image, one of the
format in the list is `undefined`. As `_renderCustomXML()` tries to
perform a `split()` on this format, a traceback appears.

Although the steps to reproduce the result seem tricky, it has been
decided to create a fix for this situation. Indeed, in version prior to
16.4, the equivalent steps to reproduce (in which the `mimetype` data
attribute is removed instead of the `mimetypeBeforeConversion`) do not
lead to a traceback. In those versions, if there is no mimetype on the
image, the options such as "Filter", "Width" and "Quality" are not shown
in the editor panel. The goal of this commit is to apply the same logic
for the version 16.4; hide the "Format" option if the image does not
have the `mimetypeBeforeConversion` data attribute. To do so, the
`_computeWidgetVisibility()` method has been adapted consequently. To
avoid the traceback, the `_computeAvailableFormats()` method has been
adapted. It now returns an empty list if the image does not have the
`mimetypeBeforeConversion` data attribute. As there is no `undefined`
format in the returned list of valid formats, the traceback is avoided.

[1]: https://github.com/odoo/odoo/commit/730588b802506844e6ca54df312333bfd8df1d52

task-3631487

closes odoo/odoo#148882

X-original-commit: 485a5d74198668fa2f2240b4e31a871f36225857
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2024-01-10 21:04:36 +00:00
Nicolas Bayet 5b04b4511c [FIX] web_editor: reset the collaborative selection when reset content
When the content of the editor is reset, the collaborative selection
should be reset as well. Otherwise, the selection is not reset and
the user can still see the selection of the previous content.

task-3675074

closes odoo/odoo#148826

Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
2024-01-10 21:04:32 +00:00
Nicolas Bayet 0e22763a85 [FIX] web_editor: use setValue instead of resetEdior when restore
Before this commit, when restoring a document was made, it would reset
the content of the editor without any consideration for the mechanism
that detect stale documents and without any consideration for the
collaboration.

This commit fixes 2 problems in one shot:

1) Any change made in the editor after a restore was impossible to
save. The reason is that the restored version would reset the wysiwyg
without the id `data-last-history-steps` of the version in database in
the historyIds of the odooEditor wich subsequently would trigger the
stale document detection, preventing the save.

2) The reset would be propagated to other peers in collaboration. The
reason is the same as the 1st problem, the wysiwyg would be reseted,
not informing other peers of that reset.

task-3675074

Part-of: odoo/odoo#148826
2024-01-10 21:04:31 +00:00
qsm-odoo 2487d8d278 [FIX] web_editor, *: restore change checks on link tooltip open/close
*: website

This basically reverts the parts of [1] that are the known cause of race
conditions in runbot tests (in particular, the link tools one:
`test_15_website_link_tools`). But more importantly, this just did not
make sense to stop observing changes for async period of time, at least
unless there is no alternative given the state of the related code.

Commit [1] test-hack was actually adapted with [2] which probably made
it even more unreliable and hacky.

On top of that, this commit is of course trying to restore whatever
purpose this was made for ("dirty" flag addition, the history steps
recording, etc). Although fixing those the most robust way would
probably require a deeper refactoring in master and other stable fixes.

Note: in this forward-ported version, the test is still disabled on
runbot and broken for other reasons. Those will be fixed later.

[1]: https://github.com/odoo/odoo/commit/8cab404dce3a65c0bdd635a93682ee14282a3ebb
[2]: https://github.com/odoo/odoo/commit/99b50d18e220aedf14de806f4bf1b2d35c32de35

runbot-18747

closes odoo/odoo#148728

X-original-commit: 003422a73f0b5fb5540fbf2bd95a26a6dd663530
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2024-01-10 10:28:17 +00:00
qsm-odoo f44ae60235 [FIX] web_editor, *: do not observe changes related to link edition
*: website

Commit [1] and [2] modified the link edition code in stable and tweaked
the DOM at multiple places... without disabling the main edition
mutation observer. Later, [3] tried to fix that but missed some
occurrences. Hopefully, this solves the remaining ones.

Steps to reproduce:
- Enter edit mode
- Add a "Text - Image" snippet
- Save
- Enter edit mode again
- Click on the button of the snippet (and do not do anything else)
- Click on discard
=> A popup appears to say you will lose your changes... while you did
   not make any.

[1]: https://github.com/odoo/odoo/commit/99bc9b115dbdfc29260b4ccdb55ffa2ed16dffb3
[2]: https://github.com/odoo/odoo/commit/d00fc75ffdbda1286e4fdb2793cb74fa78f6860d
[3]: https://github.com/odoo/odoo/commit/33ef91cc577d8b397a948c430b77c2e038013d2d

Related to runbot-18747

Courtesy of @SergeBayet for the test step.

X-original-commit: 2a535dfe655bc6a4f4a2d46a6b06a4b8b8029204
Part-of: odoo/odoo#148728
2024-01-10 10:28:17 +00:00
qsm-odoo 0a948a8386 [FIX] website, *: review text selection on click and dirty editable area
*: web_editor

The editor has a feature that allows to automatically select a whole
paragraph on click when that paragraph contains text by default. At the
origin, this happened at every click on the element, until its content
was replaced, by typing something while it is selected or the cursor is
inside. Placing the cursor inside was actually impossible by clicking on
the element, since this forced a selection on the whole text again.

Since [1], that behavior changed (for no apparent reason): only the
first click forces a selection on the element. This is done by removing
the marker class from the element ("o_default_snippet_text"). Also, the
code which removed that class while typing was left behind... even
though it did not work anymore due to a code typo.

This commit fixes that without changing the main behavior:
- On click, we do not remove the marker class anymore, but only force a
  selection on the text if it was not already seen before. Small change
  of behavior: not changing the text and coming back later in edit mode
  will force a selection on the text again on click.
- While typing, the code removes the marker class and thus the text will
  never have a forced selection again (fixed the code typo).

Note: we may reconsider restoring the behavior there was before [1], in
master. Automatically selecting default text that was never changed
could indeed be better, although it will require better code to allow
placing the cursor inside easily anyway.

The main purpose of this fix is to avoid a mutation of the DOM on click
(removing the marker class). Indeed, this wrongfully marked the page as
dirty.

Steps to reproduce:
- Enter edit mode
- Add a "Text - Image" snippet
- Save
- Enter edit mode again
- Click on the first paragraph of the snippet (=> it is auto-selected)
- Click on discard
=> A popup appears to say you will lose your changes... while you did
   not make any.

[1]: https://github.com/odoo/odoo/commit/912996fe902c41cafa12dcfe09713ce9857f95ab

Related to runbot-18747

X-original-commit: 3cc5bbcab641d7d436ebfbb0f160c9e0d77da142
Part-of: odoo/odoo#148728
2024-01-10 10:28:17 +00:00
qsm-odoo 32a6729dd0 [FIX] website, *: do not observe changes of drag and drop initialization
*: web_editor

Commit [1] made the multiple drag and drop feature of the editor stop
using jQuery and used our own implementation. Unfortunately, the
initialization of that implementation in the case of the "drag column
on image move" feature marked the page as dirty by mistake.

Steps to reproduce:
- Enter edit mode
- Add a "Text - Image" snippet
- Save
- Enter edit mode again
- Click on the image of the snippet (and do not do anything else)
- Click on discard
=> A popup appears to say you will lose your changes... while you did
   not make any.

[1]: https://github.com/odoo/odoo/commit/7594d71ca8610d5947e80f325ccb57abc23c2c76

Related to runbot-18747

Part-of: odoo/odoo#148728
2024-01-10 10:28:17 +00:00
qsm-odoo 6941af612a [FIX] website, *: add tests for checking no useless dirty editable area
*: web_editor

Next commits will extend the main new test to make sure the flows they
are fixing are not wrongfully marking the pages as dirty. This commit
introduces it on its own as it deserved some more detailed explanations.

In 15.0, where this commit is being merged, the final version of the
test was failing for no apparent reason on staging only. This is because
the staging builds are made with more apps... which fill the website
menu with more items in such a way the "+" auto-fold menu feature comes
in play. That feature is marking the page as dirty by mistake in this
version, 3 different ways for 3 different configurations:

- the menu is not folded outside of edit mode and when entering edit
  mode, the "+" appears and some menu are folded

- the menu is folded outside of edit mode and when entering edit mode
  the resize actually makes it so a different set of menu is folded

- the menu is folded outside of edit mode and when entering edit mode
  it stays the same (known to have been broken because edit mode
  tweaks the dropdown behavior)

The first problem with this is actually the way we check the page is
dirty in case of discard: we check the whole DOM and compare it to the
way it was when entering edit mode... the whole DOM, including the non
editable parts. This is wrong by definition but it is also weird that it
does not match what is done when we *save*: where we only consider
sections that are explicitly marked as dirty (.o_dirty) and other
exceptions. This can't be changed in stable though, some save / discard
override may rely on this (not marking with the o_dirty class etc).

In 15.0, the original commit of this forward-ported version fixed the
3rd case described above, which was less risky than fixing the 2 others.
The cause for the DOM diff in that case was the `data-toggle="dropdown"`
which mysteriously reappeared between the moment we check the "initial
DOM" and the "DOM when we try to discard". This was because of [1],
which makes the dropdowns behave differently in edit mode, combined with
the fact that the "+" menu is re-rendered after each resize (and one is
triggered when entering edit mode since [2], originally for that
actually). That behavior is however apparently not needed for the "+"
dropdown, so we simply disable it. Some lower level fix is still needed
but will be done in master, as the real problem falls in the dirty page
detection system. A test was added for this specific third case.

In 16.0, this is different: all 3 cases seem fixed, probably indirectly
thanks to the website-in-iframe refactoring at [3] and the bootstrap 5
migration at [4]. Not sure. This forward-port commit thus only adds
tests and a bunch of comments. Note that what was said about the 15.0
version was actually not entirely true: "That behavior is however
apparently not needed for the "+" dropdown, so we simply disable it." is
actually wrong. Indeed, it changed the behavior when clicking *outside*
of the extra items menu (which is less important). A patch in 15.0 will
be backported anyway to explain that.

To make the final test pass, it ensures most menus are removed so that
the "+" feature is basically disabled always during the test. Behaviors
will of course be fixed in further versions.

Note that in this 16.0 forward-ported version, a test kinda already
existed for this... although it was badly written and the code that was
merged with it actually worsened the dirty check behavior. See [5].
This commit adds comments around some more problematic parts.

[1]: https://github.com/odoo/odoo/commit/fe67b34f1a03d838df82a1307cf6467f994a8f3b
[2]: https://github.com/odoo/odoo/commit/392c91cda3133b921e9aca9a7b1c511231027438
[3]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b
[4]: https://github.com/odoo/odoo/commit/971e5a91aab96d36129a823e03f1f9f1b1293968
[5]: https://github.com/odoo/odoo/commit/650a97d1bd59254cc2115d54d58940b6112a8d70

Related to runbot-18747

X-original-commit: a0b741a53fef6a2a15d9283397dd7ec22d624382
Part-of: odoo/odoo#148728
2024-01-10 10:28:17 +00:00
Nicolas Bayet 4ea715e151 [FIX] web_editor: remove zws when unformat a zws
Before this commit, when trying to remove a format of a
`data-oe-zws-empty-inline` of an empty block, the attribute was added to
that block and would never be removed. Also, unformatting a zws would
not remove the zws from the dom.

How to reproduce the original bug:
- put the selection inside an emtpy p
- ctrl+b (in windows/linux) or cmd+b (in mac)
=> The zws attribute data-oe-zws-empty-inline is added on the P rather
   than creating a span.
   - The next letter that will be typed will not be bold but should be
   bold
   - That attribute should not exists in a block, that could lead to
   unexpected bug

task-3628480

closes odoo/odoo#148659

X-original-commit: 7b7e343e7b4fd5bab4f41eeead85dedbf2ab717d
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
2024-01-10 08:51:00 +00:00
shsa-odoo 45364e8ae8 [FIX] web_editor: prevent adding access token to external URL
Before this commit:

The editor's code was unnecessarily adding an access token to attachments
created from external URLs. This addition of a query string with an access
token to an external URL made no sense and could lead to issues.

After this Commit:

This commit prevents such behavior by adding a condition to check if the
attachment is created from an external URL. If so, it will not generate and
add an access token, ensuring the integrity of the external URL.

task-3470982

closes odoo/odoo#148646

X-original-commit: e5d464660f29a3b0b2af1c0ed534b63f81f1b10d
Signed-off-by: Nicolas Bayet (nby) <nby@odoo.com>
Signed-off-by: Sanjay Sharma (shsa) <shsa@odoo.com>
2024-01-10 08:50:57 +00:00
Roy Le 25e1e3679e [IMP] web_editor: do not handle history divergence if in module
installation mode to speedup

closes odoo/odoo#148097

X-original-commit: f12e0aae5181666e3bddfc04ff3aeea601e71f06
Signed-off-by: Nicolas Bayet (nby) <nby@odoo.com>
2024-01-10 08:50:50 +00:00
Rodolpho Lima cce80f4c73 [FIX] web_editor: duplicate attachments in html field
Before this commit, when an image was cropped in a record on which
multiple users were collaborating, multiple attachments would be created
for the same image (one per user).

Multiple attachments for the same image would also be created if the
user uploaded the same image multiple times in the same record.

This commit makes sure that, when about to create an attachment via the
'add_data', 'add_url' and 'modify_image' routes, if an attachment
already exists for the same field values, the existing attachment is
returned instead of creating a new one.

task-3524601

closes odoo/odoo#148556

X-original-commit: 0e2508388fc03b2ea7a4033e571d289efa4ac479
Signed-off-by: Nicolas Bayet (nby) <nby@odoo.com>
2024-01-10 06:12:32 +00:00
Nicolas Bayet 4a5b93994c [FIX] web_editor: make the row menu ui appear on left in RTL mode
Before this commit, when the user was in RTL mode, the row menu UI was
appearing on the right side of the table UI toggler, which would make
it invisible to the user.

This commit fixes the issue by making the row menu UI appear on the
left of the table UI toggler in RTL mode.

task-3664939

closes odoo/odoo#148543

X-original-commit: 25a9c993ff0bdbe30fca1e4306da9018a7ec836a
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-10 06:12:30 +00:00
Nicolas Bayet e67b16fb79 [FIX] web_editor: show the row table ui on the right for rtl languages
Before this commit, the row table UI toggler was positioned on the left
for RTL languages. Since the first TD was on the far right rather than
the far left, it was impossible to click on the row UI. It disappeared
whenever an attempt was made to click on it.

task-3664939

X-original-commit: fbc167bf84340b4bb6d0f8c59f2734814f56c6df
Part-of: odoo/odoo#148543
2024-01-10 06:12:29 +00:00
Nicolas Bayet 7e37f66839 [FIX] web_editor: remove unnecessary border on o_table_ui
The border was adding 1px offset that made the o_table_ui children 1px
off.

task-3664939

X-original-commit: cd497d12031bc88c8b62151f432970024ce5ce84
Part-of: odoo/odoo#148543
2024-01-10 06:12:29 +00:00
Antoine Guenet 759fad4472 [FIX] web_editor: preserve image/link on convert card
When converting a card for e-mail client compatibility, we apply the
attributes of the card's block children to their respective cells and
unwrap them. However, that's an issue if the child is an image or a link
since their respective `src` and `href` attributes are meaningless on
the cells.

task-3631900
opw-3580317
opw-3630693

closes odoo/odoo#148529

X-original-commit: d3bdb08c97ad7eab005ac185f393807df35f383e
Signed-off-by: Nicolas Bayet (nby) <nby@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-10 06:12:27 +00:00
Adnan Saiyed 2583c80eed [FIX] web_editor: space before word lost
Current behaviour before commit:

In website, space before the word is lost when deleting the word.

Desired behaviour after commit:

Now space is preserved when deleting the word.

task-3233352

closes odoo/odoo#148492

X-original-commit: 5f5d12dd1bbdc63a9565aa84f197c4a9bba55d7a
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-10 06:12:21 +00:00
Rodolpho Lima f4ac261bbb [FIX] web_editor: transform URL in multiple text nodes
Before this commit, if a URL was contained in two or more text nodes,
e.g. <p>"link" ".com"</p>, pressing the space key after the URL failed
to convert it into a link. Such text node split can happen as a result
of backspace or delete in the middle of a text node.

This commit makes sure adjacent text nodes are merged before searching
for a URL in its content.

task-3468763

closes odoo/odoo#148362

X-original-commit: 04f9a90127eac2a403ffe77d1e90dbe659a8fa42
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
Signed-off-by: Rodolpho Cammarosano de Lima (rcdl) <rcdl@odoo.com>
2024-01-09 06:28:01 +00:00
Odoo Translation Bot 0e23020b84 [I18N] Update translation terms from Transifex 2024-01-07 00:23:19 +01:00
Martin Trigaux 9a666bc8f0 [I18N] *: export 17.0 translations
There were a few errors

closes odoo/odoo#148315

Related: odoo/enterprise#53724
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2024-01-05 15:14:38 +00:00
Rodolpho Lima 1dc42bc66f [FIX] web_editor: link preview on label change
Before this commit, the link preview in the Link Dialog would not be
updated after changes on the label input field, depending on other
actions to be updated (e.g. picking a different type of link/button or
changing the URL input field).

This commit makes sure the link preview reacts to changes on the label
input field.

task-3580621

closes odoo/odoo#148202

X-original-commit: c7954225e8680821a46c9628e5e05df2ae575da7
Signed-off-by: Nicolas Bayet (nby) <nby@odoo.com>
Signed-off-by: Rodolpho Cammarosano de Lima (rcdl) <rcdl@odoo.com>
2024-01-05 15:14:35 +00:00
Guillaume-gdi 3859bbe99b [FIX] web_editor, *: prevent blocked UI when original image not found
*: website

When the user uploads an image and remove the original image, some
image options continue to work thanks to a backend fallback on another
image. Unfortunately, this fallback is not available for images coming
from unsplash. This commit fixes this issue by preventing the UI to be
blocked when the original image is not found.

Steps to reproduce the bug:
- Activate the developer mode
- Configure Unsplash in the settings
- Add a Cover block on a page
- Replace the background image with an unsplash image
- Save
- Edit the page and via the media dialog, remove the original image

=> The options on the image cannot start anymore.

opw-3636499
opw-3474103

closes odoo/odoo#148197

X-original-commit: 3b0ac160a800f70ae965b60110e83e41655bca5f
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com>
2024-01-05 15:14:34 +00:00
maad-odoo 7460aa2c9d [FIX] web_editor: incorrect delete behaviour of star rating elements
Before this commit:
When inserting a star rating element, pressing 'Enter' would move the cursor
to the next line, and hitting 'Backspace' would delete the star rating element.

After this commit:
After inserting a star rating element and moving to the next line with 'Enter,'
pressing 'Backspace' now causes the cursor to move to the previous <p> tag
where star element is located. If 'Backspace' is pressed again, the star
element is deleted.

task-3555394

closes odoo/odoo#148198

X-original-commit: 64a1b38450e15162f89d370fbe30abda9e5f7fe7
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-05 09:12:51 +00:00
Soukéina Bojabza f1a2fe43a4 [FIX] web_editor, website: consider images with a link as grid images
The "grid images" are grid items that only contain an image (i.e. the
image is alone in its column). This distinction with other images in
grid mode allows to set the `object-fit` CSS property to `cover` so they
take the whole space of the grid item (see commits [1] and [2]). In
commit [3], the "Position" option has been added, allowing to switch
between the `cover` and `contain` values for this property, to have the
possibility to still choose to display the entire image, so it can keep
its ratio.

However, only the images that are direct children of the column have
been considered when checking if it was a grid image and in the related
CSS rules. This means that an image with a link cannot be one, since
the image is the child of an anchor element `<a>` in that case. It can
therefore not be set as "cover" or have the "Position" option.

This commit adds the support for images with a link set on them, so they
can be considered as grid images too.

Steps to reproduce:
- Drop the "Masonry" snippet.
- Click on the image and set a link on it.
=> The image is now "contain" and the "Position" option disappeared from
the right panel so we cannot change it.

[1]: https://github.com/odoo/odoo/commit/e9c7e020daf88022d6e02de0a5620074e8417b5a
[2]: https://github.com/odoo/odoo/commit/d8c374e3e6b31bf88aa42952aadf3379936f7600
[3]: https://github.com/odoo/odoo/commit/faf19ef7f87fc043fb9a814516e01b8eeafd9b61

opw-3580128

closes odoo/odoo#148022

X-original-commit: 085d70cea571ea80c141ac6005e8bd8333bd269f
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Soukéina Bojabza (sobo) <sobo@odoo.com>
2024-01-04 12:02:07 +00:00
Robin Lejeune (role) b0bb196dce [FIX] web_editor: unobserve background grid z-index
Minor fix: the background grid is not observed in the first place,
setting a z-index on it should not be observed either.
Noticed when fixing `automaticStep(Un)active()` at [1].

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

Related to task-3576046

closes odoo/odoo#147970

X-original-commit: 901ed6d8c6c6bdb8aff8e9366d63bba59051019a
Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com>
2024-01-03 18:06:02 +00:00
Antoine (ande) bc87944b7a [FIX] web_editor: document layout has color issue
Current behaviour:
When changing the text color in the document layout
of the company to one of the first row colors,
the text stays black in the preview of the document.

Steps to reproduce:
1. Go to Settings
2. Click on Configure Document Layout
3. In Company Details, highlight the text
4. Change the font color to any of the first row
5. (By example the color #35979c)
6. The text color in the preview is still black
7. (Same when exporting to PDF)

Cause of the issue:
The css code for colors in top row (o-color-1 to 6)
is generated in web_editor (.text-o-color-1 to 6)
and was not in the report_assets_common bundle
See https://github.com/odoo/odoo/blob/01b42c7d76c814e13325f8880dc9de765b0f43c8/addons/web_editor/static/src/scss/web_editor.common.scss#L662

opw-3360456

closes odoo/odoo#147645

X-original-commit: 0b914f3d0dc209ca87837feb15e6ec3f063be534
Signed-off-by: Antoine Demany (ande) <ande@odoo.com>
2024-01-03 18:05:58 +00:00