Commit Graph
4062 Commits
Author SHA1 Message Date
Stanislas Gueniffey 0cf2437f67 [IMP] web_editor: remove dead '_onInput' code
The 'insertLineBreak' case in `onInput` is dead code because any event
that might cause it (pressing Shift+Enter) first triggers `onKeydown`,
which calls `ev.preventDefault()` and thus prevents it from reaching
`onInput`.

Task-3301232

closes odoo/odoo#121850

X-original-commit: c63cd2f0140959a7ac6e05ef15ac5c2ac552453d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-22 11:43:11 +02:00
dhba-odoo 28b54dfa39 [FIX] web_editor: entering a hax color triggers traceback
Before this commit:

In mass_mailing entering a hax color for text triggers traceback.

After this commit:

Now, the traceback will not be triggered and color will be applied to the text

Task-3271517

closes odoo/odoo#121800

X-original-commit: b526bc1e56fd486cad422bca3a7b0e837376cd17
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-19 15:40:52 +02:00
David Monjoieanddhba-odoo 6dd38640ce [FIX] web_editor: fix select all in empty paragraph
The previous code with `parentsUntil` would not return any result
in an empty paragraph because the only valid element would be the
anchorNode itself but `parentsUntil` would only return parents and
never the base node itself. It makes sense, but is not suitable for
the case at hand.

Before this commit:
CTRL+A does nothing from inside an empty paragraph.

After this commit:
CTRL+A correctly triggers a select all from inside an empty paragraph.

Task-3150956

closes odoo/odoo#121727

X-original-commit: 4bcba1d785afeaa8287adc48076f208d04fc72c3
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Co-authored-by: dhba-odoo <dhba@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
2023-05-19 10:18:57 +02:00
Preksha Chouhan feff1fc79f [FIX] web_editor: convert color opacity to be compatible with PIL Image color
ValueError 'unknown colour specifier' occurs when we access
export_icon_to_png(). This error occurs when we change the colour of an
icon in the mailing template, because the value of alpha (opacity) in 'rgba'
is in the range of 0 to 1, but PIL Image support colour opacity range 0 to 255.

This commit converts the opacity value range (0 to 1) to a range (0 to 255)
compatible with the PIL image library when the colour specifier is 'rgba'.

sentry - 3933353285

closes odoo/odoo#121696

X-original-commit: 7e4be89f6c0b2f8b82a207030e8a8cb20d72664f
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-19 10:18:53 +02:00
Martin Trigaux 077bbd0b0b [I18N] *: export master source terms
closes odoo/odoo#121563

Related: odoo/enterprise#41140
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-05-17 10:34:00 +02:00
Soukéina Bojabza fcd100cf8f [FIX] web_editor: fix grid mode with inner snippet outside a row
Before this commit, there were cases where toggling the grid mode did
not work correctly. These cases are:
- when a snippet has None columns (e.g. Cover) and that an inner snippet
containing a row (e.g. Form) was dropped into it,
- when a snippet has some content outside its row (e.g. Picture) and
that an inner snippet containing a row was dropped in this outer
content,
- when a snippet has some content outside its row (e.g. Picture) and
that an inner content (e.g. Alert) was dropped in this outer content.

The first two cases happen because the row that was taken into account
when toggling the grid mode was the first `.row` element found in
general, instead of only considering the container children. Therefore,
what happened in these problematic cases is that the row found was the
inner snippet one, which should not be the case and caused the toggle to
fail because it was trying to put the element inside itself.

The third case happens because the `div` elements were excluded when
placing the outer content in a column, instead of only excluding the row
element.

This commit fixes these issues by only considering the container
children when looking for the row element when toggling the grid mode,
and by filtering out only the row element instead of every `div` when
creating a column for the outer content.

task-3279191

closes odoo/odoo#121393

X-original-commit: f94fe1d40f05a8dbb42f0f2a95d3fff68a3af0ec
Signed-off-by: Dieleman Guillaume <gdi@odoo.com>
2023-05-16 14:42:09 +02:00
Rodolpho Lima 859b17e3fc [FIX] web_editor: fix typo that led to unexistant property read
closes odoo/odoo#119556

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-15 15:07:19 +02:00
Rodolpho Lima 5994c3a8b3 [FIX] web_editor: add unit tests for selection correction
This commit adds unit tests for cases where the cursor is placed at the
editable root (which is corrected by the Editor).

