mirror of https://github.com/OCA/web.git
[IMP] web_ckeditor4: pre-commit execution
parent
19289c7577
commit
6f0b6b3969
|
@ -0,0 +1 @@
|
|||
__import__('pkg_resources').declare_namespace(__name__)
|
|
@ -0,0 +1 @@
|
|||
__import__('pkg_resources').declare_namespace(__name__)
|
|
@ -0,0 +1 @@
|
|||
../../../../web_ckeditor4
|
|
@ -0,0 +1,6 @@
|
|||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
|
@ -1,4 +1,3 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
|
|
|
@ -1,93 +1,91 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 Therp BV <https://therp.nl>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
'name': 'CKEditor 4.x widget',
|
||||
'version': '10.0.1.0.0',
|
||||
'author': "Therp BV,Odoo Community Association (OCA)",
|
||||
'website': 'https://github.com/OCA/web',
|
||||
'summary': 'Provides a widget for editing HTML fields using CKEditor 4.x',
|
||||
"name": "CKEditor 4.x widget",
|
||||
"version": "10.0.1.0.0",
|
||||
"author": "Therp BV,Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/web",
|
||||
"summary": "Provides a widget for editing HTML fields using CKEditor 4.x",
|
||||
"category": "Tools",
|
||||
'license': 'AGPL-3',
|
||||
"license": "AGPL-3",
|
||||
"depends": [
|
||||
'web',
|
||||
"web",
|
||||
],
|
||||
'data': [
|
||||
'templates/assets.xml',
|
||||
"data": [
|
||||
"templates/assets.xml",
|
||||
],
|
||||
'css': [
|
||||
'static/src/css/web_ckeditor4.css',
|
||||
],
|
||||
'data': [
|
||||
],
|
||||
'js': [
|
||||
'static/src/js/ckeditor_basepath.js',
|
||||
'static/lib/ckeditor/ckeditor.js',
|
||||
'static/lib/ckeditor/config.js',
|
||||
#to debug ckeditor, comment the lines above,
|
||||
#do a
|
||||
#cd static/lib
|
||||
#git clone https://github.com/ckeditor/ckeditor-dev.git trunk
|
||||
#cd trunk
|
||||
#git checkout remotes/origin/release/4.1.x
|
||||
#and uncomment the lines below
|
||||
# 'static/lib/trunk/ckeditor.js',
|
||||
# 'static/lib/trunk/core/event.js',
|
||||
# 'static/lib/trunk/core/editor_basic.js',
|
||||
# 'static/lib/trunk/core/env.js',
|
||||
# 'static/lib/trunk/core/ckeditor_basic.js',
|
||||
# 'static/lib/trunk/core/dom.js',
|
||||
# 'static/lib/trunk/core/tools.js',
|
||||
# 'static/lib/trunk/core/dtd.js',
|
||||
# 'static/lib/trunk/core/dom/event.js',
|
||||
# 'static/lib/trunk/core/dom/domobject.js',
|
||||
# 'static/lib/trunk/core/dom/node.js',
|
||||
# 'static/lib/trunk/core/dom/window.js',
|
||||
# 'static/lib/trunk/core/dom/document.js',
|
||||
# 'static/lib/trunk/core/dom/nodelist.js',
|
||||
# 'static/lib/trunk/core/dom/element.js',
|
||||
# 'static/lib/trunk/core/dom/documentfragment.js',
|
||||
# 'static/lib/trunk/core/dom/walker.js',
|
||||
# 'static/lib/trunk/core/dom/range.js',
|
||||
# 'static/lib/trunk/core/dom/iterator.js',
|
||||
# 'static/lib/trunk/core/command.js',
|
||||
# 'static/lib/trunk/core/ckeditor_base.js',
|
||||
# 'static/lib/trunk/core/config.js',
|
||||
# 'static/lib/trunk/core/filter.js',
|
||||
# 'static/lib/trunk/core/focusmanager.js',
|
||||
# 'static/lib/trunk/core/keystrokehandler.js',
|
||||
# 'static/lib/trunk/core/lang.js',
|
||||
# 'static/lib/trunk/core/scriptloader.js',
|
||||
# 'static/lib/trunk/core/resourcemanager.js',
|
||||
# 'static/lib/trunk/core/plugins.js',
|
||||
# 'static/lib/trunk/core/ui.js',
|
||||
# 'static/lib/trunk/core/editor.js',
|
||||
# 'static/lib/trunk/core/htmlparser.js',
|
||||
# 'static/lib/trunk/core/htmlparser/basicwriter.js',
|
||||
# 'static/lib/trunk/core/htmlparser/node.js',
|
||||
# 'static/lib/trunk/core/htmlparser/comment.js',
|
||||
# 'static/lib/trunk/core/htmlparser/text.js',
|
||||
# 'static/lib/trunk/core/htmlparser/cdata.js',
|
||||
# 'static/lib/trunk/core/htmlparser/fragment.js',
|
||||
# 'static/lib/trunk/core/htmlparser/filter.js',
|
||||
# 'static/lib/trunk/core/htmldataprocessor.js',
|
||||
# 'static/lib/trunk/core/htmlparser/element.js',
|
||||
# 'static/lib/trunk/core/template.js',
|
||||
# 'static/lib/trunk/core/ckeditor.js',
|
||||
# 'static/lib/trunk/core/creators/inline.js',
|
||||
# 'static/lib/trunk/core/creators/themedui.js',
|
||||
# 'static/lib/trunk/core/editable.js',
|
||||
# 'static/lib/trunk/core/selection.js',
|
||||
# 'static/lib/trunk/core/style.js',
|
||||
# 'static/lib/trunk/core/dom/comment.js',
|
||||
# 'static/lib/trunk/core/dom/elementpath.js',
|
||||
# 'static/lib/trunk/core/dom/text.js',
|
||||
# 'static/lib/trunk/core/dom/rangelist.js',
|
||||
# 'static/lib/trunk/core/skin.js',
|
||||
# 'static/lib/trunk/core/_bootstrap.js',
|
||||
#end of ckeditor debug
|
||||
'static/src/js/web_ckeditor4.js',
|
||||
"css": [
|
||||
"static/src/css/web_ckeditor4.css",
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
"data": [],
|
||||
"js": [
|
||||
"static/src/js/ckeditor_basepath.js",
|
||||
"static/lib/ckeditor/ckeditor.js",
|
||||
"static/lib/ckeditor/config.js",
|
||||
# to debug ckeditor, comment the lines above,
|
||||
# do a
|
||||
# cd static/lib
|
||||
# git clone https://github.com/ckeditor/ckeditor-dev.git trunk
|
||||
# cd trunk
|
||||
# git checkout remotes/origin/release/4.1.x
|
||||
# and uncomment the lines below
|
||||
# 'static/lib/trunk/ckeditor.js',
|
||||
# 'static/lib/trunk/core/event.js',
|
||||
# 'static/lib/trunk/core/editor_basic.js',
|
||||
# 'static/lib/trunk/core/env.js',
|
||||
# 'static/lib/trunk/core/ckeditor_basic.js',
|
||||
# 'static/lib/trunk/core/dom.js',
|
||||
# 'static/lib/trunk/core/tools.js',
|
||||
# 'static/lib/trunk/core/dtd.js',
|
||||
# 'static/lib/trunk/core/dom/event.js',
|
||||
# 'static/lib/trunk/core/dom/domobject.js',
|
||||
# 'static/lib/trunk/core/dom/node.js',
|
||||
# 'static/lib/trunk/core/dom/window.js',
|
||||
# 'static/lib/trunk/core/dom/document.js',
|
||||
# 'static/lib/trunk/core/dom/nodelist.js',
|
||||
# 'static/lib/trunk/core/dom/element.js',
|
||||
# 'static/lib/trunk/core/dom/documentfragment.js',
|
||||
# 'static/lib/trunk/core/dom/walker.js',
|
||||
# 'static/lib/trunk/core/dom/range.js',
|
||||
# 'static/lib/trunk/core/dom/iterator.js',
|
||||
# 'static/lib/trunk/core/command.js',
|
||||
# 'static/lib/trunk/core/ckeditor_base.js',
|
||||
# 'static/lib/trunk/core/config.js',
|
||||
# 'static/lib/trunk/core/filter.js',
|
||||
# 'static/lib/trunk/core/focusmanager.js',
|
||||
# 'static/lib/trunk/core/keystrokehandler.js',
|
||||
# 'static/lib/trunk/core/lang.js',
|
||||
# 'static/lib/trunk/core/scriptloader.js',
|
||||
# 'static/lib/trunk/core/resourcemanager.js',
|
||||
# 'static/lib/trunk/core/plugins.js',
|
||||
# 'static/lib/trunk/core/ui.js',
|
||||
# 'static/lib/trunk/core/editor.js',
|
||||
# 'static/lib/trunk/core/htmlparser.js',
|
||||
# 'static/lib/trunk/core/htmlparser/basicwriter.js',
|
||||
# 'static/lib/trunk/core/htmlparser/node.js',
|
||||
# 'static/lib/trunk/core/htmlparser/comment.js',
|
||||
# 'static/lib/trunk/core/htmlparser/text.js',
|
||||
# 'static/lib/trunk/core/htmlparser/cdata.js',
|
||||
# 'static/lib/trunk/core/htmlparser/fragment.js',
|
||||
# 'static/lib/trunk/core/htmlparser/filter.js',
|
||||
# 'static/lib/trunk/core/htmldataprocessor.js',
|
||||
# 'static/lib/trunk/core/htmlparser/element.js',
|
||||
# 'static/lib/trunk/core/template.js',
|
||||
# 'static/lib/trunk/core/ckeditor.js',
|
||||
# 'static/lib/trunk/core/creators/inline.js',
|
||||
# 'static/lib/trunk/core/creators/themedui.js',
|
||||
# 'static/lib/trunk/core/editable.js',
|
||||
# 'static/lib/trunk/core/selection.js',
|
||||
# 'static/lib/trunk/core/style.js',
|
||||
# 'static/lib/trunk/core/dom/comment.js',
|
||||
# 'static/lib/trunk/core/dom/elementpath.js',
|
||||
# 'static/lib/trunk/core/dom/text.js',
|
||||
# 'static/lib/trunk/core/dom/rangelist.js',
|
||||
# 'static/lib/trunk/core/skin.js',
|
||||
# 'static/lib/trunk/core/_bootstrap.js',
|
||||
# end of ckeditor debug
|
||||
"static/src/js/web_ckeditor4.js",
|
||||
],
|
||||
"installable": True,
|
||||
"auto_install": False,
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
|
@ -19,25 +18,26 @@
|
|||
#
|
||||
##############################################################################
|
||||
import re
|
||||
|
||||
from lxml.html import clean
|
||||
from openerp import models
|
||||
|
||||
|
||||
class CkeditorMonkeypatch(models.AbstractModel):
|
||||
_name = 'ckeditor.monkeypatch'
|
||||
_description = 'Monkeypatches for CKEditor'
|
||||
_name = "ckeditor.monkeypatch"
|
||||
_description = "Monkeypatches for CKEditor"
|
||||
|
||||
def _register_hook(self):
|
||||
marker = self._name.replace('.', '_')
|
||||
marker = self._name.replace(".", "_")
|
||||
if not hasattr(clean, marker):
|
||||
# monkey patch lxml's html cleaner to allow image data urls
|
||||
if hasattr(clean, '_is_javascript_scheme'):
|
||||
if hasattr(clean, "_is_javascript_scheme"):
|
||||
# this is the case in lxml >= 3.3
|
||||
_is_javascript_scheme = clean._is_javascript_scheme
|
||||
_is_image_dataurl = re.compile(
|
||||
r'^data:image/.+;base64', re.I).search
|
||||
clean._is_javascript_scheme = lambda s:\
|
||||
None if _is_image_dataurl(s) else _is_javascript_scheme(s)
|
||||
_is_image_dataurl = re.compile(r"^data:image/.+;base64", re.I).search
|
||||
clean._is_javascript_scheme = (
|
||||
lambda s: None if _is_image_dataurl(s) else _is_javascript_scheme(s)
|
||||
)
|
||||
# TODO: do something else for 2.3.1 <= version <= 3.2, before data
|
||||
# urls were not cleaned at all
|
||||
setattr(clean, marker, True)
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
.odoo .oe_form_field_text_ckeditor4.disabled, .odoo td.oe_form_field_text_ckeditor4, .odoo .oe_form_field_text_ckeditor4_raw.disabled.odoo, .odoo td.oe_form_field_text_ckeditor4_raw {
|
||||
.odoo .oe_form_field_text_ckeditor4.disabled,
|
||||
.odoo td.oe_form_field_text_ckeditor4,
|
||||
.odoo .oe_form_field_text_ckeditor4_raw.disabled.odoo,
|
||||
.odoo td.oe_form_field_text_ckeditor4_raw {
|
||||
/* here we need to reset odoo's styles to
|
||||
* have the HTML display as (probably) intended
|
||||
*/
|
||||
|
|
|
@ -1 +1 @@
|
|||
CKEDITOR_BASEPATH='/web_ckeditor4/static/lib/ckeditor/'
|
||||
CKEDITOR_BASEPATH = "/web_ckeditor4/static/lib/ckeditor/";
|
||||
|
|
|
@ -20,43 +20,42 @@
|
|||
#
|
||||
############################################################################*/
|
||||
|
||||
odoo.define('web_ckeditor4', function(require){
|
||||
odoo.define("web_ckeditor4", function (require) {
|
||||
"use strict";
|
||||
var core = require('web.core');
|
||||
var session = require('web.session');
|
||||
var formats = require('web.formats');
|
||||
var ckconfig = require('web_ckeditor4.config');
|
||||
var core = require("web.core");
|
||||
var session = require("web.session");
|
||||
var formats = require("web.formats");
|
||||
var ckconfig = require("web_ckeditor4.config");
|
||||
|
||||
var FieldCKEditor4 = core.form_widget_registry.get('text').extend({
|
||||
var FieldCKEditor4 = core.form_widget_registry.get("text").extend({
|
||||
ckeditor_config: function () {
|
||||
return {
|
||||
removePlugins: this._getRemovePlugins(),
|
||||
removeButtons: this._getRemoveButtons(),
|
||||
filebrowserImageUploadUrl: 'dummy',
|
||||
extraPlugins: 'filebrowser',
|
||||
// this is '#39' per default which screws up single quoted text in ${}
|
||||
entities_additional: ''
|
||||
filebrowserImageUploadUrl: "dummy",
|
||||
extraPlugins: "filebrowser",
|
||||
// This is '#39' per default which screws up single quoted text in ${}
|
||||
entities_additional: "",
|
||||
};
|
||||
},
|
||||
ckeditor_filter: ckconfig.default_ckeditor_filter,
|
||||
ckeditor_writer: ckconfig.default_ckeditor_writer,
|
||||
_getRemovePlugins: function () {
|
||||
return 'iframe,flash,forms,smiley,pagebreak,stylescombo';
|
||||
return "iframe,flash,forms,smiley,pagebreak,stylescombo";
|
||||
},
|
||||
_getRemoveButtons: function () {
|
||||
return '';
|
||||
return "";
|
||||
},
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this.editor_lang = session.user_context.lang.split('_')[0];
|
||||
this.editor_lang = session.user_context.lang.split("_")[0];
|
||||
this.view.on("load_record", this, this._on_load_record);
|
||||
},
|
||||
start: function()
|
||||
{
|
||||
start: function () {
|
||||
this._super.apply(this, arguments);
|
||||
CKEDITOR.lang.load(this.editor_lang, 'en', function() {});
|
||||
CKEDITOR.lang.load(this.editor_lang, "en", function () {});
|
||||
},
|
||||
_on_load_record: function() {
|
||||
_on_load_record: function () {
|
||||
/* Fix widget not re-initialized on form discard.
|
||||
|
||||
When you hit "cancel" button or when you navigate away
|
||||
|
@ -75,22 +74,19 @@ odoo.define('web_ckeditor4', function(require){
|
|||
this.initialize_content();
|
||||
}
|
||||
},
|
||||
initialize_content: function()
|
||||
{
|
||||
initialize_content: function () {
|
||||
var self = this;
|
||||
this._super.apply(this, arguments);
|
||||
if(!this.$el)
|
||||
{
|
||||
if (!this.$el) {
|
||||
return;
|
||||
} else if (!this.get('effective_readonly') && !this.editor) {
|
||||
this.editor = CKEDITOR.replace(this.$el.get(0),
|
||||
} else if (!this.get("effective_readonly") && !this.editor) {
|
||||
this.editor = CKEDITOR.replace(
|
||||
this.$el.get(0),
|
||||
_.extend(
|
||||
{
|
||||
language: this.editor_lang,
|
||||
on:
|
||||
{
|
||||
'change': function()
|
||||
{
|
||||
on: {
|
||||
change: function () {
|
||||
self.store_dom_value();
|
||||
},
|
||||
},
|
||||
|
@ -100,82 +96,72 @@ odoo.define('web_ckeditor4', function(require){
|
|||
);
|
||||
}
|
||||
},
|
||||
store_dom_value: function()
|
||||
{
|
||||
this.internal_set_value(this.editor ? this.editor.getData() : formats.parse_value(this.get('value'), this));
|
||||
store_dom_value: function () {
|
||||
this.internal_set_value(
|
||||
this.editor
|
||||
? this.editor.getData()
|
||||
: formats.parse_value(this.get("value"), this)
|
||||
);
|
||||
},
|
||||
filter_html: function(value)
|
||||
{
|
||||
return ckconfig.filter_html(value, this.ckeditor_filter, this.ckeditor_writer);
|
||||
filter_html: function (value) {
|
||||
return ckconfig.filter_html(
|
||||
value,
|
||||
this.ckeditor_filter,
|
||||
this.ckeditor_writer
|
||||
);
|
||||
},
|
||||
render_value: function()
|
||||
{
|
||||
if(this.get("effective_readonly"))
|
||||
{
|
||||
this.$el.html(this.filter_html(this.get('value')));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.editor)
|
||||
{
|
||||
render_value: function () {
|
||||
if (this.get("effective_readonly")) {
|
||||
this.$el.html(this.filter_html(this.get("value")));
|
||||
} else if (this.editor) {
|
||||
var self = this;
|
||||
if(this.editor.status != 'ready')
|
||||
{
|
||||
var instanceReady = function()
|
||||
{
|
||||
self.editor.setData(self.get('value') || '');
|
||||
self.editor.removeListener('instanceReady', instanceReady);
|
||||
if (this.editor.status != "ready") {
|
||||
var instanceReady = function () {
|
||||
self.editor.setData(self.get("value") || "");
|
||||
self.editor.removeListener("instanceReady", instanceReady);
|
||||
};
|
||||
this.editor.on('instanceReady', instanceReady);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.editor.setData(self.get('value') || '');
|
||||
this.editor.on("instanceReady", instanceReady);
|
||||
} else {
|
||||
self.editor.setData(self.get("value") || "");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
destroy_content: function () {
|
||||
this._cleanup_editor();
|
||||
},
|
||||
undelegateEvents: function()
|
||||
{
|
||||
undelegateEvents: function () {
|
||||
this._cleanup_editor();
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
_cleanup_editor: function()
|
||||
{
|
||||
if(this.editor && this.editor.status == 'ready')
|
||||
{
|
||||
_cleanup_editor: function () {
|
||||
if (this.editor && this.editor.status == "ready") {
|
||||
CKEDITOR.remove(this.editor.name);
|
||||
$('#cke_' + this.editor.name).remove();
|
||||
$("#cke_" + this.editor.name).remove();
|
||||
this.editor.removeAllListeners();
|
||||
this.editor.destroy();
|
||||
this.editor = null;
|
||||
}
|
||||
},
|
||||
destroy: function()
|
||||
{
|
||||
destroy: function () {
|
||||
this.view.off("load_record", this, this._on_load_record);
|
||||
this._cleanup_editor();
|
||||
this._super();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
var FieldCKEditor4Raw = FieldCKEditor4.extend({
|
||||
filter_html: function(value)
|
||||
{
|
||||
filter_html: function (value) {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
core.form_widget_registry.add('text_ckeditor4', FieldCKEditor4);
|
||||
core.form_widget_registry.add('text_ckeditor4_raw', FieldCKEditor4Raw);
|
||||
core.form_widget_registry.add('text_html', FieldCKEditor4);
|
||||
core.form_widget_registry.add('html', FieldCKEditor4);
|
||||
core.form_widget_registry.add("text_ckeditor4", FieldCKEditor4);
|
||||
core.form_widget_registry.add("text_ckeditor4_raw", FieldCKEditor4Raw);
|
||||
core.form_widget_registry.add("text_html", FieldCKEditor4);
|
||||
core.form_widget_registry.add("html", FieldCKEditor4);
|
||||
|
||||
return {
|
||||
'FieldCKEditor4': FieldCKEditor4,
|
||||
'FieldCKEditor4Raw': FieldCKEditor4Raw
|
||||
}
|
||||
FieldCKEditor4: FieldCKEditor4,
|
||||
FieldCKEditor4Raw: FieldCKEditor4Raw,
|
||||
};
|
||||
});
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
#
|
||||
############################################################################*/
|
||||
|
||||
odoo.define('web_ckeditor4.config', function (require) {
|
||||
odoo.define("web_ckeditor4.config", function (require) {
|
||||
"use strict";
|
||||
|
||||
var ckeditor_addFunction_org = CKEDITOR.tools.addFunction;
|
||||
// this is a quite complicated way to kind of monkey patch the private
|
||||
// This is a quite complicated way to kind of monkey patch the private
|
||||
// method onDomReady of ckeditor's plugin wysiwigarea, which causes problems
|
||||
// when the editor is about to be destroyed but because of OpenERP's
|
||||
// architecture updated one last time with its current value
|
||||
|
@ -43,33 +43,39 @@ odoo.define('web_ckeditor4.config', function (require) {
|
|||
return ckeditor_addFunction_org(fn, scope);
|
||||
};
|
||||
|
||||
CKEDITOR.on('dialogDefinition', function (e) {
|
||||
CKEDITOR.on("dialogDefinition", function (e) {
|
||||
_.each(e.data.definition.contents, function (element) {
|
||||
if (!element || element.filebrowser != 'uploadButton') {
|
||||
return
|
||||
if (!element || element.filebrowser != "uploadButton") {
|
||||
return;
|
||||
}
|
||||
_.each(element.elements, function (element) {
|
||||
if (!element.onClick || element.type != 'fileButton') {
|
||||
return
|
||||
if (!element.onClick || element.type != "fileButton") {
|
||||
return;
|
||||
}
|
||||
var onClick_org = element.onClick;
|
||||
element.onClick = function (e1) {
|
||||
onClick_org.apply(this, arguments);
|
||||
_.each($('#' + this.domId).closest('table')
|
||||
.find('iframe').contents().find(':file')
|
||||
.get(0).files,
|
||||
_.each(
|
||||
$("#" + this.domId)
|
||||
.closest("table")
|
||||
.find("iframe")
|
||||
.contents()
|
||||
.find(":file")
|
||||
.get(0).files,
|
||||
function (file) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (load_event) {
|
||||
CKEDITOR.tools.callFunction(
|
||||
e.editor._.filebrowserFn,
|
||||
load_event.target.result,
|
||||
'');
|
||||
}
|
||||
""
|
||||
);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -82,18 +88,17 @@ odoo.define('web_ckeditor4.config', function (require) {
|
|||
};
|
||||
|
||||
var default_ckeditor_filter = new CKEDITOR.filter({
|
||||
'*':
|
||||
{
|
||||
attributes: 'href,src,style,alt,width,height,dir',
|
||||
styles: '*',
|
||||
classes: '*',
|
||||
"*": {
|
||||
attributes: "href,src,style,alt,width,height,dir",
|
||||
styles: "*",
|
||||
classes: "*",
|
||||
},
|
||||
'html head title meta style body p div span a h1 h2 h3 h4 h5 img br hr table tr th td ul ol li dd dt strong pre b i': true,
|
||||
"html head title meta style body p div span a h1 h2 h3 h4 h5 img br hr table tr th td ul ol li dd dt strong pre b i": true,
|
||||
});
|
||||
var default_ckeditor_writer = new CKEDITOR.htmlParser.basicWriter();
|
||||
return {
|
||||
'filter_html': filter_html,
|
||||
'default_ckeditor_filter': default_ckeditor_filter,
|
||||
'default_ckeditor_writer': default_ckeditor_writer
|
||||
}
|
||||
filter_html: filter_html,
|
||||
default_ckeditor_filter: default_ckeditor_filter,
|
||||
default_ckeditor_writer: default_ckeditor_writer,
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,25 +1,22 @@
|
|||
odoo.define('web_ckeditor4.FormView', function(require) {
|
||||
"use strict";
|
||||
odoo.define("web_ckeditor4.FormView", function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var FormView = core.view_registry.get('form');
|
||||
|
||||
FormView.include({
|
||||
|
||||
can_be_discarded: function(message) {
|
||||
var self = this;
|
||||
var res = this._super().done(function() {
|
||||
// if form can be discarded
|
||||
// we want to destroy all ck4 editor instances
|
||||
for(name in CKEDITOR.instances){
|
||||
if (self.fields.hasOwnProperty(name)){
|
||||
self.fields[name].destroy_content();
|
||||
}
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
});
|
||||
var core = require("web.core");
|
||||
var FormView = core.view_registry.get("form");
|
||||
|
||||
FormView.include({
|
||||
can_be_discarded: function (message) {
|
||||
var self = this;
|
||||
var res = this._super().done(function () {
|
||||
// If form can be discarded
|
||||
// we want to destroy all ck4 editor instances
|
||||
for (name in CKEDITOR.instances) {
|
||||
if (self.fields.hasOwnProperty(name)) {
|
||||
self.fields[name].destroy_content();
|
||||
}
|
||||
}
|
||||
});
|
||||
return res;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,20 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<template id="assets_backend" name="web_ckeditor4 assets"
|
||||
inherit_id="web.assets_backend">
|
||||
<template
|
||||
id="assets_backend"
|
||||
name="web_ckeditor4 assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript"
|
||||
src="/web_ckeditor4/static/src/js/ckeditor_basepath.js" />
|
||||
<script type="text/javascript"
|
||||
src="/web_ckeditor4/static/lib/ckeditor/ckeditor.js" />
|
||||
<script type="text/javascript"
|
||||
src="/web_ckeditor4/static/lib/ckeditor/config.js" />
|
||||
<script type="text/javascript"
|
||||
src="/web_ckeditor4/static/src/js/web_ckeditor4_config.js" />
|
||||
<script type="text/javascript"
|
||||
src="/web_ckeditor4/static/src/js/web_ckeditor4_formview.js" />
|
||||
<script type="text/javascript"
|
||||
src="/web_ckeditor4/static/src/js/web_ckeditor4.js" />
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_ckeditor4/static/src/js/ckeditor_basepath.js"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_ckeditor4/static/lib/ckeditor/ckeditor.js"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_ckeditor4/static/lib/ckeditor/config.js"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_ckeditor4/static/src/js/web_ckeditor4_config.js"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_ckeditor4/static/src/js/web_ckeditor4_formview.js"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_ckeditor4/static/src/js/web_ckeditor4.js"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
|
|
Loading…
Reference in New Issue