A new method `triggerEvent` has been introduced in order to simplify
event creation. This commit adapt the tests to use that method.
closesodoo/odoo#92653
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit, when adding a space anywhere in the a text node,
a plain text link gets transformed into a proper link.
It might be an undesired behavior as we could want to manually remove
the link but it will be re-transformed when completing a paragraph.
task-2795019
X-original-commit: 76b5ecc88001ae9decaf3943550ecb4ddb874599
Part-of: odoo/odoo#92653
Ensure the selection in the fonts tags after `applyColor`, otherwise an
undetermined race condition could generate a wrong selection during
multiples call of `_processAndApplyColor` from the color picker.
task-2822221
closesodoo/odoo#92654
X-original-commit: 2b2aba49550cf7c2ba1914f03beef9cbdf60b166
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Outlook's renderer doesn't understand Bootstrap's styling of buttons we
have a special rendering just for it but its design was suboptimal so
this improves it.
task-2761098
Part-of: odoo/odoo#87962
Since background-image elements and their children will be flattened
into images, links within them won't work. This removes the link button
of the editor toolbar, as well as the link and button commands in those
contexts.
task-2856858
Part-of: odoo/odoo#91314
This moves the `html2canvas` library from `point_of_sale` to
`web_editor` so as to be able to use it in `convert_inline`.
`point_of_sale`, depending from `web_editor`, doesn't lose access to the
library.
task-2856858
Part-of: odoo/odoo#91314
Prevent edition on e-commerce products header bar.
Since we cannot save any change done in the header object anyway,
And some edition would trigger error.
We put the all bar in a read-only mode.
task-2745151
X-original-commit: e2f7b8fad76dc816b2f6864340d3740446117cdb
Part-of: odoo/odoo#91840
In some case, when removing format on element with multiple textNode,
the code generate a traceback.
The loops in `toggleFormat` provide a limit element `closestDecorated` to
the `splitAroundUntil` util. However this limit element can be split and
dumped by the format removal. In this case the reference was never encountered
in the DOM by the `splitAroundUntil` code and will bubble all the way to the
`<html>` TAG an try to split it, which generate an error.
We fix it by getting the `closestDecorated` in every loop.
task-2850686
X-original-commit: 2d93345c38f55c276370d0059d562d28320db2fb
Part-of: odoo/odoo#91786
Add some unit test for strikeThrough format.
Those tests reveal some bug in the current formating code.
task-2850686
X-original-commit: 4d8e1dc381d01bb254d2e806a335a40733608f2e
Part-of: odoo/odoo#91786
This commit adds some commands that can be used in the html editor.
Editor Commands
---------------
Some new editor commands have been added:
- */article:*
This command is available on every html field using the Odoo Editor.
This command allows to add a direct link to the selected knowledge article.
- */file:*
This command is only available in the Knowledge App.
This command allows to add a file (or an image) download button inside the
body. The user can choose a file to add from its own file directory or an
existing attachment already present in the database.
- */template:*
This command is only available in the Knowledge App.
This command allows the user to create a block where them can write and lay out
content destined to be reused by the readers of the article. The lasts will be
able to copy and paste it to send it as message or use it as a description on
other records.
No /command can be added inside a template.
Technical notes:
/file and /template commands can be activated in other modules by adding
knowledge_commands = True on the html field in the view where they should
be activated.
Task-2674460
Part-of: odoo/odoo#82315
Co-authored-by: Damien Abeloos <abd@odoo.com>
Co-authored-by: Julien Banken <jbn@odoo.com>
Co-authored-by: David Beguin <dbe@odoo.com>
Co-authored-by: Fabio Barbero <faba@odoo.com>
Co-authored-by: Thibault Delavallee <tde@odoo.com>
Co-authored-by: Aurelien Warnong <awa@odoo.com>
Before this commit, when hitting enter while not in composition mode,
the editor sometimes removed all the content that was added the previous
composition.
task-4720
closesodoo/odoo#91235
X-original-commit: eddc820417d97b4100a9fb2f9f8934a84bb2417c
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit, whenever the element that must be deleted by
`deleteBackspace` matches `isMediaElement` or `isNotEditableNode` and
the cursor was in the beginning of a `<p>` with inline content, the
inline content moved to the parent and the `<p>` was deleted.
Which is wrong.
Now, whenever the element that must be deleted by `deleteBackspace`
matches `isMediaElement` or `isNotEditableNode`, no inline content
moves.
Task-2781328
closesodoo/odoo#91233
X-original-commit: 34d06958d053b070b1e07541214899649602873a
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Inserting `w.r.t` in the editor transformed it into an url.
This kind of content should not be considered as an url.
task-2795012
closesodoo/odoo#91221
X-original-commit: 75c146fac019b952543403736948b803689bd15b
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit:
When having a checked checklist and clicking on the `strikethrough` gives
traceback.
After this commit:
No traceback is being generated.
Task-2833325
closesodoo/odoo#91114
X-original-commit: 491a79f6f8f734990a2ece3fd1b3f90d09a55c85
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit, the linktool was disabling the editor observer
until it was destroyed. This messed up with the undo/redo and the
isDirty.
This commit only disable the observer when necessary.
task-2836351
Forward-port-of: #90064
X-original-commit: 57c98f314332bbb4c3225942e1d3748eb131d8b0
Part-of: odoo/odoo#91074
In Chrome, it is possible to partially select the contents of a
contenteditable=false element if it has a contenteditable=true child.
This commit prevents breaking such uneditables by expanding the range in a
deleterange to fully contain such elements.
It will be useful with the new blocks introduced with the Knowledge module.
Task-id: 2794990
Part-of: odoo/odoo#86489
Currently, the focus is forced on this.editable when using a powerbox command.
Knowledge /template will introduce blocks which are contentEditable=False, but
contains sub-elements with contentEditable=True, which are allowed to use
powerbox commands. Those sub-elements have another editable context as
this.editable. As such, forcing a refocus on this.editable will remove the
caret from the sub-element.
Avoid doing the refocus if the currently focused element is a child of
this.editable and is contentEditable=true.
Task-id: 2794990
Part-of: odoo/odoo#86489
Prevents the user to remove the last child (if it is an empty block) of an
editable, in order to avoid the case where the user can add text nodes directly
in a block where it should not be possible (i.e. directly under this.editable).
Replaces any empty block other than `<P>` by an empty `<P>` which is the default
block for the editor.
Task-id: 2794990
Part-of: odoo/odoo#86489
Add the attribute 'contenteditable' to the frozen list for html elements of
DOMPurify, so that this attribute is not sanitized in collaborative mode when
using _safeSetAttribute.
Task-id: 2794990
Part-of: odoo/odoo#86489
When fakeEl is empty, firstChild and lastChild both equal null.
task-2842638
closesodoo/odoo#90523
X-original-commit: 626caa89cf290f226b19dfa73bc4ab41c7f95fc0
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Avoid living `<li>` tags without a `<ul>` or `<ol>` parent
in the editable html.
task-2842638
closesodoo/odoo#90518
X-original-commit: c6660d9ae1c931da3ad442b30f610db463ede894
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
When converting an element to a list element, we didn't preserve that
original element's attributes. As a consequence the text direction was
lost.
closesodoo/odoo#90247
X-original-commit: 0731ff677491d80540fa2ffc645fd2b471a9f61c
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This introduces a "direction" option on the editor to set the text
direction of the editor (passed by Odoo based on the localization), and
a Powerbox command to switch said direction on a given block. This
allows users to mix several text directions within the same text, eg.
when quoting Hebrew in an English text.
task-2814004
X-original-commit: 693df325588ccaf6385c9f610709f687ccdf61a8
Part-of: odoo/odoo#90247
Before this commit, when pasting multiples lines a new step per line.
So when performing an undo, only one line was removed instead of the
whole pasted text.
task-2833740
closesodoo/odoo#89932
X-original-commit: 06fb4e3e8377dedb02644779f0077e0d883df918
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Before this commit, when unsing the function `insert()` with data being
an empty string, the function crashed but shouldn't.
task-2833740
X-original-commit: d44302550ddc027d4891ad04bf16c364e171e5ad
Part-of: odoo/odoo#89932
Ensure the `onChange()` callback is called
after each history steps in the editor.
Call the `_doAction()` directly, to avoid using the
disabled `_doDebouncedAction()`.
task-2760436
closesodoo/odoo#89339
X-original-commit: 18eaabcb4dab4682e3a94e16dbe66ff3c6f35a77
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
* Avoid auto-transforming an valid url inside an existing <a> tag.
* Ensure the current selection range is deleted
before embedding an image or video.
task-2604627
closesodoo/odoo#89210
X-original-commit: 070bceeadd16e0b5643b91ad583449d31c48313d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
We change the way we handle paste of html data :
The basic flow is :
1. if any range => deleteRange and continue from here
2. if the paste data has only one root <p> :
> we unwrap its content in place
2. if the paste data has two root <p> :
> we unwrap the content of the two p in place
> we force a oEnter between the two contents
3. if the paste data has more than two root <p> :
> we unwrap the content of the first and last p
> we force a oEnter between the two contents
> we insert the rest in between, out of focus block element
@see unit tests in `test/spec/copyPaste.test.js`
task-2604627
X-original-commit: 4dde6d37f30c35714c52e7e28f7011414fed7b6a
Part-of: odoo/odoo#89210
whitelist of html element was not designed to keep the style
set by our own editor ( style on <span>).
We add a system to keep the spans when they meet some requirements.
Requirements are basically having one of the few allowed inline styling css rule.
@see tests in `test/spec/copyPaste.test.js` section 'Html Paste cleaning'
task-2604627
X-original-commit: da92c2335a1241ec9f3974d3bac1c4b7227b2d28
Part-of: odoo/odoo#89210
When delete backward/forward OR deleteRange,
we need to ensure the break lines stay consistent with the user action.
Some cases where not handled correctly.
Mainly when a <p> tags was removed and not directly adjacent to another block element.
In those case we kept too much or too little break lines.
@see tests added in `test/spec/editor.test.js`
task-2604627
X-original-commit: 9f14422ffceadd48b76ff460e4080e0cf5bc6fa2
Part-of: odoo/odoo#89210
Ensure we never move nodes that were not initially in the deleted element.
When deleting an element and merging its content with its sibling,
the nodes contained in the removed element will temporary be hosted
in the common parent, beside possible other nodes.
We don't ever want to touch those others nodes when merging.
This change fix some instances where nodes would wrongly be carry
into another element.
@see new "merge node" tests in `test/spec/editor.test.js`
task-2604627
X-original-commit: 0af6e15ba9d15f20ec74144fd3069e6f409ef802
Part-of: odoo/odoo#89210
Ensure the `_active` property on the PowerBox object is always a boolean.
@see test/spec/copyPaste.test.js
task-2604627
X-original-commit: 124298546cfbc129eb9ae934923a5e4e47392797
Part-of: odoo/odoo#89210
ADD load of units tests covering :
* text paste
* html paste
* image url embed on paste
* url embed on paste
* video url embed on paste
* better coverage on some delete backward and forward
CHANGE some others unit tests :
* tests about merging of block elements that where not accurate
* test about insert HTML ( spec change )
task-2604627
X-original-commit: 378e8d1bd64e3758eb0202be33cb2d8c5bf97eea
Part-of: odoo/odoo#89210
`o_editable` is not supposed to be removed.
Example of a problem if o_editable can be removed:
In translation mode, when deleting the text of the `o_editable` container,
that container could be removed but shouldn't.
See https://drive.google.com/file/d/1U_NUFBvUninOuFKn2H2c4BDcka3OetlD/view
task-2810332
closesodoo/odoo#89071
X-original-commit: 2010c0e2c402f5bb423a0fe683e51923e1e14042
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
The function `setContenteditableLink` makes all the `contenteditable=true`
that are not the link or in the link being `contenteditable=false`.
Before this commit:
If we click on a link A then we click on link B, and if link B has
elements being `contenteditable=true`, the first click makes them
`contenteditable=false` and the second do not makes them
`contenteditable=true`.
After this commit
If we click on a link A then we click on link B, and if link B has
elements being `contenteditable=true`, the first click makes them
`contenteditable=false` and the second click now makes them
`contenteditable=true`.
task-2810332
X-original-commit: 72dd8d6e3c95f614353b1e87322a67c877c255c7
Part-of: odoo/odoo#89071
Commit e834173314f00e36cb3a1f99690d9f220584682c fixed an issue where editable
elements could not be removed if they were nested in a non-editable element,
because the editor considered them to be an editable root.
However, the same logic also applied when doing a history step after adding
such an element. Adding a nested editable element would make the history step
invalid and result in a rollback.
Such a situation can be encountered when adding a recaptcha legal notice to a
website form. The footer of the form is a non-editable paet of the document,
however the legal notice can still be updated by the user. This commit adds a
separate test for the addition of such editable elements that were previously
considered unremovable.
opw-2723017
closesodoo/odoo#88733
X-original-commit: f693e8ed27f753a728d903dfe4d7d10ae1334526
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Prior to this change, if a contenteditable=true element was a child of a
contenteditable=false element, it was always flagged as unremovable=true.
In fact what should happen is that this.editable should be unremovable, but one
of its subchildren can be contenteditable=true while having a parent
contenteditable=false and not be unremovable.
Task-id: 2794990
X-original-commit: 72e2fd7439a0d6e44b5082def35079019371a3b7
Part-of: odoo/odoo#88733
A mechanism is provided by the OdooEditor to circumvent certain problems while
editing links. More specifically, editable zones are patched when editing a
link. This avoids the cursor ending up outside the link whenever the link tag
is emptied.
However, the mechanism does not check if the link is also in the editable zone
before doing so. In translation mode, the editable zones correspond to the
individual translation strings. When translating link texts, this means the
anchor tag containing the translation string is outside the editable zone. The
patching mechanism still applies, resulting in the anchor tag becoming editable
as well.
This causes problems while translating links, for example oDeleteBackward
commands are being rolled back. Checking if the anchor tag is inside the
editable zone resolves the problem.
opw-2780312
closesodoo/odoo#88674
X-original-commit: 99050b26446bbbe949e1fa797210c2a8a68d94cd
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
The chatter and activity html have the video being sanitized upon
save. As it is a desired behavior, disable the ability to add
video from the editor for those field.
Task-2726483
closesodoo/odoo#88266
X-original-commit: c70d42d12eb522767f84a728c71ac30f66521e2a
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
The commands are grouped by command group when rendered by the Powerbox.
That creates a dissociation between the order in which they are rendered
and the order of the arrays in which they are present in the code. The
mechanism to navigate between them with the arrow keys is however
dependent on the latter. As a result we may end up with a visually
disordered navigation.
This adds a private function to reorder these arrays in the same way as
they are rendered, thereby fixing the dissociation.
task-2802749
closesodoo/odoo#87209
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
When no command is found in the Powerbox, the text "No results" is
shown, which is annoying. Instead, this hides the Powerbox we such is
the case.
task-2802749
Part-of: odoo/odoo#87209
Before this commit
On mobile, clicking on a powerbox item called the first command.
After this commit
On mobile, clicking on a powerbox item call the clicked item command.
task-2751059
closesodoo/odoo#88059
X-original-commit: 03638e4d46941bb4751ac2d6df8c08cb4cc2208e
Signed-off-by: Antoine Guenet <age@odoo.com>
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>