Commit Graph
4390 Commits
Author SHA1 Message Date
Rodolpho Lima c74d01279e [IMP] web_editor: add document parameter to parseHTML
This commit changes the public `parseHTML` utility function's signature,
in order to allow the use of the editor's document to create a document
fragment.

This aims to avoid mismatches in the prototype chain of HTML elements
created by such util and the ones present in the editable when the
editor is mounted in an iframe. This is of particular relevance for the
'insert' command, in which the node to be inserted is tested for
`instanceof` the editor's document global `Node` object.

task-3526134

closes odoo/odoo#136984

Related: odoo/enterprise#48108
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-02 08:03:44 +00:00
Benoit Socias f35de1bd5a [FIX] web_editor: only pre-convert webp images when within image fields
Since [1] when webp support was introduced, pre-converted images
(resizes and jpgs) are automatically created so that the images can be
used in PDF reports.
This only needed to be done for image fields - which can be referenced
in reports.

This commit limits the pre-conversion of images to images that are set
in image fields.

[1]: https://github.com/odoo/odoo/commit/0449fe85cb0e1d639a4e1aeba26e90906f79254d

task-3510621

closes odoo/odoo#137109

X-original-commit: cd0164339e5179177aaaf21b69615a71a8982da8
Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
2023-09-29 14:48:18 +00:00
Rodolpho Lima bfe0c5fedf [FIX] web_editor: use Node from editable's document
Steps to reproduce:
- In website, paste a URL like "odoo.com" as plain text.

The expected result is a transformed link, just like it happens when
pasting is done in an html field (ex: project.task description), but
a simple text node is inserted instead.

The reason for this is that an element created by the iframe document's
`createElement` method has in its prototype chain the iframe context's
global `Node` constructor, which is a distinct constructor object from the
main window's `Node` constructor.

task-3521152

closes odoo/odoo#136597

X-original-commit: 392d78dab632f67721ec2ba8810d5c8053640b86
Related: odoo/enterprise#48136
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-29 14:48:14 +00:00
Rodolpho Lima 5f89007b1c [FIX] web_editor: save image as attachment in forms
Before this commit, when the Wysiwyg was used in a html form (like
website_forum), its `savePendingImages` method was not called. This
resulted in keeping pasted or dropped images as base-64 encoded sources
instead of converting them to attachments.

This commit ensures such conversion takes place.

task-3499058

closes odoo/odoo#137073

X-original-commit: 00aad6aa92c8ad476f9f78779b7a24cb5f7af2ff
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Rodolpho Cammarosano de Lima (rcdl) <rcdl@odoo.com>
2023-09-29 13:11:53 +00:00
shsa-odoo 9e2f0edba5 [FIX] web_editor: apply font size on selected cells
Before this commit:

-Font size does not get applied to selected cells.
-Font style buttons were active when cells are selected.

After this commit:

-Font size can be applied.
-The font styles should not all be toggle by default.

task-3477490

closes odoo/odoo#137080

X-original-commit: 1d20abfbfd9f337f356c5a237edc713fb973b636
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Sanjay Sharma (shsa) <shsa@odoo.com>
2023-09-29 11:59:05 +00:00
abd-msyukyu-odoo e657831f5a [IMP] web_editor: add preserveCursor callback return value
By returning the `setSelection` value in the callback returned by the
`preserveCursor`, we allow better control for the caller over the fact that the
selection was effectively restored or if it failed.

task-3383561

closes odoo/odoo#126340

Related: odoo/enterprise#43087
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-09-29 11:58:58 +00:00
Benoit Socias 262a05931c [FIX] web_editor: replace extension of webp converted images
This commit replaces the `.jpg`, `.jpeg` or `.png` extension of uploaded
images to `.webp` when the image is converted to webp.

task-3460171

closes odoo/odoo#137022

X-original-commit: 77624c9eafc7f21a2ec5edcd3d56ee76e646fc38
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-09-29 09:21:55 +00:00
Soukéina Bojabza bd3e0030d0 [FIX] web_editor: make loadImageInfo robust to absolute URLs
This commit makes the rpc call in the `loadImageInfo` method robust to
the case where an image src would be an absolute URL, by only
considering the relative part of the URL.

