Commit Graph
3387 Commits
Author SHA1 Message Date
Louis Wicket (wil) f1722c7334 [IMP] *: unify sprintf and gettext
Improve gettext to directly handle value injection within translations,
removing the need for sprintf.

closes odoo/odoo#123932

Related: odoo/enterprise#45370
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
2023-08-10 18:14:04 +02:00
Nicolas Bayet 592ca1f02e [FIX] web_editor: remove dead code in html_field
The template `web_editor.assets_edit_html_field` was not used nor
required anymore. The files under that bundle were already included
in the backend.

The template under the key `cssEditAssetId` in html_field.js is in fact
loaded in wysiwyg_iframe.js through the option iframeCssAssets.

Moreover, the line `await getBundle` was doing nothing meaningful as
the bundle assets would not be loaded after being fetched.

task-3446819

closes odoo/odoo#131365

X-original-commit: 4eebfcbdf5428cd1c53bafcd89da7095964ff384
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-08-10 09:11:55 +02:00
Nicolas Bayet 645b6b2c10 [FIX] web_editor: properly fetching of colorpicker template
As described in #129974, the colorpicker cannot cache a promise
protected by `useService`. #129974 fixes the issue by through non
idiomatic practice (calling a service that is not protected by
`useService`). This commit fixes the issue idiomatically.

This commit caches the promise directly from a service and removes the
caching code from the `ColorPalette`.

task-3446691

closes odoo/odoo#130789

X-original-commit: 1d2e54088b0f0e28464ab6aa884fb2e1110e8e04
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-08-10 06:17:03 +02:00
Stanislas Gueniffeyandqsm-odoo 7880c1599b [FIX] web_editor, *: add system for editable medias in non editable envs
*: website

Some specific media items are meant to be editable even though located
in non-editable environments. The typical case in 15.0 is the website
"Team" snippet: it is made of multiple bootstrap rows, each containing
a column with an image and a column with texts. The columns with the
image are only meant to hold that image, it was therefore marked as
non editable to prevent users adding text in there by mistake... but the
image is still meant to be editable. See [1], later fixed by [2].

The problem now is that the system that [2] had to use is quite messy:
the column is marked non editable thanks to the `o_not_editable` class
but the inner images were to be declared editable via some custom JS
method overrides (`_getContentEditableAreas`). The debate about if we
should keep a class-based system and/or a method-override system will be
left to master. This commit although comes with an uniformisation about
this, introducing a new class to declare "an editable media despite its
non editable environment". This is not a counter-part of the class
`o_not_editable`: we do not want the media to be marked with the
`contenteditable` attribute. Indeed, this is actually required since [2]
was not enough to solve the problem. See those steps:

- Add a company snippet in your page
- Change one of the images by an icon
- (Save / Reenter edit mode)
- Try to change the icon again / edit its options

=> You can't. Indeed [2] relied on the media being an image to re-enable
edition on it... but even if it did not, it would not have been enough.
Indeed, icons are forced to being `contenteditable="false"` by the new
editor library (since 15.0 then), last update on that at [3].
We thus needed a different way to differentiate editable media, hence
the introduction of the new `o_editable_media` class.

Note: this system is not perfect, but so is not the whole system about
determining what is editable or not at the moment. In this case, it may
exist cases of a media marked with the class to be editable but end up
in an environment which is not editable by force (xpath somewhere etc)
... and ends up being editable anyway. Most cases work though and at
worse it will be about a non editable image being editable but not
possible to save in very rare cases. As advertised, the whole system
about what is editable or not should be improved.

[1]: https://github.com/odoo/odoo/commit/30db617bc8ff7727f40d7ef58c6578e84a13f284
[2]: https://github.com/odoo/odoo/commit/61270ee8bffb6e85f8ff0d19c7a3889fdce2f486
[3]: https://github.com/odoo/odoo/commit/7646429e894f28f398b7b212e893822c06c7b03d

