diff options
| author | Nicolas Lempereur <nle@odoo.com> | 2018-06-11 15:26:16 +0200 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2018-06-13 16:20:40 +0200 |
| commit | c4ddf55880b7aa83580aa8ab312ba71f093a7587 (patch) | |
| tree | fd7693d86ed121d817a86fe953789c53d09c17ad /addons/web_editor/static/lib | |
| parent | a8dd1de5c466b64351d54536ac0529d2a744cf4d (diff) | |
[FIX] web_editor: link don't duplicate child text
If we applied a link eg. on:
```
<span>hello <b>world</b></span>
```
The system actually gets the "label": hello worldworld because there is
3 nodes:
text node: hello
element node: `<b>world</b>`
text node: world
Also since "hello worldworld" is different than "hello world",
instead of just keeping existing nodes and adding the link, the system
would replace the selected range by:
`<span><a>hello worldworld</a></span>'
instead of:
`<span><a>hello </a><b><a>world</a></b></span>`
This commit ignores element nodes when creating a new link, since when
getting the label of the link from the selection, only the text nodes
insides the element nodes have any interest.
There was a second issue because if we had:
```
<i><a href="hello">world</a></i>!
```
and tried to put a link over "world!", the code would decide: "world" is
inside a link so we will just update that link.
Thus we would get:
```
<i><a href="hello">world!</a></i>!
```
instead of:
```
<i><a href="hello">world</a></i><a href="hello">!</a>
```
opw-1848351
closes #25187
Diffstat (limited to 'addons/web_editor/static/lib')
| -rw-r--r-- | addons/web_editor/static/lib/summernote/src/js/module/Editor.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/web_editor/static/lib/summernote/src/js/module/Editor.js b/addons/web_editor/static/lib/summernote/src/js/module/Editor.js index a30ee9c18c8..3ae8f60db7d 100644 --- a/addons/web_editor/static/lib/summernote/src/js/module/Editor.js +++ b/addons/web_editor/static/lib/summernote/src/js/module/Editor.js @@ -629,9 +629,9 @@ define([ } var anchors = []; - // ODOO: adding this branch to modify existing anchor + // ODOO: adding this branch to modify existing anchor if it fully contains the range var ancestor_anchor = dom.ancestor(rng.sc, dom.isAnchor); - if(ancestor_anchor) { + if(ancestor_anchor && ancestor_anchor === dom.ancestor(rng.ec, dom.isAnchor)) { anchors.push($(ancestor_anchor).html(linkText).get(0)); } else if (isTextChanged) { // Create a new link when text changed. |
