Commit Graph
3305 Commits
Author SHA1 Message Date
Damien Bouvy 7470797be7 [IMP] base,**: rewrite some error messages
Maintain the playful tone whilst avoiding nonsensical phrasing.

I will not take comment at this time, thank you.

Task-🤔🙃😬💅😐🤓

closes odoo/odoo#138302

Signed-off-by: Bouvy Damien (dbo) <dbo@odoo.com>
2023-10-11 06:59:49 +00:00
Kartik ChavdaandKamlesh Pathekar e3bc974ea4 [IMP] base,** : make error message user friendly
Before this commit error messages in odoo are boring and
not much attractive to user. Those were like odoo is preventing
them from doing something user want to do.

In this commit, we have modified the message to be a more friendly
and humorous tone, making it less tedious and more enjoyable. It
aims to enhance the user experience and ensure that interactions
with any application are both pleasant and informative. As a result,
the messages have been clear, short, easy to understand and informative.

task-3356114

Part-of: odoo/odoo#124820
Co-authored-by: Kamlesh Pathekar <kpt@odoo.com>
2023-10-10 12:34:56 +00:00
Odoo 7f35c48ef5 [FIX] web_editor: strange padding when background color is reset
Before this commit:

On applying background or on remove background color, strange padding
is added on the text.

After this commit:

Now, padding is not added when background is colored is applied or background
color is removed.

task-3237693

closes odoo/odoo#138143

X-original-commit: 29a40a30f3bf7a4a3a205e54fb84e569691d961f
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-10 09:42:17 +00:00
Romeo Fragomeli 5f454f0ccb [IMP] web,web_editor,website_slide: sortable service for frontend usage
This commit removes the module sortable from jQueryUI and adds instead a
sortable service to use the sortable code already used by the backend.

The service can be called using `this.call("sortable", ...)` and the
sortable listeners are added when the `enable` function is called.
This function (`enable()`) returns an object that contains the `cleanup`
function (`cleanup()`).

```javascript
// start / setup
const sortable = this.call(
    "sortable",
    "create",
    {
        ref: { el: document.querySelector(".list") },
        elements: ".items",
        handle: ".drag-icon",
    },
);

// on attach callback / on mounted
const sortableInstance = sortable.enable();

// on destroy / on willUnmount
sortableInstance.cleanup();
```

Also, it adds some new property to the useSortable:
* clone: the placeholder is a clone of the drag element
* placeholderClasses: classes added to the placeholder element
* applyChangeOnDrop: on drop the change is applied to the DOM
* followingElementClasses: classes added to the element following mouse

task-3439226

closes odoo/odoo#137527

Related: odoo/enterprise#48371
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2023-10-10 01:59:35 +00:00
shsa-odoo f5fe01a60f [FIX] web_editor: banner drag issue
Before this commit:

-Banner on drag and drop only drops content.
-Content inside banner were draggable.

After this commit:

-Now we can drop banner as well.
-Prevented content inside banner to be draggable.

task-3512199

closes odoo/odoo#136003

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-09 13:25:26 +00:00
vishal padhiyar 3c89439a16 [FIX] web_editor: calling openMediaDialog on replace media
Before this commit:

In mass mailing, Selecting image and click on replace media you get picture
middle of the screen.

After this commit:

Now, clicking on replace would open media dialog and replace picture.

task-3506590

closes odoo/odoo#137920

X-original-commit: 7e0b8af005e818c9283b332fb140aeaeaf028275
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-09 10:48:49 +00:00
stefanorigano (SRI) bf2416723a [IMP] web_editor: tweak lightness limit of increase-contrast
Increases the function's maximum lightness amount from 15% to 20%.
The new value is still arbitrary but provides better results with the
default color palette.

task-3097005

Part-of: odoo/odoo#120302
2023-10-08 10:45:45 +00:00
stefanorigano (SRI) 43fee86c79 [IMP] web_editor: improve headings color for second color combination
This commit replaces the default cc2's headings color. The aim is to
avoid misunderstandings between clickable and not-clickable titles.