Part-of: odoo/odoo#119556
2023-05-15 15:07:19 +02:00
Rodolpho Lima 0c9980f1dc [FIX] web_editor: fix selection on editable root
Some of the Editor methods relies on not having inline elements at
the editable root. For this reason, the cursor should never be placed
at the editable root, but always inside a block element.

Before this commit, in some situations (notably around tables and
horizontal separators), the cursor could be placed having its anchorNode
at the editable root, allowing the user to insert inlined text at it.

This commit fixes the selection range in such cases, and an empty paragraph
is inserted in cases where there would be no other way to insert text before
or after an existing block.

task-3128747
opw-3106752

Part-of: odoo/odoo#119556
2023-05-15 15:07:19 +02:00
Rodolpho Lima ab0b2440fc [FIX] web_editor: split isVoidElement utility function
The `isVoidElement` utility function has a misleading name, and the need
for an actual list of void elements arose.

This commit replaces the `isVoidElement` utility by two functions:
- `isArtificialVoidElement`: returns true for elements that we decided to
treat as if they were void elements. This method is used to decide whether
they should have their "isContentEditable" attribute set to false.
- `isNotAllowedContent`: actual void elements + the ones above.

Part-of: odoo/odoo#119556
2023-05-15 15:07:18 +02:00
Soukéina Bojabza fa0cd18f9d [IMP] web_editor: align numeric inputs text without units to the right
Before this commit, the input widgets that do not have units have their
text aligned to the left. However, when the content is numeric, it would
be better if the number was on the right, just as when there is a unit.

This commit also considers as numeric an input widget that has the
`data-step` attribute (and not only the `data-unit` attribute) and
forces the text alignment to the right in this case.

task-2798576

closes odoo/odoo#89055

Signed-off-by: Dieleman Guillaume <gdi@odoo.com>
2023-05-15 12:55:58 +02:00
Benoit Socias 225cea8b74 [FIX] web_editor: restore avoiding updates of link content
[1] mistakenly removed the variable used by the mechanism that was
introduced in [2] to avoid updating link content.

This commit uses the link's `needLabel` instead to achieve the same
goal.

Steps to reproduce:
- Add a mega menu.
- Set the mega menu template to Cards.
- Click on the text of a card.
- DO NOT click on the edit link icon in the popover.
- Click on the href field in the options panel.
- Change the value.

=> Links content was broken (image was removed and texts were grouped).

[1]: https://github.com/odoo/odoo/commit/75166dbcd4962f30624fe19829757acbf8e76022
[2]: https://github.com/odoo/odoo/commit/7a0e58f8d7237514d23d815cdf3d81fc79edb1ec

task-3300977

X-original-commit: 1dbcf2825b2d495c206e110a39efe620e646e7c4
Part-of: odoo/odoo#121362
2023-05-15 11:41:54 +02:00
Pulinckx Pierre (PIPU) f4f0f78318 [REF] *: Replace underscore.js function by native JS
Before this commit : The library underscore.js and
underscore.string.js were used in the ODOO solution.
After this commit : Every usages of a function from
underscore.js lib has been replaced with native javascript.
The goal is to remove all usages of underscore.js and to
not use anymore this library in ODOO.
---
TaskId : 3246238

closes odoo/odoo#120437

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-05-15 09:37:48 +02:00
Brieuc-brd 418413e499 [IMP] web, *: directional icons
This commit adapts the directional icons to improve the usability and
maintain consistency with the ui icons library.

task-2818586

Part-of: odoo/odoo#116641
2023-05-12 22:59:22 +02:00
stefanorigano (SRI) 46b762a1f1 [REF] web, *: milk colors
*: google_calendar, hr_holidays, hr_skills_slides, mail,
microsoft_calendar, point_of_sale, web_editor, website_livechat,
website_sale

task-2818586

Part-of: odoo/odoo#116641
2023-05-12 22:59:12 +02:00
Benoit Socias 4978d2d107 [IMP] *: allow empty frontend m2o and deselection in the editor
*: base, web_editor

The Many2oneUserValueWidget does not allow the user to reset it
to blank if it already contains a selection. This commit makes it
possible to select an empty value by specifying a `null_text` option.

task-2406626

