summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/editor/summernote.js
AgeCommit message (Collapse)Author
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>
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-09-22[IMP] web_editor, website, *: move text tools in snippets panelqsm-odoo
*: website_event, test_website This commit is a series of hacks. The goal is to move the summernote text tools to the editor panel for the website editor. All the code to use the text tools in a top bar is kept (mass mailing, etc) and the text tools are placed at the right place for website in an ugly way. This is obviously temporary, until we can implement those text tools more generically and in a better way thanks to the new editor. Part of https://github.com/odoo/odoo/pull/57975 task-2344227 closes odoo/odoo#57975 Related: odoo/design-themes#364 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-05-27[FIX] web_editor: fix focus for some tools in SummernoteAnh Thao Pham (pta)
- Go to Project - Open a project to display Tasks - Switch to list view - Click on create button - On task form page, click nowhere. (It is important to not click on anything) - On the taskbar of the WYSIWYG editor used for Description, click on one of the following actions: * Unordered list * Ordered list * Checklist * Table * Style - The action will be applied to the "name" field (Task Title) and an error will prompt for Unordered list, Ordered list and Checklist actions - If not, discard the form and retry by opening the form with create button In this case, the WYSIWYG editor does not have the focus and try to execute the tool action on the current focused element. opw-2256835 closes odoo/odoo#52023 X-original-commit: eaa55ce3e806ad0d9609394309ff9d48b32bb73f Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-05-15[IMP] web, web_editor: integrate colorpicker in colorpalettefja-odoo
Stop using the colorpicker dialog in the colorpalette widget. Integrate the colorpicker widget in the colorpalette widget. Of course, the colorpicker behaviors are adapted so that no useless rerendering of the colorpalette is made on each value change. The 'reset color' button is now a button like the other colors, no need for a 'color_reset' event anymore. It is removed and replaced with a 'color_picked' event with color being an empty string. The clear button now also work on hover. Also, the topbar colorpalette for text and text background colors now has the exact same behaviour as the background colorpalette: adding color preview on hover. The colorpalette now also closes on 'enter' keypress. Part of https://github.com/odoo/odoo/pull/46088 task-2195313 closes odoo/odoo#46088 Related: odoo/enterprise#8696 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-04-28[FIX] web_editor: ol in ol no number skipNicolas Lempereur
In the case of an <ol> in an <ol> we would have something like: ``` 1. 1. 2. 3. ``` because the sublist itself in version of summernote.org we are using is a list item, so it takes one extraenous item. With this changeset we have something that makes more sense: ``` 1. 1. 2. 2. ``` Because there are tons of use case of different selection of list level and indent or outdent, this commit also simplify outdenting (eg. now we outdent all the element of the same level than the first indented). opw-2185406 closes #48194 closes odoo/odoo#50352 X-original-commit: bbf4ad7d84d7fa4651744359658a8fa70cf94b17 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
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[IMP] web_editor, website: generalize colorpickerfja-odoo
Currently we have: - a colorpicker for background color of snippets - a colorpicker for foreground and background text (topbar) - a colorpicker for menu/footer/navbar/etc These 3 are separate colorpickers with different options. After this Commit All 3 will use the same color palette wich allow you to select theme color, common colors, custom color and transparent filter. Part of https://github.com/odoo/odoo/pull/38959 maintask-2066614 task-2087383
2019-10-01[IMP] website_forum, *: revamp designsri-odoo
* web_editor, website_profile Part of https://github.com/odoo/odoo/pull/35749 task-2024197 Co-authored-by: Jérémy Kersten <jke@odoo.com> Co-authored-by: qsm-odoo <qsm@odoo.com> Co-authored-by: fja-odoo <fja@odoo.com>
2019-09-25[FIX] web_editor: change do not bold nobold after boldNicolas Lempereur
If we have a content such as: `aaa <B>bbb</B> ccc` and you eg. change size of `a bbb c`, the c gets bold because of an issue in the merging after style is applied. reason: we check that the style was same as previous nodes, but because walkpoints text[a]->B->text[bbb]->B->text[c] is expurged of duplicates it becomes text[a]->B->text[bbb]->text[c] so we erroneoulsy think that the node before text[c] is text[bbb] (instead of B tag) note: 12.5 forward-port (skipping [12.3,12.4]) of 11.0 #37254 (also contain #37345) opw-2071930 closes #37295 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-09-19[FIX] web_editor: checkbox without text change can now be checkedGorash
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-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-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>
2018-11-16[MERGE] forward port branch saas-11.3 up to bab2a191d29Christophe Simonis
2018-11-15[MERGE] forward port branch 11.0 up to 468dab6748aChristophe Simonis
2018-11-12[FIX] web_editor: can't unquote on firefoxNicolas Lempereur
Firefox when asked to block format (formatting over a block with blockquote, h1, ...) has a special case for blockquote (it is documented in https://developer.mozilla.org/docs/Web/API/Document/execCommand at formatBlock command) and will wrap any element instead of replacing existing block formatting. Thus the code not expecting it was not able to remove a blockquote in firefox once introduced. opw-1903735 closes #28587
2018-11-12[FIX] web_editor: firefox ctrl+a and un/formatNicolas Lempereur
When we for example do ctrl+a in firefox, the selection is over the container and not the content. This is an issue when we apply a format, since the container could be removed. eg: we have selection over `<pre>hello</pre>`, on firefox the selected node is `pre`, on chromium it is `TextNode "hello"`. if we remove the style, `pre` is deleted so firefox selection is broken, whilst chrome has no issue since "hello" still exist. There was also an issue when the selection was over the blockquote, there was no error but the style could not be removed. opw-1903738 opw-1903735 closes #28369
2018-11-09[FIX] web_editor: don't prepend http to ${..} linkNicolas Lempereur
In mail template a link with reference such as: ${object.user_id.signup_url} are often used. These are template directives that are replaced when the mail is saved, so when editing in the editor and they are prefixed by "http://" this breaks the link which is not wanted. Now link beginning with `${` are not prefixed anymore to prevent shooting oneself in the foot. opw-1906695 closes #28522
2018-09-07[MERGE] forward port branch saas-11.4 up to d78f23df848Christophe Simonis
2018-09-05[MERGE] forward port branch 11.0 up to 213759b03e5Christophe Simonis
2018-09-04[MERGE] forward port branch saas-15 up to 653bbbc7330Christophe Simonis
2018-08-13[IMP] website, *: review snippets and colorsCocographique
* web, web_editor, website_hr_recruitment, website_mail_channel, website_mass_mailing - Review all snippets and add new ones - Add lots of new options - Use odoo colors as default theme colors task-38878
2018-08-12[IMP] web_editor: add custom colors for editor colorpickerDipalee Bhalodia
- Custom color can now be applied to elements - Find used custom colors in the page and add them as colorpicker suggestions - Current color is selected in the picker when you open the custom color wizard task-37974 Closes #26274
2018-08-12[IMP] web_editor: improve text colorpickerDipalee Bhalodia
- Split editor button: one for font color and one for background color - Remove recent color button feature - Add only theme colors and remove other color sections like graypalette/standard colors - Button's icon for font color and background color buttons have the same color of currently selected element task-37974 Closes #26274
2018-07-27[REF] *: BS4, adapt dropdowns and caretsqsm-odoo
- The dropdown structure was simplified, allowing to get rid of the 3-levels structure induced by <ul/> elements and dropdowns can now contain anything. The class 'dropdown-item' is now mandatory for each dropdown clickable element. The class 'dropdown-item-text' can be used to add same padding and style but without making the element have a clickable look. - Dividers now use the class 'dropdown-divider' - The way dropdowns are opened and hidden also changed (before the 'open' class was added on the `.dropdown-menu` parent, now the 'show' class is added on both the `.dropdown-menu` parent and the `.dropdown-menu` itself). - JS-wise, no click event handlers can be put on `.dropdown-toggle` elements anymore (instead, use handlers for dropdown events). - Carets are automatically put on `.dropdown-toggle` elements, so this commit replaces the `.caret` elements with this. This feature was possible to disable but would prevent us from adding a caret with scss. Also, this simplifies the DOM. The 'o-no-caret' class was also introduced to allow using the 'dropdown-toggle' class on non-caret elements. - Also adapt the scss to use $caret-width instead of $caret-width-base
2018-06-06[MERGE] forward port branch saas-11.2 up to c834c0f5879Christophe Simonis
2018-06-06[FIX] mail, web_editor: allow tel links in email templates (#24926)Tomas Alvarez
Before this commit: links like `tel:+1-555-555-5555` were being replaced both in javascript (prefixing `http`, when using the summernote editor) and python (prefixing the base url, when they were added directly to the template). After this commit: the replacement is avoided on links with `tel` scheme. This is related to commit: 8b97a39
2018-05-14[MERGE] forward port branch saas-15 up to d818b516c14Christophe Simonis
2018-04-16[MERGE] forward port branch saas-11.2 up to 90f8f17fb4fChristophe Simonis
2018-04-16[MERGE] forward port branch saas-15 up to bfa5af45df0Christophe Simonis
2018-04-10[FIX] web_editor: fix crash when hitting SHIFT+TAB on an empty editorVincent Schippefilt
repro : open any editor (like tasks), empty its content and hit SHIFT+TAB before this fix: you get a traceback after this fix: you don't get a traceback
2018-03-09[MERGE] forward port branch saas-11.2 up to 42659dc70c2Christophe Simonis
2018-02-28[FIX] web_editor: avoid unnecessary slowdown of the web clientChristophe Matthieu
create range method slow down all the web client because the handler who use this method it's in the module (not in the widget method) and called for each click and keyup. We need only this handler for the iframe or the website, used by the rte.
2018-02-26[FIX] web_editor: stop crashing on applying fonts with standalone summernoteqsm-odoo
Commit https://github.com/odoo/odoo/commit/137c4f5d76b55c3dd3c4f593de484aadfcf5e6da?w=1#diff-6a334b274d95fb88a4fbc29b910fbb59R2120 introduced a bug as it is using a function which is defined in another asset. This is fine for connected users but not for summernote-only users like public users on the forum. The reason the line was introduced is unsure so it is simply removed for now. The bug it was supposed to fix will be fixed later if it ever needs to be.
2018-02-09[MERGE] forward port branch saas-16 up to e2ae51c4b08Christophe Simonis
2018-02-01[MERGE] forward port branch saas-16 up to 920aa6174c9Christophe Simonis
2018-01-29[MERGE] forward port branch saas-16 up to 0b188b58046Christophe Simonis
2018-01-22[MERGE] forward port branch saas-16 up to dfe7f00e781Christophe Simonis
2018-01-02[FIX] web_editor: define variable before useChristophe Simonis
Oversight of previous forward-port
2018-01-02[MERGE] forward port branch saas-16 up to 0af13af5de4Christophe Simonis
2017-10-25[MERGE] forward port branch saas-16 up to 7bfde6e05d1Christophe Simonis
2017-10-10[FIX] web_editor, portal: some edition fixesDeep Patel
- Hide navbar divider in mobile view - Change font to default when applying header style - Remove form tag from media dialog search input to avoid redirection
2017-09-12[MERGE] forward port branch saas-17 up to d08b4407be3Christophe Simonis
2017-08-28[FIX] web_editor: properly not allow edition of non editable partsqsm-odoo
Before this commit, (double) clicking an image/link in a non editable environment still opened a dialog / change the editor bar for edition.
2017-08-16[REF] web_editor, website, *: complete refactoringqsm-odoo
* mass_mailing, payment, point_of_sale, portal, survey, web, web_tour, website_blog, website_crm_partner_assign, website_event, website_event_questions, website_form, website_forum, website_gengo, website_hr_recruitment, website_links, website_mail, website_mail_channel, website_mass_mailing, website_quote, website_sale, website_sale_options, website_slides, website_twitter This commit reviews the whole "JS side" of the web_editor and website apps. This is a first step to be able to improve them with new and better functionnalities; this commit is not supposed to change any visual behavior. The main goal was to achieve a structure similar to the backend one. Now, the frontend side also has a root widget (like the WebClient) and all other widgets are attached to it one way or another. This allows the benefits of using the 'trigger_up' functionnality for example. As RPC are now mainly done with the `this._rpc` functionnality (being possible thanks to the parent hierarchy), the frontend will also be possible to test thanks to QUnit in a future update (besides the "text" editor side which still requires a refactoring to be able to do that). --- Here are some of the changes: (-) conventions and documentation The code has been updated to follow JS conventions and a lot of code has been commented (around +2000 lines of comment). This also means that lots of functions have been renamed to use camelCase or simply to make their name understandable. See https://github.com/odoo/odoo/wiki/Javascript-coding-guidelines. (-) deprecated: web_editor.base The "web_editor.base" module has been split and does not force the modules which require it to wait for DOM ready anymore. This was indeed slowing loading times, but also prevented to use some modules in some contexts (see the LESS editor use in web_studio which is the subject of another task). Now the "editor context" can be got thanks to the "web_editor.context" JS module with its "get" function. The "web_editor.base" module should probably not be used anymore (see its code and recent updates). (-) new: web.dom_ready If a JS module should wait for the DOM to be ready to be executed, a new JS module has been created: "web.dom_ready". This should always be used in a module which only want to instantiate stuff. Do not extend (or worst, include) classes after DOM ready. (-) website.website The "website.website" module has been split. "website.website" does not return anything useful anymore, it just initialize some miscellaneous stuff, without waiting for the DOM to be ready. You might want to check "website.utils", "website.content.compatibility" or `WebsiteRoot`. Also `website.form` has been deleted (use `this._rpc`), so has been `website.error`. `website.prompt` will be removed in a future update to be replaced by `Dialog.prompt`. (-) widgets are great Many classes which were not widgets are now widgets. This allows them to use the 'events', the 'xmlDependencies' and the 'this._rpc' features for example. Here are some of the main ones: - Snippet options: these were classes with a `$el` for the menu element and `$target` for the customized element. This is still the case but following standard `Widget` structure (one exception: using `this.$(...)` searches in the `$target` as before this update). - Snippet animations: instead of class instances with a `$target` element which can be `start` and `stop`, these are now standard widgets which can be `start` and `destroy`. `this.$target` is an alias to `this.$el` for ease of compatibility. - Snippet editors: instead of class instances in charge of an editor overlay, these are now widgets. Each "child" snippet editor is properly attached as a "child", which allows editors to communicate and to be properly destroyed. (-) root widgets and website navbar The frontend is different of the backend. In the backend, the page has an empty <body/> element and all the components are instantiated from parent to children (i.e. the `WebClient` is instantiated and is in charge of instantiating the `ControlPanel`, etc). The frontend cannot work like that on page loadings as they are way more frequent than in the backend and we do not want them to flicker. A frontend page is loaded as a <body/> element which already contains the website navbar and its menus and the whole content page. JS code has to be "attached" to these existing elements. This is possible thanks to the `RootWidget` instances and the specialized `WebsiteRoot`, `IframeRoot` and `WebsiteNavbar` (see code for details). (-) lazy loading No more (or at least a lot less) XML/JS has to be loaded on page loading, thanks to the use of the `Widget.xmlDependencies` feature. XML which have to be lazy loaded is loaded only on related Widget instantiation if necessary, which allows to execute a lot of JS code before the DOM is ready and to start many widgets on DOM ready (not later). A visual benefit of this is clicking on the 'edit' button as soon as it is possible: before this commit, this was sometimes not doing anything as event handlers were not binded yet. Still a possible exception: loading the session and locales. This may be asynchronous stuff which is still required before widget instantiations but this will be the subject of another task. (-) deprecated code and code location More than reviewing code and organizing it, many apparent dead code was removed. More importantly, mislocated code was put in the right app. This is the case for snippet animations which is a concept for website apps but was defined in the web_editor app, or some translation concepts which were part of website but should have been part of web_editor. --- There are probably more things to say about this commit but I will let the comments speak for those.
2017-08-16[MOV] web_editor, website: reorganize filesqsm-odoo