task-3226172

closes odoo/odoo#131139

X-original-commit: 436265e815684046a37a8b80e4cd520c2bd637f0
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
2023-08-09 21:01:17 +02:00
qsm-odoo 9f183ea0e9 [FIX] web_editor: properly bind dblclick to videos to edit them
Commit [1] refactored the event handler code in charge of handling
double click on media elements to edit them. A mistake was made making
the code consider inner elements of the media instead of the media as a
whole when clicking on it.

Steps to reproduce:
- Enter edit mode on the homepage
- Add a text-image snippet
- Change the image to a video (after dblclick on the image for instance)
- Try to change it back with a dblclick => it does nothing

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

X-original-commit: 4b47ae0022a3e50d53dc02e399412585fc2131ef
Part-of: odoo/odoo#131139
2023-08-09 21:01:17 +02:00
Benoit Socias 205fad17a3 [IMP] web_editor, website: add drop-zone locking and exclusion
Since [1] form fields cannot be moved outside of their form and since
[2] table of contents cannot be nested within another table of content.
Those were implemented with specific references to website classes
within web_editor.

This commit introduces declarative mechanisms for both situations:
- `data-drop-lock-within`: prevents dropping outside the closest parent
that matches the specified selector.
- `data-drop-exclude-ancestor`: disallows dropping within a parent that
matches the specified selector.

[1]: https://github.com/odoo/odoo/commit/638d0e875dcb05191fe833d2f889235891dfb46a
[2]: https://github.com/odoo/odoo/commit/55339cd6a7b7916184893c0fe27b5483683a047a

task-3131384

closes odoo/odoo#130477

Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com>
2023-08-09 13:20:57 +02:00
Jinjiu Liu 3445ac4bb5 [FIX] web_editor: the dirty flag is set for character escaping
Reproduction:
1. Install Note, create a new note
2. Start the Inspector, edit the placeholder <p> element in the
description
3. Replace the element as `<p style="color: rgb(32, 31, 30); font-family
: &quot;Segoe UI&quot;, &quot;Segoe UI Web (West European)&quot;, &quot;
Segoe UI&quot;, -apple-system, BlinkMacSystemFont, Roboto, &quot;Helveti
ca Neue&quot;, sans-serif; font-size: 15px;">dsfhislahflidsahisa</p>`
4. The saving icon appears, click it but it will always be there, e.g.
always dirty

Fix: instead of comparing the raw value of the prop value and editing
value, we parse them and compare after the parsing

opw-3341605
task-3434080

closes odoo/odoo#131245

X-original-commit: eda483bd3c3bdc42b95f17a5278c1a9eb83adb05
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Jinjiu Liu (jili) <jili@odoo.com>
2023-08-09 03:08:29 +02:00
Nicolas Bayet f5405d61e7 [FIX] web_editor,mass_mailing: remove unnecessary loading of html2canvas
Since #119325, html2canvas is not used for the toInline process anymore.
Loading the script was still done in the web editor and mass mailing,
which is not needed anymore.

task-3446888

closes odoo/odoo#130862

X-original-commit: e3c9d3c4fb013124faf6d132297171a34854f991
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-08-09 01:53:07 +02:00
Pierre Pulinckx (pipu) b1ebe3b6f4 [REF] *: Replace core._t imports
In this commit, _t import from import { _t } from
"@web/legacy/js/services/core" and from
 web/static/src/legacy/js/core/translation.js are replaced by
@web/core/l10n/translation.js.

task-3292454

closes odoo/odoo#130865

Related: odoo/enterprise#45270
Signed-off-by: Michaël Mattiello (mcm) <mcm@odoo.com>
2023-08-09 00:13:08 +02:00
Aurélien (auma) 12f004f281 [FIX] web_editor: fix uneditable block when height > 10000px
When applied, this commit will restore the edition of a block when
the content has a height > 10000px.

