Commit Graph
3596 Commits
Author SHA1 Message Date
Soukéina Bojabza d1c7e37149 [IMP] web_editor, web_unsplash: improve the UX of the media dialog
When using the media dialog, the dialog always seems glitchy as its size
is always changing with the loading files. This behavior is not really
convenient as it can make the user click on unwanted images. Another
"issue" of the current media dialog is that when loading more images,
the dialog auto-scrolls to the "Load More" button, which can make the
user miss new images and he therefore needs to revert the scroll. A last
issue encountered by the users is that some of them think that the "Add"
button in the footer is used to upload files from their device, while it
only adds the selected media to the page.

This commit improves the UX of the media dialog:
- The dialog height is now fixed and has the same size as when it is
fully filled by images.
- The top bar with the search input now stays at the top when scrolling.
- There is now a small footer under the attachments (for the Images and
Documents tabs only) and containing the following:
    - When there is content to scroll, a small circle with an arrow that
scrolls one row when clicking on it.
    - When there is nothing to scroll, the "Load More" button which will
load more images. When new images are loaded, if we can scroll, the
small arrow is displayed again.
    - When there is nothing to scroll and to load anymore, the "All
images/documents have been loaded" text.

Note that the main goal of this footer is simply to indicate to the user
when there is still content to scroll and when he can load more files.

In order to solve the "Add" button issue, this commit also enables and
disables this button, depending on whether some media are selected:
- if a media is already selected, we can click on the button;
- if not, the button is greyed out and we cannot click on it.

task-3441587

closes odoo/odoo#135875

Related: odoo/enterprise#49535
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-10-25 11:37:21 +00:00
xO-TxandChrysanthe f64c9f27f1 [IMP] web, web_editor, website: add text highlight effects
The goal of this commit is to replace the "Toggle underline" option
from the website's text editor by a new "Highlight effects" option which
should allow applying some highlights on the selected text and setting
their color & thickness. Also, the text editor "Toggle strikethrough"
option will be moved to the list of highlight effects in the new option.

For this purpose, the JS code used for text animations will be updated
to be more generic and handle text highlights too. Moreover, The "Text
Highlight" options will be applied by adding a SVG to the targeted text
element (allowing to adjust their `stroke` and `stroke-width`).

To simplify adapting highlights when the text content is updated,
we follow this generic structure:
```
<span class="o_text_highlight">
    <span class="o_text_highlight_item">
        line1-textNode1 [line1-textNode2,...]
        <svg.../>
    </span>
    [<br/>]
    <span class="o_text_highlight_item">
        line2-textNode1 [line2-textNode2,...]
        <svg.../>
    </span>
    ...
</span>
```

Rendered line breaks in text nodes are detected using range client
rectangles (see: `text_processing.js` > `splitNodeLines()`), and the
highlights are updated on window resize...

We also need to adjust highlight SVGs to fit an updated text in "edit
mode" (mainly using editor's commands), a `MutationObserver` is used
for this purpose (we only redraw the SVG for each text unit).

A simple SVG path generator was implemented in this commit (see:
`text_processing.js` > `drawPath()`) to build highlights. It applies a
list of SVG path commands according to text dimensions in a specific
mode (E.g. on "pattern" mode, we repeat the same elementary path to fit
targeted text node...).

Remarks:

- The `--text-highlight-width` and `--text-highlight-color` properties
are used to control the highlight effect's thickness and color.

- We build the highlight option preview in the same way as text content.
To achieve this, a hack was used (we open the `<we-select/>` first since
we need the right `getBoundingClientRect()` dimensions to correctly draw
highlight SVGs).

task-3285817 (rd-website)
task-3269759 (rd-design)

closes odoo/odoo#122751

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: Chrysanthe (chgo) <chgo@odoo.com>
2023-10-25 11:37:14 +00:00
Serge Bayet (seba)andqsm-odoo dc81acfb2d [IMP] website, *: allow to add a language from theme tab + options
*: web_editor, portal

This adds a button to add language in theme tab. When clicked, opens
the "add a language" wizard.
If the website has only one language, the options to enable language
in header & footer are hidden.
When an user add a language, the default behavior is Header: dropdown
& Footer: inline.
Also provides two more rendering options : Language Code and Flag +
Language Code.

task-3457554

closes odoo/odoo#119650

Related: odoo/design-themes#651
Related: odoo/upgrade#5214
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
2023-10-25 11:37:12 +00:00
qsm-odooandBenoit Socias b993399f8a [IMP] web_editor, website: display better previews over dropzones
Before this commit, some snippets did not have any or complete preview
when dragging them over a dropzone.

