Commit Graph
3197 Commits
Author SHA1 Message Date
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
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
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
abd-msyukyu-odoo 4e115baaad [IMP] web_editor: fully implement oeProtected and oeTransientContent
With the introduction of Knowledge Behavior Component, came a need to create
html nodes which would have limited interactions with the editor. i.e. an Odoo
view already has everything it needs to function properly, and when it is
inserted in the editor, any manipulation on the selection or on the style that
could be done with it should be prevented. Another example would be the
/template block (will be renamed /clipboard in the future) that has a
non-editable part (buttons which have a definite action in Odoo, and which
should not be interacted with) as well as an editable part inside of it).

To solve this use case, this commit proposes to mark specific html nodes with
a `data-oe-protected` attribute which could have one of three values:
- "true"
  - Only mutations of type "attributes" can be registered on the node itself
    which has the `data-oe-protected="true"` attribute
  - Prevent mutations of children (and sub-children) from being registered by
    the mutationObserver of the editor
  - Prevent the selection handling when its anchor is inside a
    `data-oe-protected="true"` element, even if it is `contenteditable="false"`
  - Prevent the command hint
  - Prevent the usage of the wysiwyg toolbar
  - Prevent the dblClick tooltip
  - Prevent the editor sanitization `Sanitize.js`
- "false"
  - Designed to be contained inside a node with `data-oe-protected="true"`
  - Re-enable all features disabled by a parent node with
    `data-oe-protected="true" for the children of a node with
    `data-oe-protected="false"
- ("")
  - This is considered equivalent to have the `data-oe-protected` attribute
    set to "true" (like other html attributes).

Another attribute is added: `data-oe-transient-content`, with the following
values:
- "true"
  - Prevent the serialization of the children of the node, so they are not
    shared during a collaboration.
  - Transient nodes will be removed during `cleanForSave`, meaning that they
    will never be part of the html_field value in the database
- ("")
  - equivalent to "true"

The use case is an embedded view: there is a large quantity of nodes that
are not relevant to share nor to save, since it will be recreated with the
lastest data from the database, with the information relevant to the
currently active user each time it has to be rendered.

Note:
This commit does not handle the dynamic switch from a specific value for
`data-oe-protected` to another (i.e. switching from "false" to "" or "true").
This could cause a number of problems like:
- some mutations from when the value was "true" are not yet handled when the
  switch (to "false") happens => those mutations will be registered as if they
  were always under the "false" value, even though it is not the case.
- in collaborative, some nodes with oids that were not relevant (under the value
  "true") won't necessarily have the same oids in between collaborators.
  Therefore we cannot suddently listen to their mutations and expect the changes
  to be shared by switching to "false".
In conclusion: the `data-oe-protected` attribute value should stay the same
during the entire edition.

Task-2821374

Part-of: odoo/odoo#104680
2023-04-20 10:51:20 +02:00
abd-msyukyu-odoo c3f44dbf59 [FIX] web_editor: notify current step when joining a collaborator which already synced
How to reproduce (scenario):
- Open 3 windows with 3 different sessions in Odoo
user_1 -> in CRM, My Pipeline
user_2 -> in Knowledge on article "target"
user_3 -> in Knowledge on article "target"
-> user_2 and user_3 are in a collaborative session
-> user_1 "insert view in article" "target" (via Favorites)
-> user_1 is redirected to knowledge to the target article
-> RTC_DATA_CHANNEL_OPEN between user_1 and user_2 happens
-> user_1 reset the html_field value from the history steps of user_2
-> the embedded view "My Pipeline" is inserted via `execCommand` and create a
step in user_1 editor
-> user_2 is notified via OE_HISTORY_STEP and receive the new nodes (view)
-> RTC_DATA_CHANNEL_OPEN between user_1 and user_3 happens
-> since user_3 was already synced with user_2, there is no
`historyResetFromSteps`
-> user_3 does not get the step from user_1 with the embedded view nodes now
-> user_3 makes multiple steps (i.e. write some text in a paragraph)

Current Behavior:
-> user_2 and user_1 are notified of those steps and add them to their histories
-> user_3 stil did not get the step with the embedded view nodes
-> now if user_1 and user_2 make some steps, user_3 will be notified, but those
steps "parents" are the steps from user_3, so user_3 may not request a full
history comparison and may never get the missing step