Steps to reproduce:
1) Go to a runbot
2) Go to a blog or on the homepage
3) Enter edit mode
4) Add some text in one bloc with a total height above 10000px
5) The text will be uneditable on the top

Current behavior:
If the text is too important in one block (more than 10000px),
the text will be uneditable

Expected behavior:
The text should be accessible and editable even if the block
has too much content

opw-3393570

closes odoo/odoo#130965

X-original-commit: 493d31a9b2f6508e1e48627ff510120f93870c4e
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-08-07 19:57:57 +02:00
Michael (mcm) 00d8aef1c7 [REF] web, *: remove legacy patch
This commit removes legacy patch/unpatch functions and adapts their use
by using the modern patch. There was also a custom patch function used
in tests which has been replaced too.

closes odoo/odoo#130867

Related: odoo/design-themes#685
Related: odoo/enterprise#45271
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-08-07 10:58:48 +02:00
abd-msyukyu-odoo 5feda35e6f [IMP] web_editor: put rollback code assignation on its own line
If the `_toRollback` property of the editor is assigned on its own line, it is
easier to identify which assignation caused/prevented a rollback when
debugging.

closes odoo/odoo#130894

X-original-commit: 263dcbaf9aa0c48bd61bf85b091c746d7850cfe1
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-08-04 16:35:12 +02:00
Aaron Bohy 8a787f1866 [REF] web,web_editor: move SmoothScrollOnDrag to editor
This commit moves the smooth scroll on drag helper from web to
web_editor, which allows us to move it from frontend and common
assets to web_editor.assets_legacy_wysiwyg which is only loaded
in the website editor, the only place where it is used.

Note that it uses legacy Class and mixins, so it still needs to be
converted to the modern codebase, alongside editor snippets.

Part of task~3439226

closes odoo/odoo#130813

Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-08-04 12:21:58 +02:00
dhba-odoo a1f8de1454 [FIX] web_editor: avoid traceback when copying a list from a table
Before this commit:

When a user attempted to copy a list from a table, it would result in a
traceback.

After this commit:

Now, when a user copies a list from inside a table, the traceback error
will no longer occur.

Task-3384289

closes odoo/odoo#130759

X-original-commit: 53f5b98b350f6d7db80d2d1921c91c28ed7c3148
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-08-04 09:43:16 +02:00
Aaron Bohy 850427e4ba [REF] web,mail: remove legacy MockServer and related utils
This commit removes the legacy implementation of the MockServer
and test utils making it available in the test environment (e.g.
addMockEnvironment).

Part of task~3439226

closes odoo/odoo#130671

Related: odoo/enterprise#45141
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
2023-08-04 09:43:08 +02:00
Antoine (anso) 59828459ad [IMP] mass_mailing: restore sheet
This commit restores the sheet layout in mass_mailing for consistency
reasons.

The chatter was extracted from the tab it was in and moved back on
the right side.

This commit also fixes an alignment problem when an alert is displayed
and the alert was vertically bigger that the buttons of the status bar

task-3355071

closes odoo/odoo#130616

Forward-port-of: https://github.com/odoo/odoo/pull/126646
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2023-08-03 19:31:36 +02:00
Robin Lejeune (role) 73317cb9d1 [IMP] web_editor, website: use consistent margins on buttons
Commit [1] added a margin-bottom on buttons within snippets to make some
breathing space when several buttons follow each other and appear on
multiple lines on mobile.
However, buttons added by the customer do not have a margin, which
causes misalignment when they add it next to a prebuilt button.

This commit checks that whenever a user adds a new button, if any of its
direct siblings is a button, the newly added button and its button
siblings get an appropriate margin-bottom.
It also reverts commit [1] and removes the `mb-2` class on the button in
`s_text_cover.xml` from commit [2], as it is not needed anymore with
this new behavior.

task-3369604