This commit covers `s_website_form`, `s_countdown`, `s_map` and
`o_facebook_page`.
Some elements with class `s_preview` are added to the template. These
elements are removed when the snippet is dropped.

Also, the class o_colored_level was added to snippets so that the
previews matches the snippet dropped.

For "New page templates", an `s_keep_preview` class can be added on a
parent element of an `s_preview` to prevent its removal when creating
the page - thereby making the snippet ready as if is had been dropped
into the page.

Note: `s_chart` and the "dynamic snippet" and its variants are not
covered in this commit.

task-3555325 (was task-2431469)

Part-of: odoo/odoo#138748
Co-authored-by: Benoit Socias <bso@odoo.com>
2023-10-25 09:56:40 +00:00
Aaron Bohy 3f3175d4ca [REF] website,web,web_editor: convert AceEditor to owl
This commit refactors the website AceEditor to owl. The wrapper
around the lib was defined in web_editor, and extended in website,
where it was used (single usecase). This commit thus introduces an
owl Component to replace it, directly in website, and specialized
to the website usecase.

This thus allows to remove the legacy implementation.

This also removes the last usecase of Widget and select2 library
in the backend bundle, which will allow to trim it down.

Part of task~3439226

Part-of: odoo/odoo#139154
2023-10-24 12:38:29 +00:00
Soukéina Bojabza 3be69751e7 [FIX] web_editor: hide grid gap preview when toggling the mobile preview
When changing the grid gaps (see commit [1]) a grid preview is displayed
in order to visualize the changes. As it cannot be displayed in mobile
view (otherwise, the layout looks broken), some code prevents it to be
added in this case. However, a case has not been taken into account:
- In desktop view, change the gaps of a grid with the "Spacing (Y, X)"
option.
- Before the preview disappears, quickly activate the mobile preview.
=> The preview is displayed (before disappearing).

This commit prevents the grid preview to be displayed in mobile view. To
do so, its height is forced to 0. Note that `display` could be set to
`none` instead but since it prevents the animation to be played, the
preview would not be removed by its listener.

[1]: https://github.com/odoo/odoo/commit/4345df3aeeb83463d81bc24749856fef3a58fb3a

task-3555898

closes odoo/odoo#138795

Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
2023-10-24 12:38:26 +00:00
Pierre Paridans 08cd27cc8a [FIX] web_editor: BS Tooltip jQuery integration not bound to the iframe
We used to have two libraries (Bootstrap and jQueryUI) providing
tooltips.

Since the removal of the jQueryUI implementation in commit [1], adding a
image-like block in the wysiwyg editor throws an error telling that
`$().tooltip()` is not a function.

Actually, this issue happens when the wysiwyg editor is used in an
iframe and the jQuery instance used is the one from the iframe.

In a nutshell, Bootstrap 5 - even though it doesn't require jQuery
anymore - has a compatibility layer which bind the current components'
implementation to the v4-like jQuery based methods (in this case
`$().tooltip()`). In the tooltip's case, both libraries have the same
method signature.