task-3097005

Part-of: odoo/odoo#120302
2023-10-08 10:45:45 +00:00
stefanorigano (SRI)andBrieuc-brd 8175268a53 [IMP] website, *: set light background on every input
*: web_editor

This commit applies the light color on inputs to keep consistency with
the default theme redesign. That color is now customizable as it is
linked to o-color-3.

task-3097005

Part-of: odoo/odoo#120302
Co-authored-by: Brieuc-brd <brd@odoo.com>
2023-10-08 10:45:45 +00:00
Brieuc-brdandqsm-odoo fbe38fb41d [FIX] website: solve some snippets color issues
Prior to this commit, some snippets used colors that were not changed or
were not visible (white text on white background) depending on the color
preset, which created color issues.

This commit adapts colors to make elements readable and maintain
consistency with the theme design.

Note: this could be partially backported (with stable adaptation) later.

task-3097005

Part-of: odoo/odoo#120302
Co-authored-by: qsm-odoo <qsm@odoo.com>
2023-10-08 10:45:45 +00:00
0d96be06fa [IMP] website, *: improve the default theme
*: web, web_editor, portal, theme_default, website_sale

The goal of this commit is to improve the overall style of the default
website theme mostly by overriding Bootstrap variables with a bit of
customization for more advanced changes.

task-3097005

Part-of: odoo/odoo#120302
Co-authored-by: Brieuc-brd <brd@odoo.com>
Co-authored-by: Antoine (anso) <anso@odoo.com>
2023-10-08 10:45:45 +00:00
Rodolpho Lima d8a3374c43 [FIX] web_editor: node insertion from different document
Steps:
- on website or mass_mailing, insert an image via the "/image" command,
- a text node containing "[object HTMLImageElement]" is pasted instead
  of the expected content.

