Commit Graph
4830 Commits
Author SHA1 Message Date
AH-Yussef 08104386e1 [FIX] web_editor: upload CORS images by URL
- Install E-commerce app
- Go to Website > Shop, and open a product
- Click on edit on the upper right corner.
- Double click the product image to change it. A popup is shown.
- In the popup, click on Add URL and place this URL [1]
- Click Save. The image disappears!

- The issue was introduced here [2]
- As URL now starts with `/web/image/` which will be later used here [3]
- The condition to enter this line is `url_object.path.startswith('/web/image')`
- `item[field]` is used which equals to `attachment[datas]`
- But actually `datas` is empty as the image upload fails because of CORS
- `add_url` is called [4] saving attachment without `datas` but with type URL

- The commit solves the issue by fetching the remote data from the server
if the url is a remote redirection, which still happens when the image
data cannot be fetched by the client browser at upload time.

[1]: https://lowendbox.com/wp-content/uploads/2022/09/odoo_logo_1200.png
[2]: https://github.com/odoo/odoo/commit/943944dd249c15de870d6800d89e48d54a422e5a#diff-0897c80484208197b0aff67f2b06509e864c3976de1589e3cebad2788eef008fR49
[3]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/models/ir_qweb_fields.py#L473
[4]: https://github.com/odoo/odoo/blob/f72968561acec164697a7a9ee0965ec304854dd5/addons/web_editor/controllers/main.py#L268

opw-3746245

closes odoo/odoo#160085

Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2024-04-19 19:14:00 +00:00
Serge Bayet (seba) 3118782cd8 [FIX] web,website: fix a rtl issue with carousel snippet
Given the changes in [1] and subsequently in [2], which in some way
counteract the RTL adjustment, it is necessary to eliminate the rtlcss
directive from the carousel CSS to ensure the correct behavior.

Steps to reproduce:

- Enter in edit mode.
- Drag and drop an image gallery and a carousel snippet.
- Navigate to the theme tab.
- Add an RTL language (Arabic, for instance).

Bug :

- The images slide in incorrectly during transitions. In RTL mode, when
  clicking on the left chevron, the next image should appear, not the
  previous one.

If we have three slides numbered 1, 2, and 3
- In RTL mode: Clicking left should navigate from 1 to 2 to 3 and then
  back to 1.
- In non-RTL mode: Clicking left should navigate from 1 to 3 to 2 and
  then back to 1.

The directional Font Awesome icons (classes starting with `fa-` and
ending with `-right` or `-left`) are not flipped in the mobile viewport
as a result of [3]. Necessary adjustments have been implemented
to prevent this behavior.

Upon investigation, a more significant bug was discovered regarding the
'oi-...-[right/left]' icons. These icons were not flipped appropriately
in the frontend when the webpage context was set to an RTL language. A
pull request has been created and merged to address this issue [4].

More info on rtlcss [here]

[1]: https://github.com/odoo/odoo/commit/ebb61753bf3d3dd8d3f53db088112b9e4beb813d
[2]: https://github.com/odoo/odoo/commit/c48f57ea2538ad51e00ac27d58f8e191781444f3
[3]: https://github.com/odoo/odoo/commit/be375bb2a886edd002f042355455a71fcac4daf5
[4]: https://github.com/odoo/odoo/pull/157214
[here]: https://rtlcss.com/learn/usage-guide/value-directives/#tip

opw-3747848

closes odoo/odoo#162202

X-original-commit: 7f0f750b0d9e45982130742af2ac396d1985612e
Related: odoo/enterprise#60922
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2024-04-18 15:05:27 +00:00
Guillaume-gdi 5d41bb4a79 [FIX] web_editor: remove useless params when call IAP OLG
Since [this other commit], web_editor can call IAP to generate text via
chatGPT. Unfortunately, an unnecessary param (`version`) was given to
IAP leading to a warning on the IAP side
`generate_content_from_conversation> called ignoring args <version=X>`.
This commit removes this useless param.

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

Related to task-3383324

closes odoo/odoo#162249

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2024-04-18 00:32:45 +00:00
Mahdi Cheikh Rouhou (macr) 537b8d354c [FIX] web_editor: position powerbox correctly in rtl direction
Issue:
======
The powerbox keep increasing in size when you input.

Steps to reproduce the issue:
=============================
- Install arabic
- Go to notes
- write `/`, you can see the powerbox is a bit smal
- use `down/up`arrows to navigate in the powerbox.
- The powerbox width increase until finally gets to it's intended
  position.

Origin of the issue:
====================
Since we are providing that `marginRigh` should be equals to `20` in
`getRangePosition` we will move the powerbox to the left a bit and then
with the style property `max-width=100%` it will increase in size
because the current size is a bit small for it. So at every key pressed
it will increase by 20px until it gets to a point where everything is
set and the `marginRight=20` is finally visible.

Soltuion:
=========
We set min-width as max-content so we can position correctly the
powerbox knowing it's final width.