When removing the jQueryUI implementation, most of the calls to this
method naturally fallback to the Bootstrap's one... But not in our case,
as the wysiwyg editor uses its own window/frame's jQuery and not the
parent one (in the iframe's case).

Amusingly, the way Bootstrap bind its compatibility layer relies on the
`onDOMContentReady` event being dispatched... which is not the case in
the iframe, resulting to having a jQuery version without the said
compatibility layer.

This commit fixes it by removing this dependence on an external library
and use our own (existing) Tooltip component instead.

Steps to reproduce:
- Open Email Marketing app
- Create a new mailing
- Choose a template
- Drag&drop an image-like block
- Click on the newly inserted block
=> Error about $target.tooltip not being a function

[1]: odoo/odoo@25d0783b59

closes odoo/odoo#138847

Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2023-10-23 20:07:30 +00:00
Bastien PIERRE ffef01e327 [IMP] web_editor: Allow to stylize field on report editor
Before this commit, the tags t-field,t-esc,t-out were difficult to select
and couldn't be stylized.

After this commit, when clicking or selecting a tag t-field,t-esc,t-out
the whole tag is automatically selected and a style can be applied onto it.

task-id-3457404

closes odoo/odoo#135265

Related: odoo/enterprise#47089
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-10-23 20:07:17 +00:00
Bastien PIERRE d5b839f713 [IMP] web_editor: Wysiwyg: Allow to save given editable
Before this commit, the save operation of wysiwyg was applied on the current editable.

After this commit, the save operation of wysiwyg can be used on a given element.
This advantage of this change is that saving can now be triggered on a copy of the original editable
element, or on any document in memory.
This makes the use case of the report editor easier to handle. That is, when the save fails, we need to
go back to the state of the editor before the save: that is WITH the changes of the user, but not cleaned by the
wysiwyg yet.

task-id-3457404

Part-of: odoo/odoo#135265
2023-10-23 20:07:17 +00:00
Bastien PIERRE b643f7666a [FIX] web_editor: Fix column command on report editor
Before this commit, adding column in a report added a line instead because columns were too large.

After this commit, the created columns are not "lg" anymore, so column creation does make a column.

task-id-3457404

Part-of: odoo/odoo#135265
2023-10-23 20:07:17 +00:00
Adrien Dieudonne 711fc86368 [FIX] web_editor: colorpicker buttons text partially hidden
Follow-up of https://github.com/odoo/odoo/commit/ee38c69503a0fd9175751f054d88bf760ec660b8

Before this commit, the padding of these buttons was too big and
the text was partillay hidden.

This issue was introduced in the commit above. The selectors generated
by the ´.extend´ were not correct and the css rules associated to ´.btn´
was never applied. It was therefore good to remove this rule but we shoudn't
have added the ´.btn´ class.

Steps to reproduce:
- Go to website and open the Editor
- Click on "Edit"
- Drag and Drop "Text"
- Go to Customize
- Change the Background or the font color

closes odoo/odoo#139437

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-10-23 13:11:28 +00:00
Robin Lejeune (role) 710d000f18 [IMP] web_editor, website, *: allow columns on mobile snippets
*: mass_mailing

This commit introduces options for the flex column layout and the
horizontal resizing to be used on mobile and be independent from
the desktop layout.

This makes it possible to:
- Have different number of columns on mobile and on desktop.
- Use different column widths and offsets for mobile and desktop.
- Reorder columns independently.

The behavior expected from the columns is:
- In the editor panel, Cols indicate the number of columns per row on
both mobile and desktop. The option is conditional of your environment:
you edit the number for the screen size of your current resolution.
- When columns have different sizes (either because it is the default
behavior of the snippet, or because the user resized some), the counter
should read "Custom". Same when the user changed some offsets.
- If manual modifications were made on width and offset, they are reset
on the current display if the number of elements is updated. This was
decided because an old, specific layout with custom offsets / width
doesn't work well with a different number of elements. (This is also the
default behavior before this PR with desktop-only modifications.)

The expected behavior when reordering is:
- On mobile, it should only affect the mobile layout.
- On desktop, it should affect both layouts.

In order to have a coherent feature on both mobile and desktop as well
as correct some non-ideal but non-blocking behaviors, the commit also
changes the following behaviors:
- When setting a columns count lower than the current number of items in
the `.row` container, extra items are now wrapped on the next flex-rows
(still within the container) instead of being deleted.
- When going from e.g. 3 to 5 columns (and as many items), the change
happens all at once instead of each item being visibly added one by one
on the next row, then brought back to the first row.
- The columns count automatically updates when resizing an item, instead
of updating only after you click somewhere else on the snippet.

This commit also adds a test to validate the new behavior.

task-3097045

closes odoo/odoo#117562

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-10-20 19:12:43 +00:00
Robin Lejeune (role) cd58f04bea [REF] web_editor: move logic from SnippetOptionWidget to SnippetMove
The logic done in the `_computeWidgetVisibility()` method of the main
`SnippetOptionWidget` should have been placed in the `SnippetMove`
sub-widget as an override method.
This commit moves the logic at its right place and removes an unneeded
condition.

task-3097045

Part-of: odoo/odoo#117562
2023-10-20 19:12:43 +00:00
Robin Lejeune (role) d210af8348 [REF] web_editor, website: add utility functions isMobileView()
This commit implements two generic utility functions with similar
behavior that check whether the view is mobile or desktop:
- For web_editor: depending on the view of the targeted element
- For website: depending on the context

task-3097045

Part-of: odoo/odoo#117562
2023-10-20 19:12:43 +00:00
Jinjiu Liu 4faa1cb9ca [FIX] web_editor: enter resets the editor after link insertion
Reproduction for creation:

1. Create a link using /link
2. Click after the link, press enter
3. The link and cursor disappear.

Reproduction for cancellation:

1. Create a link using /link, don’t save it but cancel it
2. Click after the link, press enter
3. The link and cursor disappear.

Fix: After clicking the save button of the link dialog, the next history
step is not correctly set up as the history step is not unpaused. This
causes the mutation list of the current step to have all the mutations
before starting the link insert. Thus after the link creation, whenever
the historyRollback is executed, it’s rolled back to the very start