Part-of: odoo/odoo#67913
2023-05-12 19:54:08 +02:00
Mathieu (mano) b7b05a2d1c [IMP] web_editor: new shapes full height menu
This commit replaces the `we-select-pager` for a full-height version
allowing better sorting and visibility of the shapes and background
shapes.

The new UI now has a navbar inside the pager which allows to scroll to
anchors inside the menu. To do so a new attribute `data-scroll-to` is
added on the button element allowing to scroll to the class contained
in the attribute with the new function `_onClickScrollPage`. Thanks to
ard the Selection widget now activates the corresponding menu section
of the new pager whenever the data-scroll matches a section that has
passed the middle of the container.

The menu being full width, the angle with the class `.o_pager_nav_angle`
triggers the `_onClickCloseMenu` to close the menu.

To avoid duplication, the label for the devices now uses the same Js
logic as the Animated label for the shapes. This frees the :before and
:after which allows to use the alpha-background extended class on the
we-button for both types of shapes. The devices label information now
shows an aspect ratio rather than full dimensions.

For the new pager to appear full-height and the content being scrollable
inside the proper section of the menu, two new containers are added
one for the pager's navigation (`o_pager_nav`) and one for the shapes
pages (`o_pager_container`). This allows to have the parent div in fixed
positioning and keeping a scrollable section on the `o_pager_container`
under its inner navigation.

The previous shapes are back to their original ratio of 800x600
since switching them in square makes them less recognizable.

Finally, in the `we-toggler` when no elements are selected or when it is
empty, we now display `None` instead of `/`.

task-3266751

closes odoo/odoo#118253

Related: odoo/design-themes#653
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-05-12 11:17:41 +02:00
Odoo c6af10ff34 [FIX] web_editor: deleteing content from a link throws traceback
Before this commit:

When a new link a created on a new sentence, and clicked on it opens a popover,
when your start hitting backspace then as your reach the extreme left it throws
a trace-back error.

After this commit:

Trace-back error is not thrown while deleting backward it does not throw
back.

closes odoo/odoo#120578

Task-id: 3252709
X-original-commit: 843d1be63140b8cdb00e3f18c67ad7803d998a21
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-11 18:25:17 +02:00
qsm-odoo ad63194af3 [FIX] web, *: use proper http-equiv="X-UA-Compatible" value
*: mail, point_of_sale, pos_self_order, web_editor

The `,chrome=1` part is no longer a supported value as the Google Chrome
Frame plugin was discontinued on February 25, 2014. See [1].

Indeed the W3C validator returns an error about this.

[1]: https://rocketvalidator.com/html-validation/a-meta-element-with-an-http-equiv-attribute-whose-value-is-x-ua-compatible-must-have-a-content-attribute-with-the-value-ie-edge

Part-of: odoo/odoo#120311
2023-05-11 18:25:07 +02:00
Benoit Socias 38e2aef445 [IMP] web_editor, web_unsplash: alternate unsplash and illustrations
Before this commit, all search result illustrations were displayed
before the Unsplash images.

This commit makes the search result images from Unsplash and the
illustrations alternate, beginning with the first Unsplash image.
The existing attachment results remain in front.

task-3060679

closes odoo/odoo#111481

Signed-off-by: Bojabza Soukéina (sobo) <sobo@odoo.com>
2023-05-09 19:26:45 +02:00
Xavier-Do ab1e4f670a [REF] web_editor: change custom url
Before this commit an ir_assets generated automaticaly by the web editor
will generate an url ending with ...custom.addon.bundle_name.ext

After this commit the url will start with /_custom/addon.bundle_name/...

This will make it easier to spot at immediately if it is a custom asset
and thus it is useless to apply the glob. Actually, it will fail on the
/_custom when trying to glob, making it faster.

This is mainly useful to clarify and debug but in a case with mainly
customised ir_asset for one bundle, it may have an impact on speed.

An upgrade script was created for this change.

closes odoo/odoo#120699

Related: odoo/upgrade#4636
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2023-05-09 18:27:01 +02:00
Robin Lejeune (role) 5f197e76f4 [FIX] web_editor: fix HTML/CSS editor resizing bug
Starting on version 16.0, the HTML/CSS editor is very hard to resize.
This is due to 16.0 introducing an iframe for the website: as soon as
your mouse enters the iframe, the editor loses focus and cannot be
resized anymore.
This commit fixes that.

task-3006138

closes odoo/odoo#120729