task-3721794

closes odoo/odoo#161924

X-original-commit: b815447bf239049b37a3705cd014c67e3897ba9c
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Mahdi Cheikh Rouhou (macr) <macr@odoo.com>
2024-04-16 08:36:05 +00:00
Guillaume-gdi 9f319cbc95 [IMP] web_editor, website: add database ID to OLG calls
This commit adds the database ID to the IAP calls made to generate text.
It permits to prevent abuses of OpenAI calls.

task-3740440

closes odoo/odoo#154615

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2024-04-15 16:21:46 +00:00
Odoo Translation Bot 3275156773 [I18N] Update translation terms from Transifex 2024-04-14 00:09:33 +02:00
Robin Lejeune (role) de61ecb58f [FIX] web_editor: disable snippets on login page
On pages without visible dropzones (including if one exists in a
currently invisible snippet), snippets should not be droppable from the
editor. Up to now, the behavior did not take into account invisible
snippets, leading to confusing situatons (cf. steps to reproduce).
This commit makes sure that the drag & drop is disabled if the only spot
available is within an invisible snippet. It reenables the D&D if an
invisible snippet is shown.

Steps to reproduce:
- Go to `/web/login` and edit the page
- Most snippets can't be dragged & dropped
=> Good. There is no dropzone for them.
- Activate the cookies bar in the settings
- Go to `/web/login` and edit the page
=> The "structure" snippets can now be dragged & dropped, even though
the only place where it is possible is the cookies bar, which is
invisible. It looks like a bug for the users who try to drop blocks on
the main page and cannot.

opw-3829660

closes odoo/odoo#161210

X-original-commit: 58af56c57ca935913e81517f4a17c6b34c262301
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2024-04-11 13:16:56 +00:00
Soukéina Bojabza 47b06e0ebe [FIX] web_editor, website: make added grid items always visible
Before this commit, when adding a new grid item in a grid by using the
"Add Elements" option, if the page was scrolled such that the top of the
grid was not visible, this new grid item may not always be visible. This
is annoying as the user could add an element and not see where it
appeared and would therefore need to look for it.

This commit fixes this by making the page scroll to the added grid item
if more than half of it is not visible. A test is also added.

Steps to reproduce:
- Drop the "Text-Image" snippet and enough snippets under it to have a
  scrollbar.
- Toggle the "Text-Image" snippet to grid mode.
- Scroll the page so the top of the grid is not visible.
- Add a new "Button" with the "Add Elements" option.
=> The button is not visible.

task-3616138

closes odoo/odoo#161159

X-original-commit: 50766b74196b3cdc5ac83d7962873f4fffa4c9f6
Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com>
Signed-off-by: Soukéina Bojabza (sobo) <sobo@odoo.com>
2024-04-11 09:50:46 +00:00
Antoine Guenet f41e51ba9c [FIX] web_editor: prevent traceback odooEditor is undefined
This commit fixes a traceback that occurs when calling `getValue` on
`wysiwyg` while the `odooEditor` instance variable is not defined for
whatever reason.

task-3600667

closes odoo/odoo#161110

X-original-commit: cb2c51aa28ade702a87bbdbb3b4eb9157a56b409
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-04-11 09:50:45 +00:00
Soukéina Bojabza b392d85b62 [FIX] web_editor: fix dragging a column from the bottom in a grid
Since commit [1], we can now drag and drop an image column by dragging
it directly, and not only by the move handle. Commit [2] allowed the
image to be dragged from anywhere and not only from the top middle.
However, since commit [2], it is really difficult to drag a column
downwards in a grid, if the drag started from the bottom move handle or
near the bottom of the column if it contains an image, because we easily
get out of the dropzone.

Indeed, since the positioning of the column now takes into account the
mouse position on the column where the drag started, the mouse cursor is
therefore located under the column (or almost under in the second case).
This is why it gets out of the dropzone before a new row could be added.
For the second case, new rows can be added, but only if the drag is slow
enough, which is not convenient.

This commit bounds the vertical position of the mouse when dragging, in
order for it to always be considered inside the column, so it cannot
escape the dropzone anymore. A safety margin of one grid row is
considered, to not escape when dragging rapidly.

Steps to reproduce:
- Drop enough snippets to have a scrollbar or select the "Sidebar"
  header template.
- Drop a "Text-Image" snippet
  - at the top of the page if the header was changed at the previous
    step, or
  - at a place where the top of the snippet can be hidden with a scroll.
- Toggle it to grid mode.
- Start dragging any column with the bottom move handle or drag the
image column by clicking near the bottom of the column.
- Go over the grid dropzone if the move handle is used.
- Drag towards the bottom of the grid.
=> The mouse easily gets out of the dropzone, making it impossible to
add new rows and drag further down the grid.

[1]: https://github.com/odoo/odoo/commit/cff6f79b5f38239be8a498ff03549ad9a5deebae
[2]: https://github.com/odoo/odoo/commit/514d3dbad4d20db375cba634b6af68a4fb0cafe9

