summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js
AgeCommit message (Collapse)Author
2021-05-27[FIX] website, web_editor: fix colorpicker previewxO-Tx
Issue: > Set bg color combination for a snippet... > Save > Edit mode > Select the snippet > Open color palette in bg option > Hover a color option > When a color button is left, the preview is cancelled but the color combination class is not applied anymore. In '_computeWidgetState' (for 'selectStyle' method), the right value ('o_cci') is not returned because we get empty "colorNames" (the "colorPalette" is not rendered on start). The goal of this commit is to fix this behaviour by rendering the colorPalette in start for snippet options, this way, the new code won't affect the speed fix added in [1] for 'OPTIONS' tab. [1]: https://github.com/odoo/odoo/pull/65223/commits/ce54c3f21293513673cb1fc6073ada5f0a2b5641 task-2538326 closes odoo/odoo#71174 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-04-28[FIX] web_editor: add check before updateLeftPanel timeoutArthur Detroux (ard)
Added a check to make sure that we do not set a timeout to update the option panel when said option panel is already open. This could sometimes occur which could cause all openned select to close and could fail some tests if said events happened in the middle of selecting an option. task-2502297 closes odoo/odoo#69119 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-04-28[FIX] web_editor: email receiver see file iconNicolas Lempereur
Scenario: - add a file in mass mailing editor => an generic icon (instead of lower version where icon depended on mimetype) is added linking the file - save and send mail => no icon is shown in email received The system is targeting `a[href*="/web/content/"][data-mimetype]:empty` to add real image inside instead of using background-image attribute which is stripped in sanitized. With this commit, data-mimetype is not removed when image processing attributes are removed when a file is inserted. opw-2474053 closes odoo/odoo#69915 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-04-09[FIX] web_editor: have transcoder apply text-decorationNicolas Lempereur
The transcoder (transforming CSS rules into inline CSS for mail clients) was not working for text-decoration property because it would transform text-decoration values in: {'text-decoration-thickness': 'normal', 'text-decoration': none} And the regex that ensures we don't add duplicates check if there is: "(^|;)\s*text-decoration" so if there is text-decoration-thickness, text-decoration is not added. The regexp could be changed to: "(^|;)\s*text-decoration[^\w-]" but we already have special case for other text-decoration-* properties. With this change we should get text-decoration applied in: - edit mode (was already the case) - readonly mode (new) - mail client (only if mail client does not override it) As a side note: text-decoration-thickness seems to be rather new[^1] so at one point in time there was probably no issue. [^1]: https://developer.mozilla.org/docs/Web/CSS/text-decoration-thickness opw-2496490 closes odoo/odoo#69074 X-original-commit: f4f1b890e15e98d9a7e72586faf73327d3f7b716 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Co-authored-by: Kamen Zhekov <kzh@odoo.com>
2021-04-06[FIX] website_sale, *: make the product image container not editableYounn Olivier
*: web_editor It prevents user writing in the image preview of products. Also, the product image view now fit its container so that the user can click wherever in the frame to change the picture. Part of https://github.com/odoo/odoo/pull/65575 task-2446852 closes odoo/odoo#65575 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-04-01[FIX] web_editor: use escape for image renderingMartin Trigaux
To properly escape all tags and not just the first one And move the escape before the loop to apply for everybody This avoid weird preview with selected content rendered (had effect only on preview) closes odoo/odoo#68633 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-03-30[FIX] web_editor: show XML editor error if rejection valueNicolas Lempereur
Override in enterprise web_studio of _saveView on error never rejected promises. But now it does so the XML editor interface is not blocked after error. But we were already showing the correct error in web_studio use case, so we don't want another one and this change allow that by only showing an error if we received rejection value. opw-2460081 closes odoo/odoo#68554 Related: odoo/enterprise#17381 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-03-25[FIX] web_editor: don't run code when input is emptiedRomain Derie
Before this commit: - Edit mode, open image dialog - Upload an image to the media dialog - Reclick on Upload but don't select an image, close the browser image selector - This will trigger the input change event, as the input was emptied This is needed since in later commit, `_addData()` will do some code outside of the `files` loop, which is useless if there is no files selected. In thise case, the issue would be that it would open an empty toastr. task-2345082 Coming from #65828 Closes #68326 closes odoo/odoo#68334 X-original-commit: 94c45412714c1263788b2567ce3c9581453b2cd4 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-03-25[FIX] web_editor: fix race condition in option selectionSamuel Degueldre
Previously, when selecting certain options, especially ones which had slow updateUI methods, the selected value was sometimes reset to its previous value. This was caused by a race condition in which, when a snippet option updated its value, it would wait for options on the parent snippet editors to update all of their options' UI, but it incorrectly only waited for *one* of the snippet editors to finish instead of waiting for all of them. This commit fixes that by stopping the event propagation and triggering a new event that will let the direct parent know when all parent editors are done updating their options' UI before signalling that the UI update is done. task-2487578 closes odoo/odoo#68238 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Co-authored-by: Arthur Detroux <ard@odoo.com>
2021-03-18[FIX] web, web_editor, website: fix incorrectly translated template literalsSamuel Degueldre
closes odoo/odoo#68085 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-03-17[FIX] website_forum: show normal image modal in forumNicolas Lempereur
In #67893 the image icon was removed, but it contradicts the interface and made a feature that was working for employee less available. Since saas-12.3, we always use the full media dialog when showing the editor on the forum so we could not add an image with the image icon if were not an employee. Before saas-12.3, the original summernote image dialog was shown for everyone but website editor that saw the full media dialog (beecause we are using the same editor to do both things). With this change, we always have the original dialog in the forum message editor thanks to a new option "disableFullMediaDialog". opw-2470720 closes odoo/odoo#68018 X-original-commit: 74af23fb0be60c996503ad599eb96bc2ab4d64f9 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-03-05[FIX] web_editor: fix media-dialog not showing most imagesSamuel Degueldre
This was caused by trying to not show dynamic-svgs that had already been downloaded when the option to not allow the media-library was activated (eg in the website logo, we do not want to allow dynamic SVGs) Unfortunately the domain was doing a string comparison to make sure the url wasn't like the one from dynamic SVGs but implicitly required that the url field be not null. This commit fixes that by explicitly allowing images with a null url field. task-2466819 part of odoo/odoo#66732 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-03-05[FIX] web_editor: adapt warning when quality options are unavailableSamuel Degueldre
Previously, when quality options were not available, the option would simply not be displayed. User feedback suggests that this is confusing, as for example, in the case of modifying the image in a t-field, quality options would not be available when starting the editor, but would become available when picking the image again in the media-dialog. Some leftover code allowed to display a warning about why the quality options were not available in the case where the image is not local to the database. This warning has been adapted to display a more informative message about why quality options are not available, as well as suggest a solution: - External image => download the image and upload it in odoo - t-field => "You need to choose this image again in the media-dialog or reupload it to have access to quality options" - Images that are in an unsupported format (anything other than PNG or JPEG) => short explanation that quality options are only available on PNG and JPEG images. task-2466819 part of odoo/odoo#66732
2021-03-05[FIX] web_editor: fix parent element selectionxO-Tx
When a block is removed, the parent will be activated. If the parent element is empty and removable: 1) It will be removed too. 2) In '_activateSnippet' method, we look for the right element to be selected using the block's parent (removed from the DOM...). The goal of this commit is to fix this behaviour by computing the selected element before parent removal. task-2431506 closes odoo/odoo#65428 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-02-22[FIX] website_form, *: allow to update buttons using link dialogxO-Tx
*: web_editor, website_mass_mailing When we double click a link/button, a link dialog appears to update the target properties, and since the current link dialog can only handle anchor targets, using it on buttons leads to some inconsistencies : - visible href options for button & url required to save changes. - missing preview when button style changed. ... The goal of this commit is to add a fix (with minimum of code) on summernote linkdialog to handle button elements using the same logic as anchor nodes. Also, update website form test tour to test those new changes. Part of https://github.com/odoo/odoo/pull/62206 task-2381305
2021-02-23[FIX] web_editor: bgOptimize+parallax=bg no kaputNicolas Lempereur
Scenario: - set new background image - set parallax - save => on next edition, the editor doesn't work on background anymore Why: - backgroundOptimize copy attributes of the original image to the real target element on save - parallax change the real target element to a new child => so if the original element was an editor (with data-oe-model, ...) attributes, with the combination of the two options we will save these editing attribute on the child element which is wrong (the editing attributes are added dynamically and should not be saved). With this changeset, we don't copy the editing attributes in backgroundOptimize when we copy the original target image. opw-2427560 opw-2429340 closes odoo/odoo#66665 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-22[FIX] web_editor: can set bg position on root editorNicolas Lempereur
Scenario: - go to /slides and start editing the page - change the position of background banner - save => traceback Why: The code for pan tool duplicates the target element in an overlay. In the given use case, it means a node with .o_editable class is created that will cause an error when saving because the code expect the cloned element to be an editor (in `RTEWidget.save()`) but it is not (and is eg. missing `.data('options')`). opw-2427560 closes odoo/odoo#66639 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-19[FIX] web_editor: no error background position + ctrl ZNicolas Lempereur
Scenario: - start editing background position - press TAB key - press CTRL + Z => traceback Why: Restoring a snapshot with CTRL Z can send a click event with target not wrapped in a jQuery object which was not expected by the code. reported in https://github.com/odoo/odoo/pull/66462#issuecomment-782025417 opw-2423445 closes odoo/odoo#66540 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-18[FIX] web_editor: have video button even if sanitizedNicolas Lempereur
If a field is sanitized, a6e2b484e2 would hide the video button because the video does not show in backend. It is better for the consistency but if the field appear in frontend, the video would still show so we prevent something that worked (but is very not user friendly when editing in backend). This changeset go back to the previous behavior (keeping the code simplification), at one point there should be a fix so at least when editing we see the video (currently we see an empty div in given conditions). opw-2463746 closes odoo/odoo#66449 X-original-commit: 73f578192e453f7f8d276604017625b5e712b875 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-18[FIX] web_editor: don't save cropping tool on CTRL+ZNicolas Lempereur
Scenario: - start cropping of an image - press TAB key - do CTRL + Z => now the image cropping tool are inside the page and there is no way to remove them. Why: The image crop tool was added inside the editable elemnt, so if we did an action that changed history the cropping tools are saved in the snapshot and going back to it will add them without any code handling their removal. opw-2394877 opw-2423445 closes odoo/odoo#66462 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-18[FIX] web_editor: shift+enter in editor add direct newlineNicolas Lempereur
Enter keypress browser event were removed in 3c372d1da8b. It was reintroduced in text fields with d2f024d2543 and in source mode of html field with b10ca1f6094b. When doing ENTER in the editor, we do our special case of ENTER (eg. it will split the container in two and have other custom behavior) but when doing SHIFT+ENTER we let the browser handle it and add a normal newline. With the "Enter" prevention, SHIFT+ENTER did not work. opw-2463746 closes odoo/odoo#66442 X-original-commit: 27b84138b422f0dbb3e01c83bb817d0880e3eab3 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-16[FIX] web_editor: stop loading button once ace savedNicolas Lempereur
When we edit a view with ace in eg. studio, if it works the saved button would never be enabled again because of missing callback. Match the behavior of dom.addButtonLoadingEffect other usage (80592abd). opw-2457046 closes odoo/odoo#66269 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-16[FIX] web_editor: fix drag and drop when drop zones are too closeBenjamin Vray
Before this commit, the preview of the dragged snippet didn't work when moving a dragged snippet from a drop zone to an other drop zone when there was no space between those drop zones. It is because, in this case, the over event of the second drop zone is triggered before the out event of the first drop zone. task-2312878 closes odoo/odoo#66165 X-original-commit: 3ac79957d8f6948c965f76e0b5d73ba39a34c69e Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-02-15[IMP] web_editor: instantiate color palette only when necessaryBenoit Socias
Color palette are only visible once they are opened. However, we instantiate them a lot to build the "options" editor panel which caused the editor to appear buggy for some users... even if they would never open a colorpalette. This fixes that issue. The fix is not entirely stable but was made as stable as possible... better implementation will be done in master. task-2439295 https://github.com/odoo/odoo/pull/65223 closes odoo/odoo#65223 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Co-authored-by: qsm-odoo <qsm@odoo.com>
2021-02-15[FIX] web, web_editor: avoid rendering color palettes more than onceBenoit Socias
Before this commit the palette was rendered each time it was opened. After this commit if the palette has already been rendered only the selected color is being updated in the palette (and its colorpicker). task-2439295 https://github.com/odoo/odoo/pull/65223 Co-authored-by: Samuel Degueldre <sad@odoo.com>
2021-02-15[FIX] website, web_editor: ensure the loader appears on click optionsBenoit Socias
Before this commit the loader did not always get displayed when switching to the options tab. After this commit the loader always gets displayed ASAP when switching to the options tab until the tab is ready and displayed. task-2439295 https://github.com/odoo/odoo/pull/65223 Co-authored-by: Samuel Degueldre <sad@odoo.com>
2021-02-05[FIX] web_editor: insert record name as textSamuel Degueldre
Previously, the many2one widget from the web_editor used jQuery's '.html()' method when inserting a record name into the page. The record name was not HTML-escaped before this, which may have unexpect result and break the layout. This commit fixes that by using the '.text()' method instead. This bug only affects pages containing a many2one (contact excluded) at the time of selection and not after the selection. e.g. on the /event page, changing the category of an existing event via the website editor closes odoo/odoo#65642 X-original-commit: 53aff7f07317a8261b8b9c3e462d930141c7081b Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-02-04[FIX] website, web_editor: fix empty parallax snippet not being removedSamuel Degueldre
Previously, when removing all the content of a snippet, that snippet would get automatically deleted. This was not the case for parallax snippets because we previously intended the user to drop the parallax snippet, empty it, and drop other content inside of it. Recently, we added the parallax option on all snippets, rendering the previous workflow obsolete. There is now no longer any reason to keep empty parallax snippets. This commit fixes that. task-2446008 closes odoo/odoo#64907 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-02-02[FIX] web_editor: fix background layers buttonsxO-Tx
Example to reproduce: Drop the "Cover" snippet and try to remove the background image. Clicking on image button has to be done 3 times to land on the correct result: - First click removes image, but not filter and leaves both buttons checked - Second click removes the filter and unchecks its button. - Third click unchecks the image button. It should be one click to remove image, filter and uncheck both buttons. The goal of this commit is to prevent _applyOptions() from setting background-image values if image is not optimizable. This filter will solve the issues since empty values (badly parsed by getBgImageURL()) won't be added as background urls. task-2312878 closes odoo/odoo#62984 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-28[FIX] mass_mailing, web_editor: send mail to outlook and keep image sizeNicolas Lempereur
Office Outlook doesn't take into account the [style] attribute, and it doesn't manage width/height in percent value. This commit set width/heigth attribute in pixels and also always set the width/height in style attribute (keeping them in the original unit and setting them to auto if not present). This is a reintroduction of 2015 commit bdf58adb465b opw-2447756 closes odoo/odoo#65212 X-original-commit: c51762a790d6fefd97e6c818bfaa9307180dd5b5 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-01-28[FIX] web_editor: fix dropzones with invisible elementBenjamin Vray
Before this commit, dropzones were created around invisible elements (e.g. the snippet popup). So we had 2 dropzones instead of one at some locations. After this commit, we avoid creating dropzones around elements that must not have dropzones. task-2312878 closes odoo/odoo#65198 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-27[FIX] web_editor: prevent a modal from closing when dropping a snippetBenjamin Vray
Before this commit, when you dropped a snippet using the move button in a modal. The modal closed after the drop. This commit allows to define an element in which to destroy the editors. Part of https://github.com/odoo/odoo/pull/61998 task-2312878 closes odoo/odoo#61998 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-27[FIX] web_editor: fix scroll during dragging a snippet in a modalBenjamin Vray
Before this commit, it was not possible to scroll a popup with a dragged snippet. Part of https://github.com/odoo/odoo/pull/61998 task-2312878
2021-01-27[FIX] web_editor: close open invisible elements before deleting itBenjamin Vray
Before this commit, open invisible elements were not closed before being deleted. This created issues like the 'modal-open' class wich was not removed from the body when removing a modal. Part of https://github.com/odoo/odoo/pull/61998 task-2312878
2021-01-27[FIX] web_editor: fix drag and drop a snippet in a modalBenjamin Vray
When a modal is open, allow the drop of a snippet only in this modal. Part of https://github.com/odoo/odoo/pull/61998 task-2312878
2021-01-27[FIX] web_editor: fix scroll event on snippet popupBenjamin Vray
Before this commit, when scrolling a snippet popup, the overlay was not updating its position. So now, we use addEventListener instead of jQuery for the scroll event on the scrolling element because we need the 'capture' parameter. Setting this capture parameter to true allows us to take advantage of event bubbling for events that otherwise don’t support it. Part of https://github.com/odoo/odoo/pull/61998 task-2312878 Co-authored-by: Samuel Degueldre <sad@odoo.com>
2021-01-27[FIX] web_editor: properly hide the custom colors section if neededqsm-odoo
The 'custom' key was not working anymore as a key to exclude the ability to choose a custom color from a color palette widget. It was thus appearing for choosing the transparent color for over-the-content headers... which is not possible to save right now. Part of https://github.com/odoo/odoo/pull/65139 closes odoo/odoo#65139 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-25[FIX] web_editor: restore website header once page content is removedqsm-odoo
The affixed header was not reappearing if page content was removed and the page thus indirectly scrolled. task-2446020 closes odoo/odoo#64990 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-22[FIX] web_editor: save custom snippets per websiteBenoit Socias
Before this commit the custom snippets were saved across websites because the RPC mechanism used by the save & reload does not include the context by default. After this commit the custom snippets are saved for the specific website as initially intended. No migration is needed: already created snippets that have been created across all sites will have the correct lifecycle because of the copy-on-unlink system: trying to delete one will make it specific on other websites. Related to task-2374802 closes odoo/odoo#64917 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-21[FIX] website, web_editor: fix drop zones when dragging a snippetBenjamin Vray
Before this commit: -when moving a snippet using the drag and drop button, two drop zones instead of one was added at the initial location of the dragged snippet. -when moving a snippet using the drag and drop button, no drop zone was added at the initial location of the dragged snippet if the snippet was alone in its parent. For example, the left jumbotron in the banner snippet. -the drop zones handled by the "children rules" were never vertical when it was necessary. This commit also refactors the code to avoid some duplicated lines. task-2312878 closes odoo/odoo#64838 X-original-commit: e637056b3b1f4129342e5c79a4d761c7aaf56a40 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-13[FIX] web_editor: solve bold command issuesqsm-odoo
Summernote uses execCommand and, worth, obsolete queryCommandState function to customize the edited content. Here we try to hack the function to solve some problems by making the DOM and style easier to understand for the base functions for the duration of their executions. This won't obviously solves all problems but this is an improvement while waiting for the new Odoo editor coming in future versions. The original problem this solves is handling bold text in blog posts. Posts are using font-weight: 300 which is enough to confuse summernote. Hitting bold on a selected paragraph wraps its content in a <b> tag but hitting bold again does nothing... having a <b> rendered as fw-400 is enough to break it. What this commit does is: before any execCommand or queryCommandState being used to modify the DOM or retrieve its state, the whole DOM is forced to fw-400 and <b> elements to fw-700. This also solves issues in some base snippets. closes odoo/odoo#64472 X-original-commit: 424d9661c5657cbcf10ce40acb94a7a200c2a48b Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-12[FIX] web_editor: fix steps snippet line removed when change icon bg-colSamuel Degueldre
Previously, when changing the background-color of an icon in the s_process_steps snippet, the line that goes through the snippet would disappear from that block. This was caused by our font-application code attempting to remove extraneous DOM nodes when changing a font color or backrgound-color, but not considering elements with a ::before or ::after pseudoelement has having content, and subsequently removing them. opw-2423785 closes odoo/odoo#64404 X-original-commit: 6b363d202d9c35e8249f7bb2b0730b995fdf4a7d Signed-off-by: Samuel Degueldre <sdegueldre@users.noreply.github.com>
2021-01-11[FIX] web_editor, website: prevent multiple click on saveRomain Derie
Clicking on save on html editor is taking quite some time. The user might think something is not happening and need to click again. If he does click again, 2 write RPC will be sent, making the COW business code being triggered twice, ultimately leading to create 2 COW. Instead of A / \ B B' It will be A / | \ B B' B' With as many B' than there is click on save. This commit adds a generic helper to make a button load/spin. closes odoo/odoo#63417 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-07[FIX] web_editor: fix icons losing classes when modifying themSamuel Degueldre
Previously, when double clicking and image, video, icon, or document in the web-editor and replacing it with a different media type, it would lose its custom classes. This means among other things, that it would lose margins and paddings from bootstrap classes, or in the case of the three columns snippet, that the new media would not be properly rounded in its top corner, or not show up at all in the case of the video. The only exception was when changing any media type to an icon, but in that case it would also keep some of the media-specific classes that are supposed to be removed (eg img-fluid or media_iframe_video). This commit fixes that as well as some _clear behaviour that didn't remove all classes that had to be removed, eg some fa-classes would linger depending on their order, and the o_image class from documents would always remain Part of: odoo/odoo#60450 Linked to: #60432 #60443 task-2282542 closes odoo/odoo#64230 X-original-commit: 99531f5dd8966fc4ad89d1e9c2886ad701527f3a Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-07[FIX] web_editor: fix replacing media leaving unexpected elementsSamuel Degueldre
Previously, changing a media from a video/icon/document to a different type would leave empty elements in the DOM, this is because summernote's range API `range.insertNode` function deletes the content but not the structure (HTML elements). This commit fixes that by using jQuery's replaceWith method instead of summernote's insertNode when a media was found, and only using summernote in case no media was found (eg. a text range). Part of: odoo/odoo#60450 X-original-commit: 63f80995a05eeab1061b769c7733a1cfa98c726e
2021-01-04[FIX] web_editor: don't reoptimize already optimized image if repickedSamuel Degueldre
Previously, if you double-clicked an image in the web editor with the intention to change it, but the image had already been optimized, and then repicked the same, already optimized image, the image would be optimized again even though it had not changed. This commit fixes that by making the media-dialog not trigger an image_changed event in those cases, and by leaving the initial image untouched. Linked to issue #57604 closes odoo/odoo#57910 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-12-24[FIX] web_editor: stop suggesting shapes for model-related imagesqsm-odoo
Those kind of images use a specific route (/web_editor/shape/...) to be fetched. While waiting for a more complete solution to maybe handle them for model-related images, this commit only allows their use for images in views and HTML fields. closes odoo/odoo#63682 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-12-17[FIX] web_editor: fix permanent loading effect on option double-clickSamuel Degueldre
Previously, double clicking an arrow to change the order of images in the image-gallery snippet would cause the loading effect to permanently stay and block the snippet editor completely. This was caused by the fact that when clicking the arrow, the gallery snippet rebuilds itself from scratch. After a snippet option is used (in this case, the reordering arrow), we update the snippet overlay, and destroy snippet-editors whose target is no longer in the DOM. When double clicking, by the time we handle the second click, the target of the option has been removed from the DOM, and the widget has been destroyed. However, when we try to apply the option anyway, we trigger_up some events (eg to refresh the public widgets) and wait for the trigger_up to call back. Since the widget is already destroyed, it no longer has a parent and trigger_up fails silently, never calling us back, and blocking the mutex. This commit fixes that by checking whether the widget is destroyed before trying to apply the option, bailing immediately if it is the case, and unlocking the mutex. opw-2394953 closes odoo/odoo#63532 Signed-off-by: Samuel Degueldre <sdegueldre@users.noreply.github.com>
2020-12-15[FIX] web_editor: fix crash on chrome (cannot read editable of null)Samuel Degueldre
This crash is caused by some of our integration code with summernote. When clicking on a button of the toolbar, we attempt to create a range from the current selection so that we can show the image toolbar if the selection contains an image, but there was no check to see whether the current selection was actually inside of the editable part of the page. This causes issues later when we attempt to generate layoutInfo for the image, as it will look for the editable area that contains the image and fail. This commit fixes that by making sure that the current selection is inside of the editable area before adding it to the styleInfo. opw-2376794 closes odoo/odoo#63373 X-original-commit: b26c57b4ab269ca7ad3ba3fc2b4a7f4d60d995e8 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-12-10[FIX] web_editor: fix background position on shapesBenjamin Vray
Before this commit, the background-position was not removed from a shape when it was re-flipped to its original orientation. introduced in #61114 closes odoo/odoo#63173 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>