When the selection only contains empty lines, no text nodes are
selected. `applyInlineStyle` however counted on text nodes being
selected, resulting in a traceback.
task-2740204
closesodoo/odoo#85059
X-original-commit: ee6c71a3bcd6ec927acbe4eaf4c21acb28396e87
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit when a text color was applied on a text within
which an already colored text already existed, the inner coloring was
lost during preview. All text was therefore set to the initial coloring
of the external selected text.
After this commit the "reset" of the text color preview is done by
undoing the draft "in progress" history step that contains the preview
changes, but that is not stored within the history itself.
Steps to reproduce:
- drop the Text snippet
- select a word in the middle of a sentence (e.g. "personality")
- set text color to red
- select several words containing the colored one (e.g. "story with
personality for potential")
- open text color palette
- hover over colors but do not click
- leave color palette
=> colored word is not colored anymore
Steps to reproduce a secondary problem also fixed by this commit:
- drop the Text snippet
- select text surrounding some bold (e.g. "have a personality. Consider")
- open text color palette
- quickly hover through several colors (i.e. move pointer downwards)
=> text selection range changed between some of the color previews
task-2742112 (was task-2666200)
closesodoo/odoo#84998
X-original-commit: 9cb5a138244783580c2d1baa4dc01d1824ed20f4
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Ensure the user can keep typing inside a newly emptied inline tag:
* Add Zero-width Spaces (ZWS) in empty html tag
> We add zero-width spaces in elements in certain cases where they would
> not be correctly displayed by the browser if they were truly empty.
> This also ensure the user cursor can stay in an empty elements,
> and thus we keep the ability to add content in those elements.
>
> See the `fillEmpty` utils function.
* Remove lingering zero-width spaces
> However, we never remove those zero-width spaces when they are not
> useful anymore. In particular, keeping those invisible characters in the
> content prevents the ecommerce from saving the new price of a product if
> the previous price was previously completely emptied during edition.
> This commit fixes that.
>
> The issue didn't happen with the previous editor because they were
> using non-breaking space instead, which is removed by the text_content
> method of lxml. However, non-breaking space were visible during edition,
> which was weird on its own.
>
> Some changes had to be made to the deleteForward and backward commands,
> to ensure the new behaviors.
> Author : @dmo-odoo
* Adapt the deleteForward and backward commands
> To ensure the added ZWS do not break the Deletes behaviors,
> we need to adapt the `deleteForward` and `deleteBackward` commands.
Co-authored-by David Monjoie <dmo@odoo.com>
task-2622455
closesodoo/odoo#84891
X-original-commit: 4360643a446271d4ff1898d67a5b5287722a0820
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
* Fix some tests that will break when we change the empty inline tag handling.
* Add missing tests to ensure the new empty tag management
behave correctly.
* Improve some tests with `contentBeforeEdit` and `contentAfterEdit`
X-original-commit: af379b11462d9393c3c9846aaecb9488ffaa9212
Part-of: odoo/odoo#84891
* Ensure the test environment is clean from previous editor instances.
* Provide a way to clean the successfully test cases
to have a better and quicker overview of the failed tests.
* Better error messages in test report
X-original-commit: 9a362195ad7b3485877946d18d64fd84c62605f9
Part-of: odoo/odoo#84891
When saving a mailing with the link tools open, link tools' destroy
is called after OdooEditor's destroy, causing a traceback when link
tools tries to set a history step.
task-2733825
closesodoo/odoo#84354
X-original-commit: f565f965fdc15d744efd38cfca9b098e24181e7e
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
The PR #44537 changed the method _createVideoNode to be async while
the wysiwyg still called the method as if being sync.
This commit adapt the code to be asynchronous.
Task-2727906
closesodoo/odoo#84327
X-original-commit: 683de2b41c2e3699c39126852c82f1bb988bd3e9
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Strikethrough option was missing in the editor toolbar.
* Added the option in the toolbar.
* Added the keyboard shortcut (CTRL+5)
task-2754007
closesodoo/odoo#84029
X-original-commit: 9808073c22eacf9f2bcc55aa96eaec56f55597cc
Signed-off-by: Antoine Guenet <age@odoo.com>
When selecting the text content of a link
the underline and italic commands were not working in Firefox.
We re-implement the Browser command to fix this.
task-2667950
X-original-commit: 52a5b2bb692ab6712d497492f4f2fbef3a9a7874
Part-of: odoo/odoo#83895
Before this commit, when trying to paste an url, the editor was
properly creating a link but did not create a step in the history.
So when the user hit enter just after the paste, the last link
insertion was reverted.
Task-2720366
closesodoo/odoo#83396
X-original-commit: 0e37742d3caba1c6544e5b466503f155626375eb
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit the removeFormat command was only doing its default
native implementation, which did not clean the background-image CSS
property. Because of this, text-gradients became highlight gradients.
After this commit in addition to the default native implementation, the
removeFormat also clears the background-image CSS property.
Steps to reproduce:
- edit the website homepage
- drop a text snippet
- enter a new line of text
- set a text gradient on the new line
- switch the new line to Heading 1
=> new line has the gradient used as background
task-2741684 (was part of task-2666200)
closesodoo/odoo#83306
X-original-commit: 97da1c2106d2a0e76dff1353e56b74d70db55eb2
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
The colorpicker failed in cases like:
```xml
<font>a<span>b</span>c</font>
```
where we select the letter "b".
This was because `applyColor` only considered direct children of the
`font` element. This extends it to deal with further descendants of it.
task-2623347
closesodoo/odoo#83254
X-original-commit: 5d8d98812a4f351abd27389c4992bf9e753833b7
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
The editor toolbar button to trigger the colorpicker is supposed to show
the color of the currently selected text. This was failing in iframes
because the code was called on the wrong document.
task-2623347
X-original-commit: 7ad6536dd98f9749d63bfc7292e490f6ac629b9c
Part-of: odoo/odoo#83254
In some undetermined circumstance in chrome, the selection rect is
wrongly defined.
Task-2728792
closesodoo/odoo#83248
X-original-commit: e9ee8175538e1201acb2ae108b2283f55217ca5f
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
The random ids of checklists and stars are preserved in the dom, which
is needed for their readonly check features to work. However, it
complicates testing. This systematically removes these ids in tests.
It also removes the ids when they are not needed anymore (the node is
not a checklist anymore for instance).
closesodoo/odoo#83137
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This reverts bfed1edd26312488dc0f45e8982b51ea4d98db76.
That commit had issues which were hidden by the fact that tests had an
only in them due to a prior mistaken commit. Therefore, it must be
reverted as a proper fix needs to be found.
X-original-commit: 22c2a9dca29adcad84072e3f053ab78b7834f4f3
Part-of: odoo/odoo#83137
The fix to add an `overflow: hidden` in order to prevent the browser
from chaning the scroll create a glitch where the scrollbar dissapear
when it is overflow: hidden.
A new css property exists to specify exactly this behavior
(`overscroll-behavior: contain;`).
Task-2728791
closesodoo/odoo#82880
X-original-commit: 4cfa9e786d41a27d1bc850eff4fc89e1c4b32974
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Whenever the browser is lagging between multiple enter,
the command hints were not being updated until the browser
main thread process the event queue.
Task-2728794
closesodoo/odoo#82795
X-original-commit: bfed1edd26312488dc0f45e8982b51ea4d98db76
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
When clicking, double clicking or triple clicking in the stars widget of
the Powerbox, we don't want to see the regular options of icons or text.
This prevents them from showing.
task-2575449
closesodoo/odoo#81920
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Similar to checklists, this allows the user to click the powerbox stars
widget even in readonly mode, so as to change a rating without going in
edit mode.
task-2575449
Part-of: odoo/odoo#81920
When a checklist is present in an html field, there is a feature that
allows us to check/uncheck its boxes without going through edit mode.
That feature was broken due to a dead callback in wysiwyg.js, which is
hereby restored.
Meanwhile, the behaviour of checklists had changed but the python code
handling the readonly checking/unchecking hadn't so this brings it up to
date[1].
Finally, the code managing checklist ids was unnecessarily complicated
as it was trying to keep the ids consecutive for no particular reason.
This refactors it to simply use unique ids based on date stamps.
[1] It used to be that checking a box checked all the children of that
box but it was in the meantime decided not to do that anymore.
Part-of: odoo/odoo#81920
This adds two new widgets to the powerbox, which allow the user to
quickly insert 3 or 5 stars, then click on them to color them gold.
task-2575449
Part-of: odoo/odoo#81920
The previous code resulted in only the last editor to trigger its
handler having hints, as all the others would be killed by the last one.
closesodoo/odoo#81743
Task-id: 2632841
X-original-commit: e24b039ea120597ff5438deca3c69c7a1d54cd31
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
When pressing enter at the edge of an anchor that is a child of an
unbreakable element, we inserted line breaks in the anchor itself, which
is unexpected. This inserts the anchors after/before it instead.
closesodoo/odoo#81662
X-original-commit: df6f8dd0c54c40ea7edbd3821ae068d79b1b7af7
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Whenever there was a tag inside a link
(e.g.`<a href="..."><b>link</b></a>`), it was impossible to unlink.
closesodoo/odoo#81112
X-original-commit: a7f2027c6131309b239026b4e1299a6f396171dd
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
The call to `addRowBelow` was not updated to the new API.
Task-2698729
closesodoo/odoo#80896
X-original-commit: f7fb967cd8ada702e298d097ea107fda802fa6a4
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit, the styles of the table were not kept when
copy/pasting a table generated by the Odoo editor. Now it is.
Task-2657445
closesodoo/odoo#80246
X-original-commit: 6f4eff378fc24bdd5e8a84ee485832162108a400
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Whenever the qweb plugin modified the dom for rendering purposes,
the mutations were observed but shouldn't. The reason was that the
reference to the editor was missing in the plugin and therfore it did
not call `observerUnactive` and `observerActive`.
Task-2695658
closesodoo/odoo#80182
X-original-commit: e973526ffe6deba778a613eb4053ba3017f9fb00
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Changing value in monetary fields was not working properly in FF :
The ZeroWidthSpace inserted by the deleteRange function cannot be selected;
trying to do so loses the selection for some reason.
task-2679088
closesodoo/odoo#80071
X-original-commit: 1b36b4e8a6b319de10b6c1144c37533dab0e2f36
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
When performing undo/redo on some page, because some unneded mutation
get recorded, the page scroll to another location (either up or down).
This commit add a mechanic that filter out thoses unnecessary mutations.
task-2667885
closesodoo/odoo#79620
X-original-commit: 125730ffd9322d34ef1c7d8d0298457de3e65f90
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Because the `_historyStepsStates` was not fully set at the time of
calling `historyStep` in `historyUndo` or `historyRedo`, the listener
for the event "historyStep" was triggered to early and `historyCanRedo` at
that time could not possibly be accurate.
This commit call `historyStep` after setting all ids in
`_historyStepsStates`.
task-2667885
X-original-commit: 659b530516e13df77eed6254b81e72b8009a71bf
Part-of: odoo/odoo#79620
In the editor, there was a little spot where it was impossible to
click in order to select a text.
Task-2684378
closesodoo/odoo#79642
X-original-commit: 02c0cce926b1252596f10299597a9c984a8341ac
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet <age@odoo.com>
Some variables were used in _t function instead of raw strings.
One string was not translated properly.
task-2686066
closesodoo/odoo#79505
X-original-commit: 7c5b475532dca1efea5599fb5a3f61ea646d8267
Signed-off-by: Antoine Guenet <age@odoo.com>
Before this commit, when inserting a new snippet or moving a snippet
that was already in the page would temporarily create hooks (`we-hook`)
in the page. The insertion of thoses hooks would trigger mutation
in the dirty observer (observer defined in edit.js) and mark all
oe_structure for which a hook was temporarily inserted.
Thus, creating unnecessary views in the backend.
Now, the code skip the mutations of the drag and drop hooks.
Task-2567752
closesodoo/odoo#79394
X-original-commit: 1b80fe9b56acea09a6784691561df65fe6349f50
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet <age@odoo.com>
Steps to follow
- Edit a report with studio
- Add an inline text element
- Select it
- Select the text in the sidebar
-> An error is raised
Cause of the issue
firstButtonEl is undefined because the style section is not always
present in the toolbar
opw-2674302
closesodoo/odoo#79335
X-original-commit: 45b590d8961d56f8d207c22efbf1ba7188a3b1fa
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
When starting the editor in a web page, if there is no content, the
oe_structure is not editable. Adding snippet at that moment will
trigger `idSet` on the node with isUnbreakable returning `false` for
the node that is unbreakable because of the check
`!node.isContentEditable` in `isUnbreakable`.
When setting the ouid for the first time with `idSet`, `getOuid` is
called with `optimize` to `true`. So all the ancestor of a node that
should be unbreakable will have the wrong ouid.
Performing any command to a node with a wrong ouid is suceptible to
wrongly be reverted.
By removing `!node.isContentEditable`, the node will have the proper
ouid in case an ancestor is not editable.
task-2633368
closesodoo/odoo#79108
X-original-commit: 13804df7740317b8198e7c1de418ff019c05862b
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit, the editor hint were not properly
removed because the queryselector was made on
the wrong document.
Task-2678410
closesodoo/odoo#79104
X-original-commit: d582f43d81cb570017ef6ff90159cdb6a7ff2874
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
When pasting an youtube url in the website builder, the iframe
was inserted without the wrapper used by the website builder.
Now we use the same wrapper as by adding a video through the
video modal.
task-2668224
closesodoo/odoo#79095
X-original-commit: 0cffd7fcdc631b95795d9d819197e5f91ed8195c
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
In the website builder, when pasting a youtube url,
we can transform it to an iframe in the editor through the
Powerbox.
Adding the iframe did not remove the text in the website builder.
Now it properly remove the text in note and the website builder.
X-original-commit: a9c363cb2c6a88f7f4b1ef09b8a8f9caf39d8f32
Part-of: odoo/odoo#79095
Before this commit, when trying to delete one
unicode character (e.g. 😍), only one javascript character was delete
but one unicode character (e.g. 😍) could be two javascript characters
as the javascript string is coded in utf-16.
This commit fixes that by calculating the size of one unicode character
from the javascript string.
Task-2658890
closesodoo/odoo#79071
X-original-commit: fea5b87615077f5f41dec8c4d1480f157bbd26ae
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
When pasting HTML, we have to be careful not to introduce invalid HTML.
The editor corrected for blocks within inlines but failed to prevent the
invalid pasting of blocks within paragraph-related elements
(eg., `<p><h1>text</h1></p>`). This fixes that issue by unwrapping all
blocks from the copied content when trying to paste within an element
that doesn't accept paragraph-related elements as children.
Notably, this fixes an issue that was caused by that problem, in which
pasted HTML content could not be saved because it was invalid.
task-2632676
closesodoo/odoo#79070
X-original-commit: 9c77834e03516f831a9600f0ba4131c957b3ba74
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
When selecting text in a list, the toolbar should show that a list is
selected, and which type. It however failed to do that, which is fixed
with this commit.
task-2638422
closesodoo/odoo#77738
X-original-commit: 2a7436d83abe178bd21c0694edc9825f5d70d65f
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet <Zinston@users.noreply.github.com>
Part-of: odoo/odoo#79057