Since [1], when inserting a node, the instanceof operator is used to
compare that node to the Editor's document global `Node` object. While
it fixed cases where there was as mismatch of `Node` objects (nodes
created by the top document x nodes created via the iframe's document),
it revealed errors elsewhere. Notably, the MediaDialog inserts an image
node created by the top document, regardless if the editor is mounted in
an iframe.

This commit makes the `insert` command more permissive when resolving if
'content' is a Node or a string.

task-3543003

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

closes odoo/odoo#137872

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-06 14:33:47 +00:00
Brieuc-brd cfd1eb439d [FIX] web_editor: display read-only handles
Prior to this commit, read-only handles were hidden, which created a
layout issue (eg. the header was no longer highlighted when we clicked
on it).

This commit adapts read-only handles to make them visible by using a
border around the selected element.
It also adapts the common borders of all handles to place it
inside the element to avoid being partially hidden when the element is
on the edge of the container (eg. the header or the footer).

task-3537616

closes odoo/odoo#137569

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-10-05 15:36:23 +00:00
Brieuc-brdandqsm-odoo c16428cf39 [FIX] web_editor, website: adapt dropzone transparency
Since the introduction of the new dropzone design at [1], the dropzones
were not transparent enough anymore and the inline content behind them
was not readable.

This commit adapts the layout of dropzones to make the content behind
them more readable.

[1]: https://github.com/odoo/odoo/commit/8ca644252e2d3a1f836735454c1f936529a7914e

task-3537616

Part-of: odoo/odoo#137569
Co-authored-by: qsm-odoo <qsm@odoo.com>
2023-10-05 15:36:22 +00:00
Jorge Pinna Puissant ef424a9dc2 [REF] *: remove owl from linter's accepted global variables
Before this commit, owl was in the linter's accepted global variables.
This allowed  direct access to owl global object.

For instance, to use xml from owl, you could do :
`const { xml } = owl;`
or you could use it directly:
`owl.xml`

Now, owl is not accepted on linter's global variables anymore, so to
import xml, now you need to use a proper import:

`import { xml } from "@odoo/owl";`

task-id 3498859

closes odoo/odoo#137517

Related: odoo/enterprise#48364
Related: odoo/design-themes#709
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
2023-10-05 10:21:53 +00:00
Benjamin Vray c6ec2c5e04 [FIX] web_editor, website: fix colorpicker issues related to color names
This commit fixes two bugs with the colorpicker that occur since [1].

Steps to reproduce the 3rd bug:
- Go to Website edit mode.
- Click on the header.
- Choose "Over The content" for the "Header Position" option of the
header.
- Change the color of the header by picking a color in the "Background"
sub option (below the "Header Position" selector).
- Save and Edit.
- Go with your mouse over the different colors of the colorpicker (at
least 2).
- Bug: an infinite loader appears on the iframe and prevents from
editing the background color.

Steps to reproduce the color combinations bug:
- Go to Website edit mode.
- Drop a Call to action snippet.
- Change the background color and try to select another preset.
- Bug: the color of the text and buttons is updated, but not the
background color.

Both of these 2 bugs happen after commit [1] because the colorpicker
widget is started before the ColorPalette component is attached to the
DOM (which only happens once the user opens the picker). However, the
colorNames are only set after the setup() of the ColorPalette.
Initializing the colorNames with possible default values is thus
necessary to avoid bugs on `_computeWidgetState()`.

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

task-3440939

closes odoo/odoo#137306

X-original-commit: https://github.com/odoo/odoo/commit/2ccc01175080ddb549660713d6101dd936e0d304
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-10-04 19:40:20 +00:00
Benjamin Vray 15bfd72116 [FIX] web_editor: fix color suggestions for the transparent header
Steps to reproduce:
- Go to Website edit mode.
- Click on the header.
- Choose "Over The content" for the "Header Position" option of the
header.
- Open the colorpicker (below the "Header Position" selector).
- Bug: we shouldn't be able to choose anything other than a gray.

This bug occurs since [1] because, before the conversion to owl, the
colorpicker widget was added conditionally in JavaScript (so the widget
was not included if the option "custom" color was excluded). However, in
the current version, the color picker is inside the
'web_editor.ColorPalette' XML without any condition to display it or
not.

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

task-3440939

X-original-commit: https://github.com/odoo/odoo/commit/7919e243427899ca7c09666fbdf8453bc2defa1d
Part-of: odoo/odoo#137306
2023-10-04 19:40:20 +00:00
Louis (loco) 94b55d913b [FIX] web_editor, *: store the correct mimetype of an image with a shape
*: tools

Steps to reproduce the bug:
- Add an image on the website.
- Replace it by a "jpeg". Note that the mimetype of the image is
"image/webp" at the upload since [1].
- Add a shape on the image.
- Save and Edit.

-> If you check on the available "Format", the mimetype of the
"original" is "webp" but it should be "jpeg".

Before this commit, there were two types of mimetype data attribute:
- `mimetype`: the current mimetype of the image.
- `originalMimetype`: the mimetype of the image without a shape.
Before [1], it was also the mimetype of the original image. However,
since [1], the user has the possibility to change the mimetype of the
image so the "originalMimetype" attribute does not always refer to the
mimetype of the original image anymore.

To resolve the problem, another data attribute has to be introduced.
Here is a summary of the mimetype related attribute:
- `mimetype`: the current mimetype of an image.
- `originalMimetype`: the mimetype of the image before a shape has
been applied. It is needed when removing a shape to recover the correct
mimetype.
- `mimetypeBeforeConversion`: the mimetype of the original image. It is
needed in order to be able to change the format of an image and come
back to the original one.

In the case of an uploaded "jpeg" image on which a shape has been
applied, `mimetypeBeforeConversion` is "image/jpeg", `originalMimetype`
is "image/webp" (since [1]) and `mimetype` is "image/svg+xml".

The `loadImageInfo()` has been adapted to also handle the case of an
image that has already been loaded but that does not have the
`mimetypeBeforeConversion` attribute (for example all the images that
were uploaded on the website before this commit). In this case, the
mimetype attribute is kept and not set to the original one as the user
could have changed it.

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

task-3449866

closes odoo/odoo#137424

X-original-commit: 730588b802506844e6ca54df312333bfd8df1d52
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-10-04 18:27:03 +00:00
vishal padhiyar 45db6775eb [FIX] web_editor: remove unwanted styles and tags
Before this commit:

When pasting text from outside odoo, it often includes additional tags
such as <b> and <P>, along with unwanted styles.

After this commit:

When pasting text from outside odoo, those extra tags and styles are now
removed.

task-3378093

closes odoo/odoo#137236

X-original-commit: 5485824654179981cc7562e643123a6decbb02a2
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-04 07:11:55 +00:00
Jinjiu Liu 09736d81c8 [FIX] web_editor: patch for null selection in condition
Reproduction:

1. Go to any record with a chatter
2. Open full composer
3. Enter a special case for the text using shortcuts (CTRL+I for italic,
CTRL+B for bold, etc)
4. exit the special case with the same shortcut
5. JS error

Reason:
A selection is not null check is missing in the condition

Related PR: https://github.com/odoo/odoo/pull/136777

closes odoo/odoo#137499

X-original-commit: db0325503576d06521ab65a64d3c9cce837e66bc
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Jinjiu Liu (jili) <jili@odoo.com>
2023-10-04 05:05:47 +00:00
maad-odoo 83d7846fc3 [FIX] web_editor: p tag not added when new row or column in inserted.
Before this commit:
When we inserted a new row or column into a table, a <p> tag was not
inserted within it, resulting in the placeholder not being displayed.

After this commit:
When a new row or column is inserted into the table, a <p> tag is inserted
within the <td>.

task-3344668

closes odoo/odoo#137429

X-original-commit: a3e09ed84451f8a7c5cbc82648a02565ef63072f
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-03 21:14:45 +00:00
Odoo c3eee7c6b8 [IMP] web_editor: add button to reset table size to auto
Purpose of this commit:

Added a button to the sidebar and the column dropdown menu
for resizing the table's height and width, so that if we
want to reset the modified size of the table, we will be
able to do so

Taskid: 3344668
X-original-commit: 8740310ec845b020db0d31d3be5dfc2969665994
Part-of: odoo/odoo#137429
2023-10-03 21:14:45 +00:00
Rodolpho Lima 49277b5950 [IMP] web_editor: unify http regexes
Before this commit there were two regexes for matching http(s) URLs,
being the only difference between them the presence of a capturing group
for the protocol/scheme. The need for a nearly duplicated version of the
same regex was its use in `_onPaste` as delimiter for String.split(), in
which capturing groups are returned in the resulting array, and the
protocol/scheme was not desired.

This commmit removes the need for two different regexes to match http(s)
URLs, adapting `_onPaste`'s code to work with the presence of the
referred capturing group.

task-3520513

closes odoo/odoo#136497

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-03 19:20:09 +00:00
Rodolpho Lima 4da0608f7c [IMP] web_editor: remove global flag from URL regex
A Regex object with the 'g' flag is stateful [1]. As the URL_REGEX and
URL_REGEX_WITH_INFOS objects are exported, code that calls  their `exec`
method would be changing their `lastIndex` property, affecting future
`exec` calls in different code sections.

This commit removes the 'g' flag from the URL regexes, in order to allow
us to:
- avoid side effects of one call to `exec` to subsequent calls,
- remove the `getUrlsInfosInString` utility function,
- use `match` instead of `exec` for having results containing the
  capturing groups (see [2]).

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex#avoiding_side_effects
[2]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match#return_value

task-3520513

Part-of: odoo/odoo#136497
2023-10-03 19:20:09 +00:00
Aditya Sharma 35bb9ffd52 [IMP] various: add minor UI improvements
PURPOSE

Slightly modify various apps to improve the user experience. Changes include
notably labels and views fine tuning, roundings, and small css fixes.

SPECIFICATIONS

- Remove the decorator from the event list view as it's a bit confusing
- Ensure mailing KPIs are now shown with 2 decimal places
- Re-order the mailing stat buttons
- Improve the background / font colors of the cover block
- Improve the labels of:
  - Title and confirm button of the /button and /link modals
  - Confirm button when archiving a record

Task-3204554

closes odoo/odoo#128108

Related: odoo/enterprise#43937
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-10-03 19:19:52 +00:00
Brieuc-brd 388c88eaf2 [FIX] web_editor: remove handle area's overlapping
Prior to this commit, the area of top and bottom handles overlapped the
content according to the size of the overlay border.

This commit changes the way height is calculated to remove this overlap.

task-3368793

Part-of: odoo/odoo#132653
2023-10-03 12:52:33 +00:00
Brieuc-brd 3af727c183 [IMP] web_editor: update overlay buttons
This commit adapts the draggable icon in the overlay button to improve
the readability.

This commit also adapts the "danger" background color of
`oe_snippet_remove` button to maintain consistency with the web editor.

task-3368793

Part-of: odoo/odoo#132653
2023-10-03 12:52:33 +00:00
Brieuc-brd 8ca644252e [IMP] website, web_editor: redesign the drop zone
This commit adapts the drop zone to maintain consistency with the style
of web editor.

task-3368793

Part-of: odoo/odoo#132653
2023-10-03 12:52:33 +00:00
Brieuc-brd 70f723a9f7 [IMP] web_editor: redesign the handle elements
This commit improves the design of handles, making them more user
friendly.

task-3368793

Part-of: odoo/odoo#132653
2023-10-03 12:52:33 +00:00
Brieuc-brd 8204d15822 [IMP] web_editor: redesign the grid layout
This commit improves the design of the grid layout to make it easier to
read.

task-3368793

Part-of: odoo/odoo#132653
2023-10-03 12:52:33 +00:00
Louis (loco) f2ea69a8cf [FIX] web_editor: show dropzones at an over after an over event
Steps to reproduce the bug:
- Add a "Text-Image" snippet on the website page.
- Take an "Inner content" snippet from the right panel and drag it from
a dropzone to another. It has to be fast so that the order of the "over"
and "out" dropzone events is "over" > "over" > "out" and not "over" >
"out" > "over" as usual.

-> The exited dropzone is not correctly displayed.

The problem is that since [1], the website is inside of an iframe. Due
to that, the snippets menu does not have a direct access to the
dropzones. To solve the problem, the already defined `$dropZones`
variable is used instead of searching the dropzones inside the DOM. For
the snippet editor, the problematic line has been deleted at it is
already handled by `_outPreviousDropzone()`. This is acceptable since
the commit that introduced `_outPreviousDropzone()` ([2]) and the commit
that introduced the removed line ([3]) were both introduced to handle
the case of an "over" after an "over". In other words, as
`self.droppped` will always be `true` when
`self.dragState.currentDropzoneEl` is set and it will always be `false`
when `self.dragState.currentDropzoneEl` is not set, the problematic line
can be removed as it is already handled in `outPreviousDropzone()`.

[1]: https://github.com/odoo/odoo/commit/31cc10b
[2]: https://github.com/odoo/odoo/commit/c6886410603a16b6a3c5fe459d273dd883c110c7
[3]: https://github.com/odoo/odoo/commit/fed5854e32bcddf8b14b8311b2fe542eed990f77

task-3522552

closes odoo/odoo#137255

X-original-commit: 06fde42d3ba0e8be2128cda8e695c5def917f391
Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
2023-10-02 12:58:53 +00:00
Jinjiu LiuandRodolpho Lima 80b3edea0c [FIX] web_editor: restore popover edit link focusing on URL
Reproduction:

1. Install website
2. Change to edit mode and click a link on the main page, for example,
“contact us” at the bottom
3. click "Edit link" in the popover

Fix: use the variable `shouldFocusUrl` for link tool props update

task-3514360

closes odoo/odoo#137246

X-original-commit: af035687c57f8b34261beff121669ee044d9b7df
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Co-authored-by: Rodolpho Lima <rcdl@odoo.com>
2023-10-02 11:42:58 +00:00
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
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 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