The images src are generally always relative but commit [1] wrongly put
absolute URLs to images in grid mode with the `_reloadLazyImages`
method. While this behavior was fixed by commit [2], the images that
were saved before this fix was available still have an absolute URL.
Hence the need to make `loadImageInfo` robust.

[1]: https://github.com/odoo/odoo/commit/cc406afcea7bf5846233a9f97a4a8ac5f618f3ec
[2]: https://github.com/odoo/odoo/commit/3528f2c3f9d3b30266f3421672986d202c724a76

task-3514519

closes odoo/odoo#136951

X-original-commit: af5ddabb0285daa9e57bc01cf21628f2f94bc18f
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-09-29 09:21:54 +00:00
Rodolpho Lima 82ba5791f0 [IMP] web_editor: unify behaviour for http protocol
LinkTools creates http links by default, while OdooEditor creates https
links by default on paste and auto link transformation with SPACE.

This commit standardizes the result of both mechanisms, adopting "http"
as the default protocol.

task-3516854

closes odoo/odoo#136487

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-29 09:21:52 +00:00
Rodolpho Lima 69a27360c9 [IMP] web_editor: omit protocol in URL input field
Before this commit, when an existing link was edited with the LinkTools
or LinkDialog, the URL input field omitted the "mailto:" part of the URL
for email links, but displayed the protocol/scheme for http(s) links and
phone numbers (tel: or tel://).

This commit standardizes the behaviour of the referred input field such
that the protocol/scheme for http(s), mailto and tel URLs are omitted,
in order to have a cleaner UI.

task-3516854

Part-of: odoo/odoo#136487
2023-09-29 09:21:52 +00:00
Rodolpho Lima 6d4a3b3ab5 [IMP] web_editor: deduce phone URL in Link(Tools/Dialog)
When creating or editing a link via the LinkTools or LinkDialog, http
and email URLs can be deduced from incomplete user inputted URL (that
is, URLs not containing the http(s):// or mailto: protocol).

This commit extends such URL deduction to telephone numbers, allowing
the user to create a tel:// link without the need to explicitly write
"tel:" or "tel://".

Obs: "tel//:" protocol is preferred over "tel:" for the reasons stated
in [this] commit.

[this]: https://github.com/odoo/odoo/commit/56ce29e71f75a657d4b518d86c1d7084891e898e

task-3516854

Part-of: odoo/odoo#136487
2023-09-29 09:21:52 +00:00
mano-odoo 5e1dc71680 [FIX] web_editor: fix the design of active shape in selection menu
The border radius on an active shape in its menu was making a weird
gap between the element and its border. This commit fixes this gap by
using an outline on the active state.

task-3503975

closes odoo/odoo#136871

X-original-commit: 0c4816e1b4996b6e3048b3061c6e2cff06eeb499
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-09-28 10:22:09 +00:00
mano-odooandbvr-odoo 838564e0ac [FIX] web_editor: fix colorpicker margin and dropdown UI
The negative margin used for the colorpicker was creating a weird
spacing when we use the oval shape image or if we have a button group
without the colorpicker. This commit adapts the margin on the element
itself by overriding it with an !important instead of relying on a
negative margin.

The dropdown caret from the colorpicker dropdown was misaligned, it
happened because the default CSS rule for we-select had priority due
to more specific selector. This is fixed by making the selector more
relevant to take priority over the default rule.

task-3503975

X-original-commit: 2f81c6ae68751d5f93c30aef822730ee04ead391
Part-of: odoo/odoo#136871
Co-authored-by: bvr-odoo <bvr@odoo.com>
2023-09-28 10:22:08 +00:00
Jinjiu Liu 6adab9556a [FIX] web_editor: link is added inside a br element in chrome
Reproduction:
1. Create a link right after some text
2. Remove the whole line by backspace character by character(this should
give the p element a history steps id)
3. Try to create a link again
4. The new link is invisible and actually created in br when inspecting
the page

Reason: this is an edge case on Chrome that the document.getSelection()
returns a selection which has br element as the anchorNode. It may
happen when the parent element of the br has history steps and only has
this br element. However, the same steps done on Firefox return the
correct selection on the parent element.

Fix: we make a special case when the selection is a caret type and the
anchorNode is a br element, we re-select the parent element and collapse
the selection to the start. This is trying to mimic the normal case of
adding a link to an empty p element, e.g selection anchorNode is p,
offset is 0.

task-3181486

closes odoo/odoo#136879

X-original-commit: 084ac2a375224288f182961ff98915dbeb428bd6
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Jinjiu Liu (jili) <jili@odoo.com>
2023-09-28 07:50:08 +00:00
dhba-odoo 367ec827fe [FIX] web_editor: shift paste of vs code content looses indentation
Before this commit:

when performing a shift paste of copied VS Code content, the indentation was
lost.

After this commit:

Now, when you perform a shift paste of copied VS Code content, the indentation
is preserved

Task-2884491

closes odoo/odoo#136867

X-original-commit: 1641bb50aa30ac64340eb261b26d4706944299ba
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-28 07:50:07 +00:00
dhba-odoo 349bab3f45 [FIX] web_editor: clear format not working properly
Before this commit:

The text moves back to the left side on remove format even if the direction rtl
is applied.

After this commit:

The text will not move to the left side on remove format if the direction rtl is
applied.

task-3482193

closes odoo/odoo#136849

X-original-commit: ff955e2cf74189a7cd4b175e8edfe5cfc8f31821
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-28 07:50:05 +00:00
Jinjiu Liu ad95834434 [FIX] web_editor: clean up data-bg-src attribute for Gmail clipping
Reproduction:

1. Install mass mailing
2. Create a mailing with multiple Cover blocks, and replace each
background image by uploading one. In the inspector, you should find the
`data-bg-src` attribute
3. Send the mailing to a Gmail account (or check the sent email on a
local odoo instance), the email is with the long `data-bg-src` attribute

Fix: The fix is put into the existing flattenBackgroundImages function
because the background images are selected and `data-bg-src` is for the
background images. It simply removes this redundant attribute

task-3484103

closes odoo/odoo#136837

X-original-commit: b43d3c091c7f590bb8128dfc922345ad4dbb13dd
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Jinjiu Liu (jili) <jili@odoo.com>
2023-09-28 06:46:07 +00:00
Nicolas Bayet 1d70293093 [REF] web_editor: move handle_history_divergence in tools.py
As `handle_history_divergence` is not used in the controllers, it makes
no sense to have it in `controllers/main.py`.

task-3217965

closes odoo/odoo#136277

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-27 14:57:13 +00:00
Nicolas Bayet 1eb32c94b4 [REM] web_editor: remove route /web_editor/ensure_common_history
As the route is not used anymore, remove it.

task-3217965

Part-of: odoo/odoo#136277
2023-09-27 14:57:13 +00:00
Nicolas Bayet 2d05f703d7 [FIX] web_editor: strengthen collab stale detection & recovery
Before this commit, the stale document detection was imprecise and
incomplete.

The stale document could happen in different scenario:
1)  Client B save when client A is disconnected (therefore client A
    should be notified that the document is stale upon reconnection):

    - For that scenario, the code had a heuristic to detect if the
    internet connection disconnected and reconnected but was imprecise
    as the browser api is not 100% reliable on all browser and
    platforms. That made the code under-checking or over-checking with
    the server.

2)  The user has not yet focused on the element and before this
    commit, the stale document was not detected.