[1]: https://github.com/odoo/odoo/commit/075e915
[2]: https://github.com/odoo/odoo/commit/5ac340b

closes odoo/odoo#125824

Related: odoo/design-themes#680
Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
2023-08-03 19:30:52 +02:00
Michael (mcm) 9d6b380a24 [REF] *: adapt patches after new patch function
In the commit [1], the patch has been refactored to support the
native keyword `super`. The current commit just adapts the codebase
to that change.

task 3410198

[1]: 19ea1ac08043e22a811630968e44715cc3bfc495

Part-of: odoo/odoo#125716
2023-08-02 17:29:05 +02:00
Benoit Socias cd46857b15 [FIX] web_editor, website: use dataset mimetype when modifying images
Since [1] the mimetype used when calling `modify_image` was obtained
from the data URL contained in the `src` attribute instead of the
dataset. This is wrong for background images because they do not have an
`src` attribute.
Thanks to [2] which repaired the value contained in `dataset.mimetype`,
this value can be used as it was before [1].

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

task-3446438

closes odoo/odoo#130322

X-original-commit: e3221fe5d5efa824365210f040e93654e0a30309
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-08-02 05:10:48 +02:00
Nicolas Bayet 1feeeda8b8 [FIX] web_editor: synchronise fields with oe_unremovable
When the mechanism that synchronise odoo fields contained an
unremovable, even though no unremovable got removed, the Odoo editor
would rollback as the syncing mechanism would set innerHTML to the
synced nodes, which would remove the unremovable. To prevent the
rollback in that kind of circumstance, this commit introduce a new
method on the OdooEditor `withoutRollback`.

task-3436834

closes odoo/odoo#129320

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-08-01 15:09:24 +02:00
Deependra Solanki 0c4d747aaf [IMP] web_editor: different numbered list marker at each level
Purpose:

To make the marker of a ordered list different at each level.
- Numbers for first level.
- Alphabets for second level.
- Roman numbers for the third level.
looping back to numbers if nested further.

To make the marker of a unordered list different at each
level.
- Disc for first level.
- Circle for second level.
- Square for the third level.
looping back to disc if nested further.

task-3412826

closes odoo/odoo#128532

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-08-01 15:09:17 +02:00
Rodolpho Lima cdc8e4daad [FIX] web_editor: images stored as base64-encoded sources
Commit [1] introduced an option in the Wysiwyg widget to save pasted
and dropped images as attachments instead of keeping them as inline
base64-encoded sources.

In order to prevent records from having excessively large sizes in their
html field content, this commit makes such option the default one for
the Wysiwyg class.

task-3289061

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

closes odoo/odoo#130213

X-original-commit: 7e06b40ea58f58069729f881f7d4559d17778fe7
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-08-01 13:51:40 +02:00
Pierre Pulinckx (pipu) 60fe2e9b17 [REF] *: remove _lt()
In a previous commit 8bfa76a, _lt() returns _t().
So, in this commit, all usages of _lt() are replaced by _t().

task-3292454

closes odoo/odoo#130179

Related: odoo/enterprise#44906
Signed-off-by: Luca Vitali (luvi) <luvi@odoo.com>
2023-08-01 13:51:17 +02:00
Pierre Pulinckx (pipu) 3bc94e52ce [REF] *:Replace moment usages with luxon
luxon and moment are both used in the solution,
but these two libraries facilitate the manipulation
of dates. It was decided to replace all uses of
moment with luxon so we can then remove
moment.js from the code and lighten the assets.

task-3391739

closes odoo/odoo#128752

Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
2023-07-31 19:02:45 +02:00
Gaetan Vanden Bergh (gavb) 2008cff999 [FIX] web_editor: not access cssRules from other domains
domain = host = hostname + port

Cause: https://github.com/odoo/odoo/pull/125251

Steps to reproduce:
- Add in the custom with a href's host different than the current database host
- Open website
- Edit it
- Click on a block OR add a block and try to save