task-3601336

closes odoo/odoo#144427

Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
2024-04-10 15:14:57 +00:00
Soukéina Bojabza 3a0a52ee99 [FIX] web_editor: make the drag towards the bottom in grid mode smoother
Since commit [1], we can now drag and drop an image column by dragging
it directly, and not only by the move handle. Commit [2] allowed the
image to be dragged from anywhere and not only from the top middle.

In grid mode, in order for the column to stay well inside the grid when
dragging, its computed position was originally bound horizontally, to
the left and the right of the row. With commit [2], it is now also bound
vertically, to the top and the bottom of the row.

While it makes sense for the top, because we need to take into account
from where we dragged the image, it should not have been the case for
the bottom, as we need to overflow in order to add new rows. This
resulted in the drag towards the bottom becoming jumpy, because it locks
on the bottom of the grid until a new row is added, when the mouse
pointer is down enough.

This commit removes this bottom bound, in order for the drag towards the
bottom to be smooth again.

Steps to reproduce:
- Drop the "Text-Image" snippet and toggle the grid mode.
- Drag a column towards the bottom in order to add new rows.
=> It is not smooth: it locks on the bottom of the grid.

[1]: https://github.com/odoo/odoo/commit/cff6f79b5f38239be8a498ff03549ad9a5deebae
[2]: https://github.com/odoo/odoo/commit/514d3dbad4d20db375cba634b6af68a4fb0cafe9

task-3601336

Part-of: odoo/odoo#144427
2024-04-10 15:14:57 +00:00
Benjamin Vray fb7246f3dd [FIX] web_editor: fix infinite loop on empty oe-structure click
Steps to reproduce the bug:

- Install e-commerce.
- Open a product page in edit mode.
- Click on the "product.description_ecommerce" field.
- Bug: an infinite loop starts. The "selectionchange" event is triggered
in an endless loop, causing various issues such as the page freezing
after a while.

This issue was introduced by this commit [1].

Since this other commit [2], when a selection itself is the main
container of the editable area, we replace this selection to only
include the content of it. With commit [1], this has been modified to
take into account "oe_structure" and "[contenteditable]" elements. As
these elements can be empty, clicking on them would reselect them,
creating an endless loop since we'd never leave the condition that
replaces the selection.

[1]: https://github.com/odoo/odoo/commit/e93fa23c29421ffe8917d9650330585d6dad210f
[2]: https://github.com/odoo/odoo/commit/10c5a16cd44b8d8e54082df90166f2309dfa788d

task-3830033

closes odoo/odoo#160535

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-04-10 11:45:55 +00:00
reka-odoo 736ad5956a [FIX] web_editor: prevent typeerror at write of qweb fields
When user tries to empty start date or end date in website using editor,
a traceback will appear.

Steps to reproduce the error:
- Install "website_event"
- Go to Website > Events > Open any Event > Register > Edit
- Now try to empty start date or end date > Save

Error: A traceback appears:
"TypeError:'<' not supported between instances of 'bool' and
'datetime.datetime'"

https://github.com/odoo/odoo/blob/4759c6d1ee09c32381dc56c59c95949fd0e2807c/addons/event/models/event_event.py#L507
Here, When user tries to empty start date or end date,
start date or end date will become "False",
So it will lead to the above traceback.

solution:
A try-catch is used to catch typeerror at write of qweb fields.

sentry-5038057541

closes odoo/odoo#161083

X-original-commit: c893ff16e277b46796a943c5532e01e8edf8958f
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Renilkumar Kajavadra (reka) <reka@odoo.com>
2024-04-10 08:17:52 +00:00
ruja-odoo 439ad27b9f [FIX] web_editor: unable to add space in link label
Before this commit:

The cursor kept on flickering when attempting to enter a space at the end
of label text field of a link resulting in not being able to add space at all.

After this commit:

Now, it's possible to add  spaces at the end of a link label.

task-3820250

closes odoo/odoo#160780

X-original-commit: 1af59ba5054dae5272506aead8b2c8dd0e5616fb
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-04-08 07:35:59 +00:00
adch-odoo 1d7b08184b [FIX] web_editor: resolved NaN issue in font-size dropdown in toolbar
Commit [1] resolved an issue related to the behavior of small font sizes, which
caused 'NaN' to appear in the font-size dropdown within the floating toolbar.
This occurred due to the removal of a variable definition, resulting in the
inability to compute the font size. This commit rectifies the problem by
reintroducing the variable in the SCSS file to ensure correct rendering.

[1]: 7931d1a14a

task-3801894

closes odoo/odoo#158811

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-04-05 08:57:47 +00:00
Benjamin Vray d890ea8b8a [IMP] web_editor: prevent the colorpicker from closing on inner click
Before this commit, clicking in the area below the "Hex color" input
would close the color picker. This was annoying when entering a value in
the "Hex color" input and then clicking below to confirm it.