3) If there is a partition in the peer to peer network and a member of
   another partition that save, all other partition will not be aware
   that they are working on a stale document.

4) The stale document happen before 2 peers could be fully connected.

For any of those scenarios, if a stale document was not detected and
the user tried to save changes, only then, a popup would inform that
the version was stale. And if the user closed the tab thinking the
document would automatically save, the change would not be saved
(without warning).

This commit:
1) improve detection of stale document
To detect the document this commit add a message in the odoo bus.bus
for the channel of the record for each write. That will ensure the
message to be received as soon as a user is connected to odoo.

2) improve recovery from stale document
Before this commit, the recovery was only made from the server.

As a detection is now direct (rather than delayed by the previous
heuristic), a document could be detected stale before receiving a step
that would not make it stale. Therefore, we cannot just reset from the
server as a recovery mechanism.

To recover, this commit first tries to reset from missing steps from
all peers. If unsuccessful, it will tries to reset from a snapshot. If
unsuccessful, it will reset from the server.

3) add a mechanism for aborting requests
To prevent unexpected concurrency behavior, this commit add a mechanism
to abort requests.

4) a framework for testing the collaboration of the wysiwyg
As it could be quite tedious and error prone to manually tests
concurrency issues related to the wysiwyg, this commit add a framework
for testing the collaboration of the wysiwyg and test the detection
and recovery of stale document.

