diff options
| author | Nicolas Lempereur <nle@odoo.com> | 2015-10-06 16:40:58 +0200 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2015-10-09 08:43:49 +0200 |
| commit | 8acd1c40fe8cbbef760c0ad4321f0977d17ebe66 (patch) | |
| tree | e69ddff2d76b28a772283376557444aad7fbe5ab /addons/web_editor/static/src/js/summernote.js | |
| parent | 8c3b4b80c6393a9f5ea7f05fd697f33333e24094 (diff) | |
[FIX] web_editor: alt+tab in table and tab on collapse
When using the tab key on non text node range, it could fail in some
given case.
Also when removing the last element of the table row, a correction was done in
d33086c03fc but if there was no element before the table (eg. the editor
is empty) an error could occur.
Diffstat (limited to 'addons/web_editor/static/src/js/summernote.js')
| -rw-r--r-- | addons/web_editor/static/src/js/summernote.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index 19f559070d7..354deb19902 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -1039,7 +1039,12 @@ $.summernote.pluginEvents.tab = function (event, editor, layoutInfo, outdent) { } } else { if (!outdent){ - var next = r.sc.splitText(r.so); + if(dom.isText(r.sc)) { + var next = r.sc.splitText(r.so); + } else { + var next = document.createTextNode('') + $(r.sc.childNodes[r.so]).before(next); + } editor.typing.insertTab($editable, r, options.tabsize); r = range.create(next, 0, next, 0); r = dom.merge(r.sc.parentNode, r.sc, r.so, r.ec, r.eo, null, true); @@ -1434,7 +1439,7 @@ $.summernote.pluginEvents.backspace = function (event, editor, layoutInfo) { if (prevTr) { node = (dom.lastElementChild(prevTr).lastChild && dom.lastElementChild(prevTr).lastChild.tagName ? dom.lastElementChild(prevTr).lastChild.previousSibling : dom.lastElementChild(prevTr).lastChild) || dom.lastElementChild(prevTr); } else { - node = dom.lastChild(dom.hasContentBefore(dom.ancestorHavePreviousSibling(tr))); + node = dom.lastChild(dom.hasContentBefore(dom.ancestorHavePreviousSibling(tr)) || $editable.get(0)); } $(tr).empty(); if(!$(tr).closest('table').has('td, th').length) { |