The cancellation has two cases, clicking the discard button or clicking
the close button. Unfortunately, they have to be handled differently.
For clicking the discard button we need to bind the button with a
function doing the historystep then close. For the close window button,
we have to rewrite the close function by overwriting
this.env.dialogData.close. The overwrite method is specified in this
commit: https://github.com/odoo/odoo/commit/dc1191f6939c4bbf5cfcc865884813610f4f8f2c

task-3446357

closes odoo/odoo#139325

X-original-commit: 60089e7e100039670d98f2f41b4f56fafdb8f830
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-20 18:06:42 +00:00
abd-msyukyu-odoo 2994c7589f [FIX] web_editor: don't set the sync as finished on error
When `_resetFromClient` returns an error, `_historySyncFinished` should not be
set to true since the history was not updated from the requested snapshot.

Also await the result of `get_client_avatar` and `get_client_name` during
`rtc_data_channel_open` so that no error is produced during tests after calling
`removePeers` without properly awaiting those promises.

Export collaborative test utils for usage in Knowledge.

task-3551505

closes odoo/odoo#139040

X-original-commit: fb389213078e96c97b7187248dfdf79ad331db9f
Related: odoo/enterprise#49170
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Damien Abeloos (abd) <abd@odoo.com>
2023-10-20 14:59:21 +00:00
Antoine GuenetandLou 386a2fdebf [ADD] web_editor: create/transform content with a LLM
This commit implements a dialog for content generation using ChatGPT,
which can be opened via the Powerbox or via a button in the toolbar.

If text is selected, the dialog opens in "alternatives" mode. In this
mode, five alternative versions of the selected text are generated. The
user can choose one and it will be inserted in lieu of the selection.
Five buttons can be used to guide the AI to make the content longer,
shorter, more professional, more friendly, or more persuasive. Clicking
any of these buttons will restart the generation process with the new
parameters.

If no text is selected, the dialog opens in "prompt" mode. In this mode,
the dialog contains a textarea in which the user can input a prompt
which is then used to generate content. The user can then exchange with
the AI back and forth until the content is satisfactory. Any of the AI's
responses can be inserted into the document by clicking its "Insert"
button.

When content is inserted into the document, a green frame is shown
around it for two seconds, to make it clear to the user that something
has been inserted and where.

If an error occurs, it is inserted in the dialog like other responses
but in red and it can't be inserted into the document.

Please find the PR of the IAP part (Odoo Language Generator) here :
https://github.com/odoo/iap-apps/pull/703

task-3383324

closes odoo/odoo#137064

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Co-authored-by: Antoine Guenet (age) <age@odoo.com>
Co-authored-by: Lou (loha) <loha@odoo.com>
2023-10-20 11:22:06 +00:00
Antoine Guenet d0bb595a18 [FIX] web_editor: return all inserted nodes on insert
The `insert` command was not returning all inserted nodes.

Part-of: odoo/odoo#137064
2023-10-20 11:22:06 +00:00
Michael (mcm) 8cf98fbe67 [IMP] *: remove core.bus
This commit removes the legacy global bus (core bus) and the places
where it was used.
The main users of this bus were the public widgets, they now use the bus
on Component.env.
Some of the uses were dead code and has been removed.

closes odoo/odoo#139076

Task: 3439226
Related: odoo/enterprise#49131
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
2023-10-20 09:35:21 +00:00
Sébastien Geelen (sge) 0a3f65e144 [FIX] web_editor: history dialog foreach key
Fix wrong Qweb foreach key reference in history dialog.

task-3560850

closes odoo/odoo#139188

Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2023-10-20 07:22:49 +00:00
Arthur Detroux (ard) 7594d71ca8 [IMP] *: remove jQueryUI draggable and droppable
*: mass_mailing, test_website, web, web_editor, website, website_event,
   website_sale

This commit removes jQueryUI draggable and droppable component to
instead use our own implementation of the feature. This replaces the
last use of the lib: the web_editor drag and drop. This takes advantage
of the code that was already written for other features of the backend.

task-3079246

closes odoo/odoo#136793

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-10-19 22:01:48 +00:00
Guillaume (gdi)andqsm-odoo 97b14eef9b [IMP] web_editor: apply custom font size as rem
This commit permits to apply custom font size as rem instead of px. The
users still use px to define and to read the font size but the editor
will convert it to rem.

task-1958098