task-3217965

Part-of: odoo/odoo#136277
2023-09-27 14:57:13 +00:00
Nicolas Bayet 804b824f8a [FIX] web_editor: move _getNewPtp out of a closure
In a subsequent commit, we need to change the content of the method
`_getNewPtp` and to patch it in tests.

To make that commit more readable by understanding which lines
changed, this commit moves the creation _getNewPtp to the Wysiwyg
prototype rather in a closure.

task-3217965

Part-of: odoo/odoo#136277
2023-09-27 14:57:13 +00:00
luvi b91f4034ab [IMP] *: improve documentation of options in fields metadata
*: analytic,  base_automation, loyalty, mass_mailing, project, web, web_editor, website

This commit adds many new documentation of options and their usage for
fields. This makes them more usable and customizable in Studio, and adds
documentation for developers to know the type of expected option.

Some options that might lead to issues or that are too technical have
been removed, as they are not relevant and not required in most use cases.

task-3469741

closes odoo/odoo#134858

Related: odoo/enterprise#47148
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-09-27 14:57:03 +00:00
Michael (mcm) 7422eb643c [IMP] *: remove legacy rpc
This commit removes the files ajax.js and rpc.js then adapts all the
places where their exports were used. For most of the changes, it's a
replace of `this._rpc({...})` by a new `useService("rpc|orm")` like
pattern in the widgets.

closes odoo/odoo#136271

Task: 3439226
Related: odoo/enterprise#47775
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-09-27 11:33:01 +00:00
shsa-odoo 78d945dd81 [FIX] web_editor: remove toolbar on selection change
Before this commit:

-On selecting fullscreen/description for image toolbar stays.
-On selecting description for image focus in not set on input field.

After this commit:

-Now toolbar is removed when selection changes.
-Now on selecting description for image, focus is set on input field.

task-3468251

closes odoo/odoo#136466

X-original-commit: 210230f972c4468c3f472509adb25dfc87d4c2b2
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-26 09:32:35 +00:00
shsa-odoo 22ceb76560 [FIX] web_editor: update toolbar on list uncheck.
Before this commit:

-With selection on checklist, on unchecking it toolbar is not updating.

After this commit:

-Now toolbar is updated when list unchecks.

task-3504398

closes odoo/odoo#136541

X-original-commit: 2cf3dd5988914a09bbc2098eccb3c8419995e120
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-25 18:09:58 +00:00
Deependra Solanki f3cc75bac6 [FIX] web_editor: list indentation in table
Before this commit:

Indenting list using tab inside a table used to switch to the next cell.

After this commit:

Indenting list using tab inside a table now indents a list instead of switching
to the next cell.

task-3470092

closes odoo/odoo#136538

X-original-commit: 62c16468e2759eb0a0c3eecf3866b543be3bfabb
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-25 18:09:57 +00:00
shsa-odoo 856149776e [FIX] web_editor: remove toolbar on selection collape in table
Before this commit:

when selected cell is clicked, its selection collapses yet toolbar is visible.

After this commit:

Now toolbar is removed when selection collapses.

task-3458048

closes odoo/odoo#136533

X-original-commit: 89116f6f356df0b33ba61f8b2e725ae7530bdceb
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-25 18:09:55 +00:00
Rodolpho Lima e5c1a19858 [FIX] web_editor: toolbar in website forum
Steps:

In a website forum post without any previous scrolling, select some
text. A traceback appears due the fact that there's no .o_action_manager
element in website forum.

This commit uses the document body as a fallback for the scroll
container when the .o_action_manager element is not present.

task-3506312

closes odoo/odoo#136508

X-original-commit: fc6f66f179798a731489a6a3e73af0d37af27f7d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Rodolpho Cammarosano de Lima (rcdl) <rcdl@odoo.com>
2023-09-25 17:11:33 +00:00
abd-msyukyu-odoo 74013202c6 [FIX] web_editor: ctrl+a container should be an element
If somehow there is no selection but the `_handleShortcuts` handler still gets
called with `CTRL+A`, `container` would be a JQUERY object instead of an
element leading to a crash in `selectNodeContents` which expects a `Node`.

task-3506666

closes odoo/odoo#136499

X-original-commit: e6fac045282465960c0e4a7ecbbbb5e5ac8dff92
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Damien Abeloos (abd) <abd@odoo.com>
2023-09-25 15:20:26 +00:00
Rodolpho Lima 196cf4a7ce [FIX] web_editor: update UI on link content change
When changing a link's content, its URL (href attribute) might change
(if the new label is a valid URL), due to a mechanism in OdooEditor.

Before this commit, when a change in the link's content leads to a href
change:
- if the LinkTools is opened, the URL input field would become outdated
and display an incorrect URL.
- likewise, if the popover is shown, its content and position would be
outdated (possibly covering the link's new content).

This commit makes sure both the LinkTools URL input field and the
popover stay up-to-date if a link's content or href changes.

task-3284649

X-original-commit: 1b0952f3635f5677ba3ab221a28ceb26920a1862
Part-of: odoo/odoo#136278
2023-09-25 11:30:13 +00:00
Rodolpho Lima e881bc6284 [FIX] web_editor: Link(Dialog/Tools) label input field
Before this commit, any changes made to label input field were lost when
the LinkDialog or LinkTools component was re-rendered.

This commit fixes it without leveraging OWL's reactivity/declarative
approach, because most of the code in these components is imperative and
not yet converted to the OWL paradigm, leaving such refactor to be done
in the master branch.

Part-of: odoo/odoo#136278
2023-09-25 11:30:13 +00:00
Rodolpho Lima 7fe1731c66 [FIX] web_editor: update link content on URL change
If a link's content is equivalent to its URL, two problems can arise
when its URL is changed via the LinkTools:
- The link's content becomes outdated, showing a different URL;
- On LinkTools destroy, the OdooEditor mechanism that updates a link's
href on label(content) change will update the href according to the old
label, effectively reverting the changes in the URL.

This commit avoids such issues by syncing the label with the URL input
field in such cases.

task-3284649

X-original-commit: 8ddcc08c1700151e697ecb3c0c1daec2db9f8fd2
Part-of: odoo/odoo#136278
2023-09-25 11:30:13 +00:00
Rodolpho Lima b622dba6db [FIX] web_editor: 'mailto' to 'http' link conversion
Before this commit:
- URLs like "domain.com/@/page" were incorrectly detected as an email
URL by Link(Dialog/Tools),
- switching from an email URL to a http URL with the Link(Dialog/Tools)
was not possible (URL remained prepended with "mailto:").

This commit improves email detection from simply looking for a "@" to
something slightly more robust, and makes switching between 'http'
and 'mailto' links possible.

task-3284649
opw-3245501

X-original-commit: e849ff4333355386dfb79bc574c93c76ed3e2d3b
Part-of: odoo/odoo#136278
2023-09-25 11:30:13 +00:00
Rodolpho Lima 02add8e5de [FIX] web_editor: auto transforming email URL
Typing a URL + SPACE transforms the URL into a link.

Before this commit, email URLs were incorrectly prepended with
'https://'.

Because it is not desirable to automatically transform email URLs, this
commit disables link transformation for email URLs, leaving it only
active for http URLs.

task-3284649

X-original-commit: ad0e7845fceb578398e42e4b35820c415734452a
Part-of: odoo/odoo#136278
2023-09-25 11:30:13 +00:00
Rodolpho Lima 832b945837 [FIX] web_editor: link update on label change
OdooEditor has a mechanism to update a link's href on label change, if
the new label is a valid URL.

Before this commit, there were two issues:
1. it did not work for email links. In fact, because this mechanism was
incorrectly prepending email URLS with 'https://', [1] disabled it for
'mailto:' links.
2. when a link had a 'http' href but its label did not contain the protocol,
upon label change (into a valid URL) the link had its href changed to 'https'.

This commit:
1. re-enables the auto update mechanism for email links and fixes it, so
that it can correctly update both http and mailto links.
2. fixes the 'http' to 'https' coercion issue, making sure the current
protocol is kept when updating http(s) links.

task-3284649

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

X-original-commit: 6740e2821c51897baa110e9e4129b40c403e000c
Part-of: odoo/odoo#136278
2023-09-25 11:30:13 +00:00
Rodolpho Lima 5f7c4dda1d [FIX] web_editor: persist URL-like text transformation to link
Commit [1] separated the two responsabilites of _onURLInput: making
changes to the DOM and updating the UI, taking care that only the second
one is done at start.

But this broke the following functionality:

- Have a URL-like text (ex: odoo.com), select it and click the link icon
on the sidebar.
- The URL is deduced from the link's label.
- Click anywhere to close the sidebar.

Before [1], the link transformation would be kept. After it, it is not.
This happens because this is a particular case in which we want to apply
changes to the DOM at start time, as if a URL input event had happened.

This commit fixes it.

task-3284649

[1]: 54746012d3

X-original-commit: da0a3f34401547478107945626034d7932855f02
Part-of: odoo/odoo#136278
2023-09-25 11:30:13 +00:00
Rodolpho Lima 37ac0ba83d [FIX] web_editor: toolbar setup in website
Before this commit, the setup actions performed by _configureToolbar
were missing for the website toolbar. This resulted, among other things,
in non-responsive buttons like create link or insert media.

Part-of: odoo/odoo#136278
2023-09-25 11:30:13 +00:00
Adnan Saiyed 859714e5f6 [FIX] web_editor: traceback when clicking button in table
Current behaviour before commit:

In table, when clicking table menu icon it throws
traceback.

Desired behaviour after commit:

Now, clicking table menu icon opens table menu
without any traceback.

task-3503806

closes odoo/odoo#135324

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-25 09:38:32 +00:00
hmai 8dfe8a8c6c [FIX] web editor: color of whole cell should change
This commit fixes the issue of partial coloring of table cells.

Before this commit, if one colors part of the text in the cell
and then seeks to color the whole cell, the last coloring
would not apply on the previously colored text.

We do that by preventing the cell coloring to be done differently
than other elements except if we want to change the
background color.

Task-3454903

closes odoo/odoo#130646

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-25 09:38:31 +00:00
abd-msyukyu-odoo 576afb3f27 [FIX] web_editor: reset MoveNodePlugin when switching record
How to reproduce:
- open a record with an html_field (i.e. todo or a Knowledge article)
- switch back and forth with the pager or the knowledge sidebar between 2
  records

Current behavior:
- traceback `this._elementHookMap.get(element)` is undefined

Expected behavior:
- no traceback

Technical explanation:

When changing the editable content (i.e. `resetContent` when changing record),
there is no guarantee that `_intersectionObserverCallback`
(intersectionObserver) won't be called before `_updateHooks` (mouseMove/resize
after a mutation occured).

