diff --git a/setup/web_widget_text_markdown/odoo/addons/web_widget_text_markdown b/setup/web_widget_text_markdown/odoo/addons/web_widget_text_markdown new file mode 120000 index 000000000..872e5f4ad --- /dev/null +++ b/setup/web_widget_text_markdown/odoo/addons/web_widget_text_markdown @@ -0,0 +1 @@ +../../../../web_widget_text_markdown \ No newline at end of file diff --git a/setup/web_widget_text_markdown/setup.py b/setup/web_widget_text_markdown/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_widget_text_markdown/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_widget_text_markdown/static/src/js/web_widget_text_markdown.js b/web_widget_text_markdown/static/src/js/web_widget_text_markdown.js index 9621d9f73..c80388073 100644 --- a/web_widget_text_markdown/static/src/js/web_widget_text_markdown.js +++ b/web_widget_text_markdown/static/src/js/web_widget_text_markdown.js @@ -3,7 +3,7 @@ * Copyright 2017 Komit - * Copyright 2019 Alexandre Díaz - * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ -odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) { +odoo.define("web_widget_text_markdown.FieldTextMarkDown", function (require) { "use strict"; var basic_fields = require("web.basic_fields"); @@ -31,7 +31,7 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) { CUST_LIBS_PATH + "web_widget_text_markdown.css", ], - _getValue: function() { + _getValue: function () { var $widget = this.attrs.widget; var $type = this.field.type; if ($type === "html" && $widget && $widget === "bootstrap_markdown") { @@ -40,7 +40,7 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) { return this.$markdown.getContent(); }, - start: function() { + start: function () { this._super(); this.shw_render_html = new showdown.Converter({ extensions: ["table", "footnotes", "toc"], @@ -78,10 +78,10 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) { }); }, - _prepareInput: function() { + _prepareInput: function () { var $input = this._super.apply(this, arguments); _.defer( - function($elm) { + function ($elm) { $input.removeClass(this.className); $input.wrap( _.str.sprintf("
", this.className) @@ -94,15 +94,15 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) { ); return $input; }, - _getHtmlValue: function(value) { + _getHtmlValue: function (value) { return this.shw_render_html.makeHtml(this._formatValue(value)); }, - _renderReadonly: function() { + _renderReadonly: function () { this.$el.html(this._getHtmlValue(this.value)); }, - _getMarkdownOptions: function() { + _getMarkdownOptions: function () { var self = this; var markdownOpts = { iconlibrary: "fa", @@ -110,7 +110,7 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) { width: "o_field_text_markdown", savable: false, language: this.getSession().user_context.lang, - onPreview: function(e) { + onPreview: function (e) { var render_val = self._getHtmlValue(e.getContent()); return render_val; }, @@ -137,7 +137,7 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) { return markdownOpts; }, - _markdownTranslate: function() { + _markdownTranslate: function () { // Event is the click event from callback this._onTranslate(event); }, diff --git a/web_widget_text_markdown/static/tests/js/web_widget_text_markdown.js b/web_widget_text_markdown/static/tests/js/web_widget_text_markdown.js index 3a7072408..798b290d3 100644 --- a/web_widget_text_markdown/static/tests/js/web_widget_text_markdown.js +++ b/web_widget_text_markdown/static/tests/js/web_widget_text_markdown.js @@ -2,7 +2,7 @@ /* Copyright 2019 Alexandre Díaz - * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ -odoo.define("web_widget_text_markdown.test", function(require) { +odoo.define("web_widget_text_markdown.test", function (require) { "use strict"; var FormView = require("web.FormView"); @@ -13,7 +13,7 @@ odoo.define("web_widget_text_markdown.test", function(require) { QUnit.module( "web_widget_text_markdown", { - beforeEach: function() { + beforeEach: function () { this.data = { partner: { fields: {comment: {string: "Comment", type: "text"}}, @@ -27,11 +27,11 @@ odoo.define("web_widget_text_markdown.test", function(require) { ""; }, }, - function() { + function () { QUnit.module("FieldTextMarkDown"); QUnit.test( "bootstrap markdown widget are correctly rendered (preview)", - function(assert) { + function (assert) { assert.expect(1); var done = assert.async(); @@ -42,8 +42,8 @@ odoo.define("web_widget_text_markdown.test", function(require) { data: this.data, arch: this.arch, res_id: 1, - }).then(function(form) { - _.defer(function() { + }).then(function (form) { + _.defer(function () { assert.strictEqual(form.$(".md-editor").length, 0); form.destroy(); done(); @@ -53,7 +53,7 @@ odoo.define("web_widget_text_markdown.test", function(require) { ); QUnit.test( "bootstrap markdown widget are correctly rendered (edit)", - function(assert) { + function (assert) { assert.expect(1); var done = assert.async(); @@ -65,8 +65,8 @@ odoo.define("web_widget_text_markdown.test", function(require) { arch: this.arch, res_id: 1, viewOptions: {mode: "edit"}, - }).then(function(form) { - _.defer(function() { + }).then(function (form) { + _.defer(function () { assert.strictEqual(form.$(".md-editor").length, 1); form.destroy(); done();