After this commit, the color picker no longer closes when clicking on
its background.

task-3747408

Part-of: odoo/odoo#157034
2024-04-03 14:29:08 +00:00
Mahdi Cheikh Rouhou (macr) 4a05740bd3 [FIX] web_editor: apply color unremovable
Steps to reproduce the issue:
=============================
- Go to website and open editor
- Click on the 'Contact Us' button
- Change the color of the text
- error

Origin of the issue:
====================
`HistoryReverCurrentStep` will call `observerFlush` which will mark
`_toRollback = true` and in `_observeOdooFieldChanges` we will update
the html with `withoutRollback` but this only works only if
`_toRollback` is `false`.

Solution:
=========
We need to rever  the step without rollback too.

task-3770287

closes odoo/odoo#156461

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-04-03 14:29:07 +00:00
Benoit Socias 14c82e343d [FIX] web_editor: restore save error display
If an error happens when a website page is being saved, the error
message was displayed as a popup on the edited block.
Since [1] that error was not displayed anymore because the call to
`ir.ui.view`.`save` from `this._rpc`, which wrapped errors into a
message, was changed to `this.orm.call`, which raises errors in their
original form.

This commit adapts the error handling to expect an actual error instead
of a message.

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

task-3599890

closes odoo/odoo#155071

X-original-commit: 7d5aeabebbc56ac22d06e8291e1cf58b62d4defe
Signed-off-by: Outagant Mehdi (mou) <mou@odoo.com>
2024-04-03 12:35:22 +00:00
qsm-odoo cca8ec712a [MOV] web: move some DOM utils to the non-lazy loaded bundle
In the future, we might want to make most utils available in the non
lazy JS bundle part. We are also considering moving the Bootstrap lib
and some more in there. This commit is about moving the strict minimum
to be able to improve the lazy loading behavior in stable: the DOM utils
that allow to make async handlers and create button loading effects when
we click on them.

This also means that those utils were adapted to not use jQuery and
other non available utils.

Related to task-3770362

X-original-commit: 2e922105d8714704b3db94966defc922297e2ab6
Part-of: odoo/odoo#159680
2024-04-02 15:40:27 +00:00
imanie383 c6b6b709ef [IMP] web_editor: make formatsSpecs heritable
Make formatsSpecs heritable to allow programmers adding new inline options

closes odoo/odoo#159293

X-original-commit: 7b61bb654c587e624655904ee5d978e531c70f7b
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-04-02 08:41:48 +00:00
Deependra Solanki 298f8643a4 [FIX] web_editor: change tag between br
Before this commit:

The `<br>` tags copied from external editing software's were remained unchanged.

After this commit:

Implement breaking element at <br> during HTML paste to adress unwanted
<br> elements introduced by external editing software's or the OS.

This ensures consistent and correct behaviour for all commands.

Note that this change does not break `<li>`, `<blockquote>`, and `<pre>`
elements.

task-2936891

closes odoo/odoo#159875

X-original-commit: 94161376b296140e430d034ac79a40127a567457
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Deependra Solanki (deso) <deso@odoo.com>
2024-04-01 04:23:19 +00:00
Odoo Translation Bot 684745f5de [I18N] Update translation terms from Transifex 2024-03-31 00:09:16 +01:00
visp-odoo 591658ea67 [FIX] web_editor: show toaster notification error on uploading folder
Steps to reproduce:

OS: Ubuntu 20.04.4 LTS with nautilus
Browser: Google Chrome Version 123.0.6312.58

- type /file command in knowledge
- select a folder and click on open
- traceback occurs

Before this commit:

When a user attempts to upload a folder using /file command, the
processing begins, but the folder is not actually uploaded because the
`getDataURLFromFile` return promise which is not fulfiled. Additionally,
there is no indication of any warnings or errors during the folder
upload process.

After this commit:

If a user attempts to upload a folder instead of a file using the /file
command, it results in a error message in toaster notification.

task-3690847

closes odoo/odoo#159755

X-original-commit: 0b27ac02e499bf15d9f011beda17ab202c1f7a42
Signed-off-by: Damien Abeloos (abd) <abd@odoo.com>
2024-03-29 12:38:06 +00:00
Renaud Thiry 8d99f2f415 [MOV] test_website, web_editor: move test to right module
Some web_editor test was in "test_website" when it could
have simply been in web_editor.

It is moved there and modified to reuse existing imports and pass standard
web linting rules.

task-3741858

closes odoo/odoo#155704

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-03-29 09:12:17 +00:00
Renaud Thiry 5c7e377f77 [FIX] mail, web_editor: add attachment at file upload
When using the `/image` command in the composer, or otherwise uploading a file
the editor should add the attachment to the composer if it is the current model

During a change in js relational models [1] the code was not adapted properly.
This lead to a traceback when using the command inside the composer.

[1]: 218ad8456a

task-3741858