This is an issue because `this._elementHookMap` may not yet have a hook element
related to the editable element which stops intersecting the document.
If such a case occurs, the next `_updateHooks` should be called when the
mutationObserver flags `_resetHooksNextMouseMove` to `true` and then after the
next `mouseMove`  (or after the next resize).

Ignore the hook style update if there is currently no hook for an element which
stops intersecting.

Remove a redundant check in `_getMovableElements`

task-3506666

closes odoo/odoo#135464

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-22 15:06:02 +00:00
Jinjiu Liu dfeb387b0e [FIX] website: suggest links breaks rpc
Reproduction:
1. Install website
2. Change to edit mode and edit a link on the main page, for example,
“contact us” at the bottom
3. When you replace the link with /, the rpc breaks and no suggested
links returned

Fix: this issue is gone with a recent update on master, now the rpc used
by linkTools is the new rpc

Task-3444671

[FIX] web_editor: restore double click focusing on URL when editing link
Reproduction:

1. Install website
2. Change to edit mode and edit a link on the main page, for example,
“contact us” at the bottom
3. The focus is on the url at the link tool

Fix: The desired behavior when clicking on links in editing mode is: one
click, edit the text of the link; double click, focus on the URL in link
tools. After converting to OWL, focusing on URL is handled by props, e.g
. `shouldFocusUrl`. We also need to update the state of this prop in
`toggleLinkTools` as we did before conversion.