Part-of: odoo/odoo#129791
Co-authored-by: qsm-odoo <qsm@odoo.com>
2023-10-19 19:08:11 +00:00
qsm-odoo da8fec249a [IMP] web_editor: make oe-toolbar design closer to right panel select
The code of this commit is ugly: it only forces extra new rules to make
dropdowns in the right panel toolbar closer to the we-select design.
This should be refactored. Mass mailing should have the same visual,
CSS rules should be shared, etc etc.

task-1958098

Part-of: odoo/odoo#129791
2023-10-19 19:08:11 +00:00
Guillaume (gdi) c91f5fdc47 [IMP] web_editor: rebuild the text style dropdown
This commit improves the text style dropdown by adding new styles with
responsive font sizes. This will allow to solve the biggest responsive
font-size problem we have right now: users add a cover snippet with
a big font-size (it is currently hardcoded as 62px font size in
snippets). On mobile, it stays 62 and it's too big. Using displayN
classes of bootstrap will allow to solve that problem. Previous commit
also changed the way custom font-sizes work, so after this commit, and
after snippets are adapted every text will now be responsive.

task-1958098

Part-of: odoo/odoo#129791
2023-10-19 19:08:11 +00:00
Guillaume (gdi)andqsm-odoo 194f73a9bb [IMP] website, *: prevent hardcoded font sizes
*: web_editor, mass_mailing

This commit changes the way the font size selector works. Before this
commit, the font size selector applied a hardcoded font size using the
style attribute of the selected element. The purpose of this commit is
to change this to apply a class on the selected element, making it
responsive and customizable.

In all Odoo applications, the font size selector will now apply a class
on the current selection. An exception is made for mass mailing where
the class would not make much sense as not related to the custom heading
sizes (probably needs to be refactored in the future to use the standard
font-size classes) and fonts cannot be responsive in mails anyway (so
there would be a difference between preview and sent mail).

Those classes are:
- `display-N-fs` with N in [1 => 4]. The sizes are stored in the
`$display-font-sizes` map.
- `hN-fs` with N in [1 => 6]. The sizes are stored in the
`$hN-font-size` variables.
- `small` for the small font size. The size is stored in the
`$small-font-size` variable.

The font size selector shows the value of the class (which is dynamic)
that will be applied.

In the website application, the value of each class is configurable
thanks to a previous commit. The user can choose the size of each font
size class in the website settings.

Note that many alternatives were considered for this feature, this is
the chosen compromise. For the record, here is a very short summary of
the alternatives:

- Doing nothing: voted as the worse idea. Users see a font-size selector
  they will use it one way or another. The font-size won't be
  responsive, breaking their mobile website. And there are real use
  cases you could not do: a big "promotion" paragraph on your product
  page? Not possible: you either break your mobile page (using the font
  size option) or possibly hurt your SEO (using the font-style option
  and turning your paragraph into an h1).

- Removing the font-size selector: we did not want the loss of the
  feature as there are correct usecases to use it (as mentioned above).

- Using the Bootstrap hN and display-N classes instead of making new
  ones. Closed to be the chosen idea but discarded because those classes
  comes with colors (that the user can configure) and it would feel
  weird to have the color change when changing the font-size. Also, in
  the end, we also did not want the line-height, margins, etc of those
  classes (only the font-size).

- Instead of X new classes, have only one: o-fs, which would be applied
  alongside a bootstrap hN or display-N class, when chosen by the user,
  to cancel the unwanted style of those. It works but it forces us to
  always have an added `<span>` to apply the font-size, which we don't
  want in the future (mainly because of display-N classes, see next
  commit). It is actually very needed to be able to use proper
  line-height when reducing the font.

- Using a combination of an inline `em` font-size + a class to clamp it
  on mobile. Was probably the best next idea but rejected for several
  reasons. The main one probably being the inconsistency when changing
  the whole size of a title/paragraph (not part of it) and later
  changing the related theme size later. E.g. have an `<h1>` followed by
  a `<p>`. The h1 is 40px, the paragraph is 20px. Force the title to
  20px, because you want it smaller, same size as the paragraph. Real
  use case but also users could simply use the font-size controls by
  mistake. We would thus apply 0.5em to do that. Later, change the theme
  font-size of h1 to 36px (small change). The 0.5em one is now 18px,
  smaller than the following paragraph. Preventing that would require
  more checks which would "break" other things / possibilities.

- Probably others that were forgotten.

In the end, there was no good or bad answer. "Anything works", as long
as the feature "I want this text smaller/bigger" is there. The
surrounding features are always compromise (some users would expect some
behavior, some users would expect others). This commit focused on
solving the unresponsiveness of those custom font-sizes, which was a
problem for many users.

task-1958098

