Commit Graph
610 Commits
Author SHA1 Message Date
Christophe Simonis f5e7b86686 [MERGE] forward port branch saas-16 up to 920aa6174c 2018-02-01 17:02:19 +01:00
Christophe Simonis 920aa6174c [MERGE] forward port branch saas-15 up to e0422bfd6c 2018-02-01 16:40:13 +01:00
Christophe Simonis e0422bfd6c [MERGE] forward port branch saas-14 up to 7d465aa56c 2018-02-01 15:39:39 +01:00
Christophe Simonis 7d465aa56c [MERGE] forward port branch 10.0 up to 4c9bf7faae 2018-02-01 14:16:50 +01:00
Jeremy Kersten 8a1cb4758d [FIX] web_editor: avoid useless 404 during test
removeSrcAttribute should avoid these rpc, but for some
unknown reasons, on firefox it works but not with chrome.

Because the purpose of the test is to check the url and
not the content, that works to use an existing route.

Courtesy of @kangol for the fix
2018-02-01 14:13:32 +01:00
Nicolas Lempereur 5af1223878 [FIX] web_editor: xml editor first level not shown
There is a slight visual inconsistency since: 9af8d5e6 the xml/less
editor for first level of descendants were just prefixed by an invisible
space.

opw-807624
closes #22704
2018-02-01 14:00:06 +01:00
Christophe Simonis 4c9bf7faae [MERGE] forward port branch 9.0 up to cbaecc5cbb 2018-02-01 12:13:51 +01:00
Nicolas Lempereur 13c326caaa [FIX] web_editor: firefox editor hidden mass mail
When saving a modified mass mailing, the editor will do a number of
things to improve the mail readability accross mail client.

One of those is replacing font awesome icons by image, but firefox acts
differently than other browser. On a display:none iframe, doing
.css('color') or .height() on an element returns respectively
`undefined` and 0.

This caused an error when getting the color that we could solve by
doing a fallback for firefox like this:

 window.parent.getComputedStyle($font[0]).color

But to get the height() of an element, it seems we always need the
iframe displayed.

With this change, when the iframe is hidden and the browser is firefox,
the code try to display the iframe (with "visibility:hidden;height:1px")
when this part of the code happen.

opw-807180
closes #22639
2018-01-31 15:17:37 +01:00
Nicolas Lempereur 109ecd5205 [FIX] web_editor: firefox RTEWidget if hidden
It seems that firefox has some difference of behavior from other
browsers as said in:

- https://bugzilla.mozilla.org/show_bug.cgi?id=548397
- https://github.com/whatwg/html/issues/1813
- https://github.com/w3c/csswg-drafts/issues/571

It seems that at least in one instance (a html field hidden on the pos
configuration), firefox fails because of something similar:
window.getComputedStyle(element) returns `null` instead of the element
styles.

In my tests, using the parent window (possible if current frame and
parent have the same origin which should be the case) worked in this
instance, this is examplified by this jsfiddle:
 https://jsfiddle.net/Lpv898ve/2/

This work with window.parent and not using window directly.

So this commit adds fallback on doing getComputedStyle from the parent
window (when testing on chromium this gave exactly the same result that
before).

opw-813363
fixes #22211
closes #22610
2018-01-30 10:37:53 +01:00
Christophe Simonis 9af65a7efe [MERGE] forward port branch saas-16 up to 0b188b5804 2018-01-29 13:37:12 +01:00
Christophe Simonis 0b188b5804 [MERGE] forward port branch saas-15 up to 2629029d03 2018-01-29 13:29:14 +01:00
Christophe Simonis 2629029d03 [MERGE] forward port branch saas-14 up to 8b8f04e14c 2018-01-29 13:28:18 +01:00
qsm-odoo 7c959e3fd5 [FIX] web_editor: properly show link alignment in toolbar
When clicking on a link in the editor, the "center" alignment button
was always marked as active whatever the real alignment of the link.
This was because it considered the alignment of the text inside the
link instead of the link's one inside its parent.
2018-01-26 16:17:19 +01:00
Christophe Simonis bcf6529755 [MERGE] forward port branch 10.0 up to 8e38a3d069 2018-01-26 16:06:51 +01:00
Christophe Simonis 9620989501 [MERGE] forward port branch 9.0 up to 222cadda41 2018-01-25 20:24:39 +01:00
Nicolas Lempereur b27abee396 [FIX] web_editor: ready when translations ready
$('web_editor.base').ready() returns a deferred that:

- wait at least for $(document).ready()
- wait at least for require('web.ajax').loadXML()
- at most once starts translations configuration

But there is an issue since there is unexpectedly no reference to the
translations, whilst it should have also been ready when ready was
resolved.