Task-3444671

Forward-Port-Of: #132167

Also added fix for using the new rpc function instead of the legacy one,
edited the test accordingly.

Part-of: odoo/odoo#135371
2023-09-19 16:37:15 +00:00
Rodolpho Lima 26f447a072 [FIX] web_editor: missing record info for converted images
When the Wysiwyg is used by website, multiple editable elements are
possible, and each of them carry the related record's model and id in
the element's dataset.

On the other hand, when the Wysiwyg is used by the html field, there's
only one root editable element, and such information is not present in
the editable's dataset, but in the widget's options object.

Before this commit, when saving the content of an html field, modified
images were converted to attachments without the correct reference to
the record's model and id.

This commit makes sure that such information is passed to the route that
handles attachment creation.

task-3495668

closes odoo/odoo#135806

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2023-09-18 23:31:39 +00:00
Rodolpho Lima 00701977ad [FIX] web_editor: skipped image conversion to attachment in HtmlField
Commit [1] added a check for the closest ".o_dirty" editable element in
order to define which editable is used for obtaining the model and id
reference from its dataset, and also to avoid multiple attachment
creation for the same image.

But such check for the closest ".o-dirty" element evaluates to null when
the Wysiwyg is used by the HtmlField component, as such class is not
added to editable when saving/committing changes. This resulted in
skipping the attachment creation for pasted, dropped or modified images.

After this commit, attachment creation for modified images is not
skipped if an element with the ".o_dirty" class does not exist.

task-3495668

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

Part-of: odoo/odoo#135806
2023-09-18 23:31:39 +00:00
Benjamin Vray b9c0d9f780 [FIX] web_editor: fix oi icons css for editor panel
Since the commit [1], some Font Awesome icons have been replaced by 'oi'
icons in the editor panel. This has resulted in a situation where both
'fa' and 'oi' icons coexist.

These changes have caused two issues in the editor panel:

- The icons in the two buttons used to flip a background shape are no
longer centered within their buttons.

- When a row of buttons contains a mix of 'oi' and 'fa' icons, all these
buttons no longer have the same width. This issue was identified in
Master when new options for flipping/rotating an image shape were
introduced (see this commit [2]). Even though this bug may not be
visible in version 16.3, it is still necessary to address it here since
any potential changes could reveal this bug.

This commit resolves these issues by adjusting certain parts of the CSS
code of the the editor panel to handle 'oi' icons in the same way as
'fa' icons for these two specific cases.

[1]: https://github.com/odoo/odoo/commit/418413e4997a6b65eb7ad9e9ef8aba42805f1c0c
[2]: https://github.com/odoo/odoo/commit/fbb395021da5e8ba115d36dfd683f8576a74bf80

task-3493051

closes odoo/odoo#135330

X-original-commit: 3729cf6ab4261a29431ef05fcb7cc33ba5e3ad5a
Signed-off-by: Outagant Mehdi (mou) <mou@odoo.com>
2023-09-15 09:22:07 +00:00
Arthur Detroux (ard) 26218171a8 [FIX] web_editor: fix images getting absolute URLs in grid mode
[1] introduced the grid mode and with it a util that reloads lazy
images in order to prevent a bug in Chrome which make images disappear.