Part-of: odoo/odoo#129791
Co-authored-by: qsm-odoo <qsm@odoo.com>
2023-10-19 19:08:11 +00:00
Guillaume (gdi) 9d753397f6 [REM] web_editor: remove useless code
This commit removes the code that removes some attributes when the
font size selector is closed. We don't need this code because bootstrap
already does it for us.

task-1958098

Part-of: odoo/odoo#129791
2023-10-19 19:08:11 +00:00
Jinjiu Liu b6757cbcdb [FIX] web_editor: text's first-click selection not set after link click
Reproduction:

1. in Website, enter Editing mode, drag a block with a button, for
example, banner
2. click on the button then click on the text above the button
3. the selection should be around the text paragraph, but it's on the
button

Note the behavior is only for the first time of clicking on the element,
e.g. when dragging and dropping a new block

Fix: The selection restoration when destroying the link tools should be
done on the spot instead of binding to the destroy of linkToolsInfos.
Without this fix, the selection restore in link tool is done after the
full selection step for o_default_snippet_text element

task-3514638

closes odoo/odoo#139031

X-original-commit: 6dcc33c6c85b605f43e8f42a5d4013eca9e0ef7a
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-18 13:39:22 +00:00
Jinjiu LiuandNicolas Bayet 9ed20a5260 [FIX] web_editor: avoid contenteditable reset when doing link isolation
Reproduction:

1. install website, drag a block with button
2. click at the beginning of the button text
3. type something, it will be outside of the button area

Reason:
The contenteditable is reset depending on the o_editable and
o_not_editable class in the _onPostSanitize function.

Fix: don’t do the resetting when we have the _fixLinkMutatedElements key
in OdooEditor as it indicates that the link isolation trick is executing

task-3514628

closes odoo/odoo#139030

X-original-commit: 1727317f258d184432b01b6295d01f688e298257
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Co-authored-by: Nicolas Bayet <nby@odoo.com>
2023-10-18 13:39:21 +00:00
qsm-odoo b867cf3395 [FIX] web_editor: restore synchronous call to _addToolbar
Commit [1] changed a method to be asynchronous instead of synchronous
but did not care about where it was called or overridden. That code and
its surrounding needs to be refactored when fully switching to OWL.
Meanwhile this extracts the asynchronous part of the method to be done
once in all cases at initialization for now.

This is probably a cause of race condition or bugs but this was mainly
discovered during a master task development, preventing to code the new
feature properly.

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

closes odoo/odoo#138985

X-original-commit: e26c007dd14de9d0cbf76181e8054a3498e67bd9
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-10-18 13:39:12 +00:00
Sébastien Geelen (sge) 10b855ea87 [ADD] web_editor: add field html history
Create a new model mixins that allow other model to
activate the history feature on html fields.

This history automatically track the changes
on the related html field and allow the user
to revert to a previous version at any time.

This also introduce a new component that can be used to :
* List the recent history
* See a previous version of the document
* Compare a previous version to the current one
* Revert the document to a previous version of it

task-3039787

closes odoo/odoo#112957

Related: odoo/enterprise#37211
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-18 13:39:06 +00:00
Adnan Saiyed 9334cb922f [FIX] web_editor: enter should be caught by image editor
Current behaviour before commit:

When cropping an image, pressing ENTER creates new paragraph behind the
widget, due to this, changes are not getting applied on image and it disappears.

Desired behaviour after commit:

Now hitting ENTER works same as apply button, Changes are getting applied
when pressing ENTER.

task-3383447

closes odoo/odoo#138789

X-original-commit: add0d782fceebb84285a5f16952b852a29cf5a10
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-16 13:11:16 +00:00
Nicolas Bayet ce36c49680 [FIX] web_editor: reconnect peers after when reconnecting internet
Prior to this commit, when the user experienced an internet
disconnection, after few seconds the PeerToPeer connection state would
change to "closed" and the PeerToPeer connection would be removed
permanently. Consequently, when the user reestablished their internet
connection, the peers would remain disconnected to each other.

With this commit, peers are now re-connecting to each other.

task-3488166

closes odoo/odoo#138510

X-original-commit: b9d96629df5adf37f362eb63107fa5a9a6cd3e0d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-16 10:39:57 +00:00
VAN BOSSUYT Nicolasandbvr-odoo 507b80a125 [IMP] web_editor, website: add button/video/image as building block
This commit introduces 3 new inner snippets: button, image and video.

What sets these snippets apart is that, once dropped onto the page, they
transform into basic HTML code, just like if they were created using the
editor (no data-snippet etc).

task-3248881