X-original-commit: e489abeffc72293544acb18eba23b52ed2224d60
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-05-09 11:57:19 +02:00
Julien Mougenot c6637e537e [REF] *: Remove date picker libs from main bundles
This commit removes both DateRangePicker and TempusDominus libraries
from the common asset bundle. The legacy widgets still depending on
these libraries will now load them lazily when instanciated.

Part of task 3121497

Part-of: odoo/odoo#112171
2023-05-05 13:52:22 +02:00
Deependra Solanki 36b5757dcd [FIX] web_editor: fix line merge on color change
Before this commit:

When using shift+enter to move to a new line, now applying bold, italics,
underline, etc and then trying to add a color to both lines would result in
lines merging.

After this commit:

Now when the both lines are bold and then applying a color to both the lines
would no longer merge.

closes odoo/odoo#119701

Task: 3269922
X-original-commit: 0473dbd0090dd7b2fb1ff59a83a38df941303681
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-03 12:39:35 +02:00
Michael (mcm) 517d3258f2 [REF] web,*: add dependencies param to odoo.define
This commit makes the `dependencies` param of
`odoo.define` mandatory. It was optional and when
omitted, a regexp read the function to find the
dependencies. We can simplify it now almost all js
modules have been converted to esm.
The transpiler already adds the param for the es
modules except if the module has an alias.

task id: 3271352

closes odoo/odoo#119145

Related: odoo/enterprise#40040
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2023-05-03 12:39:30 +02:00
can-odoo 044a3cfdb3 [IMP] web_editor: set default values for repeat-pattern background size
Description of the issue/feature this PR addresses:
---

When a user chooses "Repeat Pattern" as the background image position,
nothing happens.

Current behavior before PR:
---

As the background size is set to auto, for background-position
`repeat-pattern` no effect[1] can be seen in the
background size.

[1]: https://bit.ly/3MM31Ac

Desired behavior after PR is merged:
---
Not a bug but can be considered an improvement in features by setting
some default[2] width or height for a repeat-pattern option for all
relevant snippets.

[2]: https://bit.ly/3GbGIBo

task- 2862510

closes odoo/odoo#102995

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-05-02 20:01:39 +02:00
Pulinckx Pierre (PIPU) 126da95642 [FIX] *: replace %d by %s when using sprintf
*: web, web_editor, payment
Before this commit, templates with %d was given to sprintf but it was not interpreted by the function
After the commit, %d are replaced by %s in templates for sprintf
Also this commit converts a last _.str.sprintf into sprintf

PR#120143

closes odoo/odoo#120143

Signed-off-by: Michaël Mattiello <mcm@odoo.com>
2023-05-02 15:59:04 +02:00
David MonjoieandJinjiu Liu d0e14f6064 [FIX] web_editor: fix ClipboardJS traceback in Firefox 109
Starting with Firefox 109, a widget element prototype that is put
inside an iframe will not be instanceof its original constructor.
See: https://github.com/webcompat/web-bugs/issues/118350

This is because a node that is adopted by an iframe will have its
prototype changed to match the constructor from within the iframe
instead of its original one. This has been the case for a long time.
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1470017

It largely went unnoticed because of another quirk of Firefox related
to the use of instanceof which was fixed in version 109.
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1360715

Since this bug was fixed it became apparent, in the form of a
traceback, that the wrong instance of ClipboardJS was being used
in the case of Firefox, due to the forced prototype change.

This commit could be reverted once Firefox is fixed.

Steps to reproduce the issue in Firefox > 109:
- Create a new mass mailing.
- Choose the third template with "Thank you for joining us!".
- Click on the "LOGIN" button link inside the email.
- Get a traceback about a paremeter not being the right type.

Task-3186513
OPW-3172914

closes odoo/odoo#120171

X-original-commit: c0da01c716716f9d35abe9d90dad27cce1452ebb
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Co-authored-by: Jinjiu Liu <jili@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
2023-05-02 14:47:28 +02:00
Mathieu (mano) 3e683cc716 [IMP] web_editor, website: add minor design improvements to the editor
This commit gives a small refresh to the web_editor UI. To do so we
remove the borders from the buttons and inputs. We also increase the
border radius to 4px instead of 2px. The nested menus such as in Themes
tab now have the same  background color than the rest of the UI.

