Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
6581 Zobrazení

trying to add my custom markdown editor in odoo9 for text area.

Below is the code for widget_text_markdown.js::

odoo.define('web_widget_text_markdown',function (require) {

var core = require('web.core');

var formats = require('web.formats');

var common = require('web.form_common');

var _lt = oe.web._lt;

//oe.web.form.widgets.add('bootstrap_markdown', 'openerp.web_widget_text_markdown.FieldTextMarkDown');

var FieldTextMarkDown = common.AbstractField.extend(common.ReinitializeFieldMixin, {

template: "FieldMarkDown",

display_name: _lt('MarkDown'),

internal_format: 'field_text',

widget_class: 'oe_form_field_bootstrap_markdown',

events: {

'change input': 'store_dom_value' ,

},

init: function (field_manager, node) {

this._super(field_manager, node);

this.$txt = false;

this.internal_set_value(0);

},

parse_value: function(val, def) {

return formats.parse_value(val, {"widget": this.internal_format}, def);

},

initialize_content: function () {

// Gets called at each redraw of widget

// - switching between read-only mode and edit mode

// - BUT NOT when switching to next object.

if(!this.get("effective_readonly")) {

this.$el.find('input').markdown(this.options);

this.setupFocus(this.$('input'));

}

},

store_dom_value: function () {

if (!this.get('effective_readonly')) {

this.internal_set_value(

this.parse_value(

this.$('input').val(),''));

}

},

commit_value: function () {

this.store_dom_value();

return this._super();

},

_get_raw_value: function() {

if (this.$txt === false)

return '';

return this.$txt.val();

},

render_value: function () {

// Gets called at each redraw/save of widget

// - switching between read-only mode and edit mode

// - when switching to next object.

var show_value = this.format_value(this.get('value'), '');

if (!this.get("effective_readonly")) {

this.$input = this.$el.find('input');

this.$input.val(show_value);

} else {

// avoids loading markitup...

marked.setOptions({

highlight: function (code) {

return hljs.highlightAuto(code).value;

}

});

this.$(".oe_form_text_content").html(marked(show_value));

}

},

format_value: function (val, def) {

return formats.format_value(val, {"widget": this.internal_format}, def);

},

});

core.form_widget_registry.add('bootstrap_markdown', FieldTextMarkDown);

return {

FieldTextMarkDown: FieldTextMarkDown,

};

});


After adding this widget to my field it is showing js error that module failed loading 


Avatar
Zrušit

Geetha, try to debug it from console using "Inspect Element" of your browser and check for the error, that would help you to find out the exact error in your js code..

Related Posts Odpovědi Zobrazení Aktivita
0
zář 23
1999
0
zář 23
1728
2
čvn 25
11238
6
říj 23
22079
3
bře 24
9515