Fix:
-> when a RTC_DATA_CHANNEL_OPEN event happens, the connected client is notified
of the last registered step so it can call GET_MISSING_STEPS if it does not have
it

Note:
This fix solves the specific case mentioned above, but other cases of
desynchronization may happen, see Task-3208277 for a more complete fix.

Task-2821374

Part-of: odoo/odoo#104680
2023-04-20 10:51:20 +02:00
Deependra Solanki e82def03f2 [FIX] web_editor: fix /image for pictogram not working
Before this commit:

clicking on the pictogram, the pictogram is not being displayed on the note.

After this commit:

pictogram is being displayed on the note.

task - 3249342

closes odoo/odoo#119010

X-original-commit: 05f13260c2bbce2c5c69b3626ccb628776b11c68
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-19 11:01:24 +02:00
Stanislas Gueniffey ca7bb3f8a7 [FIX] web_editor: fix powerbox search term split
Before this commit, the term used to filter the powerbox commands was
split with a simple .split('') call, separating each character. This was
erroneous as it disregarded the fact that special characters are first
escaped with a leading backslash (e.g. '\['), the combination actually
representing a single character '['. Separating those pairs would render
the constructed regex invalid when using such characters, resulting in a
traceback.

This commit replaces the use of split with a match, regognizing the use
of backslashes for escaping.

closes odoo/odoo#118922

X-original-commit: e34e908a06c18ecee5d762f6fca785b23977f47d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-18 19:28:57 +02:00
Renaud Thiry c5bb2d0838 [FIX] web_editor: prevent editing of header
The way the live HTML editor for html_field works means the header
(and other nodes that should only appear once) are removed
and the content inserted inside the body.
This results in values being edited without the user being aware.

For emails, this results in any email using 'style' in the header
to break on GMail and other clients that do not support 'style'
outside of the header.

When an html_field is passed a value containing a header
the html_field appears readonly and the user is able to toggle
the code view. Which enables them to edit the 'raw' HTML and see changes
while preventing the presentation view from affecting the database value

task - 3035163

closes odoo/odoo#118920

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Thiry Renaud (reth) <reth@odoo.com>
2023-04-18 18:29:08 +02:00
Pulinckx Pierre (PIPU) 800223ae7c [REF] *: Replace underscore _.each() by native JS
Replaced _.each() functions (average 235 occurences)

Description of the refactoring this PR addresses:

Current behavior before PR:

There are underscore.js function enumerated above used in odoo.

Desired behavior after PR is merged:

These functions has been replaced by native javascript
prototypes/methods/functions.

TaskId : 3246238

closes odoo/odoo#118565

Signed-off-by: Georis François (fge) <fge@odoo.com>
2023-04-18 15:38:54 +02:00
Benoit Socias 02ed9f5e66 [FIX] website, *: avoid using unescaped query parameters
*: google_recaptcha, web_editor, website_blog, website_event_booth,
   website_event_exhibitor, website_event_track, website_forum,
   website_jitsi, website_sale_comparison, website_slides,
   website_livechat, website_twitter

This commit fixes improperly escaped query parameters across javascripts
of website-related modules.

See https://github.com/odoo/enterprise/pull/31711

closes odoo/odoo#118599

X-original-commit: 89be076aa51b097ada48d0046006be4d9692ac1e
Related: odoo/enterprise#39783
Signed-off-by: Bojabza Soukéina (sobo) <sobo@odoo.com>
2023-04-18 11:33:46 +02:00
Antoine Guenet b90b0904f0 [FIX] web_editor: properly undo unlink
When clicking on a button from the link popover, the popover gets
hidden, which pauses the editor's mutation observer until the popover is
fully faded out. This is problematic when the button in question calls
an editor command which we need to be able to undo, since the mutation
observer will still be paused during the command execution. This lets
the buttons' listeners handle the hiding of the popover themselves to
prevent this race condition.

closes odoo/odoo#118248

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-04-18 10:29:49 +02:00
Antoine GuenetandBenoît Socias bd21ea8323 [FIX] web_editor: implement unlink without relying on execCommand
Before this commit when a button containing a text then an icon was
unlinked in Chrome, all further buttons were also unlinked (see steps
below).

