summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/inline.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web_editor/static/src/js/inline.js')
-rw-r--r--addons/web_editor/static/src/js/inline.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/addons/web_editor/static/src/js/inline.js b/addons/web_editor/static/src/js/inline.js
new file mode 100644
index 00000000000..c5fd2cfd924
--- /dev/null
+++ b/addons/web_editor/static/src/js/inline.js
@@ -0,0 +1,77 @@
+odoo.define('web_editor.inline', function (require) {
+'use strict';
+
+var editor = require('web_editor.editor');
+var rte = require('web_editor.rte');
+var widget = require('web_editor.widget');
+var transcoder = require('web_editor.transcoder');
+var snippet_editor = require('web_editor.snippet.editor');
+
+widget.MediaDialog.include({
+ start: function () {
+ this._super();
+ this.$('[href="#editor-media-video"]').addClass('hidden');
+ }
+});
+
+editor.Class.include({
+ start: function () {
+ var self = this;
+ if (location.search.indexOf("enable_editor") !== -1) {
+ this.on('rte:start', this, function () {
+ // move the caret at the end of the text when click after all content
+ $("#wrapwrap").on('click', function (event) {
+ if ($(event.target).is("#wrapwrap") || $(event.target).is("#editable_area:empty")) {
+ setTimeout(function () {
+ var node = $("#editable_area *")
+ .filter(function () { return this.textContent.match(/\S|\u00A0/); })
+ .add($("#editable_area"))
+ .last()[0];
+ $.summernote.core.range.create(node, $.summernote.core.dom.nodeLength(node)).select();
+ },0);
+ }
+ });
+ });
+ }
+ return this._super.apply(this, arguments);
+ },
+});
+
+snippet_editor.Class.include({
+ start: function () {
+ var self = this;
+ this._super();
+ setTimeout(function () {
+ var $editable = $("#editable_area");
+ transcoder.img_to_font($editable);
+ transcoder.style_to_class($editable);
+ });
+ },
+ clean_for_save: function () {
+ this._super();
+ var $editable = $("#editable_area");
+ transcoder.class_to_style($editable);
+ transcoder.font_to_img($editable);
+ },
+
+});
+
+window.top.odoo[callback+"_updown"] = function (value, fields_values) {
+ var $editable = $("#editable_area");
+ value = value || "";
+ if (value.indexOf('on_change_model_and_list') === -1 && value !== $editable.html()) {
+ rte.history.recordUndo($editable, null, true);
+ if (snippet_editor.instance) {
+ snippet_editor.instance.make_active(false);
+ }
+
+ $editable.html(value);
+
+ transcoder.img_to_font($editable);
+ transcoder.style_to_class($editable);
+ } else {
+ $editable.trigger("content_changed");
+ }
+};
+
+}); \ No newline at end of file