The box shadows on the `we-title`, `we-customize-block-options` and the
checkbox switch have been removed.

All the buttons and select components are now taking the full available
width. The inputs fields remain unchanged except their font which is now
set to sans-serif.

Finally a `<div>` have been added to the replace media snippet to make
it consistent with the other buttons having an icon. Maybe in the future
we'll need a better way to define those.

task-3265187

closes odoo/odoo#119697

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-04-28 16:04:35 +02:00
Benjamin Vray 33b86b26e3 [FIX] web_editor: fix resizing and padding options of snippets
Since this commit [1], the resizing and padding options of snippets are
not functioning properly in the website's edit mode.

For example, if a user wants to increase the width of a column to the
right, nothing happens. The user must first reduce the column by moving
to the left with the mouse before being able to increase it to the
right. The same problem occurs when attempting to adjust the padding
using the handle buttons.

This issue was caused by a numeric value ('key') being changed to a
string.

[1]: https://github.com/odoo/odoo/commit/800223ae7c5891bf700d45eb6d5f541093dc273c

task-3289164

closes odoo/odoo#119681

Signed-off-by: loco-odoo <loco@odoo.com>
2023-04-28 16:04:33 +02:00
Guillaume (gdi) b4ba82dc20 [FIX] web_editor: correct the custom block HTML
Since [this other commit], custom blocks are not displayed correctly in
the editor. The DIV tag is not supposed to be self-closing. However,
older versions of JQuery supported it anyway (they turned `<div/>` into
`<div></div>`) Since the update of JQuery to version 3.6.3, self-closing
DIVs are no longer correctly supported by JQuery.

For example, if you type this in the Chrome console:
```
$(`<div id="divRoot">
    <div id="selfClosing"/>
    <div id="notSelfClosing"></div>
</div>`)[0]
```
JQuery will create the following structure:
```
<div id="divRoot">
    <div id="selfClosing">
        <div id="notSelfClosing"></div>
    </div>
</div>
```
JQuery doesn't parse the HTML correctly and returns a wrong structure
(the `#notSelfClosing` is moved inside the `#selfClosing`).

Note that doing `$('<div/>')[0]` will return a correctly parsed DIV.

This commit corrects the layout structure of custom blocks so that they
are not composed of self-closing DIV.

Steps to reproduce the issue:
- Edit a website page
- Drop a block
- Click on the save icon
- Click on "Save and reload"

=> The custom block is not displayed correctly.

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

task-3290172

closes odoo/odoo#120027

X-original-commit: fd76d59bcd08e824c4e46814d0754a225f7a1b72
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
Signed-off-by: Guillaume-gdi <gdi@odoo.com>
2023-04-28 09:53:06 +02:00
abd-msyukyu-odoo 1baeea454f [FIX] web_editor: fontawesome subnodes should make a node non-empty
For each node that the `insert` command inserts, the previous node is evaluated
and tested to be a `shrunk` block. If it is, it is considered "invisible" and
removed.

Prior to this commit, an element containing sub-elements with a fontawesome icon
was considered to be `isEmptyBlock==='true'` even though it is supposedly
visible as it contains that icon.

Therefore in cases where multiple nodes are inserted at once, if one of them has
only fa-icon nodes as children, that node would not have been inserted.

Task-3284580

closes odoo/odoo#119931

X-original-commit: 373c3da609582bd170e1c5924a5c2351eb4706ca
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-04-27 18:25:15 +02:00
luvi 894090914e [IMP] web, *: add supportedOptions documentation as field metadata
*: mail, mass_mailing, sms, web_editor

This commit adds a new supportedOptions attribute that can be added to any
field widget metadata object. This documentation can be used from other places
(Studio for example) by getting the field from the registry and then read
this key. This attribute can contain an array, detailing the list of available
options for the field widget.

By using an array, it can be ordered easily without having an object with keys
unalphabetically. Ordering the options can make sense, especially when two
options are tied to each other, it is easier to group them one after the other.
(eg: 'start_date' first, then 'end_date')

Each option documented is an object and has the following attributes:
- help: contains more details on the current option and its use
- name: name used in the options object from the node
- label: a label with a more explicit name than the option name
- type: the type of value that must be used as a value (string, boolean, selection, field, domain)
- choices: for options with a 'selection': can be used to know available values
  where multiple values can be chosen as the value. This must be
  an array containing the options.
