Commit Graph
2957 Commits
Author SHA1 Message Date
Romeo Fragomeli 51db7cd7b6 [FIX] *: some border aren't apply anymore
* = digest, hw_posbox_homepage, im_livechat, mass_mailing, web_editor,
website, website_slides_forum

Since the migration of Bootstrap 5 [1], some CSS rules was automatically
converted (`border-left` and `border-right`) when it shouldn't be.
These conversions were made because the CSS rules was embedded in
HTML/XML code and the REGEX for the conversion had no protection for
these cases.

This commit restores the old correct value.

Ref:
[1] odoo/odoo@1fcd098af5

closes odoo/odoo#110141

X-original-commit: 0cbf7c00ecc307fc725da345415647828e771bb4
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
Signed-off-by: Romeo Fragomeli (rfr) <rfr@odoo.com>
2023-01-17 18:12:48 +01:00
David Monjoie 462f2517f6 [REV] mass_mailing: revert automatically open linktools when clicking a link
This behavior only made sense with [1] applying in all cases, but
since it was wrong to begin with (because of the "Plain Text"
template) and was reverted in the previous commit of this PR, then
the behavior does not make sense anymore, as the dialog would open
as soon as the user clicks on the link.

This reverts commit aaf70d3692.

Task-3128388
Task-2889670

[1] https://github.com/odoo/odoo/commit/61f7366d686b353ae9614285370e952253ec067c

X-original-commit: 33e5dcdb41ae2d4bb2a47ea3fd92f522b09b53e8
Part-of: odoo/odoo#110089
2023-01-17 11:34:32 +01:00
abd-msyukyu-odooandAntoine Guenet a817a865c3 [FIX] web_editor,knowledge: suspend wysiwyg onBlur with dialogs
Sometimes, there is a crash when uploading a file when loading an article for
the first time.

Impacted versions:
16.0+

How to reproduce:
- open the odoo home page (module menu) and CTRL+f5 (force reload)
- go to the knowledge app
- in an article, put the cursor somewhere and type ENTER to create a new line
- type the /file command in that line
- try to upload a file
- traceback (if it does not happen, try again from the first step, it is not
  always consistent)

Fix:
Delay the _onBlur handling of the wysiwig when using the modal. The Blur event
may occur and may trigger an update on the html_field, which may in turn induce
a rerendering of the component and its value.
We don't want this to occur when using the modal, because the selection was
registered by the modal to restore it when the modal closes (`preserveCursor`).

If the contents of the html_field are updated, then the stored position used to
restore the selection won't be in the DOM anymore, and the restoration will
fail. As such when we try to insert the Knowledge file block, the selection is
not in the editor and the method fails.

Task-2889670
Task-3128388
Task-3086694

X-original-commit: 2591d343793f59e2e70e7ffe8fa666661995348f
Part-of: odoo/odoo#110089
Co-authored-by: Antoine Guenet <age@odoo.com>
2023-01-17 11:34:32 +01:00
Dmytro Lazariev 67328ebd39 [FIX] web_editor: fix missing allow_command_image XML option
Both `allow_command_video` and `allow_command_image` options are supported by the
editor, but only `allow_command_video` was being sourced from the XML of the view.

This works:
<field name="body" widget="html" options="{'allow_command_video: false}"/>

But this didn't work without this commit:
<field name="body" widget="html" options="{'allow_command_image': false}"/>

It looks like that particular option was simply forgotten. This commit rectifies that.

Impacted version:

 - 16.0
---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

closes odoo/odoo#110088

X-original-commit: c81c5918e6ba2f263e173b27978194de1f71f1db
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-17 11:34:27 +01:00
David Monjoie 3f320c8a93 [FIX] web_editor: fix toolbar not hiding when clicking outside of editable
Commit [1] correctly disabled some of the behaviors of the editor
that used to modify the selection outside of the editable. However,
it also had the inadvertent side-effect of disabling the toolbar
update mechanism when clicking outside of the editable.

Behavior before this commit:
When the toolbar is visible, clicking outside the editable zone
does not hide the toolbar.

Behavior after this commit:
Clicking outside of the editable zone hides the toolbar.

[1]: 07a1483967

task-3131435

closes odoo/odoo#110044

X-original-commit: 28a35a6b53493abd03e42cc30d164262c86b6de5
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-17 09:14:49 +01:00
vishal padhiyar a3d20bd96d [FIX] web_editor: inconsistent behaviour of the font size selection
Before this commit:

Selecting some text and changing its size will never allow you to select 13 and
selecting default will make the text bigger than the surrounding text.
Example in project: the default size is 13px (the editor parses that info and
display 13px as the font-size), but if you want to set any text to that value
you can't. Users could set any text to that value by selecting
"default" font-size instead of 13

After this commit:

"default" sets to "font-size: medium", which is often not correct. It should
instead, do a "font-size: inherit" so that it's the default for the current
context. Hence, removed that medium font-size rule and let the cascade do it.

Task-3095887

closes odoo/odoo#109835

X-original-commit: 9878579f62b493958bb6a98e2cdc466bfc2954d8
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-13 17:33:17 +01:00
Rodopho Cammarosano de Lima (rcdl) 242f47cd86 [FIX] web_editor: fix copy to clipboard issues
Issue # 1:
Before this commit, copying an empty selection (collapsed range)
produced a Traceback. Making onClipboardCopy return when the selected
range is empty serve as double purpose: avoid that trace and not
overwrite clipboard content with an empty string (leaving the
previously copied content available for pasting).

