Commit Graph
4696 Commits
Author SHA1 Message Date
Benoit Socias 6ab7a11e3a [FIX] web_editor: adjust "add URL" button for documents
Before this commit the button to add documents from an URL is labeled
"Add Document" which is confusing given it is displayed besides an
"Upload Document" button.

This commit renames the "Add Document" button into "Add URL" to make its
purpose more obvious.

task-3493618

closes odoo/odoo#149406

X-original-commit: 860cbe0fcddc7b7a6f1ca383161ab439ba68fd72
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2024-01-26 21:07:52 +00:00
visp-odoo afb95a62a8 [FIX] web_editor: correct invalid link notification
Before this commit:

Clicking on invalid link results in a blank and bizarre notification because
we are accessing wrong parameter in wysiwyg.js.

After this commit:

After correcting parameters clicking on an invalid link triggers a notification
displaying an invalid URL message.

task-3563345

closes odoo/odoo#139301

Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
2024-01-26 10:34:59 +00:00
maad-odoo 22c082f996 [FIX] web_editor: make heigher pillow version support
Before this commit:
We used the .textsize method, which returned the height and width of the
icon. However, in the latest version of Pillow, this method was deprecated,
resulting in errors in the log.

After this commit:
We have transitioned to using the textbbox method, which returns the
coordinates of the top, left, bottom, and right of the text's bounding box.
From these coordinates, we calculate the height and width of the text.

task-3502373

closes odoo/odoo#140613

Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-26 09:13:01 +00:00
Romain Derie 97afd18f1e [FIX] web_editor: prevent en_US key to be missing from arch_db
Previous commit is fixing the code so that a view without `en_US` in
arch_db jsonb value won't make the code crash (`get_related_views`).

The commit before that actually improved the custom snippets so the
translations are forwarded to it when it's saved.
But that new code was introducing a way to have an arch without `en_US`
value, which led to the bug described above.

While the previous commit fixed the consequence of the issue, this
commit solves the root cause of the issue, introduced 2 commits before.

Arguably, this commit could be squashed in the one 2 commits ago, but
it makes things more clear to figure.

task-3375518

closes odoo/odoo#150945

X-original-commit: bf598d9098b4be36542a9a91c0dd1055cf36aed5
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2024-01-25 18:13:03 +00:00
Romain Derie 4fedd2a490 [FIX] web_editor: remove lang from ctx by poping it, not setting None
Since commit [1], the lang was removed from the context by setting it to
None.
In Odoo 16 and since jsonb, it's not correct, the lang should simply be
popped from the context.
Indeed, having `lang=None` in the context will not return any value when
reading the arch if the arch has no `en_US` default value.

The previous commit will make it so the translations will be forwarded
to custom snippets when saving a snippet. With that commit, the issue
described above will be problematic and lead to a crash.

There is probably other legit ways to reproduce the issue which are not
yet found as we don't really use non english DB often.

Step to reproduce (following previous commit):
- Create a db with french only and install website.
- Then enable dutch and add it on the website as second lang
- Drop a title snippet & translate it in the dutch version
- Save and go back to the main lang (fr)
- Drag & drop again this newly saved snippet (custom snippet)
- Save and to to dutch version
- Enter translate mode
-> A traceback will be shown, because `get_related_views` will fail on
   "empty etree document", because when in the stack doing
   `etree.fromstring(view.arch)`, it will fail since arch = ''.

Step to reproduce (without the previous commit):
- Remove the `en_US` jsonb key from a view, eg
  `update ir_ui_view set arch_db = (select arch_db - 'en_US' from ir_ui_view where id = 4) where id = 4;`
- Start odoo-bin in `shell` mode
- Do `self.env['ir.ui.view'].browse(4).arch` -> Will output the arch
- Do `self.env['ir.ui.view'].browse(4).with_context(lang=None).arch`
-> This will crash on record not found error.

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

task-3375518

X-original-commit: 9cb17bc9cb1490219d1488c99e419a84681ca121
Part-of: odoo/odoo#150945
2024-01-25 18:13:03 +00:00
Romain Derie 8255fd6bff [IMP] web_editor, website: keep custom snippet translations
This commit adds translation capability to custom snippets.
Before this commit, the custom snippet was not translate friendly:
1. Neither when saving a block as custom snippet
2. Neither when dropping a custom snippet into a page.

This was a known limitation for years. But now it's time to make it
work.

Step to reproduce (part 1):
- Enable french
- Drag & drop Title snippet in a page
- Translate the Title
- Save the block as custom snippet
-> Go in the backend view of this custom snippet, in debug, there is no
   translation that followed the title.

Step to reproduce (part 2):
- Following previous steps, now add the translation manually on the
  custom snippet view
- Back in a page in edit mode, drag & drop this custom snippet in the
  page
- Switch to french
-> The title is not translated, the drag & drop copy code but no
   translations

Those are the "page/view" to "page/view" translation transfer, but it
could also be any html field (like a product description) to view
(custom snippet) or view (custom snippet) to any html field.

task-3375518
opw-3242100

X-original-commit: 2bd6c1a8d653453692211eef0f5d46a0047eb6f2
Part-of: odoo/odoo#150945
2024-01-25 18:13:03 +00:00
3fecca569c [FIX] web_editor: properly convert px to rem based on correct doc
Commit [1] introduced a responsive font size feature was. Following
this, in the context of mass mailing, an issue arises when users select
a font size from the toolbar dropdown. Specifically, the
`_computePxByRem` function converts the `px` value selected by the user
to the wrong `rem` value. This is because it relies on the font size of
the `html` element of the main window's document rather than that of the
iframe's document. Since the iframe's document has a font size of 14px
where the main document has a font size of 16px, the conversion was
faulty. Also, the value was cached on the window object, which is common
to both documents. So this commit moves that cache to the document so
two different values can be stored.

[1]: https://github.com/odoo-dev/odoo/commit/ddf25a16c46bfc3628512aba1390a1e345ec719a

task-3653543

closes odoo/odoo#147685

Signed-off-by: Antoine Guenet (age) <age@odoo.com>
Co-authored-by: Vishal Padhiyar <visp@odoo.com>
Co-authored-by: Dieleman Guillaume <gdi@odoo.com>
2024-01-25 15:24:57 +00:00
shsa-odoo 982ccb58b1 [FIX] web_editor: emojipicker doesnot close on click
Before this commit:

On clicking the saame paragraph while emojipicker is open, it doesnot close,
 resulting in multiple emojipicker being opened at the same time.

After this commit:

Now onclick away from emojipicker on the same paragraph emojipicker closes.

task-3555717

closes odoo/odoo#151038

X-original-commit: be671cce046a72402d1746917b4b5b8715ba1d41
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
Signed-off-by: Sanjay Sharma (shsa) <shsa@odoo.com>
2024-01-25 13:42:49 +00:00
Adnan Saiyed f0e20c676a [FIX] web_editor: clear format missing from editor toolbar
Current behaviour before commit:

In v16.0 and above clear format button was missing from
snippet toolbar.

Desired behaviour after commit:

Now clear format button is getting appeared in snippet
toolbar.

task-3638147

closes odoo/odoo#150620

X-original-commit: 701bbe40554ea9b6867171a755124fe5b635988b
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-25 13:42:47 +00:00
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