diff options
| author | Christophe Simonis <chs@odoo.com> | 2016-11-17 15:27:29 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2016-11-17 15:27:29 +0100 |
| commit | e2fcace05e244bbf65da75680fe62c96eeb58455 (patch) | |
| tree | 738a2b396b4326ff92b2012dd4bc87c97b9ffb68 /addons/web_editor/static/src | |
| parent | 41cebc4637b7aa15fcf25229746bb252f9745d4e (diff) | |
| parent | 13dc7041a6b47bbcc703b855044f41321145c7ab (diff) | |
[MERGE] forward port branch 10.0 up to 13dc704
Diffstat (limited to 'addons/web_editor/static/src')
| -rw-r--r-- | addons/web_editor/static/src/js/backend.js | 10 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/rte.summernote.js | 2 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/summernote.js | 17 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/widgets.js | 6 |
4 files changed, 27 insertions, 8 deletions
diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js index 8d05a92260c..90fb0f656e3 100644 --- a/addons/web_editor/static/src/js/backend.js +++ b/addons/web_editor/static/src/js/backend.js @@ -161,6 +161,11 @@ var FieldTextHtmlSimple = widget.extend({ return !this.get('value') || this.get('value') === "<p><br/></p>" || !this.get('value').match(/\S/); }, commit_value: function () { + // leave code view before saving + if (this.$content.prev('textarea').length === 1) { + var layoutInfo = { 'editor': function() { return this.$content; }.bind(this) }; + $.summernote.pluginEvents.codeview(undefined, undefined, layoutInfo); + } if (this.options['style-inline']) { transcoder.class_to_style(this.$content); transcoder.font_to_img(this.$content); @@ -377,6 +382,11 @@ var FieldTextHtml = widget.extend({ this._dirty_flag = false; return this.editor.save(); } else if (this._dirty_flag && this.editor && this.editor.buildingBlock) { + // leave code view before saving + if (this.$content.prev('textarea').length === 1) { + var layoutInfo = { 'editor': function() { return this.$content; }.bind(this) }; + $.summernote.pluginEvents.codeview(undefined, undefined, layoutInfo); + } this.editor.buildingBlock.clean_for_save(); this.internal_set_value( this.$content.html() ); } diff --git a/addons/web_editor/static/src/js/rte.summernote.js b/addons/web_editor/static/src/js/rte.summernote.js index 1789ed69e7e..1eb8054cdc6 100644 --- a/addons/web_editor/static/src/js/rte.summernote.js +++ b/addons/web_editor/static/src/js/rte.summernote.js @@ -511,6 +511,8 @@ function prettify_html(html) { } return result; } + +// Change Warning: called with dummy arguments to quit code view before saving $.summernote.pluginEvents.codeview = function (event, editor, layoutInfo) { if (layoutInfo.toolbar) { return eventHandler.modules.codeview.toggle(layoutInfo); diff --git a/addons/web_editor/static/src/js/summernote.js b/addons/web_editor/static/src/js/summernote.js index 28bfe83a345..5c344fbbcd1 100644 --- a/addons/web_editor/static/src/js/summernote.js +++ b/addons/web_editor/static/src/js/summernote.js @@ -938,12 +938,19 @@ $.summernote.pluginEvents.insertTable = function (event, editor, layoutInfo, sDi var dimension = sDim.split('x'); var r = range.create(); if (!r) return; - r = r.deleteContents(); + r = r.deleteContents(true); - var isBodyContainer = dom.isBodyContainer; - dom.isBodyContainer = dom.isNotBreakable; - r.insertNode(editor.table.createTable(dimension[0], dimension[1])); - dom.isBodyContainer = isBodyContainer; + var table = editor.table.createTable(dimension[0], dimension[1]); + var parent = r.sc; + while (dom.isText(parent.parentNode) || dom.isRemovableEmptyNode(parent.parentNode)) { + parent = parent.parentNode; + } + var node = dom.splitTree(parent, {'node': r.sc, 'offset': r.so}) || r.sc; + node.parentNode.insertBefore(table, node); + + if ($(node).text() === '' || node.textContent === '\u00A0') { + node.parentNode.removeChild(node); + } editor.afterCommand($editable); event.preventDefault(); diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js index 61ec1564ac5..d3ad1e6fbc8 100644 --- a/addons/web_editor/static/src/js/widgets.js +++ b/addons/web_editor/static/src/js/widgets.js @@ -812,7 +812,7 @@ function createVideoNode(url, options) { class: 'vine-embed' }); } else if (vimMatch && vimMatch[3].length) { - $video = $('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>', { + $video = $('<iframe>', { src: '//player.vimeo.com/video/' + vimMatch[3], width: '640', height: '360' @@ -824,14 +824,14 @@ function createVideoNode(url, options) { height: '360' }); } else if (youkuMatch && youkuMatch[1].length) { - $video = $('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>', { + $video = $('<iframe>', { height: '498', width: '510', src: '//player.youku.com/embed/' + youkuMatch[1] }); } else { // this is not a known video link. Now what, Cat? Now what? - $video = $('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>', { + $video = $('<iframe>', { width: '640', height: '360', src: url |