Part-of: odoo/odoo#155704
2024-03-29 09:12:17 +00:00
Mahdi Cheikh Rouhou (macr) c0a4a01915 [FIX] web_editor: spacing issue between columns of tablepicker
Issue:
======
The last column in `rtl` direction is connected to it's neighbor column.

Steps to reproduce the issue:
=============================
- Install notes and website
- Change language to arabic
- Go to notes and write `/` and opent eh table picker
- The last column (most left) is connected to it's neighbor

Origin of the issue:
====================
We forced the margin-right of the last cell in the row to have
`margin-right = 0` which is the case for `ltr` but not in `rtl`.

Solution:
=========
Use of `end` and `start` better to handle the direction
(https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline-start)

task-3825970

closes odoo/odoo#159643

X-original-commit: 0d57a30d12775d8c0ecdb6c3fab5ce191d3f2ccc
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Mahdi Cheikh Rouhou (macr) <macr@odoo.com>
2024-03-29 07:53:01 +00:00
Mahdi Cheikh Rouhou (macr) 7c59e05595 [FIX] web_editor: expand tablepicker in correct direction
Issue:
======
Table picker isn't intuitive in rlt language and doesn't expand in the
correct direction.

Steps to reproduce the issue:
=============================
- Install arabic language
- Go to notes and create a new one
- Write `/` and choose table
- Use left/right arrow keys to see how the table expand.

Solution:
=========
For rtl direction it's better to make left for increase and right for
decrease since that's the direction of the langauge. Also the table
should be fixed on the right and expand on the left. (exactly the
opposite of ltr direction).

task-3721794

X-original-commit: 9d4c937e67cb72ff7152e01cda23255bf3c4d344
Part-of: odoo/odoo#159643
2024-03-29 07:53:01 +00:00
Benoit Socias 469138e229 [FIX] web_editor: update all values when using up/down on multi-value
When using the up/down arrows in an `InputUserValueWidget`, only the
first value is updated but the other ones are lost.

This commit adapts the behavior so that all parts of the composite value
are updated.
When decreasing, parts that have reached zero are set to zero.

Steps to reproduce:
- Drop a "Banner" snippet.
- Select the text block.
- Set the "Border" option to "5 10".
- Press the up or down key.

=> Only the "5" was updated, the "10" was lost.

task-3800288

closes odoo/odoo#159385

Signed-off-by: Robin Lejeune (role) <role@odoo.com>
2024-03-28 10:19:39 +00:00
Benoit Socias 5a5b77de85 [FIX] web_editor: accept composite values starting with 0
When specifying a composite value in a `UnitUserValueWidget`, if the
first element is a 0, it is considered inactive and resets to its
default value.

This commit considers composite values that start with a 0 as active.

Steps to reproduce:
- Drop a "Banner" snippet in a page.
- Select the text column.
- Specify "0 10" in the Border.

=> The value was reset to 0.

task-3800288

Part-of: odoo/odoo#159385
2024-03-28 10:19:39 +00:00
Benoit Socias e321791f84 [FIX] web_editor: fix selectStyle with conflicting extraClass
Since [1] when `extraClass` was introduced, styles are wrongly applied
if an `extraClass` is defined on a `selectStyle` option, but both the
class and the option modify the same CSS property.

Typically, the "Round Corners" option sets the `border-radius` property
and uses the `rounded` extra class. But that extra class specifies
values for the `border-radius` properties.
Without the class, `applyCSS` determines that the style of some corners
is already `0px` and does therefore not need to be added to the inline
style.
But once the class is added, this is not true anymore - and the `0px`
should have been specified.

This commit avoids this issue by applying the CSS again once the
`extraClass` is added.

It also reverts [2] partially to remove the `extraClass` handling from
within the `applyCSS` function.

Steps to reproduce:
- Drop a "Text - Image" snippet.
- Select the image.
- Set the "Round Corners" to "50 0 0 0".
- Press tab to leave the field.

=> The entered field values was transformed.

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

task-3800288

Part-of: odoo/odoo#159385
2024-03-28 10:19:39 +00:00
maad-odoo a4d6ed6332 [FIX] web_editor: delete behaviour on heading elements
Before this commit:

1. When an empty heading from H4 to H6 is the only element in the editable
   area, the backspace key doesn't turn it into paragraphs.
2. When the cursor is at the start of a heading element with text content, and the
   user hits the backspace key, the element gets converted into a paragraph.

After this commit:

All heading elements are removed on backspace if they're empty.

task-3456815

closes odoo/odoo#158970

X-original-commit: 6a52ac3d76a23f47bcebcc43603e2963ea52521e
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-03-26 13:35:54 +00:00
dhba a42ca8f3ba [FIX] web_editor: issue with copy paste
Before this commit:

When attempting to copy a button that is a direct child of a div tag, the div
was unintentionally copied along with the button, leading to additional space
upon pasting, along with the background color.

After this commit:

