summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/backend
AgeCommit message (Collapse)Author
2020-10-21[FIX] web_editor: disable embedded video for html fields in backendIEL
TLDR: the videos doesn't work anyway, but nobody noticed it for years; at the same time there is no easy way to fix it STEPS: * create a record with html field, e.g. project.task * add an embedded video (File/Image icon) * save BEFORE: video doesn't work AFTER: there is no option to add embedded video anymore WHY: * iframe tags are removed before storing html in database, so after saving a record, embedded video doesn't work anymore * possible fixes look too tricky for stable branches: * new field attribute sanitize_iframe=False -- requires changes in core python framework which may have side effect * adding iframe on client side -- the problem is that the backend doesn't have mechanism to use animation in html fields like it's done in website: https://github.com/odoo/odoo/blob/ced500e9bcbb5c84033463689d135ad4c7dc4f39/addons/website/static/src/js/content/snippets.animation.js#L623-L632 * adding iframe on server side -- parsing html fields in _read... Doesn't look good either * double selector is required to make it work both in frontend and backend: $editable.closest('.o_editable, .note-editor') * we don't need hardcoded exception for mailing.mailing, mail.compose.message because those fields marked as sanitized (default value) https://github.com/odoo/odoo/blob/c92f058571b0656451f24e24154dd1bdb3bdb48a/odoo/fields.py#L1589-L1590 https://github.com/odoo/odoo/blob/c92f058571b0656451f24e24154dd1bdb3bdb48a/addons/mail/wizard/mail_compose_message.py#L115 https://github.com/odoo/odoo/blob/61734cdaf1cf6857125b1ece63928ab080359c6c/addons/mass_mailing/models/mailing.py#L77 * I don't apply this for Odoo 12, because js is refactored in Odoo 13 (e.g. field_html.js has another name in Odoo 12) --- opw-2353103 closes odoo/odoo#60474 X-original-commit: 2dcbac08effcedafbcf50610355752030902b16d Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Signed-off-by: Ivan Yelizariev // IEL <yelizariev@users.noreply.github.com>
2020-10-19[FIX] mass_mailing, *: restore mass mailing optionsqsm-odoo
*: web_editor The snippet options which were specific to mass mailing were not loaded anymore as they were loaded outside of the iframe where the edition take places. Fortunately, the generic options were still working and are the most important. This bug was only revealed thanks to another bug fix which wanted to be done in the unloaded file. Note: this fix is a series of huge hack to make it possible and as safe as possible in stable versions. This obviously has to be refactored in master, if not already done. Part of https://github.com/odoo/odoo/pull/60203 X-original-commit: 7225ce6b862c4f6b99a97732833b43189530699a
2020-07-28[FIX] web_editor: carriage return in source modeNicolas Lempereur
Enter keypress browser event were removed in 3c372d1da8b. It was reintroduced in text fields with d2f024d2543 and this PR do the same and reintroduce it for source mode of FieldHtml (`html` widget). opw-2302605 closes #55066 closes odoo/odoo#55081 X-original-commit: b10ca1f6094b7c8e6e222aa0ea3d1f891e79379a Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-06-05[IMP] web_editor, *: move image optimization feature to left-panelSamuel Degueldre
*: website, mass_mailing In continuity with the nline crop, in an effort to make the image workflow as seamless as possible in the website editor, the image optimization feature has been moved out of the modal which could be opened through the media-dialog and into the left panel. This commit adds a quality slider and a width selector, as well as a preview of the image's weight to the left panel, and removes the image_optimize dialog. This commit also introduces the possibility to add a color filter on images. Part of https://github.com/odoo/odoo/pull/51517 task-2192755 closes odoo/odoo#51517 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-02-27[FIX] web_editor: do not store base64 of cropped image to html fieldKishan Gajjar
On crop dialog save, the image src is set to the base64. We are creating an attachment for the cropped image if the user save the changes and after that, we set the newly created image as the src of that image. Meanwhile, when the user save the 'html' field, it is not creating any attachment for the cropped image and also it leaves base64 as it is. Due to that field store large data into the database. this commit makes sure that attachment is created for cropped images and update src before storing field value to the database. closes odoo/odoo#46455 X-original-commit: 2bcaa25e67260e3013d4400d1b3ce380ba5cbd1d Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-02-11[FIX] web_editor: deny videos in mass mailingAndrea Grazioso (agr-odoo)
Create a new mass mailing, add a video via youtube embed link, save. Send email. Embedding a video can't work because it embeds an iframe, which is not supported by most email clients for security reasons. Extending the noVideo flag also to mass_mailing opw-2179665 closes odoo/odoo#45104 X-original-commit: f9f8c9cc4075fdc5fd4556aa49c914054469198a Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-01-31[FIX] web_editor: fix required html fieldsJason Van Malder
Issue - Studio - Add an required html field - Create new record - Leave it empty It is saved Cause The isSet function of FieldHtml widget, have a "/" in the <br> tag and summernote empty = <p><br></p>. If you add a space, the value becomes <p>&nbsp;&nbsp; <p>. Solution Remove the "/" and the spaces, check if value != <p></p> && <p><br></p> OPW-2183687 closes odoo/odoo#44427 X-original-commit: c984b1b1210cea1e63f3bc66cec2120554c76c2a Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-27[FIX] mass_mailing, web_editor: edit font awesome icon with zoomNicolas Lempereur
In case of font-awesome icon when the browser is being zoomed, we can get a decimal font-size. There is a system that transform font-awesome in image links so they are readable in any email client (supporting image) but it did not take into account decimal font-size. With this changeset, we only send a integer font size: we do not try to get the original value because styling is relative on elements, a 90% zoom ratio could lead to a 98% font-awesome icon ratio. Also improve edition of font-awesome icon edition after first save by reverting the transformation to image on edit. Thanks to that, the original size will also be reinstated and will not depend on zoom on previous save. opw-2156069 closes #43949 closes odoo/odoo#44033 X-original-commit: fe72bf01b67ea20ddb74a5b05464c63cc77090ef Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-12-19[FIX] web_editor: fix mail template toolbar in debug modeJason Van Malder
Issue - Install Mail template - Enable debug mode (normal or assets) - Create or edit a mail template - Click in the text editor The toolbar is not showing up (it does when we're not in debug mode) Cause We are doing `splice(-1, 0, ['view', ['codeview']])` on toolbar which is undefined, the method crashes and the toolbar doesn't render. Solution Checking if the toolbar is defined before doing all that logic. OPW-2151675 X-original-commit: 0e5ca50d5a8401bb3495e83691eab5c86a97a616
2019-12-09[REV] web: reverts update to fontawesome 5.11.2Kevin Baptiste
This reverts commit ff1c35513aecef5fbc30f7c2f3834450e719714e. closes odoo/odoo#41480 X-original-commit: 116057b26e71db4692280463669f3e80d813ddcc Related: odoo/enterprise#7110 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-11-28[IMP] web: update to fontawesome 4.7.0 to 5.11.2Kevin Baptiste
FontAwesome 5 introduced new names for some icons as described on https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4#name-changes This commit replaces the old names to the new ones. closes odoo/odoo#35826 Taskid: 2050241 Related: odoo/enterprise#5180 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-11-18[FIX] web_editor: remove forced source modeNicolas Lempereur
In e29c08969 source mode was reintroduced. Since complex template seemed broken when it was edited, the feature of forcing source mode when there is a `% if ` or `% set` template directive of 12.3 was reintroduced. Since the direct breaking of the template was mostly solved with the added line: `options.prettifyHtml = false;` the force source mode is not so much necessary and there was report that it was not very clear. In this commit it is removed, and if necessary could be reintroduced later with clearer implementation. opw-2123730 fix #40410 closes #40421 closes odoo/odoo#40458 X-original-commit: be30a3ba431cf24a5fcfdfedd0f9d9f73163c717 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-11-12[FIX] web_editor: reintroduce source mode in debugNicolas Lempereur
In 12.3 there was a number of changes in source mode. This was reverted before 13.0 and somehow it seems the source mode was lost between the 12.3 editor changes and its revert. With this changeset, we introduce back source mode as it was in 12. opw-2091649 opw-2116960 closes #40026 closes odoo/odoo#40120 X-original-commit: e29c08969f6e7ad981e9b7b79027d84dc89fbca2 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-09-19[FIX] web_editor: recursive checkbox checkGorash
In multi-level checkboxes, if there is only one checkbox per level, the expected behavior is that all checkbox will be checked if one of them is checked. This was not the case before this commit.
2019-08-22[REF] web_editor, mass_mailing: new iframe mechanismGorash
Since we reverted the saas-12.2 editor in favor of the 12.0 one, we faced a dilemna regarding how the editor iframe is handled in mass_mailing. The 12.0 version was using a special controller to get the website assets required for mass_mailing while the saas-12.2 version used a completely different mechanism that was, obviously, not handled by the 12.0 version. We did not want to reintroduce the old controllers who were considered to be a hack to load the assets in the mass_mailing iframe. However, we were very cautious about changing the editor itself to avoid introducing new bugs in the editor core of 13.0. The approach we chose at the end, is to use the loadAsset mechanism introduced in saas-12.2 to load the necessary assets and inject them in the mass_mailing iframe. This did not reintroduce the controllers nor did it require to change the code of the editor itself. However, it required moderate changes to the wysiwyg interface. Part of PR 35677. Co-authored-by: Nicolas Bayet <nby@odoo.com> Co-authored-by: Antoine Guenet <age@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com>
2019-08-21[REF] web_editor, website: adapt wysiwyg to 12.0 editorGorash
The wysiwyg abstraction layer was introduced in saas-12.2 by commit f2969923. Its goal was to provide an external interface for other modules that wanted to use the editor feature such that the editor core itself could be changed without requiring extensive changes in the other modules. This commit is adapting the wysiwyg interface to instantiate the 12.0 editor below it rather than the saas-12.2 one, thus reverting the "new editor" part of f2969923 itself. Part of PR 35677. Co-authored-by: Nicolas Bayet <nby@odoo.com> Co-authored-by: Antoine Guenet <age@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com>
2019-08-21[REV] wev_editor, website: revert saas-12.2 editorGorash
This commit reverts the saas-12.2 editor by putting back the editor of Odoo 12. The saas-12.2 editor was an intermediate work between the previous editor of Odoo 12 and the new one slated for Odoo 13. It was unstable but it was supposed to be replaced by the new editor of version 13. However, since the new editor has been postponed to Odoo 14, the saas-12.2 one would have been staying in Odoo 13, which would have been a nightmare to maintain. To avoid this outcome, we chose to put back the 12.0 editor in its place. This has the particular advantage that Odoo 13 will share the same bugfixes as Odoo 12 and 11 as they all run under the same core editor, while the saas-12.2 one would have been an entirely different beast to maintain. This is a partial revert of f2969923. Part of PR 35677. Co-authored-by: Nicolas Bayet <nby@odoo.com> Co-authored-by: Antoine Guenet <age@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com>
2019-08-08[FIX] web_editor: correctly convert inline style on loadingChristophe Simonis
Oversight of previous forward-port.
2019-08-08[MERGE] forward port branch saas-12.3 up to 752b2553c6fChristophe Simonis
2019-08-06[FIX] web_editor: remove virtual corrector/completion keyboard glitchGorash
For the ours need, we can not let the contentEditable behavior. Indeed, this one does not have the same behavior according to the browser. The DOM node could be erase, merge, cut, in them according to the keyboard interactions. The problem is that if we have to manage these behaviors, we have to manage everything. It was already the case in the previous version, however before we created an editor by zone and by a hack we mix the history. In the case of the virtual keyboard of some OS / Phone, the events are different and the autocompletion does not update (bug that prevents modification interactions with javascript). In order to solve these problems, we use another event for the insertion of the characters. However, we must also force the update of the corrector by forcing a blur and a focus. The current version is a temporary version. We are currently working on a version that uses a virtual dom and does not need to do excessive prevent default.
2019-08-07[FIX] web_editor: do to try to inline css for readonly html fieldsChristophe Simonis
closes odoo/odoo#35539 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-06-06[MERGE] forward port branch saas-12.3 up to 409679866b2Christophe Simonis
2019-06-03[MERGE] forward port branch saas-12.2 up to 995aa1685eeChristophe Simonis
2019-05-22[FIX] web_editor: render mass_mailing content after saveGorash
For some Chome version (e.g. 74 chrome verion on Debian) the iframe trigger 'load' event twice (one time for document and on time for body), the widget must insert the content in the body. Before this fix, the content are add only one time and are removed by the next iframe loading. closes odoo/odoo#33561 Signed-off-by: Toufik Benjaa (tbe) <tbe@odoo.com>
2019-03-26[MERGE] forward port branch saas-12.1 up to f00c490be86Christophe Simonis
2019-03-05[FIX]web_editor: Fixed traceback due to 'field_html' widget while saving recordmgh-odoo
Previously, when user edited record having 'field_html' widget and tried to save the record immediately, a traceback was faced sometimes because content was not loaded yet. This commit fixes the issue by calling super method if the content is not loaded yet properly. Task: #1932687 Closes: #30833 closes odoo/odoo#31581 Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-03-27[MERGE] forward port branch saas-12.2 up to 7c1a9a8204fChristophe Simonis
2019-03-13[MERGE] forward port branch saas-12.2 up to c9f832d9f03Christophe Simonis
closes odoo/odoo#31790 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-03-06[REF] web_editor: adapt code after jQuery updateVincent Schippefilt
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-02-14[IMP] web_editor: lazy load the wysiwygChristophe Matthieu
Issue: wysiwyg asset slow down the loading of the website, error inadvertently introduced: https://github.com/odoo/odoo/pull/29775 The assets are now loaded assynchroneously, when the editor is needed, its assets will be loaded. closes odoo/odoo#30700
2019-02-25[FIX] mass_mailing: fix send email issue.Siddarth Gajjar
- while clicking on send now button in mass mailing app it throws error due to wysiwyg undefined. closes odoo/odoo#30533
2019-01-17[IMP] web_editor,*: Refactoring the wysiwyg editor and 'html' fieldChristophe Matthieu
* Creating a new structure by transforming all the plugins in the library using the odoo inheritance system. Plugins are easier to implement with the AbstractPlugin to add Odoo behaviors. * From now on, the methods of the library (in this case Summernote) can no longer be called by other modules or files. Only the wysiwyg widgets can access it, to simplify the updating process. The wysiwyg object serves as an interface. * Depending on the options the snippets will be loaded or not, the editor will be in an iframe or not... all of this is transparent from the outside. * Regarding iframes, all controllers related to editing have been removed: the new API no longer needs them. This speeds up loading, eases testing and removes complexity for the same features. PUBLIC FEATURES There are several public methods on the Wysiwyg class: * Wysiwyg.prepare (WidgetParent): returns a deferred resolved when the library (xml, lazy, assets...) is loaded. * Wysiwyg.getRange (DOM): returns the range (selection in the dom) * Wysiwyg.setRange (startNode, startOffset, endNode, endOffset): creates a range (selection in the dom) * Wysiwyg.setRangeFromNode (DOM, options) that creates a range from an element (option available to select all, start or end) A jQuery selector was added: :o_editable, which indicates whether the current element is editable. That is, if it is contained in a tag with the attribute 'contentEditable = "true"' or in a tag with the class o_editable. Several methods are also present: * focusIn: makes a focus and places the cursor at the beginning of the element * focusInEnd: makes a focus and places the cursor at the end of the element * selectContent: makes a focus and selects the content HTML FIELD The HTML field can receive different options: * style-inline: {boolean} transforms a class into an inline style when saving and vice versa when reading. * no-attachment: {boolean} prevents the use of attachments (in media dialog) * cssEdit: {xml_id} to use a template containing the css to loaded in an iframe when editing * cssReadonly: {xml_id} to use a template containing the css to load into an iframe when viewing in readonly * snippets: {xml_id} snippets template (can be used with or without cssEdit) * wrapper: {template} qweb static template (containing a tag: id = "wrapper") that will include the content during editing (removed on save) MASS MAILING A widget was created for mass mailing. There are now two fields: body_html and body_arch. body_arch contains the code with the class without conversion into inline style, useful when editing and one with the inline style that is visible in readonly mode and sent by email. Advantage: no spreading errors, able to update css/theme, able to do more changes when converting to inline style so that a maximum of mail clients have an impeccable rendering. Co-authored-by: Antoine Guenet <age@odoo.com>
2019-01-17[REF] web_editor,*: Move and rename files to prepare refactoringChristophe Matthieu
The refactoring of the wysiwyg editor and 'html' field allows us to move some of the code that was in web_editor but only used in website or in mass_mailing. Some parts are still in web_editor but will be moved at a later time.
2019-04-24[IMP] web, *: add a description to generic widgetsJuhil Somaiya
A `description` key has been added on AbstractField and all generic field widgets ; it is used to display a more user friendly name (both in the webclient and in Studio). Non-generic field widgets have an empty string as description. Related task 1918327 closes odoo/odoo#30131 Signed-off-by: Martin Geubelle (mge) <mge@openerp.com> Co-authored-by: Mohammed Shekha <msh@openerp.com>
2019-04-17[FIX] web_editor: FieldHtml commitChanges called too soonmgh-odoo
The original issue appeared in mass_mailing where triggering the mail template preview throws a client error. This commit prevents commitChanges() from being called before the element is rendered. Task-ID: 1950784
2018-09-05[MERGE] forward port branch 11.0 up to 213759b03e5Christophe Simonis
2018-09-03[FIX] web_editor: focus lost with inline editorNicolas Lempereur
When an inline editor is eg. in a form view, the focus is always stolen by it. This is because we trigger a mouseup on the editor to update its toolbars values and informations. In 10.0 this was not necessary since the default values were sanely set when the editor was inside the DOM. In 11.0 the editor is not in the DOM when this is being done and the info was wrong (eg. NaN for text size). With this commit, we don't steal the focus and get the default like it was done in 10.0 instead. fixes #26366 opw-1874880 closes #26582
2018-07-13[MERGE] forward port branch saas-11.2 up to 87dadc5bc83Christophe Simonis
2018-07-11[FIX] mail: remove attachment feature in add followers modalChristophe Matthieu
Before this fix, the attachments are don't save to the record and are remove with the wizard. We can't add the attachments to mail.message (like 'mail.compose.message') because it's auto_delete/unlink and the attachments are removed before the recipient can read it.
2018-07-11[FIX] web_editor: display record linked to the record when add followersChristophe Matthieu
2018-07-11[FIX] web_editor: send an image thumbnail for attachment link in mailChristophe Matthieu
Before this fix attachmentThumbnailToLinkImg is not called for style-inline options. The mail received does not have thumbnail and the user can't click on the invisible link. opw-1863659
2018-05-09[MERGE] forward port branch saas-11.2 up to aae54ecc159Christophe Simonis
2018-05-08[FIX] web_editor: drag and dropNicolas Martinelli
Commit 6494f511718 introduces an access token to read images inside an email. This avoids access errors when accessing the email through a proxy (e.g. Gmail). That implies that all images are added as attachments. When going through the usual media dialog, the form is submitted to action '/web_editor/attachment/add', creating the attachment. However, the copy or the drag and drop of an image completely fails. Indeed, the same method `_onImageUpload` is called, but with a completely different argument type: `attachments` is a `FileList`, not a list of attachments. To solve this, we only call `_onImageUpload` on a the custom `onUpload` callback, which is not triggered during a drag and drop or a copy. Any image included thanks to these methods will be post-processed in the `create` method of `mail.message` (`base64_to_boundary`). Unfortunately, it's not possible to simulate an actual drag and drop or a copy, so we cannot add a test. opw-1840237 opw-1840411
2018-04-18[MERGE] forward port branch saas-11.2 up to fed775bc0c2Christophe Simonis
2018-04-17[FIX] web_editor,mail: send email's attachments without write accessChristophe Matthieu
Before this fix, when a user don't have write access on a document, he can't send an email with attachment because, the attachments is added on the document. The change improving security was introduced by the commit: https://github.com/odoo/odoo/commit/6494f511718893eec3573c60c0a62e04d386359d With this fix, for mail, the attachments is added on the 'mail.compose.message' and re-render the fields attachments displayed in the current view. This change respect the access rules like all others attachment of 'mail.compose.message' (can send an email when the user have read access on the document). The media dialog of the html widget display all documents attachments and the added attachments Allowing users to use these in the body of their message.
2018-04-10[IMP] web: keyboard navigation in form viewVincent Schippefilt
The goal of this commit is to allow fast entry of the same model using the keyboard for navigating through the form once, by blocking the user from advancing in the form if there is a required field or once they went through the form once to get them to a primary action (button) This commit includes the following changes 1) Enable moving forward from field to field using the TAB key 2) Entering the one to many and many to many using the TAB key a. When entering it, set the focus on the "add new line" link or button b. When adding a new line, set the focus on the field visible editable field of the new line c. Discard adding a new line with ESC key d. If the user leaves the first field empty and uses TAB, we will cancel the adding of a new line and move to the next field of the form 3) When a field is required and not filled in, do not allow the user to move out of the field using the TAB key (the user is still allowed to use the mouse though), mark the field as invalid instead 4) After going though the form once, using the TAB key on the last field will move the focus to the first primary button of the page 5) When the focus is on a primary button (EDIT/SAVE), the user cannot move the focus forward using the TAB key. Hitting TAB again will display a tooltip telling to hit ENTER to activate the button. The mouse is still available to move the focus. 6) When the user saves, the focus is placed on the first primary button of the form renderer (like VALIDATE for a new invoice) 7) On dialogs, primary buttons should stop the users from moving out of them, and showing a popup if the user tries 8) When closing a dialog, the focus will be moved back to the widget that opened it. This commit does not include the following features 1) Navigation with the keyboard on a selection one to man 2) Navigate between tabs in a form using the keyboard 3) Cancelling the adding of a new line in a many to many using the ESC key do not set the focus correctly 4) Enhancing the focusses fields (like blue underline)
2018-02-08[FIX] web_editor: add thumbnail image to send attachmentChristophe Matthieu
2018-02-08[FIX] base/mail: Added an access_token on the attachments urlChristophe Matthieu
The access_token is automatically added by the media editor. It's added on the website and by the html editor to send by email. The widget display the attachments from 'ir.ui.view' (public attachment) and the attachment from the current record. Issue: can't load image in gmail or mobile because the client mail use a proxy who avoid ours odoo access.
2018-02-01[MERGE] forward port branch saas-16 up to 920aa6174c9Christophe Simonis
2018-01-02[MERGE] forward port branch saas-16 up to 0af13af5de4Christophe Simonis