It turns out this bug is due to the browser's `execCommand`
implementation so this commit reimplements the feature without relying
on it.

Steps to reproduce (in website module):

* drop Text+Image snippet twice
* inside first button type /image and insert a pictogram after the text
* click on the text of the first button => the link popover appears
* click on the unlink button of the popover
=> both buttons become flat texts in Chrome
=> nothing happens visually in Firefox, but the <a> actually gets
turned into a <span>

task-2778912

Part-of: odoo/odoo#118248
Co-authored-by: Antoine Guenet <age@odoo.com>
Co-authored-by: Benoît Socias <bso@odoo.com>
2023-04-18 10:29:49 +02:00
Benoit Socias f9c342374c [FIX] web_editor: allow aligning pictograms to the right in cards
When replacing an image by a pictogram inside columns, the pictogram
right-alignment is neutralised by the fact that the section of the card
inside the column spans over 100% width.

This commit makes pictograms in those sections rely on their auto width
instead - thus letting the right-alignment happen as expected.

Steps to reproduce:
- Drop a "Columns" block.
- Replace an image by a pictogram.
- Select the pictogram.
- Click on the "Float Right" icon in the toolbar.
=> Pictogram remained aligned to the left.

task-2841127

closes odoo/odoo#118684

X-original-commit: c3eae07259cb38656aa910ad98d0da04f4fc7edb
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-04-17 10:34:32 +02:00
Benoit Socias f9435feb39 [FIX] web_editor, web_unsplash: use preset colors on illustrations
Since [1] when the media dialog was rewritten, the illustrations
thumbnails were not using the preset colors.

[2] did partially implement the solution: the updated images with the
right colors were not replaced in the DOM.

This commit continues what [2] started and displays the illustration
thumbnails with the preset colors.
It also assigns a media type to all fetched images.

[1]: https://github.com/odoo/odoo/commit/7fd0698cf765a79959566b51e33cb76bff83d344
[2]: https://github.com/odoo/odoo/commit/f2111cb37a572fe1ffd9b303c4abcbb7fe1d67cd

task-3060679

closes odoo/odoo#118556

X-original-commit: 75cc46c4f784edb1fb7404956e1cfdf6fae6a83c
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-04-14 11:49:25 +02:00
Younn Olivier 23b2486666 [FIX] web_editor, web_unsplash: scroll to "load more" button upon search
[1] refactored the Media Dialog using owl and the backend Dialog
component.
Doing so, the width of the dialog was reduced (using the standard
.modal-xl class). With that change, the "load more" button was not
always visible for the user.

It is acknowledged that the current Media Dialog needs a deeper UI
review. In the meantime, it was decided to scroll to the bottom after a
search/click on the load more button.

This commit implements that solution with a ref on the "load more" div.
It is used in a scrollToLoadMoreButton, that is called each time after
loading a new attachment/illustration/unsplash record. As we do not want
a jump in the UI each time an image is loaded, the function is
debounced.
It is simpler to use a debounced function that we call each time an
element is loaded, than keeping track of each loaded element to call
the function only once, when they are loaded.

[1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

task-3060679

X-original-commit: 4921442690e6f5b587441a653f73c3368155422e
Part-of: odoo/odoo#118556
2023-04-14 11:49:24 +02:00
Younn Olivier 12c9d85ba2 [IMP] web_editor: load more illustrations only when filter is set
Before this commit, clicking on the 'load more' button of the media
dialog after a search (with no filter set) would load more
attachments/illustrations/unsplash records.

As illustrations are considered less relevant than attachments/unsplash
records, it was decided to load more of them only when the filter is set
to "illustrations".

When the filter is not set, the 'load more' button will be visible only
if there are more attachments or more unsplash images to load (and not
visible otherwise, even if there are more illustrations to load).
Also, the loadMore override will only perform the query to load more
illustrations if the filter is set.

A deeper review of the Media Dialog UI will be conducted later. For now,
this commit avoids loading too many illustrations, for users that are
most of the time more interested in the unsplash results.

task-3060679

X-original-commit: 6aaca71a4b2a11ffa80578904bc7c79c1fa0339d
Part-of: odoo/odoo#118556
2023-04-14 11:49:24 +02:00