- availableTypes: for options with a 'field' selection: can be used to filter the
  available fieldNames to choose as a value.
- default: the value that is used by default, when the option is not set
  in the options

task-3259617

closes odoo/odoo#118713

Related: odoo/enterprise#39847
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-04-27 11:21:09 +02:00
Stanislas Gueniffey 7c0d82a3d9 [IMP] web_editor: allow pasting HTML tables
Previously, when a clipboardData contained both files and html content,
we prioritised files. This is correct when the original content is an
image (in which case the clipboard html may contain an image tag or be
empty, depending on the source). This is however incorrect in at least
one known case: copying a table from a spreadsheet app, as those usually
generate an image of the table alongside the actual html table. In that
case, we would rather keep the table.

This commit differentiates the specific case where the HTML represents a
table from other cases. In the former, priority is now given to the HTML
content. In the latter, we keep the files as we did before.

task-3165757

closes odoo/odoo#119862

X-original-commit: 021f2f028b382fe15ca75928d1b30a4eb48322df
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-27 07:06:08 +02:00
Jinjiu Liu 25be2d15c2 [FIX] web_editor: don’t delete table cell when its left cell has content
Reproduction:
1. Create a 1 by 3 table, input something in the first cell
2. Go to the second cell, hit backspace
3. The second cell is deleted and the third cell is moved to the second
cell

Note: in 15, we don’t have the table selector to remove a row of the
table but that is another issue

Fix: when we try to delete the table cell and the offset is 0, nothing
should be done. Also added a test to make sure the cell is unchanged
when we try to delete in an empty cell which has a cell with content
at the left. Also we skip the rejoin block step if there's a table cell
element is invoivled because the cells are not deleted and rejoining
them is not needed

Task-3171904

closes odoo/odoo#119765

X-original-commit: f62275ddb3967ff769cddcde070b4688d36dc4dd
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-26 23:01:12 +02:00
Stanislas Gueniffey 4b4ea80787 [IMP] web_editor: improve focus() for LinkDialog
Previously, LinkDialog always focused on the first editable input field.

This commit introduces a new option in the LinkDialog constructor,
`focusField`, that allows to designate a specific field to focus on.

This option is now used to focus on the second editable input field when
the first one is already filled (for example, from the user selection).

task-3224551

closes odoo/odoo#119699

X-original-commit: 70649465c35736ae5a8b918817bfd0f598600852
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-26 17:06:25 +02:00
dhba-odoo 508d4d75a1 [FIX] web_editor: shift+enter on styled elements.
Before this commit:

After selecting the text of shift+enter which is styled and pressing any key
the new hideous child gets born.

After this commit:

Now, The new input will replace the selected text.

Task-3209969

closes odoo/odoo#119506

X-original-commit: f15d5ad27c6b764f54904f6ea8f6a714974b7bd0
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-25 06:39:52 +02:00
Jinjiu Liu aff24fd851 [FIX] web_editor, web: long text and translation button overlapped
Reproduction:
1. Install Project, Helpdesk, go to Project -> Configuration -> Activity
Types-> Upload Documents
2. Type a super long text in Default Note, the text overlaps the EN
button

Reproduction 2:
1. Go to Helpdesk -> configuration -> Helpdesk Teams -> Customer Care
2. Type a super long text in the description of the team, the text
overlaps the EN button

Fix: we set concrete padding to the right to make sure the translation
button is not overlapped. The fix needs to be done in enterprise too

Note: The reproduction 2 is another sub-issue found when fixing the
first one. Reproduction 1 is for the note field with oe-bordered-editor,
and reproduction 2 is for the note field without it.

Related Previous Commit:
Odoo:
https://github.com/odoo-dev/odoo/commit/26ecbc16bc8079c7bb08095f1b27b4f68ca0e947

Enterprise:
https://github.com/odoo-dev/enterprise/commit/e2ca9d5a113bc3adbe085057eff778b24abf5ddc

task-3047773

closes odoo/odoo#119475

X-original-commit: ac5e9681b47787aafeab1a1a3f748801821d66c8
Related: odoo/enterprise#40170
Signed-off-by: Liu Jinjiu (jili) <jili@odoo.com>
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-24 23:49:02 +02:00
Rodolpho Lima 8e1bc74a67 [FIX] web_editor: prevent colorpicker close on click
Since Bootstrap was updagraded to 5.1.3, `ev.clickEvent` is no longer a
`JQuery.Event`. Therefore, the `originalEvent` property does not exist
anymore, and `__isColorpickerClick` can be accessed directly from
`ev.ClickEvent`.