Actual:
- Infinite loading due to SecurityError on the cssRules fields

Expected:
- No infinite loading

opw-3432734
opw-3438480
opw-3435892
opw-3371073

closes odoo/odoo#130151

X-original-commit: 8d550d5cc5f055a9de26e3b050550268710b1827
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-07-30 10:06:42 +02:00
Rodolpho Lima 58352b6e69 [FIX] web_editor: toolbar position after mouseup
On mouseup the toolbar size might change (eg. link button removed),
leading to an ill-positioned toolbar.

This commit makes sure the toolbar position is updated after going
through changes after a mouseup.

task-3347670

closes odoo/odoo#130022

X-original-commit: af52356704f990ecb3c8a7832fe3de8898026885
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-07-28 16:29:32 +02:00
Rodolpho Lima 940ff56920 [FIX] web_editor: empty link button group in toolbar
Buttons in the floating toolbar are displayed depending on what is
selected. When selecting text that spans multiple blocks, the
"#create-link" button is hidden from the floating toolbar.

Before this commit, when the "#create-link" button was hidden, the
"#link" button group would be left empty but still visible on the
toolbar (its separator bar remained visible).

This commit ensures that:
- the responsability of displaying/hiding the "#unlink" button
is from Wysiwyg's _updateEditorUI method, as it is the case with the
other toolbar buttons,
- when a button group has none of its children button visible, it is
made invisible too, including its separator bar.

This commit also fixes the selector for toggling the "#create-link"
button active/inactive, bringing the affected code section alive from
the dead.

task-3347670

X-original-commit: ceedd72b893316f5994727063a6a6faf49476408
Part-of: odoo/odoo#130022
2023-07-28 16:29:32 +02:00
Rodolpho Lima 230c3c212e [FIX] web_editor: missing toolbar-bottom arrow
When the floating toolbar is placed at the bottom of the selected text,
an arrow should be visible above the toolbar (pointing to the selected
text).
The CSS ruleset that makes such arrow visible was not being applied due
to an error in the CSS selector.

task-3347670

X-original-commit: 1a526b915d185e0b29bd3f9a3ff67df5178450d4
Part-of: odoo/odoo#130022
2023-07-28 16:29:32 +02:00
abd-msyukyu-odoo 24c3095532 [IMP] web_editor: allow collaboration for portal users
Encapsulate the `mail` ICE servers availability check in an overridable
function, since the hack does not work in a portal context, but Knowledge portal
users should be allowed to use the collaborative feature. Knowledge will
override the session check by always returning true, since mail is a dependency
of Knowledge and is therefore always installed with it.

Allow access to the edition channel for portal users.

task-3378266

X-original-commit: odoo/odoo@03e1148ac9
Part-of: odoo/odoo#128962
2023-07-28 14:53:42 +02:00
abd-msyukyu-odoo b19f2f9166 [IMP] web_editor: render templates insertion collaborative-friendly
In Knowledge, there is a custom `KnowledgeHtmlField` which adds a menu
placeholder if the `HtmlField` value is empty. It evaluates if it is empty after
each `historyStep`.

This commit introduces new collaborative step events so that the
`KnowledgeHtmlField` is able to properly hide/show that menu even after a
collaborator made the value empty.

task-3378266

X-original-commit: odoo/odoo@b6f103bd3e
Part-of: odoo/odoo#128962
2023-07-28 14:53:42 +02:00
Aaron Bohy 2c847afb3b [FIX] web_editor: do not cache promise forever pending
The wysiwyg component uses the ColorPalette, and gives it a callback
in props (getTemplate). This callback does an orm service call and
thus returns a promise. It is called by the ColorPalette in its
willStart, and the result (the promise) is stored in the closure of
the js module defining the ColorPalette, s.t. subsequent willStart
directly reuse the promise instead of calling getTemplate.

