mirror of https://github.com/OCA/web.git
[IMP] web_widget_text_markdown: black, isort, prettier
parent
5cdb172f17
commit
f1b55aabf5
|
@ -0,0 +1 @@
|
|||
../../../../web_widget_text_markdown
|
|
@ -0,0 +1,6 @@
|
|||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright 2017 Komit - <http:///komit-consulting.com>
|
||||
* Copyright 2019 Alexandre Díaz - <dev@redneboa.es>
|
||||
* 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("<div class='%s'></div>", 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);
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* Copyright 2019 Alexandre Díaz - <dev@redneboa.es>
|
||||
* 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) {
|
|||
"</sheet></form>";
|
||||
},
|
||||
},
|
||||
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();
|
||||
|
|
Loading…
Reference in New Issue