closes odoo/odoo#126717

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: bvr-odoo <bvr@odoo.com>
2023-10-15 12:39:20 +00:00
Soukéina Bojabza 0a52320d44 [FIX] web_editor: make background grid more visible on dark backgrounds
When redesigning the grid layout and handles, commit [1] removed the
filter that allowed the grid to be clearly visible on dark backgrounds
(added in commit [2]). Without this, the background grid when dragging/
resizing and the highlight effect when changing the gaps are difficult
to see.

This commit adds this filter back, but with a lowered opacity in order
to not obstruct the view too much.

[1]: https://github.com/odoo/odoo/commit/70f723a9f78c406746f5409f6a89cbe93ad21580
[2]: https://github.com/odoo/odoo/commit/1aa81243b7c80069c576381e2f3b04281455794f

task-3369695

Part-of: odoo/odoo#136683
2023-10-14 23:52:16 +00:00
Soukéina Bojabza 4345df3aee [IMP] web_editor, website: add a spacing option to modify the grid gaps
The `display: grid` property allows to modify the spacing (or gaps)
between the rows and columns of the grid with the `row-gap` and `column-
gap` CSS properties. When the grid mode was added with [1], these
properties were deliberately ignored and the gaps were forced to 0px.

This commit adds the "Spacing (Y, X)" option that allows to modify these
grid gaps. A grid preview is also added when using this option, in order
to visualize what is being changed in the grid.

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

task-3369695

Part-of: odoo/odoo#136683
2023-10-14 23:52:16 +00:00
Soukéina Bojabza 62985e8329 [REF] web_editor, website: remove duplicated grid/column options
When adding the grid options in commits [1] and [2], some of them have
been duplicated in order to cover the different use cases: grid-only,
columns-only and grid + columns. However, they should have been declared
only once and then called when needed.

This commit extracts the common options into views, to avoid duplicating
them.

[1]: https://github.com/odoo/odoo/commit/cc406afcea7bf5846233a9f97a4a8ac5f618f3ec
[2]: https://github.com/odoo/odoo/commit/85b352af319edec84407f2046cf795b4e5503460

task-3369695

Part-of: odoo/odoo#136683
2023-10-14 23:52:16 +00:00
Soukéina Bojabza 11418cc6f0 [IMP] web_editor, website: add individual Padding option for grid items
Before this commit, the "Padding" grid mode option, added in commit [1],
was impacting all the grid items at the same time, which was not
convenient since all these elements would have the same padding and
could not be styled individually.

This commit improves this option in order to modify the padding of the
grid items individually. The highlight effect, added in commit [2], when
changing the padding is still added.

[1]: https://github.com/odoo/odoo/commit/cc406afcea7bf5846233a9f97a4a8ac5f618f3ec
[2]: https://github.com/odoo/odoo/commit/f3f2c4c73ce08d3898b8c88e1ef045f7bbd1f624

task-3369695

Part-of: odoo/odoo#136683
2023-10-14 23:52:16 +00:00
Soukéina Bojabza e828683820 [REF] web_editor: refactor some grid code
In the grid mode code, the code managing the transformation of a grid
item into a normal column (when it is dropped or when we toggle the
normal mode) is repeated at several places.

This commit fixes that by creating a function doing this conversion
instead.

task-3369695

Part-of: odoo/odoo#136683
2023-10-14 23:52:16 +00:00
Soukéina Bojabzaandqsm-odoo 75331fd46a [IMP] web_editor: add support for data-min/max to InputUserValueWidget
Before this commit, when using a `we-input`, there was no way to easily
specify the min and max values that could be entered in the input, which
could be useful when too low/high values could break some behaviors, for
example.

This commit adds the support for the `data-min` and `data-max` data-
attributes in `InputUserValueWidget`. More precisely, when these
attributes are added on a `we-input`, if the user writes a value smaller
than the `data-min` or bigger than the `data-max`, the value snaps to
these bounds. When using the arrows, the value cannot be decreased/
increased beyond them either.

task-3369695

Part-of: odoo/odoo#136683
Co-authored-by: qsm-odoo <qsm@odoo.com>
2023-10-14 23:52:16 +00:00
Soukéina Bojabzaandqsm-odoo df7b8a17cd [IMP] web_editor: clean the snippet UI before cloning it
When cloning a snippet, if it had some previews displayed, the previews
may be cloned with it. This is not a good behavior because the clone
is a new snippet so it should not have all the preview classes that were
added when editing. Moreover, these previews could also cause bugs.

To solve this, an idea could be to call the `cleanForSave` function of
all its options before cloning the snippet. But the problem is that in
some options, the `cleanForSave` function does more than simply clean
the UI (as it was originally supposed to) and so it cannot be used for
that purpose only.