Issue # 2:
Before this commit, copying a selection that spans over two or more lines
was producing a text/plain content without line breaks. This happened
because the text was obtained getting the innerText property of a detached
element (thus, not being rendered). In such case, the returned value is
the same as textContent, which just concatenates the text content of
text nodes (thus ignoring BR elements). Selection.toString(), for
instance, represents line breaks in the selection as '\n' in the
resulting string.

This commit also removes 2 harmless but useless lines:

  if (!clipboardEvent.clipboardData.getData('text/plain'))

  if (!clipboardEvent.clipboardData.getData('text/html'))

A copy event handler cannot read the clipboard data.
(see https://developer.mozilla.org/en-US/docs/Web/API/Element/copy_event)
The expressions in the if-conditions above always return true,
as getData will return an empty string.

Finally, this commit also adds basic unit tests for copying and cutting that
were missing.

task-3114102

closes odoo/odoo#109757

X-original-commit: 3a4be5116c23e12129d6e8c9d841a17a57a710a9
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-12 14:34:53 +01:00
Romain Derie 553703cc02 [FIX] web_editor: fix full link url of the link preview
Since its introduction with [1], there is an issue about the full link
URL which is never set.
The preview has 2 URL elements:
- The main one, for which the text will either be the URL itself for
  external website or the page title for internal pages.
- The "full one", which will simply be the full URL for internal pages.
  It's basically the text of the "main one" which is moved here when
  there is a title to display.

But the "full one"'s url was never set, always being "#", meaning that
when you click on the title you land on the correct page but when you
click on the URL itself you don't go to that page.

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

task-3129267

closes odoo/odoo#109716

X-original-commit: 015c9bf111899b2a86c39b24cd1ec2d4e5278204
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-01-12 12:27:13 +01:00
Jason Au Yeung 6a174c8eb1 [FIX] web_editor: only bind cut/copy event to editor
Before this commit, cut/copy operation in non-html fields will trigger the _onClipboardCut/_onClipboardCopy handler as long as there is html field in the same form view.

This will cause cut/copy fail when using chrome or edge.

Only bind cut/copy event to html field as these event handlers are not related to non-html fields.

closes odoo/odoo#109624

X-original-commit: 494f8300f848cf258ba8ba0132af104346083b3e
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-12 11:09:31 +01:00
Benoit Socias 3ef5004c13 [FIX] web_editor: merge inline elements into previous color font
Before this commit when a color was applied on a text that spans several
nodes, it was wrapping each text node in a font node to which the color
was applied. Because of this, applied gradient colors were restarting on
each text part. (e.g. before a bold section, on the bold section, after
the bold section: each had a distinctly drawn gradient)

After this commit the bold and italic nodes are considered similar to
text nodes and are wrapped inside a common font node to which the color
is applied - using the mechanism that already existed for text nodes.
Actually applied on all visible inline & inline-block elements that do
not contain a font node (and are not buttons).

task-2666200

closes odoo/odoo#109537

X-original-commit: 8c965cad4d3fdbfefbbd5caa43d8c21e3a8e064f
Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-01-11 09:38:53 +01:00
Benoit Socias bae305fd24 [FIX] web_editor: span gradient across text style changes
Since [1] the gradient text image was reset within each font or span
block (e.g. for applying bold style).
The change was done because Chrome does not inherit the involved styles
when a transform is used, which is the case in animated texts.

After this commit the inherit style is only applied on animated texts.
This lets the gradient span across style changes.
Note that there is no solution yet for animated texts: they still have
a restarted gradient.

Steps to reproduce:
- Drop a Title block in a website page.
- Add a few words.
- Select the whole title's text.
- Make its text color a gradient. (Not the background color)
- Select the second word (avoid picking the word in the middle to
easily see the visual impact).
- Make that word bold.
=> The gradient restarts within the bold word instead of continuing
across the whole text - even though no text animation is used.

[1]: https://github.com/odoo/odoo/commit/187acb938f70a2130d25fa76079221339c742f1e

task-2666200

X-original-commit: 372eeebb47b93890d567185879981e817cdc1326
Part-of: odoo/odoo#109537
2023-01-11 09:38:53 +01:00
Benoit Socias d824a17344 [FIX] web_editor: reset m2m suggestions also after RPC returns
Since [1] when the m2m widget was introduced, when the network latency
is high enough, the `_search()` method can be called several times in
parallel. The former list of existing records is removed before doing
the RPC call, then populated with the results received after the RPC
call returns. With the proper timing and race conditions, this could
lead to having the list cleared several times, then populated several
times with the incoming results.

This commit makes sure the list is cleared after the RPC results are
obtained instead of before.

Steps to reproduce:
- Create and save a blog post with several tags.
- Edit blog post.
- Configure network latency to one second in browser's developer tools.
- Remove one tag.
- Remove another tag after 500ms. (Because the search happens after a
`setTimeout`.)
- Open tag suggestions.
=> List contained the concatenation of the two suggestion lists.

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

task-2811746

closes odoo/odoo#109479

X-original-commit: 48564abe484f61c09ca98c3cddd5b4b0b55e6497
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-01-09 21:15:45 +01:00
Benoit Socias 396ac318d9 [FIX] web_editor: restore m2m create text value before create
Since [1] when the m2m widget was introduced, events that were neither
from the create input text nor the create button did remove the internal
value of the text that was entered in the create input text.
Because of this "Create" had no effect if the user hovered e.g. a
suggested blog tag on its way to pointing to the "Create" button.

This commit replaces this behaviour by restoring the text value of the
create input when the create button is used.

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

task-2811746

X-original-commit: 59ecbb96db75a77cdcce11460cdbe8aa04438449
Part-of: odoo/odoo#109479
2023-01-09 21:15:44 +01:00
Antoine Guenet 2f196d1eb1 [FIX] web_editor: properly paste pre in pre
Commit [1] attempted to fix unexpected behavior when copy-pasting from a
<pre> to a <pre>, where the pasted text was smaller the intended, and
preceded and followed by new lines. The chosen approach had uninteded
side effects though as it removed any empty paragraph after the <pre>.
The source of the issue it tried to fix was that the pasted <pre> was
inserted as a new <pre>, splitting the existing element in two in the
process, instead of simply inserting the text content.

[1] 449cacf

task-3086603

closes odoo/odoo#109208

X-original-commit: dfcc3abe3396eaf764c3c3c8510b654649ed82f8
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-05 16:52:10 +01:00
Antoine Guenet 759d6972c2 [FIX] web_editor: prevent selection in root after insert
The insert command ends with setting the selection to the "right" of the
last inserted node. However, it did this without checking if that
position was valid for the selection, so we could end up with the
selection directly within the root of the editor. This corrects it if
such is the case.

X-original-commit: 722cf3bf11fcc9839677837018c1389d65b3f4fa
Part-of: odoo/odoo#109208
2023-01-05 16:52:10 +01:00
Guillaume (gdi) bc1b242021 [FIX] web_editor, website: debounce we-range events
This commit allows to debounce the events of the RangeUserValueWidget so
that the user can use this widget with the left and right arrows without
having a lag effect (especially on the image quality option).
In addition, steps were added in the website_gray_color_palette tour to
let the time for the debounce to trigger the changes.

task-2601533

closes odoo/odoo#109165

X-original-commit: dddec7489f5cb4e48368684a8783015517c394ee
Signed-off-by: Bojabza Soukéina (sobo) <sobo@odoo.com>
2023-01-05 15:37:34 +01:00
Benoit Socias 6657a54d10 [FIX] web_editor: support scientific notation in styles
When a big number is entered in an option field with units, it gets
automatically converted to scientific notation (1e+10) by Chrome.
This makes the unit conversion code fail because it mistakenly
interprets the 'e' as the unit.

This commit adapts the used regular expressions in order to include
the complete number in the number part even if it is written in
scientific notation.

Steps to reproduce:
- Use Chrome.
- Drop a "Banner" block.
- Set the "Position" to "Repeat Pattern".
- Type a long number in the "Width" option.
=> Error popup.

task-2853161

closes odoo/odoo#109078

X-original-commit: a554e102a7f9ca2a0b7f64573adffa4b26a0b813
Signed-off-by: Bojabza Soukéina (sobo) <sobo@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-01-05 11:35:52 +01:00
Benoit Socias 55b9e4c588 [FIX] web_editor: compare size CSS properties
When CSS properties are updated, a check is made to verify whether the
new value is different from the old one. This process sometimes involves
unit conversions.
Since [1] when a CSS property is updated, it is also set before the
check, in order to verify whether it should be set as `!important`.
When the CSS property is a size, such as the `background-size` CSS
property, it is made of two dimensions. However the verification does
not handle that situation: it handles `15px auto` as being a single
number with the unit `px auto`, which is wrong.
The full comparison is made because the strings do not fully match:
when a size property is set to a measure followed by `auto`, it is
returned without `auto` when reading the computed style.
E.g. after setting `15px auto`, it is read as `15px`.

This commit adapts the CSS properties comparison mechanism by splitting
the size properties into their parts and comparing each part separately.

This commit also introduces a few tests about the already existing
CSS properties comparisons.

Steps to reproduce:
- Drop a "Banner" block.
- Set "Position" as "Repeat Pattern".
- Type "5" in the "Width".
=> It raised an error.

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

task-2853161

X-original-commit: 07e471b9398e042c45182f1e8ca33e74dd8087a3
Part-of: odoo/odoo#109078
2023-01-05 11:35:52 +01:00
Benoit Socias d34c1e027b [FIX] web_editor: fix handling of the CSS !important marker
Since [1] the mechanism that was introduced in [2] is broken because a
snapshot of the property value is used instead of the dynamically
computed property value to determine whether the `!important` marker
should be set on the modified property.

This commit makes sure the value is obtained for each comparison
instead of relying on a snapshot across all comparisons.

Steps to reproduce:
- Drop a Banner block in a website page.
- Select the box.
- Set the background to a custom solid color.
=> The `background-color` style has the `!important` marker on it, while
it should not.

[1]: https://github.com/odoo/odoo/commit/815d1f775c13ad9d4463c2d571dffc4691e81a35
[2]: https://github.com/odoo/odoo/commit/d3c3dab8950abc25b29937605091d8ce32305fa4

closes odoo/odoo#109117

X-original-commit: fff46efc04cbce3ff5bff1ded501197fbd5dca84
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-01-05 09:30:17 +01:00
Nicolas Bayet 7e0395feb1 [FIX] web_editor: prevent collaboration to restart
When a record gets deleted, there is no more collaborationResId.
If there is no collaborationResId, prevent the collaboration to
restart, otherwise it will try to subscribe to a channel.
When trying to connect to a channel without record, there
is a cache miss being logged.

Task-3045910

closes odoo/odoo#108933

X-original-commit: e15e8fa1b039cb200686cf49f49075ec7d5486d4
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-02 20:39:39 +01:00
Benoit Socias 638d0e875d [FIX] web_editor: prevent dropping form fields outside of their form
Drop zones are available outside form when dragging form fields.
This leads to errors whenever the field is dropped outside a form.

This commit removes all drop zones outside the form when a field is
dragged.

Steps to reproduce:
- Edit Contact Us form.
- Drag'n'drop a field to the footer.
=> Error popup (should not be allowed in the first place)

task-2855670

closes odoo/odoo#108863

X-original-commit: 31aec4f89eea5f6095e420137c9603732674901c
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-01-02 13:55:48 +01:00
Rodopho Cammarosano de Lima (rcdl) e9dfb08021 [IMP] web_editor: clean buttons from icon toolbar
Some buttons/actions were unsuitable for icons (were made for images).
fa-icon for toggle icon spin was misleading ("refresh").

task#2737569

closes odoo/odoo#104163

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-02 10:53:51 +01:00
vishal padhiyar b589c95ed9 [FIX] web_editor: mailto in footer not working
Before this commit:

While creating a website: in the footer, when trying to edit the link mailto:
there is an "https://" added and preventing the link to work successfully.

After this commit:

- Whenever we try to edit mailto link and save it then in _parse(node) function
  it will set link label as new URL.

- For that we add condition by which it will avoid further operations and Now
  when we try to edit link mailto then there is no "https://" added and link
  works successfully.

Task-2977682

closes odoo/odoo#108639

X-original-commit: 680a204b952e6281d7e1bcdfe0730688ee698a9d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-02 09:54:09 +01:00
Nicolas Bayet 544afd6de9 [FIX] web_editor: prevent error on font-size change
Before this commit, changing the font size of an element with one
ancestor having the same font size could trigger a traceback. For fixing
that issue some code has to be refactored to handle the setFontSize case
in formatSelection. As a side effect of this refactoring, nested
font-size is now properly handled (see added tests).

task-3086301

closes odoo/odoo#108633

X-original-commit: d003b82043468bcf609006c5910ac8fc9520e136
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-01-02 09:54:07 +01:00
Arthur Detroux (ard)andqsm-odoo be6c45cd1e [FIX] web_editor, website: fix the fonts selection styling
Prior to [1] the font names in the font selection menu had styling.

What [1] broke could be fixed with a simple CSS rule, however, it would
not style custom fonts.

The reason is that the styles from the editor are no longer reloaded
when a SCSS variable is changed since [2]. (To note that after [2] but
prior to [1] the names would not even appear, which [1] fixed.)

This commit fixes that by setting the font-family style manually in
javascript to each widget, and loading the CSS via loadCSS.

[1]: https://github.com/odoo/odoo/commit/c0f2f670eb087991cc9a6a67f4beea5f12bd15f2#diff-70f7fe38208aa7fe678f18e329d3c11b70065dee723921352b6005774e8bab53R131
[2]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b

task-2978623

closes odoo/odoo#108819

X-original-commit: 0cbb8397ae6d57817efa5721dda8b6a0526aa43b
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
2022-12-30 13:14:40 +01:00
Benjamin Vray 10158dbeb8 [FIX] web_editor: fix auto scroll when moving inner content
Steps to reproduce:

    - Drop enough snippets to have a scrollbar.
    - Drop a snippet with inner content having up/down arrows (e.g.
      showcase,timeline).
    - Move inner content with the arrows.
    - => The element is correctly placed but the screen scrolled along
      with it.

This commit fixes it by preventing the page from scrolling if the
element being moved is still visible after the move. The page therefore
scrolls only if the moved element is not visible after the move.

This commit also improves page scrolling when the element is hidden at
the bottom. Before, the page scrolled to bring the moved element to the
top of the page but now, it stops scrolling as soon as the element is
fully visible.

task-2952200

closes odoo/odoo#108831

X-original-commit: 675ae44803539a807c79fbc32c93b4e5d230816e
Signed-off-by: Bojabza Soukéina (sobo) <sobo@odoo.com>
2022-12-30 10:45:52 +01:00
qsm-odoo 4f9bdbf6c8 [FIX] web_editor: remove light/dark computation based on main color
Commit [1] made the "light" and "dark" colors of bootstrap be very
light and dark variations of the "main" color ("alpha" at the time, now
"o-color-1", which is used as bootstrap "primary" color). It was already
not a very good idea, although slightly better than nothing (at the time
navbar and footer colors could not be changed at all, so without this,
they would use a gray with a blueish hue not related to the main color).

Since then, 2.5 years later, [2] and [3] were made which gave some
control over bootstrap default grays via two widgets controlling the
new "gray-hue" and "gray-extra-saturation" params. At that time, the
light and dark overrides made at [1] should have been removed as "light"
and "dark" normally default to two bootstrap grays, which we would have
had control over since [2] and [3]. This was however, not a big problem
since "light" and "dark" were not used by the website templates (well it
was by some but not a lot) and the overrides to gray colors related to
the main color was not "stupid", just less nice as less control over it.

However, since the many improvements made with [4] more than 1 year
later, the "light" color started to be used to achieve more detailed
designed for the eCommerce. And it is planned to use it in further
design elements later on. The fact that those "light" elements are not
following the "grays" configuration made by the user is thus starting to
be a problem.

This commit fixes the issue in master (>= 16.1): "light" and "dark"
colors will now follow the configured grays. In the future, we might
even improve the control over those two particular grays or maybe
improve their default value according to the theme color palette.
It was judged that stable versions can stay as they are right now. As
explained, it is not critical and you can still force your own CSS rules
if you are really unhappy with the "hardcoded" grays (related to the
main color) at some places.

[1]: https://github.com/odoo/odoo/commit/22c4311e283af95eafe1ba85ee1234bb8102110e
[2]: https://github.com/odoo/odoo/commit/35d27a6c1d3dab621de7f059565d7619ae004412
[3]: https://github.com/odoo/odoo/commit/e08184103c42eaf7f6bfb70655cb90b51e79913a
[4]: https://github.com/odoo/odoo/pull/98558

Related to task-3097005

closes odoo/odoo#108825

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-12-29 19:05:41 +01:00
Benoit Socias d95150c69b [FIX] web_editor: hide "Open in New Window" option for emails
When `link_tools` was introduced at [1], the selectors to the
`is_new_window` input were copied from `link_dialog`'s `_onURLInput`
without being adapted. Later the code was refactored into `link` at [2]
because they were an exact match.
This commit updates the selectors to also match the field inside the
link tools.

Steps to reproduce:
- Edit Home page
- Drop a "Banner" block
- Select the "Contact Us" button
- Change the URL to an e-mail address
=> The "Open In New Window" field was still available

[1]: https://github.com/odoo/odoo/commit/740168ce8d27da3d6a7156d2d79655a898394923#diff-6345b8d133e9b338a77c50a8e5ae824fe405cb9319e98a2ac349b072be07a3a2R321
[2]: https://github.com/odoo/odoo/commit/4a1d776243b059d423152bd026bb8bc758477224

opw-3086198
task-3096806

closes odoo/odoo#108812

X-original-commit: 292dcb99e55178358a64c9879ba4b1721e67d02c
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-12-29 17:10:34 +01:00
Benoit Sociasandqsm-odoo 54746012d3 [FIX] web_editor, website: avoid updating the DOM when selecting a link
When `link_tools` was introduced at [1], `_onURLInput` did only update
the configuration form and did not touch the edited DOM. Even though its
name would be misleading for that purpose, it was therefore used without
issue as an event handler responding to the configuration form input
events and as a private method called in the `start` method of the
widget lifecycle.

At a later stage, with [2], DOM modifications were introduced in
`_onURLInput` (using the misleading `_adaptPreview` method whose
refactoring at [3] made it update the configuration form only in the
case of the "Link Dialog" but update the actual link DOM for the "Link
tools" (website / mass mailing)).

This commit fixes that behavior by touching what is strictly necessary
in stable to keep the original intend of `_onURLInput` (updating the
configuration UI) but at the same time update the DOM following
configuration form input events (as intended by [2]).
In master, all of this should be reviewed.

Here are steps which revealed the problem. Although, meanwhile, [4] and
its parents were merged which fixed other parts of this issue but
keeping the potentially problematic DOM update on selection as described
above. Notice that [4] and its parents may be reviewed further in a
future update.
- Edit Home page
- Drop a "Banner" block
- Select the "Contact Us" button
- Select "Custom" style in the link tool
- Select a fill color
- Deselect the button by clicking on the Banner's text
- Select the button again
=> Button is redrawn without its color

[1]: https://github.com/odoo/odoo/commit/740168ce8d27da3d6a7156d2d79655a898394923
[2]: https://github.com/odoo/odoo/commit/226c4c4032c26d3d8f622b29fb151fa8e78ba70a
[3]: https://github.com/odoo/odoo/commit/4a1d776243b059d423152bd026bb8bc758477224
[4]: https://github.com/odoo/odoo/commit/eb4edac560227b46efdcfe958e3b93e0b88def64

opw-3086198
task-3096806

X-original-commit: da25eadde299b81b78d84678978b7e1f703530cc
Part-of: odoo/odoo#108812
Co-authored-by: qsm-odoo <qsm@odoo.com>
2022-12-29 17:10:33 +01:00
qsm-odoo 35d8ffd39a [FIX] web_editor: hide the "no column" option for snippets with columns
Commit [1] which occurred in 13.X for the upcoming release of the 14.0
version introduced a "No column" option for snippets whose only column
was removed but that we wanted having the possibility to switch to a
multi-columns layout. At the time: Title, Text and Cover snippets.

That "None" option was meant to be hidden (as it was at the time) for
other snippets already in a multi-columns layout. Indeed the "No column"
and "1 column" options are very similar: "No column" is just an
optimization for experienced users.

The problem here was that [2] broke the behavior. Indeed [1] marked the
code in charge to hide that "No column" option as "To improve" as the
system was limited to do that at the time... [2] actually improved the
system to allow hiding sub-widgets, but did not adapt [1], making the
"No column" option always visible.

While working and not harmful, that "No column" option may be confusing
as at best you don't see the difference with the "One column" option and
at worst, removing the column removes nice style that you cannot restore
by choosing a multi-column layout again afterwards.

While not entirely stable (in the end we never released a major version
where [1] was working as intended), this commit restores the idea behind
[1] anyway to avoid further confusion and tickets. Choosing "One column"
instead of "None" most of the time leads to a better UX anyway.

[1]: https://github.com/odoo/odoo/commit/b293ccc7c3c5ca9a55092afd2e4a7b88c7b93fc8
[2]: https://github.com/odoo/odoo/commit/ecefd51b63ed8c933243b4a2d26381d05ac288d2

Related to task-3106301

closes odoo/odoo#108757

X-original-commit: 1ff8c9a6a907b4e60f86efc27c82727b288f0947
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-12-28 15:40:43 +01:00
Soukéina Bojabza ec2bc5e47c [FIX] web_editor: fix race condition in grid_layout tour
When trying to replace an image with the media dialog, there is first a
click on the image, which activates the options of the image, and then
a double-click, opening the media dialog to choose the new image.
However, the media dialog does not wait for the image options to be
completely initialized before opening.

This behaviour is in general not problematic but if it happens quickly
enough, in a tour for example, it might cause a traceback. This happens
because the renderings (in `_renderCustomXML`) of the image before and
after replacing it happen too closely, making the first one lose the
reference to the image parent.

This commit fixes this issue by waiting for the options to be fully
initialized before opening the media dialog, that is, by adding an
empty action in the mutex and waiting for it to complete.

runbot-10692

closes odoo/odoo#108738

X-original-commit: 7667ba149aaf179f430615c4aba4b963d1d167c6
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-12-27 20:02:41 +01:00
Benjamin Vray 815d64d48b [FIX] web_editor: removes blue filter on selected image in edit mode
This commit removes the default image selection color (added by this
commit: [1]) used in "web_editor" in edit mode (Website, Email
Marketing). This prevents selected images from being covered with a blue
filter and allows to see the correct final rendering of an image when
it is edited (e.g. Apply a color filter to an image in a website page).

This commit also moves the rule (added by this commit: [2]) that
overridden the portal selection rule to "web_editor.frontend" because it
was applied everywhere even outside of the website/email marketing edit
mode. This rule no longer worked because of the "!important" in [1].

[1]: https://github.com/odoo/odoo/commit/3da301fcb24998333039a7b636cec0e5be8694c6
[2]: https://github.com/odoo/odoo/commit/aa8d2a8be2c8f713b4b39b2aa1ea2aaf1839396c

task-3073192

closes odoo/odoo#108732

X-original-commit: 19bebfc29f5c94ab11dab1fac2e6676eaab51592
Signed-off-by: Guillaume-gdi <gdi@odoo.com>
2022-12-27 16:50:00 +01:00
Benoit Socias 965e2bce29 [IMP] web_editor: align m2m widget label with first element
The m2m widget label is aligned at the middle of the height of the whole
option's display.

This commit makes the m2m widget label aligned with the first element
(either the first active value, or the "Choose a record..." dropdown if
no value is selected).

task-2811746

closes odoo/odoo#108227

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-12-27 13:18:03 +01:00
Benoit Socias 3bbce756c6 [IMP] website, web_editor, *: save dropped images as attachments
*: mass_mailing

When images are dropped from outside the browser into a website page
text paragraph, they are stored as an inline base64-encoded source.

This commit marks those images to be saved as attachments when it
happens in website. The save happens upon page save similarly to what is
done when images are transformed.
This commit also applies this behavior for pasted images.

task-2928495

closes odoo/odoo#98801

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-12-23 19:19:06 +01:00
xO-Tx 3b9406419a [FIX] web_editor: fix shape animation loss
To apply a shape on image, we use its base64 string as source on the
<image/> of the shape svg file. Then, the svg is used as source on the
targeted DOM element (<img/> on snippet).

When the targeted image is an animated GIF, the behaviour is different:

CHROME:
- The animation works correctly.

SAFARI & FF:
- The GIF animation is lost (only on non-animated shapes). The animation
works correctly on the svg file but once it is used as src of <img/> tag,
the animation is lost.

The goal of this commit is to fix this behaviour by forcing the
animation on SVG content.

task-2679905

closes odoo/odoo#108229

X-original-commit: 996acc3977de0346a45da328f42583b4366d1d47
Signed-off-by: Vray Benjamin (bvr) <bvr@odoo.com>
2022-12-22 11:40:52 +01:00
vishal padhiyar e9f99dff16 [IMP] web_editor: improve link popover
PURPOSE

Simply improve the design of the link popover

SPECIFICATION

- "ellipsis" the link preview instead of wrapping it
- only keep a 0.5rem gap between each of the right icons

Task-2916270

closes odoo/odoo#108497

X-original-commit: bb1f37226dcd842abf4ec63ecf037f5ce3a3441b
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-12-22 10:39:35 +01:00
Nicolas Bayet cb3dc19969 [FIX] web_editor: make monetary field unremovable
Before this commit, the span within monetary field could wrongly be
removed. Python code that parse the value (see `from_html` of
`ir.qweb.field.monetary`) expect to have that span available.

This commit make that span being unremovable.

opw-3090775

closes odoo/odoo#108496

X-original-commit: 7576c88fec4f993e525279d15c22077a11132281
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-12-22 10:39:31 +01:00
aath-odoo 9e5be974e0 [FIX] web_editor: spacing when changing format in checklists
Before this commit:

On changing style of a list item to normal it wrapped the content in a <p> which
results in extra spacing to next list item.

After this commit:

Now the content is not wrapped in a <p> which removes the extra spacing as well.

Task-2990517

closes odoo/odoo#108434

X-original-commit: b4cf3bcc893e345c25d863c0afaab71bbbfb404c
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-12-21 16:36:54 +01:00
Antoine Guenet 9143cef960 [FIX] web_editor: do not remove styles of non-custom buttons
This prevents the removal of styles on non-custom buttons, which the
user may have applied to them back when it was possible to apply styles
to non-custom buttons. The removal of styles now only happens when
picking a new link style in the "Style" dropdown, which is what the
removal was intended for.

task-3096806

closes odoo/odoo#108384

X-original-commit: eb4edac560227b46efdcfe958e3b93e0b88def64
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-12-21 12:33:00 +01:00
Antoine Guenet 331346dc60 [FIX] web_editor: keep gradient background on custom button on edit link
If a custom button had a gradient background, clicking in it removed
that gradient. That is because that opened the link tools, which updated
the DOM before having fetched the custom colors.

task-3096806

X-original-commit: c3d22aa0e03588cc8781f015ada9002c6a0a4384
Part-of: odoo/odoo#108384
2022-12-21 12:33:00 +01:00
dhba-odoo 3ec95bba96 [FIX] web_editor: powerbox overflow not visible
Before this commit:

In Email Marketing's Mail Body, The Powerbox is opened below the cursor,
even when there's not enough space between the cursor line and
the window's bottom. As a result, a part of the Powerbox cannot be seen.

After this commit:

Now, the Powerbox opens itself above the cursor line if it's too close to the
window's bottom.

Task-3037435

closes odoo/odoo#108352

X-original-commit: ba888c39716f0226adce993cb08852e21b0376eb
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-12-20 12:33:48 +01:00
Benoit Socias 83651c1053 [FIX] web_editor, *: make the disabled remove form field button red too
*: website

The fields of a form that are mandatory because of the model they need
to be used in cannot be removed. When such a field is selected, the
remove button displays a tooltip giving this information.
Disabling the overlay button is done by removing the specific class -
which makes the event selector not linked to the button, but also
impacts the applied CSS rules.

This commit adds an `o_disabled` CSS class upon disabling the button.
The tooltip is put on a `span` that wraps the disabled button because
tooltips cannot be shown on disabled elements.

Steps to reproduce:
- Drop a "Form" block.
- Select the "Phone Number" field.
- The overlay's delete icon has a reddish background.
- Select the "Your Email" field.
=> The overlay's delete icon had a dark gray background instead of a
reddish one.

task-2950433

closes odoo/odoo#107864

X-original-commit: ed3acbae6a6b2fe91c948ceeb16a5bdb3fa8f060
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-12-20 11:29:15 +01:00
Benjamin Vray 72fa16b9ad [FIX] web_editor: fix display of double overlays in edit mode
Steps to reproduce the bug:

1. Drag and drop the "image - text" snippet.
2. Click on the image => you have a double overlay which appears (one on
the column with handles and one on the image without handles), this is
good, that's what we want: the ability to control the column width but
as the image has options, it should be framed with an overlay too to
indicate what you are editing in the right panel.
3. Hover the column options => good, only the overlay of the column
remains in preview mode (without handles / buttons).
4. Hover the image options => good, only the overlay of the image
remains in preview mode (without handles / buttons).
5. Stop hovering the panel => the double overlay should be restored but
that's not the case: only the column one remains, even though the image
options are still displayed in the panel.

When we introduced the possibility to display 2 overlays at the same
time in this commit [1], we added a loop to search for the overlays to
display since there can now be several.

But in a later commit [2], we added a `break` in this loop, which no
longer allows displaying more than one overlay when necessary.

[1]: https://github.com/odoo/odoo/commit/9bbe5be3fb0d995374a369851df3641979d8e553
[2]: https://github.com/odoo/odoo/commit/806a8db35b5e0e6a461422f5bba7c97180c3ef29

task-2919164

closes odoo/odoo#108334

X-original-commit: ee86f5a94965ce691393f5300bdfb6dc09780b1d
Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
2022-12-20 09:25:42 +01:00
Aaron Bohy 4ed9c18199 [FIX] note,web(_editor): fix html field style
Commit [1] added a div around the `.note-editable` node of the html
editor. This broke some css rules. For instance, the html field in
form view's notebooks should have a transparent bottom border when
focused, this was no longer the case (e.g. crm lead form view).
Moreover, we sometimes want to control the height of the editor
(e.g. in Notes or in the mail full composer). That was broken as
well due to the added div.

This commit fixes those issues.

We also ensure to set the border-radius to 0 when the editor only
has a bottom border.

In notes, we do not want to have borders, but the rule didn't
apply due to selector precedence, we fix that as well.

Finally, we fix a typo in a selector in the web_editor addon.

[1] https://github.com/odoo/odoo/commit/60ac6be0d3545#

closes odoo/odoo#107740

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-12-19 12:43:09 +01:00
Benoit SociasandYounn Olivier ae0253da40 [FIX] web_editor, website: fix form custom fields starting with numbers
Before this commit, following this flow:
- Add a form
- Add a selection field
- Add an option starting with a number
- Save
=> The created form's option value is only the number

From the website_form options, the options HTMLElement of a form field
are generated using the field's records ids for their html element value
attribute (see FormEditor._renderField).

When [1] refactored the website_form options to use a generic
ListUserValueWidget, the list records id computation changed to use
parseInt instead of strings.

This commit changes the detection of parsable int to match only strings
that are made only of digits, and less than 16 of them so that their
value is not lost.

[1]: https://github.com/odoo/odoo/commit/9304f8fa7bb94f21dd4caa83f9679ffd1642691b

opw-2980760

closes odoo/odoo#108248

X-original-commit: 166f4aa4d23a01901585b60d69fac47fe70b7ebe
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
Co-authored-by: Younn Olivier <yol@odoo.com>
2022-12-19 08:20:02 +01:00
qsm-odoo 9776ff0bd2 [FIX] web_editor: review two pairs of shape junctions
As the previous commit explained, there is sometimes a gap between two
shapes due to some browser rounding errors, especially when using
browser zoom. However, there are also some things we can do in our
shapes themselves to decrease this problem.

This commit fixes two pairs of shapes which were easily fixed by
reviewing the rounding of one path and making the viewBox a square
(making a viewBox a square is known to solve issues). However:
- The first pair is not entirely fixed, the error is just reduced.
- The second pair is fixed... but the shapes actually do not join very
  well (somehow the linear gradients do not seem to join properly)...
  but still better than a white line between the two.

Reminder: several commits had attempted to fix this before ([1], [2],
[3], [4]) (and this commit's parent). But that wasn't enough to stop it
happening. Some shapes still need to be fixed although that will likely
be done in future versions.

[1]: https://github.com/odoo/odoo/commit/c0f62593a4da37e8404dddc0a5762879a5ebbf7f
[2]: https://github.com/odoo/odoo/commit/ac82407b259eab929486bf0a333a48bc507efa60
[3]: https://github.com/odoo/odoo/commit/42b3ad10e0b32b7fc72f801e2c67d6baf938c566
[4]: https://github.com/odoo/odoo/commit/e386f318f5cff50901dba3db8a2587911ba02a6e

task-2824607
opw-3069213
opw-3057533

closes odoo/odoo#108228

X-original-commit: 52e5afaa10ca7f2b3183bf6359b42929a9b3704a
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-12-18 23:16:58 +01:00
Benjamin Vray e13743ff2e [FIX] web_editor, website: mitigate line between shapes issues
This commit mitigates an issue with shape elements sometimes having tiny
spacing on their top or bottom edge.

This issue is mainly on Chrome when the user has changed the page zoom.
When the page is zoomed the elements can have a width value with a
decimal part. Because of it, the size of the SVG background images are
not correctly rounded compared to their container and therefore leaves a
visible space.

Steps to reproduce the bug:

- On Chrome, add several shapes on a website page.
- Change the zoom of the page and change the window width.
- At some points, the gap will appear.

The least bad solution we found to fix this is to ensure that the width
of the shape elements is always as close to an integer as possible.

Reminder: several commits had attempted to fix this before ([1], [2],
[3], [4]). But that wasn't enough to stop it happening. Some shapes
still need to be fixed although that will likely be done in future
versions.

[1]: https://github.com/odoo/odoo/commit/c0f62593a4da37e8404dddc0a5762879a5ebbf7f
[2]: https://github.com/odoo/odoo/commit/ac82407b259eab929486bf0a333a48bc507efa60
[3]: https://github.com/odoo/odoo/commit/42b3ad10e0b32b7fc72f801e2c67d6baf938c566
[4]: https://github.com/odoo/odoo/commit/e386f318f5cff50901dba3db8a2587911ba02a6e

task-2824607
opw-3069213
opw-3057533

X-original-commit: 623db525e18931a4dd5794da78be840afc34991a
Part-of: odoo/odoo#108228
2022-12-18 23:16:57 +01:00
Benjamin Vray c54826be4b [FIX] web_editor: fix resizing columns out of parent
Before this commit, it was possible to resize a column so that it
overflows the right border of the row.

Steps to reproduce the bug:
  1. In website edit mode, drop a `media list` snippet in the page.
  2. Select a column.
  3. Resize the column by dragging its left side to the right to make it
  smaller.
  4. Drag its right side to make it bigger and go until the edge of the
  editor => The column overflows and ends outside of the content zone.

This commit prevents the column from overflowing when it has an offset.

task-2837361

closes odoo/odoo#108218

X-original-commit: 1759079cbb084acac0616abfab84b83b1e62ae61
Signed-off-by: Bojabza Soukéina (sobo) <sobo@odoo.com>
2022-12-16 20:38:26 +01:00
Antoine Guenet f45db48f6b [FIX] web_editor: ensure correct root for wysiwyg in iframe
Since the migration to Owl, the root of wysiwyg has been wrongly set.
First, in renderElement, wysiwyg creates an editable element, which it
sets as its $root and $el elements. Then in startEdition, wysiwyg_iframe
creates a new editable element that it puts in an iframe appended to the
$el element. It then failed to change the $root element to that new
editable instead. Since we have a new editable element, the old one
should also not be contenteditable=true.

Because the $root element was wrong (and outside the iframe), all
listeners on it failed, with the effect that at least the link tools and
link popover were broken.

closes odoo/odoo#108186

X-original-commit: 86a8b31879b153bb53249fabfab47d254159effa
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-12-16 19:37:47 +01:00
aath-odoo 1aad11b0bf [FIX] web_editor: command prompt not displaying on focus
Before this commit:

command prompt is not displayed when html field has placeholder.

After this commit:

placeholder is replaced with command prompt when focused.

Task-2881079

closes odoo/odoo#108175

X-original-commit: 16cb4af921fec5483e366ea0a1b402631a7e28f3
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2022-12-16 17:19:58 +01:00