The problem is that the orm service (when defined via useService)
is bound to the component using it. If the component is destroyed
before the rpc returns, the promise is kept pending forever. It
might thus happen that the ColorPalette stored a promise forever
pending, leading to a screen never loading. It was for instance
the case in Invoices (list view), when you clicked on a record:
the form view might never open. In this situation, two renderings
where initiated, the first one triggered the rpc, and the second
one cancelled the first one, making the promise being pending
forever.

This commit bypasses useService to use the orm, which isn't the
best solution but it's the easiest and fastest one. Ideally, this
rpc should be done by a service, which could keep the promise in
its closure. However, a lot of test suites would need to be adapted
to make the service available for its tests.

closes odoo/odoo#129974

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-07-28 13:27:59 +02:00
Adnan Saiyed 4b12dc86e1 [FIX] web_editor: shiftTab doesn't work on styled text
Current behaviour before commit:

shiftTab doesn't outdent the styled text.

Desired behaviour after commit:

Now styled text gets outdent by shift + tab.

task-3283175

closes odoo/odoo#129844

X-original-commit: 1a438fa3f29794a44cda57917d2133b439c3fd0a
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-07-27 14:47:19 +02:00
Bastien PIERRE 65242e31e9 [IMP] *: Remove alias in JS files
Rename all imports with alias old system to the new js module system
Task ID: 3266759

closes odoo/odoo#127414

Related: odoo/design-themes#671
Related: odoo/enterprise#43716
Signed-off-by: Bastien Pierre (ipb) <ipb@odoo.com>
2023-07-27 11:58:34 +02:00
Aaron Bohy cf4e844aca [REF] web,*: remove legacy DataManager
The DataManager is no longer used as all views and models have
been converted to wowl.

Part of task~3439226

closes odoo/odoo#129725

Related: odoo/enterprise#44611
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
2023-07-26 13:22:13 +02:00
Louis (loco) c802efd56f [FIX] web_editor: correctly adapt the image mimetype on format change
Steps to reproduce the bug:
- Go on a product image and replace it by a ".jpeg" (note that the
mimetype of the image is "image/webp" since [1]).
- Change the format of the image and put it to "Original". The mimetype
of the image is now "image/jpeg".
- Add a shape on the image.
- Change the format of the image.

-> None is displayed as its format.

Let's first recall that adding a shape on an image transforms its
mimetype into an "image/svg+xml" and that the `originalMimetype`
attribute is used to record its original mimetype. This is needed in
order to correctly reset the image mimetype when removing its shape.

The problem here was that the `originalMimetype` attribute was not used
correctly and that the mimetype of an image with a shape was not
correctly updated at format change.

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

task-3431015

closes odoo/odoo#129680

X-original-commit: 40811e72c50faf146ccdf9f26c332db9ebc69fa9
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
Signed-off-by: Colin Louis (loco) <loco@odoo.com>
2023-07-26 09:22:27 +02:00
Simon Genin (ges) 20764d40f8 [FIX] web_editor: add missing Markup to notification
closes odoo/odoo#129681

X-original-commit: c72441b440061dd1ab794a77bf5b2c2623c525fe
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
2023-07-25 22:36:39 +02:00
vishal padhiyar f4f0a82b84 [FIX] web_{editor}: add missing args in position callback
Before this commit:

When attempting to open a dynamic placeholder in email marketing, a traceback
occurs.

After this commit:

Now the dynamic placeholder works properly.

Task-3373356

closes odoo/odoo#129415

X-original-commit: bb9fb402a135baf7e7b9da9bbb40888f5323ded9
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-07-25 08:19:01 +02:00
dhba-odoo 1a91bd9ea5 [FIX] web_editor: word tables are broken because of formatting spaces.
Before this commit:

When format styles were applied to the word table, it would break table.

After this commit:

Now, when format styles are applied to a word table, the style will be applied to it
without breaking the table.

task-3165767