Now, only the button will be copied and pasted

task-3764652

closes odoo/odoo#158975

X-original-commit: b27b9ca18da9b1c39906f8a374418105c2e9c487
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-03-26 08:20:20 +00:00
Antoine Guenet 421f1f693b [FIX] web_editor: apply format in classless unbreakable inline
When applying a format in an unbreakable inline (without a class), the
format was immediately rolled back as we tried to remove split the
unbreakable in order to remove its style.

task-3768157

closes odoo/odoo#159110

X-original-commit: 78e809c18db7bd520ccf706b2504139248fbd0ff
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-03-25 16:26:59 +00:00
Mahdi Cheikh Rouhou (macr) 7d66b910c4 [FIX] web_editor: resize columns correctly in RTL
Issue:
======
resizing columns doesn't work properly in rtl direction.

Steps to reproduce the issue:
=============================
- Install arabic
- Go to notes
- insert a table
- Try to resize columns

Solution:
=========
We will handle the cases one by one:

Start: We need to update the `marginRight` prop instead of `marginLeft`
and calculate `sizeDelta` correctly which `clientX - (rect.x +
rec.width)`.

Middle: We will handle this the same as ltr direction, since it's the
reverse direction, we swap `previous` with `next` and `next` with
`previous`. Columns are sorted from right to left so we need to swap
columns when we recalculate them from the columns array so `item` will
be the one on the left and `neighbor` the one on the right.

last: We calculate correctly `sizeDelta` which is `rect.x - clientX`

task-3721794

closes odoo/odoo#159087

X-original-commit: 87f8bcd99a4b1049deed7bccbc5b85812ebc4674
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-03-25 16:26:58 +00:00
Mahdi Cheikh Rouhou (macr) 711e2a534a [FIX] web_editor: move columns left/right correctly
Issue:
======
The icons does match the direction of the move but it doesn't match the
label in the ltr language.

Steps to reproduce the issue:
=============================
- Install arabic
- Go to notes and insert a table
- write something in a column in the middle
- Click on the top of the column on the 3 points.
- The first item of the dropdown have the label in arabic meaning `Move
  to left` but the direction of the icon and clicking on it will move it
  to the right.

Origin of the issue:
====================
- The icon is being flipped because we are in rtl but in realtity left
  is the same for rtl or ltr direction.
- We need to call `_onTableMoveLeftClick` when we are moving to the
  right in rtl because the left of rtl direction is the visible right.

task-3721794

X-original-commit: 58cdfb8c80ecfb305ecdb84398508bd2fc180fb3
Part-of: odoo/odoo#159087
2024-03-25 16:26:58 +00:00
Arthur Detroux (ard) ed10f6a814 [FIX] website_sale, *: only reload once on options changes
*: web_editor, website

Commit [1] introduced new image settings for the product page.
When those settings were introduced, the editor was reloaded after the
RPC to properly reflect when the settings were changed. While this was
done, a data-reload was also added in the XML template of the options.
This was not necessary as the data-reload only works for some methods
which are not used in the image settings. Therefore, the data-reload
did nothing.

However, with commit [2], the settings were moved and combined with
page options. So the image settings automatically inherited the page
options behavior, which is to save and reload the page when a method
with data-reload is called. This caused the editor to ask for a reload
twice.

This could cause the page to reload before the RPC was finished:
- Add a 10 seconds sleep at the start of /shop/config/website controller
- Go to products page
- Enter edit mode
- Change the number of products per row
=> Nothing happens
Indeed, the page is reloaded immediately, before the 10 seconds rpc is
actually done.

This is also needed by the conversion of the SnippetsMenu to OWL:
It seems like the race condition introduces a traceback.

This commit fixes the issue by ignoring any save request from an option
that will reload anyway. It also awaits the RPC to finish before
reloading the page.

[1]: https://github.com/odoo/odoo/commit/54c6d36cfbea31fe60b888bbb903b0c6f22216b3
[2]: https://github.com/odoo/odoo/commit/b274cf2427951761e59eb357fb796b54be375507#diff-754f6c793d6a168d006d2a9da108142b889036031ac1a2e62060c225d060f858

closes odoo/odoo#158468

X-original-commit: 556ae457b02e9c077d09fa9c3f9f1e6c6e26b345
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2024-03-25 14:39:16 +00:00
Antoine Guenet c1fa1e2391 [FIX] web_editor: prevent InvalidStateError with stressed webrtc
This prevents a traceback* which happens when the webrtc connection is
under signaling stress and a local rollback is triggered when the state
has been set back to stable.

