Add a mechanism to buffer external steps when some asynchronous rendering needs
to be done (i.e. OWL rendering). This is to prevent external steps occuring
inside the rendered result from being applied when the rendering is currently
ongoing.
Remove `historyResetFromSteps` and `onExternalHistorySteps` as they were only
introduced to trigger an update of Knowledge Behaviors, but now that update is
done through `checkForExtraRendering`.
Modify collaborative tests of the editor so that steps `afterCreate` and
`afterCursorInserted` can be asynchronous.
Task-2821374
Part-of: odoo/odoo#104680
In order to be able to use web dependencies for mocha tests, convert every
existing test to an `@odoo-module` and make a new asset
`web_editor.mocha_tests` that will be used for tests in `/web_editor/tests`
Task-2821374
Part-of: odoo/odoo#104680
Add an option to the html_field (collaborative_trigger) to allow to choose if
the peerTopeer connection of the collaborative mode should happen when the
html_field is loaded ('start') or when the field has the focus ('focus').
Will be used in Knowledge since the html_field of an article is the main focus
when opening the form in edit mode. The collaborative mode should be loaded as
fast as possible.
Task-2821374
Part-of: odoo/odoo#104680
When the current user connects to a collaborative peer, the content inside his
editor will be reset. When opening a record, there is no way to know if such a
connection will happen.
In Knowledge, when one wants to insert an embedded view in an article body from
elsewhere in Odoo, it is inserted programatically once the article is opened. At
that time the peerToPeer connection is not established. Then, if a collaborative
session is started with someone already editing the html_field, the content is
reset, and at that point, the insertedd element is removed, so it should be
inserted again.
This commit introduces a hook that can be used to execute some specific action
if the content of the editor is reset through `historyResetFromSteps` during
the collaboration first synchronization. It can be provided as an option of the
`wysiwyg`.
Task-2821374
Part-of: odoo/odoo#104680
Currently, the 'insert' command unpacks nodes from a lone paragraph, or from
the first and last node if there are multiple nodes.
In knowledge, to append an embedded view to the editable, there is a need to
insert two sibling nodes at once (without unpacking them). With the current
behavior of 'insert', it is possible to do so by inserting a paragraph
containing the 2 nodes that need to be inserted. The result will be that the
'insert' command unpacks the parent paragraph and correctly insert the 2 nodes.
This commit prevents the 'insert' command from unwrapping nodes if the
anchorNode of the selection is the editable itself.
Task-2821374
Part-of: odoo/odoo#104680
With the introduction of Knowledge Behavior Component, came a need to create
html nodes which would have limited interactions with the editor. i.e. an Odoo
view already has everything it needs to function properly, and when it is
inserted in the editor, any manipulation on the selection or on the style that
could be done with it should be prevented. Another example would be the
/template block (will be renamed /clipboard in the future) that has a
non-editable part (buttons which have a definite action in Odoo, and which
should not be interacted with) as well as an editable part inside of it).
To solve this use case, this commit proposes to mark specific html nodes with
a `data-oe-protected` attribute which could have one of three values:
- "true"
- Only mutations of type "attributes" can be registered on the node itself
which has the `data-oe-protected="true"` attribute
- Prevent mutations of children (and sub-children) from being registered by
the mutationObserver of the editor
- Prevent the selection handling when its anchor is inside a
`data-oe-protected="true"` element, even if it is `contenteditable="false"`
- Prevent the command hint
- Prevent the usage of the wysiwyg toolbar
- Prevent the dblClick tooltip
- Prevent the editor sanitization `Sanitize.js`
- "false"
- Designed to be contained inside a node with `data-oe-protected="true"`
- Re-enable all features disabled by a parent node with
`data-oe-protected="true" for the children of a node with
`data-oe-protected="false"
- ("")
- This is considered equivalent to have the `data-oe-protected` attribute
set to "true" (like other html attributes).
Another attribute is added: `data-oe-transient-content`, with the following
values:
- "true"
- Prevent the serialization of the children of the node, so they are not
shared during a collaboration.
- Transient nodes will be removed during `cleanForSave`, meaning that they
will never be part of the html_field value in the database
- ("")
- equivalent to "true"
The use case is an embedded view: there is a large quantity of nodes that
are not relevant to share nor to save, since it will be recreated with the
lastest data from the database, with the information relevant to the
currently active user each time it has to be rendered.
Note:
This commit does not handle the dynamic switch from a specific value for
`data-oe-protected` to another (i.e. switching from "false" to "" or "true").
This could cause a number of problems like:
- some mutations from when the value was "true" are not yet handled when the
switch (to "false") happens => those mutations will be registered as if they
were always under the "false" value, even though it is not the case.
- in collaborative, some nodes with oids that were not relevant (under the value
"true") won't necessarily have the same oids in between collaborators.
Therefore we cannot suddently listen to their mutations and expect the changes
to be shared by switching to "false".
In conclusion: the `data-oe-protected` attribute value should stay the same
during the entire edition.
Task-2821374
Part-of: odoo/odoo#104680
How to reproduce (scenario):
- Open 3 windows with 3 different sessions in Odoo
user_1 -> in CRM, My Pipeline
user_2 -> in Knowledge on article "target"
user_3 -> in Knowledge on article "target"
-> user_2 and user_3 are in a collaborative session
-> user_1 "insert view in article" "target" (via Favorites)
-> user_1 is redirected to knowledge to the target article
-> RTC_DATA_CHANNEL_OPEN between user_1 and user_2 happens
-> user_1 reset the html_field value from the history steps of user_2
-> the embedded view "My Pipeline" is inserted via `execCommand` and create a
step in user_1 editor
-> user_2 is notified via OE_HISTORY_STEP and receive the new nodes (view)
-> RTC_DATA_CHANNEL_OPEN between user_1 and user_3 happens
-> since user_3 was already synced with user_2, there is no
`historyResetFromSteps`
-> user_3 does not get the step from user_1 with the embedded view nodes now
-> user_3 makes multiple steps (i.e. write some text in a paragraph)
Current Behavior:
-> user_2 and user_1 are notified of those steps and add them to their histories
-> user_3 stil did not get the step with the embedded view nodes
-> now if user_1 and user_2 make some steps, user_3 will be notified, but those
steps "parents" are the steps from user_3, so user_3 may not request a full
history comparison and may never get the missing step
Fix:
-> when a RTC_DATA_CHANNEL_OPEN event happens, the connected client is notified
of the last registered step so it can call GET_MISSING_STEPS if it does not have
it
Note:
This fix solves the specific case mentioned above, but other cases of
desynchronization may happen, see Task-3208277 for a more complete fix.
Task-2821374
Part-of: odoo/odoo#104680
Before this commit:
clicking on the pictogram, the pictogram is not being displayed on the note.
After this commit:
pictogram is being displayed on the note.
task - 3249342
closesodoo/odoo#119010
X-original-commit: 05f13260c2bbce2c5c69b3626ccb628776b11c68
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit, the term used to filter the powerbox commands was
split with a simple .split('') call, separating each character. This was
erroneous as it disregarded the fact that special characters are first
escaped with a leading backslash (e.g. '\['), the combination actually
representing a single character '['. Separating those pairs would render
the constructed regex invalid when using such characters, resulting in a
traceback.
This commit replaces the use of split with a match, regognizing the use
of backslashes for escaping.
closesodoo/odoo#118922
X-original-commit: e34e908a06c18ecee5d762f6fca785b23977f47d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
The way the live HTML editor for html_field works means the header
(and other nodes that should only appear once) are removed
and the content inserted inside the body.
This results in values being edited without the user being aware.
For emails, this results in any email using 'style' in the header
to break on GMail and other clients that do not support 'style'
outside of the header.
When an html_field is passed a value containing a header
the html_field appears readonly and the user is able to toggle
the code view. Which enables them to edit the 'raw' HTML and see changes
while preventing the presentation view from affecting the database value
task - 3035163
closesodoo/odoo#118920
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Thiry Renaud (reth) <reth@odoo.com>
Replaced _.each() functions (average 235 occurences)
Description of the refactoring this PR addresses:
Current behavior before PR:
There are underscore.js function enumerated above used in odoo.
Desired behavior after PR is merged:
These functions has been replaced by native javascript
prototypes/methods/functions.
TaskId : 3246238
closesodoo/odoo#118565
Signed-off-by: Georis François (fge) <fge@odoo.com>
When clicking on a button from the link popover, the popover gets
hidden, which pauses the editor's mutation observer until the popover is
fully faded out. This is problematic when the button in question calls
an editor command which we need to be able to undo, since the mutation
observer will still be paused during the command execution. This lets
the buttons' listeners handle the hiding of the popover themselves to
prevent this race condition.
closesodoo/odoo#118248
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit when a button containing a text then an icon was
unlinked in Chrome, all further buttons were also unlinked (see steps
below).
It turns out this bug is due to the browser's `execCommand`
implementation so this commit reimplements the feature without relying
on it.
Steps to reproduce (in website module):
* drop Text+Image snippet twice
* inside first button type /image and insert a pictogram after the text
* click on the text of the first button => the link popover appears
* click on the unlink button of the popover
=> both buttons become flat texts in Chrome
=> nothing happens visually in Firefox, but the <a> actually gets
turned into a <span>
task-2778912
Part-of: odoo/odoo#118248
Co-authored-by: Antoine Guenet <age@odoo.com>
Co-authored-by: Benoît Socias <bso@odoo.com>
When replacing an image by a pictogram inside columns, the pictogram
right-alignment is neutralised by the fact that the section of the card
inside the column spans over 100% width.
This commit makes pictograms in those sections rely on their auto width
instead - thus letting the right-alignment happen as expected.
Steps to reproduce:
- Drop a "Columns" block.
- Replace an image by a pictogram.
- Select the pictogram.
- Click on the "Float Right" icon in the toolbar.
=> Pictogram remained aligned to the left.
task-2841127
closesodoo/odoo#118684
X-original-commit: c3eae07259cb38656aa910ad98d0da04f4fc7edb
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
Align images to the right by using an auto left margin.
Steps to reproduce:
- Drop a "Columns" block.
- Select an image.
- Resize image to 50%.
- Align image to the right.
=> Image did not get aligned to the right.
task-2841127
X-original-commit: d2364278371828fa353c17d53fd266350aa2446b
Part-of: odoo/odoo#118684
*: mass_mailing, website_blog, website_event, website_mail_group,
website_mass_mailing, website_payment, website_sale, website_twitter
The names of snippet blocks are not translatable because their name is
obtained from a their template name which is not a translatable item.
For markets that use a non-latin alphabet this is a no go.
This commit makes it possible to specify a `string` attribute in the
`t-snippet` blocks that makes their name inventoried by the translation
process.
closesodoo/odoo#118530
X-original-commit: a501d226d8674ed0c9b183c69a9e754c79682237
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
[1] refactored the Media Dialog using owl and the backend Dialog
component.
Doing so, the width of the dialog was reduced (using the standard
.modal-xl class). With that change, the "load more" button was not
always visible for the user.
It is acknowledged that the current Media Dialog needs a deeper UI
review. In the meantime, it was decided to scroll to the bottom after a
search/click on the load more button.
This commit implements that solution with a ref on the "load more" div.
It is used in a scrollToLoadMoreButton, that is called each time after
loading a new attachment/illustration/unsplash record. As we do not want
a jump in the UI each time an image is loaded, the function is
debounced.
It is simpler to use a debounced function that we call each time an
element is loaded, than keeping track of each loaded element to call
the function only once, when they are loaded.
[1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b
task-3060679
X-original-commit: 4921442690e6f5b587441a653f73c3368155422e
Part-of: odoo/odoo#118556
Before this commit, clicking on the 'load more' button of the media
dialog after a search (with no filter set) would load more
attachments/illustrations/unsplash records.
As illustrations are considered less relevant than attachments/unsplash
records, it was decided to load more of them only when the filter is set
to "illustrations".
When the filter is not set, the 'load more' button will be visible only
if there are more attachments or more unsplash images to load (and not
visible otherwise, even if there are more illustrations to load).
Also, the loadMore override will only perform the query to load more
illustrations if the filter is set.
A deeper review of the Media Dialog UI will be conducted later. For now,
this commit avoids loading too many illustrations, for users that are
most of the time more interested in the unsplash results.
task-3060679
X-original-commit: 6aaca71a4b2a11ffa80578904bc7c79c1fa0339d
Part-of: odoo/odoo#118556
Before this commit, typing a query in the search input of the media
dialog would output a lot of undraw images (15), making some noise and
making the unsplash results (that are fetched 10 by 10) less visible.
First, the number of fetched attachments was reduced from 30 to 10 when
converted to owl in [1], for no valid reason. This commit adds a new
NUMBER_OF_RECORDS_TO_DISPLAY value for better control over the loaded
images, and reverts it to 30.
Then, the /web_editor/media_library_search endpoint does not take any
limit param. Therefore, it was loaded with all the results as they were
returned. Now, a new NUMBER_OF_MEDIA_TO_DISPLAY variable is introduced
to load the 10 first results instead of all of them.
This way, the search results are organised as following:
- NUMBER_OF_ATTACHMENTS_TO_DISPLAY (30 for now) attachments,
- NUMBER_OF_MEDIA_TO_DISPLAY (10 for now) media (undraw, ...),
- NUMBER_OF_RECORDS_TO_DISPLAY (30 for now) unsplash images.
These values can be changed to adjust the search (it may be better to
have more unsplash images than undraw images).
[1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b
task-3060679
X-original-commit: bc4fe60bcebd3e47f206c911526784a88fd520d9
Part-of: odoo/odoo#118556
This commit makes the image options initialization more robust, by
- checking at the beginning if the specified `src` and `data-original-
src` attributes match with existing files.
- checking if there is a `data-original-src` attribute before applying
the ImageTools options (shape, filter,...).
This is needed because in the case of wrongly hardcoded templates (e.g.
in customizations), it is sometimes not possible to drop any snippet
after dropping an incorrect one. This happens because the image
`SnippetEditor` is not correctly created. Indeed, the start of the image
options is never completed because the promise rejections when a file
does not exist are not properly caught, interrupting the initialization.
Therefore, ensuring that the files exist beforehand prevents these
issues from happening.
opw-3137732
closesodoo/odoo#118546
X-original-commit: 93ddaac87a76d6d1775e0b3e30bb66ca85147503
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit changes web_editor's powerbox search feature to also look
for matches in a command's `description`, in addition to its `groupName`
and `title`.
For example, typing /track will suggest the Checklist command among the
suggestions as its description is "Track tasks with a checklist".
Note that only exact matches are considered for the description, while
fuzzy matches (with missing chars) work for other attributes.
Also fixes a typo in a local variable name because it was hazardous to
some people's eyesight.
task-3188758
closesodoo/odoo#118486
X-original-commit: 7fa6d48f1b69e4d4806db29310223d326b0e0ed5
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit prevents the activation of options when no option section is
visible, and disables overlay if there are no options to enable.
Steps to reproduce the bug:
- Go to website edit mode (homepage).
- Click on the white area (the <main> element) below the "drag building
blocks here" block.
- Bug: The customize tab is activated in the editor panel, even though
there are no options.
task-3199281
closesodoo/odoo#118461
X-original-commit: af49b1aba1454f80663c4e88e8c4915eb75bd0ff
Signed-off-by: loco-odoo <loco@odoo.com>
Before this commit, the toolbar, when in mobile mode, had a BUTTON element
containing:
- an icon with a non-unique and unnecessary id,
- a wrong/misleading title.
This commit fixes such issues.
task-3263984
closesodoo/odoo#118446
X-original-commit: d42be84de09ae65d6e8061ce6fb5b8994bc78798
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit, the `applyColor` command returned non-connected nodes
(nodes with no parent) in some not well-defined situations, leading to a Warning
when `selection.addRange()` was called by `_processAndApplyColor` with
such non-connected node as argument.
This commit properly removes such non-connected nodes from the array returned
by `applyColor`.
closesodoo/odoo#117166
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Short read version:
This commit gives the Wysiwyg class the attribution of switching between
the two types of text editor toolbar (floating or part of the sidebar),
instead of the SnippetsMenu class, as Wysiwyg owns the Toolbar instance
and has the methods to configure it.
The switching between toolbars is now done by having one instance of each
type (and properly displaying/hiding them), rather than moving the toolbar
element of place in the DOM and reconfiguring it (button handlers, CSS
classes, displayed/hidded buttons, etc), so that the configuration steps
of each toolbar can be done only once.
The floating toolbar is needed for mailings based on the "basic" theme,
where no sidebar/SnippetsMenu is available. Note that it will be only
instantiated if needed.
Long read version:
The 'basic' theme in mass_mailing has no sidebar (SnippetsMenu), so the
floating toolbar should be available instead, in order to give users access
to the text editor's features.
Commit [1] added the `setFolded` method to the SnippetsMenu class, which folds
(hides) the snippets menu and recovers the floating toolbar from the
sidebar container and vice-versa. While the recovered toolbar works well when
`isMobile` is `true` (although with some minor issues described
below), the one for the non-mobile case does not (as it must be properly
reconfigured using the document's Jquery, and not the iframe's, among other
details).
This commit proposes a different approach to the toolbar recovery issue:
if the floating toolbar is needed (mobile or basic theme), a new Toolbar
instance is instantiated and properly configured. That way the Wysiwyg
instance will hold two instances of the toolbar: the one embedded in the
sidebar (snippets menu) and the floating one. This allows for easy
switching between the two types of toolbar, without the need to run the
configuration steps for the toolbar on every switch.
Such toolbar switching is needed in mass_mailing, where a single instance of
the wysiwyg is kept while the user can switch between different records of
mailings. Some of these records could be based on the 'basic' theme
(thus, no sidebar), and other ones based on other themes that do offer
the snippets menu.
After this commit, the toolbar switching is handled by the Wysiwyg class
instead of SnippetsMenu, as Wysiwyg owns the Toolbar instance(s) and has
the methods to configure it.
The `folded` property of SnippetsMenu and the `setFolded` method are
leveraged by this commit, keeping its original purpose and meaning (except
for the toolbar handling).
Before this commit the floating toolbar for the mobile case had the
following issues, that are fixed by this commit:
- The "table" button was (incorrectly) displayed;
- The default colors of the color picker (the top row) were undefined;
- The 'Link' powerbox command and the toolbar icon should open the Dialog,
and not the LinkTools (part of the sidebar).
Finally, this commit removes the SCSS rules that hide the SnippetsMenu
when the theme in "basic", as its display is already handled by
SnippetsMenu's `setFolded` method, introduced by [1].
[1] https://github.com/odoo/odoo/pull/105472/commits/c589939eeaff928997bf6f9735b19710036f9ad6
task-3133259
opw-3165111
Part-of: odoo/odoo#117166
Before this commit:
When we create a nested list and change a tag of the one of
the list item in nested list and press backspace from start it removes the tag.
After this commit:
Now pressing backspace from the start tag, the tag is not removed.
task - 3147461
closesodoo/odoo#118353
X-original-commit: 7504dc1adc50916b9a408c3307832ab45ed5174b
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit prevents pasting content inside a link when it is
empty (ZeroWidthSpace only) or its text content is fully selected,
making the pasted content replace the link.
task-3081254
closesodoo/odoo#118204
X-original-commit: 7d0da7f56904927f93ef3d678083f3219fadfdc9
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit adds the following test cases that were missing in the
unit tests suite:
-Paste an image URL or a youtube URL as link
-Paste text containing a valid URL among other text fragments
-Paste text containing multiple URLs
-Test if the selection is properly restored after pasting content on a
non-collapsed range followed by an UNDO.
task-3099012
X-original-commit: 0167b031bc9238893c5b4f09bbda996ed0ee914f
Part-of: odoo/odoo#118204
Issue # 1: pasting image/video URL as text
This commit removes this command, because it was considered to be useless.
The category names "Embed" and "Paste" for the other two commands
("Paste as URL" and "Embed Image/Video") were ommited as it is no longer
relevant to group commands, as this would result into two categories with
one command each (the powerbox does not display the category name when all
the commands are under the same one - undefined in this case).
Issue # 2: pasting image/video URL + other text fragments
The powerbox commands are not compatible with an image/video URL + text
or multiple URLs. Choosing one of its commands will lead to loss of all
text fragments but the last valid URL.
This commit ensures the powerbox options are only offered when a single
image/video URL is pasted.
Issue # 3: pasting image URL inside an exisiting link
Even though the Editor's specs do not allow a URL to be transformed into
a link when pasting it inside an exisiting link, before this commit,
pasting an image URL inside a link would open the powerbox with 3 commands,
one of them allowing to transform the URL into a link.
This commit ensures the powerbox with the "Paste as URL" command is not
opened in such case. When pasting an image URL inside an existing link, the
image is directly embedded, and other URLs are pasted as text.
Issue # 4: unnecessary regex matching
Before this commit, every text fragment in "text URL text" was being
prepended with "https://" and a match with the URL regex was attempted.
Every fragment (text or URL) was also probed for a match with the
youtube video URL regex, but such matches would be discarded anyway in
modules like note and mass_mailing where the allowCommandVideo option
is set to false.
This commit avoids unnecessary searching with regular expressions by treating
pasting of a single URL (possibly an image or video URL that would lead
to powerbox commands) differently than URLs pasted among other text fragments
or other URLs (see issue # 2 above).
Issue # 5: `historyPauseSteps` with argument
This function takes no arguments. Yet, it was called with the string 'onPaste'
as argument. This commit removes it.
task-3099012
X-original-commit: 3fb93d7e9047a73a8e84f165e2ff52b9887d34a4
Part-of: odoo/odoo#118204
Powerbox commands are grouped under categories.
But this is not very usefull when:
- All commands are under of the same category
- Each command is under a different category
This commit hides the category name when all the commands passed to the
powebox are under the same category.
In order to avoid the second scenario, the commands array should be passed
to `Powerbox.open()` with all commands having the same category name (the name
does not matter), or even with `category` undefined.
X-original-commit: 93d632861996c78502b33538cc7ff06d8419602c
Part-of: odoo/odoo#118204
Before this commit, after pasting a valid URL on a non-collapsed selection
followed by UNDO, the selection was not restored to the original range.
This was due to not recording the selection in the current history step
before creating the link.
After pasting text composed of a valid URL between text fragments on a
non-collapsed selection followed by UNDO, the selection was again not
properly restored. This time, because each text fragment insertion was
done via execCommand, which calls _computeHistorySelection and thus
overwrites the current step's selection.
This commit:
- refactors code for link creation into a single function;
- wraps the link creation at `_onPaste` in a 'insertHTML' command called
via `_applyCommand`, which records the selection properly in the history
step;
- replaces `execCommand` by `_applyCommand` for text fragments
insertion.
task-3099012
X-original-commit: 20bb1a2090c90f87a819fdc1c3bbb332cae3720e
Part-of: odoo/odoo#118204
When assigned the role of restricted editor, there are many ways to
break the web_editor when trying to do actions that should be
unavailable. There is a traceback for the following scenarios under
some circumstances (mainly because of pages without editable areas or
features without the proper access rights):
- Drag and dropping snippet when Restricted Editor.
- Clicking on product when Restricted Editor in /shop.
- Clicking on product image on specific product page.
- Clicking on user name (e.g. Marc Demo).
- Clicking on menu items or logo.
- Clicking on a blog's image in /blog.
- Clicking on a blog's image on specific blog page.
- Clicking on calendar's image in /calendar.
There is now no longer a traceback which makes the editor crash or
freeze. This mimics the behavior in other cases where the editor does
not show a traceback, but there is no message indicating that the action
is unauthorized.
When accessing a menu that cannot be edited, the "Edit the menu" button
is not shown to the restricted editor.
task-2747895
opw-3164176
closesodoo/odoo#118116
X-original-commit: 15c85e4f9f967ee04af3cdeb766d280a2c00731e
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: Benjamin Vray <bvr@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
Steps to reproduce:
- In a snippet in grid mode, resize a column.
- Drag and drop this column in a non-grid dropzone.
- Undo.
=> The column is back in the grid but is still a normal column. The same
happens when doing these steps with a normal column to a grid.
This happens because the class changes are not observed in these cases.
When fixing the drag and drop history in [1], only the style changes
were observed because the class changes are automatically recorded. But
it is not the case after a resize.
This commit fixes that by also observing the class changes.
[1]: https://github.com/odoo/odoo/commit/1dfb127f70832aa9e9022ac337af343b7dc17729
task-3151207
closesodoo/odoo#117854
X-original-commit: 48b3683c4753f1e385ea1692db9c1a15d32cae30
Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
This commit fixes some mistakes that were found in the code of the grid
layout option. More precisely:
- When a column was dropped near a grid dropzone (so not inside it), and
if its height was bigger than the grid, the `rowCount` attribute of the
row was not updated to the correct number of rows => there was one extra
row.
- When we start dragging a grid item, if we do not go over the starting
grid at all (it happens if the move handle is placed outside of the
row), the `rowCount` of the starting grid was never updated. This is
because the resize is done at the "out" of the dropzone so if there was
no "over", it cannot be done.
=> As a fix, the starting grid is now always resized when we drop the
column.
- When dropping a grid item inside a non-grid dropzone, its `z-index`
CSS property was not removed.
- When a grid item becomes a normal column, when dropping it in a non-
grid dropzone or when toggling the normal mode, the resize classes
(`g-col-lg-*` and `g-height-*`) were not removed from it.
- When a normal column becomes a grid item, the padding and offset
classes were not removed and the `col-` class was not systematically
synchronized with the `g-col-lg-*` class.
=> The two previous points need to be fixed because after doing multiple
drag and drops, the classes could become inconsistent. This happened
especially with columns whose width changes a lot between snippets (like
with Masonry columns, because of the padding).
- When going back to normal mode, the `--grid-item-padding-*` CSS
variables were not removed from the row.
- In commit [1], a comment that should have been modified has been
forgotten.
[1]: https://github.com/odoo/odoo/commit/67d1b078329600efce414974307d74e9fa9ba9fe
task-3151207
X-original-commit: 4afd418e1a1d4231369aab08dfa5c2d10ca9a310
Part-of: odoo/odoo#117854
In some themes, RGBA colors were used to define the colors of shapes.
However, adding this color in the parameters of the background image URL
of a "shape" element was not valid. This caused several bugs, such as
the colorpicker not finding the colors of the shape used, as well as the
colors of the shape being lost after the application of a "flip".
Steps to reproduce the bug:
- In website edit mode, open the homepage page of the Nano theme.
- Drag and drop a Banner snippet onto the page.
- Bug: The colorpicker does not recognize the four colors used by the
shape.
- Click on one of the two "Flip" buttons.
- Bug: The colors of the shape are lost.
task-2824607
closesodoo/odoo#117652
X-original-commit: 0661aa0bbb4751866cfcc9a320a8eff473ba0442
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit converts almost all odoo module by native module.
The goal is to deprecate odoo.define in favor of native module and then
simplify boot.js by removing the regexp that finds module dependencies.
task id: 3162300
closesodoo/odoo#117305
Related: odoo/enterprise#39118
Signed-off-by: Géry Debongnie <ged@odoo.com>
As we have a team dedicated to work on analysing tracebacks
with sentry, and to takedown all tracebacks occuring on the saas,
we do an effort to avoid unecessary warnings and tracebacks
for both sentry and the runbot.
closesodoo/odoo#112101
Signed-off-by: Rémy Voet <ryv@odoo.com>
*: website_blog, website
Before this commit, when clicking on a column in the "Blog Posts"
snippet (only with the "Big picture layout" template), the options for
that column were displayed in the editor panel, even if options should
never be displayed for the columns of dynamic snippets.
We had already prevented the appearance of options for elements in a
dynamic snippet in this commit [1] and also in this one [2], using a
'pointer-events: none' to prevent clicking on the elements. However, as
this also removed the mouse hover effect, the 'pointer-events: none' was
changed to 'pointer-events: auto', in this other commit [3], for the
"Big picture layout" template of the "Blog Posts" snippet, so that the
user could see the hover effects in edit mode. And by doing so, we
inadvertently allowed the options to appear again.
In the end, this 'pointer-events: none' was not the right solution, as
for example, for the dynamic "Products" snippet, it may be useful in
edit mode to be able to switch between slides by clicking on arrow
buttons, or to see the mouse hover effects on images (slight zoom).
In this commit, we proceeded differently by hiding the options for
elements that are inside an 'o_not_editable' element (unless they have
the attribute and value 'contenteditable="true"'), excluding them when
generating options so that they don't have associated options.
Steps to reproduce the bug:
- In edit mode, drop a "Blog Posts" snippet in the page.
- Click on the first blog image ("Sierra Tarahumara").
- Bug => Resize options are visible when they shouldn't. The options in
the "column" part of the right panel should also not be visible.
[1]: https://github.com/odoo/odoo/commit/64b663fb42ddca67a06cb067c897abb5a3c4dd70
[2]: https://github.com/odoo/odoo/commit/1345e879d809f811641ea3ad388b5d2c0b16f005
[3]: https://github.com/odoo/odoo/commit/3c0d98bcd8adf9325ee3497eb8d25ec7f904d6a5
task-3054763
closesodoo/odoo#117407
X-original-commit: 80f841e5e33f4694361730d3e015a6a813261685
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Reproduction:
1. Switch to French, create a /heading 1, and input nothing
2. The placeholder “Heading 1” is not translated
Fix: add translate function around the terms and manually add the
translations in pot
Note: since OdooEditor.js is under web_editor/static/lib/web-editor,
only the js code under /static/src/ is considered for translation export
The translation is manually added with specific path. In Odoo 16, the
path is changed to /static/src/ and translations can be exported
correctly. The translation code paths added here should be changed in
Odoo 16
Related PR adding translations: https://github.com/odoo/odoo/pull/93272
opw-3224482
closesodoo/odoo#117142
X-original-commit: 5f297854348e073a3915bca5cec13066f6abe90e
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Steps to reproduce the bug:
- Add an Image Gallery (IG) snippet on the page.
- Click on "Remove all" to remove all the images of the IG snippet.
- Add 2 new images in the IG.
- Click on the first image of the IG to load its data.
- Click on the trash button to remove the snippet.
- Bug => The snippet is not removed (an image is removed instead).
When a snippet is removed, the `removeSnippet` function is called. The
problem is that the `call_for_each_child_snippet` will never resolve.
Two mechanisms are of interest to understand why: the first one is the
`updateCurrentSnippetEditorOverlay` function. Its goal is to destroy a
snippet each time its target is not in the DOM anymore. The second
mechanism is specific to the IG snippet: when an image of this snippet
is destroyed, the `slideshow` function goes through the remaining
images to update parameters. To do it, the function uses the
`_replaceContent` function that empties the content of the carousel and
then fills it with new data.
When a snippet is removed, a `SnippetEditor` is created for each
element of it. In the case of the IG, a `SnippetEditor` is created for
each image of the the snippet. Because the first image already has a
`SnippetEditor` (because it has been clicked), the callback of
`call_for_each_child_snippet` is called to remove this image from the
IG snippet. The second mechanism explained before will then be called.
Meanwhile, a `SnippetEditor` will be created for the second image.
However, because the `_replaceContent` function emptied the content of
the carousel, the `updateCurrentSnippetEditorOverlay` function will
destroy the `SnippetEditor` of the second image as its target is not
considered present in the DOM anymore. Unfortunately, the
`call_for_each_child_snippet` still needed this `SnippetEditor` and
will never entirely resolve.
To solve this problem, the `removeSnippet` function is executed inside
a mutex. Because the mutex is also used by
`updateCurrentSnippetEditorOverlay`, we are sure that this function
will not destroy the snippetEditor while the `removeSnippet` is still
running.
task-3147271
closesodoo/odoo#116352
X-original-commit: 1c99ab2bc04f65999098f70d062d24ed1ac4a9c3
Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
Signed-off-by: loco-odoo <loco@odoo.com>
This removes the `clearEmpty` util which was only used in the `enter`
command.
closesodoo/odoo#114178
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This removes a parameter in `isVisible` that made it consider (wrongly)
all blocks as visible. This made it confusing to use because it was
effectively returning fake news by default.
Part-of: odoo/odoo#114178