closes odoo/odoo#129356

X-original-commit: 0b06ba23aa111f6a85929abe8018b6b18da79873
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-07-24 21:27:24 +02:00
218ad8456a [REF] *: adapt codebase to new RelationalModel
This commit adapts the code in addons w.r.t. the introduction of
the RelationalModel.

Main changes that were requested are:
 - record datapoints no longer always have an "id" key in their
 data (they still do if the id field is in the view), so we use
 record.resId instead
 - the new model is based on fined-grained reactivity, so several
 components that previously relied on onWillUpdateProps to update
 their internal state no longer worked. Typically, using the hook
 "observeRecord" is the way to go now.
 - specialdata are no longer handled in the model, so the components
 needing specialData can use the hook "useSpecialData"
 - more generally, all overrides of models (RelationalModel or
 KanbanModel) needed to be reworked.

Part of task~3179751

Part-of: odoo/odoo#114024
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: FrancoisGe <fge@odoo.com>
Co-authored-by: Jorge Pinna Puissant <jpp@odoo.com>
Co-authored-by: Pierre Rousseau <pro@odoo.com>
2023-07-24 20:17:50 +02:00
Antoine Guenet b68e06e20a [FIX] web_editor: properly convert rgba colors to hexadecimal
We currently convert rgb colors to hexadecimal, but not rgba colors.
Unfortunately since many Bootstrap border colors are defined as rgba,
this meant that these were not properly converted for Outlook (which
doesn't support rgba).
To convert rgba while losing the transparency information we need to
"flatten" it by taking in consideration the background color.

closes odoo/odoo#129153

X-original-commit: dc56506cffa5a13508ca24018d4f0a25c5353cca
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2023-07-24 11:28:51 +02:00
Antoine Guenet 5ea4baa612 [FIX] web_editor: prevent double quotes in font-family style
The `font-family` style can sometimes include double quotes. This isn't
really a problem since these get escaped (`&quot;`) but emailonacid
currently has a bug where the double quotes cause every subsequent style
to be ignored, and the rendering to be incorrect. For the sake of future
testing, this converts them to single quotes. It also removes the style
entirely from image elements since they don't make sense there.

X-original-commit: 03c7e69db63f326c7a3b3085debc5d3a5c95966d
Part-of: odoo/odoo#129153
2023-07-24 11:28:51 +02:00
Antoine Guenet b2f1d72a03 [FIX] web_editor: properly set image width attributes
A semi-colon unfortunately took the place of a double pipe in code that
retrieves an image's width in order to set its width attribute. This led
to some images being wrongly sized.

opw-3299392

X-original-commit: 0a21da39f05ef9ec9d202424e0e648849f44e164
Part-of: odoo/odoo#129153
2023-07-24 11:28:51 +02:00
Jinjiu Liu fb590c1dfe [FIX] web_editor: changing inline text format resets background color
Before this commit:
When changing the tag name, e.g applying a new format, the other styles
applied are removed

After this commit:
We no longer remove already applied styles of the text and only change
the tag name

Reproduction:
1. Install Email Marketing, create an email with a template
2. Drag a text block and set the background color of the whole block as
yellow
3. Set one line of the text body as Header 1, the background color is
cleared

Reason: it’s a normal result of removeFormat, it clears the background
color of the parent element and re-apply the color to the text not
selected

Fix: After checking a few most popular editors, the common behavior is
to keep the other styles applied to the text and only change the tag.
Thus this fix will remove the format removing steps. Because of this
change, the test case to check if the gradient text background color is
modified. Other specified styles are kept after the tag change.

Note: If the background color is the 5 colors at the first row, it won’t
be cleared by setting the format because the color is set as a CSS class

task-3245698
opw-3165587

Related PR/Fix:
Adding the gradient background color removal
https://github.com/odoo/odoo/pull/83065

closes odoo/odoo#129285

X-original-commit: 17f90e304537e517233b8762d4fd2b7f75bfa642
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-07-24 08:58:23 +02:00
Damien Bouvy dfdd8d7bb6 [IMP] web_editor: align t-field with other placeholders
This commit completes the addition of t-field with a few changes in its
behaviour in the editor:
- t-field nodes, like t-esc or t-out, are considered as unbreakable
- similarly, they are defined as 'demo data' which cannot be edited

closes odoo/odoo#128228

Related: odoo/enterprise#43978
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-07-20 17:01:32 +02:00
Lucas Perais 04a836f0c8 [FIX] web_editor: Wysiwyg saveViewBlocks in a detached document
Have the wysiwyg take an editable from an iframe. At the unmounting of the wysiwyg, save it.
Before this commit, the editable and dirty nodes were not correctly resolved as the JQuery instance
would be the one of the main document.

After this commit, we build a custom jquery function to make sure to search in the relevant document, and
be able to locate nodes even if the iframe's document is not bound to a browsing context.

Part-of: odoo/odoo#128228
2023-07-20 17:01:32 +02:00
Lucas Perais f3eb3e3def [FIX] web_editor: QWebPlugin branching shows condition
Before this commit, when displaying the available conditional branches
on a node, the QWebPlugin's select element only had the name of the attribute.

This commit adds to this name, the actual condition present inside the attribute.

Part-of: odoo/odoo#128228
2023-07-20 17:01:32 +02:00
Lucas Perais d9eeb6ab9b [FIX] web_editor: wysiwyg, QWebPlugin: use getContextFromParentRect from options
Before this commit, the option getContextFromParentRect was not used to compute
the position of the branching in the QwebPlugin.
Also, the Wysiwyg forced that callback in the options.

This commit fixes those two issues

Part-of: odoo/odoo#128228
2023-07-20 17:01:32 +02:00
Lucas Perais 78dec0b378 [FIX] web_editor: OdooEditor and wysiwyg don't hint inside t-fields
Before this commit, when typing "/" inside a node that had a t-field attrbute
the OdooEditor displayed its hint in order to spawn the Powerbox.

This is not ideal as the content of a t-field is rather irrelevant.

After tis commit, a t-field node behaves like a t-out: there is no hinting inside them

Part-of: odoo/odoo#128228
2023-07-20 17:01:31 +02:00
Benjamin Vray cc6cf9ef13 [FIX] web_editor, *: fix replacing an image with shape by another media
*: test_website, website

Steps to reproduce the bug:
- Drag and drop a text-image snippet onto the page.
- Add a shape to the image of the snippet by selecting the shape from
the options.
- Click on the "replace" button in the options of the image.
- In the media dialog, navigate to the "icons" tab.
- Choose an icon.
- Inspect the HTML code of the icon in the DOM.
- Bug: The 'data-shape' attribute with a value is still present.

After this commit, when replacing media, the transfer of element
attributes specific to "shape" elements only occurs towards an image and
no longer towards other media (e.g. icons).

We also prevent adding shapes to images that don't support it (e.g. SVG
files). Before this commit, when replacing a .jpeg image that had
a shape with a SVG image, the shape was not removed.

This commit also adds tests to prevent these bugs from reappearing.

task-3420533

closes odoo/odoo#129079

X-original-commit: 023b0b3124a7181fdf486df8c830bb16edd10aa6
Signed-off-by: Soukéina Bojabza (sobo) <sobo@odoo.com>
2023-07-20 10:07:25 +02:00
Benoit Socias 567e5b58d5 [IMP] base, tools, web_editor, *: use original image if size increases
*: web_tour, website

When no transformation is applied on an image, changing the quality
sometimes increases its storage size.

This commit makes sure that the original image remains used if only the
image quality is modified and if this makes its storage size bigger.

Fixes #61619
task-2835144

closes odoo/odoo#103398

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-07-19 13:12:51 +02:00