This seems to be caused by browser bugs (both in
[Firefox](<https://bugzilla.mozilla.org/show_bug.cgi?id=1628139>) and in
[Chromium](<https://issues.chromium.org/issues/40132342>) due to an
[error](<https://github.com/w3c/webrtc-pc/issues/2508>) in the webrtc
spec) that occur under stress. To prevent this sort of issue, a solution
was provided in the form of an [implicit
rollback](<https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/setRemoteDescription#browser_compatibility>)
on the remote description setter. This solution has recently become
available everywhere (since Safari adopted it in
[2022](<https://caniuse.com/mdn-api_rtcpeerconnection_setremotedescription_implicit_rollback>)
for desktop and iOS).

This allows us to simply rely on the remote description setter to handle
the rollback if needed.

* Traceback: InvalidStateError: Cannot rollback local description in
  stable.

task-3823100

closes odoo/odoo#158861

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-03-25 13:08:01 +00:00
Mehdi Outagant (MOU) d956199ddd [FIX] web_editor, website: adapt hover animations to shape availability
Steps to reproduce:

- Go to website in "Edit" mode (on a blog post page).
- Select one of the default images in the blog content.
- Click on the "Animation" option and select "On Hover" > Traceback!

Starting from [1], the "On hover" image animation was implemented to be
able to pick an animation that triggers when hovering an image.

This feature is setting a default "Square" shape (required for the
hover effects to work) on the target. Which means that an error can
always occur if the "On Hover" animation option is available while the
targeted image is not linked to an attachment and can't support image
shapes (which is the case here).

The goal of this commit is to fix this issue by only allowing the
"On Hover" animations when it's possible to apply shapes to the image.

[1]: https://github.com/odoo/odoo/commit/7f730f81ec541cc7791fc6b3fded17c838433f85

opw-3795599

closes odoo/odoo#158433

Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2024-03-25 11:43:38 +00:00
Antoine Guenet 05e3645997 [FIX] web_editor: prevent any traceback in unserialize
A traceback was spotted when `unserializeNode` was called as a result of
a call to `resetContent`. That traceback could lead to other tracebacks
(including one when trying to read a history step's ID in
`_historyMakeSnapshot`). A traceback at that moment could remove all the
content of the editor before saving.

This commit ensures the argument passed to `unserializeNode` is defined,
that `unserializeNode` returns `undefined` if it couldn't return
anything valid, and that when such is the case the caller handles that
undefined return value properly.

task-3677431

closes odoo/odoo#158957

X-original-commit: bf062140877dabcb6db93d2a4bea2aa36f4b2601
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-03-25 10:00:49 +00:00
Antoine Guenet 6615bc76b4 [FIX] web_editor: backspace only char with composition menu open
When typing in Japanese with Romaji input, a traceback occurred when
hitting backspace to remove the only character in the editable while the
Japanese character selection menu was open. This is because that case
triggers an `insertCompositionText` input event with an empty string,
and tries to delete the editable, which is unremovable. Since we called
`_applyRawCommand` without wrapping it in `_protect`, the unremovable
error caused a traceback instead of a rollback. When fixing that, an
other bug appeared, which was the insertion of a `#` character. This was
due to the fact that `insertText` was called with empty content, and
`insertText` defaulted to the character `#` for no particular reason
since the early proof of concept of the editor.

task-3134566

closes odoo/odoo#159005

X-original-commit: cb75212d4fe302b54097fbc90da6d6ef8b38205b
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-03-25 08:33:17 +00:00
Odoo Translation Bot 395140671f [I18N] Update translation terms from Transifex 2024-03-24 00:12:07 +01:00
visp-odoo fb3ce4fc9e [FIX] web_editor: table should not preserve its height and width
Before this commit:

When you increase the height or width of cells in a table and subsequently
delete a row or column, the adjacent rows or columns experience an increase in
their height or width. This happens because the table preserves its overall
dimensions even after resizing individual cells.

After this commit:

Now, the table no longer preserves its height or width. When resizing the table,
the height or width of its rows or columns does not increase.

task-3636212

closes odoo/odoo#158256

X-original-commit: 9940bf3e153714022785b50cb423e52634c99202
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-03-22 11:20:08 +00:00
Benoit SociasandSerge Bayet 4b2656b020 [FIX] web_editor: remove image to save when removing background image
Since [1] when options on background images have been applied as soon as
they were modified instead of on save, those options were not reset when
the background was removed.

This commit removes those options when the background image is removed.

Steps to reproduce:
- Drop a Text snippet.
- Add a background image.
- Remove the background image.
- Save.

=> Save failed.

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

task-3794812

closes odoo/odoo#158326

X-original-commit: 23c805030abb89ca449cf430d5661d725f5801a8
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
Co-authored-by: Serge Bayet <seba@odoo.com>
2024-03-21 23:02:55 +00:00
Adnan Saiyed cccc9c47dc [FIX] web_editor: table cells not getting deselected
Current behaviour before commit:

After selecting cells in table, moving cursor through
arrowkeys doesn't deselect cells.

Desired behaviour after commit:

Now cells are getting deselected.

task-3718716

closes odoo/odoo#158265

X-original-commit: 0e8865e06b3cb7e8ee1a2c4983d06baef5b30933
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
Signed-off-by: Adnan Saiyed (adsa) <adsa@odoo.com>
2024-03-21 18:35:50 +00:00
Laurent Stukkens 12c327ad94 [FIX] web_editor: ensure correct fonts are used
Since commit [1], the new tiktok icon is added to odoo but the
conversion of the css class into an image is not supported.

This commit ensures that the conversion is correctly handled.

Steps to reproduce:
- Open the mail marketing app
- Create a new mass mailing
- Insert an icon in the template, for instance type /image in the text
  and select the "Pictogram" tab
- Search for tiktok icon and insert it
- Send the mass mailing
- The icon will not be found in the mail

[1]: https://github.com/odoo/odoo/commit/515915b9

closes odoo/odoo#158266

X-original-commit: 0fa2ce8212077facace67a0072aa4ddebc9b55f0
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2024-03-20 18:29:23 +00:00
Benjamin Vray 618fbc1a54 [FIX] web, web_editor: fix text muted within a dropdown menu
Steps to reproduce the bug:

- Install the "Blogs" app and go to the "/blog" page.
- Click on "Edit" to enter edit mode.
- Go to the "Theme" tab.
- Select the 4th color from the theme colors and choose "black".
- Save the page to exit edit mode.
- Perform a search in the search bar input that yields no results, for
example: "zzz".
- Bug: The message "No results found. Please try another search." is not
visible because it is displayed in white on the white background of the
dropdown.

A previous commit [1] had already addressed the issue for the "Search"
snippet that can be dropped into a page, but this fix wasn't sufficient
to solve the problem everywhere. Indeed, the text-muted in a dropdown
should be adjusted in all cases and not just for snippets; it's a
Bootstrap issue. The text-muted color should be adapted to the
background color of the dropdown.

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

task-3662985

closes odoo/odoo#158203

X-original-commit: 46fcb3712f0ba68144b03ed23f52157d4dfc789a
Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
Signed-off-by: Outagant Mehdi (mou) <mou@odoo.com>
2024-03-20 13:52:31 +00:00
Adnan Saiyed eff58a91ca [FIX] web_editor: events not getting caught in website
Current behaviour before commit:

When trying to crop image in website, 'mousedown' and
'keydown' events are not getting caught. Due to this
- Crop is not getting closed when clicking on document
- Cropped image is not getting saved when pressing
   enter

Desired behaviour after commit:

Now, events are added to the owner document of the
crop widget. As result,
- Crop gets closed when clicking anywhere in document
- Image gets saved when pressing enter.

task-3570524

closes odoo/odoo#158093

X-original-commit: afeba0d17a91d41ba2628524ccc03249835884b1
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
Signed-off-by: Adnan Saiyed (adsa) <adsa@odoo.com>
2024-03-20 13:52:24 +00:00
Julien Banken ca76366bac [FIX] web_editor: enable embedding unlisted vimeo videos
When the user inserts a video with the `/video` command and provides a
link of an unlisted vimeo video, the system generates a new url based
on the options selected but omits the hash parameter granting access to
the given video. As a result, the video can not be loaded and the vimeo
`iframe` indicates that the video does not exist.

To fix the issue, we will copy the hash parameter from the original link
to the newly generated url. That way, the video will be loaded properly
and the user will be able to embed unlisted vimeo videos.

Steps to reproduce the issue:
1. Install the website app
2. Open the website builder
3. Drag and drop a text block
4. In the text block, type the `/video` command to insert a video
5. In the modal, paste the link of an unlisted video
6. The `iframe` indicates that the video does not exist

=> The system should extract the hash parameter from the provided url
and set it on the generated url. The video should then be loaded properly.

task-3697764

closes odoo/odoo#157279

X-original-commit: f72b873e58348374f3ce0e91ec5e87ed42215e55
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2024-03-20 13:52:19 +00:00
Antoine Guenet c7580486cb [ADD] web_editor: add "correct" button to the AI Copywriter
This adds a button to the AI Copywriter that allows the user to correct
the selected text without altering it otherwise.

task-3776377

closes odoo/odoo#156067

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-03-19 11:14:04 +00:00
Mahdi Cheikh Rouhou (macr) 63fa6dd45d [FIX] web_editor: conserve changes on edit link label
Issue:
======
When you update the link button label from the sidebar it loses its
style.

Steps to reproduce the issue:
=============================
- Got to website editor
- Insert a text block
- Added a button in the text block and any label
- Click on the button to edit it from the sidebar
- Change font size or font color or any style you want
- Update the label
- The style is lost

Origin of the issue:
====================
When updating the label, we search for the first child that has that
text, but when we have `ZWS start`  it will be considered as the first
child and then we update the inner text of the `a` element so we loose
the span of the text which has the custom styles.

Solution:
=========
We search for the first child which is not `ZWS`

task-3721686

closes odoo/odoo#157758

X-original-commit: 999d5787e3d8d0518692f987341dd6b298d7ffc4
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-03-18 08:45:39 +00:00