By checking for the non-existent `originalEvent` property, the mechanism
that enables the colorpicker to remain open when clicked was being hindered.
Note that this handler's `ev` remains a `JQuery.Event`, and if a handler
returns `false`, it will prevent the default action and stop the event
propagating.

task-3274987

closes odoo/odoo#119429

X-original-commit: 6db128f7f859d7bb0f96b15b4e6a38955932f7cf
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-24 21:14:04 +02:00
Rodolpho Lima afe5455116 [IMP] web_editor: rename colorpicker tabs
The first tab of the colorpicker can, depending on the context:
- display a selection of color combinations for the current **theme**
(when launched as a snippet option, for example, in the website builder);
or
- display a selection of **solid** colors (when lauched from the toolbar).

The commit changes the tab's name to conditionally reflect its content:
"Theme" or "Solid".

The second tab allows the user to pick a **custom** RGBA color. This commit
renames it to "Custom", replacing the inaccurate "Solid" name, now in
use for the first tab.

task-3274225

closes odoo/odoo#118852

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-24 16:57:35 +02:00
Jinjiu Liu a2350508b1 [FIX] web_editor: switch the checkbox of checklist to right for rtl
Reproduction:
1. Create a /checklist, switch the direction by /swith
2. Type something and the list element is rtl, but the checkbox is on
the left

Fix: add margin to the right for checklist with the same value as what
we have on the left, reset left and right position for the li element
when we have rtl direction on the whole list. When we switch direction
on a li element when set the direction on the list level, e.g. we get
the cloest list element and set the direction for the whole list.

opw-3215701

closes odoo/odoo#119423

X-original-commit: 01b42c7d76c814e13325f8880dc9de765b0f43c8
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Liu Jinjiu (jili) <jili@odoo.com>
2023-04-22 06:53:51 +02:00
Stanislas Gueniffey 8f971c045c [FIX] web_editor: fix newline bug in code sections
This commit fixes a bug that was occurring in the code sections when
using Shift+Enter (soft return) for new lines.

Steps to reproduce:
- in a code section (a `<pre>` node)
- write two or more lines separated with Shift+Enter
- make the last line at least two characters long
- place the cursor at the end of the section and press backspace, or
before the last character of the section and press delete

Example (in a code section):
ABC
DEF
  ^ cursor before or after "F" (for delete or backspace respectively)

Unexpected behaviors:
- an extra line is inserted before the current line
- the cursor is teleported at the beginning of the current line

The bug originated from method `enforceWhitespace` which iterates over
the dom from the cursor's position. There, the conditions unintendedly
allowed the iteration to pursue until a `BR` node was found, in which
case a rule which should not have been enforced would add another `BR`
node, which also had the side effect of teleporting the cursor.

This commit adds a break statement such that if none of the "main"
conditions are met in the first iteration, it is stopped right away
instead. Meeting those conditions still allows the iteration to proceed
as before. Not meeting any of those conditions only happened in code
sections as far as we can tell, as they are explicitly excluded because
of their lower-level management of spaces. Should other cases occur,
they should have their own conditions added and not rely on a top-level
"else-by-default" to continue the iteration indefinitely.

task-3239097

closes odoo/odoo#119390

X-original-commit: e47c2eddb3b675324c181593a3243175a1095732
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-22 06:53:44 +02:00
Soukéina Bojabza 6669e1d5d6 [FIX] web_editor: avoid horizontal scrollbar in right panel
In edit mode, if the grid mode is toggled and if there are enough
options in the right panel to have a vertical scrollbar (e.g. when we
click on an image to have the image options), a horizontal scrollbar
appears. This happens because the "Add Elements" widget is too large and
it therefore overflows.

This commit improves this widget style so it does not overflow, which
will prevent the horizontal scrollbar from appearing.

task-3098222

closes odoo/odoo#119288

X-original-commit: 784a8f36471a6b7c05452f6b39ee61f6b859d9c9
Signed-off-by: Outagant Mehdi (mou) <mou@odoo.com>
2023-04-21 23:46:27 +02:00
Deependra Solanki bb914f863d [FIX] web_editor: do not scroll up when inserting a link
Before this commit:

When we write a long pad and go to bottom a insert a link when the modal opens
the editable area scrolls to the top.

After this commit:

Now from the bottom of the pad when we insert a link the editable area does not
scrolls to the top.

task - 3138700

closes odoo/odoo#119279

X-original-commit: 2c50808d9cebc7ba0913a098bf79a15ef36da47f
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-21 16:47:31 +02:00
Pulinckx Pierre (PIPU) 608e90e998 [REF] *: Replace underscore functions by native JS
Replace _.map(), _.flatten(), _.delay(), _.contains(), _.pluck(), _.isUndefined(), _.isEmpty(), _.isString(), _.isEqual(), _.isBoolean(), _.memoize(), _.invoke(), _.bind(), _.escape(), _.debounce(),
_.str.sprintf(), _.str.repeat(), _.str.startswith(), _.str.trim(),
_.str.escapeHTML(), _.str.escapeRegExp(), _.str.startsWith(), _.str.include()

closes odoo/odoo#118012

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-04-20 11:57:29 +02:00
abd-msyukyu-odoo e00a33b17a [IMP] web_editor: buffer external steps during Component rendering
Add a mechanism to buffer external steps when some asynchronous rendering needs
to be done (i.e. OWL rendering). This is to prevent external steps occuring
inside the rendered result from being applied when the rendering is currently
ongoing.

Remove `historyResetFromSteps` and `onExternalHistorySteps` as they were only
introduced to trigger an update of Knowledge Behaviors, but now that update is
done through `checkForExtraRendering`.

Modify collaborative tests of the editor so that steps `afterCreate` and
`afterCursorInserted` can be asynchronous.

Task-2821374

Part-of: odoo/odoo#104680
2023-04-20 10:51:22 +02:00
abd-msyukyu-odoo f04b8191c8 [IMP] web_editor: make mocha tests odoo modules
In order to be able to use web dependencies for mocha tests, convert every
existing test to an `@odoo-module` and make a new asset
`web_editor.mocha_tests` that will be used for tests in `/web_editor/tests`

Task-2821374

Part-of: odoo/odoo#104680
2023-04-20 10:51:21 +02:00
abd-msyukyu-odoo 40b762a69f [IMP] web_editor: force load collaborative on form view
Add an option to the html_field (collaborative_trigger) to allow to choose if
the peerTopeer connection of the collaborative mode should happen when the
html_field is loaded ('start') or when the field has the focus ('focus').

Will be used in Knowledge since the html_field of an article is the main focus
when opening the form in edit mode. The collaborative mode should be loaded as
fast as possible.

Task-2821374

Part-of: odoo/odoo#104680
2023-04-20 10:51:21 +02:00
abd-msyukyu-odoo 918d0109f4 [IMP] web_editor: add a hook for historyResetFromSteps
When the current user connects to a collaborative peer, the content inside his
editor will be reset. When opening a record, there is no way to know if such a
connection will happen.

In Knowledge, when one wants to insert an embedded view in an article body from
elsewhere in Odoo, it is inserted programatically once the article is opened. At
that time the peerToPeer connection is not established. Then, if a collaborative
session is started with someone already editing the html_field, the content is
reset, and at that point, the insertedd element is removed, so it should be
inserted again.

This commit introduces a hook that can be used to execute some specific action
if the content of the editor is reset through `historyResetFromSteps` during
the collaboration first synchronization. It can be provided as an option of the
`wysiwyg`.

Task-2821374

Part-of: odoo/odoo#104680
2023-04-20 10:51:21 +02:00
abd-msyukyu-odoo 0eac6dd552 [IMP] web_editor: prevent 'insert' command unwrapping in root
Currently, the 'insert' command unpacks nodes from a lone paragraph, or from
the first and last node if there are multiple nodes.

In knowledge, to append an embedded view to the editable, there is a need to
insert two sibling nodes at once (without unpacking them). With the current
behavior of 'insert', it is possible to do so by inserting a paragraph
containing the 2 nodes that need to be inserted. The result will be that the
'insert' command unpacks the parent paragraph and correctly insert the 2 nodes.

This commit prevents the 'insert' command from unwrapping nodes if the
anchorNode of the selection is the editable itself.

Task-2821374

Part-of: odoo/odoo#104680
2023-04-20 10:51:21 +02:00