As a solution, this commit adds a new function called `cleanUI` whose
exclusive purpose will be to clean the snippet UI. In the future, it
will replace the `cleanForSave` function.

task-3369695

Part-of: odoo/odoo#136683
Co-authored-by: qsm-odoo <qsm@odoo.com>
2023-10-14 23:52:16 +00:00
Guillaume (gdi) 514d3dbad4 [IMP] web_editor: permit drag images and start from anywhere on it
Before this commit when the user was dragging an image in the editor,
the image was always dragged from the top middle of the image. Now the
user can drag the image from anywhere on it.

task-3369600

Part-of: odoo/odoo#125151
2023-10-13 21:11:49 +00:00
Guillaume (gdi) cff6f79b5f [IMP] web_editor: permit to drag images
This commit permits to drag and drop images directly (without using the
`o_move_handle`) with the website drag & drop tools. The user can
directly drag the image in edit mode by grabbing the image itself. It
was already possible to drag the image itself but this commit permits to
activate the website tools (grid mode, see dropable areas, etc.) while
dragging the image.

task-3369600

Part-of: odoo/odoo#125151
2023-10-13 21:11:49 +00:00
Michael (mcm) e062e6f483 [IMP] web,*: remove legacy env
This commit removes all the legacy envs (common_env, env, public_env)
as well as the files used to set up them.

task 3439226

closes odoo/odoo#138348

Related: odoo/enterprise#48781
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
2023-10-13 09:17:45 +00:00
Michael (mcm) 94824d8767 [IMP] *: remove legacy notification service mapper
This commit removes the mapper to the notification service and adapts
widgets that display notifications.

task 3439226

Part-of: odoo/odoo#138348
2023-10-13 09:17:45 +00:00
Antoine Guenet e70a4baf40 [FIX] web_editor: split text node on insert after delete range
The `insert` command was splitting the selection's starting text node
only if the selection was collapsed. But after deleting the range, the
selection is inevitably collapsed and therefore the same should be done.

closes odoo/odoo#138549

X-original-commit: 06a375db7e6250b388d410010a3d1c50e8af1326
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-13 07:33:55 +00:00
Antoine Guenet 8438972939 [FIX] web_editor, test_lint: clean test HTML in utils tests
Test HTML being inserted for the utils tests was not cleaned at the end
of the tests.

X-original-commit: 092cee52b343665ea3ca90e4f4aa302318a763b5
Part-of: odoo/odoo#138549
2023-10-13 07:33:55 +00:00
Antoine Guenet 7cefa81f7e [ADD] web_editor: add some tests for state preservation utils
This adds a few tests for `getState`, `restoreState` and
`enforceWhitespace`, regarding the handling of space visibility. Each
test handles equivalent cases for all three functions.

X-original-commit: 2f28f42640a7322eec35a4d48a1ec7ce287b77b3
Part-of: odoo/odoo#138549
2023-10-13 07:33:55 +00:00
Antoine Guenet abb80ffe1c [IMP] web_editor: add debugging options for prepareUpdate
This adds an option to log information in prepareUpdate flows for
convenient debugging.

X-original-commit: 3ec104d57e9b6bbe210f45354f160d982a9c6254
Part-of: odoo/odoo#138549
2023-10-13 07:33:55 +00:00
Antoine Guenet b128d3a5a2 [IMP] web_editor: add label to prepareUpdate
This adds a label to the prepareUpdate function to be able to easily
track which update is being restored when debugging.

X-original-commit: 5bb8a5a9b5d54ebe93c473087981e3464cd61368
Part-of: odoo/odoo#138549
2023-10-13 07:33:55 +00:00
Antoine Guenet 0c95529e0f [FIX] web_editor: preserve leading spaces on delete range
When pressing delete on "[a] b c" the result is " b c" instead of
"&nbsp;b c". As result, text is rendered as "[]b c". The cause lies in
`deleteRange`: it ensures trailing spaces remains visible, but does not
take care of eventual invisible leading spaces. This adapts it to make
use of `prepareUpdate` which is made to handle this sort of issues. In
so doing we need to adapt `getState` and `prepareUpdate` to handle the
special cases brought by `deleteRange`. An option is introduced in
`prepareUpdate` to prevent its reentry until the update is complete (as
otherwise we may restore invalid intermediary states in the middle of
the deletion process).

task-3143042

X-original-commit: 8fd69afa591d11afe07da803ec550f052402713f
Part-of: odoo/odoo#138549
2023-10-13 07:33:55 +00:00