This commit keep the reference so translations can be used after
$('web_editor.base').ready() is resolved as it was before 7dfdfa0103.

note: in 11.0 it should be solved with 29729769 (so fix is for [10,11[)

opw-804148
closes #22522
2018-01-25 15:58:32 +01:00
qsm-odoo 25849e9186 [FIX] web_editor: properly allow formatting text (normal/header 1/...)
Sometimes the formatting buttons had no effect or formatted more than
they should (like a whole column when triple clicking on a paragraph
only). This was because of the `listBetween` function implementation.
This is supposed to return all the nodes between one element and another
one... but the logic is wrong without saying from which *point* to start
and which *point* to end. For example, when asking the list between an
element and its parent, the result is very wrong as there is no way to
go from the beginning of an element to the beginning of its parent using
the `walkPoint` function as the `listBetween` function is doing.

Ideally, the function should be entirely fixed but this can be tricky.
For now, the function is just extended to allow to specify points
instead of nodes, and those are used by the `formatBlock` function to
solve the current problem.
2018-01-25 14:36:47 +01:00
qsm-odoo fb81c331f8 [FIX] web_editor: fix double Shift + Enter
Pressing Shift + Enter twice was buggy because of small refactoring
made by https://github.com/odoo/odoo/commit/c227b8fd88e0ed635a8e807501b559b46fee7786#diff-cc5180b5ec2395c1df5c4e475aff43fbL416

opw-806003
2018-01-25 13:58:59 +01:00
qsm-odoo 2fad2e43b8 [FIX] web_editor: solve all triple-click issues
... hopefully.

This *must* be forward-ported.

Depending on the browser, the triple-click behavior is different. This
is especially problematic on Chrome, where blank characters at the start
of the neighbor of the clicked element are selected.

A weak attempt to solve that was made by commit https://github.com/odoo/odoo/commit/b85bd358234684974f9af63bc5f28cfabb527767

This commit hopes to solve all the issues once and for all by fully
reimplementing the triple-click for all browsers. The concept is simple:
when a triple-click occurs, select the whole *inner* content of the
deepest DOM *element* that was clicked.
2018-01-25 12:44:36 +01:00
Christophe Simonis c6b2fa47ed Revert "[FIX] base: bad back-port"
This reverts commit 0ac6043ec7.
2018-01-25 12:43:02 +01:00
Christophe Simonis da9baf2331 [MERGE] forward port branch saas-15 up to 0c97be858c 2018-01-25 11:14:56 +01:00
qsm-odoo 78a556601e [FIX] web_editor: prevent crash when dropping snippets
For some unknown reasons, the editor sometimes crashes when dropping a
snippet. As a temporary fix, the non-critical line that causes the
problem is try/catch protected by this commit.
2018-01-25 11:11:34 +01:00
Christophe Simonis 0c97be858c [MERGE] forward port branch saas-14 up to 4ea4f99df9 2018-01-24 18:12:53 +01:00
qsm-odoo bf5c90d0be [FIX] web_editor: strange horizontal scroll on mousedown
Before this commit, when pressing the mouse button on the end of the
ace editor, it scrolled to the right, selecting the whole sentence
end. This strange behavior was due to some initialization mistake
made by commit https://github.com/odoo/odoo/commit/5a030db3eb77b6d80187f8ae1a64303b2f50391d
2018-01-24 14:01:06 +01:00
Christophe Simonis 950d9b2369 [MERGE] forward port branch saas-16 up to dfe7f00e78 2018-01-22 16:38:01 +01:00
Christophe Simonis a3d3e5e7fe [MERGE] forward port branch saas-15 up to 50d87ae81b 2018-01-22 14:42:09 +01:00
Christophe Simonis 50d87ae81b [MERGE] forward port branch saas-14 up to 3d673b5900 2018-01-22 13:33:58 +01:00
Christophe Simonis 3d673b5900 [MERGE] forward port branch 10.0 up to aac9cd4ca8 2018-01-22 12:32:40 +01:00
Christophe Simonis aac9cd4ca8 [MERGE] forward port branch 9.0 up to 216edc206c 2018-01-22 11:18:14 +01:00
qsm-odoo 216edc206c [FIX] web_editor: properly evaluate if a range is an image
The previous implementation apparently came from an old version
of summernote (see https://github.com/odoo/odoo/commit/d33086c03fc1a0882be38ae62989b7f72df20d3b).

This commits should improve it to handle all known cases.

See https://github.com/odoo/odoo/issues/20877
2018-01-19 14:02:24 +01:00
qsm-odoo f314cf0bb3 [FIX] web_editor: deleteContents when no selection
Changing the `deleteContents` method of the editor is tricky. This
commit however dares to add a behavior: if the range does not
represent a selection but only the cursor position and is then asked
to delete its content... it should not do anything as nothing is
selected.
2018-01-18 15:19:16 +01:00
qsm-odoo cdb2cf744f [FIX] web_editor: DOMElement used as jQuery element
The function receives a jQuery element most of the time but it
may receive a DOMElement in some cases.
2018-01-18 15:17:48 +01:00
qsm-odoo 59e1bdff22 [FIX] web_editor, website: properly clean snippets before saving
/!\ Partial backport of https://github.com/odoo/odoo/commit/0a31cb9b4ae461119ecafdd05c5b979621ffb039
/!\ Should not be forward-ported

Before the websitepocalypse introduced in 11.0 (saas-17), when saving a
page in the editor, every `cleanForSave` method of snippet options were
called, even for snippet options which were not initialized (so if a
snippet was left unchanged before saving, the related `cleanForSave`
methods were called anyway). This behavior was bad code and did not make
much sense and was so removed with the websitepocalypse
(see https://github.com/odoo/odoo/commit/2972976962617d4b8a0113bae58c640ab41cdff8#diff-4c580abda3220e45c6b3f6bdcf77c733L415)

Unfortunatly, the behavior was necessary given the states of our snippet
options. Indeed, for the "latest posts" snippet, the `cleanForSave`
method removes the entire snippet content (as it is dynamically loaded).
The dynamic loading is performed by the snippet *animation*... and
removing the dynamic content should logically be done by the animation
too... which is the case. The problem is that animations are not stopped
before the editor is saved. This behavior was only implemented in
saas-11.1 (for future version 12.0) with commit https://github.com/odoo/odoo/commit/0a31cb9b4ae461119ecafdd05c5b979621ffb039

As a stable fix for 11.0, part of the mentioned commit is backported
here and some specific `cleanForSave` will be reviewed as animations if
necessary. Note: `cleanForSave` made useless by this commit are left
anyway as this is a stable fix.

See https://github.com/odoo/odoo/issues/22089
2018-01-17 15:55:36 +01:00
Christophe Simonis b42b9c936b [MERGE] forward port branch saas-16 up to 3b7bf3a4b8 2018-01-12 18:15:23 +01:00
Christophe Simonis 3b7bf3a4b8 [MERGE] forward port branch saas-15 up to 8962b8ecc2 2018-01-12 17:23:10 +01:00
Christophe Simonis 8962b8ecc2 [MERGE] forward port branch saas-14 up to d35a76ee17 2018-01-12 16:47:12 +01:00
Christophe Simonis d35a76ee17 [MERGE] forward port branch 10.0 up to d76237e038 2018-01-12 16:16:51 +01:00
Romain Derie bd00fa8dd1 [FIX] web_editor: dbclick a video open MediaDialog with wrong media
Before this commit:
In the web editor, if you double clicked on a video iframe to edit it, it would
open the MediaDialog(media) with the wrong media element.
Media would be ' ' instead of '.media_iframe_video' (which is its grand
parent):

  div.media_iframe_video
    div.css_editable_mode_display
      '& nbsp;'

Then, if you changed the media by another one (Image or Video), the media would
be wrongly inserted into the DOM, in the already existing iframe, eg:

  (1) div.media_iframe_video
    (2) div.css_editable_mode_display
      (3) div.media_iframe_video
        (4) div.css_editable_mode_display
          (5) '  '

Since the new media (3) is wrongly instered into (2) instead of replacing (1),
the bug it would not be visible on normal mode (you would still see the
old media) because (2) is not displayed on normal mode.
Then on edit mode you would see both media one over the other.

Note: This only happened when you opened MediaDialog thought double click
directly (not 'Edit 'in navbar) and without clicking somewhere else after you
entered edit mode.

Now, if the media has an iframe parent, we use that parent as the correct media

This closes #22109, closes #22179

Courtesy of QSM for the help
2018-01-12 10:48:42 +01:00
qsm-odoo d3cebdc4a2 [FIX] web_editor: always hide icon & video tabs when choosing bg img
This was broken in 11.0 if the media dialog was the first dialog to be
opened when using the editor. This happened for two reasons:

- Never use a widget (dialog)'s `$el` before it is started (opened).
  This was the case here. The bug is even worse in saas-11.1 as we do
  not allow to do that from there so it results in a JS crash.

- It worked in <= saas-16 because dialogs were started at once as they
  did not need to load anything. In >= 11.0, the first dialog which is
  opened in the page needs to request the main dialog template and this
  takes some time.

So, this fix makes sense in >= 9.0 but I chose to merge it in 11.0 as it
only induces a real bug from there.
2018-01-05 16:23:44 +01:00
Christophe Simonis 715fda1239 [FIX] web_editor: define variable before use
Oversight of previous forward-port
2018-01-02 17:24:11 +01:00
Christophe Simonis f02ed9ab9a [MERGE] forward port branch saas-16 up to 0af13af5de 2018-01-02 16:54:38 +01:00
Christophe Simonis 0af13af5de [MERGE] forward port branch saas-15 up to ddd293065e 2018-01-02 15:36:25 +01:00
Christophe Simonis ddd293065e [MERGE] forward port branch saas-14 up to ba2a83ddfa 2018-01-02 15:02:26 +01:00
Christophe Simonis ba2a83ddfa [MERGE] forward port branch 10.0 up to e336dc38ca 2018-01-02 13:56:49 +01:00
Christophe Matthieu fdf0f014bf [FIX] web: avoid race condition in the website
Depending on the speed of the runbot, errors may appear if one tries to
use a template that is not yet loaded. Templates are being
loaded and we add new template to read, the ready function does not
take into account new additions.
2017-12-19 13:35:36 +01:00
Christophe Matthieu 7dfdfa0103 [FIX] web_editor: Avoid twice translated for static xml
Avoid texts to be translated twice if some modules have the translated
value corresponding to the English source term.

To reproduce: create a translation for static xml (comment 'openerp-web')
with 'Modifier' translated by 'Tadaaa'. In french context, the 'Edit'
button in forms is translated by 'Tadaaa'.

Don't translate template in web_editor if we are in the backend because
the translations of all the modules have already been loaded and applied.
2017-12-19 13:35:36 +01:00
qsm-odoo b1b13dbeed [FIX] web_editor: revert copy/paste feature of the editor
The feature was introduced and fixed by following commits:
- https://github.com/odoo/odoo/commit/906875fc78cb80f6c3d5f1f14f997008cd406473
- https://github.com/odoo/odoo/commit/76be5eed449c78eaf0b4208c381169132492ab4a
- https://github.com/odoo/odoo/commit/7401807510a103374fa8eb524ae5a5698ae21a39

The feature is however still buggy in lots of cases as it is a bad
heuristic that cannot handle simple pasting cases. The feature was
initially introduced to allow pasting PDF content without having to
remove all the unwanted line breaks this induces. As this feature is
not that important and introduced more bugs than it solved, the feature
is deleted by this commit. If we want that feature again, maybe it is
worth considering an "Import from PDF" button or something like that.

See https://github.com/odoo/odoo/issues/15665
2017-12-18 16:10:33 +01:00
Alexandre Kühn 6632822d14 [FIX] web_editor: html field commitchanges fully loaded
Fix over this one: https://github.com/odoo/odoo/commit/cae188514fa8b0a7c785a630ac4aff677b2071fa

The intent was to disable buttons in form views until html fields are fully loaded,
but it was not disabling the buttons for the following reasons:

   1. It is looking for buttons in the DOM, although they
      are not already attached into the body at this moment.
   2. It was disabling the buttons only at widget start(),
      so only once after "Empty Cache and Hard Reload".

We propose a better solution than disabling the buttons in the control panel:
when we click on "Save", the html field ensures that it is fully loaded while commiting the changes.
2017-12-18 11:27:11 +01:00
qdp-odoo 78ae6f470b [MERGE] forward port branch 9.0 up to 9bba7fea42 2017-12-15 16:58:40 +01:00
qsm-odoo 69d4383d7b [FIX] web_editor: browser-unify alignment editor option
Summernote uses `document.execCommand` to apply most styles when
editing, leveraging the implementation to the browser.

Summernote is configured to use HTML styling (`'styleWithSpan': false`),
and in this case, browsers such as Firefox use HTML attributes for
styling text align, while Chrome still uses CSS for that. In fact,
`document.execCommand` is browser-inconsistent... but so is the
`styleWithSpan` option. Indeed, setting the option to `true` will make
Firefox use CSS property for alignment too... but not Internet Explorer.
So we might consider changing this option's value but this would not
solve the current problem.

Indeed, any CSS `text-align` style in Firefox takes precedence above
the element's `align` attribute, so when users were trying to align text
on stuff that was pre-aligned, they were unable to do so.

We can better explain the situation with this example:
A user tries to left-align in Firefox a `p.text-center` element, and
produces this:

```html
<p class="text-center" align="left"/>
```

(`align` attribute is ignored because of the `text-center` class)

On Chrome, this would be produced with the same steps:

```html
<p class="text-center" style="text-align:left"/>
```

With this patch, we actually make that HTML look like expected by the
user, no matter the browser he's using, by forcing the editor to use
the text-align CSS property. Note that the implementation is quite
ugly but had to take care of compatibility.

See https://github.com/odoo/odoo/pull/20900
(thanks to @Yajo for original PR)
2017-12-15 14:06:04 +01:00