summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/summernote.js
AgeCommit message (Collapse)Author
2018-09-04[MERGE] forward port branch 9.0 up to 61b771256caChristophe Simonis
2018-09-03[FIX] web_editor: normal up/down in content in cellNicolas Lempereur
In the editor in a table cell, when we press UP/DOWN keys: - we have default editor/browser behavior if there is content before (UP) or after (DOWN) the element we are currently on - else we go to the previous (UP) or next (DOWN) row if available - else we go to the next content if available - else we have the default editor/browser behavior But when checking if there is an element before/after the content, we did not take into account if there was an ancestor node inside the cell that had content after, so for example with this structure: ``` <table> <tr><td> <p>hello <b>world</b></p> <p>cruel</p> </td></tr> <tr><td> <p>bingo</p> </td></tr> </table> ``` if the current range was on 'world' text node, we would just check if there is content after this text node, not if there is content after its `<p/>` ancestor. Before the fix we would get on the next row, after we would have default editor/browser behavior: ie. if cruel is on another line, going to this line. opw-1870119 closes #26701
2018-05-14[FIX] web_editor: ignore range error on RestrictedNicolas Lempereur
In firefox, if we have a range on eg.: `<input type="file">` and we tabulate to get to it, we have the range over: `<button type="button" tabindex="0">Browse…</button>` which seems to be a "virtual" element inside the `<input/>` but this magic element is "Restricted" and causes error such as: `Permission denied to access property "nodeName"` So this fix ignore errors when getting a range from current selection on keyup. opw-1819279 closes #24524
2018-04-12[FIX] web_editor: indent just a line inside tableNicolas Lempereur
Inside the cell of a table, indenting had several behaviors: - if the selection is contained in several nodes elements: indent the element child nodes of common ancestor - if the selection is contained in one or more list items: indent these list items - if the selection is contained in one 'content block': indent the whole cell content The two first behaviors are expected, but the third one is a little odd and unexpected next to other existing editors behaviors. With this commit, the third behavior becomes: - if the selection is contained in one `content block`: indent this content block note: 'content block' is defined as p, pre, h1, h2, ..., blockquote, td opw-1824647 closes #24182
2018-02-08[MERGE] forward port branch 9.0 up to ce51ad7e69dChristophe Simonis
2018-02-08[FIX] web_editor: allow deleting all images in table cellsqsm-odoo
Before this commit, it was impossible to delete an image which was a direct child of a table cell using the trash-icon button in the toolbar. This commit fixes the behavior by changing the logic quite a lot, so it is kinda tricky (see https://github.com/odoo/odoo/commit/25849e918651eba080dac3af4e4fcdc8f1280241 for more explaination). Closes https://github.com/odoo/odoo/issues/22523
2018-02-08[FIX] web_editor: fix image deletion and replacementqsm-odoo
Deleting/replacing an image through summernote gave unexpected results. As modifiying the related function may be tricky, this commit instead wrap them to solve the specific erratic behavior: if the range is in/ matches an image, then simply remove the image and move the cursor to its previous location.
2018-02-01[MERGE] forward port branch 9.0 up to cbaecc5cbb8Christophe Simonis
2018-01-26[FIX] web_editor: properly show link alignment in toolbarqsm-odoo
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-25[MERGE] forward port branch 9.0 up to 222cadda415Christophe Simonis
2018-01-25[FIX] web_editor: properly allow formatting text (normal/header 1/...)qsm-odoo
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-22[MERGE] forward port branch 9.0 up to 216edc206c7Christophe Simonis
2018-01-19[FIX] web_editor: properly evaluate if a range is an imageqsm-odoo
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-18[FIX] web_editor: `deleteContents` when no selectionqsm-odoo
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.
2017-12-18[FIX] web_editor: revert copy/paste feature of the editorqsm-odoo
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-15[MERGE] forward port branch 9.0 up to 9bba7fea42be534fd100d809dfd1dc632ee9ace4qdp-odoo
2017-12-15[FIX] web_editor: browser-unify alignment editor optionqsm-odoo
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-10-24[MERGE] forward port branch 9.0 up to 7bd8f9a5b2cChristophe Simonis
2017-10-24[FIX] web_editor: replacing selected text in a hierarchy on Firefoxqsm-odoo
When following these steps on Firefox: - Select all text in a bold link (triple click) - Type some text The typed text did not replace the selected text but was instead put at the front of it.
2017-09-07[FIX] web_editor: enter remove or duplicate nodeNicolas Lempereur
There is some odd behavior especially inside a editable containing newlines. For example in the sale description on an ecommerce item, lines could contain newline (it is editable from backend) but as an effect of other use case, pressing enter could have a range of unwanted side effects: - removing all the content, - duplicating the editable (should never happen, if we have one field "description_sale" we don't want to duplicate it, this has no sense) In a product name which is in the same use case, there is no newline so the problem is not apparent, and ENTER do nothing. This is the behavior we should want in every instance. If we still want a newline, we have to force it with SHIFT + ENTER key, also this is regarding field that may or could be present in the backend views, so it could also be edited in backend. This change make ENTER ignored when we are editing a node directly child of an node being edited. A second part of the issue was that dom.removeBetween (used to remove content inside a range) could remove the ancestor node that was an editable. This is not wanted. For example if we did CTRL + A inside a field with `<br />` then ENTER or pasting something, the field would be removed and not just emptied and could not be gotten back without editing the template manually. This was sometimes mitigated because if a `<br />` was at the end of an element, it would stay in this use case avoiding the issue. note: not necessary after saas-16 fixes #17445 opw-751360 closes #19313
2017-03-17[FIX] web_editor: copy/paste in the editorqsm-odoo
Commit 906875fc78cb80f6c3d5f1f14f997008cd406473 (followed by commit 76be5eed449c78eaf0b4208c381169132492ab4a) tried to tweak to copy/paste functionality of the editor. Indeed, in PDF file, when copying a paragraph, a line feed is added at each forced line break (page width end). This forced a line feed and a new paragraph in the pasted text. The goal was to get rid of those useless linebreaks when pasting. The ideal solution would be to detect that the text was copied from a PDF but it is not possible. However, this commit improves the heuristic: if this is not plain text, then nothing is done, the content is pasted normally. If it is plain text (like when copying from pdf), then each line break which is surrounded by letters or numbers is considered an useless line break and replaced by a space. This is obviously not perfect but the previous implementation was really wrong (it was removing line breaks which were not preceeded by punctuation in all cases, which was removing lots of useful line breaks). Note: this commit also fixes a bug -> text was not able to be pasted with Internet Explorer. opw-715920
2017-01-17[MERGE] forward port branch saas-11 up to a0aca47feffChristophe Simonis
2017-01-17[MERGE] forward port branch 9.0 up to 16fa61b34f9Christophe Simonis
2017-01-11[FIX] web_editor: italic odd behavior because typoNicolas Lempereur
An italic node would be taken as a basic node containing text and thus would be merged unexpectedly. For example with the following content : "<i>hello</i> world" removing a letter of 'world' would merge the text node with hello making it italic. opw-703722
2016-11-15[MERGE] forward port branch saas-12 up to ca20038Christophe Simonis
2016-11-15[MERGE] forward port branch saas-11 up to 58f68ccChristophe Simonis
2016-11-14[MERGE] forward port branch 9.0 up to fb763f3Christophe Simonis
2016-11-08[FIX] web_editor: split h5,h3,...p... node to insert tableChristophe Matthieu
opw-686393
2016-11-02[MERGE] forward port branch saas-12 up to 0ca99ffChristophe Simonis
2016-10-31[FIX] web_editor: don't paste two timesNicolas Lempereur
When pasting, the paste event is cancelled and done back with the corrected data. This works fine on firefox, but this can have unwanted results on other browser like pasting two times or copying the end of the line at the beginning. This commit replace completely the summernote functionality with our small implementation of pasting corrected text. closes #14043 opw-690814
2016-10-10[FIX] web_editor: change attachment/image icon in editor barqsm-odoo
The image icon was not clear enough. The editor bar appears in the website builder, the mail composer, the forum composer, ... In each of them, we can both link a picture or a file but a picture makes more sense in some context and in some other ones not. This commit solves the problem by changing the icon to fa-file-image-o which is a mixed of file and image. This also solves the problem of having two buttons with the image icon in the website builder (indeed an image icon is also used for the image look button).
2016-09-02[FIX] web_editor: remove some defaults in text editionqsm-odoo
* On firefox, you had to click twice on a link to be able to start typing text * When selecting text which contained a <br/>, you were not able to replacing it correctly (you had to click again before starting typing) * When replacing a whole paragraph content which was below a title, the text was not replaced and you had to click again and the title transformed into a paragraph. * ...
2016-08-19[IMP] web_editor: put the "Quote" style after "Header" stylesqsm-odoo
2016-07-04[IMP] web_editor: user text copy/pasteqsm-odoo
Users copy/past text from various king of document into the editor. These texts contain useless line breaks that should be removed before pasting. Also, the editor currently add a paragraph element between each line. To correct this behaviour the onPaste callback of the summernote lib is used. However for some reason, this is triggered after the text is pasted (we should update and refactor the lib in a better way). So this commit uses a hack: undo the past thanks to the undo command then paste the formatted text we want.
2016-03-24[MERGE] forward port of branch saas-9 up to 59d3f63Christophe Simonis
2016-03-09[FIX] web_editor: leave block after two enterNicolas Lempereur
Before 3959afc the `node` tested would be the selection containing node, but since then it may have been a `<br/>` which has some damaging effects: now entering double enter at the end of a list, quote or code block doesn't end this block. Testing the use case corrected by 3959afc, the said change seems to have no effect so this commit reverts it. opw-667618
2016-02-24[REF] web_editor,website,mass_mailing: JS/XML updateqsm-odoo
* Adapt DOM selectors * Refactore dialog XMLs to have odoo styling * New editor options (background-position, ...) * Various improvements
2016-02-24[REF] website,web_editor: complete restylingstefanorigano
2016-01-28[FIX] web_editor: enter keydown create new td only if the caret is on the ↵Christophe Matthieu
last char of the last line of the td
2016-01-20[FIX] web_editor: can indent table cell (with button and tab)Christophe Matthieu
issue: the user select some line and keypress tab without indent, and the button indent doesn't work in table cell
2016-01-11[FIX] web_editor: error when long delete keypress in mass_mailing htmlChristophe Matthieu
issue: event does not a global var in firefox, and event is already prevented
2016-01-11[FIX] web_editor: clean pasted dom and avoid crappy domChristophe Matthieu
Chrome on windows add few comment tags and insert unwanted span.
2015-12-10[FIX] web_editor: enter in a p tag empty (when user change with code view) ↵Christophe Matthieu
can be raise an exception
2015-12-10[FIX] web_editor: error when paste without any content in clipboardChristophe Matthieu
2015-12-10[FIX] web_editor: remove exceed span on paste html contentChristophe Matthieu
2015-11-30[FIX] web_editor: fallback to plain text when pastingNicolas Lempereur
Depending of the location where the "Copying" happened, only text/plain content could be available from the clipboard component. So if no text/html was retrieved, we should fall back to plain text pasting. closes #9787 opw-657137
2015-11-16[FIX] web_editor: don't think HTML comment are visibleNicolas Lempereur
Summernote sometimes doesn't take into account HTML comment could be embedded in the edited content, this can lead to issue since this situation can happen in Odoo. This commit patch the "isVisiblePoint" summernote's function to take care of this issue. opw-656332
2015-10-29[FIX] web_editor: don't remove char after a selection when click on deleteChristophe Matthieu
Issue: click on an image or create a text selection and click on delete, the char after the selection is removed
2015-10-29[FIX] web_editor: remove useless duplicated codeChristophe Matthieu
2015-10-26[FIX] web_editor: visible char have the same feature that delete keydownChristophe Matthieu