This util read the .src property of the image element. That property is
the absolute URL.
In order to keep the exact URL that was on the img attribute, one needs
to use "getAttribute".

This commit does exactly that.

Steps to reproduce:
- Drop a Image - Text snippet
- Drag the image to enter grid mode
=> At the same time the image is reloaded with the wrong src

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

closes odoo/odoo#135392

X-original-commit: 3528f2c3f9d3b30266f3421672986d202c724a76
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-09-14 20:34:54 +00:00
Sébastien Geelen (sge) 639a2b2296 [FIX] web_editor: open DPH in mail template
The Dynamic placeholder was not opening properly in mail template since the wysiwyg OWL conversion.

Fix it and also fix the tour that should have detected this error.
The tour itself was not running properly.

task-3495254

closes odoo/odoo#135275

X-original-commit: df8532cffc74038db0faef36b5f43758e1bbdf43
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
2023-09-14 11:22:50 +00:00
hmai 573c59cad2 [FIX] web editor: animation triggered on every backspace
This commit fixes the issue of animations that got trigger by backspacing, pressing enter
and other causes

The cause of the issue was a custom historyRevert event that was only used to
trigger a widgets_start_request event which ended up restarting the options,
which lead to the animation option replaying the animation.

We were not able to pinpoint the use of this particular trigger_up as it does
not seem to serve any purpose anymore. Since its presence does create a bug, we
decided that the best course of action was to remove it. If this commit creates
a regression and the original bug comes back, we will reassess the situation.

Task-2752421

closes odoo/odoo#135332

X-original-commit: cef24b89405205ee0484555209e59a8599d9deb2
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-13 15:34:42 +00:00
Julien Banken 95e6d0199b [FIX] web_editor: video selector component adjustments for Knowledge
This commit will apply the following changes:
1. Introduce a new `VideoIframe` component for the `VideoSelector`
   component. With that change, one can easily mock the `VideoIframe`
   component in a tour and replace the iframe of the video with
   alternative content. It will then be possible to test the whole video
   integration flow with a tour without relying on Third-Party services.
2. Enhance the Python video parser to include the video id and the video
   parameters of the url being parsed. These new information will be
   used for the new video behavior of Knowledge.
3. Call the callback function notifying that the video url has changed
   when the textarea is emptied (see: `selectMedia`).
4. Authorize non-internal users to call the /web_editor/video_url/data
   route. This will ensure that portal users will be able to integrate
   videos in their Knowledge articles.
5. Apply some minor UI and UX adjustments:
   - The label next to the toggle buttons will now be properly aligned.
   - The textarea to input the video url will be automatically focused.

task-3297215

closes odoo/odoo#127452

Related: odoo/enterprise#40683
Signed-off-by: Damien Abeloos (abd) <abd@odoo.com>
2023-09-13 15:34:27 +00:00
hmai f567a8ef8a [FIX] web_editor: clear format button always visible
This commit makes the clear button of the toolbar always visible
even if no style is applied.

Since the display is controlled by the css, we removed the concerned
style.

Task-3459819

closes odoo/odoo#135293

X-original-commit: 78d3e1c327e81a1fddbe068860eeec498af29b89
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-13 13:49:37 +00:00
Rodolpho Lima d72e471e5f [FIX] web_editor: extra history step on image paste
Before this commit, when pasting or dropping an image, the insertion of
the image element to the DOM and the addition of the
"o_b64_image_to_save" class to it were recorded in two separate history
steps. This commit makes sure they are both recorded in a single step.

Additionally, the dataset was removed from the image element by the
(unnecessary) call to _prepareClipboardData. This resulted in losing the
file name information, which is useful when converting the image into an
attachment.

Before this commit, the "width: 100%" addition to the image's style
attribute had no effect, as it was later removed by the call to
_prepareClipboardData. In fact, the class "img-fluid" sets "max-width"
to 100% instead, which is offers desirable behaviour.

task-3497880

closes odoo/odoo#134832

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-09-13 13:49:36 +00:00